config

package
v0.0.0-...-b7472cd Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2024 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GenerationPipelineAzure      = GenerationPipeline("azure")
	GenerationPipelineCrossplane = GenerationPipeline("crossplane")
)
View Source
const (
	ImportConfigMapModeOptional = "optional"
	ImportConfigMapModeRequired = "required"
)

Variables

View Source
var VersionRegex = regexp.MustCompile(`^v\d\d?$`)

Functions

func NewStringMatcher

func NewStringMatcher(matcher string) match.StringMatcher

NewStringMatcher returns a matcher for the specified string Different strings may return different implementations: o If the string contains '*' or '?' a globbing wildcard matcher o Otherwise a case-insensitive literal string matcher

Types

type Configuration

type Configuration struct {
	// Where to load Swagger schemas from
	SchemaRoot string `yaml:"schemaRoot"`
	// Information about where to locate status (Swagger) files
	Status StatusConfiguration `yaml:"status"`
	// The pipeline that should be used for code generation
	Pipeline GenerationPipeline `yaml:"pipeline"`
	// The path to the go.mod file where the code will be generated
	DestinationGoModuleFile string `yaml:"destinationGoModuleFile"`
	// The folder relative to the go.mod file path where the code should be generated
	TypesOutputPath string `yaml:"typesOutputPath"`
	// The file relative to the go.mod file path where registration of the Go types should be generated. If omitted, this step is skipped.
	TypeRegistrationOutputFile string `yaml:"typeRegistrationOutputFile"`
	// AnyTypePackages lists packages which we expect to generate
	// interface{} fields.
	AnyTypePackages []string `yaml:"anyTypePackages"`
	// Filters used to control which types are created from the JSON schema
	TypeFilters []*TypeFilter `yaml:"typeFilters"`
	// Renamers used to resolve naming collisions during loading
	TypeLoaderRenames []*TypeLoaderRename `yaml:"typeLoaderRenames"`
	// Transformers used to remap types
	Transformers []*TypeTransformer `yaml:"typeTransformers"`
	// RootURL is the root URL for ASOv2 repo, paths are appended to this to generate resource links.
	RootURL string `yaml:"rootUrl"`
	// SamplesPath is the Path the samples are accessible at. This is used to walk through the samples directory and generate sample links.
	SamplesPath string `yaml:"samplesPath"`
	// EmitDocFiles is used as a signal to create doc.go files for packages. If omitted, default is false.
	EmitDocFiles bool `yaml:"emitDocFiles"`
	// Destination file and additional information for our supported resources report
	SupportedResourcesReport *SupportedResourcesReport `yaml:"supportedResourcesReport"`
	// Additional information about our object model
	ObjectModelConfiguration *ObjectModelConfiguration `yaml:"objectModelConfiguration"`
	// contains filtered or unexported fields
}

Configuration is used to control which types get generated

func LoadConfiguration

func LoadConfiguration(configurationFile string) (*Configuration, error)

LoadConfiguration loads a `Configuration` from the specified file

func NewConfiguration

func NewConfiguration() *Configuration

NewConfiguration returns a new empty Configuration

func (*Configuration) FullSamplesPath

func (config *Configuration) FullSamplesPath() string

func (*Configuration) FullTypesOutputPath

func (config *Configuration) FullTypesOutputPath() string

func (*Configuration) FullTypesRegistrationOutputFilePath

func (config *Configuration) FullTypesRegistrationOutputFilePath() string

func (*Configuration) GetTransformersError

func (config *Configuration) GetTransformersError() error

func (*Configuration) GetTypeFiltersError

func (config *Configuration) GetTypeFiltersError() error

func (*Configuration) LocalPathPrefix

func (config *Configuration) LocalPathPrefix() string

func (*Configuration) MakeLocalPackageReference

func (config *Configuration) MakeLocalPackageReference(group string, version string) astmodel.LocalPackageReference

MakeLocalPackageReference creates a local package reference based on the configured destination location

func (*Configuration) SetGoModulePath

func (config *Configuration) SetGoModulePath(path string)

func (*Configuration) ShouldPrune

func (config *Configuration) ShouldPrune(typeName astmodel.InternalTypeName) (result ShouldPruneResult, because string)

ShouldPrune tests for whether a given type should be extracted from the JSON schema or pruned

type EnumResult

type EnumResult struct {
	Base   string   `yaml:"base,omitempty"`
	Values []string `yaml:"values,omitempty"`
}

type FieldMatcher

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

FieldMatcher allows a StringMatcher to be deserialized from YAML

func NewFieldMatcher

func NewFieldMatcher(field string) FieldMatcher

func (*FieldMatcher) IsRestrictive

func (dm *FieldMatcher) IsRestrictive() bool

IsRestrictive returns true if our nested matcher is present and restrictive, false otherwise

func (*FieldMatcher) Matches

func (dm *FieldMatcher) Matches(value string) match.Result

func (*FieldMatcher) String

func (dm *FieldMatcher) String() string

func (*FieldMatcher) UnmarshalYAML

func (dm *FieldMatcher) UnmarshalYAML(value *yaml.Node) error

UnmarshalYAML populates our instance from the YAML. We expect just a single string, which we use create an actual StringMatcher

func (*FieldMatcher) WasMatched

func (dm *FieldMatcher) WasMatched() error

type GenerationPipeline

type GenerationPipeline string

type GroupConfiguration

type GroupConfiguration struct {

	// Configurable properties here (alphabetical, please)
	PayloadType configurable[PayloadType] // Specify how this property should be serialized for ARM
	// contains filtered or unexported fields
}

GroupConfiguration contains additional information about an entire group and forms the top of a hierarchy containing information to supplement the schema and swagger sources consumed by the generator.

┌──────────────────────────┐ ╔════════════════════╗ ┌──────────────────────┐ ┌───────────────────┐ ┌───────────────────────┐ │ │ ║ ║ │ │ │ │ │ │ │ ObjectModelConfiguration │───────║ GroupConfiguration ║───────│ VersionConfiguration │───────│ TypeConfiguration │───────│ PropertyConfiguration │ │ │1 1..n║ ║1 1..n│ │1 1..n│ │1 1..n│ │ └──────────────────────────┘ ╚════════════════════╝ └──────────────────────┘ └───────────────────┘ └───────────────────────┘

func NewGroupConfiguration

func NewGroupConfiguration(name string) *GroupConfiguration

NewGroupConfiguration returns a new (empty) GroupConfiguration

func (*GroupConfiguration) UnmarshalYAML

func (gc *GroupConfiguration) UnmarshalYAML(value *yaml.Node) error

UnmarshalYAML populates our instance from the YAML. The slice node.Content contains pairs of nodes, first one for an ID, then one for the value.

type ImportConfigMapMode

type ImportConfigMapMode string

type MapResult

type MapResult struct {
	Key   TransformResult `yaml:",omitempty"`
	Value TransformResult `yaml:",omitempty"`
}

type MapSelector

type MapSelector struct {
	Key   TransformSelector `yaml:",omitempty"`
	Value TransformSelector `yaml:",omitempty"`
}

type ObjectModelConfiguration

type ObjectModelConfiguration struct {

	// Group access fields here (alphabetical, please)
	PayloadType propertyAccess[PayloadType]

	// Type access fields here (alphabetical, please)
	AzureGeneratedSecrets    typeAccess[[]string]
	DefaultAzureName         typeAccess[bool]
	Export                   typeAccess[bool]
	ExportAs                 typeAccess[string]
	GeneratedConfigs         typeAccess[map[string]string]
	Importable               typeAccess[bool]
	IsResource               typeAccess[bool]
	ManualConfigs            typeAccess[[]string]
	RenameTo                 typeAccess[string]
	ResourceEmbeddedInParent typeAccess[string]
	OperatorSpecProperties   typeAccess[[]OperatorSpecPropertyConfiguration]
	StripDocumentation       typeAccess[bool]
	SupportedFrom            typeAccess[string]
	TypeNameInNextVersion    typeAccess[string]

	// Property access fields here (alphabetical, please)
	ARMReference                   propertyAccess[bool]
	Description                    propertyAccess[string]
	ImportConfigMapMode            propertyAccess[ImportConfigMapMode]
	IsSecret                       propertyAccess[bool]
	PropertyNameInNextVersion      propertyAccess[string]
	RenamePropertyTo               propertyAccess[string]
	ResourceLifecycleOwnedByParent propertyAccess[string]
	// contains filtered or unexported fields
}

ObjectModelConfiguration contains additional information about entire object model, allowing fine-tuning of the information loaded from JSON schema and Swagger specs. There is a hierarchy of types involved, as follows:

╔══════════════════════════╗ ┌────────────────────┐ ┌──────────────────────┐ ┌───────────────────┐ ┌───────────────────────┐ ║ ║ │ │ │ │ │ │ │ │ ║ ObjectModelConfiguration ║───────│ GroupConfiguration │───────│ VersionConfiguration │───────│ TypeConfiguration │───────│ PropertyConfiguration │ ║ ║1 1..n│ │1 1..n│ │1 1..n│ │1 1..n│ │ ╚══════════════════════════╝ └────────────────────┘ └──────────────────────┘ └───────────────────┘ └───────────────────────┘

func NewObjectModelConfiguration

func NewObjectModelConfiguration() *ObjectModelConfiguration

NewObjectModelConfiguration returns a new (empty) ObjectModelConfiguration

func (*ObjectModelConfiguration) AddTypeAlias

func (omc *ObjectModelConfiguration) AddTypeAlias(name astmodel.InternalTypeName, alias string)

AddTypeAlias adds a type alias for the specified type name, allowing configuration related to the type to be accessed via the new name.

func (*ObjectModelConfiguration) FindHandCraftedTypeNames

func (omc *ObjectModelConfiguration) FindHandCraftedTypeNames(localPath string) (astmodel.InternalTypeNameSet, error)

FindHandCraftedTypeNames returns the set of type-names that are hand-crafted. These are identified by having `v<n>` as their version.

func (*ObjectModelConfiguration) IsEmpty

func (omc *ObjectModelConfiguration) IsEmpty() bool

IsEmpty returns true if we have no configuration at all, false if we have some groups configured.

func (*ObjectModelConfiguration) IsGroupConfigured

func (omc *ObjectModelConfiguration) IsGroupConfigured(pkg astmodel.InternalPackageReference) bool

IsGroupConfigured returns true if we have any configuration for the specified group, false otherwise.

func (*ObjectModelConfiguration) IsTypeConfigured

func (omc *ObjectModelConfiguration) IsTypeConfigured(name astmodel.InternalTypeName) bool

IsTypeConfigured returns true if we have any configuration for the specified type, false otherwise.

func (*ObjectModelConfiguration) ModifyGroup

func (omc *ObjectModelConfiguration) ModifyGroup(
	ref astmodel.InternalPackageReference,
	action func(configuration *GroupConfiguration) error,
) error

ModifyGroup allows the configuration of a specific group to be modified. If configuration for that group doesn't exist, it will be created. While intended for test use, this isn't in a _test.go file as we want to use it from tests in multiple packages.

func (*ObjectModelConfiguration) ModifyProperty

func (omc *ObjectModelConfiguration) ModifyProperty(
	typeName astmodel.InternalTypeName,
	property astmodel.PropertyName,
	action func(propertyConfiguration *PropertyConfiguration) error,
) error

ModifyProperty allows the configuration of a specific property to be modified. If configuration for that property doesn't exist, it will be created. While intended for test use, this isn't in a _test.go file as we want to use it from tests in multiple packages.

func (*ObjectModelConfiguration) ModifyType

func (omc *ObjectModelConfiguration) ModifyType(
	name astmodel.InternalTypeName,
	action func(typeConfiguration *TypeConfiguration) error,
) error

ModifyType allows the configuration of a specific type to be modified. If configuration for that type doesn't exist, it will be created. While intended for test use, this isn't in a _test.go file as we want to use it from tests in multiple packages.

func (*ObjectModelConfiguration) ModifyVersion

func (omc *ObjectModelConfiguration) ModifyVersion(
	ref astmodel.InternalPackageReference,
	action func(configuration *VersionConfiguration) error,
) error

ModifyVersion allows the configuration of a specific version to be modified. If configuration for that version doesn't exist, it will be created. While intended for test use, this isn't in a _test.go file as we want to use it from tests in multiple packages.

func (*ObjectModelConfiguration) UnmarshalYAML

func (omc *ObjectModelConfiguration) UnmarshalYAML(value *yaml.Node) error

UnmarshalYAML populates our instance from the YAML. The slice node.Content contains pairs of nodes, first one for an ID, then one for the value.

type OperatorSpecPropertyConfiguration

type OperatorSpecPropertyConfiguration struct {
	Name        string `yaml:"name,omitempty"`        // Name of the new property
	Type        string `yaml:"type,omitempty"`        // Primitive type of the new property  (e.g. string, int, etc.)
	Description string `yaml:"description,omitempty"` // Description to include on the property
}

type PayloadType

type PayloadType string
const (
	OmitEmptyProperties      PayloadType = "omitempty"                // Omit all empty properties even collections
	ExplicitCollections      PayloadType = "explicitcollections"      // Always include collections (as null), omit other empty properties
	ExplicitEmptyCollections PayloadType = "explicitemptycollections" // Always include collections (as empty map/array), omit other empty properties
	ExplicitProperties       PayloadType = "explicitproperties"       // Always include all properties
)

type PropertyConfiguration

type PropertyConfiguration struct {

	// Configurable properties here (alphabetical, please)
	ARMReference                   configurable[bool]                // Specify whether this property is an ARM reference
	Description                    configurable[string]              // Specify a description override for this property
	ImportConfigMapMode            configurable[ImportConfigMapMode] // The config map mode
	IsSecret                       configurable[bool]                // Specify whether this property is a secret
	NameInNextVersion              configurable[string]              // Name this property has in the next version
	PayloadType                    configurable[PayloadType]         // Specify how this property should be serialized for ARM
	RenameTo                       configurable[string]              // Name this property should be renamed to
	ResourceLifecycleOwnedByParent configurable[string]              // Name of the parent resource which owns the lifecycle of the sub-resource.
	// contains filtered or unexported fields
}

PropertyConfiguration contains additional information about a specific property and forms part of a hierarchy containing information to supplement the schema and swagger sources consumed by the generator.

┌──────────────────────────┐ ┌────────────────────┐ ┌──────────────────────┐ ┌───────────────────┐ ╔═══════════════════════╗ │ │ │ │ │ │ │ │ ║ ║ │ ObjectModelConfiguration │───────│ GroupConfiguration │───────│ VersionConfiguration │───────│ TypeConfiguration │───────║ PropertyConfiguration ║ │ │1 1..n│ │1 1..n│ │1 1..n│ │1 1..n║ ║ └──────────────────────────┘ └────────────────────┘ └──────────────────────┘ └───────────────────┘ ╚═══════════════════════╝

func NewPropertyConfiguration

func NewPropertyConfiguration(name string) *PropertyConfiguration

NewPropertyConfiguration returns a new (empty) property configuration

func (*PropertyConfiguration) UnmarshalYAML

func (pc *PropertyConfiguration) UnmarshalYAML(value *yaml.Node) error

UnmarshalYAML populates our instance from the YAML. The slice node.Content contains pairs of nodes, first one for an ID, then one for the value.

type PropertyTransformResult

type PropertyTransformResult struct {
	TypeName        astmodel.TypeName
	NewType         *astmodel.ObjectType
	Property        astmodel.PropertyName
	NewPropertyType astmodel.Type
	Removed         bool
	Because         string
}

PropertyTransformResult is the result of applying a property type transform

func (PropertyTransformResult) LogTo

func (r PropertyTransformResult) LogTo(log logr.Logger)

LogTo creates a log message for the transformation

func (PropertyTransformResult) String

func (r PropertyTransformResult) String() string

String generates a printable representation of this result.

type ResourceConfig

type ResourceConfig struct {
	Type string `yaml:"type"`

	// TODO: Not sure that this datatype should be string, but we don't use it right now so keeping it as
	// TODO: string for simplicity
	Scopes string `yaml:"scopes"`
}

type RewriteRule

type RewriteRule struct {
	From string `yaml:"from"`
	To   string `yaml:"to"`
}

type SchemaOverride

type SchemaOverride struct {
	// The root for this group (relative to SchemaRoot)
	BasePath string `yaml:"basePath"`

	// A specific namespace (group name, in our domain language)
	Namespace string `yaml:"namespace"`

	// A suffix to add on to the group name
	Suffix string `yaml:"suffix"`

	// We don't use this now
	ResourceConfig []ResourceConfig `yaml:"resourceConfig"`

	// We don't use this now
	PostProcessor string `yaml:"postProcessor"`
}

SchemaOverride provides configuration to override namespaces (groups) this is used (for example) to distinguish Microsoft.Network.Frontdoor from Microsoft.Network, even though both use Microsoft.Network in their Swagger specs.

type ShouldPruneResult

type ShouldPruneResult string

ShouldPruneResult is returned by ShouldPrune to indicate whether the supplied type should be exported

const (
	// Include indicates the specified type should be included in the type graph
	Include ShouldPruneResult = "include"
	// Prune indicates the type (and all types only referenced by it) should be pruned from the type graph
	Prune ShouldPruneResult = "prune"
)

type StatusConfiguration

type StatusConfiguration struct {
	// Custom per-group configuration
	Overrides []SchemaOverride `yaml:"overrides"`
}

StatusConfiguration provides configuration options for the status parts of resources, which are generated from the Azure Swagger specs.

type SupportedResourcesReport

type SupportedResourcesReport struct {

	// OutputFolder is the destination folder for the report, relative to DestinationGoModuleFile
	OutputFolder string `yaml:"outputFolder,omitempty"`
	// FragmentPath is a folder path for markdown fragments to inject into the file
	FragmentPath string `yaml:"fragmentPath,omitempty"`
	// ResourceUrlTemplate is a template for URL to the API docs for a resource
	// It may use the placeholders {group} {version} and {kind}
	ResourceUrlTemplate string `yaml:"resourceUrlTemplate"`
	// ResourcePathTemplate is a template used for generating a file path for checking whether docs for a resource have been generated
	// specified relative to the directory of outputPath
	ResourcePathTemplate string `yaml:"resourcePathTemplate"`
	// CurrentRelease identifies the current release of ASO, allowing newer resources to be classified as Next Release
	CurrentRelease string `yaml:"currentRelease"`
	// contains filtered or unexported fields
}

SupportedResourcesReport is configuration for the report that lists all the supported resources.

func NewSupportedResourcesReport

func NewSupportedResourcesReport(cfg *Configuration) *SupportedResourcesReport

NewSupportedResourcesReport creates a new SupportedResourcesReport.

func (*SupportedResourcesReport) FullFragmentPath

func (srr *SupportedResourcesReport) FullFragmentPath() string

FullFragmentFolderPath returns the fully qualified path to our fragment folder

func (*SupportedResourcesReport) FullOutputPath

func (srr *SupportedResourcesReport) FullOutputPath() string

FullOutputPath returns the fully qualified path to the output file.

func (*SupportedResourcesReport) GroupFullOutputPath

func (srr *SupportedResourcesReport) GroupFullOutputPath(group string) string

FullOutputPath returns the fully qualified path to the output file for a given group

type TransformResult

type TransformResult struct {
	Group    FieldMatcher `yaml:",omitempty"`
	Version  FieldMatcher `yaml:"version,omitempty"`
	Name     FieldMatcher `yaml:",omitempty"`
	Optional bool         `yaml:",omitempty"`
	Map      *MapResult   `yaml:",omitempty"`
	Enum     *EnumResult  `yaml:",omitempty"`
}

TransformResult is used to specify the result of a transformation

type TransformSelector

type TransformSelector struct {
	Group    FieldMatcher `yaml:",omitempty"`
	Version  FieldMatcher `yaml:"version,omitempty"`
	Name     FieldMatcher `yaml:",omitempty"`
	Optional bool         `yaml:",omitempty"`
	Object   bool         `yaml:",omitempty"`
	Map      *MapSelector `yaml:",omitempty"`
	// contains filtered or unexported fields
}

TransformSelector is used to select a type for transformation

func (*TransformSelector) AppliesToType

func (ts *TransformSelector) AppliesToType(t astmodel.Type) bool

type TypeConfiguration

type TypeConfiguration struct {

	// Configurable properties here (alphabetical, please)
	AzureGeneratedSecrets    configurable[[]string]                            // A set of strings specifying which secrets are generated by Azure
	DefaultAzureName         configurable[bool]                                // Boolean indicating if the resource should automatically default AzureName
	Export                   configurable[bool]                                // Boolean specifying whether a resource type is exported
	ExportAs                 configurable[string]                              // String specifying the name to use for a type (implies $export: true)
	GeneratedConfigs         configurable[map[string]string]                   // A map of strings specifying which spec or status properties should be exported to configmap
	Importable               configurable[bool]                                // Boolean specifying whether a resource type is importable via asoctl (defaults to true)
	IsResource               configurable[bool]                                // Boolean specifying whether a particular type is a resource or not.
	ManualConfigs            configurable[[]string]                            // A set of strings specifying which config map fields should be generated (to be filled out by resource extension)
	NameInNextVersion        configurable[string]                              // When a type is renamed, specify the name it will have in the next version
	OperatorSpecProperties   configurable[[]OperatorSpecPropertyConfiguration] // A set of additional properties to inject into the operatorSpec of a resource
	PayloadType              configurable[PayloadType]                         // Specify how this property should be serialized for ARM
	RenameTo                 configurable[string]                              // Give this type a different name in the generated code
	ResourceEmbeddedInParent configurable[string]                              // String specifying resource name of parent
	SupportedFrom            configurable[string]                              // Label specifying the first ASO release supporting the resource
	StripDocumentation       configurable[bool]                                // Boolean directing the generator to strip documentation on the resource and all referenced objects. Only supported on resources.
	// contains filtered or unexported fields
}

TypeConfiguration contains additional information about a specific kind of resource within a version of a group and forms part of a hierarchy containing information to supplement the schema and swagger sources consumed by the generator.

┌──────────────────────────┐ ┌────────────────────┐ ┌──────────────────────┐ ╔═══════════════════╗ ┌───────────────────────┐ │ │ │ │ │ │ ║ ║ │ │ │ ObjectModelConfiguration │───────│ GroupConfiguration │───────│ VersionConfiguration │───────║ TypeConfiguration ║───────│ PropertyConfiguration │ │ │1 1..n│ │1 1..n│ │1 1..n║ ║1 1..n│ │ └──────────────────────────┘ └────────────────────┘ └──────────────────────┘ ╚═══════════════════╝ └───────────────────────┘

func NewTypeConfiguration

func NewTypeConfiguration(name string) *TypeConfiguration

func (*TypeConfiguration) UnmarshalYAML

func (tc *TypeConfiguration) UnmarshalYAML(value *yaml.Node) error

UnmarshalYAML populates our instance from the YAML. The slice node.Content contains pairs of nodes, first one for an ID, then one for the value.

type TypeFilter

type TypeFilter struct {
	Action      TypeFilterAction
	TypeMatcher `yaml:",inline"`
}

A TypeFilter is used to control which types should be included in the type graph when running the generator

type TypeFilterAction

type TypeFilterAction string

TypeFilterAction defines the possible actions that should happen for types matching the filter

const (
	// TypeFilterInclude indicates that any type matched by the filter should be included in the type graph
	TypeFilterInclude TypeFilterAction = "include"
	// TypeFilterPrune indicates that any type matched by the filter, and any types only referenced by that type
	// should not be included in the type graph
	TypeFilterPrune TypeFilterAction = "prune"
)

type TypeLoaderRename

type TypeLoaderRename struct {
	TypeMatcher `yaml:",inline"`
	Scope       *string `yaml:"scope,omitempty"`
	RenameTo    *string `yaml:"renameTo,omitempty"`
}

A TypeLoaderRename is used to resolve a naming conflict that happens during loading of types right at the start of the code generator.

type TypeMatcher

type TypeMatcher struct {
	Group   FieldMatcher `yaml:",omitempty"` // Filter matching types by group
	Version FieldMatcher `yaml:",omitempty"` // Filter matching types by version
	Name    FieldMatcher `yaml:",omitempty"` // Filter matching types by name
	// Because is used to articulate why the filter applied to a type (used to generate explanatory logs in debug mode)
	Because string
	// MatchRequired indicates if an error will be raised if this TypeMatcher doesn't match at least one type.
	// The default is true.
	// Don't access directly, use the MustMatch() method instead.
	MatchRequired *bool `yaml:"matchRequired,omitempty"`
	// contains filtered or unexported fields
}

TypeMatcher contains basic functionality for a filter

func (*TypeMatcher) AppliesToType

func (t *TypeMatcher) AppliesToType(typeName astmodel.InternalTypeName) bool

AppliesToType indicates whether this filter should be applied to the supplied type definition

func (*TypeMatcher) MustMatch

func (t *TypeMatcher) MustMatch() bool

func (*TypeMatcher) RequiredTypesWereMatched

func (t *TypeMatcher) RequiredTypesWereMatched() error

RequiredTypesWereMatched returns an error if no matches were made

func (*TypeMatcher) String

func (t *TypeMatcher) String() string

String returns a description of this filter

func (*TypeMatcher) WasMatched

func (t *TypeMatcher) WasMatched() error

WasMatched returns nil if this matcher ever matched at least one type, otherwise a diagnostic error

type TypeTransformer

type TypeTransformer struct {
	TypeMatcher `yaml:",inline"`

	// Property is a wildcard matching specific properties on the types selected by this filter
	Property FieldMatcher `yaml:",omitempty"`

	// IfType only performs the transform if the original type matches
	IfType *TransformSelector `yaml:"ifType,omitempty"`

	// Target is the type to turn the type into
	Target *TransformResult `yaml:",omitempty"`

	// Remove indicates that the property should be removed from the
	// type. This is only usable with Property. Target and Remove are
	// mutually exclusive.
	Remove bool `yaml:",omitempty"`

	// RenameTo allows for renaming of type definitions.
	RenameTo string `yaml:"renameTo,omitempty"`
	// contains filtered or unexported fields
}

A TypeTransformer is used to remap types

func (*TypeTransformer) AppliesToDefinition

func (transformer *TypeTransformer) AppliesToDefinition(def astmodel.TypeDefinition) bool

AppliesToDefinition returns true if this transform should be applied to the passed TypeDefinition.

func (*TypeTransformer) RequiredPropertiesWereMatched

func (transformer *TypeTransformer) RequiredPropertiesWereMatched() error

func (*TypeTransformer) TransformDefinition

func (transformer *TypeTransformer) TransformDefinition(def astmodel.TypeDefinition) (astmodel.TypeDefinition, error)

func (*TypeTransformer) TransformProperty

func (transformer *TypeTransformer) TransformProperty(
	name astmodel.InternalTypeName,
	objectType *astmodel.ObjectType,
) (*PropertyTransformResult, error)

TransformProperty transforms the property on the given object type

func (*TypeTransformer) TransformTypeName

func (transformer *TypeTransformer) TransformTypeName(typeName astmodel.InternalTypeName) (astmodel.Type, error)

TransformTypeName transforms the type with the specified name into the TypeTransformer target type if the provided type name matches the pattern(s) specified in the TypeTransformer

type VersionConfiguration

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

VersionConfiguration contains additional information about a specific version of a group and forms part of a hierarchy containing information to supplement the schema and swagger sources consumed by the generator.

┌──────────────────────────┐ ┌────────────────────┐ ╔══════════════════════╗ ┌───────────────────┐ ┌───────────────────────┐ │ │ │ │ ║ ║ │ │ │ │ │ ObjectModelConfiguration │───────│ GroupConfiguration │───────║ VersionConfiguration ║───────│ TypeConfiguration │───────│ PropertyConfiguration │ │ │1 1..n│ │1 1..n║ ║1 1..n│ │1 1..n│ │ └──────────────────────────┘ └────────────────────┘ ╚══════════════════════╝ └───────────────────┘ └───────────────────────┘

func NewVersionConfiguration

func NewVersionConfiguration(name string) *VersionConfiguration

NewVersionConfiguration returns a new (empty) VersionConfiguration

func (*VersionConfiguration) UnmarshalYAML

func (vc *VersionConfiguration) UnmarshalYAML(value *yaml.Node) error

UnmarshalYAML populates our instance from the YAML. Nested objects are handled by a *pair* of nodes (!!), one for the id and one for the content of the object

Jump to

Keyboard shortcuts

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