Skip to content

Commit

Permalink
add image pull policy
Browse files Browse the repository at this point in the history
Signed-off-by: Filinto Duran <[email protected]>
  • Loading branch information
filintod committed Nov 12, 2024
1 parent 6d5e64d commit 448ecae
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pkg/kubernetes/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
},
},
},
Expand Down
5 changes: 3 additions & 2 deletions pkg/runfileconfig/run_file_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
9 changes: 9 additions & 0 deletions pkg/runfileconfig/run_file_config_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 448ecae

Please sign in to comment.