Skip to content

Commit

Permalink
add replacements field
Browse files Browse the repository at this point in the history
  • Loading branch information
Liujingfang1 committed Oct 7, 2019
1 parent 404d2d6 commit 0a3b751
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/types/kustomization.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ type Kustomization struct {
// value of the specified field has been determined.
Vars []Var `json:"vars,omitempty" yaml:"vars,omitempty"`

// Replacements defines substitutions including source and destinations.
// It is used to inject a field from one Kubernetes resource into another Kubernetes
// resources. It can also inject a literal string into a Kubernetes resources.
Replacements []Replacement `json:"replacements,omitempty" yaml:"replacements,omitempty"`

//
// Operands - what kustomize operates on.
//
Expand Down
27 changes: 27 additions & 0 deletions pkg/types/replacement.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright 2019 The Kubernetes Authors.
// SPDX-License-Identifier: Apache-2.0

package types

// Replacement defines how to perform a substitution
// where it is from and where it is to.
type Replacement struct {
From *From `json:"from" yaml:"from"`
To *To `json:"To" yaml:"to"`
}

// From defines where a substitution is from
// It can from two different kinds of sources
// - from a field of one resource
// - from a string
type From struct {
ObjRef *Target `json:"objref,omitempty" yaml:"objref,omitempty"`
FieldRef string `json:"fieldref,omitempty" yaml:"fiedldref,omitempty"`
Value string `json:"value,omitempty" yaml:"value,omitempty"`
}

// To defines where a substitution is to.
type To struct {
Target *Selector `json:"target,omitempty" yaml:"target,omitempty"`
FieldRefs []string `json:"fieldrefs,omitempty" yaml:"fieldrefs,omitempty"`
}

0 comments on commit 0a3b751

Please sign in to comment.