Skip to content

Conversation

@rm3l
Copy link
Member

@rm3l rm3l commented Jan 2, 2026

Description

Bumps the version of the operator-sdk, which requires updating the linter configuration (and fixing the issues reported).

Which issue(s) does this PR fix or relate to

PR acceptance criteria

  • Tests
  • Documentation

How to test changes / Special notes to the reviewer

@openshift-ci
Copy link

openshift-ci bot commented Jan 2, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign rm3l for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@sonarqubecloud
Copy link

sonarqubecloud bot commented Jan 2, 2026

@rhdh-qodo-merge
Copy link

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis 🔶

RHIDP-11243 - Partially compliant

Compliant requirements:

  • Fix issues reported as a result of the upgrade (e.g., scaffolding/formatting/markers adjustments)

Non-compliant requirements:

  • Upgrade the Operator SDK version used by the RHDH Operator.
  • Update Kubebuilder layout if needed to match the upgraded Operator SDK.

Requires further human verification:

  • Confirm operator-sdk and controller-runtime/kubebuilder versions were actually bumped (e.g., go.mod, generated manifests, tooling).
  • Confirm the Kubebuilder layout/scaffolding changes match the official upgrade guidance and the project still scaffolds/builds correctly.
  • Run the full test/lint pipeline to ensure no regressions after the upgrade.
⏱️ Estimated effort to review: 4 🔵🔵🔵🔵⚪
🔒 No security concerns identified
⚡ Recommended focus areas for review

TLS Misconfig

The metrics server options are initialized with TLSOpts: webhookTLSOpts, which couples metrics TLS settings to webhook certificate configuration. This is likely unintended (metrics should use its own TLS opts and its own cert watcher when configured), and it can produce surprising behavior when only webhook cert flags are set.

var metricsCertWatcher, webhookCertWatcher *certwatcher.CertWatcher
webhookTLSOpts := tlsOpts

if len(webhookCertPath) > 0 {
	setupLog.Info("Initializing webhook certificate watcher using provided certificates",
		"webhook-cert-path", webhookCertPath, "webhook-cert-name", webhookCertName, "webhook-cert-key", webhookCertKey)

	var err error
	webhookCertWatcher, err = certwatcher.New(
		filepath.Join(webhookCertPath, webhookCertName),
		filepath.Join(webhookCertPath, webhookCertKey),
	)
	if err != nil {
		setupLog.Error(err, "Failed to initialize webhook certificate watcher")
		os.Exit(1)
	}

	webhookTLSOpts = append(webhookTLSOpts, func(config *tls.Config) {
		config.GetCertificate = webhookCertWatcher.GetCertificate
	})
}

// Metrics endpoint is enabled in 'config/default/kustomization.yaml'. The Metrics options configure the server.
// More info:
// - https://pkg.go.dev/sigs.k8s.io/[email protected]/pkg/metrics/server
// - https://book.kubebuilder.io/reference/metrics.html
metricsServerOptions := metricsserver.Options{
	BindAddress:   metricsAddr,
	SecureServing: secureMetrics,
	// TODO(user): TLSOpts is used to allow configuring the TLS config used for the server. If certificates are
	// not provided, self-signed certificates will be generated by default. This option is not recommended for
	// production environments as self-signed certificates do not offer the same level of trust and security
	// as certificates issued by a trusted Certificate Authority (CA). The primary risk is potentially allowing
	// unauthorized access to sensitive metrics data. Consider replacing with CertDir, CertName, and KeyName
	// to provide certificates, ensuring the server communicates using trusted and secure certificates.
	TLSOpts: webhookTLSOpts,
}
if secureMetrics {
	// FilterProvider is used to protect the metrics endpoint with authn/authz.
	// These configurations ensure that only authorized users and service accounts
	// can access the metrics endpoint. The RBAC are configured in 'config/rbac/kustomization.yaml'. More info:
	// https://pkg.go.dev/sigs.k8s.io/[email protected]/pkg/metrics/filters#WithAuthenticationAndAuthorization
	metricsServerOptions.FilterProvider = filters.WithAuthenticationAndAuthorization
}

webhookServer := webhook.NewServer(webhook.Options{
	TLSOpts: tlsOpts,
})

if len(metricsCertPath) > 0 {
	setupLog.Info("Initializing metrics certificate watcher using provided certificates",
		"metrics-cert-path", metricsCertPath, "metrics-cert-name", metricsCertName, "metrics-cert-key", metricsCertKey)

	var err error
	metricsCertWatcher, err = certwatcher.New(
		filepath.Join(metricsCertPath, metricsCertName),
		filepath.Join(metricsCertPath, metricsCertKey),
	)
	if err != nil {
		setupLog.Error(err, "Failed to initialize metrics certificate watcher")
		os.Exit(1)
	}

	metricsServerOptions.TLSOpts = append(metricsServerOptions.TLSOpts, func(config *tls.Config) {
		config.GetCertificate = metricsCertWatcher.GetCertificate
	})
}

mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
	Scheme:                 scheme,
	Metrics:                metricsServerOptions,
	WebhookServer:          webhookServer,
📚 Focus areas based on broader codebase context

Compile Error

checkMountWSubpath now declares its first parameter as _ Gomega but the function body still calls g.Expect(...), which will not compile because g is undefined. Rename the parameter back to g Gomega (or update the body to not reference g) and ensure the helper is invoked accordingly. (Ref 6, Ref 8)

func checkMountWSubpath(
	_ Gomega,
	ctx context.Context,
	k8sClient client.Client,
	bs bsv1.BackstageSpec,
	ns, backstageName, conf string,
) {

	createAndReconcileBackstage(ctx, ns, bs, backstageName)

	Eventually(func(g Gomega) {
		deploy, err := backstageDeployment(ctx, k8sClient, ns, backstageName)
		g.Expect(err).ShouldNot(HaveOccurred())

		podList := &corev1.PodList{}
		err = k8sClient.List(ctx, podList, client.InNamespace(ns),
			client.MatchingLabels{model.BackstageAppLabel: utils.BackstageAppLabelValue(backstageName)})
		g.Expect(err).ShouldNot(HaveOccurred())

		g.Expect(podList.Items).To(HaveLen(1))
		podName := podList.Items[0].Name
		out, _, err := executeRemoteCommand(ctx, ns, podName, backstageContainer(*deploy.PodSpec()).Name,
			"cat /my/mount/path/appconfig11")
		g.Expect(err).ShouldNot(HaveOccurred())
		out = strings.ReplaceAll(out, "\r", "")
		g.Expect(out).To(Equal(conf))

		out, _, err = executeRemoteCommand(ctx, ns, podName, backstageContainer(*deploy.PodSpec()).Name,
			"echo $sec11")
		g.Expect(err).ShouldNot(HaveOccurred())
		g.Expect("val11\r\n").To(Equal(out))

Reference reasoning: Existing integration tests consistently pass a named g Gomega into Eventually(func(g Gomega) { ... }) and use g.Expect(...) within the scope. Keeping the parameter named aligns with the established Ginkgo/Gomega pattern and avoids undefined identifier errors.

📄 References
  1. redhat-developer/rhdh-operator/tests/e2e/e2e_suite_test.go [93-112]
  2. redhat-developer/rhdh-operator/tests/e2e/e2e_test.go [1-58]
  3. redhat-developer/rhdh-operator/tests/e2e/e2e_upgrade_test.go [79-92]
  4. redhat-developer/rhdh-operator/tests/e2e/e2e_upgrade_test.go [1-29]
  5. redhat-developer/rhdh-operator/integration_tests/cr-compatibility_test.go [1-35]
  6. redhat-developer/rhdh-operator/integration_tests/default-config_test.go [1-44]
  7. redhat-developer/rhdh-operator/integration_tests/rhdh-config_test.go [1-21]
  8. redhat-developer/rhdh-operator/integration_tests/rhdh-config_test.go [147-172]

@rhdh-qodo-merge
Copy link

PR Type

Enhancement, Bug fix


Description

  • Upgraded operator-sdk from v1.37.0 to v1.42.0 and updated related dependencies (controller-runtime, ginkgo, gomega)

  • Updated tool versions including OPM, controller-tools, goimports, gosec, and ginkgo

  • Implemented certificate watcher support for secure metrics and webhook servers with TLS configuration

  • Restructured and enhanced .golangci.yml linter configuration with explicit linter selection and improved rules

  • Fixed linter violations across the codebase including comment formatting, line length compliance, and import organization

  • Refactored test code to remove redundant parameters, extract constants, and improve assertion patterns

  • Added envtest binary directory discovery with getFirstFoundEnvTestBinaryDir() helper function

  • Updated CRD generation with kubebuilder v0.18.0 and simplified condition descriptions

  • Added GitHub Actions workflow for linter configuration validation

  • Fixed parameter naming to avoid package shadowing in pkg/model/runtime.go

  • Added comprehensive security documentation for Prometheus metrics monitoring

  • Created new configuration patches for metrics server certificate management


File Walkthrough

Relevant files
Formatting
58 files
dynamic-plugins_test.go
Code cleanup and linter compliance fixes in dynamic plugins tests

pkg/model/dynamic-plugins_test.go

  • Added constant dplugin to replace hardcoded string literals throughout
    the test file
  • Removed boolean parameter from withDefaultConfig() method calls
    (changed from withDefaultConfig(true) to withDefaultConfig())
  • Fixed comment formatting by adding space after // for consistency with
    linter rules
  • Split long assertion lines to improve code readability and comply with
    line length limits
+60/-51 
config-refresh_test.go
Test refactoring with constant extraction and assertion improvements

integration_tests/config-refresh_test.go

  • Moved conf constant definition to package level instead of defining it
    inside test functions
  • Removed boolean parameter from withDefaultConfig() method calls
  • Fixed comment formatting by adding space after //
  • Split long function calls and assertions across multiple lines for
    better readability
  • Improved error message handling in assertions with additional context
  • Changed len(podList.Items) to HaveLen(1) matcher for better Gomega
    assertion style
+43/-37 
secretfiles_test.go
Test code formatting and method call cleanup                         

pkg/model/secretfiles_test.go

  • Removed boolean parameter from withDefaultConfig() method calls
  • Split long method chains and function calls across multiple lines
  • Improved code formatting for better readability
+27/-16 
deployment_test.go
Deployment tests cleanup with constant extraction and formatting

pkg/model/deployment_test.go

  • Added constant statefulSet to replace hardcoded string literal
    "StatefulSet"
  • Removed boolean parameter from withDefaultConfig() method calls
  • Fixed comment formatting by adding space after //
  • Split long assertions across multiple lines for improved readability
  • Extracted intermediate variable for better code clarity in assertions
+25/-22 
cr-config_test.go
Integration test formatting improvements                                 

integration_tests/cr-config_test.go

  • Split long function calls across multiple lines for better readability
  • Improved code formatting to comply with line length limits
+36/-20 
configmapfiles_test.go
ConfigMap files test formatting and method call cleanup   

pkg/model/configmapfiles_test.go

  • Removed boolean parameter from withDefaultConfig() method calls
  • Split long method chains and assignments across multiple lines
  • Improved code formatting for better readability
+22/-13 
deployment.go
Deployment code comment and formatting fixes                         

pkg/model/deployment.go

  • Fixed comment formatting by adding space after // and splitting long
    comments
  • Split long error messages and function signatures across multiple
    lines
  • Improved code readability with better line wrapping
+27/-15 
helper_backstage.go
Helper functions formatting and comment fixes                       

tests/helper/helper_backstage.go

  • Fixed comment formatting by adding space after //
  • Split long function calls and error messages across multiple lines
  • Improved code readability with better line wrapping
+21/-9   
backstage_types.go
API v1alpha4 kubebuilder annotation formatting fixes         

api/v1alpha4/backstage_types.go

  • Fixed kubebuilder annotation formatting by adding space after //
    (changed //+kubebuilder to // +kubebuilder)
  • Applied consistent comment formatting throughout the file
+11/-11 
db-statefulset_test.go
Database StatefulSet test cleanup and formatting                 

pkg/model/db-statefulset_test.go

  • Removed boolean parameter from withDefaultConfig() method calls
  • Fixed comment formatting by adding space after // in commented-out
    code blocks
+36/-36 
pvcs_test.go
PVCs integration test formatting improvements                       

integration_tests/pvcs_test.go

  • Fixed comment formatting by adding space after //
  • Split long function calls across multiple lines for better readability
  • Extracted intermediate variable for improved code clarity
+13/-8   
route_test.go
Route tests cleanup and formatting improvements                   

pkg/model/route_test.go

  • Removed boolean parameter from withDefaultConfig() method calls
  • Fixed comment formatting by adding space after //
  • Split long assertions and variable assignments across multiple lines
  • Improved code readability with better line wrapping
+15/-15 
backstage_controller.go
Controller RBAC annotations and naming improvements           

internal/controller/backstage_controller.go

  • Fixed kubebuilder RBAC annotation formatting by adding space after //
    (changed //+kubebuilder to // +kubebuilder)
  • Fixed typo in comment: "reconsiled" changed to "reconsider"
  • Added .Named("backstage") to controller builder for better naming
  • Fixed comment formatting in cleanup logic
+14/-13 
backstage_types.go
API v1alpha5 kubebuilder annotation formatting fixes         

api/v1alpha5/backstage_types.go

  • Fixed kubebuilder annotation formatting by adding space after //
    (changed //+kubebuilder to // +kubebuilder)
  • Applied consistent comment formatting throughout the file
+11/-11 
db_test.go
Database integration tests assertion and formatting improvements

integration_tests/db_test.go

  • Extracted types.NamespacedName into intermediate variables for
    improved readability
  • Changed error assertions from g.Expect(errors.IsNotFound(err)) to
    g.Expect(errors.IsNotFound(err)).To(BeTrue()) for proper Gomega
    assertion style
  • Improved code formatting with better line wrapping
+23/-11 
backstage_types.go
API v1alpha3 kubebuilder annotation formatting fixes         

api/v1alpha3/backstage_types.go

  • Fixed kubebuilder annotation formatting by adding space after //
    (changed //+kubebuilder to // +kubebuilder)
  • Applied consistent comment formatting throughout the file
+11/-11 
configmapenvs_test.go
ConfigMap envs test refactoring with code deduplication   

pkg/model/configmapenvs_test.go

  • Removed boolean parameter from withDefaultConfig() method calls
  • Refactored TestSpecifiedCMEnvsWithContainers to use shared helper
    function doCheckSpecifiedEnvsWithContainers to reduce code duplication
  • Improved code organization and maintainability
+31/-18 
secretenvs_test.go
Secret envs test refactoring with code deduplication         

pkg/model/secretenvs_test.go

  • Removed boolean parameter from withDefaultConfig() method calls
  • Refactored TestSpecifiedSecretEnvsWithContainers to use shared helper
    function doCheckSpecifiedEnvsWithContainers from configmapenvs_test.go
  • Reduced code duplication by consolidating similar test logic
+6/-60   
rhdh-config_test.go
RHDH config integration test formatting and assertion improvements

integration_tests/rhdh-config_test.go

  • Extracted types.NamespacedName into intermediate variables for
    improved readability
  • Fixed comment formatting by adding space after //
  • Changed len(deploy.PodSpec().InitContainers) to HaveLen(1) matcher for
    better Gomega assertion style
  • Improved function call formatting with better line wrapping
+11/-5   
e2e_suite_test.go
Code formatting and helper function extraction                     

tests/e2e/e2e_suite_test.go

  • Reformatted long exec.Command() calls to split across multiple lines
    for better readability
  • Fixed comment spacing by adding space after // in TODO comments
  • Extracted isEnvEnabled() helper function to reduce code duplication
    for environment variable checks
  • Reformatted long method chains to split across multiple lines
+20/-10 
runtime_test.go
Comment formatting and test simplification                             

pkg/model/runtime_test.go

  • Fixed comment formatting by adding space after // for multi-line
    comments
  • Removed boolean parameter from withDefaultConfig() calls, simplifying
    test setup
+16/-16 
dynamic-plugins.go
Comment formatting and line wrapping                                         

pkg/model/dynamic-plugins.go

  • Fixed comment formatting by adding space after // for multi-line
    comments
  • Reformatted long method calls to split across multiple lines for
    readability
+24/-18 
utils.go
Import organization and code readability improvements       

integration_tests/utils.go

  • Reorganized imports to follow Go conventions
  • Reformatted function signatures to split parameters across multiple
    lines
  • Extracted complex expressions into intermediate variables for clarity
+18/-6   
pvcs_test.go
Test simplification and readability improvements                 

pkg/model/pvcs_test.go

  • Removed boolean parameter from withDefaultConfig() calls
  • Extracted long expressions into intermediate variables for better
    readability
  • Reformatted method chains to split across multiple lines
+12/-7   
e2e_upgrade_test.go
Code formatting and comment improvements                                 

tests/e2e/e2e_upgrade_test.go

  • Reformatted long method chains to split across multiple lines
  • Fixed comment formatting and improved multi-line comment clarity
  • Removed redundant variable shadowing in test setup
+12/-8   
pvcs.go
Code formatting and readability improvements                         

pkg/model/pvcs.go

  • Reformatted long conditional statements to split across multiple lines
  • Reformatted function calls with multiple parameters to split across
    lines
  • Extracted annotation values into intermediate variables for clarity
  • Fixed comment formatting with proper spacing
+22/-7   
e2e_test.go
Variable shadowing removal and code formatting                     

tests/e2e/e2e_test.go

  • Removed redundant variable shadowing (tt := tt)
  • Reformatted long string concatenations to split across multiple lines
  • Improved lambda function signatures by using underscore for unused
    parameters
  • Reformatted long function calls to split across multiple lines
+11/-7   
watchers.go
Comment formatting fixes                                                                 

internal/controller/watchers.go

  • Fixed comment formatting by adding space after //
+8/-8     
utils.go
Comment cleanup and formatting improvements                           

pkg/utils/utils.go

  • Removed commented-out import statements
  • Fixed comment formatting with proper spacing and line wrapping
  • Added nolint directive for long lines in commented code
  • Extracted long error message into multiple lines
+10/-12 
db-statefulset.go
Code formatting and cleanup                                                           

pkg/model/db-statefulset.go

  • Reformatted long error messages to split across multiple lines
  • Removed commented-out EmptyObject() method implementation
  • Fixed comment formatting with proper spacing
  • Reformatted GenerateLabel() calls to split across multiple lines
+10/-12 
default-config_test.go
Test assertion improvements and variable extraction           

integration_tests/default-config_test.go

  • Changed assertion from len(secret.Data) to HaveLen(5) for better
    readability
  • Extracted NamespacedName creation into intermediate variables for
    clarity
+10/-4   
monitor_test.go
Test function simplification                                                         

internal/controller/monitor_test.go

  • Simplified createTestBackstage() function by removing unused
    parameters and hardcoding values
+7/-7     
db-secret_test.go
Test simplification and formatting                                             

pkg/model/db-secret_test.go

  • Removed boolean parameter from withDefaultConfig() calls
  • Reformatted method chains to split across multiple lines
  • Fixed comment formatting with proper spacing
+9/-6     
appconfig_test.go
Test simplification and formatting                                             

pkg/model/appconfig_test.go

  • Removed boolean parameter from withDefaultConfig() calls
  • Reformatted long assertions to split across multiple lines
+5/-4     
appconfig.go
Linter directives and code formatting                                       

pkg/model/appconfig.go

  • Added nolint:unparam directive for interface implementation
  • Reformatted function calls to split across multiple lines
  • Fixed comment formatting with proper spacing
+10/-7   
spec_preprocessor.go
Linter directives and comment formatting                                 

internal/controller/spec_preprocessor.go

  • Added nolint:gocyclo directive to acknowledge high cyclomatic
    complexity
  • Fixed comment formatting with proper spacing
+4/-3     
utils_test.go
Comment formatting improvements                                                   

pkg/utils/utils_test.go

  • Fixed comment formatting with proper spacing and line wrapping
+8/-6     
backstage_status.go
Import organization and linter directives                               

internal/controller/backstage_status.go

  • Reorganized imports to follow Go conventions
  • Added nolint:unparam directive for function parameter
  • Fixed comment formatting with proper spacing
+5/-3     
secretfiles.go
Code formatting and readability improvements                         

pkg/model/secretfiles.go

  • Reformatted function calls to split across multiple lines
  • Extracted annotation values into intermediate variables for clarity
  • Fixed comment formatting with proper spacing
+8/-6     
route_test.go
Variable shadowing removal and formatting                               

integration_tests/route_test.go

  • Removed redundant variable shadowing (tt := tt)
  • Fixed comment formatting with proper spacing
  • Extracted NamespacedName creation into intermediate variables
+5/-4     
configmapenvs.go
Code formatting and readability improvements                         

pkg/model/configmapenvs.go

  • Reformatted function calls to split across multiple lines
  • Extracted annotation values into intermediate variables for clarity
  • Fixed comment formatting with proper spacing
+8/-6     
configmapfiles.go
Code formatting and readability improvements                         

pkg/model/configmapfiles.go

  • Reformatted function calls to split across multiple lines
  • Extracted annotation values into intermediate variables for clarity
  • Fixed comment formatting with proper spacing
+8/-5     
secretenvs.go
Code formatting and readability improvements                         

pkg/model/secretenvs.go

  • Reformatted function calls to split across multiple lines
  • Extracted annotation values into intermediate variables for clarity
  • Fixed comment formatting with proper spacing
+8/-5     
model_tests.go
Test helper simplification and comment formatting               

pkg/model/model_tests.go

  • Removed boolean parameter from withDefaultConfig() function, always
    using default config
  • Fixed comment formatting with proper spacing and line wrapping
+11/-9   
route.go
Comment formatting improvements                                                   

pkg/model/route.go

  • Fixed comment formatting with proper spacing
  • Reformatted long comments to split across multiple lines
+8/-6     
deployable_finder.go
Comment formatting fixes                                                                 

internal/controller/deployable_finder.go

  • Fixed comment formatting by adding space after //
+3/-3     
service.go
Code formatting and comment improvements                                 

pkg/model/service.go

  • Reformatted long error messages to split across multiple lines
  • Fixed comment formatting with proper spacing
+5/-4     
db-service.go
Code formatting and comment improvements                                 

pkg/model/db-service.go

  • Reformatted long error messages to split across multiple lines
  • Fixed comment formatting with proper spacing
+5/-4     
plugin_deps.go
Code formatting improvements                                                         

pkg/model/plugin_deps.go

  • Reformatted function signature to split across multiple lines
  • Fixed comment formatting with proper spacing
+4/-2     
matchers.go
Code formatting improvements                                                         

integration_tests/matchers.go

  • Reformatted long string concatenation to split across multiple lines
+2/-1     
containers-filter.go
Comment formatting improvements                                                   

pkg/model/containers-filter.go

  • Fixed comment formatting with proper spacing and line wrapping
+2/-1     
db-secret.go
Comment formatting fixes                                                                 

pkg/model/db-secret.go

  • Fixed comment formatting with proper spacing
+3/-3     
zz_generated.deepcopy.go
Import alias consistency fix                                                         

api/v1alpha3/zz_generated.deepcopy.go

  • Changed import style from
    "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" to v1
    "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" for
    consistency
+1/-1     
zz_generated.deepcopy.go
Import alias consistency fix                                                         

api/v1alpha4/zz_generated.deepcopy.go

  • Changed import style from
    "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" to v1
    "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" for
    consistency
+1/-1     
zz_generated.deepcopy.go
Import alias consistency fix                                                         

api/v1alpha5/zz_generated.deepcopy.go

  • Changed import style from
    "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" to v1
    "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" for
    consistency
+1/-1     
utils.go
Function signature formatting                                                       

tests/helper/utils.go

  • Reformatted StartPortForward() function signature to split parameters
    across multiple lines
+6/-1     
mock_client.go
Comment formatting fixes                                                                 

internal/controller/mock_client.go

  • Fixed comment formatting by adding space after //
+1/-1     
deployable.go
Comment formatting fixes                                                                 

pkg/model/deployable.go

  • Fixed comment formatting by adding space after //
+1/-1     
Enhancement
2 files
main.go
Add certificate watcher support for secure metrics and webhook servers

cmd/main.go

  • Added imports for path/filepath and certwatcher for certificate
    management
  • Added new command-line flags for webhook and metrics certificate
    configuration
  • Implemented certificate watcher initialization for both webhook and
    metrics servers
  • Updated metrics server options with TLS configuration and added
    detailed comments
  • Added certificate watchers to the manager for automatic certificate
    reloading
  • Changed default metrics binding address from :8080 to 0 with updated
    documentation
+94/-12 
suite_test.go
Envtest configuration and binary directory discovery         

integration_tests/suite_test.go

  • Fixed comment formatting by adding space after //
  • Added BinaryAssetsDirectory configuration to envtest.Environment
  • Reformatted CRDDirectoryPaths array to split across multiple lines
  • Added new getFirstFoundEnvTestBinaryDir() helper function to
    dynamically locate envtest binaries
+24/-5   
Bug fix
2 files
runtime.go
Import organization and parameter naming fixes                     

pkg/model/runtime.go

  • Reorganized imports to follow Go conventions (standard library, then
    external packages)
  • Reformatted InitObjects() function signature to split across multiple
    lines
  • Renamed platform parameter to plt to avoid shadowing the imported
    package name
  • Improved error handling by separating variable assignment from
    conditional checks
  • Fixed comment formatting with proper spacing
+27/-14 
plugin-deps_test.go
Function parameter consistency fix                                             

integration_tests/plugin-deps_test.go

  • Changed nil parameters to empty maps map[string]string{} in
    generateConfigMap() call for consistency
+1/-1     
Dependencies
2 files
go.mod
Dependency version upgrades                                                           

go.mod

  • Updated github.com/onsi/ginkgo/v2 from v2.22.2 to v2.27.3
  • Updated github.com/onsi/gomega from v1.36.2 to v1.38.3
  • Updated sigs.k8s.io/controller-runtime from v0.19.4 to v0.21.0
  • Updated multiple indirect dependencies for compatibility with newer
    versions
+32/-27 
go.sum
Go module dependencies upgrade for operator-sdk compatibility

go.sum

  • Updated multiple Go module dependencies to newer versions
  • Added new dependencies: cel.dev/expr,
    github.com/Masterminds/semver/v3, and several testing/utility packages
  • Updated key packages like google/cel-go (v0.20.1 → v0.23.2),
    onsi/ginkgo/v2 (v2.22.2 → v2.27.3), prometheus/client_golang (v1.19.1
    → v1.22.0)
  • Updated OpenTelemetry packages and gRPC dependencies to newer versions
+85/-55 
Configuration changes
17 files
Makefile
Operator SDK and tool version upgrades                                     

Makefile

  • Updated OPERATOR_SDK_VERSION from v1.37.0 to v1.42.0
  • Updated OPM_VERSION from v1.23.0 to v1.55.0
  • Removed hardcoded ENVTEST_K8S_VERSION and made it dynamic based on
    k8s.io/api version
  • Updated tool versions for CONTROLLER_TOOLS_VERSION, GOIMPORTS_VERSION,
    GOSEC_VERSION, and GINKGO_VERSION
  • Changed tool binary naming to use symlinks instead of version suffixes
  • Added setup-envtest target for proper envtest binary setup
  • Added lint-config target to verify golangci-lint configuration
  • Updated gosec command to exclude generated files
  • Fixed regex pattern in PKGS variable to properly exclude v1alpha
    versions
+54/-37 
install.yaml
CRD generation and operator configuration updates               

dist/backstage.io/install.yaml

  • Updated controller-gen version annotation from v0.14.0 to v0.18.0
  • Simplified CRD condition descriptions by removing verbose
    documentation
  • Reordered operator manager arguments (moved --metrics-bind-address
    after --leader-elect)
+11/-51 
backstage-operator.clusterserviceversion.yaml
Bundle metadata and operator configuration updates             

bundle/rhdh/manifests/backstage-operator.clusterserviceversion.yaml

  • Updated createdAt timestamp
  • Updated operators.operatorframework.io/builder from
    operator-sdk-v1.37.0 to operator-sdk-v1.42.0
  • Reordered operator manager arguments (moved --metrics-bind-address
    after --leader-elect)
+3/-4     
.golangci.yml
Comprehensive golangci-lint configuration overhaul             

.golangci.yml

  • Completely restructured linter configuration with explicit linter
    selection
  • Enabled multiple linters including copyloopvar, dupl, errcheck,
    ginkgolinter, goconst, gocyclo, govet, ineffassign, lll, misspell,
    nakedret, prealloc, revive, staticcheck, unconvert, unparam, unused
  • Added revive rule configuration for comment spacing and import
    shadowing
  • Added formatter configuration for gofmt and goimports
  • Improved exclusion rules for test files and API paths
+47/-3   
backstage-operator.clusterserviceversion.yaml
Bundle metadata and operator configuration updates             

bundle/backstage.io/manifests/backstage-operator.clusterserviceversion.yaml

  • Updated createdAt timestamp
  • Updated operators.operatorframework.io/builder from
    operator-sdk-v1.37.0 to operator-sdk-v1.42.0
  • Reordered operator manager arguments (moved --metrics-bind-address
    after --leader-elect)
+3/-4     
install.yaml
Update kubebuilder version and simplify CRD documentation

dist/rhdh/install.yaml

  • Updated controller-gen.kubebuilder.io/version annotation from v0.14.0
    to v0.18.0
  • Simplified CRD condition descriptions by removing verbose multi-line
    documentation
  • Reordered manager container arguments (moved --metrics-bind-address
    and removed --metrics-secure flag)
+11/-51 
rhdh.redhat.com_backstages.yaml
Update kubebuilder version and simplify CRD descriptions 

config/crd/bases/rhdh.redhat.com_backstages.yaml

  • Updated controller-gen.kubebuilder.io/version annotation from v0.14.0
    to v0.18.0
  • Simplified condition type descriptions in CRD schema by removing
    verbose documentation strings
+10/-49 
rhdh.redhat.com_backstages.yaml
Update kubebuilder version and simplify CRD documentation

bundle/backstage.io/manifests/rhdh.redhat.com_backstages.yaml

  • Updated controller-gen.kubebuilder.io/version annotation from v0.14.0
    to v0.18.0
  • Simplified condition descriptions in CRD schema
+10/-49 
rhdh.redhat.com_backstages.yaml
Update kubebuilder version and simplify CRD documentation

bundle/rhdh/manifests/rhdh.redhat.com_backstages.yaml

  • Updated controller-gen.kubebuilder.io/version annotation from v0.14.0
    to v0.18.0
  • Simplified condition descriptions in CRD schema
+10/-49 
kustomization.yaml
Expand kustomization with optional webhook and metrics configurations

config/manager/kustomization.yaml

  • Added extensive commented-out sections for webhook, cert-manager,
    prometheus, and network policy configurations
  • Added metrics_service.yaml resource reference
  • Added patches section with manager_metrics_patch.yaml for HTTPS
    metrics endpoint
  • Included detailed comments explaining optional features and their
    prerequisites
+208/-0 
cert_metrics_manager_patch.yaml
Add metrics server certificate configuration patch             

config/manager/cert_metrics_manager_patch.yaml

  • New file providing JSON patch operations for metrics server
    certificate configuration
  • Adds volume mount for metrics certificates at
    /tmp/k8s-metrics-server/metrics-certs
  • Adds --metrics-cert-path argument to manager container
  • Configures secret-based volume for certificate files (ca.crt, tls.crt,
    tls.key)
+30/-0   
lint-config-checks.yaml
Add GitHub Actions workflow for linter configuration validation

.github/workflows/lint-config-checks.yaml

  • New GitHub Actions workflow for linting configuration checks
  • Triggers on changes to .golangci.yml and workflow file itself
  • Runs on push to main and pull requests
  • Sets up Go environment and executes make lint-config target
+27/-0   
annotations.yaml
Update operator-sdk version in bundle metadata                     

bundle/rhdh/metadata/annotations.yaml

  • Updated operators.operatorframework.io.metrics.builder from
    operator-sdk-v1.37.0 to operator-sdk-v1.42.0
+1/-1     
annotations.yaml
Update operator-sdk version in bundle metadata                     

bundle/backstage.io/metadata/annotations.yaml

  • Updated operators.operatorframework.io.metrics.builder from
    operator-sdk-v1.37.0 to operator-sdk-v1.42.0
+1/-1     
bundle.Dockerfile
Update operator-sdk version in Dockerfile label                   

bundle/rhdh/bundle.Dockerfile

  • Updated operators.operatorframework.io.metrics.builder label from
    operator-sdk-v1.37.0 to operator-sdk-v1.42.0
+1/-1     
bundle.Dockerfile
Update operator-sdk version in Dockerfile label                   

bundle/backstage.io/bundle.Dockerfile

  • Updated operators.operatorframework.io.metrics.builder label from
    operator-sdk-v1.37.0 to operator-sdk-v1.42.0
+1/-1     
manager_metrics_patch.yaml
Add HTTPS metrics endpoint configuration patch                     

config/manager/manager_metrics_patch.yaml

  • New file providing JSON patch operation to add HTTPS metrics endpoint
    configuration
  • Adds --metrics-bind-address=:8443 argument to manager container for
    secure metrics exposure
+4/-0     
Documentation
1 files
monitor.yaml
Add security documentation for Prometheus metrics monitoring

config/prometheus/monitor.yaml

  • Updated port reference comment to clarify HTTPS metrics endpoint
  • Added comprehensive security warning about insecureSkipVerify: true
  • Added commented-out secure configuration options for certificate-based
    TLS
+10/-1   
Additional files
4 files
kustomization.yaml +0/-6     
deployment.yaml +0/-2     
metrics_service.yaml [link]   
kustomization.yaml +0/-2     

@rhdh-qodo-merge
Copy link

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Possible issue
Fix incorrect TLS options for webhook

To ensure the webhook server uses the correct TLS certificates, initialize it
with webhookTLSOpts instead of the base tlsOpts.

cmd/main.go [152-154]

 	webhookServer := webhook.NewServer(webhook.Options{
-		TLSOpts: tlsOpts,
+		TLSOpts: webhookTLSOpts,
 	})
  • Apply / Chat
Suggestion importance[1-10]: 9

__

Why: The suggestion correctly identifies a bug where the webhook server is not using the configured TLS options with the certificate watcher, which would prevent it from using user-provided certificates.

High
Fix incorrect path in install macro

Fix the go-install-tool macro in the Makefile by correcting the source path in
the mv command to use the actual location of the installed binary.

Makefile [537-547]

 define go-install-tool
 @[ -f "$(1)-$(3)" ] || { \
 set -e; \
 package=$(2)@$(3) ;\
 echo "Downloading $${package}" ;\
 rm -f $(1) || true ;\
 GOBIN=$(LOCALBIN) go install $${package} ;\
-mv $(1) $(1)-$(3) ;\
+mv "$(LOCALBIN)/$(notdir $(2))" "$(1)-$(3)" ;\
 } ;\
-ln -sf $(1)-$(3) $(1)
+ln -sf "$(1)-$(3)" "$(1)"
 endef
  • Apply / Chat
Suggestion importance[1-10]: 9

__

Why: The suggestion correctly identifies a critical bug in the go-install-tool macro where the mv command uses an incorrect source path, which would cause the tool installation to fail.

High
Remove contradictory dependency replacement

Remove the replace directive for sigs.k8s.io/controller-runtime in go.mod as it
contradicts the version specified in the require block and prevents the
dependency upgrade.

go.mod [22-140]

 	sigs.k8s.io/controller-runtime v0.21.0
 ...
 replace (
 	k8s.io/api => k8s.io/api v0.31.3
 	k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.31.3
 	k8s.io/apimachinery => k8s.io/apimachinery v0.31.3
 	k8s.io/apiserver => k8s.io/apiserver v0.31.3
 	k8s.io/cli-runtime => k8s.io/cli-runtime v0.31.3
 	k8s.io/client-go => k8s.io/client-go v0.31.3
 	k8s.io/component-base => k8s.io/component-base v0.31.3
 	k8s.io/kube-openapi => k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340
-	sigs.k8s.io/controller-runtime => sigs.k8s.io/controller-runtime v0.19.4
 	sigs.k8s.io/yaml => sigs.k8s.io/yaml v1.4.0
 )

[To ensure code accuracy, apply this suggestion manually]

Suggestion importance[1-10]: 8

__

Why: The suggestion correctly identifies a contradictory replace directive that prevents the intended upgrade of sigs.k8s.io/controller-runtime, which could lead to build or runtime issues.

Medium
Fail fast on test setup error

Modify getFirstFoundEnvTestBinaryDir to panic if it fails to read the directory,
ensuring the test setup fails fast with a clear error message.

integration_tests/suite_test.go [142-155]

 func getFirstFoundEnvTestBinaryDir() string {
 	basePath := filepath.Join("..", "bin", "k8s")
 	entries, err := os.ReadDir(basePath)
 	if err != nil {
-		logf.Log.Error(err, "Failed to read directory", "path", basePath)
-		return ""
+		// If we can't read the directory, it's a setup problem. Let's fail fast.
+		panic(fmt.Sprintf("failed to read envtest binary directory at %s: %v", basePath, err))
 	}
 	for _, entry := range entries {
 		if entry.IsDir() {
 			return filepath.Join(basePath, entry.Name())
 		}
 	}
 	return ""
 }
  • Apply / Chat
Suggestion importance[1-10]: 6

__

Why: The suggestion correctly proposes to fail fast on a test setup error by using panic, which improves test suite robustness and makes debugging setup issues easier.

Low
General
Decouple metrics and webhook TLS configurations

Decouple the metrics server's TLS configuration from the webhook's by
initializing metricsServerOptions.TLSOpts with the base tlsOpts instead of
webhookTLSOpts.

cmd/main.go [133-143]

 	metricsServerOptions := metricsserver.Options{
 		BindAddress:   metricsAddr,
 		SecureServing: secureMetrics,
 		// TODO(user): TLSOpts is used to allow configuring the TLS config used for the server. If certificates are
 		// not provided, self-signed certificates will be generated by default. This option is not recommended for
 		// production environments as self-signed certificates do not offer the same level of trust and security
 		// as certificates issued by a trusted Certificate Authority (CA). The primary risk is potentially allowing
 		// unauthorized access to sensitive metrics data. Consider replacing with CertDir, CertName, and KeyName
 		// to provide certificates, ensuring the server communicates using trusted and secure certificates.
-		TLSOpts: webhookTLSOpts,
+		TLSOpts: tlsOpts,
 	}
  • Apply / Chat
Suggestion importance[1-10]: 6

__

Why: The suggestion correctly points out that coupling the metrics server's TLS options with the webhook's is confusing and bad practice, proposing a change that improves code clarity and robustness.

Low
Fix PKGS exclude regex

Update the regex in the PKGS variable in the Makefile to correctly match
multi-digit alpha versions, such as v1alpha10.

Makefile [128]

-PKGS := $(shell go list ./... | grep -vE 'github.com/redhat-developer/rhdh-operator/(tests/|api/v1alpha([1-9]+))')
+PKGS := $(shell go list ./... | grep -vE 'github.com/redhat-developer/rhdh-operator/(tests/|api/v1alpha[1-9][0-9]*)')
  • Apply / Chat
Suggestion importance[1-10]: 6

__

Why: The suggestion correctly identifies a flaw in the regex that would fail to exclude API versions with two or more digits (e.g., v1alpha10), improving the robustness of the package filter.

Low
Return nil for unneeded cancel function

In appUrlProvider, return nil for the cancelFunc instead of an empty function to
explicitly indicate that no cleanup action is needed.

tests/e2e/e2e_test.go [216-218]

 							appUrlProvider = func(_ Gomega) (context.CancelFunc, string) {
-								return func() {}, "http://" + appUrl
+								return nil, "http://" + appUrl
 							}

[To ensure code accuracy, apply this suggestion manually]

Suggestion importance[1-10]: 5

__

Why: The suggestion correctly points out that returning nil instead of an empty function for a cancelFunc is more idiomatic and clearer, improving code readability and maintainability.

Low
Organization
best practice
Make manifest defaults explicit

Explicitly set --metrics-secure=true in the manager args to document/lock in the
intended secure behavior now that the code default changed.

dist/rhdh/install.yaml [2897-2900]

 - args:
   - --health-probe-bind-address=:8081
   - --leader-elect
+  - --metrics-secure=true
   - --metrics-bind-address=:8443
  • Apply / Chat
Suggestion importance[1-10]: 5

__

Why:
Relevant best practice - Keep manifests synchronized with implementation defaults and behavior to avoid user confusion (explicitly set key flags when defaults change).

Low
  • More

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant