-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Baptiste Noleau
committed
Sep 5, 2024
1 parent
4212891
commit 540abae
Showing
5 changed files
with
87 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
{{/* | ||
Copyright Broadcom, Inc. All Rights Reserved. | ||
SPDX-License-Identifier: APACHE-2.0 | ||
*/}} | ||
|
||
{{/* vim: set filetype=mustache: */}} | ||
|
||
{{/* | ||
Return true if the detected platform is Openshift | ||
Usage: | ||
{{- include "common.compatibility.isOpenshift" . -}} | ||
*/}} | ||
{{- define "common.compatibility.isOpenshift" -}} | ||
{{- if .Capabilities.APIVersions.Has "security.openshift.io/v1" -}} | ||
{{- true -}} | ||
{{- end -}} | ||
{{- end -}} | ||
|
||
{{/* | ||
Render a compatible securityContext depending on the platform. By default it is maintained as it is. In other platforms like Openshift we remove default user/group values that do not work out of the box with the restricted-v1 SCC | ||
Usage: | ||
{{- include "common.compatibility.renderSecurityContext" (dict "secContext" .Values.containerSecurityContext "context" $) -}} | ||
*/}} | ||
{{- define "common.compatibility.renderSecurityContext" -}} | ||
{{- $adaptedContext := .secContext -}} | ||
|
||
{{- if (((.context.Values.global).compatibility).openshift) -}} | ||
{{- if or (eq .context.Values.global.compatibility.openshift.adaptSecurityContext "force") (and (eq .context.Values.global.compatibility.openshift.adaptSecurityContext "auto") (include "common.compatibility.isOpenshift" .context)) -}} | ||
{{/* Remove incompatible user/group values that do not work in Openshift out of the box */}} | ||
{{- $adaptedContext = omit $adaptedContext "fsGroup" "runAsUser" "runAsGroup" -}} | ||
{{- if not .secContext.seLinuxOptions -}} | ||
{{/* If it is an empty object, we remove it from the resulting context because it causes validation issues */}} | ||
{{- $adaptedContext = omit $adaptedContext "seLinuxOptions" -}} | ||
{{- end -}} | ||
{{- end -}} | ||
{{- end -}} | ||
{{/* Remove fields that are disregarded when running the container in privileged mode */}} | ||
{{- if $adaptedContext.privileged -}} | ||
{{- $adaptedContext = omit $adaptedContext "capabilities" "seLinuxOptions" -}} | ||
{{- end -}} | ||
{{- omit $adaptedContext "enabled" | toYaml -}} | ||
{{- end -}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters