Skip to content

Commit

Permalink
fix patch.Target is nil in writePatchTargets
Browse files Browse the repository at this point in the history
  • Loading branch information
Aceralon committed Nov 5, 2023
1 parent e7c8ed1 commit 5494a47
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions kustomize/commands/edit/fix/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ import (
"strconv"
"strings"

"sigs.k8s.io/yaml"

"sigs.k8s.io/kustomize/api/types"
"sigs.k8s.io/kustomize/kyaml/filesys"
"sigs.k8s.io/kustomize/kyaml/kio"
"sigs.k8s.io/kustomize/kyaml/resid"
kyaml "sigs.k8s.io/kustomize/kyaml/yaml"
"sigs.k8s.io/yaml"
)

func ConvertVarsToReplacements(fSys filesys.FileSystem, k *types.Kustomization) error {
Expand Down Expand Up @@ -134,7 +135,7 @@ func getNodesFromFile(fileName string, fSys filesys.FileSystem) ([]*kyaml.RNode,
}
out := &bytes.Buffer{}
r := kio.ByteReadWriter{
Reader: bytes.NewBufferString(string(b)),
Reader: bytes.NewReader(b),
Writer: out,
KeepReaderAnnotations: true,
OmitReaderAnnotations: true,
Expand Down Expand Up @@ -284,7 +285,11 @@ func constructTargets(file string, node *kyaml.RNode, fieldPaths []string,
func writePatchTargets(patch types.Patch, node *kyaml.RNode, fieldPaths []string,
options []*types.FieldOptions) ([]*types.TargetSelector, error) {
var result []*types.TargetSelector
selector := patch.Target.Copy()

selector := types.Selector{}
if patch.Target != nil {
selector = patch.Target.Copy()
}

for i := range fieldPaths {
target := &types.TargetSelector{
Expand Down

0 comments on commit 5494a47

Please sign in to comment.