mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-07-16 17:33:14 +00:00
new command kustomize edit add buildmetadata (#4413)
* new command kustomize edit add buildmetadata * new commands kustomize edit set buildmetadata and kustomize edit remove buildmetadata
This commit is contained in:
@@ -67,6 +67,7 @@ func determineFieldOrder() []string {
|
||||
"Inventory",
|
||||
"Components",
|
||||
"OpenAPI",
|
||||
"BuildMetadata",
|
||||
}
|
||||
|
||||
// Add deprecated fields here.
|
||||
|
||||
@@ -49,6 +49,7 @@ func TestFieldOrder(t *testing.T) {
|
||||
"Inventory",
|
||||
"Components",
|
||||
"OpenAPI",
|
||||
"BuildMetadata",
|
||||
}
|
||||
actual := determineFieldOrder()
|
||||
if len(expected) != len(actual) {
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
// Copyright 2019 The Kubernetes Authors.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package util
|
||||
|
||||
import (
|
||||
|
||||
31
kustomize/commands/internal/util/validate.go
Normal file
31
kustomize/commands/internal/util/validate.go
Normal file
@@ -0,0 +1,31 @@
|
||||
// Copyright 2022 The Kubernetes Authors.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package util
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"sigs.k8s.io/kustomize/api/types"
|
||||
"sigs.k8s.io/kustomize/kustomize/v4/commands/internal/kustfile"
|
||||
)
|
||||
|
||||
type BuildMetadataValidator struct{}
|
||||
|
||||
func (b *BuildMetadataValidator) Validate(args []string) ([]string, error) {
|
||||
if len(args) == 0 {
|
||||
return nil, errors.New("must specify a buildMetadata option")
|
||||
}
|
||||
if len(args) > 1 {
|
||||
return nil, fmt.Errorf("too many arguments: %s; to provide multiple buildMetadata options, please separate options by comma", args)
|
||||
}
|
||||
opts := strings.Split(args[0], ",")
|
||||
for _, opt := range opts {
|
||||
if !kustfile.StringInSlice(opt, types.BuildMetadataOptions) {
|
||||
return nil, fmt.Errorf("invalid buildMetadata option: %s", opt)
|
||||
}
|
||||
}
|
||||
return opts, nil
|
||||
}
|
||||
Reference in New Issue
Block a user