mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 03:41:45 +00:00
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.
This commit is contained in:
parent
a8d43eb784
commit
192541824f
@ -47,6 +47,14 @@ Examples:
|
||||
client, err := f.Client(cmd, mapping)
|
||||
checkErr(err)
|
||||
|
||||
// use the default namespace if not specified, or check for conflict with the file's namespace
|
||||
if len(namespace) == 0 {
|
||||
namespace = getKubeNamespace(cmd)
|
||||
} else {
|
||||
err = CompareNamespaceFromFile(cmd, namespace)
|
||||
checkErr(err)
|
||||
}
|
||||
|
||||
err = kubectl.NewRESTHelper(client, mapping).Create(namespace, true, data)
|
||||
checkErr(err)
|
||||
fmt.Fprintf(out, "%s\n", name)
|
||||
|
Loading…
Reference in New Issue
Block a user