Skip to content

Commit

Permalink
Move HubConversionFunction into functions folder
Browse files Browse the repository at this point in the history
  • Loading branch information
theunrepentantgeek committed Jun 27, 2021
1 parent 8d5ea47 commit 632f9a5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions hack/generator/pkg/codegen/storage/storage_type_factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,8 @@ func (f *StorageTypeFactory) injectConversionsBetween(
// TODO: Make this work when types are discontinued
hubType := astmodel.MakeTypeName(f.hubPackage, upstreamName.Name())

convertFromFn := conversions.NewConversionFromHubFunction(hubType, assignFromFn.OtherType(), assignFromFn.Name(), f.idFactory)
convertToFn := conversions.NewConversionToHubFunction(hubType, assignToFn.OtherType(), assignToFn.Name(), f.idFactory)
convertFromFn := functions.NewConversionFromHubFunction(hubType, assignFromFn.OtherType(), assignFromFn.Name(), f.idFactory)
convertToFn := functions.NewConversionToHubFunction(hubType, assignToFn.OtherType(), assignToFn.Name(), f.idFactory)

convertibleImplementation := astmodel.NewInterfaceImplementation(astmodel.ConvertibleInterface, convertFromFn, convertToFn)

Expand Down
9 changes: 5 additions & 4 deletions hack/generator/pkg/functions/hub_conversion_function.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the MIT license.
*/

package conversions
package functions

import (
"fmt"
Expand All @@ -13,6 +13,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"
)

// HubConversionFunction implements conversions to/from our hub type
Expand All @@ -21,7 +22,7 @@ type HubConversionFunction struct {
// hub is the TypeName of the canonical hub type, the final target or original source for conversion
hub astmodel.TypeName
// direction specifies whether we are converting to the hub type, or from it
direction Direction
direction conversions.Direction
// propertyFunctionName is the name of the function we call to copy properties across
propertyFunctionName string
// intermediateType is the TypeName of an intermediate type we use as part of a multiple step conversion
Expand All @@ -42,7 +43,7 @@ func NewConversionToHubFunction(
idFactory astmodel.IdentifierFactory) *HubConversionFunction {
result := &HubConversionFunction{
hub: hub,
direction: ConvertTo,
direction: conversions.ConvertTo,
propertyFunctionName: propertyFunctionName,
idFactory: idFactory,
}
Expand All @@ -62,7 +63,7 @@ func NewConversionFromHubFunction(
idFactory astmodel.IdentifierFactory) *HubConversionFunction {
result := &HubConversionFunction{
hub: hub,
direction: ConvertFrom,
direction: conversions.ConvertFrom,
propertyFunctionName: propertyFunctionName,
idFactory: idFactory,
}
Expand Down

0 comments on commit 632f9a5

Please sign in to comment.