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
0118630a
Unverified
Commit
0118630a
authored
Mar 21, 2019
by
Kubernetes Prow Robot
Committed by
GitHub
Mar 21, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #75072 from lblackstone/dynamic-get-name-validation
Check for required name parameter in dynamic client
parents
657951c3
a9cba032
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
2 deletions
+23
-2
simple.go
staging/src/k8s.io/client-go/dynamic/simple.go
+23
-2
No files found.
staging/src/k8s.io/client-go/dynamic/simple.go
View file @
0118630a
...
@@ -17,6 +17,7 @@ limitations under the License.
...
@@ -17,6 +17,7 @@ limitations under the License.
package
dynamic
package
dynamic
import
(
import
(
"fmt"
"io"
"io"
"k8s.io/apimachinery/pkg/api/meta"
"k8s.io/apimachinery/pkg/api/meta"
...
@@ -102,6 +103,9 @@ func (c *dynamicResourceClient) Create(obj *unstructured.Unstructured, opts meta
...
@@ -102,6 +103,9 @@ func (c *dynamicResourceClient) Create(obj *unstructured.Unstructured, opts meta
return
nil
,
err
return
nil
,
err
}
}
name
=
accessor
.
GetName
()
name
=
accessor
.
GetName
()
if
len
(
name
)
==
0
{
return
nil
,
fmt
.
Errorf
(
"name is required"
)
}
}
}
result
:=
c
.
client
.
client
.
result
:=
c
.
client
.
client
.
...
@@ -130,6 +134,10 @@ func (c *dynamicResourceClient) Update(obj *unstructured.Unstructured, opts meta
...
@@ -130,6 +134,10 @@ func (c *dynamicResourceClient) Update(obj *unstructured.Unstructured, opts meta
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
name
:=
accessor
.
GetName
()
if
len
(
name
)
==
0
{
return
nil
,
fmt
.
Errorf
(
"name is required"
)
}
outBytes
,
err
:=
runtime
.
Encode
(
unstructured
.
UnstructuredJSONScheme
,
obj
)
outBytes
,
err
:=
runtime
.
Encode
(
unstructured
.
UnstructuredJSONScheme
,
obj
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
...
@@ -137,7 +145,7 @@ func (c *dynamicResourceClient) Update(obj *unstructured.Unstructured, opts meta
...
@@ -137,7 +145,7 @@ func (c *dynamicResourceClient) Update(obj *unstructured.Unstructured, opts meta
result
:=
c
.
client
.
client
.
result
:=
c
.
client
.
client
.
Put
()
.
Put
()
.
AbsPath
(
append
(
c
.
makeURLSegments
(
accessor
.
GetName
()
),
subresources
...
)
...
)
.
AbsPath
(
append
(
c
.
makeURLSegments
(
name
),
subresources
...
)
...
)
.
Body
(
outBytes
)
.
Body
(
outBytes
)
.
SpecificallyVersionedParams
(
&
opts
,
dynamicParameterCodec
,
versionV1
)
.
SpecificallyVersionedParams
(
&
opts
,
dynamicParameterCodec
,
versionV1
)
.
Do
()
Do
()
...
@@ -161,6 +169,10 @@ func (c *dynamicResourceClient) UpdateStatus(obj *unstructured.Unstructured, opt
...
@@ -161,6 +169,10 @@ func (c *dynamicResourceClient) UpdateStatus(obj *unstructured.Unstructured, opt
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
name
:=
accessor
.
GetName
()
if
len
(
name
)
==
0
{
return
nil
,
fmt
.
Errorf
(
"name is required"
)
}
outBytes
,
err
:=
runtime
.
Encode
(
unstructured
.
UnstructuredJSONScheme
,
obj
)
outBytes
,
err
:=
runtime
.
Encode
(
unstructured
.
UnstructuredJSONScheme
,
obj
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -169,7 +181,7 @@ func (c *dynamicResourceClient) UpdateStatus(obj *unstructured.Unstructured, opt
...
@@ -169,7 +181,7 @@ func (c *dynamicResourceClient) UpdateStatus(obj *unstructured.Unstructured, opt
result
:=
c
.
client
.
client
.
result
:=
c
.
client
.
client
.
Put
()
.
Put
()
.
AbsPath
(
append
(
c
.
makeURLSegments
(
accessor
.
GetName
()
),
"status"
)
...
)
.
AbsPath
(
append
(
c
.
makeURLSegments
(
name
),
"status"
)
...
)
.
Body
(
outBytes
)
.
Body
(
outBytes
)
.
SpecificallyVersionedParams
(
&
opts
,
dynamicParameterCodec
,
versionV1
)
.
SpecificallyVersionedParams
(
&
opts
,
dynamicParameterCodec
,
versionV1
)
.
Do
()
Do
()
...
@@ -189,6 +201,9 @@ func (c *dynamicResourceClient) UpdateStatus(obj *unstructured.Unstructured, opt
...
@@ -189,6 +201,9 @@ func (c *dynamicResourceClient) UpdateStatus(obj *unstructured.Unstructured, opt
}
}
func
(
c
*
dynamicResourceClient
)
Delete
(
name
string
,
opts
*
metav1
.
DeleteOptions
,
subresources
...
string
)
error
{
func
(
c
*
dynamicResourceClient
)
Delete
(
name
string
,
opts
*
metav1
.
DeleteOptions
,
subresources
...
string
)
error
{
if
len
(
name
)
==
0
{
return
fmt
.
Errorf
(
"name is required"
)
}
if
opts
==
nil
{
if
opts
==
nil
{
opts
=
&
metav1
.
DeleteOptions
{}
opts
=
&
metav1
.
DeleteOptions
{}
}
}
...
@@ -224,6 +239,9 @@ func (c *dynamicResourceClient) DeleteCollection(opts *metav1.DeleteOptions, lis
...
@@ -224,6 +239,9 @@ func (c *dynamicResourceClient) DeleteCollection(opts *metav1.DeleteOptions, lis
}
}
func
(
c
*
dynamicResourceClient
)
Get
(
name
string
,
opts
metav1
.
GetOptions
,
subresources
...
string
)
(
*
unstructured
.
Unstructured
,
error
)
{
func
(
c
*
dynamicResourceClient
)
Get
(
name
string
,
opts
metav1
.
GetOptions
,
subresources
...
string
)
(
*
unstructured
.
Unstructured
,
error
)
{
if
len
(
name
)
==
0
{
return
nil
,
fmt
.
Errorf
(
"name is required"
)
}
result
:=
c
.
client
.
client
.
Get
()
.
AbsPath
(
append
(
c
.
makeURLSegments
(
name
),
subresources
...
)
...
)
.
SpecificallyVersionedParams
(
&
opts
,
dynamicParameterCodec
,
versionV1
)
.
Do
()
result
:=
c
.
client
.
client
.
Get
()
.
AbsPath
(
append
(
c
.
makeURLSegments
(
name
),
subresources
...
)
...
)
.
SpecificallyVersionedParams
(
&
opts
,
dynamicParameterCodec
,
versionV1
)
.
Do
()
if
err
:=
result
.
Error
();
err
!=
nil
{
if
err
:=
result
.
Error
();
err
!=
nil
{
return
nil
,
err
return
nil
,
err
...
@@ -292,6 +310,9 @@ func (c *dynamicResourceClient) Watch(opts metav1.ListOptions) (watch.Interface,
...
@@ -292,6 +310,9 @@ func (c *dynamicResourceClient) Watch(opts metav1.ListOptions) (watch.Interface,
}
}
func
(
c
*
dynamicResourceClient
)
Patch
(
name
string
,
pt
types
.
PatchType
,
data
[]
byte
,
opts
metav1
.
PatchOptions
,
subresources
...
string
)
(
*
unstructured
.
Unstructured
,
error
)
{
func
(
c
*
dynamicResourceClient
)
Patch
(
name
string
,
pt
types
.
PatchType
,
data
[]
byte
,
opts
metav1
.
PatchOptions
,
subresources
...
string
)
(
*
unstructured
.
Unstructured
,
error
)
{
if
len
(
name
)
==
0
{
return
nil
,
fmt
.
Errorf
(
"name is required"
)
}
result
:=
c
.
client
.
client
.
result
:=
c
.
client
.
client
.
Patch
(
pt
)
.
Patch
(
pt
)
.
AbsPath
(
append
(
c
.
makeURLSegments
(
name
),
subresources
...
)
...
)
.
AbsPath
(
append
(
c
.
makeURLSegments
(
name
),
subresources
...
)
...
)
.
...
...
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