builtinconfig

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package builtinconfig provides legacy methods for configuring builtin plugins from a common config file. As a user, its best to configure plugins individually with plugin config files specified in the `transformers:` or `generators:` field, than to use this legacy configuration technique.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type NameBackReferences

type NameBackReferences struct {
	resid.Gvk `json:",inline,omitempty" yaml:",inline,omitempty"`
	// TODO: rename json 'fieldSpecs' to 'referrers' for clarity.
	// This will, however, break anyone using a custom config.
	Referrers types.FsSlice `json:"fieldSpecs,omitempty" yaml:"fieldSpecs,omitempty"`
}

NameBackReferences is an association between a gvk.GVK (a ReferralTarget) and a list of Referrers that could refer to it.

It is used to handle name changes, and can be thought of as a a contact list. If you change your own contact info (name, phone number, etc.), you must tell your contacts or they won't know about the change.

For example, ConfigMaps can be used by Pods and everything that contains a Pod; Deployment, Job, StatefulSet, etc. The ConfigMap is the ReferralTarget, the others are Referrers.

If the name of a ConfigMap instance changed from 'alice' to 'bob', one must

  • visit all objects that could refer to the ConfigMap (the Referrers)
  • see if they mention 'alice',
  • if so, change the Referrer's name reference to 'bob'.

The NameBackReferences instance to aid in this could look like

{
  kind: ConfigMap
  version: v1
  fieldSpecs:
  - kind: Pod
    version: v1
    path: spec/volumes/configMap/name
  - kind: Deployment
    path: spec/template/spec/volumes/configMap/name
  - kind: Job
    path: spec/template/spec/volumes/configMap/name
    (etc.)
}

func (NameBackReferences) String

func (n NameBackReferences) String() string

type TransformerConfig

type TransformerConfig struct {
	// if any fields are added, update the DeepCopy implementation
	NamePrefix        types.FsSlice `json:"namePrefix,omitempty" yaml:"namePrefix,omitempty"`
	NameSuffix        types.FsSlice `json:"nameSuffix,omitempty" yaml:"nameSuffix,omitempty"`
	NameSpace         types.FsSlice `json:"namespace,omitempty" yaml:"namespace,omitempty"`
	CommonLabels      types.FsSlice `json:"commonLabels,omitempty" yaml:"commonLabels,omitempty"`
	Labels            types.FsSlice `json:"labels,omitempty" yaml:"labels,omitempty"`
	TemplateLabels    types.FsSlice `json:"templateLabels,omitempty" yaml:"templateLabels,omitempty"`
	CommonAnnotations types.FsSlice `json:"commonAnnotations,omitempty" yaml:"commonAnnotations,omitempty"`
	NameReference     nbrSlice      `json:"nameReference,omitempty" yaml:"nameReference,omitempty"`
	VarReference      types.FsSlice `json:"varReference,omitempty" yaml:"varReference,omitempty"`
	Images            types.FsSlice `json:"images,omitempty" yaml:"images,omitempty"`
	Replicas          types.FsSlice `json:"replicas,omitempty" yaml:"replicas,omitempty"`
}

TransformerConfig holds the data needed to perform transformations.

func MakeDefaultConfig

func MakeDefaultConfig() *TransformerConfig

MakeDefaultConfig returns a default TransformerConfig.

func MakeEmptyConfig

func MakeEmptyConfig() *TransformerConfig

MakeEmptyConfig returns an empty TransformerConfig object

func MakeTransformerConfig

func MakeTransformerConfig(
	ldr ifc.Loader, paths []string) (*TransformerConfig, error)

MakeTransformerConfig returns a merger of custom config, if any, with default config.

func (*TransformerConfig) AddAnnotationFieldSpec

func (t *TransformerConfig) AddAnnotationFieldSpec(fs types.FieldSpec) (err error)

AddAnnotationFieldSpec adds a FieldSpec to CommonAnnotations

func (*TransformerConfig) AddCommonLabelsFieldSpec added in v0.17.2

func (t *TransformerConfig) AddCommonLabelsFieldSpec(fs types.FieldSpec) (err error)

AddCommonLabelsFieldSpec adds a FieldSpec to CommonLabels

func (*TransformerConfig) AddLabelsFieldSpec added in v0.17.2

func (t *TransformerConfig) AddLabelsFieldSpec(fs types.FieldSpec) (err error)

AddLabelsFieldSpec adds a FieldSpec to Labels

func (*TransformerConfig) AddNamereferenceFieldSpec

func (t *TransformerConfig) AddNamereferenceFieldSpec(
	nbrs NameBackReferences) (err error)

AddNamereferenceFieldSpec adds a NameBackReferences to NameReference

func (*TransformerConfig) AddPrefixFieldSpec

func (t *TransformerConfig) AddPrefixFieldSpec(fs types.FieldSpec) (err error)

AddPrefixFieldSpec adds a FieldSpec to NamePrefix

func (*TransformerConfig) AddSuffixFieldSpec

func (t *TransformerConfig) AddSuffixFieldSpec(fs types.FieldSpec) (err error)

AddSuffixFieldSpec adds a FieldSpec to NameSuffix

func (*TransformerConfig) DeepCopy added in v0.16.0

func (t *TransformerConfig) DeepCopy() *TransformerConfig

DeepCopy returns a new copy of TransformerConfig

func (*TransformerConfig) Merge

func (t *TransformerConfig) Merge(input *TransformerConfig) (
	merged *TransformerConfig, err error)

Merge merges two TransformerConfigs objects into a new TransformerConfig object

Jump to

Keyboard shortcuts

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