mirror of https://github.com/k3s-io/k3s
Merge pull request #48244 from xilabao/add-validation-when-create-directory
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. add validation in kubectl create if no file in directory **What this PR does / why we need it**: if no yaml or json file in a directory ``` # ./cluster/kubectl.sh create -f ../0/1 --dry-run pod "nginx" created (dry run) # ./cluster/kubectl.sh create -f ../0 error: You must provide one or more resources by argument or filename. Example resource specifications include: '-f rsrc.yaml' '--filename=rsrc.json' '<resource> <name>' '<resource>' ``` expected: ``` # ./cluster/kubectl.sh create -f ../0 error: error reading [../0]: please make sure the file extension is [.json .yaml .yml] ``` **Which issue this PR fixes**: fixes # **Special notes for your reviewer**: **Release note**: ```release-note NONE ```pull/8/head
commit
c36e66dd66
|
@ -287,6 +287,9 @@ func (b *Builder) Path(recursive bool, paths ...string) *Builder {
|
|||
|
||||
b.paths = append(b.paths, visitors...)
|
||||
}
|
||||
if len(b.paths) == 0 && len(b.errs) == 0 {
|
||||
b.errs = append(b.errs, fmt.Errorf("error reading %v: recognized file extensions are %v", paths, FileExtensions))
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue