From 448ecaeb28fb4c87b40cc7171786c2e639013d2d Mon Sep 17 00:00:00 2001 From: Filinto Duran Date: Tue, 12 Nov 2024 12:38:24 -0600 Subject: [PATCH] add image pull policy Signed-off-by: Filinto Duran --- pkg/kubernetes/run.go | 2 +- pkg/runfileconfig/run_file_config.go | 5 +++-- pkg/runfileconfig/run_file_config_parser.go | 9 +++++++++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/pkg/kubernetes/run.go b/pkg/kubernetes/run.go index 6a7199d64..b8869916e 100644 --- a/pkg/kubernetes/run.go +++ b/pkg/kubernetes/run.go @@ -297,7 +297,7 @@ func createDeploymentConfig(client versioned.Interface, app runfileconfig.App) d Name: app.AppID, Image: app.ContainerImage, Env: getEnv(app), - ImagePullPolicy: corev1.PullAlways, + ImagePullPolicy: corev1.PullPolicy(app.ContainerImagePullPolicy), }, }, }, diff --git a/pkg/runfileconfig/run_file_config.go b/pkg/runfileconfig/run_file_config.go index 50f17a977..575237600 100644 --- a/pkg/runfileconfig/run_file_config.go +++ b/pkg/runfileconfig/run_file_config.go @@ -41,8 +41,9 @@ type RunFileConfig struct { // ContainerConfiguration represents the application container configuration parameters. type ContainerConfiguration struct { - ContainerImage string `yaml:"containerImage"` - CreateService bool `yaml:"createService"` + ContainerImage string `yaml:"containerImage"` + ContainerImagePullPolicy string `yaml:"containerImagePullPolicy"` + CreateService bool `yaml:"createService"` } // App represents the configuration options for the apps in the run file. diff --git a/pkg/runfileconfig/run_file_config_parser.go b/pkg/runfileconfig/run_file_config_parser.go index 207bfd2fa..8a2c0a941 100644 --- a/pkg/runfileconfig/run_file_config_parser.go +++ b/pkg/runfileconfig/run_file_config_parser.go @@ -97,6 +97,15 @@ func (a *RunFileConfig) validateRunConfig(runFilePath string) error { if len(strings.TrimSpace(a.Apps[i].ResourcesPath)) > 0 { a.Apps[i].ResourcesPaths = append(a.Apps[i].ResourcesPaths, a.Apps[i].ResourcesPath) } + + // Check containerImagePullPolicy is valid + if a.Apps[i].ContainerImagePullPolicy != "" { + if a.Apps[i].ContainerImagePullPolicy != "Always" && a.Apps[i].ContainerImagePullPolicy != "Never" && a.Apps[i].ContainerImagePullPolicy != "IfNotPresent" { + return fmt.Errorf("invalid containerImagePullPolicy: %s", a.Apps[i].ContainerImagePullPolicy) + } + } else { + a.Apps[i].ContainerImagePullPolicy = "Always" + } } return nil }