Skip to content

Commit

Permalink
Update dependencies
Browse files Browse the repository at this point in the history
Signed-off-by: Tamal Saha <[email protected]>
  • Loading branch information
tamalsaha committed May 25, 2020
1 parent d2b2b09 commit 8b7b805
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 135 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ require (
k8s.io/apimachinery v0.18.3
k8s.io/client-go v12.0.0+incompatible
k8s.io/kube-openapi v0.0.0-20200410145947-61e04a5be9a6
kmodules.xyz/client-go v0.0.0-20200524205059-e986bc44c91b
kmodules.xyz/client-go v0.0.0-20200525012433-99c6914a1eca
kmodules.xyz/crd-schema-fuzz v0.0.0-20200521005638-2433a187de95
sigs.k8s.io/yaml v1.2.0
)
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -624,8 +624,8 @@ k8s.io/kube-openapi v0.0.0-20200410145947-61e04a5be9a6 h1:Oh3Mzx5pJ+yIumsAD0MOEC
k8s.io/kube-openapi v0.0.0-20200410145947-61e04a5be9a6/go.mod h1:GRQhZsXIAJ1xR0C9bd8UpWHZ5plfAS9fzPjJuQ6JL3E=
k8s.io/utils v0.0.0-20200324210504-a9aa75ae1b89 h1:d4vVOjXm687F1iLSP2q3lyPPuyvTUt3aVoBpi2DqRsU=
k8s.io/utils v0.0.0-20200324210504-a9aa75ae1b89/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew=
kmodules.xyz/client-go v0.0.0-20200524205059-e986bc44c91b h1:2ylkWuybCgj1FzQ62BdonjACgXQ2jm3FEf0crrnKTns=
kmodules.xyz/client-go v0.0.0-20200524205059-e986bc44c91b/go.mod h1:sY/eoe4ktxZEoHpr5NpAQ5s22VSwTE8psJtKVeVgLRY=
kmodules.xyz/client-go v0.0.0-20200525012433-99c6914a1eca h1:mPVAdb27pSmNt1gKB7UFCKmRSeUEFwSvCXIlKUvy8Fk=
kmodules.xyz/client-go v0.0.0-20200525012433-99c6914a1eca/go.mod h1:sY/eoe4ktxZEoHpr5NpAQ5s22VSwTE8psJtKVeVgLRY=
kmodules.xyz/crd-schema-fuzz v0.0.0-20200521005638-2433a187de95 h1:v0S/+ftzL6Xrs9XevgchAOJyPKlRQXPiZf87xotj3X4=
kmodules.xyz/crd-schema-fuzz v0.0.0-20200521005638-2433a187de95/go.mod h1:jpu8xFsDKd6kAWUAKk8oTu/GQGBWqhrcaDeOJdaCJnk=
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
Expand Down
11 changes: 6 additions & 5 deletions vendor/kmodules.xyz/client-go/apiextensions/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,13 @@ func RegisterCRDs(client crd_cs.Interface, crds []*CustomResourceDefinition) err
if err != nil {
return err
}
k116OrLater := major > 1 || (major == 1 && minor >= 16)

for _, crd := range crds {
// Use crd v1 for k8s >= 1.16, if available
// ref: https://github.com/kubernetes/kubernetes/issues/91395
if major == 1 && minor >= 16 && crd.V1 != nil {
_, _, err := v1.CreateOrPatchCustomResourceDefinition(
if k116OrLater && crd.V1 != nil {
_, _, err := v1.CreateOrUpdateCustomResourceDefinition(
context.TODO(),
client,
crd.V1.Name,
Expand All @@ -59,7 +60,7 @@ func RegisterCRDs(client crd_cs.Interface, crds []*CustomResourceDefinition) err
in.Spec = crd.V1.Spec
return crd.V1
},
metav1.PatchOptions{},
metav1.UpdateOptions{},
)
if err != nil {
return err
Expand All @@ -75,7 +76,7 @@ func RegisterCRDs(client crd_cs.Interface, crds []*CustomResourceDefinition) err
crd.V1beta1.Spec.Validation.OpenAPIV3Schema.Type = ""
}

_, _, err := v1beta1.CreateOrPatchCustomResourceDefinition(
_, _, err := v1beta1.CreateOrUpdateCustomResourceDefinition(
context.TODO(),
client,
crd.V1beta1.Name,
Expand All @@ -86,7 +87,7 @@ func RegisterCRDs(client crd_cs.Interface, crds []*CustomResourceDefinition) err
in.Spec = crd.V1beta1.Spec
return crd.V1beta1
},
metav1.PatchOptions{},
metav1.UpdateOptions{},
)
if err != nil {
return err
Expand Down
48 changes: 6 additions & 42 deletions vendor/kmodules.xyz/client-go/apiextensions/v1/crd.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,24 @@ import (
cs "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset"
kerr "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/strategicpatch"
"k8s.io/apimachinery/pkg/util/wait"
kutil "kmodules.xyz/client-go"
)

func CreateOrPatchCustomResourceDefinition(
func CreateOrUpdateCustomResourceDefinition(
ctx context.Context,
c cs.Interface,
name string,
transform func(in *api.CustomResourceDefinition) *api.CustomResourceDefinition,
opts metav1.PatchOptions,
opts metav1.UpdateOptions,
) (*api.CustomResourceDefinition, kutil.VerbType, error) {
cur, err := c.ApiextensionsV1().CustomResourceDefinitions().Get(ctx, name, metav1.GetOptions{})
_, err := c.ApiextensionsV1().CustomResourceDefinitions().Get(ctx, name, metav1.GetOptions{})
if kerr.IsNotFound(err) {
glog.V(3).Infof("Creating CustomResourceDefinition %s.", name)
out, err := c.ApiextensionsV1().CustomResourceDefinitions().Create(ctx, transform(&api.CustomResourceDefinition{
TypeMeta: metav1.TypeMeta{
Kind: "CustomResourceDefinition",
APIVersion: api.SchemeGroupVersion.String(),
Kind: "CustomResourceDefinition",
},
ObjectMeta: metav1.ObjectMeta{
Name: name,
Expand All @@ -57,45 +55,11 @@ func CreateOrPatchCustomResourceDefinition(
} else if err != nil {
return nil, kutil.VerbUnchanged, err
}
return PatchCustomResourceDefinition(ctx, c, cur, transform, opts)
}

func PatchCustomResourceDefinition(
ctx context.Context,
c cs.Interface,
cur *api.CustomResourceDefinition,
transform func(*api.CustomResourceDefinition) *api.CustomResourceDefinition,
opts metav1.PatchOptions,
) (*api.CustomResourceDefinition, kutil.VerbType, error) {
return PatchCustomResourceDefinitionObject(ctx, c, cur, transform(cur.DeepCopy()), opts)
}

func PatchCustomResourceDefinitionObject(
ctx context.Context,
c cs.Interface,
cur, mod *api.CustomResourceDefinition,
opts metav1.PatchOptions,
) (*api.CustomResourceDefinition, kutil.VerbType, error) {
curJson, err := json.Marshal(cur)
if err != nil {
return nil, kutil.VerbUnchanged, err
}

modJson, err := json.Marshal(mod)
cur, err := TryUpdateCustomResourceDefinition(ctx, c, name, transform, opts)
if err != nil {
return nil, kutil.VerbUnchanged, err
}

patch, err := strategicpatch.CreateTwoWayMergePatch(curJson, modJson, api.CustomResourceDefinition{})
if err != nil {
return nil, kutil.VerbUnchanged, err
}
if len(patch) == 0 || string(patch) == "{}" {
return cur, kutil.VerbUnchanged, nil
}
glog.V(3).Infof("Patching CustomResourceDefinition %s with %s.", cur.Name, string(patch))
out, err := c.ApiextensionsV1().CustomResourceDefinitions().Patch(ctx, cur.Name, types.StrategicMergePatchType, patch, opts)
return out, kutil.VerbPatched, err
return cur, kutil.VerbUpdated, nil
}

func TryUpdateCustomResourceDefinition(
Expand Down
21 changes: 0 additions & 21 deletions vendor/kmodules.xyz/client-go/apiextensions/v1/kubernetes.go

This file was deleted.

48 changes: 6 additions & 42 deletions vendor/kmodules.xyz/client-go/apiextensions/v1beta1/crd.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,24 @@ import (
cs "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset"
kerr "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/strategicpatch"
"k8s.io/apimachinery/pkg/util/wait"
kutil "kmodules.xyz/client-go"
)

func CreateOrPatchCustomResourceDefinition(
func CreateOrUpdateCustomResourceDefinition(
ctx context.Context,
c cs.Interface,
name string,
transform func(in *api.CustomResourceDefinition) *api.CustomResourceDefinition,
opts metav1.PatchOptions,
opts metav1.UpdateOptions,
) (*api.CustomResourceDefinition, kutil.VerbType, error) {
cur, err := c.ApiextensionsV1beta1().CustomResourceDefinitions().Get(ctx, name, metav1.GetOptions{})
_, err := c.ApiextensionsV1beta1().CustomResourceDefinitions().Get(ctx, name, metav1.GetOptions{})
if kerr.IsNotFound(err) {
glog.V(3).Infof("Creating CustomResourceDefinition %s.", name)
out, err := c.ApiextensionsV1beta1().CustomResourceDefinitions().Create(ctx, transform(&api.CustomResourceDefinition{
TypeMeta: metav1.TypeMeta{
Kind: "CustomResourceDefinition",
APIVersion: api.SchemeGroupVersion.String(),
Kind: "CustomResourceDefinition",
},
ObjectMeta: metav1.ObjectMeta{
Name: name,
Expand All @@ -57,45 +55,11 @@ func CreateOrPatchCustomResourceDefinition(
} else if err != nil {
return nil, kutil.VerbUnchanged, err
}
return PatchCustomResourceDefinition(ctx, c, cur, transform, opts)
}

func PatchCustomResourceDefinition(
ctx context.Context,
c cs.Interface,
cur *api.CustomResourceDefinition,
transform func(*api.CustomResourceDefinition) *api.CustomResourceDefinition,
opts metav1.PatchOptions,
) (*api.CustomResourceDefinition, kutil.VerbType, error) {
return PatchCustomResourceDefinitionObject(ctx, c, cur, transform(cur.DeepCopy()), opts)
}

func PatchCustomResourceDefinitionObject(
ctx context.Context,
c cs.Interface,
cur, mod *api.CustomResourceDefinition,
opts metav1.PatchOptions,
) (*api.CustomResourceDefinition, kutil.VerbType, error) {
curJson, err := json.Marshal(cur)
if err != nil {
return nil, kutil.VerbUnchanged, err
}

modJson, err := json.Marshal(mod)
cur, err := TryUpdateCustomResourceDefinition(ctx, c, name, transform, opts)
if err != nil {
return nil, kutil.VerbUnchanged, err
}

patch, err := strategicpatch.CreateTwoWayMergePatch(curJson, modJson, api.CustomResourceDefinition{})
if err != nil {
return nil, kutil.VerbUnchanged, err
}
if len(patch) == 0 || string(patch) == "{}" {
return cur, kutil.VerbUnchanged, nil
}
glog.V(3).Infof("Patching CustomResourceDefinition %s with %s.", cur.Name, string(patch))
out, err := c.ApiextensionsV1beta1().CustomResourceDefinitions().Patch(ctx, cur.Name, types.StrategicMergePatchType, patch, opts)
return out, kutil.VerbPatched, err
return cur, kutil.VerbUpdated, nil
}

func TryUpdateCustomResourceDefinition(
Expand Down
21 changes: 0 additions & 21 deletions vendor/kmodules.xyz/client-go/apiextensions/v1beta1/kubernetes.go

This file was deleted.

2 changes: 1 addition & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,7 @@ k8s.io/utils/net
k8s.io/utils/path
k8s.io/utils/pointer
k8s.io/utils/trace
# kmodules.xyz/client-go v0.0.0-20200524205059-e986bc44c91b
# kmodules.xyz/client-go v0.0.0-20200525012433-99c6914a1eca
kmodules.xyz/client-go
kmodules.xyz/client-go/apiextensions
kmodules.xyz/client-go/apiextensions/v1
Expand Down

0 comments on commit 8b7b805

Please sign in to comment.