yamlprocessor

package
v0.3.13 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2021 License: Apache-2.0 Imports: 6 Imported by: 5

Documentation

Overview

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

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Processor

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

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

func NewSimpleProcessor() *SimpleProcessor

func (*SimpleProcessor) GetTemplateName

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

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

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

func (*SimpleProcessor) Process

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.

Jump to

Keyboard shortcuts

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