Skip to content

Reduce API packages dependencies #4667

@timuthy

Description

@timuthy

Component(s)

No response

Is your feature request related to a problem? Please describe.

The API packages v1alpha1 and v1beta1 include imports of external and shared components, such as sigs.k8s.io/controller-runtime.
This design makes it challenging to import these API packages into other projects.

For instance, both github.com/open-telemetry/opentelemetry-operator and sigs.k8s.io/controller-runtime are direct dependencies of one of our components. As a result, we are required to use the same version of controller-runtime as the opentelemetry-operator, especially when breaking changes are introduced.
This issue recently arose when controller-runtime (version v0.23.0) modified some webhook interfaces, leading to the following error during our upgrade:

pkg/client/kubernetes/types.go:14:24: could not import github.com/open-telemetry/opentelemetry-operator/apis/v1alpha1 (/Users/tim/go/pkg/mod/github.com/open-telemetry/[email protected]/apis/v1alpha1/convert.go:15:2: could not import github.com/open-telemetry/opentelemetry-operator/apis/v1beta1 (-: # github.com/open-telemetry/opentelemetry-operator/apis/v1beta1                                                                               
../../../../pkg/mod/github.com/open-telemetry/[email protected]/apis/v1beta1/collector_webhook.go:448:34: not enough arguments in call to ctrl.NewWebhookManagedBy                                                           
        have (controllerruntime.Manager)                                                                                                                                                                                                   
        want (manager.Manager, T))) (typecheck)                                                                                                                                                                                            
        opentelemetryv1alpha1 "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha1"
                              ^

Describe the solution you'd like

As #4362 (comment) already mentioned, the API packages should not bring any transitive dependencies, or as few as possible.

After the discussion in #4362, this issue is somehow a duplicate but describes the issue again from the beginning and generally.
Please feel free to close either of them.

Describe alternatives you've considered

No response

Additional context

No response

Tip

React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it. Learn more here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions