From 47739980423ffdd1fb281b6d2e0754ed8cd081c5 Mon Sep 17 00:00:00 2001 From: Bevan Arps Date: Tue, 5 Sep 2023 10:02:14 +1200 Subject: [PATCH] Remove references to hack/generated and hack/generator (#3223) * Rename gitmodule * Update docs * Remove unused golden files --- .gitmodules | 2 +- .../add-a-new-code-generated-resource.md | 4 +- .../content/contributing/developer-setup.md | 6 +- ..._GeneratesExpectedResults-v20200101.golden | 170 ---------------- ...tesExpectedResults-v20200101storage.golden | 53 ----- ..._GeneratesExpectedResults-v20211231.golden | 184 ------------------ ...tesExpectedResults-v20211231storage.golden | 54 ----- 7 files changed, 7 insertions(+), 466 deletions(-) delete mode 100644 v2/tools/generator/internal/codegen/storage/testdata/Test_StorageTypeFactory_GeneratesExpectedResults-v20200101.golden delete mode 100644 v2/tools/generator/internal/codegen/storage/testdata/Test_StorageTypeFactory_GeneratesExpectedResults-v20200101storage.golden delete mode 100644 v2/tools/generator/internal/codegen/storage/testdata/Test_StorageTypeFactory_GeneratesExpectedResults-v20211231.golden delete mode 100644 v2/tools/generator/internal/codegen/storage/testdata/Test_StorageTypeFactory_GeneratesExpectedResults-v20211231storage.golden diff --git a/.gitmodules b/.gitmodules index ed6614c11d0..819d01406fa 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ -[submodule "hack/generator/specs/azure-rest-api-specs"] +[submodule "azure-rest-api-specs"] path = v2/specs/azure-rest-api-specs url = https://github.com/Azure/azure-rest-api-specs diff --git a/docs/hugo/content/contributing/add-a-new-code-generated-resource.md b/docs/hugo/content/contributing/add-a-new-code-generated-resource.md index c7012688146..e53edc40f71 100644 --- a/docs/hugo/content/contributing/add-a-new-code-generated-resource.md +++ b/docs/hugo/content/contributing/add-a-new-code-generated-resource.md @@ -85,8 +85,8 @@ Once you have a working development environment, run the `task` command to run t ### \ looks like a resource reference but was not labelled as one Example: -> Replace cross-resource references with genruntime.ResourceReference: -> ["github.com/Azure/azure-service-operator/hack/generated/_apis/containerservice/v1alpha1api20210501/PrivateLinkResource.Id" looks like a resource reference but was not labelled as one. +> Replace cross-resource references with genruntime.ResourceReference: +> ["github.com/Azure/azure-service-operator/v2/apis/containerservice/v1api20210501/PrivateLinkResource.Id" looks like a resource reference but was not labelled as one. To fix this error, determine whether the property in question is an ARM ID or not, and then update the `objectModelConfiguration` section in the configuration file. diff --git a/docs/hugo/content/contributing/developer-setup.md b/docs/hugo/content/contributing/developer-setup.md index 32b59dc0628..492e324a356 100644 --- a/docs/hugo/content/contributing/developer-setup.md +++ b/docs/hugo/content/contributing/developer-setup.md @@ -144,11 +144,13 @@ From the root of your ASO repo clone, run ``` bash $ git submodule init -Submodule 'hack/generator/specs/azure-rest-api-specs' (https://github.com/Azure/azure-rest-api-specs) registered for path 'specs/azure-rest-api-specs' +Submodule 'azure-rest-api-specs' (https://github.com/Azure/azure-rest-api-specs) registered for path 'v2/specs/azure-rest-api-specs' $ git submodule update Cloning into '/workspaces/azure-service-operator/v2/specs/azure-rest-api-specs'... -Submodule path 'specs/azure-rest-api-specs': checked out '3ac733b1b1c63969fbed0c7ffe60ff5cccc708c7' +remote: Enumerating objects: 15, done. +... elided ... +Submodule path 'v2/specs/azure-rest-api-specs': checked out '35f8372749cbe9b1f69bde0eee3b0bc63c49c2c2' ``` The exact git hash that's checked out will likely be different. diff --git a/v2/tools/generator/internal/codegen/storage/testdata/Test_StorageTypeFactory_GeneratesExpectedResults-v20200101.golden b/v2/tools/generator/internal/codegen/storage/testdata/Test_StorageTypeFactory_GeneratesExpectedResults-v20200101.golden deleted file mode 100644 index c7b533e6a68..00000000000 --- a/v2/tools/generator/internal/codegen/storage/testdata/Test_StorageTypeFactory_GeneratesExpectedResults-v20200101.golden +++ /dev/null @@ -1,170 +0,0 @@ -// Code generated by azure-service-operator-codegen. DO NOT EDIT. -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. -package v20200101 - -import ( - "github.com/Azure/azure-service-operator/hack/generated/microsoft.person/v20200101storage" - "github.com/pkg/errors" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -// +kubebuilder:object:root=true -// +kubebuilder:subresource:status -type Person struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty"` - Spec Person_Spec `json:"spec,omitempty"` - Status Person_Status `json:"status,omitempty"` -} - -// AssignPropertiesFromPerson populates our Person from the provided source Person -func (person *Person) AssignPropertiesFromPerson(source *v20200101storage.Person) error { - - // Spec - var spec Person_Spec - err := spec.AssignPropertiesFromPersonSpec(&source.Spec) - if err != nil { - return errors.Wrap(err, "populating Spec from Spec, calling AssignPropertiesFromPersonSpec()") - } - person.Spec = spec - - // Status - var status Person_Status - err = status.AssignPropertiesFromPersonStatus(&source.Status) - if err != nil { - return errors.Wrap(err, "populating Status from Status, calling AssignPropertiesFromPersonStatus()") - } - person.Status = status - - // No error - return nil -} - -// AssignPropertiesToPerson populates the provided destination Person from our Person -func (person *Person) AssignPropertiesToPerson(destination *v20200101storage.Person) error { - - // Spec - var spec v20200101storage.Person_Spec - err := person.Spec.AssignPropertiesToPersonSpec(&spec) - if err != nil { - return errors.Wrap(err, "populating Spec from Spec, calling AssignPropertiesToPersonSpec()") - } - destination.Spec = spec - - // Status - var status v20200101storage.Person_Status - err = person.Status.AssignPropertiesToPersonStatus(&status) - if err != nil { - return errors.Wrap(err, "populating Status from Status, calling AssignPropertiesToPersonStatus()") - } - destination.Status = status - - // No error - return nil -} - -// +kubebuilder:object:root=true -type PersonList struct { - metav1.TypeMeta `json:",inline"` - metav1.ListMeta `json:"metadata,omitempty"` - Items []Person `json:"items"` -} - -type Person_Spec struct { - //FamilyName: Shared name of the family - FamilyName string `json:"familyName"` - - //FullName: As would be used to address mail - FullName string `json:"fullName"` - - //KnownAs: How the person is generally known - KnownAs string `json:"knownAs"` -} - -// AssignPropertiesFromPersonSpec populates our Person_Spec from the provided source Person_Spec -func (personSpec *Person_Spec) AssignPropertiesFromPersonSpec(source *v20200101storage.Person_Spec) error { - - // FamilyName - if source.FamilyName != nil { - personSpec.FamilyName = *source.FamilyName - } else { - personSpec.FamilyName = "" - } - - // FullName - if source.FullName != nil { - personSpec.FullName = *source.FullName - } else { - personSpec.FullName = "" - } - - // KnownAs - if source.KnownAs != nil { - personSpec.KnownAs = *source.KnownAs - } else { - personSpec.KnownAs = "" - } - - // No error - return nil -} - -// AssignPropertiesToPersonSpec populates the provided destination Person_Spec from our Person_Spec -func (personSpec *Person_Spec) AssignPropertiesToPersonSpec(destination *v20200101storage.Person_Spec) error { - - // FamilyName - familyName := personSpec.FamilyName - destination.FamilyName = &familyName - - // FullName - fullName := personSpec.FullName - destination.FullName = &fullName - - // KnownAs - knownA := personSpec.KnownAs - destination.KnownAs = &knownA - - // OriginalVersion - destination.OriginalVersion = personSpec.OriginalVersion() - - // No error - return nil -} - -func (personSpec *Person_Spec) OriginalVersion() string { - return GroupVersion.Version -} - -type Person_Status struct { - Status string `json:"status"` -} - -// AssignPropertiesFromPersonStatus populates our Person_Status from the provided source Person_Status -func (personStatus *Person_Status) AssignPropertiesFromPersonStatus(source *v20200101storage.Person_Status) error { - - // Status - if source.Status != nil { - personStatus.Status = *source.Status - } else { - personStatus.Status = "" - } - - // No error - return nil -} - -// AssignPropertiesToPersonStatus populates the provided destination Person_Status from our Person_Status -func (personStatus *Person_Status) AssignPropertiesToPersonStatus(destination *v20200101storage.Person_Status) error { - - // Status - status := personStatus.Status - destination.Status = &status - - // No error - return nil -} - -func init() { - SchemeBuilder.Register(&Person{}, &PersonList{}) -} diff --git a/v2/tools/generator/internal/codegen/storage/testdata/Test_StorageTypeFactory_GeneratesExpectedResults-v20200101storage.golden b/v2/tools/generator/internal/codegen/storage/testdata/Test_StorageTypeFactory_GeneratesExpectedResults-v20200101storage.golden deleted file mode 100644 index a52cf4621c6..00000000000 --- a/v2/tools/generator/internal/codegen/storage/testdata/Test_StorageTypeFactory_GeneratesExpectedResults-v20200101storage.golden +++ /dev/null @@ -1,53 +0,0 @@ -// Code generated by azure-service-operator-codegen. DO NOT EDIT. -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. -package v20200101storage - -import ( - "github.com/Azure/azure-service-operator/hack/generated/microsoft.person/v20200101storage" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime/schema" -) - -// +kubebuilder:object:root=true -// +kubebuilder:subresource:status -//Storage version of v20200101.Person -type Person struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty"` - Spec v20200101storage.Person_Spec `json:"spec,omitempty"` - Status v20200101storage.Person_Status `json:"status,omitempty"` -} - -func (person *v20200101storage.Person) OriginalGVK() *schema.GroupVersionKind { - return &schema.GroupVersionKind{ - Group: GroupVersion.Group, - Version: person.Spec.OriginalVersion, - Kind: "Person", - } -} - -// +kubebuilder:object:root=true -//Storage version of v20200101.Person -type PersonList struct { - metav1.TypeMeta `json:",inline"` - metav1.ListMeta `json:"metadata,omitempty"` - Items []v20200101storage.Person `json:"items"` -} - -//Storage version of v20200101.Person_Spec -type Person_Spec struct { - FamilyName *string `json:"familyName,omitempty"` - FullName *string `json:"fullName,omitempty"` - KnownAs *string `json:"knownAs,omitempty"` - OriginalVersion string `json:"original-version"` -} - -//Storage version of v20200101.Person_Status -type Person_Status struct { - Status *string `json:"status,omitempty"` -} - -func init() { - SchemeBuilder.Register(&v20200101storage.Person{}, &v20200101storage.PersonList{}) -} diff --git a/v2/tools/generator/internal/codegen/storage/testdata/Test_StorageTypeFactory_GeneratesExpectedResults-v20211231.golden b/v2/tools/generator/internal/codegen/storage/testdata/Test_StorageTypeFactory_GeneratesExpectedResults-v20211231.golden deleted file mode 100644 index beedb9824bd..00000000000 --- a/v2/tools/generator/internal/codegen/storage/testdata/Test_StorageTypeFactory_GeneratesExpectedResults-v20211231.golden +++ /dev/null @@ -1,184 +0,0 @@ -// Code generated by azure-service-operator-codegen. DO NOT EDIT. -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. -package v20211231 - -import ( - "github.com/Azure/azure-service-operator/hack/generated/microsoft.person/v20211231storage" - "github.com/pkg/errors" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -// +kubebuilder:object:root=true -// +kubebuilder:subresource:status -type Person struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty"` - Spec Person_Spec `json:"spec,omitempty"` - Status Person_Status `json:"status,omitempty"` -} - -// AssignPropertiesFromPerson populates our Person from the provided source Person -func (person *Person) AssignPropertiesFromPerson(source *v20211231storage.Person) error { - - // Spec - var spec Person_Spec - err := spec.AssignPropertiesFromPersonSpec(&source.Spec) - if err != nil { - return errors.Wrap(err, "populating Spec from Spec, calling AssignPropertiesFromPersonSpec()") - } - person.Spec = spec - - // Status - var status Person_Status - err = status.AssignPropertiesFromPersonStatus(&source.Status) - if err != nil { - return errors.Wrap(err, "populating Status from Status, calling AssignPropertiesFromPersonStatus()") - } - person.Status = status - - // No error - return nil -} - -// AssignPropertiesToPerson populates the provided destination Person from our Person -func (person *Person) AssignPropertiesToPerson(destination *v20211231storage.Person) error { - - // Spec - var spec v20211231storage.Person_Spec - err := person.Spec.AssignPropertiesToPersonSpec(&spec) - if err != nil { - return errors.Wrap(err, "populating Spec from Spec, calling AssignPropertiesToPersonSpec()") - } - destination.Spec = spec - - // Status - var status v20211231storage.Person_Status - err = person.Status.AssignPropertiesToPersonStatus(&status) - if err != nil { - return errors.Wrap(err, "populating Status from Status, calling AssignPropertiesToPersonStatus()") - } - destination.Status = status - - // No error - return nil -} - -// +kubebuilder:object:root=true -type PersonList struct { - metav1.TypeMeta `json:",inline"` - metav1.ListMeta `json:"metadata,omitempty"` - Items []Person `json:"items"` -} - -type Person_Spec struct { - //CustomerProgram: Level of customer programme (Silver/Gold/Platinum/Diamond) - CustomerProgram string `json:"customerProgram"` - - //FamilyName: Shared name of the family - FamilyName string `json:"familyName"` - - //FullName: As would be used to address mail - FullName string `json:"fullName"` - - //KnownAs: How the person is generally known - KnownAs string `json:"knownAs"` -} - -// AssignPropertiesFromPersonSpec populates our Person_Spec from the provided source Person_Spec -func (personSpec *Person_Spec) AssignPropertiesFromPersonSpec(source *v20211231storage.Person_Spec) error { - - // CustomerProgram - if source.CustomerProgram != nil { - personSpec.CustomerProgram = *source.CustomerProgram - } else { - personSpec.CustomerProgram = "" - } - - // FamilyName - if source.FamilyName != nil { - personSpec.FamilyName = *source.FamilyName - } else { - personSpec.FamilyName = "" - } - - // FullName - if source.FullName != nil { - personSpec.FullName = *source.FullName - } else { - personSpec.FullName = "" - } - - // KnownAs - if source.KnownAs != nil { - personSpec.KnownAs = *source.KnownAs - } else { - personSpec.KnownAs = "" - } - - // No error - return nil -} - -// AssignPropertiesToPersonSpec populates the provided destination Person_Spec from our Person_Spec -func (personSpec *Person_Spec) AssignPropertiesToPersonSpec(destination *v20211231storage.Person_Spec) error { - - // CustomerProgram - customerProgram := personSpec.CustomerProgram - destination.CustomerProgram = &customerProgram - - // FamilyName - familyName := personSpec.FamilyName - destination.FamilyName = &familyName - - // FullName - fullName := personSpec.FullName - destination.FullName = &fullName - - // KnownAs - knownA := personSpec.KnownAs - destination.KnownAs = &knownA - - // OriginalVersion - destination.OriginalVersion = personSpec.OriginalVersion() - - // No error - return nil -} - -func (personSpec *Person_Spec) OriginalVersion() string { - return GroupVersion.Version -} - -type Person_Status struct { - Status string `json:"status"` -} - -// AssignPropertiesFromPersonStatus populates our Person_Status from the provided source Person_Status -func (personStatus *Person_Status) AssignPropertiesFromPersonStatus(source *v20211231storage.Person_Status) error { - - // Status - if source.Status != nil { - personStatus.Status = *source.Status - } else { - personStatus.Status = "" - } - - // No error - return nil -} - -// AssignPropertiesToPersonStatus populates the provided destination Person_Status from our Person_Status -func (personStatus *Person_Status) AssignPropertiesToPersonStatus(destination *v20211231storage.Person_Status) error { - - // Status - status := personStatus.Status - destination.Status = &status - - // No error - return nil -} - -func init() { - SchemeBuilder.Register(&Person{}, &PersonList{}) -} diff --git a/v2/tools/generator/internal/codegen/storage/testdata/Test_StorageTypeFactory_GeneratesExpectedResults-v20211231storage.golden b/v2/tools/generator/internal/codegen/storage/testdata/Test_StorageTypeFactory_GeneratesExpectedResults-v20211231storage.golden deleted file mode 100644 index 688648a185b..00000000000 --- a/v2/tools/generator/internal/codegen/storage/testdata/Test_StorageTypeFactory_GeneratesExpectedResults-v20211231storage.golden +++ /dev/null @@ -1,54 +0,0 @@ -// Code generated by azure-service-operator-codegen. DO NOT EDIT. -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. -package v20211231storage - -import ( - "github.com/Azure/azure-service-operator/hack/generated/microsoft.person/v20211231storage" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime/schema" -) - -// +kubebuilder:object:root=true -// +kubebuilder:subresource:status -//Storage version of v20211231.Person -type Person struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty"` - Spec v20211231storage.Person_Spec `json:"spec,omitempty"` - Status v20211231storage.Person_Status `json:"status,omitempty"` -} - -func (person *v20211231storage.Person) OriginalGVK() *schema.GroupVersionKind { - return &schema.GroupVersionKind{ - Group: GroupVersion.Group, - Version: person.Spec.OriginalVersion, - Kind: "Person", - } -} - -// +kubebuilder:object:root=true -//Storage version of v20211231.Person -type PersonList struct { - metav1.TypeMeta `json:",inline"` - metav1.ListMeta `json:"metadata,omitempty"` - Items []v20211231storage.Person `json:"items"` -} - -//Storage version of v20211231.Person_Spec -type Person_Spec struct { - CustomerProgram *string `json:"customerProgram,omitempty"` - FamilyName *string `json:"familyName,omitempty"` - FullName *string `json:"fullName,omitempty"` - KnownAs *string `json:"knownAs,omitempty"` - OriginalVersion string `json:"original-version"` -} - -//Storage version of v20211231.Person_Status -type Person_Status struct { - Status *string `json:"status,omitempty"` -} - -func init() { - SchemeBuilder.Register(&v20211231storage.Person{}, &v20211231storage.PersonList{}) -}