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
1aa84d10
Commit
1aa84d10
authored
Apr 25, 2017
by
Fabiano Franz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes get -oname for unstructured objects
parent
98398d5d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
16 deletions
+19
-16
test-cmd-util.sh
hack/make-rules/test-cmd-util.sh
+2
-0
factory_builder.go
pkg/kubectl/cmd/util/factory_builder.go
+4
-1
name.go
pkg/printers/name.go
+13
-15
No files found.
hack/make-rules/test-cmd-util.sh
View file @
1aa84d10
...
@@ -1362,6 +1362,8 @@ __EOF__
...
@@ -1362,6 +1362,8 @@ __EOF__
kubectl
"
${
kube_flags
[@]
}
"
get foos/test
-o
"jsonpath={.someField}"
--allow-missing-template-keys
=
false
kubectl
"
${
kube_flags
[@]
}
"
get foos/test
-o
"jsonpath={.someField}"
--allow-missing-template-keys
=
false
kubectl
"
${
kube_flags
[@]
}
"
get foos
-o
"go-template={{range .items}}{{.someField}}{{end}}"
--allow-missing-template-keys
=
false
kubectl
"
${
kube_flags
[@]
}
"
get foos
-o
"go-template={{range .items}}{{.someField}}{{end}}"
--allow-missing-template-keys
=
false
kubectl
"
${
kube_flags
[@]
}
"
get foos/test
-o
"go-template={{.someField}}"
--allow-missing-template-keys
=
false
kubectl
"
${
kube_flags
[@]
}
"
get foos/test
-o
"go-template={{.someField}}"
--allow-missing-template-keys
=
false
output_message
=
$(
kubectl get foos/test
-o
name
)
kube::test::if_has_string
"
${
output_message
}
"
'foos/test'
# Test patching
# Test patching
kube::log::status
"Testing ThirdPartyResource patching"
kube::log::status
"Testing ThirdPartyResource patching"
...
...
pkg/kubectl/cmd/util/factory_builder.go
View file @
1aa84d10
...
@@ -46,7 +46,10 @@ func NewBuilderFactory(clientAccessFactory ClientAccessFactory, objectMappingFac
...
@@ -46,7 +46,10 @@ func NewBuilderFactory(clientAccessFactory ClientAccessFactory, objectMappingFac
}
}
func
(
f
*
ring2Factory
)
PrinterForCommand
(
cmd
*
cobra
.
Command
)
(
printers
.
ResourcePrinter
,
bool
,
error
)
{
func
(
f
*
ring2Factory
)
PrinterForCommand
(
cmd
*
cobra
.
Command
)
(
printers
.
ResourcePrinter
,
bool
,
error
)
{
mapper
,
typer
:=
f
.
objectMappingFactory
.
Object
()
mapper
,
typer
,
err
:=
f
.
objectMappingFactory
.
UnstructuredObject
()
if
err
!=
nil
{
return
nil
,
false
,
err
}
// TODO: used by the custom column implementation and the name implementation, break this dependency
// TODO: used by the custom column implementation and the name implementation, break this dependency
decoders
:=
[]
runtime
.
Decoder
{
f
.
clientAccessFactory
.
Decoder
(
true
),
unstructured
.
UnstructuredJSONScheme
}
decoders
:=
[]
runtime
.
Decoder
{
f
.
clientAccessFactory
.
Decoder
(
true
),
unstructured
.
UnstructuredJSONScheme
}
return
PrinterForCommand
(
cmd
,
mapper
,
typer
,
decoders
)
return
PrinterForCommand
(
cmd
,
mapper
,
typer
,
decoders
)
...
...
pkg/printers/name.go
View file @
1aa84d10
...
@@ -62,26 +62,24 @@ func (p *NamePrinter) PrintObj(obj runtime.Object, w io.Writer) error {
...
@@ -62,26 +62,24 @@ func (p *NamePrinter) PrintObj(obj runtime.Object, w io.Writer) error {
}
}
}
}
kind
:=
obj
.
GetObjectKind
()
.
GroupVersionKind
()
groupVersionKind
:=
obj
.
GetObjectKind
()
.
GroupVersionKind
()
if
len
(
kind
.
Kind
)
==
0
{
if
len
(
groupVersionKind
.
Kind
)
>
0
{
if
gvks
,
_
,
err
:=
p
.
Typer
.
ObjectKinds
(
obj
);
err
==
nil
{
if
mappings
,
err
:=
p
.
Mapper
.
RESTMappings
(
groupVersionKind
.
GroupKind
(),
groupVersionKind
.
Version
);
err
==
nil
&&
len
(
mappings
)
>
0
{
for
_
,
gvk
:=
range
gvks
{
fmt
.
Fprintf
(
w
,
"%s/%s
\n
"
,
mappings
[
0
]
.
Resource
,
name
)
if
mappings
,
err
:=
p
.
Mapper
.
RESTMappings
(
gvk
.
GroupKind
(),
gvk
.
Version
);
err
==
nil
&&
len
(
mappings
)
>
0
{
return
nil
fmt
.
Fprintf
(
w
,
"%s/%s
\n
"
,
mappings
[
0
]
.
Resource
,
name
)
}
}
}
else
{
fmt
.
Fprintf
(
w
,
"<unknown>/%s
\n
"
,
name
)
}
}
}
}
else
{
if
gvks
,
_
,
err
:=
p
.
Typer
.
ObjectKinds
(
obj
);
err
==
nil
{
if
mappings
,
err
:=
p
.
Mapper
.
RESTMappings
(
kind
.
GroupKind
(),
kind
.
Version
);
err
==
nil
&&
len
(
mappings
)
>
0
{
for
_
,
gvk
:=
range
gvks
{
fmt
.
Fprintf
(
w
,
"%s/%s
\n
"
,
mappings
[
0
]
.
Resource
,
name
)
if
mappings
,
err
:=
p
.
Mapper
.
RESTMappings
(
gvk
.
GroupKind
(),
gvk
.
Version
);
err
==
nil
&&
len
(
mappings
)
>
0
{
}
else
{
fmt
.
Fprintf
(
w
,
"%s/%s
\n
"
,
mappings
[
0
]
.
Resource
,
name
)
fmt
.
Fprintf
(
w
,
"<unknown>/%s
\n
"
,
name
)
return
nil
}
}
}
}
}
fmt
.
Fprintf
(
w
,
"<unknown>/%s
\n
"
,
name
)
return
nil
return
nil
}
}
...
...
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