Skip to content

Commit

Permalink
Add function to clear the runAsGroup and runAsUser values in the defa…
Browse files Browse the repository at this point in the history
…ult cm for triggers
  • Loading branch information
savitaashture committed Jul 8, 2024
1 parent 2d1f579 commit 5286871
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ seLinuxContext:
type: MustRunAs
supplementalGroups:
type: RunAsAny
seccompProfiles:
- runtime/default
volumes:
- configMap
- downwardAPI
Expand Down
8 changes: 8 additions & 0 deletions pkg/apis/operator/v1alpha1/tektontrigger_defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"context"

"github.com/tektoncd/triggers/pkg/apis/config"
"knative.dev/pkg/ptr"
)

var (
Expand All @@ -46,4 +47,11 @@ func (t *Trigger) openshiftDefaulting() {
if t.DefaultServiceAccount == "" {
t.DefaultServiceAccount = DefaultOpenshiftSA
}

if t.DefaultRunAsUser == nil {
t.DefaultRunAsUser = ptr.String("")
}
if t.DefaultRunAsGroup == nil {
t.DefaultRunAsGroup = ptr.String("")
}
}
4 changes: 3 additions & 1 deletion pkg/apis/operator/v1alpha1/tektontrigger_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,5 +92,7 @@ type TriggersProperties struct {
// OptionalTriggersProperties defines the fields which are to be
// defined for triggers only if user pass them
type OptionalTriggersProperties struct {
DefaultServiceAccount string `json:"default-service-account,omitempty"`
DefaultServiceAccount string `json:"default-service-account,omitempty"`
DefaultRunAsUser *string `json:"default-run-as-user,omitempty"`
DefaultRunAsGroup *string `json:"default-run-as-group,omitempty"`
}
14 changes: 12 additions & 2 deletions pkg/apis/operator/v1alpha1/zz_generated.deepcopy.go

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

3 changes: 1 addition & 2 deletions pkg/reconciler/openshift/tektontrigger/transformers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,12 @@ func TestReplaceImages(t *testing.T) {
}

newManifest, err := manifest.Transform(
replaceDeploymentArgs("-el-security-context", "false"),
replaceDeploymentArgs("-el-events", "enable"),
)
if err != nil {
t.Errorf("assertion failed; expected no error %v", err)
}
assertDeployContainerArgsValue(t, newManifest.Resources(), "-el-security-context", "false")
assertDeployContainerArgsValue(t, newManifest.Resources(), "-el-security-context", "true")
assertDeployContainerArgsValue(t, newManifest.Resources(), "-el-events", "enable")
})
}
Expand Down

0 comments on commit 5286871

Please sign in to comment.