Introduce gvk package to isolate apimachinery schema.

This commit is contained in:
Jeffrey Regan
2018-09-25 16:57:31 -07:00
parent 8aa0cc145c
commit fb355eb320
38 changed files with 570 additions and 477 deletions

View File

@@ -17,29 +17,19 @@ limitations under the License.
package transformerconfig
import (
"k8s.io/apimachinery/pkg/runtime/schema"
"strings"
"sigs.k8s.io/kustomize/pkg/gvk"
)
// PathConfig contains the configuration of a field, including the gvk it ties to,
// path to the field, etc.
type PathConfig struct {
Group string `json:"group,omitempty" yaml:"group,omitempty"`
Version string `json:"version,omitempty" yaml:"version,omitempty"`
Kind string `json:"kind,omitempty" yaml:"kind,omitempty"`
gvk.Gvk `json:",inline,omitempty" yaml:",inline,omitempty"`
Path string `json:"path,omitempty" yaml:"path,omitempty"`
CreateIfNotPresent bool `json:"create,omitempty" yaml:"create,omitempty"`
}
// Gvk returns GroupVersionKind of the pathConfig
func (p PathConfig) Gvk() *schema.GroupVersionKind {
return &schema.GroupVersionKind{
Group: p.Group,
Version: p.Version,
Kind: p.Kind,
}
}
// PathSlice converts the path string to a slice of strings, separated by "/"
func (p PathConfig) PathSlice() []string {
return strings.Split(p.Path, "/")