Skip to content

Commit

Permalink
Apply TargetNamespace to Dashboard contaner args
Browse files Browse the repository at this point in the history
  • Loading branch information
aThorp96 committed Jan 28, 2025
1 parent 97819ea commit 221d438
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
10 changes: 5 additions & 5 deletions pkg/reconciler/common/transformers.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const (
HubImagePrefix = "IMAGE_HUB_"
DashboardImagePrefix = "IMAGE_DASHBOARD_"

DefaultPipelinesNamespace = "tekton-pipelines"
DefaultTargetNamespace = "tekton-pipelines"

ArgPrefix = "arg_"
ParamPrefix = "param_"
Expand Down Expand Up @@ -471,7 +471,7 @@ func injectNamespaceClusterRole(targetNamespace string) mf.Transformer {
if containsNamespaceResource && ok {
nm := []interface{}{}
for _, rn := range resourceNames.([]interface{}) {
if rn.(string) == DefaultPipelinesNamespace {
if rn.(string) == DefaultTargetNamespace {
nm = append(nm, targetNamespace)
} else {
nm = append(nm, rn)
Expand Down Expand Up @@ -515,7 +515,7 @@ func replaceNamespaceInDBAddress(envs []corev1.EnvVar, targetNamespace string) [

for i, e := range envs {
if slices.Contains(req, e.Name) {
envs[i].Value = strings.ReplaceAll(e.Value, DefaultPipelinesNamespace, targetNamespace)
envs[i].Value = strings.ReplaceAll(e.Value, DefaultTargetNamespace, targetNamespace)
}
}
return envs
Expand Down Expand Up @@ -549,8 +549,8 @@ func ReplaceNamespaceInDeploymentArgs(deploymentNames []string, targetNamespace

func replaceNamespaceInContainerArg(container *corev1.Container, targetNamespace string) {
for i, a := range container.Args {
if strings.Contains(a, DefaultPipelinesNamespace) {
container.Args[i] = strings.ReplaceAll(a, DefaultPipelinesNamespace, targetNamespace)
if strings.Contains(a, DefaultTargetNamespace) {
container.Args[i] = strings.ReplaceAll(a, DefaultTargetNamespace, targetNamespace)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -404,15 +404,15 @@ spec:
app.kubernetes.io/name: dashboard
app.kubernetes.io/part-of: tekton-dashboard
app.kubernetes.io/version: v0.48.0
operator.tekton.dev/deployment-spec-applied-hash: 0d7e625dccc2efab4493c409bdc71e88
operator.tekton.dev/deployment-spec-applied-hash: e521024acd6c6a280dc53fb4de0a6725
name: tekton-dashboard
spec:
containers:
- args:
- --port=9097
- --logout-url=
- --pipelines-namespace=tekton-pipelines
- --triggers-namespace=tekton-pipelines
- --pipelines-namespace=foo-ns
- --triggers-namespace=foo-ns
- --read-only=false
- --log-level=info
- --log-format=json
Expand Down
5 changes: 4 additions & 1 deletion pkg/reconciler/kubernetes/tektondashboard/transform.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ const (
func filterAndTransform(extension common.Extension) client.FilterAndTransform {
return func(ctx context.Context, manifest *mf.Manifest, comp v1alpha1.TektonComponent) (*mf.Manifest, error) {
dashboard := comp.(*v1alpha1.TektonDashboard)
targetNamespace := dashboard.Spec.GetTargetNamespace()


images := common.ToLowerCaseKeys(common.ImagesFromEnv(common.DashboardImagePrefix))

Expand All @@ -42,6 +44,7 @@ func filterAndTransform(extension common.Extension) client.FilterAndTransform {
common.AddConfiguration(dashboard.Spec.Config),
common.AddDeploymentRestrictedPSA(),
common.DeploymentImages(images),
common.ReplaceNamespaceInDeploymentArgs([]string{dashboardDeploymentName}, targetNamespace),
}
trns = append(trns, extra...)
if dashboard.Spec.ExternalLogs != "" {
Expand All @@ -54,7 +57,7 @@ func filterAndTransform(extension common.Extension) client.FilterAndTransform {

// additional options transformer
// always execute as last transformer, so that the values in options will be final update values on the manifests
if err := common.ExecuteAdditionalOptionsTransformer(ctx, manifest, dashboard.Spec.GetTargetNamespace(), dashboard.Spec.Dashboard.Options); err != nil {
if err := common.ExecuteAdditionalOptionsTransformer(ctx, manifest, targetNamespace, dashboard.Spec.Dashboard.Options); err != nil {
return &mf.Manifest{}, err
}

Expand Down

0 comments on commit 221d438

Please sign in to comment.