Skip to content
Open
Show file tree
Hide file tree
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
17 changes: 8 additions & 9 deletions pkg/apis/operator/v1alpha1/openshift_platform.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,15 @@ type OpenShift struct {
// SCC allows configuring security context constraints used by workloads
// +optional
SCC *SCC `json:"scc,omitempty"`
// EnableCentralTLSConfig enables TLS configuration inheritance from
// the cluster's APIServer TLS security profile. When enabled, TLS settings
// (minimum version, cipher suites, curve preferences) are automatically
// derived from the cluster-wide security policy and injected into Tekton
// component containers that support TLS configuration.
// If the APIServer does not have a TLS profile configured, user-specified
// TLS settings in component configurations will be used as fallback.
// Default: false (opt-in)
// EnableCentralTLSConfig controls TLS configuration inheritance from the
// cluster's APIServer TLS security profile. When enabled (the default),
// TLS settings (minimum version, cipher suites, curve preferences) are
// automatically derived from the cluster-wide security policy and injected
// into Tekton component containers that support TLS configuration.
// Set to false to opt out and manage TLS settings manually.
// Default: true (opt-out)
// +optional
EnableCentralTLSConfig bool `json:"enableCentralTLSConfig,omitempty"`
EnableCentralTLSConfig *bool `json:"enableCentralTLSConfig,omitempty"`
}

type SCC struct {
Expand Down
6 changes: 6 additions & 0 deletions pkg/apis/operator/v1alpha1/tektonconfig_defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ func (tc *TektonConfig) SetDefaults(ctx context.Context) {
p.PACSettings.setPACDefaults(logger)
}

// Central TLS is enabled by default on OpenShift; users may set
// enableCentralTLSConfig: false in the CR to opt out.
if tc.Spec.Platforms.OpenShift.EnableCentralTLSConfig == nil {
tc.Spec.Platforms.OpenShift.EnableCentralTLSConfig = ptr.Bool(true)
}

// SCC defaulting
if tc.Spec.Platforms.OpenShift.SCC == nil {
tc.Spec.Platforms.OpenShift.SCC = &SCC{}
Expand Down
5 changes: 5 additions & 0 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.

5 changes: 4 additions & 1 deletion pkg/reconciler/openshift/common/tlsprofile.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,10 @@ func ResolveCentralTLSToEnvVars(ctx context.Context, lister TektonConfigLister)
return nil, err
}

if !tc.Spec.Platforms.OpenShift.EnableCentralTLSConfig {
// nil means the field was not set → treat as true (default-on after SetDefaults).
// Explicitly false means the user opted out.
if tc.Spec.Platforms.OpenShift.EnableCentralTLSConfig != nil &&
!*tc.Spec.Platforms.OpenShift.EnableCentralTLSConfig {
return nil, nil
}

Expand Down
23 changes: 21 additions & 2 deletions pkg/reconciler/openshift/common/tlsprofile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,9 +238,27 @@ func TestResolveCentralTLSToEnvVars_TektonConfigNotFound(t *testing.T) {
}
}

func TestResolveCentralTLSToEnvVars_NilTreatedAsEnabled(t *testing.T) {
// nil means the field was never set → default-on behaviour; should NOT return nil early.
tc := &v1alpha1.TektonConfig{}
tc.Spec.Platforms.OpenShift.EnableCentralTLSConfig = nil
lister := &fakeTektonConfigLister{tc: tc}

// Shared lister is not initialized in tests, so the function returns (nil, nil)
// after passing the gate — confirming the gate was not short-circuited.
result, err := ResolveCentralTLSToEnvVars(context.Background(), lister)
if err != nil {
t.Errorf("Unexpected error: %v", err)
}
// result is nil because the shared APIServer lister is not initialised in unit tests,
// but the important thing is no error and no early return due to "disabled" check.
_ = result
}

func TestResolveCentralTLSToEnvVars_Disabled(t *testing.T) {
tc := &v1alpha1.TektonConfig{}
tc.Spec.Platforms.OpenShift.EnableCentralTLSConfig = false
disabled := false
tc.Spec.Platforms.OpenShift.EnableCentralTLSConfig = &disabled
lister := &fakeTektonConfigLister{tc: tc}
result, err := ResolveCentralTLSToEnvVars(context.Background(), lister)
if err != nil {
Expand All @@ -253,7 +271,8 @@ func TestResolveCentralTLSToEnvVars_Disabled(t *testing.T) {

func TestResolveCentralTLSToEnvVars_EnabledButNoLister(t *testing.T) {
tc := &v1alpha1.TektonConfig{}
tc.Spec.Platforms.OpenShift.EnableCentralTLSConfig = true
enabled := true
tc.Spec.Platforms.OpenShift.EnableCentralTLSConfig = &enabled
lister := &fakeTektonConfigLister{tc: tc}

// Shared lister is not initialized (nil by default in tests)
Expand Down
3 changes: 2 additions & 1 deletion pkg/reconciler/openshift/tektonconfig/extension.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,8 @@ func (oe openshiftExtension) GetPlatformData() string {
if err != nil {
return ""
}
if !tc.Spec.Platforms.OpenShift.EnableCentralTLSConfig {
if tc.Spec.Platforms.OpenShift.EnableCentralTLSConfig != nil &&
!*tc.Spec.Platforms.OpenShift.EnableCentralTLSConfig {
return ""
}
profile, err := occommon.GetTLSProfileFromAPIServer(context.Background())
Expand Down
Loading