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

bugfix: empty securityContext breaks console process with nil #1736

Merged
merged 1 commit into from
Aug 22, 2023
Merged
Changes from all 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
15 changes: 12 additions & 3 deletions api/tenants_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,20 @@ func convertModelSCToK8sSC(sc *models.SecurityContext) (*corev1.PodSecurityConte

// convertK8sSCToModelSC validates and converts from corev1.PodSecurityContext to models.SecurityContext
func convertK8sSCToModelSC(sc *corev1.PodSecurityContext) *models.SecurityContext {
runAsUser := strconv.FormatInt(*sc.RunAsUser, 10)
runAsGroup := strconv.FormatInt(*sc.RunAsGroup, 10)
fsGroup := strconv.FormatInt(*sc.FSGroup, 10)
var runAsUser string
var runAsGroup string
var fsGroup string
fsGroupChangePolicy := "Always"

if sc.RunAsUser != nil && *sc.RunAsUser != 0 {
runAsUser = strconv.FormatInt(*sc.RunAsUser, 10)
}
if sc.RunAsGroup != nil && *sc.RunAsGroup != 0 {
runAsGroup = strconv.FormatInt(*sc.RunAsGroup, 10)
}
if sc.FSGroup != nil && *sc.FSGroup != 0 {
fsGroup = strconv.FormatInt(*sc.FSGroup, 10)
}
if sc.FSGroupChangePolicy != nil {
fsGroupChangePolicy = string(*sc.FSGroupChangePolicy)
}
Expand Down
Loading