azure-service-operator
azure-service-operator copied to clipboard
Bug/Swagger: Incorrect generation for ImageReference
Describe the bug
Discovered during merge of main into the Swagger WIP branch, code generation for ImageReference is inconsistent between versions.
For version v1beta20201201, the generated code for the Version property correctly reads:
type ImageReference struct {
Offer *string `json:"offer,omitempty"`
Publisher *string `json:"publisher,omitempty"`
Reference *genruntime.ResourceReference `armReference:"Id" json:"reference,omitempty"`
Sku *string `json:"sku,omitempty"`
// Version: Specifies the version of the platform image or marketplace image used to create the virtual machine. The
// allowed formats are Major.Minor.Build or 'latest'. Major, Minor, and Build are decimal numbers. Specify 'latest' to use
// the latest version of an image available at deploy time. Even if you use 'latest', the VM image will not automatically
// update after deploy time even if a new version becomes available.
Version *string `json:"version,omitempty"`
}
Comments removed for brevity.
For version v1beta20220301, the generated code incorrectly reads:
type ImageReference struct {
CommunityGalleryImageId *string `json:"communityGalleryImageId,omitempty"`
Offer *string `json:"offer,omitempty"`
Publisher *string `json:"publisher,omitempty"`
Reference *genruntime.ResourceReference `armReference:"Id" json:"reference,omitempty"`
SharedGalleryImageId *string `json:"sharedGalleryImageId,omitempty"`
Sku *string `json:"sku,omitempty"`
// VersionReference: Specifies the version of the platform image or marketplace image used to create the virtual machine.
// The allowed formats are Major.Minor.Build or 'latest'. Major, Minor, and Build are decimal numbers. Specify 'latest' to
// use the latest version of an image available at deploy time. Even if you use 'latest', the VM image will not
// automatically update after deploy time even if a new version becomes available. Please do not use field 'version' for
// gallery image deployment, gallery image should always use 'id' field for deployment, to use 'latest' version of gallery
// image, just set
// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{imageName}'
// in the 'id' field without version input.
VersionReference *genruntime.ResourceReference `armReference:"Version" json:"versionReference,omitempty"`
}
The type of the Version property is incorrect, and the name has been changed.
Both properties are configured as $armReference: false in our configuration.
my theory was that something funky was happening in config management where even though it's set to false that's not applying. Not sure what though...
Maybe the heuristic that flags things that are likely references is somehow accidentally overriding the value set in the azure-arm.yaml
Somehow this was fixed in 5cdd9705d317f1c7e7713b14c3d366a686e8052c. I don't actually know why though.
I took a quick look through all of the structure.txt files and there are a lot more references in the sswwaaggggeerr branch than main, but that's because we haven't fixed the embedded resource detection yet. In theory when we fix that, we should have exactly the same number.
Can do this to check:
grep --include=structure.txt -rEi genruntime.ResourceReference > s.txt
change branch
grep --include=structure.txt -rEi genruntime.ResourceReference > m.txt
and diff those 2 files.
For now I am closing this as it doesn't seem to be an issue anymore.