settersutil

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2020 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetAllSetterDefinitions added in v0.1.4

func SetAllSetterDefinitions(openAPIPath string, dirs ...string) error

SetAllSetterDefinitions reads all the Setter Definitions from the OpenAPI file and sets all values in the provided directories.

Types

type DeleterCreator added in v0.3.1

type DeleterCreator struct {
	// Name is the name of the setter or substitution to delete
	Name string

	// DefinitionPrefix is the prefix of the OpenAPI definition type
	DefinitionPrefix string
}

DeleterCreator delete a definition in the OpenAPI definitions, and removes references to the definition from matching resource fields.

func (DeleterCreator) Delete added in v0.3.1

func (d DeleterCreator) Delete(openAPIPath, resourcesPath string) error

type FieldSetter

type FieldSetter struct {
	// Name is the name of the setter to set
	Name string

	// Value is the value to set
	Value string

	// ListValues contains a list of values to set on a Sequence
	ListValues []string

	Description string

	SetBy string

	Count int

	OpenAPIPath string

	ResourcesPath string
}

FieldSetter sets the value for a field setter.

func (*FieldSetter) Filter added in v0.1.2

func (fs *FieldSetter) Filter(input []*yaml.RNode) ([]*yaml.RNode, error)

func (FieldSetter) Set

func (fs FieldSetter) Set(openAPIPath, resourcesPath string) (int, error)

Set updates the OpenAPI definitions and resources with the new setter value

type SetterCreator

type SetterCreator struct {
	// Name is the name of the setter to create or update.
	Name string

	SetBy string

	Description string

	Type string

	Schema string

	// FieldName if set will add the OpenAPI reference to fields with this name or path
	// FieldName may be the full name of the field, full path to the field, or the path suffix.
	// e.g. all of the following would match spec.template.spec.containers.image --
	// [image, containers.image, spec.containers.image, template.spec.containers.image,
	//  spec.template.spec.containers.image]
	// Optional.  If unspecified match all field names.
	FieldName string

	// FieldValue if set will add the OpenAPI reference to fields if they have this value.
	// Optional.  If unspecified match all field values.
	FieldValue string

	// Required indicates that the setter must be set by package consumer before
	// live apply/preview. This field is added to the setter definition to record
	// the package publisher's intent to make the setter required to be set.
	Required bool

	// Path to openAPI file
	OpenAPIPath string

	// Path to resources folder
	ResourcesPath string
}

SetterCreator creates or updates a setter in the OpenAPI definitions, and inserts references to the setter from matching resource fields.

func (SetterCreator) Create

func (c SetterCreator) Create(openAPIPath, resourcesPath string) error

func (*SetterCreator) Filter added in v0.5.0

func (c *SetterCreator) Filter(input []*yaml.RNode) ([]*yaml.RNode, error)

type SubstitutionCreator

type SubstitutionCreator struct {
	// Name is the name of the substitution to create
	Name string

	// Pattern is the substitution pattern
	Pattern string

	// Values are the substitution values for the pattern
	Values []setters2.Value

	// FieldName if set will add the OpenAPI reference to fields with this name or path
	// FieldName may be the full name of the field, full path to the field, or the path suffix.
	// e.g. all of the following would match spec.template.spec.containers.image --
	// [image, containers.image, spec.containers.image, template.spec.containers.image,
	//  spec.template.spec.containers.image]
	// Optional.  If unspecified match all field names.
	FieldName string

	// FieldValue if set will add the OpenAPI reference to fields if they have this value.
	// Optional.  If unspecified match all field values.
	FieldValue string

	// Path to openAPI file
	OpenAPIPath string

	// Path to resources folder
	ResourcesPath string
}

SubstitutionCreator creates or updates a substitution in the OpenAPI definitions, and inserts references to the substitution from matching resource fields.

func (SubstitutionCreator) Create

func (c SubstitutionCreator) Create(openAPIPath, resourcesPath string) error

func (SubstitutionCreator) CreateSettersForSubstitution added in v0.1.0

func (c SubstitutionCreator) CreateSettersForSubstitution(openAPIPath string) error

CreateSettersForSubstitution creates the setters for all the references in the substitution values if they don't already exist in openAPIPath file.

func (*SubstitutionCreator) Filter added in v0.5.0

func (c *SubstitutionCreator) Filter(input []*yaml.RNode) ([]*yaml.RNode, error)

func (SubstitutionCreator) GetStartIndices added in v0.1.0

func (c SubstitutionCreator) GetStartIndices() (map[int]string, error)

GetStartIndices returns the start indices of all the markers in the pattern

func (SubstitutionCreator) GetValuesForMarkers added in v0.1.0

func (c SubstitutionCreator) GetValuesForMarkers() (map[string]string, error)

GetValuesForMarkers parses the pattern and field value to derive values for the markers in the pattern string. Returns error if the marker values can't be derived

Jump to

Keyboard shortcuts

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