transformer

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: May 6, 2022 License: Apache-2.0 Imports: 4 Imported by: 4

Documentation

Overview

Copyright 2022 Google LLC

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.

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

func GetDependsOnMap

func GetDependsOnMap(objects []*fn.KubeObject) map[string]bool

GetDependsOnMap iterates `objects` to get the annotation which contains namespace value.

func ReplaceNamespace

func ReplaceNamespace(objects []*fn.KubeObject, newNs string, count *int, oldNamespace map[string]struct{})

ReplaceNamespace iterates the `objects` to replace the `OldNs` with `newNs` on namespace field.

func SetNamespace

func SetNamespace(rl *fn.ResourceList) (bool, error)

func UpdateAnnotation

func UpdateAnnotation(objects []*fn.KubeObject, newNs string, oldNs map[string]struct{}, dependsOnMap map[string]bool)

UpdateAnnotation updates the `objects`'s "config.kubernetes.io/depends-on" annotation which contains namespace value.

func VisitNamespaces

func VisitNamespaces(objects []*fn.KubeObject, visitor func(namespace *Namespace))

VisitNamespaces iterates the `objects` to execute the `visitor` function on each corresponding namespace field.

Types

type Namespace

type Namespace struct {
	Ptr                 *string
	IsNamespace         bool
	DependsOnAnnotation string
	// contains filtered or unexported fields
}

func NewNamespace

func NewNamespace(obj *fn.KubeObject, namespacePtr *string) *Namespace

func (*Namespace) GetDependsOnAnnotation

func (n *Namespace) GetDependsOnAnnotation() string

func (*Namespace) SetDependsOnAnnotation

func (n *Namespace) SetDependsOnAnnotation(newDependsOn string)

type NamespaceTransformer

type NamespaceTransformer struct {
	NewNamespace string
	DependsOnMap map[string]bool
	Errors       []string
}

func (*NamespaceTransformer) Config

func (p *NamespaceTransformer) Config(o *fn.KubeObject) error

Config gets the attributes from different FunctionConfig formats.

func (*NamespaceTransformer) LogResults added in v0.4.0

func (p *NamespaceTransformer) LogResults(rl *fn.ResourceList, count int, oldNamespaces map[string]struct{}) *fn.Result

func (*NamespaceTransformer) Transform

func (p *NamespaceTransformer) Transform(objects []*fn.KubeObject, oldNamespaces map[string]struct{}) int

Transform replace the existing Namespace object, namespace-scoped resources' `metadata.name` and other namespace reference fields to the new value.

Jump to

Keyboard shortcuts

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