Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RS-23978] Make operator api a go module #3786

Open
wants to merge 16 commits into
base: master
Choose a base branch
from

Conversation

LorcanMcVeigh
Copy link
Contributor

Description

For PR author

  • Tests for change.
  • If changing pkg/apis/, run make gen-files
  • If changing versions, run make gen-versions

For PR reviewers

A note for code reviewers - all pull requests must have the following:

  • Milestone set according to targeted release.
  • Appropriate labels:
    • kind/bug if this is a bugfix.
    • kind/enhancement if this is a a new feature.
    • enterprise if this PR applies to Calico Enterprise only.

@LorcanMcVeigh LorcanMcVeigh force-pushed the lorcan/create-submodule branch from f084ed1 to 7648d83 Compare February 26, 2025 12:59
@LorcanMcVeigh LorcanMcVeigh force-pushed the lorcan/create-submodule branch from 82ea1f9 to 94bdfe2 Compare February 26, 2025 14:26
@@ -15,6 +15,7 @@
package v1

import (
operatorapi "github.com/tigera/operator/api/v1"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: could we rename operatorapi to api? Maybe just v1? Not sure, but find operatorapi quite long when it's in the same repo...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep - conventionally we have called this operator in other packages (sometimes operatorv1 but I think that is also more wordy than it needs to be).

v1 is slightly less good - there are several v1 packages used in this codebase.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually thought the opposite. Having an import named operator in operator might have been confusing so I opted for something more descriptive but happy to change it if that's the consensus

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it's just what we have used (somewhat inconsistently) in this repo.

go 1.23.5

require (
github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring v0.80.1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to remove this dependency as well

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This import is used in the Endpoint API here https://github.com/tigera/operator/blob/master/api/v1/monitor_types.go#L69 for the Interval and ScrapeTimeout fields. In order to remove that dependency we would need to change the type of those fields or move the Endpoint struct to somewhere else. Moving the struct would require moving the ServiceMonitor, ExternalPrometheus & MonitorSpec out of the API as well because those structs are all dependent on each other in the installation_types.go .

I don't know how/where these definitions are used, so any guidance on this would be much appreciated

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds like it might be more work than it is worth.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's ignore for now

const (
Automatic AssignmentMode = "Automatic"
Manual AssignmentMode = "Manual"
Automatic operatorapi.AssignmentMode = "Automatic"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should be defined in the operator API package rather than here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is an overlap in var name with PolicyMode https://github.com/tigera/operator/blob/master/api/v1/installation_types.go#L228 so unless we want to rename one of the vars.
Given I don't work on this code or with these vars at all. I would probably favour someone with more experience with them to rename them. Thoughts?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should rename both of these constants - the convention for enums is that they should include the type in the name to avoid this type of conflict.

type AssignmentMode string

const (
  AssignmentModeAutomatic = "Automatic"
  AssignmentModeManual = "Manual"
)

@@ -658,6 +656,8 @@ func (nt NATOutgoingType) String() string {

const NodeSelectorDefault string = "all()"

type AssignmentMode string
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing the const definitions for this type?

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.

4 participants