From a9e9a0ea615034983243dba7ae6d46494a2e2710 Mon Sep 17 00:00:00 2001 From: Matthew Christopher Date: Wed, 7 Jul 2021 23:07:00 -0700 Subject: [PATCH 1/3] Return error if reference-like property is not labelled (#1629) This reduces the probability of us accidentally missing references, which it turns out we had already done because as soon as this was turned on, a number of errors were returned due to references we missed. --- hack/generated/controllers/crd_vmss_test.go | 10 ++- .../pkg/testcommon/kube_per_test_context.go | 5 ++ .../pipeline/add_cross_resource_references.go | 86 +++++++++++++++---- 3 files changed, 83 insertions(+), 18 deletions(-) diff --git a/hack/generated/controllers/crd_vmss_test.go b/hack/generated/controllers/crd_vmss_test.go index a56ab2ab705..e85b4b184f3 100644 --- a/hack/generated/controllers/crd_vmss_test.go +++ b/hack/generated/controllers/crd_vmss_test.go @@ -113,6 +113,11 @@ func newVMSS( upgradePolicyMode := compute.UpgradePolicyModeAutomatic adminUsername := "adminUser" + inboundNATPoolRef := genruntime.ResourceReference{ + // TODO: It is the most awkward thing in the world that this is not a fully fledged resource + ARMID: *loadBalancer.Status.InboundNatPools[0].Id, + } + return &compute.VirtualMachineScaleSet{ ObjectMeta: tc.MakeObjectMetaWithName(tc.Namer.GenerateName("vmss")), Spec: compute.VirtualMachineScaleSets_Spec{ @@ -162,12 +167,11 @@ func newVMSS( Name: "myipconfiguration", Properties: &compute.VirtualMachineScaleSetIPConfigurationProperties{ Subnet: &compute.ApiEntityReference{ - Id: subnet.Status.Id, + Reference: tc.MakeReferencePtrFromResource(subnet), }, LoadBalancerInboundNatPools: []compute.SubResource{ { - // TODO: It is the most awkward thing in the world that this is not a fully fledged resource - Id: loadBalancer.Status.InboundNatPools[0].Id, + Reference: &inboundNATPoolRef, }, }, }, diff --git a/hack/generated/pkg/testcommon/kube_per_test_context.go b/hack/generated/pkg/testcommon/kube_per_test_context.go index 5ec08325a80..7cf7126fe49 100644 --- a/hack/generated/pkg/testcommon/kube_per_test_context.go +++ b/hack/generated/pkg/testcommon/kube_per_test_context.go @@ -89,6 +89,11 @@ func (tc KubePerTestContext) MakeReferenceFromResource(resource controllerutil.O } } +func (tc KubePerTestContext) MakeReferencePtrFromResource(resource controllerutil.Object) *genruntime.ResourceReference { + result := tc.MakeReferenceFromResource(resource) + return &result +} + func (tc KubePerTestContext) NewTestResourceGroup() *resources.ResourceGroup { return &resources.ResourceGroup{ ObjectMeta: tc.MakeObjectMeta("rg"), diff --git a/hack/generator/pkg/codegen/pipeline/add_cross_resource_references.go b/hack/generator/pkg/codegen/pipeline/add_cross_resource_references.go index 98c41533608..93e10963a31 100644 --- a/hack/generator/pkg/codegen/pipeline/add_cross_resource_references.go +++ b/hack/generator/pkg/codegen/pipeline/add_cross_resource_references.go @@ -11,6 +11,7 @@ import ( "strings" "github.com/pkg/errors" + kerrors "k8s.io/apimachinery/pkg/util/errors" "k8s.io/klog/v2" "github.com/Azure/azure-service-operator/hack/generator/pkg/astmodel" @@ -30,15 +31,23 @@ func AddCrossResourceReferences(configuration *config.Configuration, idFactory a result := make(astmodel.Types) knownReferences := newKnownReferencesMap(configuration) + + var isCrossResourceReferenceErrs []error + isCrossResourceReference := func(typeName astmodel.TypeName, prop *astmodel.PropertyDefinition) bool { ref := referencePair{ typeName: typeName, propName: prop.PropertyName(), } - _, isReference := knownReferences[ref] - - if DoesPropertyLookLikeARMReference(prop) && !isReference { - klog.V(0).Infof("\"%s.%s\" looks like a resource reference but was not labelled as one", typeName, prop.PropertyName()) + isReference, found := knownReferences[ref] + + if DoesPropertyLookLikeARMReference(prop) && !found { + // This is an error for now to ensure that we don't accidentally miss adding references. + // If/when we move to using an upstream marker for cross resource refs, we can remove this and just + // trust the Swagger. + isCrossResourceReferenceErrs = append( + isCrossResourceReferenceErrs, + errors.Errorf("\"%s.%s\" looks like a resource reference but was not labelled as one", typeName, prop.PropertyName())) } return isReference @@ -64,6 +73,11 @@ func AddCrossResourceReferences(configuration *config.Configuration, idFactory a // TODO: Properties collapsing work for this. } + err := kerrors.NewAggregate(isCrossResourceReferenceErrs) + if err != nil { + return nil, err + } + return result, nil }) } @@ -75,15 +89,15 @@ type referencePair struct { type crossResourceReferenceChecker func(typeName astmodel.TypeName, prop *astmodel.PropertyDefinition) bool -type crossResourceReferenceTypeVisitor struct { +type CrossResourceReferenceTypeVisitor struct { astmodel.TypeVisitor // referenceChecker is a function describing what a cross resource reference looks like. It is overridable so that // we can use a more simplistic criteria for tests. isPropertyAnARMReference crossResourceReferenceChecker } -func MakeCrossResourceReferenceTypeVisitor(idFactory astmodel.IdentifierFactory, referenceChecker crossResourceReferenceChecker) crossResourceReferenceTypeVisitor { - visitor := crossResourceReferenceTypeVisitor{ +func MakeCrossResourceReferenceTypeVisitor(idFactory astmodel.IdentifierFactory, referenceChecker crossResourceReferenceChecker) CrossResourceReferenceTypeVisitor { + visitor := CrossResourceReferenceTypeVisitor{ isPropertyAnARMReference: referenceChecker, } @@ -166,31 +180,73 @@ func makeResourceReferenceProperty(idFactory astmodel.IdentifierFactory, existin } // TODO: This will go away in favor of a cleaner solution in the future, as obviously this isn't great -func newKnownReferencesMap(configuration *config.Configuration) map[referencePair]struct{} { - return map[referencePair]struct{}{ +// Set the value to false to eliminate a reference which has incorrectly been flagged +func newKnownReferencesMap(configuration *config.Configuration) map[referencePair]bool { + return map[referencePair]bool{ + // Batch { typeName: astmodel.MakeTypeName(configuration.MakeLocalPackageReference("microsoft.batch", "v1alpha1api20210101"), "KeyVaultReference"), propName: "Id", - }: {}, + }: true, + // Document DB { typeName: astmodel.MakeTypeName(configuration.MakeLocalPackageReference("microsoft.documentdb", "v1alpha1api20210515"), "VirtualNetworkRule"), propName: "Id", - }: {}, + }: true, + // Storage { typeName: astmodel.MakeTypeName(configuration.MakeLocalPackageReference("microsoft.storage", "v1alpha1api20210401"), "VirtualNetworkRule"), propName: "Id", - }: {}, + }: true, + // Service bus + { + typeName: astmodel.MakeTypeName(configuration.MakeLocalPackageReference("microsoft.servicebus", "v1alpha1api20210101preview"), "PrivateEndpoint"), + propName: "Id", + }: true, + // Network { typeName: astmodel.MakeTypeName(configuration.MakeLocalPackageReference("microsoft.network", "v1alpha1api20201101"), "SubResource"), propName: "Id", - }: {}, + }: true, + // Compute { typeName: astmodel.MakeTypeName(configuration.MakeLocalPackageReference("microsoft.compute", "v1alpha1api20200930"), "SourceVault"), propName: "Id", - }: {}, + }: true, { typeName: astmodel.MakeTypeName(configuration.MakeLocalPackageReference("microsoft.compute", "v1alpha1api20200930"), "ImageDiskReference"), propName: "Id", - }: {}, + }: true, + { + typeName: astmodel.MakeTypeName(configuration.MakeLocalPackageReference("microsoft.compute", "v1alpha1api20201201"), "DiskEncryptionSetParameters"), + propName: "Id", + }: true, + // This is an Id that I believe refers to itself. + // It's never supplied in a PUT I don't think, and is only returned in a GET because the + // IPConfiguration is actually an ARM resource that can only be created by issuing a PUT VMSS. + { + typeName: astmodel.MakeTypeName(configuration.MakeLocalPackageReference("microsoft.compute", "v1alpha1api20201201"), "VirtualMachineScaleSetIPConfiguration"), + propName: "Id", + }: false, + { + typeName: astmodel.MakeTypeName(configuration.MakeLocalPackageReference("microsoft.compute", "v1alpha1api20201201"), "ApiEntityReference"), + propName: "Id", + }: true, + { + typeName: astmodel.MakeTypeName(configuration.MakeLocalPackageReference("microsoft.compute", "v1alpha1api20201201"), "ImageReference"), + propName: "Id", + }: true, + // This is an Id that I believe refers to itself. + // It's never supplied in a PUT I don't think, and is only returned in a GET because the + // IPConfiguration is actually an ARM resource that can only be created by issuing a PUT VMSS. + { + typeName: astmodel.MakeTypeName(configuration.MakeLocalPackageReference("microsoft.compute", "v1alpha1api20201201"), "VirtualMachineScaleSetNetworkConfiguration"), + propName: "Id", + }: false, + // When SubResource is used directly in a property, it's meant as a reference. When it's inherited from, the Id is for self + { + typeName: astmodel.MakeTypeName(configuration.MakeLocalPackageReference("microsoft.compute", "v1alpha1api20201201"), "SubResource"), + propName: "Id", + }: true, } } From 5e6b16bdcbc527177f96407de79bb7276d7ce096 Mon Sep 17 00:00:00 2001 From: Bevan Arps Date: Fri, 9 Jul 2021 08:52:29 +1200 Subject: [PATCH 2/3] Convert Direction from enum into a discriminated union (#1618) --- hack/generator/pkg/conversions/direction.go | 72 +++++++++++++++++-- .../property_assignment_function.go | 48 +++++-------- 2 files changed, 84 insertions(+), 36 deletions(-) diff --git a/hack/generator/pkg/conversions/direction.go b/hack/generator/pkg/conversions/direction.go index 1a80f64b273..ac0aa4d7c1c 100644 --- a/hack/generator/pkg/conversions/direction.go +++ b/hack/generator/pkg/conversions/direction.go @@ -5,12 +5,76 @@ package conversions +import ( + "github.com/Azure/azure-service-operator/hack/generator/pkg/astmodel" +) + // Direction specifies the direction of conversion we're implementing with this function -type Direction int +type Direction interface { + // SelectString returns one of the provided strings, depending on the direction of conversion + SelectString(from string, to string) string + // SelectType returns one of the provided types, depending on the direction of conversion + SelectType(from astmodel.Type, to astmodel.Type) astmodel.Type + // WhenFrom will run the specified function only if the direction is "From", returning the current direction for chaining + WhenFrom(fn func()) Direction + // WhenTo will run the specified function only if the direction is "To", returning the current direction for chaining + WhenTo(fn func()) Direction +} -const ( +var ( // ConvertFrom indicates the conversion is from the passed 'other', populating the receiver with properties from the other - ConvertFrom = Direction(1) + ConvertFrom Direction = &ConvertFromDirection{} // ConvertTo indicates the conversion is to the passed 'other', populating the other with properties from the receiver - ConvertTo = Direction(2) + ConvertTo Direction = &ConvertToDirection{} ) + +type ConvertFromDirection struct{} + +var _ Direction = &ConvertFromDirection{} + +// SelectString returns the string for conversion FROM +func (dir *ConvertFromDirection) SelectString(fromString string, _ string) string { + return fromString +} + +// SelectType returns the type for conversion FROM +func (dir *ConvertFromDirection) SelectType(fromType astmodel.Type, _ astmodel.Type) astmodel.Type { + return fromType +} + +// WhenFrom will run the supplied function, returning this FROM direction for chaining +func (dir *ConvertFromDirection) WhenFrom(fn func()) Direction { + fn() + return dir +} + +// WhenTo will skip the supplied function, returning this FROM direction for chaining +func (dir *ConvertFromDirection) WhenTo(_ func()) Direction { + // Nothing + return dir +} + +type ConvertToDirection struct{} + +var _ Direction = &ConvertToDirection{} + +// SelectString returns the string for conversion TO +func (dir *ConvertToDirection) SelectString(_ string, toValue string) string { + return toValue +} + +// SelectType returns the type for conversion TO +func (dir *ConvertToDirection) SelectType(_ astmodel.Type, toType astmodel.Type) astmodel.Type { + return toType +} + +// WhenFrom will skip the supplied function, returning this TO direction for chaining +func (dir *ConvertToDirection) WhenFrom(_ func()) Direction { + return dir +} + +// WhenTo will run the supplied function, returning this TO direction for chaining +func (dir *ConvertToDirection) WhenTo(fn func()) Direction { + fn() + return dir +} diff --git a/hack/generator/pkg/conversions/property_assignment_function.go b/hack/generator/pkg/conversions/property_assignment_function.go index bc19aa8d731..ac2ecb5eeb1 100644 --- a/hack/generator/pkg/conversions/property_assignment_function.go +++ b/hack/generator/pkg/conversions/property_assignment_function.go @@ -154,15 +154,10 @@ func (fn *PropertyAssignmentFunction) Equals(f astmodel.Function) bool { // AsFunc renders this function as an AST for serialization to a Go source file func (fn *PropertyAssignmentFunction) AsFunc(generationContext *astmodel.CodeGenerationContext, receiver astmodel.TypeName) *dst.FuncDecl { - var description string - switch fn.direction { - case ConvertFrom: - description = fmt.Sprintf("populates our %s from the provided source %s", receiver.Name(), fn.otherDefinition.Name().Name()) - case ConvertTo: - description = fmt.Sprintf("populates the provided destination %s from our %s", fn.otherDefinition.Name().Name(), receiver.Name()) - default: - panic(fmt.Sprintf("unexpected conversion direction %q", fn.direction)) - } + + description := fn.direction.SelectString( + fmt.Sprintf("populates our %s from the provided source %s", receiver.Name(), fn.otherDefinition.Name().Name()), + fmt.Sprintf("populates the provided destination %s from our %s", fn.otherDefinition.Name().Name(), receiver.Name())) // We always use a pointer receiver so we can modify it receiverType := astmodel.NewOptionalType(receiver).AsType(generationContext) @@ -268,19 +263,14 @@ func (fn *PropertyAssignmentFunction) generateAssignments( // createConversions iterates through the properties on our receiver type, matching them up with // our other type and generating conversions where possible func (fn *PropertyAssignmentFunction) createConversions(receiver astmodel.TypeDefinition) error { - var sourceEndpoints map[string]ReadableConversionEndpoint - var destinationEndpoints map[string]WritableConversionEndpoint + // When converting FROM, otherDefinition.Type() is our source + // When converting TO, receiver.Type() is our source + // and conversely for our destination + sourceType := fn.direction.SelectType(fn.otherDefinition.Type(), receiver.Type()) + destinationType := fn.direction.SelectType(receiver.Type(), fn.otherDefinition.Type()) - switch fn.direction { - case ConvertFrom: - sourceEndpoints = fn.createReadableEndpoints(fn.otherDefinition.Type()) - destinationEndpoints = fn.createWritableEndpoints(receiver.Type()) - case ConvertTo: - sourceEndpoints = fn.createReadableEndpoints(receiver.Type()) - destinationEndpoints = fn.createWritableEndpoints(fn.otherDefinition.Type()) - default: - panic(fmt.Sprintf("unexpected conversion direction %q", fn.direction)) - } + sourceEndpoints := fn.createReadableEndpoints(sourceType) + destinationEndpoints := fn.createWritableEndpoints(destinationType) // Flag receiver and parameter names as used fn.knownLocals.Add(fn.receiverName) @@ -301,8 +291,8 @@ func (fn *PropertyAssignmentFunction) createConversions(receiver astmodel.TypeDe return errors.Wrapf( err, "creating conversion to %s by %s", - sourceEndpoint, - destinationEndpoint) + destinationEndpoint, + sourceEndpoint) } else if conv != nil { // A conversion was created, keep it for later fn.conversions[destinationName] = conv @@ -377,13 +367,7 @@ func (fn *PropertyAssignmentFunction) createConversion( func nameOfPropertyAssignmentFunction(name astmodel.TypeName, direction Direction, idFactory astmodel.IdentifierFactory) string { nameOfOtherType := idFactory.CreateIdentifier(name.Name(), astmodel.Exported) - switch direction { - case ConvertTo: - return "AssignPropertiesTo" + nameOfOtherType - - case ConvertFrom: - return "AssignPropertiesFrom" + nameOfOtherType - } - - panic(fmt.Sprintf("unexpected conversion direction %q", direction)) + return direction.SelectString( + "AssignPropertiesFrom"+nameOfOtherType, + "AssignPropertiesTo"+nameOfOtherType) } From e16e163ccfc322d8b956ec21a70357a714fe3b68 Mon Sep 17 00:00:00 2001 From: Bevan Arps Date: Fri, 9 Jul 2021 09:27:19 +1200 Subject: [PATCH 3/3] Move Property Assignment Function into the functions package (#1622) --- hack/generator/pkg/astbuilder/builder.go | 15 ++++ .../inject_property_assignment_functions.go | 5 +- .../conversions/package_references_test.go | 12 --- .../pkg/conversions/property_conversions.go | 9 +- .../readable_conversion_endpoint.go | 38 +++++++++ .../writable_conversion_endpoint.go | 27 ++++++ .../property_assignment_function.go | 85 +++++-------------- .../property_assignment_function_test.go | 9 +- .../ConvertBetweenAliasAndAliasType.golden | 2 +- .../ConvertBetweenAliasAndBaseType.golden | 2 +- ...ertBetweenAliasAndOptionalAliasType.golden | 2 +- .../ConvertBetweenEnumAndBaseType.golden | 2 +- ...nvertBetweenEnumAndOptionalBaseType.golden | 2 +- ...vertBetweenOptionalAliasAndBaseType.golden | 2 +- ...enOptionalAliasAndOptionalAliasType.golden | 2 +- ...eenOptionalAliasAndOptionalBaseType.golden | 2 +- ...nvertBetweenOptionalEnumAndBaseType.golden | 2 +- ...weenOptionalEnumAndOptionalBaseType.golden | 2 +- ...tBetweenOptionalEnumAndOptionalEnum.golden | 2 +- ...weenOptionalObjectAndOptionalObject.golden | 2 +- ...tBetweenRequiredEnumAndOptionalEnum.golden | 2 +- ...tBetweenRequiredEnumAndRequiredEnum.golden | 2 +- ...weenRequiredObjectAndOptionalObject.golden | 2 +- ...weenRequiredObjectAndRequiredObject.golden | 2 +- .../testdata/CopyJSONObjectProperty.golden | 2 +- .../testdata/CopyJSONProperty.golden | 2 +- .../CopyKnownReferenceProperty.golden | 2 +- .../testdata/CopyOptionalJSONProperty.golden | 2 +- .../testdata/CopyReferenceProperty.golden | 2 +- .../testdata/NastyTest.golden | 2 +- ...eadFromFunctionIntoOptionalProperty.golden | 2 +- .../ReadFromFunctionIntoProperty.golden | 2 +- ...tArrayOfOptionalFromArrayOfRequired.golden | 2 +- ...tArrayOfRequiredFromArrayOfOptional.golden | 2 +- ...tArrayOfRequiredFromArrayOfRequired.golden | 2 +- .../testdata/SetIntFromInt.golden | 2 +- .../testdata/SetIntFromOptionalInt.golden | 2 +- .../SetMapOfOptionalFromMapOfRequired.golden | 2 +- .../SetMapOfRequiredFromMapOfOptional.golden | 2 +- .../SetMapOfRequiredFromMapOfRequired.golden | 2 +- ...SetOptionalStringFromOptionalString.golden | 2 +- .../SetOptionalStringFromString.golden | 2 +- .../SetStringFromOptionalString.golden | 2 +- .../testdata/SetStringFromString.golden | 2 +- 44 files changed, 152 insertions(+), 120 deletions(-) delete mode 100644 hack/generator/pkg/conversions/package_references_test.go rename hack/generator/pkg/{conversions => functions}/property_assignment_function.go (82%) rename hack/generator/pkg/{conversions => functions}/property_assignment_function_test.go (97%) rename hack/generator/pkg/{conversions => functions}/testdata/ConvertBetweenAliasAndAliasType.golden (88%) rename hack/generator/pkg/{conversions => functions}/testdata/ConvertBetweenAliasAndBaseType.golden (88%) rename hack/generator/pkg/{conversions => functions}/testdata/ConvertBetweenAliasAndOptionalAliasType.golden (89%) rename hack/generator/pkg/{conversions => functions}/testdata/ConvertBetweenEnumAndBaseType.golden (88%) rename hack/generator/pkg/{conversions => functions}/testdata/ConvertBetweenEnumAndOptionalBaseType.golden (89%) rename hack/generator/pkg/{conversions => functions}/testdata/ConvertBetweenOptionalAliasAndBaseType.golden (89%) rename hack/generator/pkg/{conversions => functions}/testdata/ConvertBetweenOptionalAliasAndOptionalAliasType.golden (90%) rename hack/generator/pkg/{conversions => functions}/testdata/ConvertBetweenOptionalAliasAndOptionalBaseType.golden (90%) rename hack/generator/pkg/{conversions => functions}/testdata/ConvertBetweenOptionalEnumAndBaseType.golden (89%) rename hack/generator/pkg/{conversions => functions}/testdata/ConvertBetweenOptionalEnumAndOptionalBaseType.golden (90%) rename hack/generator/pkg/{conversions => functions}/testdata/ConvertBetweenOptionalEnumAndOptionalEnum.golden (90%) rename hack/generator/pkg/{conversions => functions}/testdata/ConvertBetweenOptionalObjectAndOptionalObject.golden (93%) rename hack/generator/pkg/{conversions => functions}/testdata/ConvertBetweenRequiredEnumAndOptionalEnum.golden (90%) rename hack/generator/pkg/{conversions => functions}/testdata/ConvertBetweenRequiredEnumAndRequiredEnum.golden (89%) rename hack/generator/pkg/{conversions => functions}/testdata/ConvertBetweenRequiredObjectAndOptionalObject.golden (93%) rename hack/generator/pkg/{conversions => functions}/testdata/ConvertBetweenRequiredObjectAndRequiredObject.golden (92%) rename hack/generator/pkg/{conversions => functions}/testdata/CopyJSONObjectProperty.golden (94%) rename hack/generator/pkg/{conversions => functions}/testdata/CopyJSONProperty.golden (90%) rename hack/generator/pkg/{conversions => functions}/testdata/CopyKnownReferenceProperty.golden (91%) rename hack/generator/pkg/{conversions => functions}/testdata/CopyOptionalJSONProperty.golden (91%) rename hack/generator/pkg/{conversions => functions}/testdata/CopyReferenceProperty.golden (90%) rename hack/generator/pkg/{conversions => functions}/testdata/NastyTest.golden (95%) rename hack/generator/pkg/{conversions => functions}/testdata/ReadFromFunctionIntoOptionalProperty.golden (88%) rename hack/generator/pkg/{conversions => functions}/testdata/ReadFromFunctionIntoProperty.golden (87%) rename hack/generator/pkg/{conversions => functions}/testdata/SetArrayOfOptionalFromArrayOfRequired.golden (92%) rename hack/generator/pkg/{conversions => functions}/testdata/SetArrayOfRequiredFromArrayOfOptional.golden (92%) rename hack/generator/pkg/{conversions => functions}/testdata/SetArrayOfRequiredFromArrayOfRequired.golden (92%) rename hack/generator/pkg/{conversions => functions}/testdata/SetIntFromInt.golden (88%) rename hack/generator/pkg/{conversions => functions}/testdata/SetIntFromOptionalInt.golden (89%) rename hack/generator/pkg/{conversions => functions}/testdata/SetMapOfOptionalFromMapOfRequired.golden (93%) rename hack/generator/pkg/{conversions => functions}/testdata/SetMapOfRequiredFromMapOfOptional.golden (93%) rename hack/generator/pkg/{conversions => functions}/testdata/SetMapOfRequiredFromMapOfRequired.golden (92%) rename hack/generator/pkg/{conversions => functions}/testdata/SetOptionalStringFromOptionalString.golden (90%) rename hack/generator/pkg/{conversions => functions}/testdata/SetOptionalStringFromString.golden (89%) rename hack/generator/pkg/{conversions => functions}/testdata/SetStringFromOptionalString.golden (89%) rename hack/generator/pkg/{conversions => functions}/testdata/SetStringFromString.golden (88%) diff --git a/hack/generator/pkg/astbuilder/builder.go b/hack/generator/pkg/astbuilder/builder.go index 7ad046992d5..4c90207859b 100644 --- a/hack/generator/pkg/astbuilder/builder.go +++ b/hack/generator/pkg/astbuilder/builder.go @@ -25,6 +25,21 @@ func CheckErrorAndReturn(otherReturns ...dst.Expr) dst.Stmt { return CheckErrorAndSingleStatement(retStmt) } +// CheckErrorAndWrap checks if the err is non-nil, and if it is returns it, wrapped with additional information +// +// if err != nil { +// return errors.Wrapf(err, , ) +// } +// +func CheckErrorAndWrap(errorsPackage string, message string, args ...dst.Expr) dst.Stmt { + wrap := CallQualifiedFunc( + errorsPackage, + "Wrap", + Expressions(dst.NewIdent("err"), StringLiteral(message), args)...) + + return CheckErrorAndSingleStatement(Returns(wrap)) +} + // CheckErrorAndSingleStatement checks if the err is non-nil, and if it is executes the provided statement. // // if err != nil { diff --git a/hack/generator/pkg/codegen/pipeline/inject_property_assignment_functions.go b/hack/generator/pkg/codegen/pipeline/inject_property_assignment_functions.go index b62fcf5a2bc..d280e98a0f8 100644 --- a/hack/generator/pkg/codegen/pipeline/inject_property_assignment_functions.go +++ b/hack/generator/pkg/codegen/pipeline/inject_property_assignment_functions.go @@ -14,6 +14,7 @@ import ( "github.com/Azure/azure-service-operator/hack/generator/pkg/astmodel" "github.com/Azure/azure-service-operator/hack/generator/pkg/codegen/storage" "github.com/Azure/azure-service-operator/hack/generator/pkg/conversions" + "github.com/Azure/azure-service-operator/hack/generator/pkg/functions" ) // injectPropertyAssignmentFunctionsStageId is the unique identifier for this pipeline stage @@ -102,13 +103,13 @@ func (f propertyAssignmentFunctionsFactory) injectBetween( // Create conversion functions conversionContext := conversions.NewPropertyConversionContext(f.types, f.idFactory) - assignFromFn, err := conversions.NewPropertyAssignmentFromFunction(upstreamDef, downstreamDef, f.idFactory, conversionContext) + assignFromFn, err := functions.NewPropertyAssignmentFromFunction(upstreamDef, downstreamDef, f.idFactory, conversionContext) upstreamName := upstreamDef.Name() if err != nil { return astmodel.TypeDefinition{}, errors.Wrapf(err, "creating AssignFrom() function for %q", upstreamName) } - assignToFn, err := conversions.NewPropertyAssignmentToFunction(upstreamDef, downstreamDef, f.idFactory, conversionContext) + assignToFn, err := functions.NewPropertyAssignmentToFunction(upstreamDef, downstreamDef, f.idFactory, conversionContext) if err != nil { return astmodel.TypeDefinition{}, errors.Wrapf(err, "creating AssignTo() function for %q", upstreamName) } diff --git a/hack/generator/pkg/conversions/package_references_test.go b/hack/generator/pkg/conversions/package_references_test.go deleted file mode 100644 index 5508c3f2ddc..00000000000 --- a/hack/generator/pkg/conversions/package_references_test.go +++ /dev/null @@ -1,12 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT license. - */ - -package conversions - -import "github.com/Azure/azure-service-operator/hack/generator/pkg/astmodel" - -func makeTestLocalPackageReference(group string, version string) astmodel.LocalPackageReference { - return astmodel.MakeLocalPackageReference("github.com/Azure/azure-service-operator/hack/generated/_apis", group, version) -} diff --git a/hack/generator/pkg/conversions/property_conversions.go b/hack/generator/pkg/conversions/property_conversions.go index 55ec6617f07..7174a5a4f64 100644 --- a/hack/generator/pkg/conversions/property_conversions.go +++ b/hack/generator/pkg/conversions/property_conversions.go @@ -145,6 +145,13 @@ func CreateTypeConversion( return nil, err } +func NameOfPropertyAssignmentFunction(name astmodel.TypeName, direction Direction, idFactory astmodel.IdentifierFactory) string { + nameOfOtherType := idFactory.CreateIdentifier(name.Name(), astmodel.Exported) + return direction.SelectString( + "AssignPropertiesFrom"+nameOfOtherType, + "AssignPropertiesTo"+nameOfOtherType) +} + // assignToOptional will generate a conversion where the destination is optional, if the // underlying type of the destination is compatible with the source. // @@ -853,7 +860,7 @@ func assignObjectFromObject( actualReader = astbuilder.AddrOf(reader) } - functionName := nameOfPropertyAssignmentFunction(sourceName, conversionContext.direction, conversionContext.idFactory) + functionName := NameOfPropertyAssignmentFunction(sourceName, conversionContext.direction, conversionContext.idFactory) var conversion dst.Stmt if destinationName.PackageReference.Equals(generationContext.CurrentPackage()) { diff --git a/hack/generator/pkg/conversions/readable_conversion_endpoint.go b/hack/generator/pkg/conversions/readable_conversion_endpoint.go index cb1cb591438..7cbc19b0791 100644 --- a/hack/generator/pkg/conversions/readable_conversion_endpoint.go +++ b/hack/generator/pkg/conversions/readable_conversion_endpoint.go @@ -60,3 +60,41 @@ func MakeReadableConversionEndpointForValueFunction( func (r ReadableConversionEndpoint) String() string { return r.description } + +// Read generates an expression to read our endpoint +func (r ReadableConversionEndpoint) Read(expr dst.Expr) dst.Expr { + return r.reader(expr) +} + +// Endpoint provides access to the end point we read +func (r ReadableConversionEndpoint) Endpoint() *TypedConversionEndpoint { + return r.endpoint +} + +// CreateReadableEndpoints creates a map of all the readable endpoints found on a type +func CreateReadableEndpoints( + instance astmodel.Type, + knownLocals *astmodel.KnownLocalsSet) map[string]ReadableConversionEndpoint { + result := make(map[string]ReadableConversionEndpoint) + + propContainer, ok := astmodel.AsPropertyContainer(instance) + if ok { + for _, prop := range propContainer.Properties() { + endpoint := MakeReadableConversionEndpointForProperty(prop, knownLocals) + result[string(prop.PropertyName())] = endpoint + } + } + + funcContainer, ok := astmodel.AsFunctionContainer(instance) + if ok { + for _, f := range funcContainer.Functions() { + valueFn, ok := f.(astmodel.ValueFunction) + if ok { + endpoint := MakeReadableConversionEndpointForValueFunction(valueFn, knownLocals) + result[f.Name()] = endpoint + } + } + } + + return result +} diff --git a/hack/generator/pkg/conversions/writable_conversion_endpoint.go b/hack/generator/pkg/conversions/writable_conversion_endpoint.go index b9388626eaa..9ad424a7a3c 100644 --- a/hack/generator/pkg/conversions/writable_conversion_endpoint.go +++ b/hack/generator/pkg/conversions/writable_conversion_endpoint.go @@ -50,3 +50,30 @@ func MakeWritableConversionEndpointForProperty( func (w WritableConversionEndpoint) String() string { return w.description } + +// Write generates a series of statements to write the specified value to our destination endpoint +func (w WritableConversionEndpoint) Write(destination dst.Expr, value dst.Expr) []dst.Stmt { + return w.writer(destination, value) +} + +// Endpoint() provides access to the endpoint we write +func (w WritableConversionEndpoint) Endpoint() *TypedConversionEndpoint { + return w.endpoint +} + +// CreateWritableEndpoints creates a map of all the writable endpoints found on a type +func CreateWritableEndpoints( + instance astmodel.Type, + knownLocals *astmodel.KnownLocalsSet) map[string]WritableConversionEndpoint { + result := make(map[string]WritableConversionEndpoint) + + propContainer, ok := astmodel.AsPropertyContainer(instance) + if ok { + for _, prop := range propContainer.Properties() { + endpoint := MakeWritableConversionEndpointForProperty(prop, knownLocals) + result[string(prop.PropertyName())] = endpoint + } + } + + return result +} diff --git a/hack/generator/pkg/conversions/property_assignment_function.go b/hack/generator/pkg/functions/property_assignment_function.go similarity index 82% rename from hack/generator/pkg/conversions/property_assignment_function.go rename to hack/generator/pkg/functions/property_assignment_function.go index ac2ecb5eeb1..6d84cfea5c2 100644 --- a/hack/generator/pkg/conversions/property_assignment_function.go +++ b/hack/generator/pkg/functions/property_assignment_function.go @@ -3,7 +3,7 @@ * Licensed under the MIT license. */ -package conversions +package functions import ( "fmt" @@ -14,6 +14,7 @@ import ( "github.com/Azure/azure-service-operator/hack/generator/pkg/astbuilder" "github.com/Azure/azure-service-operator/hack/generator/pkg/astmodel" + "github.com/Azure/azure-service-operator/hack/generator/pkg/conversions" ) // PropertyAssignmentFunction represents a function that assigns all the properties from one resource or object to @@ -28,11 +29,11 @@ type PropertyAssignmentFunction struct { // idFactory is a reference to an identifier factory used for creating Go identifiers idFactory astmodel.IdentifierFactory // direction indicates the kind of conversion we are generating - direction Direction + direction conversions.Direction // knownLocals is a cached set of local identifiers that have already been used, to avoid conflicts knownLocals *astmodel.KnownLocalsSet // conversionContext is additional information about the context in which this conversion was made - conversionContext *PropertyConversionContext + conversionContext *conversions.PropertyConversionContext // identifier to use for our receiver in generated code receiverName string // identifier to use for our parameter in generated code @@ -54,12 +55,12 @@ func NewPropertyAssignmentFromFunction( receiver astmodel.TypeDefinition, otherDefinition astmodel.TypeDefinition, idFactory astmodel.IdentifierFactory, - conversionContext *PropertyConversionContext, + conversionContext *conversions.PropertyConversionContext, ) (*PropertyAssignmentFunction, error) { result := &PropertyAssignmentFunction{ otherDefinition: otherDefinition, idFactory: idFactory, - direction: ConvertFrom, + direction: conversions.ConvertFrom, conversions: make(map[string]StoragePropertyConversion), knownLocals: astmodel.NewKnownLocalsSet(idFactory), receiverName: idFactory.CreateIdentifier(receiver.Name().Name(), astmodel.NotExported), @@ -68,7 +69,7 @@ func NewPropertyAssignmentFromFunction( result.conversionContext = conversionContext.WithFunctionName(result.Name()). WithKnownLocals(result.knownLocals). - WithDirection(ConvertFrom) + WithDirection(conversions.ConvertFrom) err := result.createConversions(receiver) if err != nil { @@ -83,12 +84,12 @@ func NewPropertyAssignmentToFunction( receiver astmodel.TypeDefinition, otherDefinition astmodel.TypeDefinition, idFactory astmodel.IdentifierFactory, - conversionContext *PropertyConversionContext, + conversionContext *conversions.PropertyConversionContext, ) (*PropertyAssignmentFunction, error) { result := &PropertyAssignmentFunction{ otherDefinition: otherDefinition, idFactory: idFactory, - direction: ConvertTo, + direction: conversions.ConvertTo, conversions: make(map[string]StoragePropertyConversion), knownLocals: astmodel.NewKnownLocalsSet(idFactory), receiverName: idFactory.CreateIdentifier(receiver.Name().Name(), astmodel.NotExported), @@ -97,7 +98,7 @@ func NewPropertyAssignmentToFunction( result.conversionContext = conversionContext.WithFunctionName(result.Name()). WithKnownLocals(result.knownLocals). - WithDirection(ConvertTo) + WithDirection(conversions.ConvertTo) err := result.createConversions(receiver) if err != nil { @@ -109,7 +110,7 @@ func NewPropertyAssignmentToFunction( // Name returns the name of this function func (fn *PropertyAssignmentFunction) Name() string { - return nameOfPropertyAssignmentFunction(fn.otherDefinition.Name(), fn.direction, fn.idFactory) + return conversions.NameOfPropertyAssignmentFunction(fn.otherDefinition.Name(), fn.direction, fn.idFactory) } // RequiredPackageReferences returns the set of package references required by this function @@ -193,9 +194,9 @@ func (fn *PropertyAssignmentFunction) generateBody( generationContext *astmodel.CodeGenerationContext, ) []dst.Stmt { switch fn.direction { - case ConvertFrom: + case conversions.ConvertFrom: return fn.generateDirectConversionFrom(receiver, parameter, generationContext) - case ConvertTo: + case conversions.ConvertTo: return fn.generateDirectConversionTo(receiver, parameter, generationContext) default: panic(fmt.Sprintf("unexpected conversion direction %q", fn.direction)) @@ -269,8 +270,8 @@ func (fn *PropertyAssignmentFunction) createConversions(receiver astmodel.TypeDe sourceType := fn.direction.SelectType(fn.otherDefinition.Type(), receiver.Type()) destinationType := fn.direction.SelectType(receiver.Type(), fn.otherDefinition.Type()) - sourceEndpoints := fn.createReadableEndpoints(sourceType) - destinationEndpoints := fn.createWritableEndpoints(destinationType) + sourceEndpoints := conversions.CreateReadableEndpoints(sourceType, fn.knownLocals) + destinationEndpoints := conversions.CreateWritableEndpoints(destinationType, fn.knownLocals) // Flag receiver and parameter names as used fn.knownLocals.Add(fn.receiverName) @@ -302,52 +303,13 @@ func (fn *PropertyAssignmentFunction) createConversions(receiver astmodel.TypeDe return nil } -func (fn *PropertyAssignmentFunction) createReadableEndpoints(instance astmodel.Type) map[string]ReadableConversionEndpoint { - result := make(map[string]ReadableConversionEndpoint) - - propContainer, ok := astmodel.AsPropertyContainer(instance) - if ok { - for _, prop := range propContainer.Properties() { - endpoint := MakeReadableConversionEndpointForProperty(prop, fn.knownLocals) - result[string(prop.PropertyName())] = endpoint - } - } - - funcContainer, ok := astmodel.AsFunctionContainer(instance) - if ok { - for _, f := range funcContainer.Functions() { - valueFn, ok := f.(astmodel.ValueFunction) - if ok { - endpoint := MakeReadableConversionEndpointForValueFunction(valueFn, fn.knownLocals) - result[f.Name()] = endpoint - } - } - } - - return result -} - -func (fn *PropertyAssignmentFunction) createWritableEndpoints(instance astmodel.Type) map[string]WritableConversionEndpoint { - result := make(map[string]WritableConversionEndpoint) - - propContainer, ok := astmodel.AsPropertyContainer(instance) - if ok { - for _, prop := range propContainer.Properties() { - endpoint := MakeWritableConversionEndpointForProperty(prop, fn.knownLocals) - result[string(prop.PropertyName())] = endpoint - } - } - - return result -} - // createPropertyConversion tries to create a conversion between the two provided endpoints, using all of the // available conversion functions in priority order to do so. If no valid conversion can be created an error is returned. func (fn *PropertyAssignmentFunction) createConversion( - sourceEndpoint ReadableConversionEndpoint, - destinationEndpoint WritableConversionEndpoint) (StoragePropertyConversion, error) { + sourceEndpoint conversions.ReadableConversionEndpoint, + destinationEndpoint conversions.WritableConversionEndpoint) (StoragePropertyConversion, error) { - conversion, err := CreateTypeConversion(sourceEndpoint.endpoint, destinationEndpoint.endpoint, fn.conversionContext) + conversion, err := conversions.CreateTypeConversion(sourceEndpoint.Endpoint(), destinationEndpoint.Endpoint(), fn.conversionContext) if err != nil { return nil, errors.Wrapf( err, @@ -356,18 +318,11 @@ func (fn *PropertyAssignmentFunction) createConversion( } return func(source dst.Expr, destination dst.Expr, generationContext *astmodel.CodeGenerationContext) []dst.Stmt { - reader := sourceEndpoint.reader(source) + reader := sourceEndpoint.Read(source) writer := func(expr dst.Expr) []dst.Stmt { - return destinationEndpoint.writer(destination, expr) + return destinationEndpoint.Write(destination, expr) } return conversion(reader, writer, generationContext) }, nil } - -func nameOfPropertyAssignmentFunction(name astmodel.TypeName, direction Direction, idFactory astmodel.IdentifierFactory) string { - nameOfOtherType := idFactory.CreateIdentifier(name.Name(), astmodel.Exported) - return direction.SelectString( - "AssignPropertiesFrom"+nameOfOtherType, - "AssignPropertiesTo"+nameOfOtherType) -} diff --git a/hack/generator/pkg/conversions/property_assignment_function_test.go b/hack/generator/pkg/functions/property_assignment_function_test.go similarity index 97% rename from hack/generator/pkg/conversions/property_assignment_function_test.go rename to hack/generator/pkg/functions/property_assignment_function_test.go index 9975e85b00b..f0b308bcdcb 100644 --- a/hack/generator/pkg/conversions/property_assignment_function_test.go +++ b/hack/generator/pkg/functions/property_assignment_function_test.go @@ -3,12 +3,13 @@ * Licensed under the MIT license. */ -package conversions +package functions import ( "testing" "github.com/Azure/azure-service-operator/hack/generator/pkg/astmodel" + "github.com/Azure/azure-service-operator/hack/generator/pkg/conversions" "github.com/Azure/azure-service-operator/hack/generator/pkg/test" . "github.com/onsi/gomega" @@ -24,8 +25,8 @@ type StorageConversionPropertyTestCase struct { func CreatePropertyAssignmentFunctionTestCases() []*StorageConversionPropertyTestCase { // Package References - vCurrent := makeTestLocalPackageReference("Verification", "vCurrent") - vNext := makeTestLocalPackageReference("Verification", "vNext") + vCurrent := test.MakeLocalPackageReference("Verification", "vCurrent") + vNext := test.MakeLocalPackageReference("Verification", "vNext") // Custom Types alpha := astmodel.EnumValue{Identifier: "Alpha", Value: "alpha"} @@ -223,7 +224,7 @@ func runTestPropertyAssignmentFunction_AsFunc(c *StorageConversionPropertyTestCa currentType, ok := astmodel.AsObjectType(c.currentObject.Type()) g.Expect(ok).To(BeTrue()) - conversionContext := NewPropertyConversionContext(c.types, idFactory) + conversionContext := conversions.NewPropertyConversionContext(c.types, idFactory) convertFrom, errs := NewPropertyAssignmentFromFunction(c.currentObject, c.otherObject, idFactory, conversionContext) g.Expect(errs).To(BeNil()) diff --git a/hack/generator/pkg/conversions/testdata/ConvertBetweenAliasAndAliasType.golden b/hack/generator/pkg/functions/testdata/ConvertBetweenAliasAndAliasType.golden similarity index 88% rename from hack/generator/pkg/conversions/testdata/ConvertBetweenAliasAndAliasType.golden rename to hack/generator/pkg/functions/testdata/ConvertBetweenAliasAndAliasType.golden index a897c5e606e..8842639847d 100644 --- a/hack/generator/pkg/conversions/testdata/ConvertBetweenAliasAndAliasType.golden +++ b/hack/generator/pkg/functions/testdata/ConvertBetweenAliasAndAliasType.golden @@ -3,7 +3,7 @@ // Licensed under the MIT license. package vCurrent -import "github.com/Azure/azure-service-operator/hack/generated/_apis/Verification/vNext" +import "github.com/Azure/azure-service-operator/testing/Verification/vNext" type Person struct { Age Age `json:"age"` diff --git a/hack/generator/pkg/conversions/testdata/ConvertBetweenAliasAndBaseType.golden b/hack/generator/pkg/functions/testdata/ConvertBetweenAliasAndBaseType.golden similarity index 88% rename from hack/generator/pkg/conversions/testdata/ConvertBetweenAliasAndBaseType.golden rename to hack/generator/pkg/functions/testdata/ConvertBetweenAliasAndBaseType.golden index 23f99bb5634..0fd00cc5858 100644 --- a/hack/generator/pkg/conversions/testdata/ConvertBetweenAliasAndBaseType.golden +++ b/hack/generator/pkg/functions/testdata/ConvertBetweenAliasAndBaseType.golden @@ -3,7 +3,7 @@ // Licensed under the MIT license. package vCurrent -import "github.com/Azure/azure-service-operator/hack/generated/_apis/Verification/vNext" +import "github.com/Azure/azure-service-operator/testing/Verification/vNext" type Person struct { Age Age `json:"age"` diff --git a/hack/generator/pkg/conversions/testdata/ConvertBetweenAliasAndOptionalAliasType.golden b/hack/generator/pkg/functions/testdata/ConvertBetweenAliasAndOptionalAliasType.golden similarity index 89% rename from hack/generator/pkg/conversions/testdata/ConvertBetweenAliasAndOptionalAliasType.golden rename to hack/generator/pkg/functions/testdata/ConvertBetweenAliasAndOptionalAliasType.golden index 555938c4052..3f3d681db40 100644 --- a/hack/generator/pkg/conversions/testdata/ConvertBetweenAliasAndOptionalAliasType.golden +++ b/hack/generator/pkg/functions/testdata/ConvertBetweenAliasAndOptionalAliasType.golden @@ -3,7 +3,7 @@ // Licensed under the MIT license. package vCurrent -import "github.com/Azure/azure-service-operator/hack/generated/_apis/Verification/vNext" +import "github.com/Azure/azure-service-operator/testing/Verification/vNext" type Person struct { Age Age `json:"age"` diff --git a/hack/generator/pkg/conversions/testdata/ConvertBetweenEnumAndBaseType.golden b/hack/generator/pkg/functions/testdata/ConvertBetweenEnumAndBaseType.golden similarity index 88% rename from hack/generator/pkg/conversions/testdata/ConvertBetweenEnumAndBaseType.golden rename to hack/generator/pkg/functions/testdata/ConvertBetweenEnumAndBaseType.golden index 69d0d839e44..61ae3b5b8c4 100644 --- a/hack/generator/pkg/conversions/testdata/ConvertBetweenEnumAndBaseType.golden +++ b/hack/generator/pkg/functions/testdata/ConvertBetweenEnumAndBaseType.golden @@ -3,7 +3,7 @@ // Licensed under the MIT license. package vCurrent -import "github.com/Azure/azure-service-operator/hack/generated/_apis/Verification/vNext" +import "github.com/Azure/azure-service-operator/testing/Verification/vNext" type Person struct { Sku string `json:"sku"` diff --git a/hack/generator/pkg/conversions/testdata/ConvertBetweenEnumAndOptionalBaseType.golden b/hack/generator/pkg/functions/testdata/ConvertBetweenEnumAndOptionalBaseType.golden similarity index 89% rename from hack/generator/pkg/conversions/testdata/ConvertBetweenEnumAndOptionalBaseType.golden rename to hack/generator/pkg/functions/testdata/ConvertBetweenEnumAndOptionalBaseType.golden index 70444bfe76a..2332ab77c26 100644 --- a/hack/generator/pkg/conversions/testdata/ConvertBetweenEnumAndOptionalBaseType.golden +++ b/hack/generator/pkg/functions/testdata/ConvertBetweenEnumAndOptionalBaseType.golden @@ -3,7 +3,7 @@ // Licensed under the MIT license. package vCurrent -import "github.com/Azure/azure-service-operator/hack/generated/_apis/Verification/vNext" +import "github.com/Azure/azure-service-operator/testing/Verification/vNext" type Person struct { Sku *string `json:"sku"` diff --git a/hack/generator/pkg/conversions/testdata/ConvertBetweenOptionalAliasAndBaseType.golden b/hack/generator/pkg/functions/testdata/ConvertBetweenOptionalAliasAndBaseType.golden similarity index 89% rename from hack/generator/pkg/conversions/testdata/ConvertBetweenOptionalAliasAndBaseType.golden rename to hack/generator/pkg/functions/testdata/ConvertBetweenOptionalAliasAndBaseType.golden index d5e1f589d5e..67b34241fc6 100644 --- a/hack/generator/pkg/conversions/testdata/ConvertBetweenOptionalAliasAndBaseType.golden +++ b/hack/generator/pkg/functions/testdata/ConvertBetweenOptionalAliasAndBaseType.golden @@ -3,7 +3,7 @@ // Licensed under the MIT license. package vCurrent -import "github.com/Azure/azure-service-operator/hack/generated/_apis/Verification/vNext" +import "github.com/Azure/azure-service-operator/testing/Verification/vNext" type Person struct { Age *Age `json:"age"` diff --git a/hack/generator/pkg/conversions/testdata/ConvertBetweenOptionalAliasAndOptionalAliasType.golden b/hack/generator/pkg/functions/testdata/ConvertBetweenOptionalAliasAndOptionalAliasType.golden similarity index 90% rename from hack/generator/pkg/conversions/testdata/ConvertBetweenOptionalAliasAndOptionalAliasType.golden rename to hack/generator/pkg/functions/testdata/ConvertBetweenOptionalAliasAndOptionalAliasType.golden index bd4032276a5..577fe69d366 100644 --- a/hack/generator/pkg/conversions/testdata/ConvertBetweenOptionalAliasAndOptionalAliasType.golden +++ b/hack/generator/pkg/functions/testdata/ConvertBetweenOptionalAliasAndOptionalAliasType.golden @@ -3,7 +3,7 @@ // Licensed under the MIT license. package vCurrent -import "github.com/Azure/azure-service-operator/hack/generated/_apis/Verification/vNext" +import "github.com/Azure/azure-service-operator/testing/Verification/vNext" type Person struct { Age *Age `json:"age"` diff --git a/hack/generator/pkg/conversions/testdata/ConvertBetweenOptionalAliasAndOptionalBaseType.golden b/hack/generator/pkg/functions/testdata/ConvertBetweenOptionalAliasAndOptionalBaseType.golden similarity index 90% rename from hack/generator/pkg/conversions/testdata/ConvertBetweenOptionalAliasAndOptionalBaseType.golden rename to hack/generator/pkg/functions/testdata/ConvertBetweenOptionalAliasAndOptionalBaseType.golden index d64e5136b5b..9bcbb2f64f7 100644 --- a/hack/generator/pkg/conversions/testdata/ConvertBetweenOptionalAliasAndOptionalBaseType.golden +++ b/hack/generator/pkg/functions/testdata/ConvertBetweenOptionalAliasAndOptionalBaseType.golden @@ -3,7 +3,7 @@ // Licensed under the MIT license. package vCurrent -import "github.com/Azure/azure-service-operator/hack/generated/_apis/Verification/vNext" +import "github.com/Azure/azure-service-operator/testing/Verification/vNext" type Person struct { Age *Age `json:"age"` diff --git a/hack/generator/pkg/conversions/testdata/ConvertBetweenOptionalEnumAndBaseType.golden b/hack/generator/pkg/functions/testdata/ConvertBetweenOptionalEnumAndBaseType.golden similarity index 89% rename from hack/generator/pkg/conversions/testdata/ConvertBetweenOptionalEnumAndBaseType.golden rename to hack/generator/pkg/functions/testdata/ConvertBetweenOptionalEnumAndBaseType.golden index c1957c362c6..f1767907b27 100644 --- a/hack/generator/pkg/conversions/testdata/ConvertBetweenOptionalEnumAndBaseType.golden +++ b/hack/generator/pkg/functions/testdata/ConvertBetweenOptionalEnumAndBaseType.golden @@ -3,7 +3,7 @@ // Licensed under the MIT license. package vCurrent -import "github.com/Azure/azure-service-operator/hack/generated/_apis/Verification/vNext" +import "github.com/Azure/azure-service-operator/testing/Verification/vNext" type Person struct { Sku string `json:"sku"` diff --git a/hack/generator/pkg/conversions/testdata/ConvertBetweenOptionalEnumAndOptionalBaseType.golden b/hack/generator/pkg/functions/testdata/ConvertBetweenOptionalEnumAndOptionalBaseType.golden similarity index 90% rename from hack/generator/pkg/conversions/testdata/ConvertBetweenOptionalEnumAndOptionalBaseType.golden rename to hack/generator/pkg/functions/testdata/ConvertBetweenOptionalEnumAndOptionalBaseType.golden index 964557ba02f..bf8617fa628 100644 --- a/hack/generator/pkg/conversions/testdata/ConvertBetweenOptionalEnumAndOptionalBaseType.golden +++ b/hack/generator/pkg/functions/testdata/ConvertBetweenOptionalEnumAndOptionalBaseType.golden @@ -3,7 +3,7 @@ // Licensed under the MIT license. package vCurrent -import "github.com/Azure/azure-service-operator/hack/generated/_apis/Verification/vNext" +import "github.com/Azure/azure-service-operator/testing/Verification/vNext" type Person struct { Sku *string `json:"sku"` diff --git a/hack/generator/pkg/conversions/testdata/ConvertBetweenOptionalEnumAndOptionalEnum.golden b/hack/generator/pkg/functions/testdata/ConvertBetweenOptionalEnumAndOptionalEnum.golden similarity index 90% rename from hack/generator/pkg/conversions/testdata/ConvertBetweenOptionalEnumAndOptionalEnum.golden rename to hack/generator/pkg/functions/testdata/ConvertBetweenOptionalEnumAndOptionalEnum.golden index 8ce0f1d1501..1945fabd468 100644 --- a/hack/generator/pkg/conversions/testdata/ConvertBetweenOptionalEnumAndOptionalEnum.golden +++ b/hack/generator/pkg/functions/testdata/ConvertBetweenOptionalEnumAndOptionalEnum.golden @@ -3,7 +3,7 @@ // Licensed under the MIT license. package vCurrent -import "github.com/Azure/azure-service-operator/hack/generated/_apis/Verification/vNext" +import "github.com/Azure/azure-service-operator/testing/Verification/vNext" type Person struct { Release *Bucket `json:"release"` diff --git a/hack/generator/pkg/conversions/testdata/ConvertBetweenOptionalObjectAndOptionalObject.golden b/hack/generator/pkg/functions/testdata/ConvertBetweenOptionalObjectAndOptionalObject.golden similarity index 93% rename from hack/generator/pkg/conversions/testdata/ConvertBetweenOptionalObjectAndOptionalObject.golden rename to hack/generator/pkg/functions/testdata/ConvertBetweenOptionalObjectAndOptionalObject.golden index db934684b84..81dc5aacaca 100644 --- a/hack/generator/pkg/conversions/testdata/ConvertBetweenOptionalObjectAndOptionalObject.golden +++ b/hack/generator/pkg/functions/testdata/ConvertBetweenOptionalObjectAndOptionalObject.golden @@ -4,7 +4,7 @@ package vCurrent import ( - "github.com/Azure/azure-service-operator/hack/generated/_apis/Verification/vNext" + "github.com/Azure/azure-service-operator/testing/Verification/vNext" "github.com/pkg/errors" ) diff --git a/hack/generator/pkg/conversions/testdata/ConvertBetweenRequiredEnumAndOptionalEnum.golden b/hack/generator/pkg/functions/testdata/ConvertBetweenRequiredEnumAndOptionalEnum.golden similarity index 90% rename from hack/generator/pkg/conversions/testdata/ConvertBetweenRequiredEnumAndOptionalEnum.golden rename to hack/generator/pkg/functions/testdata/ConvertBetweenRequiredEnumAndOptionalEnum.golden index d0c8419da0d..3890d8f7342 100644 --- a/hack/generator/pkg/conversions/testdata/ConvertBetweenRequiredEnumAndOptionalEnum.golden +++ b/hack/generator/pkg/functions/testdata/ConvertBetweenRequiredEnumAndOptionalEnum.golden @@ -3,7 +3,7 @@ // Licensed under the MIT license. package vCurrent -import "github.com/Azure/azure-service-operator/hack/generated/_apis/Verification/vNext" +import "github.com/Azure/azure-service-operator/testing/Verification/vNext" type Person struct { Release Bucket `json:"release"` diff --git a/hack/generator/pkg/conversions/testdata/ConvertBetweenRequiredEnumAndRequiredEnum.golden b/hack/generator/pkg/functions/testdata/ConvertBetweenRequiredEnumAndRequiredEnum.golden similarity index 89% rename from hack/generator/pkg/conversions/testdata/ConvertBetweenRequiredEnumAndRequiredEnum.golden rename to hack/generator/pkg/functions/testdata/ConvertBetweenRequiredEnumAndRequiredEnum.golden index 02ede3be964..b5fa174fca3 100644 --- a/hack/generator/pkg/conversions/testdata/ConvertBetweenRequiredEnumAndRequiredEnum.golden +++ b/hack/generator/pkg/functions/testdata/ConvertBetweenRequiredEnumAndRequiredEnum.golden @@ -3,7 +3,7 @@ // Licensed under the MIT license. package vCurrent -import "github.com/Azure/azure-service-operator/hack/generated/_apis/Verification/vNext" +import "github.com/Azure/azure-service-operator/testing/Verification/vNext" type Person struct { Release Bucket `json:"release"` diff --git a/hack/generator/pkg/conversions/testdata/ConvertBetweenRequiredObjectAndOptionalObject.golden b/hack/generator/pkg/functions/testdata/ConvertBetweenRequiredObjectAndOptionalObject.golden similarity index 93% rename from hack/generator/pkg/conversions/testdata/ConvertBetweenRequiredObjectAndOptionalObject.golden rename to hack/generator/pkg/functions/testdata/ConvertBetweenRequiredObjectAndOptionalObject.golden index 2aa15e4cdfa..0ca2dc07510 100644 --- a/hack/generator/pkg/conversions/testdata/ConvertBetweenRequiredObjectAndOptionalObject.golden +++ b/hack/generator/pkg/functions/testdata/ConvertBetweenRequiredObjectAndOptionalObject.golden @@ -4,7 +4,7 @@ package vCurrent import ( - "github.com/Azure/azure-service-operator/hack/generated/_apis/Verification/vNext" + "github.com/Azure/azure-service-operator/testing/Verification/vNext" "github.com/pkg/errors" ) diff --git a/hack/generator/pkg/conversions/testdata/ConvertBetweenRequiredObjectAndRequiredObject.golden b/hack/generator/pkg/functions/testdata/ConvertBetweenRequiredObjectAndRequiredObject.golden similarity index 92% rename from hack/generator/pkg/conversions/testdata/ConvertBetweenRequiredObjectAndRequiredObject.golden rename to hack/generator/pkg/functions/testdata/ConvertBetweenRequiredObjectAndRequiredObject.golden index 02047794adc..9e0882666d1 100644 --- a/hack/generator/pkg/conversions/testdata/ConvertBetweenRequiredObjectAndRequiredObject.golden +++ b/hack/generator/pkg/functions/testdata/ConvertBetweenRequiredObjectAndRequiredObject.golden @@ -4,7 +4,7 @@ package vCurrent import ( - "github.com/Azure/azure-service-operator/hack/generated/_apis/Verification/vNext" + "github.com/Azure/azure-service-operator/testing/Verification/vNext" "github.com/pkg/errors" ) diff --git a/hack/generator/pkg/conversions/testdata/CopyJSONObjectProperty.golden b/hack/generator/pkg/functions/testdata/CopyJSONObjectProperty.golden similarity index 94% rename from hack/generator/pkg/conversions/testdata/CopyJSONObjectProperty.golden rename to hack/generator/pkg/functions/testdata/CopyJSONObjectProperty.golden index e7a3cae4fbe..dc98c5de34f 100644 --- a/hack/generator/pkg/conversions/testdata/CopyJSONObjectProperty.golden +++ b/hack/generator/pkg/functions/testdata/CopyJSONObjectProperty.golden @@ -4,7 +4,7 @@ package vCurrent import ( - "github.com/Azure/azure-service-operator/hack/generated/_apis/Verification/vNext" + "github.com/Azure/azure-service-operator/testing/Verification/vNext" "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" ) diff --git a/hack/generator/pkg/conversions/testdata/CopyJSONProperty.golden b/hack/generator/pkg/functions/testdata/CopyJSONProperty.golden similarity index 90% rename from hack/generator/pkg/conversions/testdata/CopyJSONProperty.golden rename to hack/generator/pkg/functions/testdata/CopyJSONProperty.golden index 70b0b3ce5b8..9909cb133ff 100644 --- a/hack/generator/pkg/conversions/testdata/CopyJSONProperty.golden +++ b/hack/generator/pkg/functions/testdata/CopyJSONProperty.golden @@ -4,7 +4,7 @@ package vCurrent import ( - "github.com/Azure/azure-service-operator/hack/generated/_apis/Verification/vNext" + "github.com/Azure/azure-service-operator/testing/Verification/vNext" "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" ) diff --git a/hack/generator/pkg/conversions/testdata/CopyKnownReferenceProperty.golden b/hack/generator/pkg/functions/testdata/CopyKnownReferenceProperty.golden similarity index 91% rename from hack/generator/pkg/conversions/testdata/CopyKnownReferenceProperty.golden rename to hack/generator/pkg/functions/testdata/CopyKnownReferenceProperty.golden index 7a2e3023cb9..a587f924393 100644 --- a/hack/generator/pkg/conversions/testdata/CopyKnownReferenceProperty.golden +++ b/hack/generator/pkg/functions/testdata/CopyKnownReferenceProperty.golden @@ -4,8 +4,8 @@ package vCurrent import ( - "github.com/Azure/azure-service-operator/hack/generated/_apis/Verification/vNext" "github.com/Azure/azure-service-operator/hack/generated/pkg/genruntime" + "github.com/Azure/azure-service-operator/testing/Verification/vNext" ) type Person struct { diff --git a/hack/generator/pkg/conversions/testdata/CopyOptionalJSONProperty.golden b/hack/generator/pkg/functions/testdata/CopyOptionalJSONProperty.golden similarity index 91% rename from hack/generator/pkg/conversions/testdata/CopyOptionalJSONProperty.golden rename to hack/generator/pkg/functions/testdata/CopyOptionalJSONProperty.golden index edde985b214..38e3e01dfaf 100644 --- a/hack/generator/pkg/conversions/testdata/CopyOptionalJSONProperty.golden +++ b/hack/generator/pkg/functions/testdata/CopyOptionalJSONProperty.golden @@ -4,7 +4,7 @@ package vCurrent import ( - "github.com/Azure/azure-service-operator/hack/generated/_apis/Verification/vNext" + "github.com/Azure/azure-service-operator/testing/Verification/vNext" "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" ) diff --git a/hack/generator/pkg/conversions/testdata/CopyReferenceProperty.golden b/hack/generator/pkg/functions/testdata/CopyReferenceProperty.golden similarity index 90% rename from hack/generator/pkg/conversions/testdata/CopyReferenceProperty.golden rename to hack/generator/pkg/functions/testdata/CopyReferenceProperty.golden index 30734259cdf..2733943c1ff 100644 --- a/hack/generator/pkg/conversions/testdata/CopyReferenceProperty.golden +++ b/hack/generator/pkg/functions/testdata/CopyReferenceProperty.golden @@ -4,8 +4,8 @@ package vCurrent import ( - "github.com/Azure/azure-service-operator/hack/generated/_apis/Verification/vNext" "github.com/Azure/azure-service-operator/hack/generated/pkg/genruntime" + "github.com/Azure/azure-service-operator/testing/Verification/vNext" ) type Person struct { diff --git a/hack/generator/pkg/conversions/testdata/NastyTest.golden b/hack/generator/pkg/functions/testdata/NastyTest.golden similarity index 95% rename from hack/generator/pkg/conversions/testdata/NastyTest.golden rename to hack/generator/pkg/functions/testdata/NastyTest.golden index 3fe1c9f1779..e0d08cc60ce 100644 --- a/hack/generator/pkg/conversions/testdata/NastyTest.golden +++ b/hack/generator/pkg/functions/testdata/NastyTest.golden @@ -3,7 +3,7 @@ // Licensed under the MIT license. package vCurrent -import "github.com/Azure/azure-service-operator/hack/generated/_apis/Verification/vNext" +import "github.com/Azure/azure-service-operator/testing/Verification/vNext" type Person struct { nasty map[string][]map[string]bool `json:"nasty"` diff --git a/hack/generator/pkg/conversions/testdata/ReadFromFunctionIntoOptionalProperty.golden b/hack/generator/pkg/functions/testdata/ReadFromFunctionIntoOptionalProperty.golden similarity index 88% rename from hack/generator/pkg/conversions/testdata/ReadFromFunctionIntoOptionalProperty.golden rename to hack/generator/pkg/functions/testdata/ReadFromFunctionIntoOptionalProperty.golden index 829d9bd4dd3..f1409131d89 100644 --- a/hack/generator/pkg/conversions/testdata/ReadFromFunctionIntoOptionalProperty.golden +++ b/hack/generator/pkg/functions/testdata/ReadFromFunctionIntoOptionalProperty.golden @@ -3,7 +3,7 @@ // Licensed under the MIT license. package vCurrent -import "github.com/Azure/azure-service-operator/hack/generated/_apis/Verification/vNext" +import "github.com/Azure/azure-service-operator/testing/Verification/vNext" type Person struct { } diff --git a/hack/generator/pkg/conversions/testdata/ReadFromFunctionIntoProperty.golden b/hack/generator/pkg/functions/testdata/ReadFromFunctionIntoProperty.golden similarity index 87% rename from hack/generator/pkg/conversions/testdata/ReadFromFunctionIntoProperty.golden rename to hack/generator/pkg/functions/testdata/ReadFromFunctionIntoProperty.golden index 2a623a4f531..5c1f65b3127 100644 --- a/hack/generator/pkg/conversions/testdata/ReadFromFunctionIntoProperty.golden +++ b/hack/generator/pkg/functions/testdata/ReadFromFunctionIntoProperty.golden @@ -3,7 +3,7 @@ // Licensed under the MIT license. package vCurrent -import "github.com/Azure/azure-service-operator/hack/generated/_apis/Verification/vNext" +import "github.com/Azure/azure-service-operator/testing/Verification/vNext" type Person struct { } diff --git a/hack/generator/pkg/conversions/testdata/SetArrayOfOptionalFromArrayOfRequired.golden b/hack/generator/pkg/functions/testdata/SetArrayOfOptionalFromArrayOfRequired.golden similarity index 92% rename from hack/generator/pkg/conversions/testdata/SetArrayOfOptionalFromArrayOfRequired.golden rename to hack/generator/pkg/functions/testdata/SetArrayOfOptionalFromArrayOfRequired.golden index 71e4d38d504..41168ceebe2 100644 --- a/hack/generator/pkg/conversions/testdata/SetArrayOfOptionalFromArrayOfRequired.golden +++ b/hack/generator/pkg/functions/testdata/SetArrayOfOptionalFromArrayOfRequired.golden @@ -3,7 +3,7 @@ // Licensed under the MIT license. package vCurrent -import "github.com/Azure/azure-service-operator/hack/generated/_apis/Verification/vNext" +import "github.com/Azure/azure-service-operator/testing/Verification/vNext" type Person struct { Scores []*int `json:"scores"` diff --git a/hack/generator/pkg/conversions/testdata/SetArrayOfRequiredFromArrayOfOptional.golden b/hack/generator/pkg/functions/testdata/SetArrayOfRequiredFromArrayOfOptional.golden similarity index 92% rename from hack/generator/pkg/conversions/testdata/SetArrayOfRequiredFromArrayOfOptional.golden rename to hack/generator/pkg/functions/testdata/SetArrayOfRequiredFromArrayOfOptional.golden index a787e7d0648..5fc3631c4ba 100644 --- a/hack/generator/pkg/conversions/testdata/SetArrayOfRequiredFromArrayOfOptional.golden +++ b/hack/generator/pkg/functions/testdata/SetArrayOfRequiredFromArrayOfOptional.golden @@ -3,7 +3,7 @@ // Licensed under the MIT license. package vCurrent -import "github.com/Azure/azure-service-operator/hack/generated/_apis/Verification/vNext" +import "github.com/Azure/azure-service-operator/testing/Verification/vNext" type Person struct { Scores []int `json:"scores"` diff --git a/hack/generator/pkg/conversions/testdata/SetArrayOfRequiredFromArrayOfRequired.golden b/hack/generator/pkg/functions/testdata/SetArrayOfRequiredFromArrayOfRequired.golden similarity index 92% rename from hack/generator/pkg/conversions/testdata/SetArrayOfRequiredFromArrayOfRequired.golden rename to hack/generator/pkg/functions/testdata/SetArrayOfRequiredFromArrayOfRequired.golden index 2a851afad6e..52d39613706 100644 --- a/hack/generator/pkg/conversions/testdata/SetArrayOfRequiredFromArrayOfRequired.golden +++ b/hack/generator/pkg/functions/testdata/SetArrayOfRequiredFromArrayOfRequired.golden @@ -3,7 +3,7 @@ // Licensed under the MIT license. package vCurrent -import "github.com/Azure/azure-service-operator/hack/generated/_apis/Verification/vNext" +import "github.com/Azure/azure-service-operator/testing/Verification/vNext" type Person struct { Scores []int `json:"scores"` diff --git a/hack/generator/pkg/conversions/testdata/SetIntFromInt.golden b/hack/generator/pkg/functions/testdata/SetIntFromInt.golden similarity index 88% rename from hack/generator/pkg/conversions/testdata/SetIntFromInt.golden rename to hack/generator/pkg/functions/testdata/SetIntFromInt.golden index ca14e06d08c..ab06a8b0559 100644 --- a/hack/generator/pkg/conversions/testdata/SetIntFromInt.golden +++ b/hack/generator/pkg/functions/testdata/SetIntFromInt.golden @@ -3,7 +3,7 @@ // Licensed under the MIT license. package vCurrent -import "github.com/Azure/azure-service-operator/hack/generated/_apis/Verification/vNext" +import "github.com/Azure/azure-service-operator/testing/Verification/vNext" type Person struct { Age int `json:"age"` diff --git a/hack/generator/pkg/conversions/testdata/SetIntFromOptionalInt.golden b/hack/generator/pkg/functions/testdata/SetIntFromOptionalInt.golden similarity index 89% rename from hack/generator/pkg/conversions/testdata/SetIntFromOptionalInt.golden rename to hack/generator/pkg/functions/testdata/SetIntFromOptionalInt.golden index d339e6cb181..d996af44844 100644 --- a/hack/generator/pkg/conversions/testdata/SetIntFromOptionalInt.golden +++ b/hack/generator/pkg/functions/testdata/SetIntFromOptionalInt.golden @@ -3,7 +3,7 @@ // Licensed under the MIT license. package vCurrent -import "github.com/Azure/azure-service-operator/hack/generated/_apis/Verification/vNext" +import "github.com/Azure/azure-service-operator/testing/Verification/vNext" type Person struct { Age int `json:"age"` diff --git a/hack/generator/pkg/conversions/testdata/SetMapOfOptionalFromMapOfRequired.golden b/hack/generator/pkg/functions/testdata/SetMapOfOptionalFromMapOfRequired.golden similarity index 93% rename from hack/generator/pkg/conversions/testdata/SetMapOfOptionalFromMapOfRequired.golden rename to hack/generator/pkg/functions/testdata/SetMapOfOptionalFromMapOfRequired.golden index 29d0a736c22..0e5568de7d7 100644 --- a/hack/generator/pkg/conversions/testdata/SetMapOfOptionalFromMapOfRequired.golden +++ b/hack/generator/pkg/functions/testdata/SetMapOfOptionalFromMapOfRequired.golden @@ -3,7 +3,7 @@ // Licensed under the MIT license. package vCurrent -import "github.com/Azure/azure-service-operator/hack/generated/_apis/Verification/vNext" +import "github.com/Azure/azure-service-operator/testing/Verification/vNext" type Person struct { Ratings map[string]*int `json:"ratings"` diff --git a/hack/generator/pkg/conversions/testdata/SetMapOfRequiredFromMapOfOptional.golden b/hack/generator/pkg/functions/testdata/SetMapOfRequiredFromMapOfOptional.golden similarity index 93% rename from hack/generator/pkg/conversions/testdata/SetMapOfRequiredFromMapOfOptional.golden rename to hack/generator/pkg/functions/testdata/SetMapOfRequiredFromMapOfOptional.golden index b6fe8bdd0af..5190f867166 100644 --- a/hack/generator/pkg/conversions/testdata/SetMapOfRequiredFromMapOfOptional.golden +++ b/hack/generator/pkg/functions/testdata/SetMapOfRequiredFromMapOfOptional.golden @@ -3,7 +3,7 @@ // Licensed under the MIT license. package vCurrent -import "github.com/Azure/azure-service-operator/hack/generated/_apis/Verification/vNext" +import "github.com/Azure/azure-service-operator/testing/Verification/vNext" type Person struct { Ratings map[string]int `json:"ratings"` diff --git a/hack/generator/pkg/conversions/testdata/SetMapOfRequiredFromMapOfRequired.golden b/hack/generator/pkg/functions/testdata/SetMapOfRequiredFromMapOfRequired.golden similarity index 92% rename from hack/generator/pkg/conversions/testdata/SetMapOfRequiredFromMapOfRequired.golden rename to hack/generator/pkg/functions/testdata/SetMapOfRequiredFromMapOfRequired.golden index e6c0f421886..849db2ba72d 100644 --- a/hack/generator/pkg/conversions/testdata/SetMapOfRequiredFromMapOfRequired.golden +++ b/hack/generator/pkg/functions/testdata/SetMapOfRequiredFromMapOfRequired.golden @@ -3,7 +3,7 @@ // Licensed under the MIT license. package vCurrent -import "github.com/Azure/azure-service-operator/hack/generated/_apis/Verification/vNext" +import "github.com/Azure/azure-service-operator/testing/Verification/vNext" type Person struct { Ratings map[string]int `json:"ratings"` diff --git a/hack/generator/pkg/conversions/testdata/SetOptionalStringFromOptionalString.golden b/hack/generator/pkg/functions/testdata/SetOptionalStringFromOptionalString.golden similarity index 90% rename from hack/generator/pkg/conversions/testdata/SetOptionalStringFromOptionalString.golden rename to hack/generator/pkg/functions/testdata/SetOptionalStringFromOptionalString.golden index d59e804cff9..acfb4ba23a7 100644 --- a/hack/generator/pkg/conversions/testdata/SetOptionalStringFromOptionalString.golden +++ b/hack/generator/pkg/functions/testdata/SetOptionalStringFromOptionalString.golden @@ -3,7 +3,7 @@ // Licensed under the MIT license. package vCurrent -import "github.com/Azure/azure-service-operator/hack/generated/_apis/Verification/vNext" +import "github.com/Azure/azure-service-operator/testing/Verification/vNext" type Person struct { Name *string `json:"name"` diff --git a/hack/generator/pkg/conversions/testdata/SetOptionalStringFromString.golden b/hack/generator/pkg/functions/testdata/SetOptionalStringFromString.golden similarity index 89% rename from hack/generator/pkg/conversions/testdata/SetOptionalStringFromString.golden rename to hack/generator/pkg/functions/testdata/SetOptionalStringFromString.golden index 9c2a9221a98..27eac305256 100644 --- a/hack/generator/pkg/conversions/testdata/SetOptionalStringFromString.golden +++ b/hack/generator/pkg/functions/testdata/SetOptionalStringFromString.golden @@ -3,7 +3,7 @@ // Licensed under the MIT license. package vCurrent -import "github.com/Azure/azure-service-operator/hack/generated/_apis/Verification/vNext" +import "github.com/Azure/azure-service-operator/testing/Verification/vNext" type Person struct { Name *string `json:"name"` diff --git a/hack/generator/pkg/conversions/testdata/SetStringFromOptionalString.golden b/hack/generator/pkg/functions/testdata/SetStringFromOptionalString.golden similarity index 89% rename from hack/generator/pkg/conversions/testdata/SetStringFromOptionalString.golden rename to hack/generator/pkg/functions/testdata/SetStringFromOptionalString.golden index f24cb2159b6..63e036814fa 100644 --- a/hack/generator/pkg/conversions/testdata/SetStringFromOptionalString.golden +++ b/hack/generator/pkg/functions/testdata/SetStringFromOptionalString.golden @@ -3,7 +3,7 @@ // Licensed under the MIT license. package vCurrent -import "github.com/Azure/azure-service-operator/hack/generated/_apis/Verification/vNext" +import "github.com/Azure/azure-service-operator/testing/Verification/vNext" type Person struct { Name string `json:"name"` diff --git a/hack/generator/pkg/conversions/testdata/SetStringFromString.golden b/hack/generator/pkg/functions/testdata/SetStringFromString.golden similarity index 88% rename from hack/generator/pkg/conversions/testdata/SetStringFromString.golden rename to hack/generator/pkg/functions/testdata/SetStringFromString.golden index 134c507b0d3..363a0a3b18a 100644 --- a/hack/generator/pkg/conversions/testdata/SetStringFromString.golden +++ b/hack/generator/pkg/functions/testdata/SetStringFromString.golden @@ -3,7 +3,7 @@ // Licensed under the MIT license. package vCurrent -import "github.com/Azure/azure-service-operator/hack/generated/_apis/Verification/vNext" +import "github.com/Azure/azure-service-operator/testing/Verification/vNext" type Person struct { Name string `json:"name"`