Skip to content

Commit d4367f3

Browse files
committed
Automatically pull templater images if they do not exist.
1 parent 9144423 commit d4367f3

File tree

3 files changed

+27
-2
lines changed

3 files changed

+27
-2
lines changed

commands/deploy.go

+25
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,22 @@ func clearYamlsFromDir(folderOut string) error {
3131
return nil
3232
}
3333

34+
func pullImageIfNotExists(image string) error {
35+
cmd := exec.Command("docker", "inspect", image)
36+
if cmd.Run() == nil {
37+
return nil //already exists
38+
}
39+
fmt.Println("Pulling the templater image "+image+"...")
40+
cmd = exec.Command(
41+
"docker",
42+
"pull",
43+
image,
44+
)
45+
cmd.Stdout = os.Stdout
46+
cmd.Stderr = os.Stderr
47+
return cmd.Run()
48+
}
49+
3450
func runTemplater(folderIn, folderOut, templaterImage, namespace string) error {
3551
if namespace == "" {
3652
namespace = "<ERROR_NAMESPACE_NOT_DEFINED_IN_THIS_ENV>"
@@ -67,6 +83,15 @@ func runTemplater(folderIn, folderOut, templaterImage, namespace string) error {
6783
}
6884
defer os.RemoveAll(tempFolderOut)
6985

86+
if !strings.Contains(templaterImage, ":") {
87+
templaterImage = templaterImage+":latest"
88+
}
89+
90+
err = pullImageIfNotExists(templaterImage)
91+
if err != nil {
92+
return fmt.Errorf("could not pull the templater image %s: %s", templaterImage, err)
93+
}
94+
7095
cmd := exec.Command(
7196
"docker",
7297
"run",

example/timestamp-as-a-service/sanic.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ environments:
1616
kubeConfig: ~/.kube/sanic.io.config
1717
deploy:
1818
folder: "deploy"
19-
templaterImage: "sanic/templater-golang:latest"
19+
templaterImage: "distributedcontainers/templater-golang:latest"

main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ func main() {
2222

2323
app.EnableBashCompletion = true
2424

25-
app.Version = "v1.2.7"
25+
app.Version = "v1.2.8"
2626
app.Usage = "build & deploy kubernetes monorepos"
2727

2828
err := app.Run(os.Args)

0 commit comments

Comments
 (0)