Skip to content
This repository was archived by the owner on May 6, 2022. It is now read-only.

Commit 56681c6

Browse files
authored
Update deps to k8s 1.18, adjust code after bump (#2796)
1 parent 87a6e81 commit 56681c6

2,315 files changed

Lines changed: 263283 additions & 75015 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Makefile

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,15 @@ endif
5858

5959
TYPES_FILES = $(shell find pkg/apis -name types.go)
6060
GO_VERSION ?= 1.13
61-
GOFLAGS =-mod=vendor
6261

62+
# Preserve also user values
63+
ifeq ($(GOFLAGS),)
64+
GOFLAGS := -mod=vendor
65+
else
66+
GOFLAGS := $(GOFLAGS) -mod=vendor
67+
endif
68+
69+
export GOFLAGS
6370
export GO111MODULE=on
6471

6572
ALL_ARCH=amd64 arm arm64 ppc64le s390x
@@ -80,7 +87,7 @@ endif
8087
BASEIMAGE?=gcr.io/google-containers/debian-base-$(ARCH):v1.0.0
8188

8289
GO_BUILD = env CGO_ENABLED=0 GOOS=$(PLATFORM) GOARCH=$(ARCH) \
83-
go build $(GOFLAGS) -a -tags netgo -installsuffix netgo \
90+
go build -a -tags netgo -installsuffix netgo \
8491
-ldflags '-s -w -X $(SC_PKG)/pkg.VERSION=$(VERSION) $(BUILD_LDFLAGS)'
8592

8693
BASE_PATH = $(ROOT:/src/github.com/kubernetes-sigs/service-catalog/=)
@@ -168,13 +175,13 @@ generators: $(GENERATORS)
168175
.SECONDEXPANSION:
169176

170177
$(BINDIR)/openapi-gen: $$(shell find vendor/k8s.io/kube-openapi/cmd/openapi-gen vendor/k8s.io/gengo) .init
171-
$(DOCKER_CMD) go build $(GOFLAGS) -o $@ $(SC_PKG)/vendor/k8s.io/kube-openapi/cmd/openapi-gen
178+
$(DOCKER_CMD) go build -o $@ $(SC_PKG)/vendor/k8s.io/kube-openapi/cmd/openapi-gen
172179

173180
# We specify broad dependencies for these generator binaries: each one depends
174181
# on everything under its source tree as well as gengo's. This uses GNU Make's
175182
# secondary expansion feature to pass $* to `find`.
176183
$(BINDIR)/%-gen: $$(shell find vendor/k8s.io/code-generator/cmd/$$*-gen vendor/k8s.io/gengo) .init
177-
$(DOCKER_CMD) go build $(GOFLAGS) -o $@ $(SC_PKG)/vendor/k8s.io/code-generator/cmd/$*-gen
184+
$(DOCKER_CMD) go build -o $@ $(SC_PKG)/vendor/k8s.io/code-generator/cmd/$*-gen
178185

179186
# Regenerate all files if the gen exes changed or any "types.go" files changed
180187
.generate_files: .init generators $(TYPES_FILES)

cmd/healthcheck/framework/healthcheck.go

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ limitations under the License.
1717
package framework
1818

1919
import (
20+
"context"
2021
goflag "flag"
2122
"fmt"
2223
"os"
@@ -235,7 +236,7 @@ func (h *HealthCheck) createInstance() error {
235236
},
236237
}
237238
operationStartTime := time.Now()
238-
instance, err = h.serviceCatalogClientSet.ServicecatalogV1beta1().ServiceInstances(h.namespace.Name).Create(instance)
239+
instance, err = h.serviceCatalogClientSet.ServicecatalogV1beta1().ServiceInstances(h.namespace.Name).Create(context.Background(), instance, metav1.CreateOptions{})
239240
if err != nil {
240241
return h.setError("error creating instance: %v", err.Error())
241242
}
@@ -259,7 +260,7 @@ func (h *HealthCheck) createInstance() error {
259260
ReportOperationCompleted("create_instance", operationStartTime)
260261

261262
klog.V(4).Info("Verifing references are resolved")
262-
sc, err := h.serviceCatalogClientSet.ServicecatalogV1beta1().ServiceInstances(h.namespace.Name).Get(h.instanceName, metav1.GetOptions{})
263+
sc, err := h.serviceCatalogClientSet.ServicecatalogV1beta1().ServiceInstances(h.namespace.Name).Get(context.Background(), h.instanceName, metav1.GetOptions{})
263264
if err != nil {
264265
return h.setError("error getting instance: %v", err.Error())
265266
}
@@ -300,7 +301,7 @@ func (h *HealthCheck) createBinding() error {
300301
},
301302
}
302303
operationStartTime := time.Now()
303-
binding, err := h.serviceCatalogClientSet.ServicecatalogV1beta1().ServiceBindings(h.namespace.Name).Create(binding)
304+
binding, err := h.serviceCatalogClientSet.ServicecatalogV1beta1().ServiceBindings(h.namespace.Name).Create(context.Background(), binding, metav1.CreateOptions{})
304305
if err != nil {
305306
return h.setError("Error creating binding: %v", err.Error())
306307
}
@@ -323,7 +324,7 @@ func (h *HealthCheck) createBinding() error {
323324
ReportOperationCompleted("binding_ready", operationStartTime)
324325

325326
klog.V(4).Info("Validating that a secret was created after binding")
326-
_, err = h.kubeClientSet.CoreV1().Secrets(h.namespace.Name).Get("my-secret", metav1.GetOptions{})
327+
_, err = h.kubeClientSet.CoreV1().Secrets(h.namespace.Name).Get(context.Background(), "my-secret", metav1.GetOptions{})
327328
if err != nil {
328329
return h.setError("Error getting secret: %v", err.Error())
329330
}
@@ -339,7 +340,7 @@ func (h *HealthCheck) deprovision() error {
339340
}
340341
klog.V(4).Info("Deleting the ServiceBinding.")
341342
operationStartTime := time.Now()
342-
err := h.serviceCatalogClientSet.ServicecatalogV1beta1().ServiceBindings(h.namespace.Name).Delete(h.bindingName, nil)
343+
err := h.serviceCatalogClientSet.ServicecatalogV1beta1().ServiceBindings(h.namespace.Name).Delete(context.Background(), h.bindingName, metav1.DeleteOptions{})
343344
if err != nil {
344345
return h.setError("error deleting binding: %v", err.Error())
345346
}
@@ -352,15 +353,15 @@ func (h *HealthCheck) deprovision() error {
352353
ReportOperationCompleted("binding_deleted", operationStartTime)
353354

354355
klog.V(4).Info("Verifying that the secret was deleted after deleting the binding")
355-
_, err = h.kubeClientSet.CoreV1().Secrets(h.namespace.Name).Get("my-secret", metav1.GetOptions{})
356+
_, err = h.kubeClientSet.CoreV1().Secrets(h.namespace.Name).Get(context.Background(), "my-secret", metav1.GetOptions{})
356357
if err == nil {
357358
return h.setError("secret not deleted")
358359
}
359360

360361
// Deprovisioning the ServiceInstance
361362
klog.V(4).Info("Deleting the ServiceInstance")
362363
operationStartTime = time.Now()
363-
err = h.serviceCatalogClientSet.ServicecatalogV1beta1().ServiceInstances(h.namespace.Name).Delete(h.instanceName, nil)
364+
err = h.serviceCatalogClientSet.ServicecatalogV1beta1().ServiceInstances(h.namespace.Name).Delete(context.Background(), h.instanceName, metav1.DeleteOptions{})
364365
if err != nil {
365366
return h.setError("error deleting instance: %v", err.Error())
366367
}
@@ -378,8 +379,8 @@ func (h *HealthCheck) deprovision() error {
378379
func (h *HealthCheck) cleanup() {
379380
if h.frameworkError != nil && h.namespace != nil {
380381
klog.V(4).Infof("Cleaning up. Deleting the binding, instance and test namespace %v", h.namespace.Name)
381-
h.serviceCatalogClientSet.ServicecatalogV1beta1().ServiceBindings(h.namespace.Name).Delete(h.bindingName, nil)
382-
h.serviceCatalogClientSet.ServicecatalogV1beta1().ServiceInstances(h.namespace.Name).Delete(h.instanceName, nil)
382+
h.serviceCatalogClientSet.ServicecatalogV1beta1().ServiceBindings(h.namespace.Name).Delete(context.Background(), h.bindingName, metav1.DeleteOptions{})
383+
h.serviceCatalogClientSet.ServicecatalogV1beta1().ServiceInstances(h.namespace.Name).Delete(context.Background(), h.instanceName, metav1.DeleteOptions{})
383384
DeleteKubeNamespace(h.kubeClientSet, h.namespace.Name)
384385
h.namespace = nil
385386
}

cmd/healthcheck/framework/utils.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ limitations under the License.
1717
package framework
1818

1919
import (
20+
"context"
2021
"fmt"
2122
"time"
2223

@@ -76,7 +77,7 @@ func CreateKubeNamespace(c kubernetes.Interface) (*corev1.Namespace, error) {
7677
var got *corev1.Namespace
7778
err := wait.PollImmediate(poll, defaultTimeout, func() (bool, error) {
7879
var err error
79-
got, err = c.CoreV1().Namespaces().Create(ns)
80+
got, err = c.CoreV1().Namespaces().Create(context.Background(), ns, metav1.CreateOptions{})
8081
if err != nil {
8182
klog.Errorf("Unexpected error while creating namespace: %v", err)
8283
return false, err
@@ -91,7 +92,7 @@ func CreateKubeNamespace(c kubernetes.Interface) (*corev1.Namespace, error) {
9192

9293
// DeleteKubeNamespace deletes the specified K8s namespace
9394
func DeleteKubeNamespace(c kubernetes.Interface, namespace string) error {
94-
return c.CoreV1().Namespaces().Delete(namespace, nil)
95+
return c.CoreV1().Namespaces().Delete(context.Background(), namespace, metav1.DeleteOptions{})
9596
}
9697

9798
// WaitForEndpoint waits for 'defaultTimeout' interval for an endpoint to be available
@@ -101,7 +102,7 @@ func WaitForEndpoint(c kubernetes.Interface, namespace, name string) error {
101102

102103
func endpointAvailable(c kubernetes.Interface, namespace, name string) wait.ConditionFunc {
103104
return func() (bool, error) {
104-
endpoint, err := c.CoreV1().Endpoints(namespace).Get(name, metav1.GetOptions{})
105+
endpoint, err := c.CoreV1().Endpoints(namespace).Get(context.Background(), name, metav1.GetOptions{})
105106
if err != nil {
106107
if apierrs.IsNotFound(err) {
107108
return false, nil

cmd/svcat/main.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,6 @@ import (
2121
"fmt"
2222
"os"
2323

24-
"k8s.io/client-go/rest"
25-
"k8s.io/client-go/tools/clientcmd"
26-
"k8s.io/klog"
27-
"k8s.io/kubectl/pkg/pluginutils"
28-
2924
"github.com/kubernetes-sigs/service-catalog/cmd/svcat/binding"
3025
"github.com/kubernetes-sigs/service-catalog/cmd/svcat/broker"
3126
"github.com/kubernetes-sigs/service-catalog/cmd/svcat/browsing"
@@ -42,7 +37,11 @@ import (
4237
"github.com/spf13/cobra"
4338
"github.com/spf13/pflag"
4439
"github.com/spf13/viper"
40+
"k8s.io/cli-runtime/pkg/genericclioptions"
4541
k8sclient "k8s.io/client-go/kubernetes"
42+
"k8s.io/client-go/rest"
43+
"k8s.io/client-go/tools/clientcmd"
44+
"k8s.io/klog"
4645
)
4746

4847
// These are build-time values, set during an official release
@@ -216,7 +215,9 @@ func getClients(kubeConfig, kubeContext string) (k8sClient k8sclient.Interface,
216215
var config clientcmd.ClientConfig
217216

218217
if plugin.IsPlugin() {
219-
restConfig, config, err = pluginutils.InitClientAndConfig()
218+
configFlags := genericclioptions.NewConfigFlags(true)
219+
config = configFlags.ToRawKubeConfigLoader()
220+
restConfig, err = configFlags.ToRESTConfig()
220221
if err != nil {
221222
return nil, nil, "", fmt.Errorf("could not get Kubernetes config from kubectl plugin context: %s", err)
222223
}

cmd/svcat/svcat_test.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,9 @@ func TestGetSvcatWithNamespacedBrokerFeatureDisabled(t *testing.T) {
112112
CommonServicePlanSpec: v1beta1.CommonServicePlanSpec{
113113
ExternalName: "my-cluster-plan",
114114
},
115+
ClusterServiceClassRef: v1beta1.ClusterObjectReference{
116+
Name: "my-cluster-class",
117+
},
115118
},
116119
},
117120
}
@@ -549,17 +552,18 @@ func executeCommand(t *testing.T, cmd string, continueOnErr bool) string {
549552
// executeCommand runs a svcat command against a fake k8s api,
550553
// returning the cli output.
551554
func executeFakeCommand(t *testing.T, cmd string, fakeContext *command.Context, continueOnErr bool) string {
555+
t.Helper()
552556
// Setup the svcat command
553-
svcat, _, err := buildCommand(cmd, fakeContext, "")
557+
cli, _, err := buildCommand(cmd, fakeContext, "")
554558
if err != nil {
555559
t.Fatalf("%+v", err)
556560
}
557561

558562
// Capture all output: stderr and stdout
559563
output := &bytes.Buffer{}
560-
svcat.SetOutput(output)
564+
cli.SetOutput(output)
561565

562-
err = svcat.Execute()
566+
err = cli.Execute()
563567
if err != nil && !continueOnErr {
564568
t.Fatalf("%+v", err)
565569
}

0 commit comments

Comments
 (0)