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
f0b616c0
Unverified
Commit
f0b616c0
authored
Mar 27, 2018
by
Jordan Liggitt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ensure -o yaml populates kind/apiVersion
parent
233cb1f9
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
0 deletions
+20
-0
test-cmd-util.sh
hack/make-rules/test-cmd-util.sh
+7
-0
create_clusterrole_test.go
pkg/kubectl/cmd/create_clusterrole_test.go
+4
-0
create_role_test.go
pkg/kubectl/cmd/create_role_test.go
+4
-0
versioned.go
pkg/printers/versioned.go
+5
-0
No files found.
hack/make-rules/test-cmd-util.sh
View file @
f0b616c0
...
@@ -2385,6 +2385,13 @@ run_secrets_test() {
...
@@ -2385,6 +2385,13 @@ run_secrets_test() {
create_and_use_new_namespace
create_and_use_new_namespace
kube::log::status
"Testing secrets"
kube::log::status
"Testing secrets"
# Ensure dry run succeeds and includes kind, apiVersion and data
output_message
=
$(
kubectl create secret generic
test
--from-literal
=
key1
=
value1
--dry-run
-o
yaml
)
kube::test::if_has_string
"
${
output_message
}
"
'kind: Secret'
kube::test::if_has_string
"
${
output_message
}
"
'apiVersion: v1'
kube::test::if_has_string
"
${
output_message
}
"
'key1: dmFsdWUx'
### 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
kube::test::get_object_assert
'namespaces'
'{{range.items}}{{ if eq $id_field \"test-secrets\" }}found{{end}}{{end}}:'
':'
kube::test::get_object_assert
'namespaces'
'{{range.items}}{{ if eq $id_field \"test-secrets\" }}found{{end}}{{end}}:'
':'
...
...
pkg/kubectl/cmd/create_clusterrole_test.go
View file @
f0b616c0
...
@@ -50,6 +50,7 @@ func TestCreateClusterRole(t *testing.T) {
...
@@ -50,6 +50,7 @@ func TestCreateClusterRole(t *testing.T) {
verbs
:
"get,watch,list"
,
verbs
:
"get,watch,list"
,
resources
:
"pods,pods"
,
resources
:
"pods,pods"
,
expectedClusterRole
:
&
rbac
.
ClusterRole
{
expectedClusterRole
:
&
rbac
.
ClusterRole
{
TypeMeta
:
v1
.
TypeMeta
{
APIVersion
:
"rbac.authorization.k8s.io/v1"
,
Kind
:
"ClusterRole"
},
ObjectMeta
:
v1
.
ObjectMeta
{
ObjectMeta
:
v1
.
ObjectMeta
{
Name
:
clusterRoleName
,
Name
:
clusterRoleName
,
},
},
...
@@ -67,6 +68,7 @@ func TestCreateClusterRole(t *testing.T) {
...
@@ -67,6 +68,7 @@ func TestCreateClusterRole(t *testing.T) {
verbs
:
"get,watch,list"
,
verbs
:
"get,watch,list"
,
resources
:
"pods,deployments.extensions"
,
resources
:
"pods,deployments.extensions"
,
expectedClusterRole
:
&
rbac
.
ClusterRole
{
expectedClusterRole
:
&
rbac
.
ClusterRole
{
TypeMeta
:
v1
.
TypeMeta
{
APIVersion
:
"rbac.authorization.k8s.io/v1"
,
Kind
:
"ClusterRole"
},
ObjectMeta
:
v1
.
ObjectMeta
{
ObjectMeta
:
v1
.
ObjectMeta
{
Name
:
clusterRoleName
,
Name
:
clusterRoleName
,
},
},
...
@@ -90,6 +92,7 @@ func TestCreateClusterRole(t *testing.T) {
...
@@ -90,6 +92,7 @@ func TestCreateClusterRole(t *testing.T) {
verbs
:
"get"
,
verbs
:
"get"
,
nonResourceURL
:
"/logs/,/healthz"
,
nonResourceURL
:
"/logs/,/healthz"
,
expectedClusterRole
:
&
rbac
.
ClusterRole
{
expectedClusterRole
:
&
rbac
.
ClusterRole
{
TypeMeta
:
v1
.
TypeMeta
{
APIVersion
:
"rbac.authorization.k8s.io/v1"
,
Kind
:
"ClusterRole"
},
ObjectMeta
:
v1
.
ObjectMeta
{
ObjectMeta
:
v1
.
ObjectMeta
{
Name
:
clusterRoleName
,
Name
:
clusterRoleName
,
},
},
...
@@ -106,6 +109,7 @@ func TestCreateClusterRole(t *testing.T) {
...
@@ -106,6 +109,7 @@ func TestCreateClusterRole(t *testing.T) {
nonResourceURL
:
"/logs/,/healthz"
,
nonResourceURL
:
"/logs/,/healthz"
,
resources
:
"pods"
,
resources
:
"pods"
,
expectedClusterRole
:
&
rbac
.
ClusterRole
{
expectedClusterRole
:
&
rbac
.
ClusterRole
{
TypeMeta
:
v1
.
TypeMeta
{
APIVersion
:
"rbac.authorization.k8s.io/v1"
,
Kind
:
"ClusterRole"
},
ObjectMeta
:
v1
.
ObjectMeta
{
ObjectMeta
:
v1
.
ObjectMeta
{
Name
:
clusterRoleName
,
Name
:
clusterRoleName
,
},
},
...
...
pkg/kubectl/cmd/create_role_test.go
View file @
f0b616c0
...
@@ -51,6 +51,7 @@ func TestCreateRole(t *testing.T) {
...
@@ -51,6 +51,7 @@ func TestCreateRole(t *testing.T) {
verbs
:
"get,watch,list"
,
verbs
:
"get,watch,list"
,
resources
:
"pods,pods"
,
resources
:
"pods,pods"
,
expectedRole
:
&
rbac
.
Role
{
expectedRole
:
&
rbac
.
Role
{
TypeMeta
:
v1
.
TypeMeta
{
APIVersion
:
"rbac.authorization.k8s.io/v1"
,
Kind
:
"Role"
},
ObjectMeta
:
v1
.
ObjectMeta
{
ObjectMeta
:
v1
.
ObjectMeta
{
Name
:
roleName
,
Name
:
roleName
,
},
},
...
@@ -68,6 +69,7 @@ func TestCreateRole(t *testing.T) {
...
@@ -68,6 +69,7 @@ func TestCreateRole(t *testing.T) {
verbs
:
"get,watch,list"
,
verbs
:
"get,watch,list"
,
resources
:
"replicasets/scale"
,
resources
:
"replicasets/scale"
,
expectedRole
:
&
rbac
.
Role
{
expectedRole
:
&
rbac
.
Role
{
TypeMeta
:
v1
.
TypeMeta
{
APIVersion
:
"rbac.authorization.k8s.io/v1"
,
Kind
:
"Role"
},
ObjectMeta
:
v1
.
ObjectMeta
{
ObjectMeta
:
v1
.
ObjectMeta
{
Name
:
roleName
,
Name
:
roleName
,
},
},
...
@@ -85,6 +87,7 @@ func TestCreateRole(t *testing.T) {
...
@@ -85,6 +87,7 @@ func TestCreateRole(t *testing.T) {
verbs
:
"get,watch,list"
,
verbs
:
"get,watch,list"
,
resources
:
"replicasets.extensions/scale"
,
resources
:
"replicasets.extensions/scale"
,
expectedRole
:
&
rbac
.
Role
{
expectedRole
:
&
rbac
.
Role
{
TypeMeta
:
v1
.
TypeMeta
{
APIVersion
:
"rbac.authorization.k8s.io/v1"
,
Kind
:
"Role"
},
ObjectMeta
:
v1
.
ObjectMeta
{
ObjectMeta
:
v1
.
ObjectMeta
{
Name
:
roleName
,
Name
:
roleName
,
},
},
...
@@ -102,6 +105,7 @@ func TestCreateRole(t *testing.T) {
...
@@ -102,6 +105,7 @@ func TestCreateRole(t *testing.T) {
verbs
:
"get,watch,list"
,
verbs
:
"get,watch,list"
,
resources
:
"pods,deployments.extensions"
,
resources
:
"pods,deployments.extensions"
,
expectedRole
:
&
rbac
.
Role
{
expectedRole
:
&
rbac
.
Role
{
TypeMeta
:
v1
.
TypeMeta
{
APIVersion
:
"rbac.authorization.k8s.io/v1"
,
Kind
:
"Role"
},
ObjectMeta
:
v1
.
ObjectMeta
{
ObjectMeta
:
v1
.
ObjectMeta
{
Name
:
roleName
,
Name
:
roleName
,
},
},
...
...
pkg/printers/versioned.go
View file @
f0b616c0
...
@@ -76,6 +76,11 @@ func (p *VersionedPrinter) PrintObj(obj runtime.Object, w io.Writer) error {
...
@@ -76,6 +76,11 @@ func (p *VersionedPrinter) PrintObj(obj runtime.Object, w io.Writer) error {
}
}
if
!
needsConversion
{
if
!
needsConversion
{
// We might be an external type, but have empty kind/apiVersion fields. Ensure they are populated before printing.
if
obj
.
GetObjectKind
()
.
GroupVersionKind
()
.
Empty
()
{
obj
=
obj
.
DeepCopyObject
()
obj
.
GetObjectKind
()
.
SetGroupVersionKind
(
gvks
[
0
])
}
return
p
.
printer
.
PrintObj
(
obj
,
w
)
return
p
.
printer
.
PrintObj
(
obj
,
w
)
}
}
...
...
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