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

Generated packages should define an accessible ARMAPIVersion variable #1554

Closed
matthchr opened this issue Jun 10, 2021 · 1 comment · Fixed by #2285
Closed

Generated packages should define an accessible ARMAPIVersion variable #1554

matthchr opened this issue Jun 10, 2021 · 1 comment · Fixed by #2285
Milestone

Comments

@matthchr
Copy link
Member

Describe the current behavior
Today, we have per-resource ARM API versions, for example:

// +kubebuilder:validation:Enum={"2020-11-01"}
type LoadBalancersSpecApiVersion string

const LoadBalancersSpecApiVersion20201101 = LoadBalancersSpecApiVersion("2020-11-01")

This is used like so:

// ConvertToARM converts from a Kubernetes CRD object to an ARM object
func (loadBalancersSpec *LoadBalancers_Spec) ConvertToARM(name string, resolvedReferences genruntime.ResolvedReferences) (interface{}, error) {
        ...
	result.ApiVersion = LoadBalancersSpecApiVersion20201101
        ...

Describe the improvement
Since our packages are per-API version anyway, I think we can do away with the per-resource APIVersion and instead just use a package global one, maybe called ARMAPIVersion.

Then the tests could also use this via:

network "github.com/Azure/azure-service-operator/hack/generated/_apis/microsoft.network/v1alpha1api20201101"
...

network.ARMAPIVersion
@matthchr
Copy link
Member Author

matthchr commented Mar 8, 2022

I think @Porges is changing this now

@matthchr matthchr mentioned this issue Mar 10, 2022
Porges added a commit that referenced this issue May 19, 2022
1. Add a new pipeline stage to create (singleton) enum types for API versions
2. Update GetAPIVersion function generation to return this enum value
3. Correct TypeVisitor so it visits the API Version typename (if any) on resource types
4. Add a small hack into the Storage type creation to also copy API versions explicitly

This fixes #1554
@theunrepentantgeek theunrepentantgeek modified the milestones: v2.1.0, v2.0.0 Jan 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
2 participants