Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add image pull policy #1462

Merged
merged 10 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
11 changes: 11 additions & 0 deletions pkg/runfileconfig/run_file_config_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
"gopkg.in/yaml.v2"
)

var imagePullPolicyValuesAllowed = []string{"Always", "Never", "IfNotPresent"}

// Parse the provided run file into a RunFileConfig struct.
func (a *RunFileConfig) parseAppsConfig(runFilePath string) error {
var err error
Expand Down Expand Up @@ -97,6 +99,15 @@
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

Check failure on line 103 in pkg/runfileconfig/run_file_config_parser.go

View workflow job for this annotation

GitHub Actions / Build linux_amd64 binaries

Comment should end in a period (godot)
if a.Apps[i].ContainerImagePullPolicy != "" {
if !utils.Contains(imagePullPolicyValuesAllowed, a.Apps[i].ContainerImagePullPolicy) {
return fmt.Errorf("invalid containerImagePullPolicy: %s, allowed values: %s", a.Apps[i].ContainerImagePullPolicy, strings.Join(imagePullPolicyValuesAllowed, ", "))
}
} else {
a.Apps[i].ContainerImagePullPolicy = "Always"
}
}
return nil
}
Expand Down
Loading