mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-11 17:12:51 +00:00
Merge pull request #2984 from phanimarupaka/FixCmdCfgIssues
Do not print package info in grep
This commit is contained in:
@@ -120,6 +120,7 @@ func (r *GrepRunner) runE(c *cobra.Command, args []string) error {
|
|||||||
recurseSubPackages: r.RecurseSubPackages,
|
recurseSubPackages: r.RecurseSubPackages,
|
||||||
cmdRunner: r,
|
cmdRunner: r,
|
||||||
rootPkgPath: args[1],
|
rootPkgPath: args[1],
|
||||||
|
skipPkgPathPrint: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
return e.execute()
|
return e.execute()
|
||||||
@@ -152,5 +153,6 @@ func (r *GrepRunner) executeCmd(w io.Writer, pkgPath string) error {
|
|||||||
fmt.Fprintf(w, "%s\n", err.Error())
|
fmt.Fprintf(w, "%s\n", err.Error())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
fmt.Fprintf(w, "---")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -283,8 +283,7 @@ func TestGrepSubPackages(t *testing.T) {
|
|||||||
name: "grep-recurse-subpackages",
|
name: "grep-recurse-subpackages",
|
||||||
dataset: "dataset-without-setters",
|
dataset: "dataset-without-setters",
|
||||||
args: []string{"kind=Deployment"},
|
args: []string{"kind=Deployment"},
|
||||||
expected: `${baseDir}/mysql/
|
expected: `# Copyright 2019 The Kubernetes Authors.
|
||||||
# Copyright 2019 The Kubernetes Authors.
|
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
apiVersion: apps/v1
|
apiVersion: apps/v1
|
||||||
@@ -302,8 +301,7 @@ spec:
|
|||||||
containers:
|
containers:
|
||||||
- name: mysql
|
- name: mysql
|
||||||
image: mysql:1.7.9
|
image: mysql:1.7.9
|
||||||
|
---
|
||||||
${baseDir}/mysql/storage/
|
|
||||||
# Copyright 2019 The Kubernetes Authors.
|
# Copyright 2019 The Kubernetes Authors.
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
@@ -322,15 +320,14 @@ spec:
|
|||||||
containers:
|
containers:
|
||||||
- name: storage
|
- name: storage
|
||||||
image: storage:1.7.7
|
image: storage:1.7.7
|
||||||
`,
|
---`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "grep-top-level-pkg-no-recurse-subpackages",
|
name: "grep-top-level-pkg-no-recurse-subpackages",
|
||||||
dataset: "dataset-without-setters",
|
dataset: "dataset-without-setters",
|
||||||
args: []string{"kind=Deployment", "-R=false"},
|
args: []string{"kind=Deployment", "-R=false"},
|
||||||
packagePath: "mysql",
|
packagePath: "mysql",
|
||||||
expected: `${baseDir}/mysql/
|
expected: `# Copyright 2019 The Kubernetes Authors.
|
||||||
# Copyright 2019 The Kubernetes Authors.
|
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
apiVersion: apps/v1
|
apiVersion: apps/v1
|
||||||
@@ -348,15 +345,14 @@ spec:
|
|||||||
containers:
|
containers:
|
||||||
- name: mysql
|
- name: mysql
|
||||||
image: mysql:1.7.9
|
image: mysql:1.7.9
|
||||||
`,
|
---`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "grep-nested-pkg-no-recurse-subpackages",
|
name: "grep-nested-pkg-no-recurse-subpackages",
|
||||||
dataset: "dataset-without-setters",
|
dataset: "dataset-without-setters",
|
||||||
packagePath: "mysql/storage",
|
packagePath: "mysql/storage",
|
||||||
args: []string{"kind=Deployment", "-R=false"},
|
args: []string{"kind=Deployment", "-R=false"},
|
||||||
expected: `${baseDir}/mysql/storage/
|
expected: `# Copyright 2019 The Kubernetes Authors.
|
||||||
# Copyright 2019 The Kubernetes Authors.
|
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
apiVersion: apps/v1
|
apiVersion: apps/v1
|
||||||
@@ -374,7 +370,7 @@ spec:
|
|||||||
containers:
|
containers:
|
||||||
- name: storage
|
- name: storage
|
||||||
image: storage:1.7.7
|
image: storage:1.7.7
|
||||||
`,
|
---`,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
for i := range tests {
|
for i := range tests {
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ func DirsWithFile(root, fileName string, recurse bool) ([]string, error) {
|
|||||||
// else return empty list
|
// else return empty list
|
||||||
_, err := os.Stat(filepath.Join(root, fileName))
|
_, err := os.Stat(filepath.Join(root, fileName))
|
||||||
if !os.IsNotExist(err) {
|
if !os.IsNotExist(err) {
|
||||||
res = append(res, root)
|
res = append(res, filepath.Clean(root))
|
||||||
}
|
}
|
||||||
return res, nil
|
return res, nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user