Skip to content

Commit

Permalink
Update client-go to 0.18.5 (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
vsliouniaev authored Jul 15, 2020
1 parent 2e70121 commit 736bd36
Show file tree
Hide file tree
Showing 1,092 changed files with 181,933 additions and 58,125 deletions.
23 changes: 3 additions & 20 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,12 @@ module github.com/jet/kube-webhook-certgen
go 1.14

require (
github.com/evanphx/json-patch v4.2.0+incompatible // indirect
github.com/gogo/protobuf v1.2.1 // indirect
github.com/google/btree v1.0.0 // indirect
github.com/google/gofuzz v1.0.0 // indirect
github.com/googleapis/gnostic v0.2.0 // indirect
github.com/gregjones/httpcache v0.0.0-20190212212710-3befbb6ad0cc // indirect
github.com/imdario/mergo v0.3.7 // indirect
github.com/json-iterator/go v1.1.6 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.1 // indirect
github.com/onrik/logrus v0.3.0
github.com/onsi/ginkgo v1.8.0 // indirect
github.com/onsi/gomega v1.5.0 // indirect
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
github.com/sirupsen/logrus v1.4.2
github.com/spf13/cobra v0.0.4
golang.org/x/oauth2 v0.0.0-20190523182746-aaccbc9213b0 // indirect
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
k8s.io/api v0.0.0-20190222213804-5cb15d344471
k8s.io/apimachinery v0.0.0-20190221213512-86fb29eff628
k8s.io/client-go v10.0.0+incompatible
k8s.io/klog v0.3.0 // indirect
k8s.io/kube-openapi v0.0.0-20180216212618-50ae88d24ede // indirect
sigs.k8s.io/yaml v1.1.0 // indirect
k8s.io/api v0.18.5
k8s.io/apimachinery v0.18.5
k8s.io/client-go v0.18.5
)
171 changes: 151 additions & 20 deletions go.sum

Large diffs are not rendered by default.

17 changes: 11 additions & 6 deletions pkg/k8s/k8s.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package k8s

import (
"context"
log "github.com/sirupsen/logrus"
admissionv1beta1 "k8s.io/api/admissionregistration/v1beta1"
"k8s.io/api/core/v1"
Expand Down Expand Up @@ -41,7 +42,7 @@ func (k8s *k8s) PatchWebhookConfigurations(
valHook, err := k8s.clientset.
AdmissionregistrationV1beta1().
ValidatingWebhookConfigurations().
Get(configurationNames, metav1.GetOptions{})
Get(context.TODO(), configurationNames, metav1.GetOptions{})

if err != nil {
log.WithField("err", err).Fatal("failed getting validating webhook")
Expand All @@ -55,7 +56,9 @@ func (k8s *k8s) PatchWebhookConfigurations(
}
}

if _, err = k8s.clientset.AdmissionregistrationV1beta1().ValidatingWebhookConfigurations().Update(valHook); err != nil {
if _, err = k8s.clientset.AdmissionregistrationV1beta1().
ValidatingWebhookConfigurations().
Update(context.TODO(), valHook, metav1.UpdateOptions{}); err != nil {
log.WithField("err", err).Fatal("failed patching validating webhook")
}
log.Debug("patched validating hook")
Expand All @@ -67,7 +70,7 @@ func (k8s *k8s) PatchWebhookConfigurations(
mutHook, err := k8s.clientset.
AdmissionregistrationV1beta1().
MutatingWebhookConfigurations().
Get(configurationNames, metav1.GetOptions{})
Get(context.TODO(), configurationNames, metav1.GetOptions{})
if err != nil {
log.WithField("err", err).Fatal("failed getting validating webhook")
}
Expand All @@ -80,7 +83,9 @@ func (k8s *k8s) PatchWebhookConfigurations(
}
}

if _, err = k8s.clientset.AdmissionregistrationV1beta1().MutatingWebhookConfigurations().Update(mutHook); err != nil {
if _, err = k8s.clientset.AdmissionregistrationV1beta1().
MutatingWebhookConfigurations().
Update(context.TODO(), mutHook, metav1.UpdateOptions{}); err != nil {
log.WithField("err", err).Fatal("failed patching validating webhook")
}
log.Debug("patched mutating hook")
Expand All @@ -95,7 +100,7 @@ func (k8s *k8s) PatchWebhookConfigurations(
// "ca" from the secret, otherwise will return nil
func (k8s *k8s) GetCaFromSecret(secretName string, namespace string) []byte {
log.Debugf("getting secret '%s' in namespace '%s'", secretName, namespace)
secret, err := k8s.clientset.CoreV1().Secrets(namespace).Get(secretName, metav1.GetOptions{})
secret, err := k8s.clientset.CoreV1().Secrets(namespace).Get(context.TODO(), secretName, metav1.GetOptions{})
if err != nil {
if k8serrors.IsNotFound(err) {
log.WithField("err", err).Info("no secret found")
Expand Down Expand Up @@ -124,7 +129,7 @@ func (k8s *k8s) SaveCertsToSecret(secretName, namespace, certName, keyName strin
}

log.Debug("saving secret")
_, err := k8s.clientset.CoreV1().Secrets(namespace).Create(secret)
_, err := k8s.clientset.CoreV1().Secrets(namespace).Create(context.TODO(), secret, metav1.CreateOptions{})
if err != nil {
log.WithField("err", err).Fatal("failed creating secret")
}
Expand Down
17 changes: 9 additions & 8 deletions pkg/k8s/k8s_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package k8s

import (
"bytes"
"context"
"k8s.io/api/admissionregistration/v1beta1"
admissionv1beta1 "k8s.io/api/admissionregistration/v1beta1"
"k8s.io/api/core/v1"
Expand Down Expand Up @@ -49,7 +50,7 @@ func TestGetCaFromCertificate(t *testing.T) {
Data: map[string][]byte{"ca": ca, "cert": cert, "key": key},
}

k.clientset.CoreV1().Secrets(testNamespace).Create(secret)
k.clientset.CoreV1().Secrets(testNamespace).Create(context.Background(), secret, metav1.CreateOptions{})

retrievedCa := k.GetCaFromSecret(testSecretName, testNamespace)
if !bytes.Equal(retrievedCa, ca) {
Expand All @@ -64,7 +65,7 @@ func TestSaveCertsToSecret(t *testing.T) {

k.SaveCertsToSecret(testSecretName, testNamespace, "cert", "key", ca, cert, key)

secret, _ := k.clientset.CoreV1().Secrets(testNamespace).Get(testSecretName, metav1.GetOptions{})
secret, _ := k.clientset.CoreV1().Secrets(testNamespace).Get(context.Background(), testSecretName, metav1.GetOptions{})

if !bytes.Equal(secret.Data["cert"], cert) {
t.Error("'cert' saved data does not match retrieved")
Expand Down Expand Up @@ -93,29 +94,29 @@ func TestPatchWebhookConfigurations(t *testing.T) {
k.clientset.
AdmissionregistrationV1beta1().
MutatingWebhookConfigurations().
Create(&v1beta1.MutatingWebhookConfiguration{
Create(context.Background(), &v1beta1.MutatingWebhookConfiguration{
TypeMeta: metav1.TypeMeta{},
ObjectMeta: metav1.ObjectMeta{
Name: testWebhookName,
},
Webhooks: []v1beta1.Webhook{{Name: "m1"}, {Name: "m2"}}})
Webhooks: []v1beta1.MutatingWebhook{{Name: "m1"}, {Name: "m2"}}}, metav1.CreateOptions{})

k.clientset.
AdmissionregistrationV1beta1().
ValidatingWebhookConfigurations().
Create(&v1beta1.ValidatingWebhookConfiguration{
Create(context.Background(), &v1beta1.ValidatingWebhookConfiguration{
TypeMeta: metav1.TypeMeta{},
ObjectMeta: metav1.ObjectMeta{
Name: testWebhookName,
},
Webhooks: []v1beta1.Webhook{{Name: "v1"}, {Name: "v2"}}})
Webhooks: []v1beta1.ValidatingWebhook{{Name: "v1"}, {Name: "v2"}}}, metav1.CreateOptions{})

k.PatchWebhookConfigurations(testWebhookName, ca, &fail, true, true)

whmut, err := k.clientset.
AdmissionregistrationV1beta1().
MutatingWebhookConfigurations().
Get(testWebhookName, metav1.GetOptions{})
Get(context.Background(), testWebhookName, metav1.GetOptions{})

if err != nil {
t.Error(err)
Expand All @@ -124,7 +125,7 @@ func TestPatchWebhookConfigurations(t *testing.T) {
whval, err := k.clientset.
AdmissionregistrationV1beta1().
MutatingWebhookConfigurations().
Get(testWebhookName, metav1.GetOptions{})
Get(context.Background(), testWebhookName, metav1.GetOptions{})

if err != nil {
t.Error(err)
Expand Down
2 changes: 2 additions & 0 deletions vendor/github.com/gogo/protobuf/proto/encode.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions vendor/github.com/gogo/protobuf/proto/extensions.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions vendor/github.com/gogo/protobuf/proto/extensions_gogo.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 13 additions & 7 deletions vendor/github.com/gogo/protobuf/proto/lib.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

71 changes: 41 additions & 30 deletions vendor/github.com/gogo/protobuf/proto/properties.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 10 additions & 7 deletions vendor/github.com/gogo/protobuf/proto/table_marshal.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 736bd36

Please sign in to comment.