cluster-api: sigs.k8s.io/cluster-api/cmd/clusterctl/client/yamlprocessor Index | Files

package yamlprocessor

import "sigs.k8s.io/cluster-api/cmd/clusterctl/client/yamlprocessor"

Copyright 2020 The Kubernetes Authors.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Package Files

processor.go simple_processor.go

type Processor Uses

type Processor interface {
    // GetTemplateName returns the name of the template that needs to be
    // retrieved from the source.
    GetTemplateName(version, flavor string) string

    // GetVariables parses the template blob of bytes and provides a
    // list of variables that the template requires.
    GetVariables([]byte) ([]string, error)

    // Process processes the template blob of bytes and will return the final
    // yaml with values retrieved from the values getter
    Process([]byte, func(string) (string, error)) ([]byte, error)
}

Processor defines the methods necessary for creating a specific yaml processor.

type SimpleProcessor Uses

type SimpleProcessor struct{}

SimpleProcessor is a yaml processor that uses envsubst to substitute values for variables in the format ${var}. It also allows default values if specified in the format ${var:=default}. See https://github.com/drone/envsubst for more details.

func NewSimpleProcessor Uses

func NewSimpleProcessor() *SimpleProcessor

func (*SimpleProcessor) GetTemplateName Uses

func (tp *SimpleProcessor) GetTemplateName(_, flavor string) string

GetTemplateName returns the name of the template that the simple processor uses. It follows the cluster template naming convention of "cluster-template<-flavor>.yaml".

func (*SimpleProcessor) GetVariables Uses

func (tp *SimpleProcessor) GetVariables(rawArtifact []byte) ([]string, error)

GetVariables returns a list of the variables specified in the yaml.

func (*SimpleProcessor) Process Uses

func (tp *SimpleProcessor) Process(rawArtifact []byte, variablesClient func(string) (string, error)) ([]byte, error)

Process returns the final yaml with all the variables replaced with their respective values. If there are variables without corresponding values, it will return the raw yaml along with an error.

Package yamlprocessor imports 6 packages (graph) and is imported by 6 packages. Updated 2020-09-25. Refresh now. Tools for package owners.