Add ObjectMeta type.

This commit is contained in:
Jeffrey Regan
2019-06-28 14:38:07 -07:00
parent 615a41d6be
commit 233b3613ae
2 changed files with 16 additions and 27 deletions

View File

@@ -1,18 +1,5 @@
/* // Copyright 2019 The Kubernetes Authors.
Copyright 2017 The Kubernetes Authors. // SPDX-License-Identifier: Apache-2.0
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.
*/
// Package types holds struct definitions that should find a better home. // Package types holds struct definitions that should find a better home.
package types package types
@@ -29,13 +16,18 @@ const (
KustomizationKind = "Kustomization" KustomizationKind = "Kustomization"
) )
// TypeMeta copies apimachinery/pkg/apis/meta/v1.TypeMeta // TypeMeta partially copies apimachinery/pkg/apis/meta/v1.TypeMeta
// No need for a direct dependence; the fields are stable.
type TypeMeta struct { type TypeMeta struct {
// Kind copies apimachinery/pkg/apis/meta/v1.Typemeta.Kind Kind string `json:"kind,omitempty" yaml:"kind,omitempty"`
Kind string `json:"kind,omitempty" protobuf:"bytes,1,opt,name=kind"` APIVersion string `json:"apiVersion,omitempty" yaml:"apiversion,omitempty"`
}
// APIVersion copies apimachinery/pkg/apis/meta/v1.Typemeta.APIVersion // ObjectMeta partially copies apimachinery/pkg/apis/meta/v1.ObjectMeta
APIVersion string `json:"apiVersion,omitempty" protobuf:"bytes,2,opt,name=apiVersion"` // No need for a direct dependence; the fields are stable.
type ObjectMeta struct {
Name string `json:"name,omitempty" yaml:"name,omitempty"`
Namespace string `json:"namespace,omitempty" yaml:"namespace,omitempty"`
} }
// Kustomization holds the information needed to generate customized k8s api resources. // Kustomization holds the information needed to generate customized k8s api resources.

View File

@@ -9,6 +9,7 @@ import (
"sigs.k8s.io/kustomize/v3/pkg/resmap" "sigs.k8s.io/kustomize/v3/pkg/resmap"
"sigs.k8s.io/kustomize/v3/pkg/transformers" "sigs.k8s.io/kustomize/v3/pkg/transformers"
"sigs.k8s.io/kustomize/v3/pkg/transformers/config" "sigs.k8s.io/kustomize/v3/pkg/transformers/config"
"sigs.k8s.io/kustomize/v3/pkg/types"
"sigs.k8s.io/kustomize/v3/plugin/builtin" "sigs.k8s.io/kustomize/v3/plugin/builtin"
"sigs.k8s.io/yaml" "sigs.k8s.io/yaml"
) )
@@ -16,12 +17,8 @@ import (
// Add a string prefix to the name. // Add a string prefix to the name.
// A plugin that adapts another plugin. // A plugin that adapts another plugin.
type plugin struct { type plugin struct {
Metadata metaData `json:"metadata,omitempty" yaml:"metadata,omitempty"` types.ObjectMeta `json:"metadata,omitempty" yaml:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
t transformers.Transformer t transformers.Transformer
}
type metaData struct {
Name string `json:"name,omitempty" yaml:"name,omitempty"`
} }
//nolint: golint //nolint: golint
@@ -47,7 +44,7 @@ func (p *plugin) Config(
if err != nil { if err != nil {
return err return err
} }
c, err = p.makePrefixSuffixPluginConfig(p.Metadata.Name) c, err = p.makePrefixSuffixPluginConfig(p.Name)
if err != nil { if err != nil {
return err return err
} }