Skip to content

Commit

Permalink
Make it explicit that we inject OriginalVersion() before creating sto…
Browse files Browse the repository at this point in the history
…rate types
  • Loading branch information
theunrepentantgeek committed Jul 7, 2021
1 parent 59d8dbc commit 3be33df
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
4 changes: 2 additions & 2 deletions hack/generator/pkg/codegen/pipeline/create_storage_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ import (
"github.com/Azure/azure-service-operator/hack/generator/pkg/codegen/storage"
)

const createStorageTypesStageId = "createStorageTypes"
const CreateStorageTypesStageId = "createStorageTypes"

// CreateStorageTypes returns a pipeline stage that creates dedicated storage types for each resource and nested object.
// Storage versions are created for *all* API versions to allow users of older versions of the operator to easily
// upgrade. This is of course a bit odd for the first release, but defining the approach from day one is useful.
func CreateStorageTypes(conversionGraph *storage.ConversionGraph) Stage {
result := MakeStage(
createStorageTypesStageId,
CreateStorageTypesStageId,
"Create storage versions of CRD types",
func(ctx context.Context, types astmodel.Types) (astmodel.Types, error) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ const injectOriginalVersionFunctionStageId = "injectOriginalVersionFunction"
// InjectOriginalVersionFunction injects the function OriginalVersion() into each Spec type
// This function allows us to recover the original version used to create each custom resource, giving the operator the
// information needed to interact with ARM using the correct API version.
// We run this stage before we create any storage types, ensuring only API versions get the function.
func InjectOriginalVersionFunction(idFactory astmodel.IdentifierFactory) Stage {

return MakeStage(
stage := MakeStage(
injectOriginalVersionFunctionStageId,
"Inject the function OriginalVersion() into each Spec type",
func(ctx context.Context, types astmodel.Types) (astmodel.Types, error) {
Expand All @@ -43,4 +44,7 @@ func InjectOriginalVersionFunction(idFactory astmodel.IdentifierFactory) Stage {

return result, nil
})

stage.RequiresPostrequisiteStages(CreateStorageTypesStageId, InjectOriginalVersionPropertyId)
return stage
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import (
"github.com/Azure/azure-service-operator/hack/generator/pkg/codegen/storage"
)

// injectOriginalVersionPropertyId is the unique identifier for this pipeline stage
const injectOriginalVersionPropertyId = "injectOriginalVersionProperty"
// InjectOriginalVersionPropertyId is the unique identifier for this pipeline stage
const InjectOriginalVersionPropertyId = "injectOriginalVersionProperty"

// InjectOriginalVersionProperty injects the property OriginalVersion into each Storage Spec type
// This property gets populated by reading from the OriginalVersion() function previously injected into the API Spec
Expand All @@ -24,7 +24,7 @@ const injectOriginalVersionPropertyId = "injectOriginalVersionProperty"
func InjectOriginalVersionProperty() Stage {

stage := MakeStage(
injectOriginalVersionPropertyId,
InjectOriginalVersionPropertyId,
"Inject the property OriginalVersion into each Storage Spec type",
func(ctx context.Context, types astmodel.Types) (astmodel.Types, error) {
injector := storage.NewPropertyInjector()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func InjectPropertyAssignmentFunctions(graph *storage.ConversionGraph, idFactory
})

// Needed to populate the conversion graph
stage.RequiresPrerequisiteStages(createStorageTypesStageId)
stage.RequiresPrerequisiteStages(CreateStorageTypesStageId)
return stage
}

Expand Down

0 comments on commit 3be33df

Please sign in to comment.