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
9c42d219
Commit
9c42d219
authored
Feb 12, 2016
by
deads2k
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
allow disambiguation of resouces
parent
2b84d58b
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
18 additions
and
7 deletions
+18
-7
test-cmd.sh
hack/test-cmd.sh
+4
-4
group_version.go
pkg/api/unversioned/group_version.go
+11
-0
explain.go
pkg/kubectl/cmd/explain.go
+1
-1
builder.go
pkg/kubectl/resource/builder.go
+2
-2
No files found.
hack/test-cmd.sh
View file @
9c42d219
...
...
@@ -702,7 +702,7 @@ __EOF__
# Command: autoscale rc "frontend"
kubectl autoscale
-f
hack/testdata/frontend-controller.yaml
--save-config
"
${
kube_flags
[@]
}
"
--max
=
2
# Post-Condition: hpa "frontend" has configuration annotation
[[
"
$(
kubectl get hpa frontend
-o
yaml
"
${
kube_flags
[@]
}
"
|
grep
kubectl.kubernetes.io/last-applied-configuration
)
"
]]
[[
"
$(
kubectl get hpa
.extensions
frontend
-o
yaml
"
${
kube_flags
[@]
}
"
|
grep
kubectl.kubernetes.io/last-applied-configuration
)
"
]]
# Clean up
kubectl delete rc,hpa frontend
"
${
kube_flags
[@]
}
"
...
...
@@ -1191,10 +1191,10 @@ __EOF__
kube::test::get_object_assert deployment
"{{range.items}}{{
$id_field
}}:{{end}}"
'nginx-deployment:'
# autoscale 2~3 pods, default CPU utilization (80%)
kubectl-with-retry autoscale deployment nginx-deployment
"
${
kube_flags
[@]
}
"
--min
=
2
--max
=
3
kube::test::get_object_assert
'hpa nginx-deployment'
"{{
$hpa_min_field
}} {{
$hpa_max_field
}} {{
$hpa_cpu_field
}}"
'2 3 80'
kube::test::get_object_assert
'hpa
.extensions
nginx-deployment'
"{{
$hpa_min_field
}} {{
$hpa_max_field
}} {{
$hpa_cpu_field
}}"
'2 3 80'
# Clean up
kubectl delete hpa nginx-deployment
"
${
kube_flags
[@]
}
"
kubectl delete deployment nginx-deployment
"
${
kube_flags
[@]
}
"
kubectl delete deployment
.extensions
nginx-deployment
"
${
kube_flags
[@]
}
"
### Rollback a deployment
# Pre-condition: no deployment exists
...
...
@@ -1209,7 +1209,7 @@ __EOF__
kube::test::get_object_assert deployment
"{{range.items}}{{
$deployment_image_field
}}:{{end}}"
'nginx:'
# Update the deployment (revision 2)
kubectl apply
-f
hack/testdata/deployment-revision2.yaml
"
${
kube_flags
[@]
}
"
kube::test::get_object_assert deployment
"{{range.items}}{{
$deployment_image_field
}}:{{end}}"
'nginx:latest:'
kube::test::get_object_assert deployment
.extensions
"{{range.items}}{{
$deployment_image_field
}}:{{end}}"
'nginx:latest:'
# Rollback to revision 1
kubectl rollout undo deployment nginx-deployment
--to-revision
=
1
"
${
kube_flags
[@]
}
"
sleep
1
...
...
pkg/api/unversioned/group_version.go
View file @
9c42d219
...
...
@@ -46,6 +46,17 @@ func (gr *GroupResource) String() string {
return
gr
.
Resource
+
"."
+
gr
.
Group
}
// ParseGroupResource turns "resource.group" string into a GroupResource struct. Empty strings are allowed
// for each field.
func
ParseGroupResource
(
gr
string
)
GroupResource
{
s
:=
strings
.
SplitN
(
gr
,
"."
,
2
)
if
len
(
s
)
==
1
{
return
GroupResource
{
Resource
:
s
[
0
]}
}
return
GroupResource
{
Group
:
s
[
1
],
Resource
:
s
[
0
]}
}
// GroupVersionResource unambiguously identifies a resource. It doesn't anonymously include GroupVersion
// to avoid automatic coersion. It doesn't use a GroupVersion to avoid custom marshalling
//
...
...
pkg/kubectl/cmd/explain.go
View file @
9c42d219
...
...
@@ -79,7 +79,7 @@ func RunExplain(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []st
}
// TODO: We should deduce the group for a resource by discovering the supported resources at server.
gvk
,
err
:=
mapper
.
KindFor
(
unversioned
.
GroupVersionResource
{
Resource
:
inModel
}
)
gvk
,
err
:=
mapper
.
KindFor
(
unversioned
.
ParseGroupResource
(
inModel
)
.
WithVersion
(
""
)
)
if
err
!=
nil
{
return
err
}
...
...
pkg/kubectl/resource/builder.go
View file @
9c42d219
...
...
@@ -440,7 +440,7 @@ func (b *Builder) resourceMappings() ([]*meta.RESTMapping, error) {
}
mappings
:=
[]
*
meta
.
RESTMapping
{}
for
_
,
r
:=
range
b
.
resources
{
gvk
,
err
:=
b
.
mapper
.
KindFor
(
unversioned
.
GroupVersionResource
{
Resource
:
r
}
)
gvk
,
err
:=
b
.
mapper
.
KindFor
(
unversioned
.
ParseGroupResource
(
r
)
.
WithVersion
(
""
)
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -460,7 +460,7 @@ func (b *Builder) resourceTupleMappings() (map[string]*meta.RESTMapping, error)
if
_
,
ok
:=
mappings
[
r
.
Resource
];
ok
{
continue
}
gvk
,
err
:=
b
.
mapper
.
KindFor
(
unversioned
.
GroupVersionResource
{
Resource
:
r
.
Resource
}
)
gvk
,
err
:=
b
.
mapper
.
KindFor
(
unversioned
.
ParseGroupResource
(
r
.
Resource
)
.
WithVersion
(
""
)
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
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