pipeline

package
v0.0.0-...-8a43960 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 29, 2024 License: MIT Imports: 45 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ARMIDPropertyClassificationUnset       = ARMIDPropertyClassification("unset")
	ARMIDPropertyClassificationSet         = ARMIDPropertyClassification("set")
	ARMIDPropertyClassificationUnspecified = ARMIDPropertyClassification("unspecified")
)
View Source
const AddAPIVersionEnumsStageId = "add-api-version-enums"
View Source
const AddConfigMapsStageID = "addConfigMaps"

AddConfigMapsStageID is the unique identifier for this pipeline stage

View Source
const AddKubernetesExporterStageID = "addKubernetesExporter"
View Source
const AddLocatableInterfaceStageID = "addLocatableInterface"
View Source
const AddOperatorSpecStageID = "addOperatorSpec"
View Source
const AddSecretsStageID = "addSecrets"

AddSecretsStageID is the unique identifier for this pipeline stage

View Source
const AddSerializationTypeTagStageID = "addSerializationTypeTag"
View Source
const AddStatusConditionsStageID = "addStatusConditions"
View Source
const ApplyARMConversionInterfaceStageID = "applyArmConversionInterface"

ApplyARMConversionInterfaceStageID is the unique identifier of this pipeline stage

View Source
const ApplyCrossResourceReferencesFromConfigStageID = "applyCrossResourceReferencesFromConfig"

ApplyCrossResourceReferencesFromConfigStageID is the unique identifier for this pipeline stage

View Source
const ApplyDefaulterAndValidatorInterfaceStageID = "applyDefaulterAndValidatorInterfaces"
View Source
const ApplyExportFiltersStageID = "filterTypes"
View Source
const ApplyKubernetesResourceInterfaceStageID = "applyKubernetesResourceInterface"
View Source
const AssembleOneOfTypesID = "assembleOneOfTypes"
View Source
const CheckForAnyTypeStageID = "rogueCheck"

CheckForAnyTypeStageID is the unique identifier for this stage

View Source
const CollapseCrossGroupReferencesStageID = "collapseCrossGroupReferences"

CollapseCrossGroupReferencesStageID is the unique identifier for this pipeline stage

View Source
const CreateARMTypesStageID = "createArmTypes"

CreateARMTypesStageID is the unique identifier for this pipeline stage

View Source
const CreateConversionGraphStageId = "createConversionGraph"

CreateConversionGraphStageId is the unique identifier for this stage

View Source
const (
	CreateResourceExtensionsStageID = "createResourceExtensions"
)

CreateResourceExtensionsStageID is the unique identifier of this stage

View Source
const CreateStorageTypesStageID = "createStorageTypes"
View Source
const DeleteGeneratedCodeStageID = "deleteGenerated"

DeleteGeneratedCodeStageID is the unique identifier of this stage

View Source
const DetermineResourceOwnershipStageId = "determineResourceOwnership"
View Source
const ExportPackagesStageID = "exportPackages"

ExportPackagesStageID is the unique identifier for this pipeline stage

View Source
const FixOptionalCollectionAliasesStageId = "fixOptionalCollectionAliases"
View Source
const FlattenPropertiesStageId = "flattenProperties"
View Source
const HandleUserAssignedIdentitiesStageID = "handleUserAssignedIdentities"
View Source
const ImplementConvertibleInterfaceStageId = "implementConvertibleInterface"

ImplementConvertibleInterfaceStageId is the unique identifier for this pipeline stage

View Source
const ImplementConvertibleSpecInterfaceStageId = "implementConvertibleSpecInterface"

ImplementConvertibleSpecInterfaceStageId is the unique identifier for this pipeline stage

View Source
const ImplementConvertibleStatusInterfaceStageId = "implementConvertibleStatusInterface"

ImplementConvertibleStatusInterfaceStageId is the unique identifier for this pipeline stage

View Source
const ImplementImportableResourceInterfaceStageID = "implementImportableResourceInterface"
View Source
const ImprovePropertyDescriptionsStageId = "improvePropertyDescriptions"

ImprovePropertyDescriptionsStageId is the unique identifier for this pipeline stage

View Source
const InjectHubFunctionStageID = "injectHubFunction"

InjectHubFunctionStageID is the unique identifier for this pipeline stage

View Source
const InjectJsonSerializationTestsID = "injectJSONTestCases"

InjectJsonSerializationTestsID is the unique identifier for this pipeline stage

View Source
const InjectOriginalGVKFunctionStageID = "injectOriginalGVKFunction"

InjectOriginalGVKFunctionStageID is the unique identifier for this pipeline stage

View Source
const InjectOriginalVersionFunctionStageID = "injectOriginalVersionFunction"

InjectOriginalVersionFunctionStageID is the unique identifier for this pipeline stage

View Source
const InjectOriginalVersionPropertyStageID = "injectOriginalVersionProperty"

InjectOriginalVersionPropertyStageID is the unique identifier for this pipeline stage

View Source
const InjectPropertyAssignmentFunctionsStageID = "injectPropertyAssignmentFunctions"

InjectPropertyAssignmentFunctionsStageID is the unique identifier for this pipeline stage

View Source
const InjectPropertyAssignmentTestsID = "injectPropertyAssignmentTestCases"

InjectPropertyAssignmentTestsID is the unique identifier for this stage

View Source
const InjectResourceConversionTestsID = "injectResourceConversionTestCases"

InjectResourceConversionTestsID is the unique identifier for this stage

View Source
const InjectSpecInitializationFunctionsStageID = "injectSpecInitializationFunctions"

InjectSpecInitializationFunctionsStageID is the unique identifier for this pipeline stage

View Source
const LoadTypesStageID = "loadTypes"
View Source
const MakeOneOfDiscriminantRequiredStageId = "makeOneOfDiscriminantRequired"

MakeOneOfDiscriminantRequiredStageId is the unique identifier for this pipeline stage

View Source
const MakeStatusPropertiesOptionalStageID = "makeStatusPropertiesOptional"
View Source
const MarkLatestAPIVersionAsStorageVersionId = "markStorageVersion"

MarkLatestAPIVersionAsStorageVersionId is the unique identifier for this pipeline stage

View Source
const MarkLatestStorageVariantAsHubVersionID = "markLatestStorageVariantAsHubVersion"

MarkLatestStorageVariantAsHubVersionID is the unique identifier for this pipeline stage

View Source
const PruneResourcesWithLifecycleOwnedByParentStageID = "pruneResourcesWithLifecycleOwnedByParentStage"

PruneResourcesWithLifecycleOwnedByParentStageID is the unique identifier for this pipeline stage

View Source
const RemoveEmbeddedResourcesStageID = "removeEmbeddedResources"

RemoveEmbeddedResourcesStageID is the unique identifier for this pipeline stage

View Source
const RemoveEmptyObjectsStageId = "removeEmptyObjects"
View Source
const RemoveStatusPropertyValidationsStageID = "removeStatusPropertyValidation"
View Source
const RemoveTypeAliasesStageID = "removeAliases"

RemoveTypeAliasesStageID is the unique identifier for this pipeline stage

View Source
const RenamePropertiesStageID = "renameProperties"

RenamePropertiesStageID is the unique identifier for this pipeline stage

View Source
const RepairSkippingPropertiesStageID = "repairSkippingProperties"
View Source
const ReportOnTypesAndVersionsStageID = "reportTypesAndVersions"

ReportOnTypesAndVersionsStageID is the unique identifier of this stage

View Source
const ReportResourceStructureStageId = "reportResourceStructure"

ReportResourceStructureStageId is the unique identifier for this stage

View Source
const (
	// ReportResourceVersionsStageID is the unique identifier of this stage
	ReportResourceVersionsStageID = "reportResourceVersions"
)
View Source
const SimplifyDefinitionsStageId = "simplifyDefinitions"
View Source
const StripUnreferencedTypeDefinitionsStageID = "stripUnreferenced"

StripUnreferencedTypeDefinitionsStageID is the unique identifier for this pipeline stage

View Source
const TransformCrossResourceReferencesStageID = "transformCrossResourceReferences"

TransformCrossResourceReferencesStageID is the unique identifier for this pipeline stage

View Source
const TransformCrossResourceReferencesToStringStageID = "transformCrossResourceReferencesToString"

TransformCrossResourceReferencesToStringStageID is the unique identifier for this pipeline stage

View Source
const (
	TransformValidatedFloatsStageID = "transformValidatedFloats"
)

TransformValidatedFloatsStageID is the unique identifier of this stage

View Source
const UnrollRecursiveTypesStageID = "unrollRecursiveTypes"
View Source
const UserAssignedIdentityTypeDescription = "Information about the user assigned identity for the resource"
View Source
const VerifyNoErroredTypesStageID = "verifyNoErroredTypes"

Variables

View Source
var CrossplaneRuntimeV1Package = astmodel.MakeExternalPackageReference("github.com/crossplane/crossplane-runtime/apis/common/v1")

Functions

func CreatePackagesForDefinitions

func CreatePackagesForDefinitions(
	definitions astmodel.TypeDefinitionSet,
) (map[astmodel.InternalPackageReference]*astmodel.PackageDefinition, error)

CreatePackagesForDefinitions groups type definitions into packages

func DoesPropertyLookLikeARMReference

func DoesPropertyLookLikeARMReference(prop *astmodel.PropertyDefinition) bool

DoesPropertyLookLikeARMReference uses a simple heuristic to determine if a property looks like it might be an ARM reference. This can be used for logging/reporting purposes to discover references which we missed.

func GetARMTypeDefinition

GetARMTypeDefinition gets the ARM type definition for a given Kubernetes type name. If no matching definition can be found an error is returned.

func MarkLatestResourceVersionsForStorage

func MarkLatestResourceVersionsForStorage(definitions astmodel.TypeDefinitionSet) (astmodel.TypeDefinitionSet, error)

MarkLatestResourceVersionsForStorage marks the latest version of each resource as the storage version

func NewConditionerInterfaceImpl

func NewConditionerInterfaceImpl(
	idFactory astmodel.IdentifierFactory,
	resource *astmodel.ResourceType,
) (*astmodel.InterfaceImplementation, error)

NewConditionerInterfaceImpl creates an InterfaceImplementation with GetConditions() and SetConditions() methods, implementing the genruntime.Conditioner interface.

func NewValidateConfigMapDestinationsFunction

func NewValidateConfigMapDestinationsFunction(resource *astmodel.ResourceType, idFactory astmodel.IdentifierFactory) *functions.ResourceFunction

func NewValidateSecretDestinationsFunction

func NewValidateSecretDestinationsFunction(resource *astmodel.ResourceType, idFactory astmodel.IdentifierFactory) *functions.ResourceFunction

func StripUnusedDefinitions

func StripUnusedDefinitions(
	roots astmodel.TypeNameSet,
	defs astmodel.TypeDefinitionSet,
) (astmodel.TypeDefinitionSet, error)

StripUnusedDefinitions removes all types that aren't in roots or referred to by the types in roots, for example types that are generated as a byproduct of an allOf element.

Types

type ARMIDPropertyClassification

type ARMIDPropertyClassification string

type ARMIDPropertyTypeVisitor

type ARMIDPropertyTypeVisitor struct {
	astmodel.TypeVisitor[astmodel.InternalTypeName]
	// contains filtered or unexported fields
}

func MakeARMIDPropertyTypeVisitor

func MakeARMIDPropertyTypeVisitor(
	referenceChecker crossResourceReferenceChecker,
	log logr.Logger,
) ARMIDPropertyTypeVisitor

type ARMIDToGenruntimeReferenceTypeVisitor

type ARMIDToGenruntimeReferenceTypeVisitor struct {
	astmodel.TypeVisitor[astmodel.InternalTypeName]
	// contains filtered or unexported fields
}

type DebugSettings

type DebugSettings struct {
	// contains filtered or unexported fields
}

func NewDebugSettings

func NewDebugSettings(groupSelector string, outputFolder string) *DebugSettings

NewDebugSettings creates a new DebugSettings.

func (*DebugSettings) CreateFileName

func (dr *DebugSettings) CreateFileName(name string) string

createFileName creates the filename for the debug report from the name of the stage, filtering out any characters that are unsafe in filenames

func (*DebugSettings) MatchesGroup

func (ds *DebugSettings) MatchesGroup(ref astmodel.InternalPackageReference) bool

MatchesGroup returns true if the InternalPackageReference matches the groupSelector.

type DiagnosticAction

type DiagnosticAction func(settings *DebugSettings, index int, state *State) error

type ExportedProperties

type ExportedProperties = map[string][]*astmodel.PropertyDefinition

ExportedProperties is a map of string property name to a chain of properties. For allowing the export of a property "foo" that writes the status.a.b.c property to a config map would be "foo" -> []{status, a, b, c}

type ExportedTypeNameProperties

type ExportedTypeNameProperties struct {
	// contains filtered or unexported fields
}

func NewExportedTypeNameProperties

func NewExportedTypeNameProperties() *ExportedTypeNameProperties

func (*ExportedTypeNameProperties) Add

func (*ExportedTypeNameProperties) Copy

func (*ExportedTypeNameProperties) Get

type PackagesMatrixReport

type PackagesMatrixReport struct {
	// contains filtered or unexported fields
}

func NewPackagesMatrixReport

func NewPackagesMatrixReport() *PackagesMatrixReport

func (*PackagesMatrixReport) ServiceName

func (*PackagesMatrixReport) Summarize

func (report *PackagesMatrixReport) Summarize(definitions astmodel.TypeDefinitionSet)

func (*PackagesMatrixReport) WriteTableTo

func (report *PackagesMatrixReport) WriteTableTo(table *reporting.SparseTable, pkg string, outputPath string) error

func (*PackagesMatrixReport) WriteTo

func (report *PackagesMatrixReport) WriteTo(outputPath string) error

type PayloadTypeDetails

type PayloadTypeDetails struct {
	// contains filtered or unexported fields
}

type PipelineDiagram

type PipelineDiagram struct {
	// contains filtered or unexported fields
}

func NewPipelineDiagram

func NewPipelineDiagram(settings *DebugSettings) *PipelineDiagram

NewPipelineDiagram creates a new PipelineDiagram to write into the specified directory.

func (*PipelineDiagram) WriteDiagram

func (diagram *PipelineDiagram) WriteDiagram(stages []*Stage) error

WriteDiagram writes a diagram of the pipeline to pipeline.dot

type ResourceRegistrationFile

type ResourceRegistrationFile struct {
	// contains filtered or unexported fields
}

ResourceRegistrationFile is a file containing functions that assist in registering resources with a Kubernetes scheme.

func NewResourceRegistrationFile

func NewResourceRegistrationFile(
	resources []astmodel.InternalTypeName,
	storageVersionResources []astmodel.InternalTypeName,
	indexFunctions map[astmodel.InternalTypeName][]*functions.IndexRegistrationFunction,
	secretPropertyKeys map[astmodel.InternalTypeName][]string,
	configMapPropertyKeys map[astmodel.InternalTypeName][]string,
	resourceExtensions []astmodel.InternalTypeName,
) *ResourceRegistrationFile

NewResourceRegistrationFile returns a ResourceRegistrationFile for registering the specified resources with a controller

func (*ResourceRegistrationFile) AsAst

func (r *ResourceRegistrationFile) AsAst() (*dst.File, error)

AsAst returns this file as a Go AST.

type ResourceStructureReport

type ResourceStructureReport struct {
	// contains filtered or unexported fields
}

func (*ResourceStructureReport) SaveReports

func (report *ResourceStructureReport) SaveReports(baseFolder string) error

SaveReports writes the reports to the specified files

type ResourceVersionsReport

type ResourceVersionsReport struct {
	// contains filtered or unexported fields
}

func NewResourceVersionsReport

func NewResourceVersionsReport(
	definitions astmodel.TypeDefinitionSet,
	cfg *config.Configuration,
) (*ResourceVersionsReport, error)
func (report *ResourceVersionsReport) FindSampleLinks(group string) (map[string]string, error)

func (*ResourceVersionsReport) SaveAllResourcesReportTo

func (report *ResourceVersionsReport) SaveAllResourcesReportTo(outputFile string) error

SaveAllResourcesReportTo creates a file containing a report listing all supported resources outputFile is the path to the file to create

func (*ResourceVersionsReport) SaveGroupResourcesReportTo

func (report *ResourceVersionsReport) SaveGroupResourcesReportTo(group string, outputFile string) error

SaveGroupResourcesReportTo creates a file containing a report listing supported resources in the specified group. group identifies the set of resources to include. outputFile is the path to the file to create.

func (*ResourceVersionsReport) WriteAllResourcesReportToBuffer

func (report *ResourceVersionsReport) WriteAllResourcesReportToBuffer(
	frontMatter string,
	buffer *strings.Builder,
) error

WriteAllResourcesReportToBuffer creates the report in the provided buffer

func (*ResourceVersionsReport) WriteGroupResourcesReportToBuffer

func (report *ResourceVersionsReport) WriteGroupResourcesReportToBuffer(
	group string,
	frontMatter string,
	buffer *strings.Builder,
) error

WriteGroupResourcesReportToBuffer creates the report in the provided buffer

type ResourceVersionsReportGroupInfo

type ResourceVersionsReportGroupInfo struct {
	Group    string
	Provider string
	Title    string
}

type ResourceVersionsReportResourceItem

type ResourceVersionsReportResourceItem struct {
	// contains filtered or unexported fields
}

type Stage

type Stage struct {
	// contains filtered or unexported fields
}

Stage represents a composable stage of processing that can transform or process the set of generated types

func AddAPIVersionEnums

func AddAPIVersionEnums() *Stage

func AddConfigMaps

func AddConfigMaps(config *config.Configuration) *Stage

AddConfigMaps replaces properties flagged as a config map with genruntime.ConfigMapReference or genruntime.OptionalConfigMapReference

func AddCrossplaneAtProvider

func AddCrossplaneAtProvider(idFactory astmodel.IdentifierFactory) *Stage

AddCrossplaneAtProvider adds an "AtProvider" property as the sole property in every resource status

func AddCrossplaneEmbeddedResourceSpec

func AddCrossplaneEmbeddedResourceSpec(idFactory astmodel.IdentifierFactory) *Stage

AddCrossplaneEmbeddedResourceSpec puts an embedded runtimev1alpha1.ResourceSpec on every spec type

func AddCrossplaneEmbeddedResourceStatus

func AddCrossplaneEmbeddedResourceStatus(idFactory astmodel.IdentifierFactory) *Stage

AddCrossplaneEmbeddedResourceStatus puts an embedded runtimev1alpha1.ResourceStatus on every spec type

func AddCrossplaneForProvider

func AddCrossplaneForProvider(idFactory astmodel.IdentifierFactory) *Stage

AddCrossplaneForProvider adds a "ForProvider" property as the sole property in every resource spec and moves everything that was at the spec level down a level into the ForProvider type

func AddCrossplaneOwnerProperties

func AddCrossplaneOwnerProperties(idFactory astmodel.IdentifierFactory) *Stage

AddCrossplaneOwnerProperties adds the 3-tuple of (xName, xNameRef, xNameSelector) for each owning resource

func AddKubernetesExporter

func AddKubernetesExporter(idFactory astmodel.IdentifierFactory) *Stage

func AddLocatableInterface

func AddLocatableInterface(idFactory astmodel.IdentifierFactory) *Stage

func AddOperatorSpec

func AddOperatorSpec(configuration *config.Configuration, idFactory astmodel.IdentifierFactory) *Stage

func AddSecrets

func AddSecrets(config *config.Configuration) *Stage

AddSecrets replaces properties flagged as secret with genruntime.SecretReference

func AddSerializationTypeTag

func AddSerializationTypeTag(configuration *config.Configuration) *Stage

AddSerializationTypeTag adds a property tag to properties with special serialization instructions to initialize empty collections when serializing the payload to Azure. This uses a property tag for a few reasons:

  1. Some types are flattened and other approaches are easily lost when flattening occurs. Putting the tag onto the property preserves it even through flattening.
  2. In many ways this behavior is like an augmented `json:omitempty`, so it (IMO) makes sense to have a tag just like for JSON. It makes it clearer when looking at the Go object that the serialization behavior of these fields is special.

func AddStatusConditions

func AddStatusConditions(idFactory astmodel.IdentifierFactory) *Stage

func ApplyARMConversionInterface

func ApplyARMConversionInterface(idFactory astmodel.IdentifierFactory, config *config.ObjectModelConfiguration) *Stage

ApplyARMConversionInterface adds the genruntime.ARMTransformer interface and the Owner property to all Kubernetes types. The genruntime.ARMTransformer interface is used to convert from the Kubernetes type to the corresponding ARM type and back.

func ApplyCrossResourceReferencesFromConfig

func ApplyCrossResourceReferencesFromConfig(
	configuration *config.Configuration,
	log logr.Logger,
) *Stage

ApplyCrossResourceReferencesFromConfig replaces cross resource references from the configuration with astmodel.ARMID.

func ApplyDefaulterAndValidatorInterfaces

func ApplyDefaulterAndValidatorInterfaces(configuration *config.Configuration, idFactory astmodel.IdentifierFactory) *Stage

ApplyDefaulterAndValidatorInterfaces add the admission.Defaulter and admission.Validator interfaces to each resource that requires them

func ApplyExportFilters

func ApplyExportFilters(
	configuration *config.Configuration,
	log logr.Logger,
) *Stage

ApplyExportFilters creates a Stage to reduce our set of types for export

func ApplyIsResourceOverrides

func ApplyIsResourceOverrides(configuration *config.Configuration) *Stage

func ApplyKubernetesResourceInterface

func ApplyKubernetesResourceInterface(
	idFactory astmodel.IdentifierFactory,
	log logr.Logger,
) *Stage

ApplyKubernetesResourceInterface ensures that every Resource implements the KubernetesResource interface

func ApplyTypeRewrites

func ApplyTypeRewrites(
	config *config.Configuration,
	log logr.Logger,
) *Stage

ApplyTypeRewrites applies any typeTransformers.

func AssembleOneOfTypes

func AssembleOneOfTypes(idFactory astmodel.IdentifierFactory) *Stage

func AssertTypesCollectionValid

func AssertTypesCollectionValid() *Stage

AssertTypesCollectionValid creates a Stage that ensures that each reachable type in the types collection has TypeName's that are all reachable as well. This check fails if there is any TypeName that refers to a type that doesn't exist.

func CollapseCrossGroupReferences

func CollapseCrossGroupReferences(idFactory astmodel.IdentifierFactory) *Stage

CollapseCrossGroupReferences finds and removes references between API groups. This isn't particularly common but does occur in a few instances, for example from Microsoft.Compute -> Microsoft.Compute.Extensions.

func ConvertAllOfAndOneOfToObjects

func ConvertAllOfAndOneOfToObjects(idFactory astmodel.IdentifierFactory) *Stage

ConvertAllOfAndOneOfToObjects reduces the AllOfType and OneOfType to ObjectType

func CreateARMTypes

func CreateARMTypes(
	configuration *config.ObjectModelConfiguration,
	idFactory astmodel.IdentifierFactory,
	log logr.Logger,
) *Stage

CreateARMTypes walks the type graph and builds new types for communicating with ARM

func CreateConversionGraph

func CreateConversionGraph(
	configuration *config.Configuration,
	generatorPrefix string,
) *Stage

CreateConversionGraph walks the set of available types and creates a graph of conversions that will be used to convert resources to/from the designated storage (or hub) version

func CreateResourceExtensions

func CreateResourceExtensions(localPath string, idFactory astmodel.IdentifierFactory) *Stage

func CreateStorageTypes

func CreateStorageTypes() *Stage

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 DeleteGeneratedCode

func DeleteGeneratedCode(outputFolder string) *Stage

DeleteGeneratedCode creates a pipeline stage for cleanup of our output folder prior to generating files

func DetermineResourceOwnership

func DetermineResourceOwnership(
	configuration *config.Configuration,
) *Stage

func EnsureARMTypeExistsForEveryResource

func EnsureARMTypeExistsForEveryResource() *Stage

TODO: Wondering if we should have an even stronger version of this that asserts it for all types rather than just the top level? EnsureARMTypeExistsForEveryResource performs a check ensuring that every Kubernetes resource spec/status has a corresponding ARM type

func EnsureDefinitionsDoNotUseAnyTypes

func EnsureDefinitionsDoNotUseAnyTypes() *Stage

EnsureDefinitionsDoNotUseAnyTypes returns a stage that will check for any definitions containing AnyTypes. The stage will return errors for each type found that uses an AnyType.

func ExportControllerResourceRegistrations

func ExportControllerResourceRegistrations(idFactory astmodel.IdentifierFactory, outputPath string) *Stage

ExportControllerResourceRegistrations creates a Stage to generate type registrations for resources.

func ExportPackages

func ExportPackages(
	outputPath string,
	emitDocFiles bool,
	log logr.Logger,
) *Stage

ExportPackages creates a Stage to export our generated code as a set of packages

func FilterOutDefinitionsUsingAnyType

func FilterOutDefinitionsUsingAnyType(packages []string) *Stage

FilterOutDefinitionsUsingAnyType returns a stage that will check for any definitions containing AnyTypes. It accepts a set of packages that we expect to contain types with AnyTypes. Those packages will be quietly filtered out of the output of the stage, but if there are more AnyTypes in other packages they'll be reported as an error. The stage will also return an error if there are packages that we expect to have AnyTypes but turn out not to, ensuring that we clean up our configuration as the schemas are fixed and our handling improves.

func FixIDFields

func FixIDFields() *Stage

func FixOptionalCollectionAliases

func FixOptionalCollectionAliases() *Stage

func FlattenProperties

func FlattenProperties(log logr.Logger) *Stage

func FlattenResources

func FlattenResources() *Stage

FlattenResources flattens any resources directly inside other resources

func HandleUserAssignedIdentities

func HandleUserAssignedIdentities() *Stage

func ImplementConvertibleInterface

func ImplementConvertibleInterface(idFactory astmodel.IdentifierFactory) *Stage

ImplementConvertibleInterface injects the functions ConvertTo() and ConvertFrom() into each non-hub Resource Type, providing the required implementation of the Convertible interface needed by the controller

func ImplementConvertibleSpecInterface

func ImplementConvertibleSpecInterface(idFactory astmodel.IdentifierFactory) *Stage

func ImplementConvertibleStatusInterface

func ImplementConvertibleStatusInterface(idFactory astmodel.IdentifierFactory) *Stage

func ImplementImportableResourceInterface

func ImplementImportableResourceInterface(
	configuration *config.Configuration,
	idFactory astmodel.IdentifierFactory,
) *Stage

func ImprovePropertyDescriptions

func ImprovePropertyDescriptions() *Stage

ImprovePropertyDescriptions adds documentation to any properties missing it by copying the description from the corresponding type

func InjectHubFunction

func InjectHubFunction(idFactory astmodel.IdentifierFactory) *Stage

InjectHubFunction modifies the nominates storage version (aka hub version) of each resource by injecting a Hub() function so that it satisfies the required interface.

func InjectJsonSerializationTests

func InjectJsonSerializationTests(idFactory astmodel.IdentifierFactory) *Stage

func InjectOriginalGVKFunction

func InjectOriginalGVKFunction(idFactory astmodel.IdentifierFactory) *Stage

InjectOriginalGVKFunction injects the function OriginalGVK() into each Resource 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.

func InjectOriginalVersionFunction

func InjectOriginalVersionFunction(idFactory astmodel.IdentifierFactory) *Stage

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 InjectOriginalVersionProperty

func InjectOriginalVersionProperty() *Stage

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 types, allowing us to recover the original version used to create each custom resource, and giving the operator the information needed to interact with ARM using the correct API version.

func InjectPropertyAssignmentFunctions

func InjectPropertyAssignmentFunctions(
	configuration *config.Configuration,
	idFactory astmodel.IdentifierFactory,
	log logr.Logger,
) *Stage

InjectPropertyAssignmentFunctions injects property assignment functions AssignTo*() and AssignFrom*() into both resources and object types. These functions do the heavy lifting of the conversions between versions of each type and are the building blocks of the main CovertTo*() and ConvertFrom*() methods.

func InjectPropertyAssignmentTests

func InjectPropertyAssignmentTests(idFactory astmodel.IdentifierFactory) *Stage

func InjectResourceConversionTestCases

func InjectResourceConversionTestCases(idFactory astmodel.IdentifierFactory) *Stage

InjectResourceConversionTestCases is a pipeline stage to inject test cases

func InjectSpecInitializationFunctions

func InjectSpecInitializationFunctions(
	configuration *config.Configuration,
	idFactory astmodel.IdentifierFactory,
) *Stage

InjectSpecInitializationFunctions injects the Spec initialization functions Initialize_From_*() into resources and object types. These functions are called from InitializeSpec() to initialize the spec from the status when the resource is imported.

func LoadTypes

func LoadTypes(
	idFactory astmodel.IdentifierFactory,
	config *config.Configuration,
	log logr.Logger,
) *Stage
LoadTypes creates a PipelineStage to load Swagger data.

This information is derived from the Azure Swagger specifications. We parse the Swagger specs and look for any actions that appear to be ARM resources (have PUT methods with types we can use and appropriate names in the action path). Then for each resource, we use the existing JSON AST parser to extract the status type (the type-definition part of swagger is the same as JSON Schema).

func MakeOneOfDiscriminantRequired

func MakeOneOfDiscriminantRequired() *Stage

MakeOneOfDiscriminantRequired walks the type graph and builds new types for communicating with ARM

func MakeStatusPropertiesOptional

func MakeStatusPropertiesOptional() *Stage

MakeStatusPropertiesOptional makes all top level Status properties optional. This is required because Status itself is actually optional (it's not set initially) and if any top level properties are not optional they end up always being returned, which makes for an awkward GET response initially (before the Status has been set). It also has implications for updating or patching the CRD resource as patching something in the spec or changing an annotation will deserialize the response from apiserver into the object passed in. If there are any spurious empty properties in Status included they will end up getting overwritten (possibly before the client.Status().Update() call can be made).

func MarkLatestAPIVersionAsStorageVersion

func MarkLatestAPIVersionAsStorageVersion() *Stage

MarkLatestAPIVersionAsStorageVersion creates a Stage to mark a particular version as a storage version

func MarkLatestStorageVariantAsHubVersion

func MarkLatestStorageVariantAsHubVersion() *Stage

MarkLatestStorageVariantAsHubVersion creates a Stage to mark the latest non-preview storage variant of a resource as the hub version of that resource for persistence

func NameTypesForCRD

func NameTypesForCRD(idFactory astmodel.IdentifierFactory) *Stage

NameTypesForCRD - for CRDs all inner enums and objects and validated types must be named, so we do it here

func NewLegacyStage

func NewLegacyStage(
	id string,
	description string,
	action func(context.Context, astmodel.TypeDefinitionSet) (astmodel.TypeDefinitionSet, error),
) *Stage

NewLegacyStage is a legacy constructor for creating a new pipeline stage that's ready for execution DO NOT USE THIS FOR ANY NEW STAGES - it's kept for compatibility with an older style of pipeline stages that will be migrated to the new style over time.

func NewStage

func NewStage(
	id string,
	description string,
	action func(context.Context, *State) (*State, error),
) *Stage

NewStage creates a new pipeline stage that's ready for execution

func PruneResourcesWithLifecycleOwnedByParent

func PruneResourcesWithLifecycleOwnedByParent(configuration *config.Configuration) *Stage

PruneResourcesWithLifecycleOwnedByParent prunes networking embedded types

func RemoveEmbeddedResources

func RemoveEmbeddedResources(
	configuration *config.Configuration,
	log logr.Logger,
) *Stage

func RemoveEmptyObjects

func RemoveEmptyObjects(log logr.Logger) *Stage

RemoveEmptyObjects removes Definitions which are empty (an object type with no properties)

func RemoveStatusValidations

func RemoveStatusValidations() *Stage

RemoveStatusValidations removes property validations from all Status types. This is required because Status is retrieved directly from the ARM API, and there are cases where ARM might return something that isn't actually "valid" according to the validation, but makes sense in context. Some examples:

  1. Status has a modelAsString enum with 2 values, but in a future API version, a 3rd value is added. The fact that the enum is modelAsString allows the service to return the new 3rd value even in old API versions.
  2. Status has an int that must be between 10 and 20. In a future API version, that restriction is relaxed and the same int can now be between 0 and 50.
  3. A bug in the services Swagger specification causes the service to accept enums with any case, but always return the enum all uppercase

In the above cases, if we left validation on the Status types, we would be unable to persist the content returned by the service (apiserver will reject it as not matching the OpenAPI schema). This could be a problem in cases where the resource was created via some other means and then imported into

func RemoveTypeAliases

func RemoveTypeAliases() *Stage

RemoveTypeAliases creates a pipeline stage removing type aliases

func RenameProperties

func RenameProperties(cfg *config.ObjectModelConfiguration) *Stage

func RepairSkippingProperties

func RepairSkippingProperties() *Stage

RepairSkippingProperties repairs any properties that skip one or more versions of an object and are reintroduced. As described in issue #1776, such properties are a problem because they might create incompatibilities between different versions of ASO, or between different versions of a given resource.

To repair these, we need to ensure that objects stored in property bags are always serialized with the same shape. For more details, see https://azure.github.io/azure-service-operator/design/adr-2023-09-skipping-properties/

Repair works by scanning for properties that are dropped between versions of a resource. We keep track of all these properties, and if a specific property appears more than once (implying there are two or more sequence versions of that property) we know a repair is required.

To illustrate, assume we have the following set of objects across versions of our mythical CRM service:

v1: Person(GivenName, FamilyName, Address) v2: Person(KnownAs, FullName, FamilyName) v3: Person(KnownAs, FullName, FamilyName, Address)

Scanning these types, we find:

FamilyName: present in (v1, v2, v3); no issue FullName: present in (v2, v3); no issue KnownAs: also present in (v2, v3); no issue GivenName: present in (v1); no issue

Address: present in (v1, v3); (skipping v2), repair required.

func ReplaceAnyTypeWithJSON

func ReplaceAnyTypeWithJSON() *Stage

func ReportOnTypesAndVersions

func ReportOnTypesAndVersions(configuration *config.Configuration) *Stage

ReportOnTypesAndVersions creates a pipeline stage that generates a report for each group showing a matrix of all types and versions

func ReportResourceStructure

func ReportResourceStructure(configuration *config.Configuration) *Stage

ReportResourceStructure creates a pipeline stage that reports the structure of resources in each package

func ReportResourceVersions

func ReportResourceVersions(configuration *config.Configuration) *Stage

ReportResourceVersions creates a pipeline stage that generates a report listing all generated resources.

func SimplifyDefinitions

func SimplifyDefinitions() *Stage

SimplifyDefinitions creates a pipeline stage that removes any wrapper types prior to actual code generation

func StripUnreferencedTypeDefinitions

func StripUnreferencedTypeDefinitions() *Stage

func TransformCrossResourceReferences

func TransformCrossResourceReferences(configuration *config.Configuration, idFactory astmodel.IdentifierFactory) *Stage

TransformCrossResourceReferences replaces cross resource references with genruntime.ResourceReference.

func TransformCrossResourceReferencesToString

func TransformCrossResourceReferencesToString() *Stage

TransformCrossResourceReferencesToString replaces cross resource references with string.

func TransformValidatedFloats

func TransformValidatedFloats() *Stage

func UnrollRecursiveTypes

func UnrollRecursiveTypes(log logr.Logger) *Stage

UnrollRecursiveTypes finds types that reference themselves and "unrolls" the reference. So a type that looks like:

type Error struct {
    code    string
    message string
    errors []Error
}

gets unrolled to look like:

type Error struct {
    code    string
    message string
    errors []Error_Unrolled
}

where Error_Unrolled looks like:

type Error_Unrolled struct {
    code    string
    message string
}

The recursive references must be removed because controller-tools doesn't support generating "references" (JSON $ref) so it can't support recursive types today. See https://github.com/kubernetes-sigs/controller-tools/issues/489 for more information. Unrolling these types, while required for controller-tools to function, means THAT THE TYPES WE GENERATE DON'T EXACTLY CONFORM TO THE PUBLISHED API! In practice, we think this is ok for Error types because our observation is that Errors that reference themselves only return a depth of 1 in practice. If we were to unroll all loops (rather than just types that directly reference themselves like we're doing here) that "in practice" observation may no longer hold, so we avoid doing it here (it's also more complicated to do that).

func VerifyNoErroredTypes

func VerifyNoErroredTypes() *Stage

VerifyNoErroredTypes creates a Stage that verifies that no types contain an ErroredType with errors

func (*Stage) AddDiagnostic

func (stage *Stage) AddDiagnostic(diagnostic DiagnosticAction)

AddDiagnostic specifies a diagnostic generator for this stage. The generator will be used if the generator is run with a --debug flag`

func (*Stage) Description

func (stage *Stage) Description() string

Description returns a human-readable description of this stage

func (*Stage) HasId

func (stage *Stage) HasId(id string) bool

HasId returns true if this stage has the specified id, false otherwise

func (*Stage) Id

func (stage *Stage) Id() string

Id returns the unique identifier for this stage

func (*Stage) IsUsedFor

func (stage *Stage) IsUsedFor(target Target) bool

IsUsedFor returns true if this stage should be used for the specified target

func (*Stage) Postrequisites

func (stage *Stage) Postrequisites() []string

Postrequisites returns the unique ids of stages that must run after this stage

func (*Stage) RequiresPostrequisiteStages

func (stage *Stage) RequiresPostrequisiteStages(postrequisites ...string)

RequiresPostrequisiteStages declares which stages must be executed after this one has completed Use postrequisites when it is necessary for that later stage to act on the results of this one.

For example, InjectJsonSerializationTests creates round trip serialization tests for any object types that have properties. It's not correct to give InjectJsonSerializationTests a prerequisite on every earlier stage that creates new object types becauses it isn't concerned with where those object came from. However, those earlier stages DO want their new object types to be tested, so they declare a post-requisite on InjectJsonSerializationTests to ensure this happens.

Post-requisites are thus not completely isomorphic with RequiresPrerequisiteStages as there may be supporting stages that are sometimes omitted from execution when targeting different outcomes. Having both pre- and post-requisites allows the dependencies to drop out cleanly when different stages are present.

func (*Stage) RequiresPrerequisiteStages

func (stage *Stage) RequiresPrerequisiteStages(prerequisites ...string)

RequiresPrerequisiteStages declares which stages must have completed before this one is executed. Use prerequisites to specify stages that must be present for this stage to work - typically this means that the earlier stage is responsible for creating the preconditions required for this stage to operate correctly.

func (*Stage) Run

func (stage *Stage) Run(ctx context.Context, state *State) (*State, error)

Run is used to execute the action associated with this stage

func (*Stage) RunDiagnostic

func (stage *Stage) RunDiagnostic(settings *DebugSettings, index int, state *State) error

RunDiagnostic triggers our attached diagnostic generator, if any

func (*Stage) Targets

func (stage *Stage) Targets() []Target

Targets returns the targets this stage should be used for If no targets are returned, this stage should always be used

func (*Stage) UsedFor

func (stage *Stage) UsedFor(targets ...Target) *Stage

UsedFor specifies that this stage should be used for only the specified targets

type State

type State struct {
	// contains filtered or unexported fields
}

State is an immutable instance that captures the information being passed along the pipeline

func NewState

func NewState(definitions ...astmodel.TypeDefinitionSet) *State

NewState returns a new empty state definitions is a (possibly empty) sequence of types to combine for the initial state

func (*State) CheckFinalState

func (s *State) CheckFinalState() error

CheckFinalState checks that our final state is valid, returning an error if not

func (*State) ConversionGraph

func (s *State) ConversionGraph() *storage.ConversionGraph

ConversionGraph returns the conversion graph included in our state (may be null)

func (*State) Definitions

func (s *State) Definitions() astmodel.TypeDefinitionSet

Definitions returns the set of type definitions contained by the state

func (*State) GeneratedConfigMaps

func (s *State) GeneratedConfigMaps() *ExportedTypeNameProperties

GeneratedConfigMaps returns the set of generated config maps

func (*State) WithConversionGraph

func (s *State) WithConversionGraph(graph *storage.ConversionGraph) *State

WithConversionGraph returns a new independent State with the given conversion graph instead

func (*State) WithDefinitions

func (s *State) WithDefinitions(definitions astmodel.TypeDefinitionSet) *State

WithDefinitions returns a new independentState with the given type definitions instead

func (*State) WithExpectation

func (s *State) WithExpectation(earlierStage string, laterStage string) *State

WithExpectation records our expectation that the later stage is coming

func (*State) WithGeneratedConfigMaps

func (s *State) WithGeneratedConfigMaps(exportedConfigMaps *ExportedTypeNameProperties) *State

WithGeneratedConfigMaps returns a new independent State with the given generated config maps

func (*State) WithOverlaidDefinitions

func (s *State) WithOverlaidDefinitions(definitions astmodel.TypeDefinitionSet) *State

WithOverlaidDefinitions returns a new independent State with the given type definitions overlaid on the existing ones. Any new definitions are added, and any existing definitions are replaced.

func (*State) WithSeenStage

func (s *State) WithSeenStage(id string) *State

WithSeenStage records that the passed stage has been seen

type Target

type Target struct {
	// contains filtered or unexported fields
}

Target is used to classify what kind of pipeline we have Deliberately wraps a string because we *do* *not* want type compatibility with literal strings

var (
	// ARMTarget is used to tag stages that are required when generating types for working directly with Azure
	ARMTarget Target = MakePipelineTarget("azure")

	// CrossplaneTarget is used to tag stages that are required when generating types for working with Crossplane
	CrossplaneTarget Target = MakePipelineTarget("crossplane")
)

func MakePipelineTarget

func MakePipelineTarget(tag string) Target

func TranslatePipelineToTarget

func TranslatePipelineToTarget(pipeline config.GenerationPipeline) (Target, error)

func (Target) String

func (t Target) String() string

Source Files

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL