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
71970d64
Commit
71970d64
authored
Aug 01, 2018
by
Antoine Pelisse
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dry-run: Update DynamicClient to pass Create/Update options
parent
a54c0974
Show whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
108 additions
and
77 deletions
+108
-77
operations.go
pkg/controller/garbagecollector/operations.go
+2
-2
create.go
pkg/kubectl/cmd/create/create.go
+2
-1
expose.go
pkg/kubectl/cmd/expose.go
+2
-1
basic_test.go
...io/apiextensions-apiserver/test/integration/basic_test.go
+8
-8
finalization_test.go
...xtensions-apiserver/test/integration/finalization_test.go
+2
-2
resources.go
...tensions-apiserver/test/integration/fixtures/resources.go
+1
-1
helpers.go
...8s.io/apiextensions-apiserver/test/integration/helpers.go
+1
-1
subresources_test.go
...xtensions-apiserver/test/integration/subresources_test.go
+16
-16
table_test.go
...io/apiextensions-apiserver/test/integration/table_test.go
+1
-1
validation_test.go
...iextensions-apiserver/test/integration/validation_test.go
+4
-4
client.go
staging/src/k8s.io/client-go/deprecated-dynamic/client.go
+3
-3
client_test.go
staging/src/k8s.io/client-go/dynamic/client_test.go
+3
-3
simple.go
staging/src/k8s.io/client-go/dynamic/fake/simple.go
+4
-4
interface.go
staging/src/k8s.io/client-go/dynamic/interface.go
+4
-4
simple.go
staging/src/k8s.io/client-go/dynamic/simple.go
+39
-10
aggregator.go
test/e2e/apimachinery/aggregator.go
+1
-1
crd_watch.go
test/e2e/apimachinery/crd_watch.go
+1
-1
garbage_collector.go
test/e2e/apimachinery/garbage_collector.go
+4
-4
webhook.go
test/e2e/apimachinery/webhook.go
+2
-2
etcd_storage_path_test.go
test/integration/etcd/etcd_storage_path_test.go
+1
-1
garbage_collector_test.go
test/integration/garbagecollector/garbage_collector_test.go
+5
-5
crd_test.go
test/integration/master/crd_test.go
+2
-2
No files found.
pkg/controller/garbagecollector/operations.go
View file @
71970d64
...
@@ -73,7 +73,7 @@ func (gc *GarbageCollector) updateObject(item objectReference, obj *unstructured
...
@@ -73,7 +73,7 @@ func (gc *GarbageCollector) updateObject(item objectReference, obj *unstructured
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
return
gc
.
dynamicClient
.
Resource
(
resource
)
.
Namespace
(
resourceDefaultNamespace
(
namespaced
,
item
.
Namespace
))
.
Update
(
obj
)
return
gc
.
dynamicClient
.
Resource
(
resource
)
.
Namespace
(
resourceDefaultNamespace
(
namespaced
,
item
.
Namespace
))
.
Update
(
obj
,
metav1
.
UpdateOptions
{}
)
}
}
func
(
gc
*
GarbageCollector
)
patchObject
(
item
objectReference
,
patch
[]
byte
,
pt
types
.
PatchType
)
(
*
unstructured
.
Unstructured
,
error
)
{
func
(
gc
*
GarbageCollector
)
patchObject
(
item
objectReference
,
patch
[]
byte
,
pt
types
.
PatchType
)
(
*
unstructured
.
Unstructured
,
error
)
{
...
@@ -81,7 +81,7 @@ func (gc *GarbageCollector) patchObject(item objectReference, patch []byte, pt t
...
@@ -81,7 +81,7 @@ func (gc *GarbageCollector) patchObject(item objectReference, patch []byte, pt t
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
return
gc
.
dynamicClient
.
Resource
(
resource
)
.
Namespace
(
resourceDefaultNamespace
(
namespaced
,
item
.
Namespace
))
.
Patch
(
item
.
Name
,
pt
,
patch
)
return
gc
.
dynamicClient
.
Resource
(
resource
)
.
Namespace
(
resourceDefaultNamespace
(
namespaced
,
item
.
Namespace
))
.
Patch
(
item
.
Name
,
pt
,
patch
,
metav1
.
UpdateOptions
{}
)
}
}
// TODO: Using Patch when strategicmerge supports deleting an entry from a
// TODO: Using Patch when strategicmerge supports deleting an entry from a
...
...
pkg/kubectl/cmd/create/create.go
View file @
71970d64
...
@@ -28,6 +28,7 @@ import (
...
@@ -28,6 +28,7 @@ import (
"github.com/spf13/cobra"
"github.com/spf13/cobra"
"k8s.io/apimachinery/pkg/api/meta"
"k8s.io/apimachinery/pkg/api/meta"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
kruntime
"k8s.io/apimachinery/pkg/runtime"
kruntime
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/runtime/schema"
...
@@ -434,7 +435,7 @@ func (o *CreateSubcommandOptions) Run() error {
...
@@ -434,7 +435,7 @@ func (o *CreateSubcommandOptions) Run() error {
if
mapping
.
Scope
.
Name
()
==
meta
.
RESTScopeNameRoot
{
if
mapping
.
Scope
.
Name
()
==
meta
.
RESTScopeNameRoot
{
o
.
Namespace
=
""
o
.
Namespace
=
""
}
}
actualObject
,
err
:=
o
.
DynamicClient
.
Resource
(
mapping
.
Resource
)
.
Namespace
(
o
.
Namespace
)
.
Create
(
asUnstructured
)
actualObject
,
err
:=
o
.
DynamicClient
.
Resource
(
mapping
.
Resource
)
.
Namespace
(
o
.
Namespace
)
.
Create
(
asUnstructured
,
metav1
.
CreateOptions
{}
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
...
pkg/kubectl/cmd/expose.go
View file @
71970d64
...
@@ -24,6 +24,7 @@ import (
...
@@ -24,6 +24,7 @@ import (
"github.com/spf13/cobra"
"github.com/spf13/cobra"
"k8s.io/apimachinery/pkg/api/meta"
"k8s.io/apimachinery/pkg/api/meta"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured/unstructuredscheme"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured/unstructuredscheme"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime"
...
@@ -341,7 +342,7 @@ func (o *ExposeServiceOptions) RunExpose(cmd *cobra.Command, args []string) erro
...
@@ -341,7 +342,7 @@ func (o *ExposeServiceOptions) RunExpose(cmd *cobra.Command, args []string) erro
return
err
return
err
}
}
// Serialize the object with the annotation applied.
// Serialize the object with the annotation applied.
actualObject
,
err
:=
o
.
DynamicClient
.
Resource
(
objMapping
.
Resource
)
.
Namespace
(
o
.
Namespace
)
.
Create
(
asUnstructured
)
actualObject
,
err
:=
o
.
DynamicClient
.
Resource
(
objMapping
.
Resource
)
.
Namespace
(
o
.
Namespace
)
.
Create
(
asUnstructured
,
metav1
.
CreateOptions
{}
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
...
staging/src/k8s.io/apiextensions-apiserver/test/integration/basic_test.go
View file @
71970d64
...
@@ -213,7 +213,7 @@ func testSimpleCRUD(t *testing.T, ns string, noxuDefinition *apiextensionsv1beta
...
@@ -213,7 +213,7 @@ func testSimpleCRUD(t *testing.T, ns string, noxuDefinition *apiextensionsv1beta
}
}
gottenNoxuInstance
.
Object
[
"updated"
]
=
version2
gottenNoxuInstance
.
Object
[
"updated"
]
=
version2
updatedNoxuInstance
,
err
:=
noxuResourceClient2
.
Update
(
gottenNoxuInstance
)
updatedNoxuInstance
,
err
:=
noxuResourceClient2
.
Update
(
gottenNoxuInstance
,
metav1
.
UpdateOptions
{}
)
if
disabledVersions
[
version2
]
{
if
disabledVersions
[
version2
]
{
if
!
errors
.
IsNotFound
(
err
)
{
if
!
errors
.
IsNotFound
(
err
)
{
t
.
Errorf
(
"expected the update operation fail with NotFound for disabled version %s, got error: %v"
,
version2
,
err
)
t
.
Errorf
(
"expected the update operation fail with NotFound for disabled version %s, got error: %v"
,
version2
,
err
)
...
@@ -580,7 +580,7 @@ func TestSelfLink(t *testing.T) {
...
@@ -580,7 +580,7 @@ func TestSelfLink(t *testing.T) {
noxuNamespacedResourceClient
:=
newNamespacedCustomResourceClient
(
ns
,
dynamicClient
,
noxuDefinition
)
noxuNamespacedResourceClient
:=
newNamespacedCustomResourceClient
(
ns
,
dynamicClient
,
noxuDefinition
)
noxuInstanceToCreate
:=
fixtures
.
NewNoxuInstance
(
ns
,
"foo"
)
noxuInstanceToCreate
:=
fixtures
.
NewNoxuInstance
(
ns
,
"foo"
)
createdNoxuInstance
,
err
:=
noxuNamespacedResourceClient
.
Create
(
noxuInstanceToCreate
)
createdNoxuInstance
,
err
:=
noxuNamespacedResourceClient
.
Create
(
noxuInstanceToCreate
,
metav1
.
CreateOptions
{}
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatal
(
err
)
t
.
Fatal
(
err
)
}
}
...
@@ -599,7 +599,7 @@ func TestSelfLink(t *testing.T) {
...
@@ -599,7 +599,7 @@ func TestSelfLink(t *testing.T) {
curletResourceClient
:=
newNamespacedCustomResourceClient
(
ns
,
dynamicClient
,
curletDefinition
)
curletResourceClient
:=
newNamespacedCustomResourceClient
(
ns
,
dynamicClient
,
curletDefinition
)
curletInstanceToCreate
:=
fixtures
.
NewCurletInstance
(
ns
,
"foo"
)
curletInstanceToCreate
:=
fixtures
.
NewCurletInstance
(
ns
,
"foo"
)
createdCurletInstance
,
err
:=
curletResourceClient
.
Create
(
curletInstanceToCreate
)
createdCurletInstance
,
err
:=
curletResourceClient
.
Create
(
curletInstanceToCreate
,
metav1
.
CreateOptions
{}
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatal
(
err
)
t
.
Fatal
(
err
)
}
}
...
@@ -626,7 +626,7 @@ func TestPreserveInt(t *testing.T) {
...
@@ -626,7 +626,7 @@ func TestPreserveInt(t *testing.T) {
noxuNamespacedResourceClient
:=
newNamespacedCustomResourceClient
(
ns
,
dynamicClient
,
noxuDefinition
)
noxuNamespacedResourceClient
:=
newNamespacedCustomResourceClient
(
ns
,
dynamicClient
,
noxuDefinition
)
noxuInstanceToCreate
:=
fixtures
.
NewNoxuInstance
(
ns
,
"foo"
)
noxuInstanceToCreate
:=
fixtures
.
NewNoxuInstance
(
ns
,
"foo"
)
createdNoxuInstance
,
err
:=
noxuNamespacedResourceClient
.
Create
(
noxuInstanceToCreate
)
createdNoxuInstance
,
err
:=
noxuNamespacedResourceClient
.
Create
(
noxuInstanceToCreate
,
metav1
.
CreateOptions
{}
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatal
(
err
)
t
.
Fatal
(
err
)
}
}
...
@@ -668,25 +668,25 @@ func TestPatch(t *testing.T) {
...
@@ -668,25 +668,25 @@ func TestPatch(t *testing.T) {
noxuNamespacedResourceClient
:=
newNamespacedCustomResourceClient
(
ns
,
dynamicClient
,
noxuDefinition
)
noxuNamespacedResourceClient
:=
newNamespacedCustomResourceClient
(
ns
,
dynamicClient
,
noxuDefinition
)
noxuInstanceToCreate
:=
fixtures
.
NewNoxuInstance
(
ns
,
"foo"
)
noxuInstanceToCreate
:=
fixtures
.
NewNoxuInstance
(
ns
,
"foo"
)
createdNoxuInstance
,
err
:=
noxuNamespacedResourceClient
.
Create
(
noxuInstanceToCreate
)
createdNoxuInstance
,
err
:=
noxuNamespacedResourceClient
.
Create
(
noxuInstanceToCreate
,
metav1
.
CreateOptions
{}
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatal
(
err
)
t
.
Fatal
(
err
)
}
}
patch
:=
[]
byte
(
`{"num": {"num2":999}}`
)
patch
:=
[]
byte
(
`{"num": {"num2":999}}`
)
createdNoxuInstance
,
err
=
noxuNamespacedResourceClient
.
Patch
(
"foo"
,
types
.
MergePatchType
,
patch
)
createdNoxuInstance
,
err
=
noxuNamespacedResourceClient
.
Patch
(
"foo"
,
types
.
MergePatchType
,
patch
,
metav1
.
UpdateOptions
{}
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
}
}
// a patch with no change
// a patch with no change
createdNoxuInstance
,
err
=
noxuNamespacedResourceClient
.
Patch
(
"foo"
,
types
.
MergePatchType
,
patch
)
createdNoxuInstance
,
err
=
noxuNamespacedResourceClient
.
Patch
(
"foo"
,
types
.
MergePatchType
,
patch
,
metav1
.
UpdateOptions
{}
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
}
}
// an empty patch
// an empty patch
createdNoxuInstance
,
err
=
noxuNamespacedResourceClient
.
Patch
(
"foo"
,
types
.
MergePatchType
,
[]
byte
(
`{}`
))
createdNoxuInstance
,
err
=
noxuNamespacedResourceClient
.
Patch
(
"foo"
,
types
.
MergePatchType
,
[]
byte
(
`{}`
)
,
metav1
.
UpdateOptions
{}
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
}
}
...
...
staging/src/k8s.io/apiextensions-apiserver/test/integration/finalization_test.go
View file @
71970d64
...
@@ -76,7 +76,7 @@ func TestFinalization(t *testing.T) {
...
@@ -76,7 +76,7 @@ func TestFinalization(t *testing.T) {
// object will be deleted as part of the finalizer update.
// object will be deleted as part of the finalizer update.
for
{
for
{
gottenNoxuInstance
.
SetFinalizers
(
nil
)
gottenNoxuInstance
.
SetFinalizers
(
nil
)
_
,
err
=
noxuResourceClient
.
Update
(
gottenNoxuInstance
)
_
,
err
=
noxuResourceClient
.
Update
(
gottenNoxuInstance
,
metav1
.
UpdateOptions
{}
)
if
err
==
nil
{
if
err
==
nil
{
break
break
}
}
...
@@ -137,7 +137,7 @@ func TestFinalizationAndDeletion(t *testing.T) {
...
@@ -137,7 +137,7 @@ func TestFinalizationAndDeletion(t *testing.T) {
// Update the CR to remove the finalizer.
// Update the CR to remove the finalizer.
for
{
for
{
gottenNoxuInstance
.
SetFinalizers
(
nil
)
gottenNoxuInstance
.
SetFinalizers
(
nil
)
_
,
err
=
noxuResourceClient
.
Update
(
gottenNoxuInstance
)
_
,
err
=
noxuResourceClient
.
Update
(
gottenNoxuInstance
,
metav1
.
UpdateOptions
{}
)
if
err
==
nil
{
if
err
==
nil
{
break
break
}
}
...
...
staging/src/k8s.io/apiextensions-apiserver/test/integration/fixtures/resources.go
View file @
71970d64
...
@@ -313,7 +313,7 @@ func isWatchCachePrimed(crd *apiextensionsv1beta1.CustomResourceDefinition, dyna
...
@@ -313,7 +313,7 @@ func isWatchCachePrimed(crd *apiextensionsv1beta1.CustomResourceDefinition, dyna
"spec"
:
map
[
string
]
interface
{}{},
"spec"
:
map
[
string
]
interface
{}{},
},
},
}
}
createdInstance
,
err
:=
resourceClient
.
Create
(
instance
)
createdInstance
,
err
:=
resourceClient
.
Create
(
instance
,
metav1
.
CreateOptions
{}
)
if
err
!=
nil
{
if
err
!=
nil
{
return
false
,
err
return
false
,
err
}
}
...
...
staging/src/k8s.io/apiextensions-apiserver/test/integration/helpers.go
View file @
71970d64
...
@@ -35,7 +35,7 @@ func instantiateCustomResource(t *testing.T, instanceToCreate *unstructured.Unst
...
@@ -35,7 +35,7 @@ func instantiateCustomResource(t *testing.T, instanceToCreate *unstructured.Unst
}
}
func
instantiateVersionedCustomResource
(
t
*
testing
.
T
,
instanceToCreate
*
unstructured
.
Unstructured
,
client
dynamic
.
ResourceInterface
,
definition
*
apiextensionsv1beta1
.
CustomResourceDefinition
,
version
string
)
(
*
unstructured
.
Unstructured
,
error
)
{
func
instantiateVersionedCustomResource
(
t
*
testing
.
T
,
instanceToCreate
*
unstructured
.
Unstructured
,
client
dynamic
.
ResourceInterface
,
definition
*
apiextensionsv1beta1
.
CustomResourceDefinition
,
version
string
)
(
*
unstructured
.
Unstructured
,
error
)
{
createdInstance
,
err
:=
client
.
Create
(
instanceToCreate
)
createdInstance
,
err
:=
client
.
Create
(
instanceToCreate
,
metav1
.
CreateOptions
{}
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Logf
(
"%#v"
,
createdInstance
)
t
.
Logf
(
"%#v"
,
createdInstance
)
return
nil
,
err
return
nil
,
err
...
...
staging/src/k8s.io/apiextensions-apiserver/test/integration/subresources_test.go
View file @
71970d64
...
@@ -128,7 +128,7 @@ func TestStatusSubresource(t *testing.T) {
...
@@ -128,7 +128,7 @@ func TestStatusSubresource(t *testing.T) {
// UpdateStatus should not update spec.
// UpdateStatus should not update spec.
// Check that .spec.num = 10 and .status.num = 20
// Check that .spec.num = 10 and .status.num = 20
updatedStatusInstance
,
err
:=
noxuResourceClient
.
UpdateStatus
(
gottenNoxuInstance
)
updatedStatusInstance
,
err
:=
noxuResourceClient
.
UpdateStatus
(
gottenNoxuInstance
,
metav1
.
UpdateOptions
{}
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"unable to update status: %v"
,
err
)
t
.
Fatalf
(
"unable to update status: %v"
,
err
)
}
}
...
@@ -168,7 +168,7 @@ func TestStatusSubresource(t *testing.T) {
...
@@ -168,7 +168,7 @@ func TestStatusSubresource(t *testing.T) {
// Update should not update status.
// Update should not update status.
// Check that .spec.num = 40 and .status.num = 20
// Check that .spec.num = 40 and .status.num = 20
updatedInstance
,
err
:=
noxuResourceClient
.
Update
(
gottenNoxuInstance
)
updatedInstance
,
err
:=
noxuResourceClient
.
Update
(
gottenNoxuInstance
,
metav1
.
UpdateOptions
{}
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"unable to update instance: %v"
,
err
)
t
.
Fatalf
(
"unable to update instance: %v"
,
err
)
}
}
...
@@ -247,7 +247,7 @@ func TestScaleSubresource(t *testing.T) {
...
@@ -247,7 +247,7 @@ func TestScaleSubresource(t *testing.T) {
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
}
}
_
,
err
=
noxuResourceClient
.
UpdateStatus
(
gottenNoxuInstance
)
_
,
err
=
noxuResourceClient
.
UpdateStatus
(
gottenNoxuInstance
,
metav1
.
UpdateOptions
{}
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"unable to update status: %v"
,
err
)
t
.
Fatalf
(
"unable to update status: %v"
,
err
)
}
}
...
@@ -315,7 +315,7 @@ func TestScaleSubresource(t *testing.T) {
...
@@ -315,7 +315,7 @@ func TestScaleSubresource(t *testing.T) {
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
}
}
_
,
err
=
noxuResourceClient
.
Update
(
gottenNoxuInstance
)
_
,
err
=
noxuResourceClient
.
Update
(
gottenNoxuInstance
,
metav1
.
UpdateOptions
{}
)
if
err
==
nil
{
if
err
==
nil
{
t
.
Fatalf
(
"unexpected non-error: .spec.replicas should be less than 2147483647"
)
t
.
Fatalf
(
"unexpected non-error: .spec.replicas should be less than 2147483647"
)
}
}
...
@@ -432,7 +432,7 @@ func TestValidateOnlyStatus(t *testing.T) {
...
@@ -432,7 +432,7 @@ func TestValidateOnlyStatus(t *testing.T) {
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"unexpected error setting .spec.num: %v"
,
err
)
t
.
Fatalf
(
"unexpected error setting .spec.num: %v"
,
err
)
}
}
createdNoxuInstance
,
err
=
noxuResourceClient
.
UpdateStatus
(
createdNoxuInstance
)
createdNoxuInstance
,
err
=
noxuResourceClient
.
UpdateStatus
(
createdNoxuInstance
,
metav1
.
UpdateOptions
{}
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"unexpected error: %v"
,
err
)
t
.
Errorf
(
"unexpected error: %v"
,
err
)
}
}
...
@@ -442,7 +442,7 @@ func TestValidateOnlyStatus(t *testing.T) {
...
@@ -442,7 +442,7 @@ func TestValidateOnlyStatus(t *testing.T) {
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"unexpected error setting .status.num: %v"
,
err
)
t
.
Fatalf
(
"unexpected error setting .status.num: %v"
,
err
)
}
}
createdNoxuInstance
,
err
=
noxuResourceClient
.
UpdateStatus
(
createdNoxuInstance
)
createdNoxuInstance
,
err
=
noxuResourceClient
.
UpdateStatus
(
createdNoxuInstance
,
metav1
.
UpdateOptions
{}
)
if
err
==
nil
{
if
err
==
nil
{
t
.
Fatal
(
"expected error, but got none"
)
t
.
Fatal
(
"expected error, but got none"
)
}
}
...
@@ -575,7 +575,7 @@ func TestGeneration(t *testing.T) {
...
@@ -575,7 +575,7 @@ func TestGeneration(t *testing.T) {
}
}
// UpdateStatus does not increment generation
// UpdateStatus does not increment generation
updatedStatusInstance
,
err
:=
noxuResourceClient
.
UpdateStatus
(
gottenNoxuInstance
)
updatedStatusInstance
,
err
:=
noxuResourceClient
.
UpdateStatus
(
gottenNoxuInstance
,
metav1
.
UpdateOptions
{}
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"unable to update status: %v"
,
err
)
t
.
Fatalf
(
"unable to update status: %v"
,
err
)
}
}
...
@@ -595,7 +595,7 @@ func TestGeneration(t *testing.T) {
...
@@ -595,7 +595,7 @@ func TestGeneration(t *testing.T) {
}
}
// Update increments generation
// Update increments generation
updatedInstance
,
err
:=
noxuResourceClient
.
Update
(
gottenNoxuInstance
)
updatedInstance
,
err
:=
noxuResourceClient
.
Update
(
gottenNoxuInstance
,
metav1
.
UpdateOptions
{}
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"unable to update instance: %v"
,
err
)
t
.
Fatalf
(
"unable to update instance: %v"
,
err
)
}
}
...
@@ -644,7 +644,7 @@ func TestSubresourcePatch(t *testing.T) {
...
@@ -644,7 +644,7 @@ func TestSubresourcePatch(t *testing.T) {
}
}
patch
:=
[]
byte
(
`{"spec": {"num":999}, "status": {"num":999}}`
)
patch
:=
[]
byte
(
`{"spec": {"num":999}, "status": {"num":999}}`
)
patchedNoxuInstance
,
err
:=
noxuResourceClient
.
Patch
(
"foo"
,
types
.
MergePatchType
,
patch
,
"status"
)
patchedNoxuInstance
,
err
:=
noxuResourceClient
.
Patch
(
"foo"
,
types
.
MergePatchType
,
patch
,
metav1
.
UpdateOptions
{},
"status"
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
}
}
...
@@ -679,19 +679,19 @@ func TestSubresourcePatch(t *testing.T) {
...
@@ -679,19 +679,19 @@ func TestSubresourcePatch(t *testing.T) {
}
}
// no-op patch
// no-op patch
_
,
err
=
noxuResourceClient
.
Patch
(
"foo"
,
types
.
MergePatchType
,
patch
,
"status"
)
_
,
err
=
noxuResourceClient
.
Patch
(
"foo"
,
types
.
MergePatchType
,
patch
,
metav1
.
UpdateOptions
{},
"status"
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
}
}
// empty patch
// empty patch
_
,
err
=
noxuResourceClient
.
Patch
(
"foo"
,
types
.
MergePatchType
,
[]
byte
(
`{}`
),
"status"
)
_
,
err
=
noxuResourceClient
.
Patch
(
"foo"
,
types
.
MergePatchType
,
[]
byte
(
`{}`
),
metav1
.
UpdateOptions
{},
"status"
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
}
}
patch
=
[]
byte
(
`{"spec": {"replicas":7}, "status": {"replicas":7}}`
)
patch
=
[]
byte
(
`{"spec": {"replicas":7}, "status": {"replicas":7}}`
)
patchedNoxuInstance
,
err
=
noxuResourceClient
.
Patch
(
"foo"
,
types
.
MergePatchType
,
patch
,
"scale"
)
patchedNoxuInstance
,
err
=
noxuResourceClient
.
Patch
(
"foo"
,
types
.
MergePatchType
,
patch
,
metav1
.
UpdateOptions
{},
"scale"
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
}
}
...
@@ -720,24 +720,24 @@ func TestSubresourcePatch(t *testing.T) {
...
@@ -720,24 +720,24 @@ func TestSubresourcePatch(t *testing.T) {
}
}
// no-op patch
// no-op patch
_
,
err
=
noxuResourceClient
.
Patch
(
"foo"
,
types
.
MergePatchType
,
patch
,
"scale"
)
_
,
err
=
noxuResourceClient
.
Patch
(
"foo"
,
types
.
MergePatchType
,
patch
,
metav1
.
UpdateOptions
{},
"scale"
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
}
}
// empty patch
// empty patch
_
,
err
=
noxuResourceClient
.
Patch
(
"foo"
,
types
.
MergePatchType
,
[]
byte
(
`{}`
),
"scale"
)
_
,
err
=
noxuResourceClient
.
Patch
(
"foo"
,
types
.
MergePatchType
,
[]
byte
(
`{}`
),
metav1
.
UpdateOptions
{},
"scale"
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
}
}
// make sure strategic merge patch is not supported for both status and scale
// make sure strategic merge patch is not supported for both status and scale
_
,
err
=
noxuResourceClient
.
Patch
(
"foo"
,
types
.
StrategicMergePatchType
,
patch
,
"status"
)
_
,
err
=
noxuResourceClient
.
Patch
(
"foo"
,
types
.
StrategicMergePatchType
,
patch
,
metav1
.
UpdateOptions
{},
"status"
)
if
err
==
nil
{
if
err
==
nil
{
t
.
Fatalf
(
"unexpected non-error: strategic merge patch is not supported for custom resources"
)
t
.
Fatalf
(
"unexpected non-error: strategic merge patch is not supported for custom resources"
)
}
}
_
,
err
=
noxuResourceClient
.
Patch
(
"foo"
,
types
.
StrategicMergePatchType
,
patch
,
"scale"
)
_
,
err
=
noxuResourceClient
.
Patch
(
"foo"
,
types
.
StrategicMergePatchType
,
patch
,
metav1
.
UpdateOptions
{},
"scale"
)
if
err
==
nil
{
if
err
==
nil
{
t
.
Fatalf
(
"unexpected non-error: strategic merge patch is not supported for custom resources"
)
t
.
Fatalf
(
"unexpected non-error: strategic merge patch is not supported for custom resources"
)
}
}
...
...
staging/src/k8s.io/apiextensions-apiserver/test/integration/table_test.go
View file @
71970d64
...
@@ -108,7 +108,7 @@ func TestTableGet(t *testing.T) {
...
@@ -108,7 +108,7 @@ func TestTableGet(t *testing.T) {
t
.
Logf
(
"table crd created: %#v"
,
crd
)
t
.
Logf
(
"table crd created: %#v"
,
crd
)
crClient
:=
newNamespacedCustomResourceClient
(
""
,
dynamicClient
,
crd
)
crClient
:=
newNamespacedCustomResourceClient
(
""
,
dynamicClient
,
crd
)
foo
,
err
:=
crClient
.
Create
(
newTableInstance
(
"foo"
))
foo
,
err
:=
crClient
.
Create
(
newTableInstance
(
"foo"
)
,
metav1
.
CreateOptions
{}
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"unable to create noxu instance: %v"
,
err
)
t
.
Fatalf
(
"unable to create noxu instance: %v"
,
err
)
}
}
...
...
staging/src/k8s.io/apiextensions-apiserver/test/integration/validation_test.go
View file @
71970d64
...
@@ -71,7 +71,7 @@ func TestForProperValidationErrors(t *testing.T) {
...
@@ -71,7 +71,7 @@ func TestForProperValidationErrors(t *testing.T) {
}
}
for
_
,
tc
:=
range
tests
{
for
_
,
tc
:=
range
tests
{
_
,
err
:=
noxuResourceClient
.
Create
(
tc
.
instanceFn
())
_
,
err
:=
noxuResourceClient
.
Create
(
tc
.
instanceFn
()
,
metav1
.
CreateOptions
{}
)
if
err
==
nil
{
if
err
==
nil
{
t
.
Errorf
(
"%v: expected %v"
,
tc
.
name
,
tc
.
expectedError
)
t
.
Errorf
(
"%v: expected %v"
,
tc
.
name
,
tc
.
expectedError
)
continue
continue
...
@@ -225,7 +225,7 @@ func TestCustomResourceUpdateValidation(t *testing.T) {
...
@@ -225,7 +225,7 @@ func TestCustomResourceUpdateValidation(t *testing.T) {
"delta"
:
"hello"
,
"delta"
:
"hello"
,
}
}
_
,
err
=
noxuResourceClient
.
Update
(
gottenNoxuInstance
)
_
,
err
=
noxuResourceClient
.
Update
(
gottenNoxuInstance
,
metav1
.
UpdateOptions
{}
)
if
err
==
nil
{
if
err
==
nil
{
t
.
Fatalf
(
"unexpected non-error: alpha and beta should be present while updating %v"
,
gottenNoxuInstance
)
t
.
Fatalf
(
"unexpected non-error: alpha and beta should be present while updating %v"
,
gottenNoxuInstance
)
}
}
...
@@ -309,7 +309,7 @@ func TestCustomResourceValidationErrors(t *testing.T) {
...
@@ -309,7 +309,7 @@ func TestCustomResourceValidationErrors(t *testing.T) {
}
}
for
_
,
tc
:=
range
tests
{
for
_
,
tc
:=
range
tests
{
_
,
err
:=
noxuResourceClient
.
Create
(
tc
.
instanceFn
())
_
,
err
:=
noxuResourceClient
.
Create
(
tc
.
instanceFn
()
,
metav1
.
CreateOptions
{}
)
if
err
==
nil
{
if
err
==
nil
{
t
.
Errorf
(
"%v: expected %v"
,
tc
.
name
,
tc
.
expectedError
)
t
.
Errorf
(
"%v: expected %v"
,
tc
.
name
,
tc
.
expectedError
)
continue
continue
...
@@ -357,7 +357,7 @@ func TestCRValidationOnCRDUpdate(t *testing.T) {
...
@@ -357,7 +357,7 @@ func TestCRValidationOnCRDUpdate(t *testing.T) {
// CR is now accepted
// CR is now accepted
err
=
wait
.
Poll
(
500
*
time
.
Millisecond
,
wait
.
ForeverTestTimeout
,
func
()
(
bool
,
error
)
{
err
=
wait
.
Poll
(
500
*
time
.
Millisecond
,
wait
.
ForeverTestTimeout
,
func
()
(
bool
,
error
)
{
_
,
err
:=
noxuResourceClient
.
Create
(
newNoxuValidationInstance
(
ns
,
"foo"
))
_
,
err
:=
noxuResourceClient
.
Create
(
newNoxuValidationInstance
(
ns
,
"foo"
)
,
metav1
.
CreateOptions
{}
)
if
statusError
,
isStatus
:=
err
.
(
*
apierrors
.
StatusError
);
isStatus
{
if
statusError
,
isStatus
:=
err
.
(
*
apierrors
.
StatusError
);
isStatus
{
if
strings
.
Contains
(
statusError
.
Error
(),
"is invalid"
)
{
if
strings
.
Contains
(
statusError
.
Error
(),
"is invalid"
)
{
return
false
,
nil
return
false
,
nil
...
...
staging/src/k8s.io/client-go/deprecated-dynamic/client.go
View file @
71970d64
...
@@ -107,11 +107,11 @@ type oldResourceShimType struct {
...
@@ -107,11 +107,11 @@ type oldResourceShimType struct {
}
}
func
(
s
oldResourceShimType
)
Create
(
obj
*
unstructured
.
Unstructured
)
(
*
unstructured
.
Unstructured
,
error
)
{
func
(
s
oldResourceShimType
)
Create
(
obj
*
unstructured
.
Unstructured
)
(
*
unstructured
.
Unstructured
,
error
)
{
return
s
.
ResourceInterface
.
Create
(
obj
,
s
.
subresources
...
)
return
s
.
ResourceInterface
.
Create
(
obj
,
metav1
.
CreateOptions
{},
s
.
subresources
...
)
}
}
func
(
s
oldResourceShimType
)
Update
(
obj
*
unstructured
.
Unstructured
)
(
*
unstructured
.
Unstructured
,
error
)
{
func
(
s
oldResourceShimType
)
Update
(
obj
*
unstructured
.
Unstructured
)
(
*
unstructured
.
Unstructured
,
error
)
{
return
s
.
ResourceInterface
.
Update
(
obj
,
s
.
subresources
...
)
return
s
.
ResourceInterface
.
Update
(
obj
,
metav1
.
UpdateOptions
{},
s
.
subresources
...
)
}
}
func
(
s
oldResourceShimType
)
Delete
(
name
string
,
opts
*
metav1
.
DeleteOptions
)
error
{
func
(
s
oldResourceShimType
)
Delete
(
name
string
,
opts
*
metav1
.
DeleteOptions
)
error
{
...
@@ -127,5 +127,5 @@ func (s oldResourceShimType) List(opts metav1.ListOptions) (runtime.Object, erro
...
@@ -127,5 +127,5 @@ func (s oldResourceShimType) List(opts metav1.ListOptions) (runtime.Object, erro
}
}
func
(
s
oldResourceShimType
)
Patch
(
name
string
,
pt
types
.
PatchType
,
data
[]
byte
)
(
*
unstructured
.
Unstructured
,
error
)
{
func
(
s
oldResourceShimType
)
Patch
(
name
string
,
pt
types
.
PatchType
,
data
[]
byte
)
(
*
unstructured
.
Unstructured
,
error
)
{
return
s
.
ResourceInterface
.
Patch
(
name
,
pt
,
data
,
s
.
subresources
...
)
return
s
.
ResourceInterface
.
Patch
(
name
,
pt
,
data
,
metav1
.
UpdateOptions
{},
s
.
subresources
...
)
}
}
staging/src/k8s.io/client-go/dynamic/client_test.go
View file @
71970d64
...
@@ -404,7 +404,7 @@ func TestCreate(t *testing.T) {
...
@@ -404,7 +404,7 @@ func TestCreate(t *testing.T) {
}
}
defer
srv
.
Close
()
defer
srv
.
Close
()
got
,
err
:=
cl
.
Resource
(
resource
)
.
Namespace
(
tc
.
namespace
)
.
Create
(
tc
.
obj
,
tc
.
subresource
...
)
got
,
err
:=
cl
.
Resource
(
resource
)
.
Namespace
(
tc
.
namespace
)
.
Create
(
tc
.
obj
,
metav1
.
CreateOptions
{},
tc
.
subresource
...
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"unexpected error when creating %q: %v"
,
tc
.
name
,
err
)
t
.
Errorf
(
"unexpected error when creating %q: %v"
,
tc
.
name
,
err
)
continue
continue
...
@@ -481,7 +481,7 @@ func TestUpdate(t *testing.T) {
...
@@ -481,7 +481,7 @@ func TestUpdate(t *testing.T) {
}
}
defer
srv
.
Close
()
defer
srv
.
Close
()
got
,
err
:=
cl
.
Resource
(
resource
)
.
Namespace
(
tc
.
namespace
)
.
Update
(
tc
.
obj
,
tc
.
subresource
...
)
got
,
err
:=
cl
.
Resource
(
resource
)
.
Namespace
(
tc
.
namespace
)
.
Update
(
tc
.
obj
,
metav1
.
UpdateOptions
{},
tc
.
subresource
...
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"unexpected error when updating %q: %v"
,
tc
.
name
,
err
)
t
.
Errorf
(
"unexpected error when updating %q: %v"
,
tc
.
name
,
err
)
continue
continue
...
@@ -638,7 +638,7 @@ func TestPatch(t *testing.T) {
...
@@ -638,7 +638,7 @@ func TestPatch(t *testing.T) {
}
}
defer
srv
.
Close
()
defer
srv
.
Close
()
got
,
err
:=
cl
.
Resource
(
resource
)
.
Namespace
(
tc
.
namespace
)
.
Patch
(
tc
.
name
,
types
.
StrategicMergePatchType
,
tc
.
patch
,
tc
.
subresource
...
)
got
,
err
:=
cl
.
Resource
(
resource
)
.
Namespace
(
tc
.
namespace
)
.
Patch
(
tc
.
name
,
types
.
StrategicMergePatchType
,
tc
.
patch
,
metav1
.
UpdateOptions
{},
tc
.
subresource
...
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"unexpected error when patching %q: %v"
,
tc
.
name
,
err
)
t
.
Errorf
(
"unexpected error when patching %q: %v"
,
tc
.
name
,
err
)
continue
continue
...
...
staging/src/k8s.io/client-go/dynamic/fake/simple.go
View file @
71970d64
...
@@ -86,7 +86,7 @@ func (c *dynamicResourceClient) Namespace(ns string) dynamic.ResourceInterface {
...
@@ -86,7 +86,7 @@ func (c *dynamicResourceClient) Namespace(ns string) dynamic.ResourceInterface {
return
&
ret
return
&
ret
}
}
func
(
c
*
dynamicResourceClient
)
Create
(
obj
*
unstructured
.
Unstructured
,
subresources
...
string
)
(
*
unstructured
.
Unstructured
,
error
)
{
func
(
c
*
dynamicResourceClient
)
Create
(
obj
*
unstructured
.
Unstructured
,
opts
metav1
.
CreateOptions
,
subresources
...
string
)
(
*
unstructured
.
Unstructured
,
error
)
{
var
uncastRet
runtime
.
Object
var
uncastRet
runtime
.
Object
var
err
error
var
err
error
switch
{
switch
{
...
@@ -132,7 +132,7 @@ func (c *dynamicResourceClient) Create(obj *unstructured.Unstructured, subresour
...
@@ -132,7 +132,7 @@ func (c *dynamicResourceClient) Create(obj *unstructured.Unstructured, subresour
return
ret
,
err
return
ret
,
err
}
}
func
(
c
*
dynamicResourceClient
)
Update
(
obj
*
unstructured
.
Unstructured
,
subresources
...
string
)
(
*
unstructured
.
Unstructured
,
error
)
{
func
(
c
*
dynamicResourceClient
)
Update
(
obj
*
unstructured
.
Unstructured
,
opts
metav1
.
UpdateOptions
,
subresources
...
string
)
(
*
unstructured
.
Unstructured
,
error
)
{
var
uncastRet
runtime
.
Object
var
uncastRet
runtime
.
Object
var
err
error
var
err
error
switch
{
switch
{
...
@@ -168,7 +168,7 @@ func (c *dynamicResourceClient) Update(obj *unstructured.Unstructured, subresour
...
@@ -168,7 +168,7 @@ func (c *dynamicResourceClient) Update(obj *unstructured.Unstructured, subresour
return
ret
,
err
return
ret
,
err
}
}
func
(
c
*
dynamicResourceClient
)
UpdateStatus
(
obj
*
unstructured
.
Unstructured
)
(
*
unstructured
.
Unstructured
,
error
)
{
func
(
c
*
dynamicResourceClient
)
UpdateStatus
(
obj
*
unstructured
.
Unstructured
,
opts
metav1
.
UpdateOptions
)
(
*
unstructured
.
Unstructured
,
error
)
{
var
uncastRet
runtime
.
Object
var
uncastRet
runtime
.
Object
var
err
error
var
err
error
switch
{
switch
{
...
@@ -331,7 +331,7 @@ func (c *dynamicResourceClient) Watch(opts metav1.ListOptions) (watch.Interface,
...
@@ -331,7 +331,7 @@ func (c *dynamicResourceClient) Watch(opts metav1.ListOptions) (watch.Interface,
panic
(
"math broke"
)
panic
(
"math broke"
)
}
}
func
(
c
*
dynamicResourceClient
)
Patch
(
name
string
,
pt
types
.
PatchType
,
data
[]
byte
,
subresources
...
string
)
(
*
unstructured
.
Unstructured
,
error
)
{
func
(
c
*
dynamicResourceClient
)
Patch
(
name
string
,
pt
types
.
PatchType
,
data
[]
byte
,
opts
metav1
.
UpdateOptions
,
subresources
...
string
)
(
*
unstructured
.
Unstructured
,
error
)
{
var
uncastRet
runtime
.
Object
var
uncastRet
runtime
.
Object
var
err
error
var
err
error
switch
{
switch
{
...
...
staging/src/k8s.io/client-go/dynamic/interface.go
View file @
71970d64
...
@@ -29,15 +29,15 @@ type Interface interface {
...
@@ -29,15 +29,15 @@ type Interface interface {
}
}
type
ResourceInterface
interface
{
type
ResourceInterface
interface
{
Create
(
obj
*
unstructured
.
Unstructured
,
subresources
...
string
)
(
*
unstructured
.
Unstructured
,
error
)
Create
(
obj
*
unstructured
.
Unstructured
,
options
metav1
.
CreateOptions
,
subresources
...
string
)
(
*
unstructured
.
Unstructured
,
error
)
Update
(
obj
*
unstructured
.
Unstructured
,
subresources
...
string
)
(
*
unstructured
.
Unstructured
,
error
)
Update
(
obj
*
unstructured
.
Unstructured
,
options
metav1
.
UpdateOptions
,
subresources
...
string
)
(
*
unstructured
.
Unstructured
,
error
)
UpdateStatus
(
obj
*
unstructured
.
Unstructured
)
(
*
unstructured
.
Unstructured
,
error
)
UpdateStatus
(
obj
*
unstructured
.
Unstructured
,
options
metav1
.
UpdateOptions
)
(
*
unstructured
.
Unstructured
,
error
)
Delete
(
name
string
,
options
*
metav1
.
DeleteOptions
,
subresources
...
string
)
error
Delete
(
name
string
,
options
*
metav1
.
DeleteOptions
,
subresources
...
string
)
error
DeleteCollection
(
options
*
metav1
.
DeleteOptions
,
listOptions
metav1
.
ListOptions
)
error
DeleteCollection
(
options
*
metav1
.
DeleteOptions
,
listOptions
metav1
.
ListOptions
)
error
Get
(
name
string
,
options
metav1
.
GetOptions
,
subresources
...
string
)
(
*
unstructured
.
Unstructured
,
error
)
Get
(
name
string
,
options
metav1
.
GetOptions
,
subresources
...
string
)
(
*
unstructured
.
Unstructured
,
error
)
List
(
opts
metav1
.
ListOptions
)
(
*
unstructured
.
UnstructuredList
,
error
)
List
(
opts
metav1
.
ListOptions
)
(
*
unstructured
.
UnstructuredList
,
error
)
Watch
(
opts
metav1
.
ListOptions
)
(
watch
.
Interface
,
error
)
Watch
(
opts
metav1
.
ListOptions
)
(
watch
.
Interface
,
error
)
Patch
(
name
string
,
pt
types
.
PatchType
,
data
[]
byte
,
subresources
...
string
)
(
*
unstructured
.
Unstructured
,
error
)
Patch
(
name
string
,
pt
types
.
PatchType
,
data
[]
byte
,
options
metav1
.
UpdateOptions
,
subresources
...
string
)
(
*
unstructured
.
Unstructured
,
error
)
}
}
type
NamespaceableResourceInterface
interface
{
type
NamespaceableResourceInterface
interface
{
...
...
staging/src/k8s.io/client-go/dynamic/simple.go
View file @
71970d64
...
@@ -82,7 +82,7 @@ func (c *dynamicResourceClient) Namespace(ns string) ResourceInterface {
...
@@ -82,7 +82,7 @@ func (c *dynamicResourceClient) Namespace(ns string) ResourceInterface {
return
&
ret
return
&
ret
}
}
func
(
c
*
dynamicResourceClient
)
Create
(
obj
*
unstructured
.
Unstructured
,
subresources
...
string
)
(
*
unstructured
.
Unstructured
,
error
)
{
func
(
c
*
dynamicResourceClient
)
Create
(
obj
*
unstructured
.
Unstructured
,
opts
metav1
.
CreateOptions
,
subresources
...
string
)
(
*
unstructured
.
Unstructured
,
error
)
{
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
...
@@ -96,7 +96,12 @@ func (c *dynamicResourceClient) Create(obj *unstructured.Unstructured, subresour
...
@@ -96,7 +96,12 @@ func (c *dynamicResourceClient) Create(obj *unstructured.Unstructured, subresour
name
=
accessor
.
GetName
()
name
=
accessor
.
GetName
()
}
}
result
:=
c
.
client
.
client
.
Post
()
.
AbsPath
(
append
(
c
.
makeURLSegments
(
name
),
subresources
...
)
...
)
.
Body
(
outBytes
)
.
Do
()
result
:=
c
.
client
.
client
.
Post
()
.
AbsPath
(
append
(
c
.
makeURLSegments
(
name
),
subresources
...
)
...
)
.
Body
(
outBytes
)
.
SpecificallyVersionedParams
(
&
opts
,
dynamicParameterCodec
,
versionV1
)
.
Do
()
if
err
:=
result
.
Error
();
err
!=
nil
{
if
err
:=
result
.
Error
();
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
@@ -112,7 +117,7 @@ func (c *dynamicResourceClient) Create(obj *unstructured.Unstructured, subresour
...
@@ -112,7 +117,7 @@ func (c *dynamicResourceClient) Create(obj *unstructured.Unstructured, subresour
return
uncastObj
.
(
*
unstructured
.
Unstructured
),
nil
return
uncastObj
.
(
*
unstructured
.
Unstructured
),
nil
}
}
func
(
c
*
dynamicResourceClient
)
Update
(
obj
*
unstructured
.
Unstructured
,
subresources
...
string
)
(
*
unstructured
.
Unstructured
,
error
)
{
func
(
c
*
dynamicResourceClient
)
Update
(
obj
*
unstructured
.
Unstructured
,
opts
metav1
.
UpdateOptions
,
subresources
...
string
)
(
*
unstructured
.
Unstructured
,
error
)
{
accessor
,
err
:=
meta
.
Accessor
(
obj
)
accessor
,
err
:=
meta
.
Accessor
(
obj
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
...
@@ -122,7 +127,12 @@ func (c *dynamicResourceClient) Update(obj *unstructured.Unstructured, subresour
...
@@ -122,7 +127,12 @@ func (c *dynamicResourceClient) Update(obj *unstructured.Unstructured, subresour
return
nil
,
err
return
nil
,
err
}
}
result
:=
c
.
client
.
client
.
Put
()
.
AbsPath
(
append
(
c
.
makeURLSegments
(
accessor
.
GetName
()),
subresources
...
)
...
)
.
Body
(
outBytes
)
.
Do
()
result
:=
c
.
client
.
client
.
Put
()
.
AbsPath
(
append
(
c
.
makeURLSegments
(
accessor
.
GetName
()),
subresources
...
)
...
)
.
Body
(
outBytes
)
.
SpecificallyVersionedParams
(
&
opts
,
dynamicParameterCodec
,
versionV1
)
.
Do
()
if
err
:=
result
.
Error
();
err
!=
nil
{
if
err
:=
result
.
Error
();
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
@@ -138,7 +148,7 @@ func (c *dynamicResourceClient) Update(obj *unstructured.Unstructured, subresour
...
@@ -138,7 +148,7 @@ func (c *dynamicResourceClient) Update(obj *unstructured.Unstructured, subresour
return
uncastObj
.
(
*
unstructured
.
Unstructured
),
nil
return
uncastObj
.
(
*
unstructured
.
Unstructured
),
nil
}
}
func
(
c
*
dynamicResourceClient
)
UpdateStatus
(
obj
*
unstructured
.
Unstructured
)
(
*
unstructured
.
Unstructured
,
error
)
{
func
(
c
*
dynamicResourceClient
)
UpdateStatus
(
obj
*
unstructured
.
Unstructured
,
opts
metav1
.
UpdateOptions
)
(
*
unstructured
.
Unstructured
,
error
)
{
accessor
,
err
:=
meta
.
Accessor
(
obj
)
accessor
,
err
:=
meta
.
Accessor
(
obj
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
...
@@ -149,7 +159,12 @@ func (c *dynamicResourceClient) UpdateStatus(obj *unstructured.Unstructured) (*u
...
@@ -149,7 +159,12 @@ func (c *dynamicResourceClient) UpdateStatus(obj *unstructured.Unstructured) (*u
return
nil
,
err
return
nil
,
err
}
}
result
:=
c
.
client
.
client
.
Put
()
.
AbsPath
(
append
(
c
.
makeURLSegments
(
accessor
.
GetName
()),
"status"
)
...
)
.
Body
(
outBytes
)
.
Do
()
result
:=
c
.
client
.
client
.
Put
()
.
AbsPath
(
append
(
c
.
makeURLSegments
(
accessor
.
GetName
()),
"status"
)
...
)
.
Body
(
outBytes
)
.
SpecificallyVersionedParams
(
&
opts
,
dynamicParameterCodec
,
versionV1
)
.
Do
()
if
err
:=
result
.
Error
();
err
!=
nil
{
if
err
:=
result
.
Error
();
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
@@ -174,7 +189,11 @@ func (c *dynamicResourceClient) Delete(name string, opts *metav1.DeleteOptions,
...
@@ -174,7 +189,11 @@ func (c *dynamicResourceClient) Delete(name string, opts *metav1.DeleteOptions,
return
err
return
err
}
}
result
:=
c
.
client
.
client
.
Delete
()
.
AbsPath
(
append
(
c
.
makeURLSegments
(
name
),
subresources
...
)
...
)
.
Body
(
deleteOptionsByte
)
.
Do
()
result
:=
c
.
client
.
client
.
Delete
()
.
AbsPath
(
append
(
c
.
makeURLSegments
(
name
),
subresources
...
)
...
)
.
Body
(
deleteOptionsByte
)
.
Do
()
return
result
.
Error
()
return
result
.
Error
()
}
}
...
@@ -187,7 +206,12 @@ func (c *dynamicResourceClient) DeleteCollection(opts *metav1.DeleteOptions, lis
...
@@ -187,7 +206,12 @@ func (c *dynamicResourceClient) DeleteCollection(opts *metav1.DeleteOptions, lis
return
err
return
err
}
}
result
:=
c
.
client
.
client
.
Delete
()
.
AbsPath
(
c
.
makeURLSegments
(
""
)
...
)
.
Body
(
deleteOptionsByte
)
.
SpecificallyVersionedParams
(
&
listOptions
,
dynamicParameterCodec
,
versionV1
)
.
Do
()
result
:=
c
.
client
.
client
.
Delete
()
.
AbsPath
(
c
.
makeURLSegments
(
""
)
...
)
.
Body
(
deleteOptionsByte
)
.
SpecificallyVersionedParams
(
&
listOptions
,
dynamicParameterCodec
,
versionV1
)
.
Do
()
return
result
.
Error
()
return
result
.
Error
()
}
}
...
@@ -259,8 +283,13 @@ func (c *dynamicResourceClient) Watch(opts metav1.ListOptions) (watch.Interface,
...
@@ -259,8 +283,13 @@ func (c *dynamicResourceClient) Watch(opts metav1.ListOptions) (watch.Interface,
WatchWithSpecificDecoders
(
wrappedDecoderFn
,
unstructured
.
UnstructuredJSONScheme
)
WatchWithSpecificDecoders
(
wrappedDecoderFn
,
unstructured
.
UnstructuredJSONScheme
)
}
}
func
(
c
*
dynamicResourceClient
)
Patch
(
name
string
,
pt
types
.
PatchType
,
data
[]
byte
,
subresources
...
string
)
(
*
unstructured
.
Unstructured
,
error
)
{
func
(
c
*
dynamicResourceClient
)
Patch
(
name
string
,
pt
types
.
PatchType
,
data
[]
byte
,
opts
metav1
.
UpdateOptions
,
subresources
...
string
)
(
*
unstructured
.
Unstructured
,
error
)
{
result
:=
c
.
client
.
client
.
Patch
(
pt
)
.
AbsPath
(
append
(
c
.
makeURLSegments
(
name
),
subresources
...
)
...
)
.
Body
(
data
)
.
Do
()
result
:=
c
.
client
.
client
.
Patch
(
pt
)
.
AbsPath
(
append
(
c
.
makeURLSegments
(
name
),
subresources
...
)
...
)
.
Body
(
data
)
.
SpecificallyVersionedParams
(
&
opts
,
dynamicParameterCodec
,
versionV1
)
.
Do
()
if
err
:=
result
.
Error
();
err
!=
nil
{
if
err
:=
result
.
Error
();
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
...
test/e2e/apimachinery/aggregator.go
View file @
71970d64
...
@@ -436,7 +436,7 @@ func TestSampleAPIServer(f *framework.Framework, image string) {
...
@@ -436,7 +436,7 @@ func TestSampleAPIServer(f *framework.Framework, image string) {
unstruct
:=
&
unstructuredv1
.
Unstructured
{}
unstruct
:=
&
unstructuredv1
.
Unstructured
{}
err
=
unstruct
.
UnmarshalJSON
(
jsonFlunder
)
err
=
unstruct
.
UnmarshalJSON
(
jsonFlunder
)
framework
.
ExpectNoError
(
err
,
"unmarshalling test-flunder as unstructured for create using dynamic client"
)
framework
.
ExpectNoError
(
err
,
"unmarshalling test-flunder as unstructured for create using dynamic client"
)
unstruct
,
err
=
dynamicClient
.
Create
(
unstruct
)
unstruct
,
err
=
dynamicClient
.
Create
(
unstruct
,
metav1
.
CreateOptions
{}
)
framework
.
ExpectNoError
(
err
,
"listing flunders using dynamic client"
)
framework
.
ExpectNoError
(
err
,
"listing flunders using dynamic client"
)
// kubectl get flunders
// kubectl get flunders
...
...
test/e2e/apimachinery/crd_watch.go
View file @
71970d64
...
@@ -125,7 +125,7 @@ func watchCRWithName(crdResourceClient dynamic.ResourceInterface, name string) (
...
@@ -125,7 +125,7 @@ func watchCRWithName(crdResourceClient dynamic.ResourceInterface, name string) (
}
}
func
instantiateCustomResource
(
instanceToCreate
*
unstructured
.
Unstructured
,
client
dynamic
.
ResourceInterface
,
definition
*
apiextensionsv1beta1
.
CustomResourceDefinition
)
(
*
unstructured
.
Unstructured
,
error
)
{
func
instantiateCustomResource
(
instanceToCreate
*
unstructured
.
Unstructured
,
client
dynamic
.
ResourceInterface
,
definition
*
apiextensionsv1beta1
.
CustomResourceDefinition
)
(
*
unstructured
.
Unstructured
,
error
)
{
createdInstance
,
err
:=
client
.
Create
(
instanceToCreate
)
createdInstance
,
err
:=
client
.
Create
(
instanceToCreate
,
metav1
.
CreateOptions
{}
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
...
test/e2e/apimachinery/garbage_collector.go
View file @
71970d64
...
@@ -935,7 +935,7 @@ var _ = SIGDescribe("Garbage collector", func() {
...
@@ -935,7 +935,7 @@ var _ = SIGDescribe("Garbage collector", func() {
},
},
},
},
}
}
persistedOwner
,
err
:=
resourceClient
.
Create
(
owner
)
persistedOwner
,
err
:=
resourceClient
.
Create
(
owner
,
metav1
.
CreateOptions
{}
)
if
err
!=
nil
{
if
err
!=
nil
{
framework
.
Failf
(
"failed to create owner resource %q: %v"
,
ownerName
,
err
)
framework
.
Failf
(
"failed to create owner resource %q: %v"
,
ownerName
,
err
)
}
}
...
@@ -960,7 +960,7 @@ var _ = SIGDescribe("Garbage collector", func() {
...
@@ -960,7 +960,7 @@ var _ = SIGDescribe("Garbage collector", func() {
},
},
},
},
}
}
persistedDependent
,
err
:=
resourceClient
.
Create
(
dependent
)
persistedDependent
,
err
:=
resourceClient
.
Create
(
dependent
,
metav1
.
CreateOptions
{}
)
if
err
!=
nil
{
if
err
!=
nil
{
framework
.
Failf
(
"failed to create dependent resource %q: %v"
,
dependentName
,
err
)
framework
.
Failf
(
"failed to create dependent resource %q: %v"
,
dependentName
,
err
)
}
}
...
@@ -1036,7 +1036,7 @@ var _ = SIGDescribe("Garbage collector", func() {
...
@@ -1036,7 +1036,7 @@ var _ = SIGDescribe("Garbage collector", func() {
},
},
},
},
}
}
persistedOwner
,
err
:=
resourceClient
.
Create
(
owner
)
persistedOwner
,
err
:=
resourceClient
.
Create
(
owner
,
metav1
.
CreateOptions
{}
)
if
err
!=
nil
{
if
err
!=
nil
{
framework
.
Failf
(
"failed to create owner resource %q: %v"
,
ownerName
,
err
)
framework
.
Failf
(
"failed to create owner resource %q: %v"
,
ownerName
,
err
)
}
}
...
@@ -1061,7 +1061,7 @@ var _ = SIGDescribe("Garbage collector", func() {
...
@@ -1061,7 +1061,7 @@ var _ = SIGDescribe("Garbage collector", func() {
},
},
},
},
}
}
_
,
err
=
resourceClient
.
Create
(
dependent
)
_
,
err
=
resourceClient
.
Create
(
dependent
,
metav1
.
CreateOptions
{}
)
if
err
!=
nil
{
if
err
!=
nil
{
framework
.
Failf
(
"failed to create dependent resource %q: %v"
,
dependentName
,
err
)
framework
.
Failf
(
"failed to create dependent resource %q: %v"
,
dependentName
,
err
)
}
}
...
...
test/e2e/apimachinery/webhook.go
View file @
71970d64
...
@@ -1100,7 +1100,7 @@ func testCustomResourceWebhook(f *framework.Framework, crd *apiextensionsv1beta1
...
@@ -1100,7 +1100,7 @@ func testCustomResourceWebhook(f *framework.Framework, crd *apiextensionsv1beta1
},
},
},
},
}
}
_
,
err
:=
customResourceClient
.
Create
(
crInstance
)
_
,
err
:=
customResourceClient
.
Create
(
crInstance
,
metav1
.
CreateOptions
{}
)
Expect
(
err
)
.
NotTo
(
BeNil
())
Expect
(
err
)
.
NotTo
(
BeNil
())
expectedErrMsg
:=
"the custom resource contains unwanted data"
expectedErrMsg
:=
"the custom resource contains unwanted data"
if
!
strings
.
Contains
(
err
.
Error
(),
expectedErrMsg
)
{
if
!
strings
.
Contains
(
err
.
Error
(),
expectedErrMsg
)
{
...
@@ -1123,7 +1123,7 @@ func testMutatingCustomResourceWebhook(f *framework.Framework, crd *apiextension
...
@@ -1123,7 +1123,7 @@ func testMutatingCustomResourceWebhook(f *framework.Framework, crd *apiextension
},
},
},
},
}
}
mutatedCR
,
err
:=
customResourceClient
.
Create
(
cr
)
mutatedCR
,
err
:=
customResourceClient
.
Create
(
cr
,
metav1
.
CreateOptions
{}
)
Expect
(
err
)
.
To
(
BeNil
())
Expect
(
err
)
.
To
(
BeNil
())
expectedCRData
:=
map
[
string
]
interface
{}{
expectedCRData
:=
map
[
string
]
interface
{}{
"mutation-start"
:
"yes"
,
"mutation-start"
:
"yes"
,
...
...
test/integration/etcd/etcd_storage_path_test.go
View file @
71970d64
...
@@ -810,7 +810,7 @@ func (c *allClient) create(stub, ns string, mapping *meta.RESTMapping, all *[]cl
...
@@ -810,7 +810,7 @@ func (c *allClient) create(stub, ns string, mapping *meta.RESTMapping, all *[]cl
ns
=
""
ns
=
""
}
}
obj
:=
&
unstructured
.
Unstructured
{
Object
:
typeMetaAdder
}
obj
:=
&
unstructured
.
Unstructured
{
Object
:
typeMetaAdder
}
actual
,
err
:=
c
.
dynamicClient
.
Resource
(
mapping
.
Resource
)
.
Namespace
(
ns
)
.
Create
(
obj
)
actual
,
err
:=
c
.
dynamicClient
.
Resource
(
mapping
.
Resource
)
.
Namespace
(
ns
)
.
Create
(
obj
,
metav1
.
CreateOptions
{}
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
...
test/integration/garbagecollector/garbage_collector_test.go
View file @
71970d64
...
@@ -812,7 +812,7 @@ func TestCustomResourceCascadingDeletion(t *testing.T) {
...
@@ -812,7 +812,7 @@ func TestCustomResourceCascadingDeletion(t *testing.T) {
// Create a custom owner resource.
// Create a custom owner resource.
owner
:=
newCRDInstance
(
definition
,
ns
.
Name
,
names
.
SimpleNameGenerator
.
GenerateName
(
"owner"
))
owner
:=
newCRDInstance
(
definition
,
ns
.
Name
,
names
.
SimpleNameGenerator
.
GenerateName
(
"owner"
))
owner
,
err
:=
resourceClient
.
Create
(
owner
)
owner
,
err
:=
resourceClient
.
Create
(
owner
,
metav1
.
CreateOptions
{}
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"failed to create owner resource %q: %v"
,
owner
.
GetName
(),
err
)
t
.
Fatalf
(
"failed to create owner resource %q: %v"
,
owner
.
GetName
(),
err
)
}
}
...
@@ -822,7 +822,7 @@ func TestCustomResourceCascadingDeletion(t *testing.T) {
...
@@ -822,7 +822,7 @@ func TestCustomResourceCascadingDeletion(t *testing.T) {
dependent
:=
newCRDInstance
(
definition
,
ns
.
Name
,
names
.
SimpleNameGenerator
.
GenerateName
(
"dependent"
))
dependent
:=
newCRDInstance
(
definition
,
ns
.
Name
,
names
.
SimpleNameGenerator
.
GenerateName
(
"dependent"
))
link
(
t
,
owner
,
dependent
)
link
(
t
,
owner
,
dependent
)
dependent
,
err
=
resourceClient
.
Create
(
dependent
)
dependent
,
err
=
resourceClient
.
Create
(
dependent
,
metav1
.
CreateOptions
{}
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"failed to create dependent resource %q: %v"
,
dependent
.
GetName
(),
err
)
t
.
Fatalf
(
"failed to create dependent resource %q: %v"
,
dependent
.
GetName
(),
err
)
}
}
...
@@ -873,7 +873,7 @@ func TestMixedRelationships(t *testing.T) {
...
@@ -873,7 +873,7 @@ func TestMixedRelationships(t *testing.T) {
definition
,
resourceClient
:=
createRandomCustomResourceDefinition
(
t
,
apiExtensionClient
,
dynamicClient
,
ns
.
Name
)
definition
,
resourceClient
:=
createRandomCustomResourceDefinition
(
t
,
apiExtensionClient
,
dynamicClient
,
ns
.
Name
)
// Create a custom owner resource.
// Create a custom owner resource.
customOwner
,
err
:=
resourceClient
.
Create
(
newCRDInstance
(
definition
,
ns
.
Name
,
names
.
SimpleNameGenerator
.
GenerateName
(
"owner"
)))
customOwner
,
err
:=
resourceClient
.
Create
(
newCRDInstance
(
definition
,
ns
.
Name
,
names
.
SimpleNameGenerator
.
GenerateName
(
"owner"
))
,
metav1
.
CreateOptions
{}
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"failed to create owner: %v"
,
err
)
t
.
Fatalf
(
"failed to create owner: %v"
,
err
)
}
}
...
@@ -900,7 +900,7 @@ func TestMixedRelationships(t *testing.T) {
...
@@ -900,7 +900,7 @@ func TestMixedRelationships(t *testing.T) {
coreOwner
.
TypeMeta
.
Kind
=
"ConfigMap"
coreOwner
.
TypeMeta
.
Kind
=
"ConfigMap"
coreOwner
.
TypeMeta
.
APIVersion
=
"v1"
coreOwner
.
TypeMeta
.
APIVersion
=
"v1"
link
(
t
,
coreOwner
,
customDependent
)
link
(
t
,
coreOwner
,
customDependent
)
customDependent
,
err
=
resourceClient
.
Create
(
customDependent
)
customDependent
,
err
=
resourceClient
.
Create
(
customDependent
,
metav1
.
CreateOptions
{}
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"failed to create dependent: %v"
,
err
)
t
.
Fatalf
(
"failed to create dependent: %v"
,
err
)
}
}
...
@@ -971,7 +971,7 @@ func TestCRDDeletionCascading(t *testing.T) {
...
@@ -971,7 +971,7 @@ func TestCRDDeletionCascading(t *testing.T) {
definition
,
resourceClient
:=
createRandomCustomResourceDefinition
(
t
,
apiExtensionClient
,
dynamicClient
,
ns
.
Name
)
definition
,
resourceClient
:=
createRandomCustomResourceDefinition
(
t
,
apiExtensionClient
,
dynamicClient
,
ns
.
Name
)
// Create a custom owner resource.
// Create a custom owner resource.
owner
,
err
:=
resourceClient
.
Create
(
newCRDInstance
(
definition
,
ns
.
Name
,
names
.
SimpleNameGenerator
.
GenerateName
(
"owner"
)))
owner
,
err
:=
resourceClient
.
Create
(
newCRDInstance
(
definition
,
ns
.
Name
,
names
.
SimpleNameGenerator
.
GenerateName
(
"owner"
))
,
metav1
.
CreateOptions
{}
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"failed to create owner: %v"
,
err
)
t
.
Fatalf
(
"failed to create owner: %v"
,
err
)
}
}
...
...
test/integration/master/crd_test.go
View file @
71970d64
...
@@ -199,7 +199,7 @@ func TestCRD(t *testing.T) {
...
@@ -199,7 +199,7 @@ func TestCRD(t *testing.T) {
}
}
createErr
:=
make
(
chan
error
,
1
)
createErr
:=
make
(
chan
error
,
1
)
go
func
()
{
go
func
()
{
_
,
err
:=
dynamicClient
.
Resource
(
fooResource
)
.
Namespace
(
"default"
)
.
Create
(
unstructuredFoo
)
_
,
err
:=
dynamicClient
.
Resource
(
fooResource
)
.
Namespace
(
"default"
)
.
Create
(
unstructuredFoo
,
metav1
.
CreateOptions
{}
)
t
.
Logf
(
"Foo instance create returned: %v"
,
err
)
t
.
Logf
(
"Foo instance create returned: %v"
,
err
)
if
err
!=
nil
{
if
err
!=
nil
{
createErr
<-
err
createErr
<-
err
...
@@ -272,7 +272,7 @@ func TestCRD(t *testing.T) {
...
@@ -272,7 +272,7 @@ func TestCRD(t *testing.T) {
}
}
fooUnstructured
.
UnmarshalJSON
(
bs
)
fooUnstructured
.
UnmarshalJSON
(
bs
)
_
,
err
=
dynamicClient
.
Resource
(
fooResource
)
.
Namespace
(
"default"
)
.
Update
(
fooUnstructured
)
_
,
err
=
dynamicClient
.
Resource
(
fooResource
)
.
Namespace
(
"default"
)
.
Update
(
fooUnstructured
,
metav1
.
UpdateOptions
{}
)
if
err
!=
nil
&&
!
errors
.
IsConflict
(
err
)
{
if
err
!=
nil
&&
!
errors
.
IsConflict
(
err
)
{
t
.
Fatalf
(
"Failed to update Foo instance: %v"
,
err
)
t
.
Fatalf
(
"Failed to update Foo instance: %v"
,
err
)
}
else
if
err
==
nil
{
}
else
if
err
==
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