Skip to content

Commit

Permalink
Made recommended changes!
Browse files Browse the repository at this point in the history
  • Loading branch information
Auston-Ivison-Suse committed Aug 30, 2023
1 parent 526f1f0 commit f4a9a0f
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 17 deletions.
1 change: 0 additions & 1 deletion pkg/apis/upgrade.cattle.io/v1/types.go
Expand Up @@ -67,7 +67,6 @@ type ContainerSpec struct {
EnvFrom []corev1.EnvFromSource `json:"envFrom,omitempty"`
Volumes []VolumeSpec `json:"volumes,omitempty"`
SecurityContext *corev1.SecurityContext `json:"securityContext,omitempty"`
SELinuxOptions *corev1.SELinuxOptions `json:"seLinuxOptions,omitempty"`
}

type VolumeSpec struct {
Expand Down
5 changes: 0 additions & 5 deletions pkg/apis/upgrade.cattle.io/v1/zz_generated_deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 0 additions & 6 deletions pkg/upgrade/container/container.go
Expand Up @@ -37,12 +37,6 @@ func WithSecurityContext(securityContext *corev1.SecurityContext) Option {
}
}

func WithSELinuxOptions(seLinuxoptions *corev1.SELinuxOptions) Option {
return func(container *corev1.Container) {
container.SecurityContext.SELinuxOptions = seLinuxoptions
}
}

func WithImagePullPolicy(pullPolicy corev1.PullPolicy) Option {
return func(container *corev1.Container) {
container.ImagePullPolicy = pullPolicy
Expand Down
8 changes: 3 additions & 5 deletions pkg/upgrade/job/job.go
Expand Up @@ -245,6 +245,7 @@ func New(plan *upgradeapiv1.Plan, node *corev1.Node, controllerName string) *bat
upgradectr.WithPlanEnvironment(plan.Name, plan.Status),
upgradectr.WithImagePullPolicy(ImagePullPolicy),
upgradectr.WithVolumes(plan.Spec.Upgrade.Volumes),
upgradectr.WithSecurityContext(plan.Spec.Upgrade.SecurityContext),
),
)
}
Expand Down Expand Up @@ -332,18 +333,15 @@ func New(plan *upgradeapiv1.Plan, node *corev1.Node, controllerName string) *bat
securityContext = plan.Spec.Upgrade.SecurityContext
}

// Check if SELinuxOptions from the Plan is non-nil
seLinuxOptions := &corev1.SELinuxOptions{}
if plan.Spec.Upgrade.SELinuxOptions != nil {
seLinuxOptions = plan.Spec.Upgrade.SELinuxOptions
if plan.Spec.Upgrade.SecurityContext.SELinuxOptions != nil {
securityContext.SELinuxOptions = plan.Spec.Upgrade.SecurityContext.SELinuxOptions
}

// and finally, we upgrade
podTemplate.Spec.Containers = []corev1.Container{
upgradectr.New("upgrade", *plan.Spec.Upgrade,
upgradectr.WithLatestTag(plan.Status.LatestVersion),
upgradectr.WithSecurityContext(securityContext),
upgradectr.WithSELinuxOptions(seLinuxOptions),
upgradectr.WithSecrets(plan.Spec.Secrets),
upgradectr.WithPlanEnvironment(plan.Name, plan.Status),
upgradectr.WithImagePullPolicy(ImagePullPolicy),
Expand Down

0 comments on commit f4a9a0f

Please sign in to comment.