Skip to content

Commit 1925418

Browse files
Check namespace on create of objects like update
A user should be allowed to create an object in a non-default namespace if non is specified in the passed file.
1 parent a8d43eb commit 1925418

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

pkg/kubectl/cmd/create.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,14 @@ Examples:
4747
client, err := f.Client(cmd, mapping)
4848
checkErr(err)
4949

50+
// use the default namespace if not specified, or check for conflict with the file's namespace
51+
if len(namespace) == 0 {
52+
namespace = getKubeNamespace(cmd)
53+
} else {
54+
err = CompareNamespaceFromFile(cmd, namespace)
55+
checkErr(err)
56+
}
57+
5058
err = kubectl.NewRESTHelper(client, mapping).Create(namespace, true, data)
5159
checkErr(err)
5260
fmt.Fprintf(out, "%s\n", name)

0 commit comments

Comments
 (0)