Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
51 changes: 51 additions & 0 deletions go/internal/forked/api/builtins/builtins.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// Copyright 2021 The Kubernetes Authors.
// SPDX-License-Identifier: Apache-2.0

// Deprecated: Package api/builtins will not be available in API v1.
package builtins

import (
internal "sigs.k8s.io/kustomize/api/internal/builtins"
)

type (
AnnotationsTransformerPlugin = internal.AnnotationsTransformerPlugin
ConfigMapGeneratorPlugin = internal.ConfigMapGeneratorPlugin
HashTransformerPlugin = internal.HashTransformerPlugin
HelmChartInflationGeneratorPlugin = internal.HelmChartInflationGeneratorPlugin
IAMPolicyGeneratorPlugin = internal.IAMPolicyGeneratorPlugin
ImageTagTransformerPlugin = internal.ImageTagTransformerPlugin
LabelTransformerPlugin = internal.LabelTransformerPlugin
LegacyOrderTransformerPlugin = internal.LegacyOrderTransformerPlugin
NamespaceTransformerPlugin = internal.NamespaceTransformerPlugin
PatchJson6902TransformerPlugin = internal.PatchJson6902TransformerPlugin
PatchStrategicMergeTransformerPlugin = internal.PatchStrategicMergeTransformerPlugin
PatchTransformerPlugin = internal.PatchTransformerPlugin
PrefixTransformerPlugin = internal.PrefixTransformerPlugin
SuffixTransformerPlugin = internal.SuffixTransformerPlugin
ReplacementTransformerPlugin = internal.ReplacementTransformerPlugin
ReplicaCountTransformerPlugin = internal.ReplicaCountTransformerPlugin
SecretGeneratorPlugin = internal.SecretGeneratorPlugin
ValueAddTransformerPlugin = internal.ValueAddTransformerPlugin
)

var (
NewAnnotationsTransformerPlugin = internal.NewAnnotationsTransformerPlugin
NewConfigMapGeneratorPlugin = internal.NewConfigMapGeneratorPlugin
NewHashTransformerPlugin = internal.NewHashTransformerPlugin
NewHelmChartInflationGeneratorPlugin = internal.NewHelmChartInflationGeneratorPlugin
NewIAMPolicyGeneratorPlugin = internal.NewIAMPolicyGeneratorPlugin
NewImageTagTransformerPlugin = internal.NewImageTagTransformerPlugin
NewLabelTransformerPlugin = internal.NewLabelTransformerPlugin
NewLegacyOrderTransformerPlugin = internal.NewLegacyOrderTransformerPlugin
NewNamespaceTransformerPlugin = internal.NewNamespaceTransformerPlugin
NewPatchJson6902TransformerPlugin = internal.NewPatchJson6902TransformerPlugin
NewPatchStrategicMergeTransformerPlugin = internal.NewPatchStrategicMergeTransformerPlugin
NewPatchTransformerPlugin = internal.NewPatchTransformerPlugin
NewPrefixTransformerPlugin = internal.NewPrefixTransformerPlugin
NewSuffixTransformerPlugin = internal.NewSuffixTransformerPlugin
NewReplacementTransformerPlugin = internal.NewReplacementTransformerPlugin
NewReplicaCountTransformerPlugin = internal.NewReplicaCountTransformerPlugin
NewSecretGeneratorPlugin = internal.NewSecretGeneratorPlugin
NewValueAddTransformerPlugin = internal.NewValueAddTransformerPlugin
)
61 changes: 61 additions & 0 deletions go/internal/forked/api/filesys/filesys.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// Copyright 2021 The Kubernetes Authors.
// SPDX-License-Identifier: Apache-2.0

// Package filesys provides a file system abstraction,
// a subset of that provided by golang.org/pkg/os,
// with an on-disk and in-memory representation.
//
// Deprecated: use github.com/GoogleContainerTools/kpt-functions-sdk/krmfn/internal/forked/kyaml/filesys instead.
package filesys

import "github.com/GoogleContainerTools/kpt-functions-sdk/krmfn/internal/forked/kyaml/filesys"

const (
// Separator is deprecated, use github.com/GoogleContainerTools/kpt-functions-sdk/krmfn/internal/forked/kyaml/filesys.Separator.
Separator = filesys.Separator
// SelfDir is deprecated, use github.com/GoogleContainerTools/kpt-functions-sdk/krmfn/internal/forked/kyaml/filesys.SelfDir.
SelfDir = filesys.SelfDir
// ParentDir is deprecated, use github.com/GoogleContainerTools/kpt-functions-sdk/krmfn/internal/forked/kyaml/filesys.ParentDir.
ParentDir = filesys.ParentDir
)

type (
// FileSystem is deprecated, use github.com/GoogleContainerTools/kpt-functions-sdk/krmfn/internal/forked/kyaml/filesys.FileSystem.
FileSystem = filesys.FileSystem
// FileSystemOrOnDisk is deprecated, use github.com/GoogleContainerTools/kpt-functions-sdk/krmfn/internal/forked/kyaml/filesys.FileSystemOrOnDisk.
FileSystemOrOnDisk = filesys.FileSystemOrOnDisk
// ConfirmedDir is deprecated, use github.com/GoogleContainerTools/kpt-functions-sdk/krmfn/internal/forked/kyaml/filesys.ConfirmedDir.
ConfirmedDir = filesys.ConfirmedDir
)

// MakeEmptyDirInMemory is deprecated, use github.com/GoogleContainerTools/kpt-functions-sdk/krmfn/internal/forked/kyaml/filesys.MakeEmptyDirInMemory.
func MakeEmptyDirInMemory() FileSystem { return filesys.MakeEmptyDirInMemory() }

// MakeFsInMemory is deprecated, use github.com/GoogleContainerTools/kpt-functions-sdk/krmfn/internal/forked/kyaml/filesys.MakeFsInMemory.
func MakeFsInMemory() FileSystem { return filesys.MakeFsInMemory() }

// MakeFsOnDisk is deprecated, use github.com/GoogleContainerTools/kpt-functions-sdk/krmfn/internal/forked/kyaml/filesys.MakeFsOnDisk.
func MakeFsOnDisk() FileSystem { return filesys.MakeFsOnDisk() }

// NewTmpConfirmedDir is deprecated, use github.com/GoogleContainerTools/kpt-functions-sdk/krmfn/internal/forked/kyaml/filesys.NewTmpConfirmedDir.
func NewTmpConfirmedDir() (filesys.ConfirmedDir, error) { return filesys.NewTmpConfirmedDir() }

// RootedPath is deprecated, use github.com/GoogleContainerTools/kpt-functions-sdk/krmfn/internal/forked/kyaml/filesys.RootedPath.
func RootedPath(elem ...string) string { return filesys.RootedPath(elem...) }

// StripTrailingSeps is deprecated, use github.com/GoogleContainerTools/kpt-functions-sdk/krmfn/internal/forked/kyaml/filesys.StripTrailingSeps.
func StripTrailingSeps(s string) string { return filesys.StripTrailingSeps(s) }

// StripLeadingSeps is deprecated, use github.com/GoogleContainerTools/kpt-functions-sdk/krmfn/internal/forked/kyaml/filesys.StripLeadingSeps.
func StripLeadingSeps(s string) string { return filesys.StripLeadingSeps(s) }

// PathSplit is deprecated, use github.com/GoogleContainerTools/kpt-functions-sdk/krmfn/internal/forked/kyaml/filesys.PathSplit.
func PathSplit(incoming string) []string { return filesys.PathSplit(incoming) }

// PathJoin is deprecated, use github.com/GoogleContainerTools/kpt-functions-sdk/krmfn/internal/forked/kyaml/filesys.PathJoin.
func PathJoin(incoming []string) string { return filesys.PathJoin(incoming) }

// InsertPathPart is deprecated, use github.com/GoogleContainerTools/kpt-functions-sdk/krmfn/internal/forked/kyaml/filesys.InsertPathPart.
func InsertPathPart(path string, pos int, part string) string {
return filesys.InsertPathPart(path, pos, part)
}
61 changes: 61 additions & 0 deletions go/internal/forked/api/filesys/filesys.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// Copyright 2021 The Kubernetes Authors.
// SPDX-License-Identifier: Apache-2.0

// Package filesys provides a file system abstraction,
// a subset of that provided by golang.org/pkg/os,
// with an on-disk and in-memory representation.
//
// Deprecated: use github.com/GoogleContainerTools/kpt-functions-sdk/internal/forked/kyaml/filesys instead.
package filesys

import "github.com/GoogleContainerTools/kpt-functions-sdk/internal/forked/kyaml/filesys"

const (
// Separator is deprecated, use github.com/GoogleContainerTools/kpt-functions-sdk/internal/forked/kyaml/filesys.Separator.
Separator = filesys.Separator
// SelfDir is deprecated, use github.com/GoogleContainerTools/kpt-functions-sdk/internal/forked/kyaml/filesys.SelfDir.
SelfDir = filesys.SelfDir
// ParentDir is deprecated, use github.com/GoogleContainerTools/kpt-functions-sdk/internal/forked/kyaml/filesys.ParentDir.
ParentDir = filesys.ParentDir
)

type (
// FileSystem is deprecated, use github.com/GoogleContainerTools/kpt-functions-sdk/internal/forked/kyaml/filesys.FileSystem.
FileSystem = filesys.FileSystem
// FileSystemOrOnDisk is deprecated, use github.com/GoogleContainerTools/kpt-functions-sdk/internal/forked/kyaml/filesys.FileSystemOrOnDisk.
FileSystemOrOnDisk = filesys.FileSystemOrOnDisk
// ConfirmedDir is deprecated, use github.com/GoogleContainerTools/kpt-functions-sdk/internal/forked/kyaml/filesys.ConfirmedDir.
ConfirmedDir = filesys.ConfirmedDir
)

// MakeEmptyDirInMemory is deprecated, use github.com/GoogleContainerTools/kpt-functions-sdk/internal/forked/kyaml/filesys.MakeEmptyDirInMemory.
func MakeEmptyDirInMemory() FileSystem { return filesys.MakeEmptyDirInMemory() }

// MakeFsInMemory is deprecated, use github.com/GoogleContainerTools/kpt-functions-sdk/internal/forked/kyaml/filesys.MakeFsInMemory.
func MakeFsInMemory() FileSystem { return filesys.MakeFsInMemory() }

// MakeFsOnDisk is deprecated, use github.com/GoogleContainerTools/kpt-functions-sdk/internal/forked/kyaml/filesys.MakeFsOnDisk.
func MakeFsOnDisk() FileSystem { return filesys.MakeFsOnDisk() }

// NewTmpConfirmedDir is deprecated, use github.com/GoogleContainerTools/kpt-functions-sdk/internal/forked/kyaml/filesys.NewTmpConfirmedDir.
func NewTmpConfirmedDir() (filesys.ConfirmedDir, error) { return filesys.NewTmpConfirmedDir() }

// RootedPath is deprecated, use github.com/GoogleContainerTools/kpt-functions-sdk/internal/forked/kyaml/filesys.RootedPath.
func RootedPath(elem ...string) string { return filesys.RootedPath(elem...) }

// StripTrailingSeps is deprecated, use github.com/GoogleContainerTools/kpt-functions-sdk/internal/forked/kyaml/filesys.StripTrailingSeps.
func StripTrailingSeps(s string) string { return filesys.StripTrailingSeps(s) }

// StripLeadingSeps is deprecated, use github.com/GoogleContainerTools/kpt-functions-sdk/internal/forked/kyaml/filesys.StripLeadingSeps.
func StripLeadingSeps(s string) string { return filesys.StripLeadingSeps(s) }

// PathSplit is deprecated, use github.com/GoogleContainerTools/kpt-functions-sdk/internal/forked/kyaml/filesys.PathSplit.
func PathSplit(incoming string) []string { return filesys.PathSplit(incoming) }

// PathJoin is deprecated, use github.com/GoogleContainerTools/kpt-functions-sdk/internal/forked/kyaml/filesys.PathJoin.
func PathJoin(incoming []string) string { return filesys.PathJoin(incoming) }

// InsertPathPart is deprecated, use github.com/GoogleContainerTools/kpt-functions-sdk/internal/forked/kyaml/filesys.InsertPathPart.
func InsertPathPart(path string, pos int, part string) string {
return filesys.InsertPathPart(path, pos, part)
}
52 changes: 52 additions & 0 deletions go/internal/forked/api/filters/annotations/annotations.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// Copyright 2020 The Kubernetes Authors.
// SPDX-License-Identifier: Apache-2.0

package annotations

import (
"sigs.k8s.io/kustomize/api/filters/filtersutil"
"sigs.k8s.io/kustomize/api/filters/fsslice"
"sigs.k8s.io/kustomize/api/types"
"github.com/GoogleContainerTools/kpt-functions-sdk/krmfn/internal/forked/kyaml/kio"
"github.com/GoogleContainerTools/kpt-functions-sdk/krmfn/internal/forked/kyaml/yaml"
)

type annoMap map[string]string

type Filter struct {
// Annotations is the set of annotations to apply to the inputs
Annotations annoMap `yaml:"annotations,omitempty"`

// FsSlice contains the FieldSpecs to locate the namespace field
FsSlice types.FsSlice

trackableSetter filtersutil.TrackableSetter
}

var _ kio.Filter = Filter{}
var _ kio.TrackableFilter = &Filter{}

// WithMutationTracker registers a callback which will be invoked each time a field is mutated
func (f *Filter) WithMutationTracker(callback func(key, value, tag string, node *yaml.RNode)) {
f.trackableSetter.WithMutationTracker(callback)
}

func (f Filter) Filter(nodes []*yaml.RNode) ([]*yaml.RNode, error) {
keys := yaml.SortedMapKeys(f.Annotations)
_, err := kio.FilterAll(yaml.FilterFunc(
func(node *yaml.RNode) (*yaml.RNode, error) {
for _, k := range keys {
if err := node.PipeE(fsslice.Filter{
FsSlice: f.FsSlice,
SetValue: f.trackableSetter.SetEntry(
k, f.Annotations[k], yaml.NodeTagString),
CreateKind: yaml.MappingNode, // Annotations are MappingNodes.
CreateTag: yaml.NodeTagMap,
}); err != nil {
return nil, err
}
}
return node, nil
})).Filter(nodes)
return nodes, err
}
52 changes: 52 additions & 0 deletions go/internal/forked/api/filters/annotations/annotations.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// Copyright 2020 The Kubernetes Authors.
// SPDX-License-Identifier: Apache-2.0

package annotations

import (
"sigs.k8s.io/kustomize/api/filters/filtersutil"
"sigs.k8s.io/kustomize/api/filters/fsslice"
"sigs.k8s.io/kustomize/api/types"
"github.com/GoogleContainerTools/kpt-functions-sdk/internal/forked/kyaml/kio"
"github.com/GoogleContainerTools/kpt-functions-sdk/internal/forked/kyaml/yaml"
)

type annoMap map[string]string

type Filter struct {
// Annotations is the set of annotations to apply to the inputs
Annotations annoMap `yaml:"annotations,omitempty"`

// FsSlice contains the FieldSpecs to locate the namespace field
FsSlice types.FsSlice

trackableSetter filtersutil.TrackableSetter
}

var _ kio.Filter = Filter{}
var _ kio.TrackableFilter = &Filter{}

// WithMutationTracker registers a callback which will be invoked each time a field is mutated
func (f *Filter) WithMutationTracker(callback func(key, value, tag string, node *yaml.RNode)) {
f.trackableSetter.WithMutationTracker(callback)
}

func (f Filter) Filter(nodes []*yaml.RNode) ([]*yaml.RNode, error) {
keys := yaml.SortedMapKeys(f.Annotations)
_, err := kio.FilterAll(yaml.FilterFunc(
func(node *yaml.RNode) (*yaml.RNode, error) {
for _, k := range keys {
if err := node.PipeE(fsslice.Filter{
FsSlice: f.FsSlice,
SetValue: f.trackableSetter.SetEntry(
k, f.Annotations[k], yaml.NodeTagString),
CreateKind: yaml.MappingNode, // Annotations are MappingNodes.
CreateTag: yaml.NodeTagMap,
}); err != nil {
return nil, err
}
}
return node, nil
})).Filter(nodes)
return nodes, err
}
Loading