diff --git a/hack/generator/pkg/astmodel/interface_injector.go b/hack/generator/pkg/astmodel/interface_injector.go index 4ced81de380..807b4b4831d 100644 --- a/hack/generator/pkg/astmodel/interface_injector.go +++ b/hack/generator/pkg/astmodel/interface_injector.go @@ -24,8 +24,8 @@ func NewInterfaceInjector() *InterfaceInjector { } // Inject modifies the passed type definition by injecting the passed function -func (fi *InterfaceInjector) Inject(def TypeDefinition, implementation *InterfaceImplementation) (TypeDefinition, error) { - result, err := fi.visitor.VisitDefinition(def, implementation) +func (i *InterfaceInjector) Inject(def TypeDefinition, implementation *InterfaceImplementation) (TypeDefinition, error) { + result, err := i.visitor.VisitDefinition(def, implementation) if err != nil { return TypeDefinition{}, err } @@ -34,7 +34,7 @@ func (fi *InterfaceInjector) Inject(def TypeDefinition, implementation *Interfac // injectFunctionIntoObject takes the function provided as a context and includes it on the // provided object type -func (_ *InterfaceInjector) injectInterfaceIntoObject( +func (i *InterfaceInjector) injectInterfaceIntoObject( _ *TypeVisitor, ot *ObjectType, ctx interface{}) (Type, error) { implementation := ctx.(*InterfaceImplementation) return ot.WithInterface(implementation), nil @@ -42,7 +42,7 @@ func (_ *InterfaceInjector) injectInterfaceIntoObject( // injectFunctionIntoResource takes the function provided as a context and includes it on the // provided resource type -func (_ *InterfaceInjector) injectInterfaceIntoResource( +func (i *InterfaceInjector) injectInterfaceIntoResource( _ *TypeVisitor, rt *ResourceType, ctx interface{}) (Type, error) { fn := ctx.(*InterfaceImplementation) return rt.WithInterface(fn), nil diff --git a/hack/generator/pkg/codegen/pipeline/implement_convertible_interface.go b/hack/generator/pkg/codegen/pipeline/implement_convertible_interface.go index bdf7acf4d4e..bb087c137f0 100644 --- a/hack/generator/pkg/codegen/pipeline/implement_convertible_interface.go +++ b/hack/generator/pkg/codegen/pipeline/implement_convertible_interface.go @@ -62,6 +62,10 @@ func ImplementConvertibleInterface(idFactory astmodel.IdentifierFactory) Stage { return stage } +// createConvertibleInterfaceImplementation creates the required implementation of conversion.Convertible, ready for +// injection onto the resource. The ConvertTo() and ConvertFrom() methods chain the required conversion between resource +// versions, but are dependent upon previously injected AssignPropertiesTo() and AssignPropertiesFrom() methods to +// actually copy information across. See resource_conversion_function.go for more information. func createConvertibleInterfaceImplementation( name astmodel.TypeName, resource *astmodel.ResourceType, @@ -78,4 +82,4 @@ func createConvertibleInterfaceImplementation( } return astmodel.NewInterfaceImplementation(astmodel.ConvertibleInterface, conversionFunctions...) -} \ No newline at end of file +} diff --git a/hack/generator/pkg/codegen/pipeline/implement_convertible_interface_test.go b/hack/generator/pkg/codegen/pipeline/implement_convertible_interface_test.go index 731c0764d94..834a815505c 100644 --- a/hack/generator/pkg/codegen/pipeline/implement_convertible_interface_test.go +++ b/hack/generator/pkg/codegen/pipeline/implement_convertible_interface_test.go @@ -15,6 +15,8 @@ import ( "github.com/Azure/azure-service-operator/hack/generator/pkg/test" ) +// TestInjectConvertibleInterface checks that the pipeline stage does what we expect when run in relative isolation, +// with only a few expected (and closely reated) stages in operation func TestInjectConvertibleInterface(t *testing.T) { g := NewGomegaWithT(t)