mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-10 16:42:51 +00:00
@@ -109,16 +109,16 @@ func (mf *kustomizationFile) validate() error {
|
||||
}
|
||||
|
||||
func (mf *kustomizationFile) read() (*types.Kustomization, error) {
|
||||
bytes, err := mf.fsys.ReadFile(mf.path)
|
||||
data, err := mf.fsys.ReadFile(mf.path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var kustomization types.Kustomization
|
||||
err = yaml.Unmarshal(bytes, &kustomization)
|
||||
err = yaml.Unmarshal(data, &kustomization)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
err = mf.parseCommentedFields(bytes)
|
||||
err = mf.parseCommentedFields(data)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -129,11 +129,11 @@ func (mf *kustomizationFile) write(kustomization *types.Kustomization) error {
|
||||
if kustomization == nil {
|
||||
return errors.New("util: kustomization file arg is nil")
|
||||
}
|
||||
bytes, err := mf.marshal(kustomization)
|
||||
data, err := mf.marshal(kustomization)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return mf.fsys.WriteFile(mf.path, bytes)
|
||||
return mf.fsys.WriteFile(mf.path, data)
|
||||
}
|
||||
|
||||
func stringInSlice(str string, list []string) bool {
|
||||
@@ -173,7 +173,7 @@ func (mf *kustomizationFile) parseCommentedFields(content []byte) error {
|
||||
}
|
||||
|
||||
func (mf *kustomizationFile) marshal(kustomization *types.Kustomization) ([]byte, error) {
|
||||
output := []byte{}
|
||||
var output []byte
|
||||
for _, comment := range mf.originalFields {
|
||||
output = append(output, comment.comment...)
|
||||
content, err := marshalField(comment.field, kustomization)
|
||||
|
||||
@@ -69,13 +69,13 @@ and overwrite the previous newTag if the image name exists.
|
||||
// Validate validates setImageTag command.
|
||||
func (o *setImageTagOptions) Validate(args []string) error {
|
||||
if len(args) == 0 {
|
||||
return errors.New("No image and newTag specified.")
|
||||
return errors.New("no image and newTag specified")
|
||||
}
|
||||
o.imageTagMap = make(map[string]string)
|
||||
for _, arg := range args {
|
||||
imagetag := pattern.FindStringSubmatch(arg)
|
||||
if len(imagetag) != 3 {
|
||||
return errors.New("Invalid format of imagetag, must specify it as <image>:<newtag>")
|
||||
return errors.New("invalid format of imagetag, must specify it as <image>:<newtag>")
|
||||
}
|
||||
o.imageTagMap[imagetag[1]] = imagetag[2]
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ func TestSetImageTagsNoArgs(t *testing.T) {
|
||||
if err == nil {
|
||||
t.Errorf("expected error: %v", err)
|
||||
}
|
||||
if err.Error() != "No image and newTag specified." {
|
||||
if err.Error() != "no image and newTag specified" {
|
||||
t.Errorf("incorrect error: %v", err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -272,7 +272,7 @@ func MergeWithOverride(maps ...ResMap) (ResMap, error) {
|
||||
result[id] = r
|
||||
}
|
||||
} else {
|
||||
return nil, fmt.Errorf("Merge conflict, found multiple objects %v the Resmap %v can merge into", matchedId, id)
|
||||
return nil, fmt.Errorf("merge conflict, found multiple objects %v the Resmap %v can merge into", matchedId, id)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ func (pt *patchTransformer) Transform(baseResourceMap resmap.ResMap) error {
|
||||
return fmt.Errorf("failed to find an object with %#v to apply the patch", id.Gvk())
|
||||
}
|
||||
if len(matchedIds) > 1 {
|
||||
return fmt.Errorf("Found multiple objects %#v that the patch %#v can apply", matchedIds, id)
|
||||
return fmt.Errorf("found multiple objects %#v targeted by patch %#v (ambiguous)", matchedIds, id)
|
||||
}
|
||||
id = matchedIds[0]
|
||||
base := baseResourceMap[id]
|
||||
|
||||
Reference in New Issue
Block a user