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.
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.
Index ¶
- func FindAllNamespaces(objects []*fn.KubeObject) ([]string, map[string]int)
- func GetDependsOnMap(objects []*fn.KubeObject) map[string]bool
- func ReplaceNamespace(objects []*fn.KubeObject, oldNs, newNs string)
- func SetNamespace(rl *fn.ResourceList) (bool, error)
- func UpdateAnnotation(objects []*fn.KubeObject, oldNs, newNs string, dependsOnMap map[string]bool)
- func VisitNamespaces(objects []*fn.KubeObject, visitor func(namespace *Namespace))
- type Namespace
- type NamespaceTransformer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FindAllNamespaces ¶
func FindAllNamespaces(objects []*fn.KubeObject) ([]string, map[string]int)
FindAllNamespaces iterates the `objects` to list all namespaces and count the number of Namespace objects.
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, oldNs, newNs string)
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, oldNs, newNs string, 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 (*Namespace) SetDependsOnAnnotation ¶
type NamespaceTransformer ¶
type NamespaceTransformer struct { NewNamespace string NamespaceMatcher 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) GetOldNamespace ¶
func (p *NamespaceTransformer) GetOldNamespace(fromResources []string, nsCount map[string]int) (string, bool)
GetOldNamespace finds the existing namespace and make sure the input resourceList.items satisfy the requirements. - no more than one Namespace Object can exist in the input resource.items - If Namespace object exists, its name is the `oldNs` - If `namespaceMatcher` is given, its value is the `oldNs` - If neither Namespace object nor `namespaceMatcher` found, all resources should have the same namespace value and this value is teh `oldNs`
func (*NamespaceTransformer) Transform ¶
func (p *NamespaceTransformer) Transform(objects []*fn.KubeObject)
Transform replace the existing Namespace object, namespace-scoped resources' `metadata.name` and other namespace reference fields to the new value.