Change 'interval' to something more meaningful

This commit is contained in:
Antoni Rościszewski 2017-01-31 09:40:14 +01:00
parent 259b4d8d25
commit 23aff4b2c8
2 changed files with 9 additions and 7 deletions

View File

@ -1,19 +1,20 @@
package entrypoint
import (
cli "github.com/stackanetes/kubernetes-entrypoint/client"
"github.com/stackanetes/kubernetes-entrypoint/logger"
"k8s.io/client-go/rest"
"os"
"sync"
"time"
cli "github.com/stackanetes/kubernetes-entrypoint/client"
"github.com/stackanetes/kubernetes-entrypoint/logger"
"k8s.io/client-go/rest"
)
var dependencies []Resolver // List containing all dependencies to be resolved
const (
//DependencyPrefix is a prefix for env variables
DependencyPrefix = "DEPENDENCY_"
interval = 2
resolverSleepInterval = 2
)
//Resolver is an interface which all dependencies should implement
@ -79,7 +80,7 @@ func (e Entrypoint) Resolve() {
if status, err = dep.IsResolved(e); err != nil {
logger.Warning.Printf("Resolving dependency for %v failed: %v", dep.GetName(), err)
}
time.Sleep(interval * time.Second)
time.Sleep(resolverSleepInterval * time.Second)
}
logger.Info.Printf("Dependency %v is resolved", dep.GetName())

View File

@ -27,6 +27,7 @@ func main() {
logger.Error.Printf("Creating entrypoint failed: %v", err)
os.Exit(1)
}
entrypoint.Resolve()
if comm = env.SplitEnvToList("COMMAND", " "); len(comm) == 0 {
@ -34,8 +35,8 @@ func main() {
// is an init-container
logger.Warning.Printf("COMMAND env is empty")
os.Exit(0)
}
if err = command.Execute(comm); err != nil {
logger.Error.Printf("Cannot execute command: %v", err)
os.Exit(1)