Skip to content

Commit

Permalink
bugfix: empty securityContext breaks console process with nil (#1736)
Browse files Browse the repository at this point in the history
Signed-off-by: pjuarezd <pjuarezd@users.noreply.github.com>
  • Loading branch information
pjuarezd committed Aug 22, 2023
1 parent 1542ad5 commit 619699e
Showing 1 changed file with 12 additions and 3 deletions.
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

0 comments on commit 619699e

Please sign in to comment.