diff --git a/entrypoint/entrypoint.go b/entrypoint/entrypoint.go index 5bacbdb..eb60cd7 100644 --- a/entrypoint/entrypoint.go +++ b/entrypoint/entrypoint.go @@ -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 + DependencyPrefix = "DEPENDENCY_" + 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()) diff --git a/kubernetes-entrypoint.go b/kubernetes-entrypoint.go index c645299..7647986 100644 --- a/kubernetes-entrypoint.go +++ b/kubernetes-entrypoint.go @@ -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)