mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-30 01:46:23 +00:00
Introduce ResId and ResMap.
This commit is contained in:
@@ -1,35 +0,0 @@
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors.
|
||||
|
||||
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
|
||||
|
||||
import (
|
||||
"sort"
|
||||
)
|
||||
|
||||
// ByGVKN implements the sort interface.
|
||||
type ByGVKN []GroupVersionKindName
|
||||
|
||||
var _ sort.Interface = ByGVKN{}
|
||||
|
||||
func (a ByGVKN) Len() int { return len(a) }
|
||||
func (a ByGVKN) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
|
||||
func (a ByGVKN) Less(i, j int) bool {
|
||||
if a[i].GVK.String() != a[j].GVK.String() {
|
||||
return a[i].GVK.String() < a[j].GVK.String()
|
||||
}
|
||||
return a[i].Name < a[j].Name
|
||||
}
|
||||
@@ -67,7 +67,7 @@ type ConfigMapArgs struct {
|
||||
// hash(content of configmap).
|
||||
Name string `json:"name,omitempty" yaml:"name,omitempty"`
|
||||
|
||||
// Behavior of configmap, must be one of create, merge and replace
|
||||
// behavior of configmap, must be one of create, merge and replace
|
||||
// 'create': create a new one;
|
||||
// 'replace': replace the existing one;
|
||||
// 'merge': merge the existing one.
|
||||
@@ -84,7 +84,7 @@ type SecretArgs struct {
|
||||
// hash(content of secret).
|
||||
Name string `json:"name,omitempty" yaml:"name,omitempty"`
|
||||
|
||||
// Behavior of secretGenerator, must be one of create, merge and replace
|
||||
// behavior of secretGenerator, must be one of create, merge and replace
|
||||
// 'create': create a new one;
|
||||
// 'replace': replace the existing one;
|
||||
// 'merge': merge the existing one.
|
||||
|
||||
@@ -17,25 +17,16 @@ limitations under the License.
|
||||
package types
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
)
|
||||
|
||||
func (gvkn GroupVersionKindName) String() string {
|
||||
if gvkn.GVK.Group == "" {
|
||||
return strings.Join([]string{gvkn.GVK.Version, gvkn.GVK.Kind, gvkn.Name}, "_") + ".yaml"
|
||||
}
|
||||
return strings.Join([]string{gvkn.GVK.Group, gvkn.GVK.Version, gvkn.GVK.Kind, gvkn.Name}, "_") + ".yaml"
|
||||
}
|
||||
|
||||
// SelectByGVK returns true if `selector` selects `in`; otherwise, false.
|
||||
// If `selector` and `in` are the same, return true.
|
||||
// If `selector` is nil, it is considered as a wildcard and always return true.
|
||||
// e.g. selector <Group: "", Version: "", Kind: "Deployemt"> CAN select
|
||||
// <Group: "extensions", Version: "v1beta1", Kind: "Deployemt">.
|
||||
// selector <Group: "apps", Version: "", Kind: "Deployemt"> CANNOT select
|
||||
// <Group: "extensions", Version: "v1beta1", Kind: "Deployemt">.
|
||||
// e.g. selector <Group: "", Version: "", Kind: "Deployment"> CAN select
|
||||
// <Group: "extensions", Version: "v1beta1", Kind: "Deployment">.
|
||||
// selector <Group: "apps", Version: "", Kind: "Deployment"> CANNOT select
|
||||
// <Group: "extensions", Version: "v1beta1", Kind: "Deployment">.
|
||||
func SelectByGVK(in schema.GroupVersionKind, selector *schema.GroupVersionKind) bool {
|
||||
if selector == nil {
|
||||
return true
|
||||
@@ -22,7 +22,7 @@ import (
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
)
|
||||
|
||||
func TestFilterByGVK(t *testing.T) {
|
||||
func TestSelectByGVK(t *testing.T) {
|
||||
type testCase struct {
|
||||
description string
|
||||
in schema.GroupVersionKind
|
||||
@@ -37,7 +37,7 @@ func TestFilterByGVK(t *testing.T) {
|
||||
expected: true,
|
||||
},
|
||||
{
|
||||
description: "GVK matches",
|
||||
description: "gvk matches",
|
||||
in: schema.GroupVersionKind{
|
||||
Group: "group1",
|
||||
Version: "version1",
|
||||
@@ -1,29 +0,0 @@
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors.
|
||||
|
||||
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
|
||||
|
||||
import (
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
)
|
||||
|
||||
// GroupVersionKindName contains GroupVersionKind and original name of the resource.
|
||||
type GroupVersionKindName struct {
|
||||
// GroupVersionKind of the resource.
|
||||
GVK schema.GroupVersionKind
|
||||
// original name of the resource before transformation.
|
||||
Name string
|
||||
}
|
||||
Reference in New Issue
Block a user