istio: istio.io/istio/operator/pkg/translate Index | Files

package translate

import "istio.io/istio/operator/pkg/translate"

Package translate defines translations from installer proto to values.yaml.

Index

Package Files

translate.go translate_common.go translate_value.go yaml_tree.go

Constants

const (
    // HelmValuesEnabledSubpath is the subpath from the component root to the enabled parameter.
    HelmValuesEnabledSubpath = "enabled"
    // HelmValuesNamespaceSubpath is the subpath from the component root to the namespace parameter.
    HelmValuesNamespaceSubpath = "namespace"
    // HelmValuesHubSubpath is the subpath from the component root to the hub parameter.
    HelmValuesHubSubpath = "hub"
    // HelmValuesTagSubpath is the subpath from the component root to the tag parameter.
    HelmValuesTagSubpath = "tag"
)

func IOPStoIOP Uses

func IOPStoIOP(iops proto.Message, name, namespace string) (*iopv1alpha1.IstioOperator, error)

IOPStoIOP takes an IstioOperatorSpec and returns a corresponding IstioOperator with the given name and namespace.

func IOPStoIOPstr Uses

func IOPStoIOPstr(iops proto.Message, name, namespace string) (string, error)

IOPStoIOPstr takes an IstioOperatorSpec and returns a corresponding IstioOperator string with the given name and namespace.

func IsComponentEnabledFromValue Uses

func IsComponentEnabledFromValue(cn name.ComponentName, valueSpec map[string]interface{}) (enabled bool, pathExist bool, err error)

IsComponentEnabledFromValue get whether component is enabled in helm value.yaml tree. valuePath points to component path in the values tree.

func IsComponentEnabledInSpec Uses

func IsComponentEnabledInSpec(componentName name.ComponentName, controlPlaneSpec *v1alpha1.IstioOperatorSpec) (bool, error)

IsComponentEnabledInSpec reports whether the given component is enabled in the given spec. IsComponentEnabledInSpec assumes that controlPlaneSpec has been validated. TODO: remove extra validations when comfort level is high enough.

func MergeK8sObject Uses

func MergeK8sObject(base *object.K8sObject, overlayNode interface{}, path util.Path) (*object.K8sObject, error)

MergeK8sObject does strategic merge for overlayNode on the base object.

func OverlayValuesEnablement Uses

func OverlayValuesEnablement(baseYAML, fileOverlayYAML, setOverlayYAML string) (string, error)

OverlayValuesEnablement overlays any enablement in values path from the user file overlay or set flag overlay. The overlay is translated from values to the corresponding addonComponents enablement paths.

func YAMLTree Uses

func YAMLTree(inTreeStr, outTreeStr string, translations map[string]string) (string, error)

YAMLTree takes an input tree inTreeStr, a partially constructed output tree outTreeStr, and a map of translations of source-path:dest-path in pkg/tpath format. It returns an output tree with paths from the input tree, translated and overlaid on the output tree.

type ComponentMaps Uses

type ComponentMaps struct {
    // ResourceType maps a ComponentName to the type of the rendered k8s resource.
    ResourceType string
    // ResourceName maps a ComponentName to the name of the rendered k8s resource.
    ResourceName string
    // ContainerName maps a ComponentName to the name of the container in a Deployment.
    ContainerName string
    // HelmSubdir is a mapping between a component name and the subdirectory of the component Chart.
    HelmSubdir string
    // ToHelmValuesTreeRoot is the tree root in values YAML files for the component.
    ToHelmValuesTreeRoot string
    // SkipReverseTranslate defines whether reverse translate of this component need to be skipped.
    SkipReverseTranslate bool
}

ComponentMaps is a set of mappings for an Istio component.

type ReverseTranslator Uses

type ReverseTranslator struct {
    Version version.MinorVersion
    // APIMapping is Values.yaml path to API path mapping using longest prefix match. If the path is a non-leaf node,
    // the output path is the matching portion of the path, plus any remaining output path.
    APIMapping map[string]*Translation `yaml:"apiMapping,omitempty"`
    // KubernetesPatternMapping defines mapping patterns from k8s resource paths to IstioOperator API paths.
    KubernetesPatternMapping map[string]string `yaml:"kubernetesPatternMapping,omitempty"`
    // KubernetesMapping defines actual k8s mappings generated from KubernetesPatternMapping before each translation.
    KubernetesMapping map[string]*Translation `yaml:"kubernetesMapping,omitempty"`
    // GatewayKubernetesMapping defines actual k8s mappings for gateway components generated from KubernetesPatternMapping before each translation.
    GatewayKubernetesMapping gatewayKubernetesMapping `yaml:"GatewayKubernetesMapping,omitempty"`
    // ValuesToComponentName defines mapping from value path to component name in API paths.
    ValuesToComponentName map[string]name.ComponentName `yaml:"valuesToComponentName,omitempty"`
}

ReverseTranslator is a set of mappings to translate between values.yaml and API paths, charts, k8s paths.

func NewReverseTranslator Uses

func NewReverseTranslator() *ReverseTranslator

NewReverseTranslator creates a new ReverseTranslator for minorVersion and returns a ptr to it.

func (*ReverseTranslator) TranslateFromValueToSpec Uses

func (t *ReverseTranslator) TranslateFromValueToSpec(values []byte, force bool) (controlPlaneSpec *v1alpha1.IstioOperatorSpec, err error)

TranslateFromValueToSpec translates from values.yaml value to IstioOperatorSpec.

func (*ReverseTranslator) TranslateK8S Uses

func (t *ReverseTranslator) TranslateK8S(valueTree map[string]interface{}, cpSpecTree map[string]interface{}) error

TranslateK8S is a helper function to translate k8s settings from values.yaml to IstioOperator, except for gateways.

func (*ReverseTranslator) TranslateK8SfromValueToIOP Uses

func (t *ReverseTranslator) TranslateK8SfromValueToIOP(userOverlayYaml string) (string, error)

TranslateK8SfromValueToIOP use reverse translation to convert k8s settings defined in values API to IOP API. this ensures that user overlays that set k8s through spec.values are not overridden by spec.components.X.k8s settings in the base profiles

func (*ReverseTranslator) TranslateTree Uses

func (t *ReverseTranslator) TranslateTree(valueTree map[string]interface{}, cpSpecTree map[string]interface{}, path util.Path) error

TranslateTree translates input value.yaml Tree to ControlPlaneSpec Tree.

func (*ReverseTranslator) WarningForGatewayK8SSettings Uses

func (t *ReverseTranslator) WarningForGatewayK8SSettings(valuesOverlay string) (string, error)

WarningForGatewayK8SSettings creates deprecated warning messages when user try to set kubernetes settings for gateways via values api.

type Translation Uses

type Translation struct {
    // OutPath defines the position in the yaml file
    OutPath string `yaml:"outPath"`
    // contains filtered or unexported fields
}

Translation is a mapping to an output path using a translation function.

type TranslationFunc Uses

type TranslationFunc func(t *Translation, root map[string]interface{}, valuesPath string, value interface{}) error

TranslationFunc maps a yamlStr API path into a YAML values tree.

type Translator Uses

type Translator struct {
    // Translations remain the same within a minor version.
    Version version.MinorVersion
    // APIMapping is a mapping between an API path and the corresponding values.yaml path using longest prefix
    // match. If the path is a non-leaf node, the output path is the matching portion of the path, plus any remaining
    // output path.
    APIMapping map[string]*Translation `yaml:"apiMapping"`
    // KubernetesMapping defines mappings from an IstioOperator API paths to k8s resource paths.
    KubernetesMapping map[string]*Translation `yaml:"kubernetesMapping"`
    // GlobalNamespaces maps feature namespaces to Helm global namespace definitions.
    GlobalNamespaces map[name.ComponentName]string `yaml:"globalNamespaces"`
    // ComponentMaps is a set of mappings for each Istio component.
    ComponentMaps map[name.ComponentName]*ComponentMaps `yaml:"componentMaps"`
}

Translator is a set of mappings to translate between API paths, charts, values.yaml and k8s paths.

func NewTranslator Uses

func NewTranslator() *Translator

NewTranslator creates a new translator for minorVersion and returns a ptr to it.

func (*Translator) ComponentMap Uses

func (t *Translator) ComponentMap(cns string) *ComponentMaps

ComponentMap returns a ComponentMaps struct ptr for the given component name if one exists. If the name of the component is lower case, the function will use the capitalized version of the name.

func (*Translator) IsComponentEnabled Uses

func (t *Translator) IsComponentEnabled(cn name.ComponentName, iop *v1alpha1.IstioOperatorSpec) (bool, error)

IsComponentEnabled reports whether the component with name cn is enabled, according to the translations in t, and the contents of ocp.

func (*Translator) OverlayK8sSettings Uses

func (t *Translator) OverlayK8sSettings(yml string, iop *v1alpha1.IstioOperatorSpec, componentName name.ComponentName,
    resourceName string, index int) (string, error)

OverlayK8sSettings overlays k8s settings from iop over the manifest objects, based on t's translation mappings.

func (*Translator) ProtoToHelmValues Uses

func (t *Translator) ProtoToHelmValues(node interface{}, root map[string]interface{}, path util.Path) (errs util.Errors)

ProtoToHelmValues takes an interface which must be a struct ptr and recursively iterates through all its fields. For each leaf, if looks for a mapping from the struct data path to the corresponding YAML path and if one is found, it calls the associated mapping function if one is defined to populate the values YAML path. If no mapping function is defined, it uses the default mapping function.

func (*Translator) ProtoToValues Uses

func (t *Translator) ProtoToValues(ii *v1alpha1.IstioOperatorSpec) (string, error)

ProtoToValues traverses the supplied IstioOperatorSpec and returns a values.yaml translation from it.

func (*Translator) TranslateHelmValues Uses

func (t *Translator) TranslateHelmValues(iop *v1alpha1.IstioOperatorSpec, componentsSpec interface{}, componentName name.ComponentName) (string, error)

TranslateHelmValues creates a Helm values.yaml config data tree from iop using the given translator.

Package translate imports 19 packages (graph) and is imported by 8 packages. Updated 2021-01-21. Refresh now. Tools for package owners.