Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
91744297
Commit
91744297
authored
Oct 15, 2016
by
Kubernetes Submit Queue
Committed by
GitHub
Oct 15, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #33546 from k82cn/k8s_15834
Automatic merge from submit-queue Updated err message when retrieving resources by name with --all-name… fixes #15834
parents
88d6d7a6
005b8dad
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
8 deletions
+21
-8
test-cmd.sh
hack/make-rules/test-cmd.sh
+7
-4
builder.go
pkg/kubectl/resource/builder.go
+14
-4
No files found.
hack/make-rules/test-cmd.sh
View file @
91744297
...
@@ -1581,9 +1581,9 @@ __EOF__
...
@@ -1581,9 +1581,9 @@ __EOF__
# Clean up
# Clean up
kubectl delete namespace my-namespace
kubectl delete namespace my-namespace
##############
##############
########
# Pods in Namespaces #
# Pods in Namespaces #
##############
##############
########
### Create a new namespace
### Create a new namespace
# Pre-condition: the other namespace does not exist
# Pre-condition: the other namespace does not exist
...
@@ -1602,6 +1602,9 @@ __EOF__
...
@@ -1602,6 +1602,9 @@ __EOF__
kube::test::get_object_assert
'pods --namespace=other'
"{{range.items}}{{
$id_field
}}:{{end}}"
'valid-pod:'
kube::test::get_object_assert
'pods --namespace=other'
"{{range.items}}{{
$id_field
}}:{{end}}"
'valid-pod:'
# Post-condition: verify shorthand `-n other` has the same results as `--namespace=other`
# Post-condition: verify shorthand `-n other` has the same results as `--namespace=other`
kube::test::get_object_assert
'pods -n other'
"{{range.items}}{{
$id_field
}}:{{end}}"
'valid-pod:'
kube::test::get_object_assert
'pods -n other'
"{{range.items}}{{
$id_field
}}:{{end}}"
'valid-pod:'
# Post-condition: a resource cannot be retrieved by name across all namespaces
output_message
=
$(
!
kubectl get
"
${
kube_flags
[@]
}
"
pod valid-pod
--all-namespaces
2>&1
)
kube::test::if_has_string
"
${
output_message
}
"
"a resource cannot be retrieved by name across all namespaces"
### Delete POD valid-pod in specific namespace
### Delete POD valid-pod in specific namespace
# Pre-condition: valid-pod POD exists
# Pre-condition: valid-pod POD exists
...
@@ -1613,9 +1616,9 @@ __EOF__
...
@@ -1613,9 +1616,9 @@ __EOF__
# Clean up
# Clean up
kubectl delete namespace other
kubectl delete namespace other
###########
###
###########
# Secrets #
# Secrets #
###########
###
###########
### Create a new namespace
### Create a new namespace
# Pre-condition: the test-secrets namespace does not exist
# Pre-condition: the test-secrets namespace does not exist
...
...
pkg/kubectl/resource/builder.go
View file @
91744297
...
@@ -55,8 +55,9 @@ type Builder struct {
...
@@ -55,8 +55,9 @@ type Builder struct {
resources
[]
string
resources
[]
string
namespace
string
namespace
string
names
[]
string
allNamespace
bool
names
[]
string
resourceTuples
[]
resourceTuple
resourceTuples
[]
resourceTuple
...
@@ -296,6 +297,7 @@ func (b *Builder) AllNamespaces(allNamespace bool) *Builder {
...
@@ -296,6 +297,7 @@ func (b *Builder) AllNamespaces(allNamespace bool) *Builder {
if
allNamespace
{
if
allNamespace
{
b
.
namespace
=
api
.
NamespaceAll
b
.
namespace
=
api
.
NamespaceAll
}
}
b
.
allNamespace
=
allNamespace
return
b
return
b
}
}
...
@@ -644,7 +646,11 @@ func (b *Builder) visitByResource() *Result {
...
@@ -644,7 +646,11 @@ func (b *Builder) visitByResource() *Result {
selectorNamespace
=
""
selectorNamespace
=
""
}
else
{
}
else
{
if
len
(
b
.
namespace
)
==
0
{
if
len
(
b
.
namespace
)
==
0
{
return
&
Result
{
singular
:
isSingular
,
err
:
fmt
.
Errorf
(
"namespace may not be empty when retrieving a resource by name"
)}
errMsg
:=
"namespace may not be empty when retrieving a resource by name"
if
b
.
allNamespace
{
errMsg
=
"a resource cannot be retrieved by name across all namespaces"
}
return
&
Result
{
singular
:
isSingular
,
err
:
fmt
.
Errorf
(
errMsg
)}
}
}
}
}
...
@@ -690,7 +696,11 @@ func (b *Builder) visitByName() *Result {
...
@@ -690,7 +696,11 @@ func (b *Builder) visitByName() *Result {
selectorNamespace
=
""
selectorNamespace
=
""
}
else
{
}
else
{
if
len
(
b
.
namespace
)
==
0
{
if
len
(
b
.
namespace
)
==
0
{
return
&
Result
{
singular
:
isSingular
,
err
:
fmt
.
Errorf
(
"namespace may not be empty when retrieving a resource by name"
)}
errMsg
:=
"namespace may not be empty when retrieving a resource by name"
if
b
.
allNamespace
{
errMsg
=
"a resource cannot be retrieved by name across all namespaces"
}
return
&
Result
{
singular
:
isSingular
,
err
:
fmt
.
Errorf
(
errMsg
)}
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment