From 0c159e607bcae1967e73b69accc2bd7a8000fb06 Mon Sep 17 00:00:00 2001 From: Nacho Cano Date: Mon, 13 Jul 2020 12:49:04 -0700 Subject: [PATCH 01/11] v1beta1 sinkBinding types. --- hack/update-codegen.sh | 4 +- pkg/apis/sources/v1beta1/doc.go | 20 + pkg/apis/sources/v1beta1/implements_test.go | 41 ++ pkg/apis/sources/v1beta1/register.go | 53 ++ pkg/apis/sources/v1beta1/register_test.go | 71 +++ .../sources/v1beta1/sinkbinding_context.go | 43 ++ .../v1beta1/sinkbinding_context_test.go | 43 ++ .../sources/v1beta1/sinkbinding_conversion.go | 34 ++ .../v1beta1/sinkbinding_conversion_test.go | 34 ++ .../sources/v1beta1/sinkbinding_defaults.go | 34 ++ .../v1beta1/sinkbinding_defaults_test.go | 151 +++++ .../sources/v1beta1/sinkbinding_lifecycle.go | 157 ++++++ .../v1beta1/sinkbinding_lifecycle_test.go | 514 ++++++++++++++++++ pkg/apis/sources/v1beta1/sinkbinding_types.go | 101 ++++ .../sources/v1beta1/sinkbinding_types_test.go | 36 ++ .../sources/v1beta1/sinkbinding_validation.go | 38 ++ .../v1beta1/sinkbinding_validation_test.go | 126 +++++ .../sources/v1beta1/zz_generated.deepcopy.go | 121 +++++ pkg/client/clientset/versioned/clientset.go | 14 + .../versioned/fake/clientset_generated.go | 7 + .../clientset/versioned/fake/register.go | 2 + .../clientset/versioned/scheme/register.go | 2 + .../versioned/typed/sources/v1beta1/doc.go | 20 + .../typed/sources/v1beta1/fake/doc.go | 20 + .../sources/v1beta1/fake/fake_sinkbinding.go | 140 +++++ .../v1beta1/fake/fake_sources_client.go | 40 ++ .../sources/v1beta1/generated_expansion.go | 21 + .../typed/sources/v1beta1/sinkbinding.go | 191 +++++++ .../typed/sources/v1beta1/sources_client.go | 89 +++ .../informers/externalversions/generic.go | 5 + .../externalversions/sources/interface.go | 8 + .../sources/v1beta1/interface.go | 45 ++ .../sources/v1beta1/sinkbinding.go | 89 +++ .../sources/v1beta1/sinkbinding/fake/fake.go | 40 ++ .../v1beta1/sinkbinding/sinkbinding.go | 52 ++ .../sources/v1beta1/expansion_generated.go | 27 + .../listers/sources/v1beta1/sinkbinding.go | 94 ++++ 37 files changed, 2525 insertions(+), 2 deletions(-) create mode 100644 pkg/apis/sources/v1beta1/doc.go create mode 100644 pkg/apis/sources/v1beta1/implements_test.go create mode 100644 pkg/apis/sources/v1beta1/register.go create mode 100644 pkg/apis/sources/v1beta1/register_test.go create mode 100644 pkg/apis/sources/v1beta1/sinkbinding_context.go create mode 100644 pkg/apis/sources/v1beta1/sinkbinding_context_test.go create mode 100644 pkg/apis/sources/v1beta1/sinkbinding_conversion.go create mode 100644 pkg/apis/sources/v1beta1/sinkbinding_conversion_test.go create mode 100644 pkg/apis/sources/v1beta1/sinkbinding_defaults.go create mode 100644 pkg/apis/sources/v1beta1/sinkbinding_defaults_test.go create mode 100644 pkg/apis/sources/v1beta1/sinkbinding_lifecycle.go create mode 100644 pkg/apis/sources/v1beta1/sinkbinding_lifecycle_test.go create mode 100644 pkg/apis/sources/v1beta1/sinkbinding_types.go create mode 100644 pkg/apis/sources/v1beta1/sinkbinding_types_test.go create mode 100644 pkg/apis/sources/v1beta1/sinkbinding_validation.go create mode 100644 pkg/apis/sources/v1beta1/sinkbinding_validation_test.go create mode 100644 pkg/apis/sources/v1beta1/zz_generated.deepcopy.go create mode 100644 pkg/client/clientset/versioned/typed/sources/v1beta1/doc.go create mode 100644 pkg/client/clientset/versioned/typed/sources/v1beta1/fake/doc.go create mode 100644 pkg/client/clientset/versioned/typed/sources/v1beta1/fake/fake_sinkbinding.go create mode 100644 pkg/client/clientset/versioned/typed/sources/v1beta1/fake/fake_sources_client.go create mode 100644 pkg/client/clientset/versioned/typed/sources/v1beta1/generated_expansion.go create mode 100644 pkg/client/clientset/versioned/typed/sources/v1beta1/sinkbinding.go create mode 100644 pkg/client/clientset/versioned/typed/sources/v1beta1/sources_client.go create mode 100644 pkg/client/informers/externalversions/sources/v1beta1/interface.go create mode 100644 pkg/client/informers/externalversions/sources/v1beta1/sinkbinding.go create mode 100644 pkg/client/injection/informers/sources/v1beta1/sinkbinding/fake/fake.go create mode 100644 pkg/client/injection/informers/sources/v1beta1/sinkbinding/sinkbinding.go create mode 100644 pkg/client/listers/sources/v1beta1/expansion_generated.go create mode 100644 pkg/client/listers/sources/v1beta1/sinkbinding.go diff --git a/hack/update-codegen.sh b/hack/update-codegen.sh index 89080ed776b..e3d5795d81b 100755 --- a/hack/update-codegen.sh +++ b/hack/update-codegen.sh @@ -45,7 +45,7 @@ chmod +x ${CODEGEN_PKG}/generate-groups.sh # instead of the $GOPATH directly. For normal projects this can be dropped. ${CODEGEN_PKG}/generate-groups.sh "deepcopy,client,informer,lister" \ knative.dev/eventing/pkg/client knative.dev/eventing/pkg/apis \ - "eventing:v1beta1 eventing:v1 messaging:v1beta1 messaging:v1 flows:v1beta1 flows:v1 sources:v1alpha1 sources:v1alpha2 configs:v1alpha1" \ + "eventing:v1beta1 eventing:v1 messaging:v1beta1 messaging:v1 flows:v1beta1 flows:v1 sources:v1alpha1 sources:v1alpha2 sources:v1beta1 configs:v1alpha1" \ --go-header-file ${REPO_ROOT_DIR}/hack/boilerplate/boilerplate.go.txt # Deep copy config @@ -65,7 +65,7 @@ ${CODEGEN_PKG}/generate-groups.sh "deepcopy" \ chmod +x ${KNATIVE_CODEGEN_PKG}/hack/generate-knative.sh ${KNATIVE_CODEGEN_PKG}/hack/generate-knative.sh "injection" \ knative.dev/eventing/pkg/client knative.dev/eventing/pkg/apis \ - "eventing:v1beta1 eventing:v1 messaging:v1beta1 messaging:v1 flows:v1beta1 flows:v1 sources:v1alpha1 sources:v1alpha2 duck:v1alpha1 duck:v1beta1 duck:v1 configs:v1alpha1" \ + "eventing:v1beta1 eventing:v1 messaging:v1beta1 messaging:v1 flows:v1beta1 flows:v1 sources:v1alpha1 sources:v1alpha2 sources:v1beta1 duck:v1alpha1 duck:v1beta1 duck:v1 configs:v1alpha1" \ --go-header-file ${REPO_ROOT_DIR}/hack/boilerplate/boilerplate.go.txt # Make sure our dependencies are up-to-date diff --git a/pkg/apis/sources/v1beta1/doc.go b/pkg/apis/sources/v1beta1/doc.go new file mode 100644 index 00000000000..c49210a401a --- /dev/null +++ b/pkg/apis/sources/v1beta1/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2020 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Package v1beta1 contains API Schema definitions for the sources v1beta1 API group. +// +k8s:deepcopy-gen=package +// +groupName=sources.knative.dev +package v1beta1 diff --git a/pkg/apis/sources/v1beta1/implements_test.go b/pkg/apis/sources/v1beta1/implements_test.go new file mode 100644 index 00000000000..a2ec4ebeecc --- /dev/null +++ b/pkg/apis/sources/v1beta1/implements_test.go @@ -0,0 +1,41 @@ +/* +Copyright 2020 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +package v1beta1 + +import ( + "testing" + + "knative.dev/pkg/apis/duck" + duckv1 "knative.dev/pkg/apis/duck/v1" + duckv1alpha1 "knative.dev/pkg/apis/duck/v1alpha1" +) + +func TestTypesImplements(t *testing.T) { + testCases := []struct { + instance interface{} + iface duck.Implementable + }{ + // SinkBinding + {instance: &SinkBinding{}, iface: &duckv1.Conditions{}}, + {instance: &SinkBinding{}, iface: &duckv1.Source{}}, + {instance: &SinkBinding{}, iface: &duckv1alpha1.Binding{}}, + } + for _, tc := range testCases { + if err := duck.VerifyType(tc.instance, tc.iface); err != nil { + t.Error(err) + } + } +} diff --git a/pkg/apis/sources/v1beta1/register.go b/pkg/apis/sources/v1beta1/register.go new file mode 100644 index 00000000000..be4a87cfa1d --- /dev/null +++ b/pkg/apis/sources/v1beta1/register.go @@ -0,0 +1,53 @@ +/* +Copyright 2020 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1beta1 + +import ( + "knative.dev/eventing/pkg/apis/sources" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +// SchemeGroupVersion is group version used to register these objects +var SchemeGroupVersion = schema.GroupVersion{Group: sources.GroupName, Version: "v1beta1"} + +// Kind takes an unqualified kind and returns back a Group qualified GroupKind +func Kind(kind string) schema.GroupKind { + return SchemeGroupVersion.WithKind(kind).GroupKind() +} + +// Resource takes an unqualified resource and returns a Group qualified GroupResource +func Resource(resource string) schema.GroupResource { + return SchemeGroupVersion.WithResource(resource).GroupResource() +} + +var ( + SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) + AddToScheme = SchemeBuilder.AddToScheme +) + +// Adds the list of known types to Scheme. +func addKnownTypes(scheme *runtime.Scheme) error { + scheme.AddKnownTypes(SchemeGroupVersion, + &SinkBinding{}, + &SinkBindingList{}, + ) + metav1.AddToGroupVersion(scheme, SchemeGroupVersion) + return nil +} diff --git a/pkg/apis/sources/v1beta1/register_test.go b/pkg/apis/sources/v1beta1/register_test.go new file mode 100644 index 00000000000..b927626ade0 --- /dev/null +++ b/pkg/apis/sources/v1beta1/register_test.go @@ -0,0 +1,71 @@ +/* +Copyright 2020 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1beta1 + +import ( + "testing" + + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" + + "github.com/google/go-cmp/cmp" +) + +// Resource takes an unqualified resource and returns a Group qualified GroupResource +func TestResource(t *testing.T) { + want := schema.GroupResource{ + Group: "sources.knative.dev", + Resource: "foo", + } + + got := Resource("foo") + + if diff := cmp.Diff(want, got); diff != "" { + t.Errorf("unexpected resource (-want, +got) = %v", diff) + } +} + +// Kind takes an unqualified resource and returns a Group qualified GroupKind +func TestKind(t *testing.T) { + want := schema.GroupKind{ + Group: "sources.knative.dev", + Kind: "kind", + } + + got := Kind("kind") + + if diff := cmp.Diff(want, got); diff != "" { + t.Errorf("unexpected resource (-want, +got) = %v", diff) + } +} + +// TestKnownTypes makes sure that expected types get added. +func TestKnownTypes(t *testing.T) { + scheme := runtime.NewScheme() + addKnownTypes(scheme) + types := scheme.KnownTypes(SchemeGroupVersion) + + for _, name := range []string{ + "SinkBinding", + "SinkBindingList", + } { + if _, ok := types[name]; !ok { + t.Errorf("Did not find %q as registered type", name) + } + } + +} diff --git a/pkg/apis/sources/v1beta1/sinkbinding_context.go b/pkg/apis/sources/v1beta1/sinkbinding_context.go new file mode 100644 index 00000000000..787f91ca345 --- /dev/null +++ b/pkg/apis/sources/v1beta1/sinkbinding_context.go @@ -0,0 +1,43 @@ +/* +Copyright 2020 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1beta1 + +import ( + "context" + + "knative.dev/pkg/apis" +) + +// sinkURIKey is used as the key for associating information +// with a context.Context. +type sinkURIKey struct{} + +// WithSinkURI notes on the context for binding that the resolved SinkURI +// is the provided apis.URL. +func WithSinkURI(ctx context.Context, uri *apis.URL) context.Context { + return context.WithValue(ctx, sinkURIKey{}, uri) +} + +// GetSinkURI accesses the apis.URL for the Sink URI that has been associated +// with this context. +func GetSinkURI(ctx context.Context) *apis.URL { + value := ctx.Value(sinkURIKey{}) + if value == nil { + return nil + } + return value.(*apis.URL) +} diff --git a/pkg/apis/sources/v1beta1/sinkbinding_context_test.go b/pkg/apis/sources/v1beta1/sinkbinding_context_test.go new file mode 100644 index 00000000000..854cac88592 --- /dev/null +++ b/pkg/apis/sources/v1beta1/sinkbinding_context_test.go @@ -0,0 +1,43 @@ +/* +Copyright 2020 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1beta1 + +import ( + "context" + "testing" + + "knative.dev/pkg/apis" +) + +func TestGetSinkURI(t *testing.T) { + ctx := context.Background() + + if uri := GetSinkURI(ctx); uri != nil { + t.Errorf("GetSinkURI() = %v, wanted nil", uri) + } + + want := &apis.URL{ + Scheme: "https", + Host: "knobots.io", + Path: "/omg/a/path", + } + ctx = WithSinkURI(ctx, want) + + if got := GetSinkURI(ctx); got != want { + t.Errorf("GetSinkURI() = %v, wanted %v", got, want) + } +} diff --git a/pkg/apis/sources/v1beta1/sinkbinding_conversion.go b/pkg/apis/sources/v1beta1/sinkbinding_conversion.go new file mode 100644 index 00000000000..de89653fa75 --- /dev/null +++ b/pkg/apis/sources/v1beta1/sinkbinding_conversion.go @@ -0,0 +1,34 @@ +/* +Copyright 2020 The Knative Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1beta1 + +import ( + "context" + "fmt" + + "knative.dev/pkg/apis" +) + +// ConvertTo implements apis.Convertible +func (source *SinkBinding) ConvertTo(ctx context.Context, sink apis.Convertible) error { + return fmt.Errorf("v1beta1 is the highest known version, got: %T", sink) +} + +// ConvertFrom implements apis.Convertible +func (sink *SinkBinding) ConvertFrom(ctx context.Context, source apis.Convertible) error { + return fmt.Errorf("v1beta1 is the highest known version, got: %T", source) +} diff --git a/pkg/apis/sources/v1beta1/sinkbinding_conversion_test.go b/pkg/apis/sources/v1beta1/sinkbinding_conversion_test.go new file mode 100644 index 00000000000..a25d5bf2351 --- /dev/null +++ b/pkg/apis/sources/v1beta1/sinkbinding_conversion_test.go @@ -0,0 +1,34 @@ +/* +Copyright 2020 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1beta1 + +import ( + "context" + "testing" +) + +func TestSinkBindingConversionBadType(t *testing.T) { + good, bad := &SinkBinding{}, &SinkBinding{} + + if err := good.ConvertTo(context.Background(), bad); err == nil { + t.Errorf("ConvertTo() = %#v, wanted error", bad) + } + + if err := good.ConvertFrom(context.Background(), bad); err == nil { + t.Errorf("ConvertFrom() = %#v, wanted error", good) + } +} diff --git a/pkg/apis/sources/v1beta1/sinkbinding_defaults.go b/pkg/apis/sources/v1beta1/sinkbinding_defaults.go new file mode 100644 index 00000000000..b04ced1170f --- /dev/null +++ b/pkg/apis/sources/v1beta1/sinkbinding_defaults.go @@ -0,0 +1,34 @@ +/* +Copyright 2020 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1beta1 + +import ( + "context" + + "knative.dev/pkg/apis" +) + +// SetDefaults implements apis.Defaultable +func (fb *SinkBinding) SetDefaults(ctx context.Context) { + if fb.Spec.Subject.Namespace == "" { + // Default the subject's namespace to our namespace. + fb.Spec.Subject.Namespace = fb.Namespace + } + + withNS := apis.WithinParent(ctx, fb.ObjectMeta) + fb.Spec.Sink.SetDefaults(withNS) +} diff --git a/pkg/apis/sources/v1beta1/sinkbinding_defaults_test.go b/pkg/apis/sources/v1beta1/sinkbinding_defaults_test.go new file mode 100644 index 00000000000..9062c24735e --- /dev/null +++ b/pkg/apis/sources/v1beta1/sinkbinding_defaults_test.go @@ -0,0 +1,151 @@ +/* +Copyright 2020 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1beta1 + +import ( + "context" + "testing" + + "github.com/google/go-cmp/cmp" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "knative.dev/pkg/apis" + duckv1 "knative.dev/pkg/apis/duck/v1" + duckv1alpha1 "knative.dev/pkg/apis/duck/v1alpha1" + "knative.dev/pkg/tracker" +) + +func TestSinkBindingDefaulting(t *testing.T) { + tests := []struct { + name string + in *SinkBinding + want *SinkBinding + }{{ + name: "namespace is defaulted", + in: &SinkBinding{ + ObjectMeta: metav1.ObjectMeta{ + Name: "matt", + Namespace: "moore", + }, + Spec: SinkBindingSpec{ + BindingSpec: duckv1alpha1.BindingSpec{ + Subject: tracker.Reference{ + APIVersion: "apps/v1", + Kind: "Deployment", + Name: "jeanne", + }, + }, + SourceSpec: duckv1.SourceSpec{ + Sink: duckv1.Destination{ + Ref: &duckv1.KReference{ + APIVersion: "serving.knative.dev/v1", + Kind: "Service", + Name: "gemma", + }, + }, + }, + }, + }, + want: &SinkBinding{ + ObjectMeta: metav1.ObjectMeta{ + Name: "matt", + Namespace: "moore", + }, + Spec: SinkBindingSpec{ + BindingSpec: duckv1alpha1.BindingSpec{ + Subject: tracker.Reference{ + APIVersion: "apps/v1", + Kind: "Deployment", + Name: "jeanne", + // This is filled in by defaulting. + Namespace: "moore", + }, + }, + SourceSpec: duckv1.SourceSpec{ + Sink: duckv1.Destination{ + Ref: &duckv1.KReference{ + APIVersion: "serving.knative.dev/v1", + Kind: "Service", + Name: "gemma", + // This is filled in by defaulting. + Namespace: "moore", + }, + }, + }, + }, + }, + }, { + name: "no ref, given namespace", + in: &SinkBinding{ + ObjectMeta: metav1.ObjectMeta{ + Name: "matt", + Namespace: "moore", + }, + Spec: SinkBindingSpec{ + BindingSpec: duckv1alpha1.BindingSpec{ + Subject: tracker.Reference{ + APIVersion: "apps/v1", + Kind: "Deployment", + Name: "jeanne", + Namespace: "lorefice", + }, + }, + SourceSpec: duckv1.SourceSpec{ + Sink: duckv1.Destination{ + URI: &apis.URL{ + Scheme: "http", + Host: "moore.dev", + }, + }, + }, + }, + }, + want: &SinkBinding{ + ObjectMeta: metav1.ObjectMeta{ + Name: "matt", + Namespace: "moore", + }, + Spec: SinkBindingSpec{ + BindingSpec: duckv1alpha1.BindingSpec{ + Subject: tracker.Reference{ + APIVersion: "apps/v1", + Kind: "Deployment", + Name: "jeanne", + Namespace: "lorefice", + }, + }, + SourceSpec: duckv1.SourceSpec{ + Sink: duckv1.Destination{ + URI: &apis.URL{ + Scheme: "http", + Host: "moore.dev", + }, + }, + }, + }, + }, + }} + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + got := test.in + got.SetDefaults(context.Background()) + if !cmp.Equal(test.want, got) { + t.Errorf("SetDefaults (-want, +got) = %v", cmp.Diff(test.want, got)) + } + }) + } +} diff --git a/pkg/apis/sources/v1beta1/sinkbinding_lifecycle.go b/pkg/apis/sources/v1beta1/sinkbinding_lifecycle.go new file mode 100644 index 00000000000..56de4d8f097 --- /dev/null +++ b/pkg/apis/sources/v1beta1/sinkbinding_lifecycle.go @@ -0,0 +1,157 @@ +/* +Copyright 2020 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1beta1 + +import ( + "context" + "encoding/json" + "fmt" + + corev1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/runtime/schema" + "knative.dev/eventing/pkg/logging" + "knative.dev/pkg/apis" + "knative.dev/pkg/apis/duck" + duckv1 "knative.dev/pkg/apis/duck/v1" + "knative.dev/pkg/tracker" +) + +var sbCondSet = apis.NewLivingConditionSet() + +// GetConditionSet retrieves the condition set for this resource. Implements the KRShaped interface. +func (*SinkBinding) GetConditionSet() apis.ConditionSet { + return sbCondSet +} + +// GetGroupVersionKind returns the GroupVersionKind. +func (*SinkBinding) GetGroupVersionKind() schema.GroupVersionKind { + return SchemeGroupVersion.WithKind("SinkBinding") +} + +// GetUntypedSpec implements apis.HasSpec +func (s *SinkBinding) GetUntypedSpec() interface{} { + return s.Spec +} + +// GetSubject implements psbinding.Bindable +func (sb *SinkBinding) GetSubject() tracker.Reference { + return sb.Spec.Subject +} + +// GetBindingStatus implements psbinding.Bindable +func (sb *SinkBinding) GetBindingStatus() duck.BindableStatus { + return &sb.Status +} + +// SetObservedGeneration implements psbinding.BindableStatus +func (sbs *SinkBindingStatus) SetObservedGeneration(gen int64) { + sbs.ObservedGeneration = gen +} + +// InitializeConditions populates the SinkBindingStatus's conditions field +// with all of its conditions configured to Unknown. +func (sbs *SinkBindingStatus) InitializeConditions() { + sbCondSet.Manage(sbs).InitializeConditions() +} + +// MarkBindingUnavailable marks the SinkBinding's Ready condition to False with +// the provided reason and message. +func (sbs *SinkBindingStatus) MarkBindingUnavailable(reason, message string) { + sbCondSet.Manage(sbs).MarkFalse(SinkBindingConditionReady, reason, message) +} + +// MarkBindingAvailable marks the SinkBinding's Ready condition to True. +func (sbs *SinkBindingStatus) MarkBindingAvailable() { + sbCondSet.Manage(sbs).MarkTrue(SinkBindingConditionReady) +} + +// Do implements psbinding.Bindable +func (sb *SinkBinding) Do(ctx context.Context, ps *duckv1.WithPod) { + // First undo so that we can just unconditionally append below. + sb.Undo(ctx, ps) + + uri := GetSinkURI(ctx) + if uri == nil { + logging.FromContext(ctx).Error(fmt.Sprintf("No sink URI associated with context for %+v", sb)) + return + } + + var ceOverrides string + if sb.Spec.CloudEventOverrides != nil { + if co, err := json.Marshal(sb.Spec.SourceSpec.CloudEventOverrides); err != nil { + logging.FromContext(ctx).Error(fmt.Sprintf("Failed to marshal CloudEventOverrides into JSON for %+v, %v", sb, err)) + } else if len(co) > 0 { + ceOverrides = string(co) + } + } + + spec := ps.Spec.Template.Spec + for i := range spec.InitContainers { + spec.InitContainers[i].Env = append(spec.InitContainers[i].Env, corev1.EnvVar{ + Name: "K_SINK", + Value: uri.String(), + }) + spec.InitContainers[i].Env = append(spec.InitContainers[i].Env, corev1.EnvVar{ + Name: "K_CE_OVERRIDES", + Value: ceOverrides, + }) + } + for i := range spec.Containers { + spec.Containers[i].Env = append(spec.Containers[i].Env, corev1.EnvVar{ + Name: "K_SINK", + Value: uri.String(), + }) + spec.Containers[i].Env = append(spec.Containers[i].Env, corev1.EnvVar{ + Name: "K_CE_OVERRIDES", + Value: ceOverrides, + }) + } +} + +func (sb *SinkBinding) Undo(ctx context.Context, ps *duckv1.WithPod) { + spec := ps.Spec.Template.Spec + for i, c := range spec.InitContainers { + if len(c.Env) == 0 { + continue + } + env := make([]corev1.EnvVar, 0, len(spec.InitContainers[i].Env)) + for j, ev := range c.Env { + switch ev.Name { + case "K_SINK", "K_CE_OVERRIDES": + continue + default: + env = append(env, spec.InitContainers[i].Env[j]) + } + } + spec.InitContainers[i].Env = env + } + for i, c := range spec.Containers { + if len(c.Env) == 0 { + continue + } + env := make([]corev1.EnvVar, 0, len(spec.Containers[i].Env)) + for j, ev := range c.Env { + switch ev.Name { + case "K_SINK", "K_CE_OVERRIDES": + continue + default: + env = append(env, spec.Containers[i].Env[j]) + } + } + spec.Containers[i].Env = env + } +} diff --git a/pkg/apis/sources/v1beta1/sinkbinding_lifecycle_test.go b/pkg/apis/sources/v1beta1/sinkbinding_lifecycle_test.go new file mode 100644 index 00000000000..c95fa3e11bb --- /dev/null +++ b/pkg/apis/sources/v1beta1/sinkbinding_lifecycle_test.go @@ -0,0 +1,514 @@ +/* +Copyright 2020 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1beta1 + +import ( + "context" + "reflect" + "testing" + + "github.com/google/go-cmp/cmp" + corev1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/runtime/schema" + "knative.dev/pkg/apis" + duckv1 "knative.dev/pkg/apis/duck/v1" + duckv1alpha1 "knative.dev/pkg/apis/duck/v1alpha1" + "knative.dev/pkg/tracker" +) + +func TestSinkBindingGetConditionSet(t *testing.T) { + r := &SinkBinding{} + + if got, want := r.GetConditionSet().GetTopLevelConditionType(), apis.ConditionReady; got != want { + t.Errorf("GetTopLevelCondition=%v, want=%v", got, want) + } +} + +func TestSinkBindingGetGroupVersionKind(t *testing.T) { + r := &SinkBinding{} + want := schema.GroupVersionKind{ + Group: "sources.knative.dev", + Version: "v1beta1", + Kind: "SinkBinding", + } + if got := r.GetGroupVersionKind(); got != want { + t.Errorf("got: %v, want: %v", got, want) + } +} + +func TestSinkBindingGetters(t *testing.T) { + r := &SinkBinding{ + Spec: SinkBindingSpec{ + BindingSpec: duckv1alpha1.BindingSpec{ + Subject: tracker.Reference{ + APIVersion: "foo", + }, + }, + }, + } + if got, want := r.GetUntypedSpec(), r.Spec; !reflect.DeepEqual(got, want) { + t.Errorf("GetUntypedSpec() = %v, want: %v", got, want) + } + if got, want := r.GetSubject(), r.Spec.Subject; !reflect.DeepEqual(got, want) { + t.Errorf("GetSubject() = %v, want: %v", got, want) + } + if got, want := r.GetBindingStatus(), &r.Status; !reflect.DeepEqual(got, want) { + t.Errorf("GetBindingStatus() = %v, want: %v", got, want) + } +} + +func TestSinkBindingSetObsGen(t *testing.T) { + r := &SinkBinding{ + Spec: SinkBindingSpec{ + BindingSpec: duckv1alpha1.BindingSpec{ + Subject: tracker.Reference{ + APIVersion: "foo", + }, + }, + }, + } + want := int64(3762) + r.GetBindingStatus().SetObservedGeneration(want) + if got := r.Status.ObservedGeneration; got != want { + t.Errorf("SetObservedGeneration() = %d, wanted %d", got, want) + } +} + +func TestSinkBindingStatusIsReady(t *testing.T) { + tests := []struct { + name string + s *SinkBindingStatus + want bool + }{{ + name: "uninitialized", + s: &SinkBindingStatus{}, + want: false, + }, { + name: "initialized", + s: func() *SinkBindingStatus { + s := &SinkBindingStatus{} + s.InitializeConditions() + return s + }(), + want: false, + }, { + name: "mark available", + s: func() *SinkBindingStatus { + s := &SinkBindingStatus{} + s.InitializeConditions() + s.MarkBindingUnavailable("TheReason", "this is the message") + return s + }(), + want: false, + }, { + name: "mark available", + s: func() *SinkBindingStatus { + s := &SinkBindingStatus{} + s.InitializeConditions() + s.MarkBindingAvailable() + return s + }(), + want: true, + }} + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + got := test.s.IsReady() + if diff := cmp.Diff(test.want, got); diff != "" { + t.Errorf("%s: unexpected condition (-want, +got) = %v", test.name, diff) + } + }) + } +} + +func TestSinkBindingUndo(t *testing.T) { + tests := []struct { + name string + in *duckv1.WithPod + want *duckv1.WithPod + }{{ + name: "nothing to remove", + in: &duckv1.WithPod{ + Spec: duckv1.WithPodSpec{ + Template: duckv1.PodSpecable{ + Spec: corev1.PodSpec{ + Containers: []corev1.Container{{ + Name: "blah", + Image: "busybox", + }}, + }, + }, + }, + }, + want: &duckv1.WithPod{ + Spec: duckv1.WithPodSpec{ + Template: duckv1.PodSpecable{ + Spec: corev1.PodSpec{ + Containers: []corev1.Container{{ + Name: "blah", + Image: "busybox", + }}, + }, + }, + }, + }, + }, { + name: "lots to remove", + in: &duckv1.WithPod{ + Spec: duckv1.WithPodSpec{ + Template: duckv1.PodSpecable{ + Spec: corev1.PodSpec{ + InitContainers: []corev1.Container{{ + Name: "setup", + Image: "busybox", + Env: []corev1.EnvVar{{ + Name: "FOO", + Value: "BAR", + }, { + Name: "K_SINK", + Value: "http://localhost:8080", + }, { + Name: "BAZ", + Value: "INGA", + }, { + Name: "K_CE_OVERRIDES", + Value: `{"extensions":{"foo":"bar"}}`, + }}, + }}, + Containers: []corev1.Container{{ + Name: "blah", + Image: "busybox", + Env: []corev1.EnvVar{{ + Name: "FOO", + Value: "BAR", + }, { + Name: "K_SINK", + Value: "http://localhost:8080", + }, { + Name: "BAZ", + Value: "INGA", + }, { + Name: "K_CE_OVERRIDES", + Value: `{"extensions":{"foo":"bar"}}`, + }}, + }, { + Name: "sidecar", + Image: "busybox", + Env: []corev1.EnvVar{{ + Name: "K_SINK", + Value: "http://localhost:8080", + }, { + Name: "BAZ", + Value: "INGA", + }, { + Name: "K_CE_OVERRIDES", + Value: `{"extensions":{"foo":"bar"}}`, + }}, + }}, + }, + }, + }, + }, + want: &duckv1.WithPod{ + Spec: duckv1.WithPodSpec{ + Template: duckv1.PodSpecable{ + Spec: corev1.PodSpec{ + InitContainers: []corev1.Container{{ + Name: "setup", + Image: "busybox", + Env: []corev1.EnvVar{{ + Name: "FOO", + Value: "BAR", + }, { + Name: "BAZ", + Value: "INGA", + }}, + }}, + Containers: []corev1.Container{{ + Name: "blah", + Image: "busybox", + Env: []corev1.EnvVar{{ + Name: "FOO", + Value: "BAR", + }, { + Name: "BAZ", + Value: "INGA", + }}, + }, { + Name: "sidecar", + Image: "busybox", + Env: []corev1.EnvVar{{ + Name: "BAZ", + Value: "INGA", + }}, + }}, + }, + }, + }, + }, + }} + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + got := test.in + sb := &SinkBinding{} + sb.Undo(context.Background(), got) + + if !cmp.Equal(got, test.want) { + t.Errorf("Undo (-want, +got): %s", cmp.Diff(test.want, got)) + } + }) + } +} + +func TestSinkBindingDo(t *testing.T) { + sinkURI := &apis.URL{ + Scheme: "http", + Host: "thing.ns.svc.cluster.local", + Path: "/a/path", + } + + overrides := duckv1.CloudEventOverrides{Extensions: map[string]string{"foo": "bar"}} + + tests := []struct { + name string + in *duckv1.WithPod + want *duckv1.WithPod + }{{ + name: "nothing to add", + in: &duckv1.WithPod{ + Spec: duckv1.WithPodSpec{ + Template: duckv1.PodSpecable{ + Spec: corev1.PodSpec{ + Containers: []corev1.Container{{ + Name: "blah", + Image: "busybox", + Env: []corev1.EnvVar{{ + Name: "K_SINK", + Value: sinkURI.String(), + }, { + Name: "K_CE_OVERRIDES", + Value: `{"extensions":{"foo":"bar"}}`, + }}, + }}, + }, + }, + }, + }, + want: &duckv1.WithPod{ + Spec: duckv1.WithPodSpec{ + Template: duckv1.PodSpecable{ + Spec: corev1.PodSpec{ + Containers: []corev1.Container{{ + Name: "blah", + Image: "busybox", + Env: []corev1.EnvVar{{ + Name: "K_SINK", + Value: sinkURI.String(), + }, { + Name: "K_CE_OVERRIDES", + Value: `{"extensions":{"foo":"bar"}}`, + }}, + }}, + }, + }, + }, + }, + }, { + name: "fix the URI", + in: &duckv1.WithPod{ + Spec: duckv1.WithPodSpec{ + Template: duckv1.PodSpecable{ + Spec: corev1.PodSpec{ + Containers: []corev1.Container{{ + Name: "blah", + Image: "busybox", + Env: []corev1.EnvVar{{ + Name: "K_SINK", + Value: "the wrong value", + }, { + Name: "K_CE_OVERRIDES", + Value: `{"extensions":{"wrong":"value"}}`, + }}, + }}, + }, + }, + }, + }, + want: &duckv1.WithPod{ + Spec: duckv1.WithPodSpec{ + Template: duckv1.PodSpecable{ + Spec: corev1.PodSpec{ + Containers: []corev1.Container{{ + Name: "blah", + Image: "busybox", + Env: []corev1.EnvVar{{ + Name: "K_SINK", + Value: sinkURI.String(), + }, { + Name: "K_CE_OVERRIDES", + Value: `{"extensions":{"foo":"bar"}}`, + }}, + }}, + }, + }, + }, + }, + }, { + name: "lots to add", + in: &duckv1.WithPod{ + Spec: duckv1.WithPodSpec{ + Template: duckv1.PodSpecable{ + Spec: corev1.PodSpec{ + InitContainers: []corev1.Container{{ + Name: "setup", + Image: "busybox", + }}, + Containers: []corev1.Container{{ + Name: "blah", + Image: "busybox", + Env: []corev1.EnvVar{{ + Name: "FOO", + Value: "BAR", + }, { + Name: "BAZ", + Value: "INGA", + }}, + }, { + Name: "sidecar", + Image: "busybox", + Env: []corev1.EnvVar{{ + Name: "BAZ", + Value: "INGA", + }}, + }}, + }, + }, + }, + }, + want: &duckv1.WithPod{ + Spec: duckv1.WithPodSpec{ + Template: duckv1.PodSpecable{ + Spec: corev1.PodSpec{ + InitContainers: []corev1.Container{{ + Name: "setup", + Image: "busybox", + Env: []corev1.EnvVar{{ + Name: "K_SINK", + Value: sinkURI.String(), + }, { + Name: "K_CE_OVERRIDES", + Value: `{"extensions":{"foo":"bar"}}`, + }}, + }}, + Containers: []corev1.Container{{ + Name: "blah", + Image: "busybox", + Env: []corev1.EnvVar{{ + Name: "FOO", + Value: "BAR", + }, { + Name: "BAZ", + Value: "INGA", + }, { + Name: "K_SINK", + Value: sinkURI.String(), + }, { + Name: "K_CE_OVERRIDES", + Value: `{"extensions":{"foo":"bar"}}`, + }}, + }, { + Name: "sidecar", + Image: "busybox", + Env: []corev1.EnvVar{{ + Name: "BAZ", + Value: "INGA", + }, { + Name: "K_SINK", + Value: sinkURI.String(), + }, { + Name: "K_CE_OVERRIDES", + Value: `{"extensions":{"foo":"bar"}}`, + }}, + }}, + }, + }, + }, + }, + }} + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + got := test.in + + ctx := WithSinkURI(context.Background(), sinkURI) + + sb := &SinkBinding{Spec: SinkBindingSpec{ + SourceSpec: duckv1.SourceSpec{ + CloudEventOverrides: &overrides, + }, + }} + sb.Do(ctx, got) + + if !cmp.Equal(got, test.want) { + t.Errorf("Undo (-want, +got): %s", cmp.Diff(test.want, got)) + } + }) + } +} + +func TestSinkBindingDoNoURI(t *testing.T) { + want := &duckv1.WithPod{ + Spec: duckv1.WithPodSpec{ + Template: duckv1.PodSpecable{ + Spec: corev1.PodSpec{ + Containers: []corev1.Container{{ + Name: "blah", + Image: "busybox", + Env: []corev1.EnvVar{}, + }}, + }, + }, + }, + } + got := &duckv1.WithPod{ + Spec: duckv1.WithPodSpec{ + Template: duckv1.PodSpecable{ + Spec: corev1.PodSpec{ + Containers: []corev1.Container{{ + Name: "blah", + Image: "busybox", + Env: []corev1.EnvVar{{ + Name: "K_SINK", + Value: "this should be removed", + }, { + Name: "K_CE_OVERRIDES", + Value: `{"extensions":{"tobe":"removed"}}`, + }}, + }}, + }, + }, + }, + } + + sb := &SinkBinding{} + sb.Do(context.Background(), got) + + if !cmp.Equal(got, want) { + t.Errorf("Undo (-want, +got): %s", cmp.Diff(want, got)) + } +} diff --git a/pkg/apis/sources/v1beta1/sinkbinding_types.go b/pkg/apis/sources/v1beta1/sinkbinding_types.go new file mode 100644 index 00000000000..ab45cea688c --- /dev/null +++ b/pkg/apis/sources/v1beta1/sinkbinding_types.go @@ -0,0 +1,101 @@ +/* +Copyright 2020 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1beta1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "knative.dev/pkg/apis" + duckv1 "knative.dev/pkg/apis/duck/v1" + duckv1alpha1 "knative.dev/pkg/apis/duck/v1alpha1" + "knative.dev/pkg/kmeta" +) + +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +k8s:defaulter-gen=true + +// SinkBinding describes a Binding that is also a Source. +// The `sink` (from the Source duck) is resolved to a URL and +// then projected into the `subject` by augmenting the runtime +// contract of the referenced containers to have a `K_SINK` +// environment variable holding the endpoint to which to send +// cloud events. +type SinkBinding struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec SinkBindingSpec `json:"spec"` + Status SinkBindingStatus `json:"status"` +} + +// Check the interfaces that SinkBinding should be implementing. +var ( + _ runtime.Object = (*SinkBinding)(nil) + _ kmeta.OwnerRefable = (*SinkBinding)(nil) + _ apis.Validatable = (*SinkBinding)(nil) + _ apis.Defaultable = (*SinkBinding)(nil) + _ apis.HasSpec = (*SinkBinding)(nil) + _ duckv1.KRShaped = (*SinkBinding)(nil) +) + +// SinkBindingSpec holds the desired state of the SinkBinding (from the client). +type SinkBindingSpec struct { + // inherits duck/v1 SourceSpec, which currently provides: + // * Sink - a reference to an object that will resolve to a domain name or + // a URI directly to use as the sink. + // * CloudEventOverrides - defines overrides to control the output format + // and modifications of the event sent to the sink. + duckv1.SourceSpec `json:",inline"` + + // inherits duck/v1alpha1 BindingSpec, which currently provides: + // * Subject - Subject references the resource(s) whose "runtime contract" + // should be augmented by Binding implementations. + duckv1alpha1.BindingSpec `json:",inline"` +} + +const ( + // SinkBindingConditionReady is configured to indicate whether the Binding + // has been configured for resources subject to its runtime contract. + SinkBindingConditionReady = apis.ConditionReady +) + +// SinkBindingStatus communicates the observed state of the SinkBinding (from the controller). +type SinkBindingStatus struct { + // inherits duck/v1 SourceStatus, which currently provides: + // * ObservedGeneration - the 'Generation' of the Service that was last + // processed by the controller. + // * Conditions - the latest available observations of a resource's current + // state. + // * SinkURI - the current active sink URI that has been configured for the + // Source. + duckv1.SourceStatus `json:",inline"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// SinkBindingList contains a list of SinkBinding +type SinkBindingList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []SinkBinding `json:"items"` +} + +// GetStatus retrieves the status of the SinkBinding. Implements the KRShaped interface. +func (s *SinkBinding) GetStatus() *duckv1.Status { + return &s.Status.Status +} diff --git a/pkg/apis/sources/v1beta1/sinkbinding_types_test.go b/pkg/apis/sources/v1beta1/sinkbinding_types_test.go new file mode 100644 index 00000000000..a30f7230815 --- /dev/null +++ b/pkg/apis/sources/v1beta1/sinkbinding_types_test.go @@ -0,0 +1,36 @@ +/* +Copyright 2020 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1beta1 + +import "testing" + +func TestSinkBinding_GetStatus(t *testing.T) { + r := &SinkBinding{ + Status: SinkBindingStatus{}, + } + if got, want := r.GetStatus(), &r.Status.Status; got != want { + t.Errorf("GetStatus=%v, want=%v", got, want) + } +} + +func TestSinkBinding_GetGroupVersionKind(t *testing.T) { + sb := SinkBinding{} + gvk := sb.GetGroupVersionKind() + if gvk.Kind != "SinkBinding" { + t.Errorf("Should be SinkBinding.") + } +} diff --git a/pkg/apis/sources/v1beta1/sinkbinding_validation.go b/pkg/apis/sources/v1beta1/sinkbinding_validation.go new file mode 100644 index 00000000000..a8447905c19 --- /dev/null +++ b/pkg/apis/sources/v1beta1/sinkbinding_validation.go @@ -0,0 +1,38 @@ +/* +Copyright 2020 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1beta1 + +import ( + "context" + + "knative.dev/pkg/apis" +) + +// Validate implements apis.Validatable +func (fb *SinkBinding) Validate(ctx context.Context) *apis.FieldError { + err := fb.Spec.Validate(ctx).ViaField("spec") + if fb.Spec.Subject.Namespace != "" && fb.Namespace != fb.Spec.Subject.Namespace { + err = err.Also(apis.ErrInvalidValue(fb.Spec.Subject.Namespace, "spec.subject.namespace")) + } + return err +} + +// Validate implements apis.Validatable +func (fbs *SinkBindingSpec) Validate(ctx context.Context) *apis.FieldError { + return fbs.Subject.Validate(ctx).ViaField("subject").Also( + fbs.Sink.Validate(ctx).ViaField("sink")) +} diff --git a/pkg/apis/sources/v1beta1/sinkbinding_validation_test.go b/pkg/apis/sources/v1beta1/sinkbinding_validation_test.go new file mode 100644 index 00000000000..ed8ca73e4f1 --- /dev/null +++ b/pkg/apis/sources/v1beta1/sinkbinding_validation_test.go @@ -0,0 +1,126 @@ +/* +Copyright 2020 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1beta1 + +import ( + "context" + "testing" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "knative.dev/pkg/apis" + duckv1 "knative.dev/pkg/apis/duck/v1" + duckv1alpha1 "knative.dev/pkg/apis/duck/v1alpha1" + "knative.dev/pkg/tracker" +) + +func TestSinkBindingValidation(t *testing.T) { + tests := []struct { + name string + in *SinkBinding + want *apis.FieldError + }{{ + name: "missing subject namespace", + in: &SinkBinding{ + ObjectMeta: metav1.ObjectMeta{ + Name: "matt", + Namespace: "moore", + }, + Spec: SinkBindingSpec{ + BindingSpec: duckv1alpha1.BindingSpec{ + Subject: tracker.Reference{ + APIVersion: "apps/v1", + Kind: "Deployment", + Name: "jeanne", + }, + }, + SourceSpec: duckv1.SourceSpec{ + Sink: duckv1.Destination{ + Ref: &duckv1.KReference{ + APIVersion: "serving.knative.dev/v1", + Kind: "Service", + Name: "gemma", + Namespace: "namespace", + }, + }, + }, + }, + }, + want: apis.ErrMissingField("spec.subject.namespace"), + }, { + name: "invalid subject namespace", + in: &SinkBinding{ + ObjectMeta: metav1.ObjectMeta{ + Name: "matt", + Namespace: "moore", + }, + Spec: SinkBindingSpec{ + BindingSpec: duckv1alpha1.BindingSpec{ + Subject: tracker.Reference{ + APIVersion: "apps/v1", + Kind: "Deployment", + Name: "jeanne", + Namespace: "lorefice", + }, + }, + SourceSpec: duckv1.SourceSpec{ + Sink: duckv1.Destination{ + Ref: &duckv1.KReference{ + APIVersion: "serving.knative.dev/v1", + Kind: "Service", + Name: "gemma", + Namespace: "namespace", + }, + }, + }, + }, + }, + want: apis.ErrInvalidValue("lorefice", "spec.subject.namespace"), + }, { + name: "missing sink information", + in: &SinkBinding{ + ObjectMeta: metav1.ObjectMeta{ + Name: "matt", + Namespace: "moore", + }, + Spec: SinkBindingSpec{ + BindingSpec: duckv1alpha1.BindingSpec{ + Subject: tracker.Reference{ + APIVersion: "apps/v1", + Kind: "Deployment", + Name: "jeanne", + Namespace: "moore", + }, + }, + SourceSpec: duckv1.SourceSpec{ + Sink: duckv1.Destination{}, + }, + }, + }, + want: apis.ErrGeneric("expected at least one, got none", "spec.sink.ref", "spec.sink.uri"), + }} + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + got := test.in.Validate(context.Background()) + if (test.want != nil) != (got != nil) { + t.Errorf("Validation() = %v, wanted %v", got, test.want) + } else if test.want != nil && test.want.Error() != got.Error() { + t.Errorf("Validation() = %v, wanted %v", got, test.want) + } + }) + } +} diff --git a/pkg/apis/sources/v1beta1/zz_generated.deepcopy.go b/pkg/apis/sources/v1beta1/zz_generated.deepcopy.go new file mode 100644 index 00000000000..9536de29c7e --- /dev/null +++ b/pkg/apis/sources/v1beta1/zz_generated.deepcopy.go @@ -0,0 +1,121 @@ +// +build !ignore_autogenerated + +/* +Copyright 2020 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by deepcopy-gen. DO NOT EDIT. + +package v1beta1 + +import ( + runtime "k8s.io/apimachinery/pkg/runtime" +) + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SinkBinding) DeepCopyInto(out *SinkBinding) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SinkBinding. +func (in *SinkBinding) DeepCopy() *SinkBinding { + if in == nil { + return nil + } + out := new(SinkBinding) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *SinkBinding) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SinkBindingList) DeepCopyInto(out *SinkBindingList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]SinkBinding, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SinkBindingList. +func (in *SinkBindingList) DeepCopy() *SinkBindingList { + if in == nil { + return nil + } + out := new(SinkBindingList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *SinkBindingList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SinkBindingSpec) DeepCopyInto(out *SinkBindingSpec) { + *out = *in + in.SourceSpec.DeepCopyInto(&out.SourceSpec) + in.BindingSpec.DeepCopyInto(&out.BindingSpec) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SinkBindingSpec. +func (in *SinkBindingSpec) DeepCopy() *SinkBindingSpec { + if in == nil { + return nil + } + out := new(SinkBindingSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SinkBindingStatus) DeepCopyInto(out *SinkBindingStatus) { + *out = *in + in.SourceStatus.DeepCopyInto(&out.SourceStatus) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SinkBindingStatus. +func (in *SinkBindingStatus) DeepCopy() *SinkBindingStatus { + if in == nil { + return nil + } + out := new(SinkBindingStatus) + in.DeepCopyInto(out) + return out +} diff --git a/pkg/client/clientset/versioned/clientset.go b/pkg/client/clientset/versioned/clientset.go index b69841c4ab2..578ed727b40 100644 --- a/pkg/client/clientset/versioned/clientset.go +++ b/pkg/client/clientset/versioned/clientset.go @@ -33,6 +33,7 @@ import ( messagingv1beta1 "knative.dev/eventing/pkg/client/clientset/versioned/typed/messaging/v1beta1" sourcesv1alpha1 "knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha1" sourcesv1alpha2 "knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha2" + sourcesv1beta1 "knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1beta1" ) type Interface interface { @@ -46,6 +47,7 @@ type Interface interface { MessagingV1() messagingv1.MessagingV1Interface SourcesV1alpha1() sourcesv1alpha1.SourcesV1alpha1Interface SourcesV1alpha2() sourcesv1alpha2.SourcesV1alpha2Interface + SourcesV1beta1() sourcesv1beta1.SourcesV1beta1Interface } // Clientset contains the clients for groups. Each group has exactly one @@ -61,6 +63,7 @@ type Clientset struct { messagingV1 *messagingv1.MessagingV1Client sourcesV1alpha1 *sourcesv1alpha1.SourcesV1alpha1Client sourcesV1alpha2 *sourcesv1alpha2.SourcesV1alpha2Client + sourcesV1beta1 *sourcesv1beta1.SourcesV1beta1Client } // ConfigsV1alpha1 retrieves the ConfigsV1alpha1Client @@ -108,6 +111,11 @@ func (c *Clientset) SourcesV1alpha2() sourcesv1alpha2.SourcesV1alpha2Interface { return c.sourcesV1alpha2 } +// SourcesV1beta1 retrieves the SourcesV1beta1Client +func (c *Clientset) SourcesV1beta1() sourcesv1beta1.SourcesV1beta1Interface { + return c.sourcesV1beta1 +} + // Discovery retrieves the DiscoveryClient func (c *Clientset) Discovery() discovery.DiscoveryInterface { if c == nil { @@ -165,6 +173,10 @@ func NewForConfig(c *rest.Config) (*Clientset, error) { if err != nil { return nil, err } + cs.sourcesV1beta1, err = sourcesv1beta1.NewForConfig(&configShallowCopy) + if err != nil { + return nil, err + } cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfig(&configShallowCopy) if err != nil { @@ -186,6 +198,7 @@ func NewForConfigOrDie(c *rest.Config) *Clientset { cs.messagingV1 = messagingv1.NewForConfigOrDie(c) cs.sourcesV1alpha1 = sourcesv1alpha1.NewForConfigOrDie(c) cs.sourcesV1alpha2 = sourcesv1alpha2.NewForConfigOrDie(c) + cs.sourcesV1beta1 = sourcesv1beta1.NewForConfigOrDie(c) cs.DiscoveryClient = discovery.NewDiscoveryClientForConfigOrDie(c) return &cs @@ -203,6 +216,7 @@ func New(c rest.Interface) *Clientset { cs.messagingV1 = messagingv1.New(c) cs.sourcesV1alpha1 = sourcesv1alpha1.New(c) cs.sourcesV1alpha2 = sourcesv1alpha2.New(c) + cs.sourcesV1beta1 = sourcesv1beta1.New(c) cs.DiscoveryClient = discovery.NewDiscoveryClient(c) return &cs diff --git a/pkg/client/clientset/versioned/fake/clientset_generated.go b/pkg/client/clientset/versioned/fake/clientset_generated.go index dd0fed242f3..9a337f5b3e1 100644 --- a/pkg/client/clientset/versioned/fake/clientset_generated.go +++ b/pkg/client/clientset/versioned/fake/clientset_generated.go @@ -43,6 +43,8 @@ import ( fakesourcesv1alpha1 "knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha1/fake" sourcesv1alpha2 "knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha2" fakesourcesv1alpha2 "knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha2/fake" + sourcesv1beta1 "knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1beta1" + fakesourcesv1beta1 "knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1beta1/fake" ) // NewSimpleClientset returns a clientset that will respond with the provided objects. @@ -136,3 +138,8 @@ func (c *Clientset) SourcesV1alpha1() sourcesv1alpha1.SourcesV1alpha1Interface { func (c *Clientset) SourcesV1alpha2() sourcesv1alpha2.SourcesV1alpha2Interface { return &fakesourcesv1alpha2.FakeSourcesV1alpha2{Fake: &c.Fake} } + +// SourcesV1beta1 retrieves the SourcesV1beta1Client +func (c *Clientset) SourcesV1beta1() sourcesv1beta1.SourcesV1beta1Interface { + return &fakesourcesv1beta1.FakeSourcesV1beta1{Fake: &c.Fake} +} diff --git a/pkg/client/clientset/versioned/fake/register.go b/pkg/client/clientset/versioned/fake/register.go index f2579b5b7e6..a750bf0aec8 100644 --- a/pkg/client/clientset/versioned/fake/register.go +++ b/pkg/client/clientset/versioned/fake/register.go @@ -33,6 +33,7 @@ import ( messagingv1beta1 "knative.dev/eventing/pkg/apis/messaging/v1beta1" sourcesv1alpha1 "knative.dev/eventing/pkg/apis/sources/v1alpha1" sourcesv1alpha2 "knative.dev/eventing/pkg/apis/sources/v1alpha2" + sourcesv1beta1 "knative.dev/eventing/pkg/apis/sources/v1beta1" ) var scheme = runtime.NewScheme() @@ -48,6 +49,7 @@ var localSchemeBuilder = runtime.SchemeBuilder{ messagingv1.AddToScheme, sourcesv1alpha1.AddToScheme, sourcesv1alpha2.AddToScheme, + sourcesv1beta1.AddToScheme, } // AddToScheme adds all types of this clientset into the given scheme. This allows composition diff --git a/pkg/client/clientset/versioned/scheme/register.go b/pkg/client/clientset/versioned/scheme/register.go index e055463a7d0..1927c9c1f80 100644 --- a/pkg/client/clientset/versioned/scheme/register.go +++ b/pkg/client/clientset/versioned/scheme/register.go @@ -33,6 +33,7 @@ import ( messagingv1beta1 "knative.dev/eventing/pkg/apis/messaging/v1beta1" sourcesv1alpha1 "knative.dev/eventing/pkg/apis/sources/v1alpha1" sourcesv1alpha2 "knative.dev/eventing/pkg/apis/sources/v1alpha2" + sourcesv1beta1 "knative.dev/eventing/pkg/apis/sources/v1beta1" ) var Scheme = runtime.NewScheme() @@ -48,6 +49,7 @@ var localSchemeBuilder = runtime.SchemeBuilder{ messagingv1.AddToScheme, sourcesv1alpha1.AddToScheme, sourcesv1alpha2.AddToScheme, + sourcesv1beta1.AddToScheme, } // AddToScheme adds all types of this clientset into the given scheme. This allows composition diff --git a/pkg/client/clientset/versioned/typed/sources/v1beta1/doc.go b/pkg/client/clientset/versioned/typed/sources/v1beta1/doc.go new file mode 100644 index 00000000000..b641cb37309 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/sources/v1beta1/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2020 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package v1beta1 diff --git a/pkg/client/clientset/versioned/typed/sources/v1beta1/fake/doc.go b/pkg/client/clientset/versioned/typed/sources/v1beta1/fake/doc.go new file mode 100644 index 00000000000..c7f6e65cab8 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/sources/v1beta1/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2020 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +// Package fake has the automatically generated clients. +package fake diff --git a/pkg/client/clientset/versioned/typed/sources/v1beta1/fake/fake_sinkbinding.go b/pkg/client/clientset/versioned/typed/sources/v1beta1/fake/fake_sinkbinding.go new file mode 100644 index 00000000000..1d5d81e9c42 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/sources/v1beta1/fake/fake_sinkbinding.go @@ -0,0 +1,140 @@ +/* +Copyright 2020 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + schema "k8s.io/apimachinery/pkg/runtime/schema" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" + v1beta1 "knative.dev/eventing/pkg/apis/sources/v1beta1" +) + +// FakeSinkBindings implements SinkBindingInterface +type FakeSinkBindings struct { + Fake *FakeSourcesV1beta1 + ns string +} + +var sinkbindingsResource = schema.GroupVersionResource{Group: "sources.knative.dev", Version: "v1beta1", Resource: "sinkbindings"} + +var sinkbindingsKind = schema.GroupVersionKind{Group: "sources.knative.dev", Version: "v1beta1", Kind: "SinkBinding"} + +// Get takes name of the sinkBinding, and returns the corresponding sinkBinding object, and an error if there is any. +func (c *FakeSinkBindings) Get(name string, options v1.GetOptions) (result *v1beta1.SinkBinding, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(sinkbindingsResource, c.ns, name), &v1beta1.SinkBinding{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.SinkBinding), err +} + +// List takes label and field selectors, and returns the list of SinkBindings that match those selectors. +func (c *FakeSinkBindings) List(opts v1.ListOptions) (result *v1beta1.SinkBindingList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(sinkbindingsResource, sinkbindingsKind, c.ns, opts), &v1beta1.SinkBindingList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1beta1.SinkBindingList{ListMeta: obj.(*v1beta1.SinkBindingList).ListMeta} + for _, item := range obj.(*v1beta1.SinkBindingList).Items { + if label.Matches(labels.Set(item.Labels)) { + list.Items = append(list.Items, item) + } + } + return list, err +} + +// Watch returns a watch.Interface that watches the requested sinkBindings. +func (c *FakeSinkBindings) Watch(opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(sinkbindingsResource, c.ns, opts)) + +} + +// Create takes the representation of a sinkBinding and creates it. Returns the server's representation of the sinkBinding, and an error, if there is any. +func (c *FakeSinkBindings) Create(sinkBinding *v1beta1.SinkBinding) (result *v1beta1.SinkBinding, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(sinkbindingsResource, c.ns, sinkBinding), &v1beta1.SinkBinding{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.SinkBinding), err +} + +// Update takes the representation of a sinkBinding and updates it. Returns the server's representation of the sinkBinding, and an error, if there is any. +func (c *FakeSinkBindings) Update(sinkBinding *v1beta1.SinkBinding) (result *v1beta1.SinkBinding, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(sinkbindingsResource, c.ns, sinkBinding), &v1beta1.SinkBinding{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.SinkBinding), err +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *FakeSinkBindings) UpdateStatus(sinkBinding *v1beta1.SinkBinding) (*v1beta1.SinkBinding, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(sinkbindingsResource, "status", c.ns, sinkBinding), &v1beta1.SinkBinding{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.SinkBinding), err +} + +// Delete takes name of the sinkBinding and deletes it. Returns an error if one occurs. +func (c *FakeSinkBindings) Delete(name string, options *v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(sinkbindingsResource, c.ns, name), &v1beta1.SinkBinding{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeSinkBindings) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(sinkbindingsResource, c.ns, listOptions) + + _, err := c.Fake.Invokes(action, &v1beta1.SinkBindingList{}) + return err +} + +// Patch applies the patch and returns the patched sinkBinding. +func (c *FakeSinkBindings) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.SinkBinding, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(sinkbindingsResource, c.ns, name, pt, data, subresources...), &v1beta1.SinkBinding{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.SinkBinding), err +} diff --git a/pkg/client/clientset/versioned/typed/sources/v1beta1/fake/fake_sources_client.go b/pkg/client/clientset/versioned/typed/sources/v1beta1/fake/fake_sources_client.go new file mode 100644 index 00000000000..d0e8689da8e --- /dev/null +++ b/pkg/client/clientset/versioned/typed/sources/v1beta1/fake/fake_sources_client.go @@ -0,0 +1,40 @@ +/* +Copyright 2020 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + rest "k8s.io/client-go/rest" + testing "k8s.io/client-go/testing" + v1beta1 "knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1beta1" +) + +type FakeSourcesV1beta1 struct { + *testing.Fake +} + +func (c *FakeSourcesV1beta1) SinkBindings(namespace string) v1beta1.SinkBindingInterface { + return &FakeSinkBindings{c, namespace} +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *FakeSourcesV1beta1) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret +} diff --git a/pkg/client/clientset/versioned/typed/sources/v1beta1/generated_expansion.go b/pkg/client/clientset/versioned/typed/sources/v1beta1/generated_expansion.go new file mode 100644 index 00000000000..f6a4b04ba21 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/sources/v1beta1/generated_expansion.go @@ -0,0 +1,21 @@ +/* +Copyright 2020 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package v1beta1 + +type SinkBindingExpansion interface{} diff --git a/pkg/client/clientset/versioned/typed/sources/v1beta1/sinkbinding.go b/pkg/client/clientset/versioned/typed/sources/v1beta1/sinkbinding.go new file mode 100644 index 00000000000..1a963ac0b9e --- /dev/null +++ b/pkg/client/clientset/versioned/typed/sources/v1beta1/sinkbinding.go @@ -0,0 +1,191 @@ +/* +Copyright 2020 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package v1beta1 + +import ( + "time" + + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + rest "k8s.io/client-go/rest" + v1beta1 "knative.dev/eventing/pkg/apis/sources/v1beta1" + scheme "knative.dev/eventing/pkg/client/clientset/versioned/scheme" +) + +// SinkBindingsGetter has a method to return a SinkBindingInterface. +// A group's client should implement this interface. +type SinkBindingsGetter interface { + SinkBindings(namespace string) SinkBindingInterface +} + +// SinkBindingInterface has methods to work with SinkBinding resources. +type SinkBindingInterface interface { + Create(*v1beta1.SinkBinding) (*v1beta1.SinkBinding, error) + Update(*v1beta1.SinkBinding) (*v1beta1.SinkBinding, error) + UpdateStatus(*v1beta1.SinkBinding) (*v1beta1.SinkBinding, error) + Delete(name string, options *v1.DeleteOptions) error + DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error + Get(name string, options v1.GetOptions) (*v1beta1.SinkBinding, error) + List(opts v1.ListOptions) (*v1beta1.SinkBindingList, error) + Watch(opts v1.ListOptions) (watch.Interface, error) + Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.SinkBinding, err error) + SinkBindingExpansion +} + +// sinkBindings implements SinkBindingInterface +type sinkBindings struct { + client rest.Interface + ns string +} + +// newSinkBindings returns a SinkBindings +func newSinkBindings(c *SourcesV1beta1Client, namespace string) *sinkBindings { + return &sinkBindings{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the sinkBinding, and returns the corresponding sinkBinding object, and an error if there is any. +func (c *sinkBindings) Get(name string, options v1.GetOptions) (result *v1beta1.SinkBinding, err error) { + result = &v1beta1.SinkBinding{} + err = c.client.Get(). + Namespace(c.ns). + Resource("sinkbindings"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of SinkBindings that match those selectors. +func (c *sinkBindings) List(opts v1.ListOptions) (result *v1beta1.SinkBindingList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1beta1.SinkBindingList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("sinkbindings"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested sinkBindings. +func (c *sinkBindings) Watch(opts v1.ListOptions) (watch.Interface, error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + opts.Watch = true + return c.client.Get(). + Namespace(c.ns). + Resource("sinkbindings"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch() +} + +// Create takes the representation of a sinkBinding and creates it. Returns the server's representation of the sinkBinding, and an error, if there is any. +func (c *sinkBindings) Create(sinkBinding *v1beta1.SinkBinding) (result *v1beta1.SinkBinding, err error) { + result = &v1beta1.SinkBinding{} + err = c.client.Post(). + Namespace(c.ns). + Resource("sinkbindings"). + Body(sinkBinding). + Do(). + Into(result) + return +} + +// Update takes the representation of a sinkBinding and updates it. Returns the server's representation of the sinkBinding, and an error, if there is any. +func (c *sinkBindings) Update(sinkBinding *v1beta1.SinkBinding) (result *v1beta1.SinkBinding, err error) { + result = &v1beta1.SinkBinding{} + err = c.client.Put(). + Namespace(c.ns). + Resource("sinkbindings"). + Name(sinkBinding.Name). + Body(sinkBinding). + Do(). + Into(result) + return +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). + +func (c *sinkBindings) UpdateStatus(sinkBinding *v1beta1.SinkBinding) (result *v1beta1.SinkBinding, err error) { + result = &v1beta1.SinkBinding{} + err = c.client.Put(). + Namespace(c.ns). + Resource("sinkbindings"). + Name(sinkBinding.Name). + SubResource("status"). + Body(sinkBinding). + Do(). + Into(result) + return +} + +// Delete takes name of the sinkBinding and deletes it. Returns an error if one occurs. +func (c *sinkBindings) Delete(name string, options *v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("sinkbindings"). + Name(name). + Body(options). + Do(). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *sinkBindings) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + var timeout time.Duration + if listOptions.TimeoutSeconds != nil { + timeout = time.Duration(*listOptions.TimeoutSeconds) * time.Second + } + return c.client.Delete(). + Namespace(c.ns). + Resource("sinkbindings"). + VersionedParams(&listOptions, scheme.ParameterCodec). + Timeout(timeout). + Body(options). + Do(). + Error() +} + +// Patch applies the patch and returns the patched sinkBinding. +func (c *sinkBindings) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.SinkBinding, err error) { + result = &v1beta1.SinkBinding{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("sinkbindings"). + SubResource(subresources...). + Name(name). + Body(data). + Do(). + Into(result) + return +} diff --git a/pkg/client/clientset/versioned/typed/sources/v1beta1/sources_client.go b/pkg/client/clientset/versioned/typed/sources/v1beta1/sources_client.go new file mode 100644 index 00000000000..0938a37c593 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/sources/v1beta1/sources_client.go @@ -0,0 +1,89 @@ +/* +Copyright 2020 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package v1beta1 + +import ( + rest "k8s.io/client-go/rest" + v1beta1 "knative.dev/eventing/pkg/apis/sources/v1beta1" + "knative.dev/eventing/pkg/client/clientset/versioned/scheme" +) + +type SourcesV1beta1Interface interface { + RESTClient() rest.Interface + SinkBindingsGetter +} + +// SourcesV1beta1Client is used to interact with features provided by the sources.knative.dev group. +type SourcesV1beta1Client struct { + restClient rest.Interface +} + +func (c *SourcesV1beta1Client) SinkBindings(namespace string) SinkBindingInterface { + return newSinkBindings(c, namespace) +} + +// NewForConfig creates a new SourcesV1beta1Client for the given config. +func NewForConfig(c *rest.Config) (*SourcesV1beta1Client, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + client, err := rest.RESTClientFor(&config) + if err != nil { + return nil, err + } + return &SourcesV1beta1Client{client}, nil +} + +// NewForConfigOrDie creates a new SourcesV1beta1Client for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *SourcesV1beta1Client { + client, err := NewForConfig(c) + if err != nil { + panic(err) + } + return client +} + +// New creates a new SourcesV1beta1Client for the given RESTClient. +func New(c rest.Interface) *SourcesV1beta1Client { + return &SourcesV1beta1Client{c} +} + +func setConfigDefaults(config *rest.Config) error { + gv := v1beta1.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = scheme.Codecs.WithoutConversion() + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } + + return nil +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *SourcesV1beta1Client) RESTClient() rest.Interface { + if c == nil { + return nil + } + return c.restClient +} diff --git a/pkg/client/informers/externalversions/generic.go b/pkg/client/informers/externalversions/generic.go index 029ac619b48..2491460511d 100644 --- a/pkg/client/informers/externalversions/generic.go +++ b/pkg/client/informers/externalversions/generic.go @@ -32,6 +32,7 @@ import ( messagingv1beta1 "knative.dev/eventing/pkg/apis/messaging/v1beta1" sourcesv1alpha1 "knative.dev/eventing/pkg/apis/sources/v1alpha1" v1alpha2 "knative.dev/eventing/pkg/apis/sources/v1alpha2" + sourcesv1beta1 "knative.dev/eventing/pkg/apis/sources/v1beta1" ) // GenericInformer is type of SharedIndexInformer which will locate and delegate to other @@ -124,6 +125,10 @@ func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource case v1alpha2.SchemeGroupVersion.WithResource("sinkbindings"): return &genericInformer{resource: resource.GroupResource(), informer: f.Sources().V1alpha2().SinkBindings().Informer()}, nil + // Group=sources.knative.dev, Version=v1beta1 + case sourcesv1beta1.SchemeGroupVersion.WithResource("sinkbindings"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Sources().V1beta1().SinkBindings().Informer()}, nil + } return nil, fmt.Errorf("no informer found for %v", resource) diff --git a/pkg/client/informers/externalversions/sources/interface.go b/pkg/client/informers/externalversions/sources/interface.go index 926705695cc..ee195923952 100644 --- a/pkg/client/informers/externalversions/sources/interface.go +++ b/pkg/client/informers/externalversions/sources/interface.go @@ -22,6 +22,7 @@ import ( internalinterfaces "knative.dev/eventing/pkg/client/informers/externalversions/internalinterfaces" v1alpha1 "knative.dev/eventing/pkg/client/informers/externalversions/sources/v1alpha1" v1alpha2 "knative.dev/eventing/pkg/client/informers/externalversions/sources/v1alpha2" + v1beta1 "knative.dev/eventing/pkg/client/informers/externalversions/sources/v1beta1" ) // Interface provides access to each of this group's versions. @@ -30,6 +31,8 @@ type Interface interface { V1alpha1() v1alpha1.Interface // V1alpha2 provides access to shared informers for resources in V1alpha2. V1alpha2() v1alpha2.Interface + // V1beta1 provides access to shared informers for resources in V1beta1. + V1beta1() v1beta1.Interface } type group struct { @@ -52,3 +55,8 @@ func (g *group) V1alpha1() v1alpha1.Interface { func (g *group) V1alpha2() v1alpha2.Interface { return v1alpha2.New(g.factory, g.namespace, g.tweakListOptions) } + +// V1beta1 returns a new v1beta1.Interface. +func (g *group) V1beta1() v1beta1.Interface { + return v1beta1.New(g.factory, g.namespace, g.tweakListOptions) +} diff --git a/pkg/client/informers/externalversions/sources/v1beta1/interface.go b/pkg/client/informers/externalversions/sources/v1beta1/interface.go new file mode 100644 index 00000000000..dca4c3c249c --- /dev/null +++ b/pkg/client/informers/externalversions/sources/v1beta1/interface.go @@ -0,0 +1,45 @@ +/* +Copyright 2020 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by informer-gen. DO NOT EDIT. + +package v1beta1 + +import ( + internalinterfaces "knative.dev/eventing/pkg/client/informers/externalversions/internalinterfaces" +) + +// Interface provides access to all the informers in this group version. +type Interface interface { + // SinkBindings returns a SinkBindingInformer. + SinkBindings() SinkBindingInformer +} + +type version struct { + factory internalinterfaces.SharedInformerFactory + namespace string + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// New returns a new Interface. +func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { + return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} +} + +// SinkBindings returns a SinkBindingInformer. +func (v *version) SinkBindings() SinkBindingInformer { + return &sinkBindingInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} diff --git a/pkg/client/informers/externalversions/sources/v1beta1/sinkbinding.go b/pkg/client/informers/externalversions/sources/v1beta1/sinkbinding.go new file mode 100644 index 00000000000..ea8045e373f --- /dev/null +++ b/pkg/client/informers/externalversions/sources/v1beta1/sinkbinding.go @@ -0,0 +1,89 @@ +/* +Copyright 2020 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by informer-gen. DO NOT EDIT. + +package v1beta1 + +import ( + time "time" + + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" + sourcesv1beta1 "knative.dev/eventing/pkg/apis/sources/v1beta1" + versioned "knative.dev/eventing/pkg/client/clientset/versioned" + internalinterfaces "knative.dev/eventing/pkg/client/informers/externalversions/internalinterfaces" + v1beta1 "knative.dev/eventing/pkg/client/listers/sources/v1beta1" +) + +// SinkBindingInformer provides access to a shared informer and lister for +// SinkBindings. +type SinkBindingInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1beta1.SinkBindingLister +} + +type sinkBindingInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewSinkBindingInformer constructs a new informer for SinkBinding type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewSinkBindingInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredSinkBindingInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredSinkBindingInformer constructs a new informer for SinkBinding type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredSinkBindingInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.SourcesV1beta1().SinkBindings(namespace).List(options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.SourcesV1beta1().SinkBindings(namespace).Watch(options) + }, + }, + &sourcesv1beta1.SinkBinding{}, + resyncPeriod, + indexers, + ) +} + +func (f *sinkBindingInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredSinkBindingInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *sinkBindingInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&sourcesv1beta1.SinkBinding{}, f.defaultInformer) +} + +func (f *sinkBindingInformer) Lister() v1beta1.SinkBindingLister { + return v1beta1.NewSinkBindingLister(f.Informer().GetIndexer()) +} diff --git a/pkg/client/injection/informers/sources/v1beta1/sinkbinding/fake/fake.go b/pkg/client/injection/informers/sources/v1beta1/sinkbinding/fake/fake.go new file mode 100644 index 00000000000..17ed97dad81 --- /dev/null +++ b/pkg/client/injection/informers/sources/v1beta1/sinkbinding/fake/fake.go @@ -0,0 +1,40 @@ +/* +Copyright 2020 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by injection-gen. DO NOT EDIT. + +package fake + +import ( + context "context" + + fake "knative.dev/eventing/pkg/client/injection/informers/factory/fake" + sinkbinding "knative.dev/eventing/pkg/client/injection/informers/sources/v1beta1/sinkbinding" + controller "knative.dev/pkg/controller" + injection "knative.dev/pkg/injection" +) + +var Get = sinkbinding.Get + +func init() { + injection.Fake.RegisterInformer(withInformer) +} + +func withInformer(ctx context.Context) (context.Context, controller.Informer) { + f := fake.Get(ctx) + inf := f.Sources().V1beta1().SinkBindings() + return context.WithValue(ctx, sinkbinding.Key{}, inf), inf.Informer() +} diff --git a/pkg/client/injection/informers/sources/v1beta1/sinkbinding/sinkbinding.go b/pkg/client/injection/informers/sources/v1beta1/sinkbinding/sinkbinding.go new file mode 100644 index 00000000000..af4c9411890 --- /dev/null +++ b/pkg/client/injection/informers/sources/v1beta1/sinkbinding/sinkbinding.go @@ -0,0 +1,52 @@ +/* +Copyright 2020 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by injection-gen. DO NOT EDIT. + +package sinkbinding + +import ( + context "context" + + v1beta1 "knative.dev/eventing/pkg/client/informers/externalversions/sources/v1beta1" + factory "knative.dev/eventing/pkg/client/injection/informers/factory" + controller "knative.dev/pkg/controller" + injection "knative.dev/pkg/injection" + logging "knative.dev/pkg/logging" +) + +func init() { + injection.Default.RegisterInformer(withInformer) +} + +// Key is used for associating the Informer inside the context.Context. +type Key struct{} + +func withInformer(ctx context.Context) (context.Context, controller.Informer) { + f := factory.Get(ctx) + inf := f.Sources().V1beta1().SinkBindings() + return context.WithValue(ctx, Key{}, inf), inf.Informer() +} + +// Get extracts the typed informer from the context. +func Get(ctx context.Context) v1beta1.SinkBindingInformer { + untyped := ctx.Value(Key{}) + if untyped == nil { + logging.FromContext(ctx).Panic( + "Unable to fetch knative.dev/eventing/pkg/client/informers/externalversions/sources/v1beta1.SinkBindingInformer from context.") + } + return untyped.(v1beta1.SinkBindingInformer) +} diff --git a/pkg/client/listers/sources/v1beta1/expansion_generated.go b/pkg/client/listers/sources/v1beta1/expansion_generated.go new file mode 100644 index 00000000000..6d37b88b8fd --- /dev/null +++ b/pkg/client/listers/sources/v1beta1/expansion_generated.go @@ -0,0 +1,27 @@ +/* +Copyright 2020 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by lister-gen. DO NOT EDIT. + +package v1beta1 + +// SinkBindingListerExpansion allows custom methods to be added to +// SinkBindingLister. +type SinkBindingListerExpansion interface{} + +// SinkBindingNamespaceListerExpansion allows custom methods to be added to +// SinkBindingNamespaceLister. +type SinkBindingNamespaceListerExpansion interface{} diff --git a/pkg/client/listers/sources/v1beta1/sinkbinding.go b/pkg/client/listers/sources/v1beta1/sinkbinding.go new file mode 100644 index 00000000000..61930ed2e7a --- /dev/null +++ b/pkg/client/listers/sources/v1beta1/sinkbinding.go @@ -0,0 +1,94 @@ +/* +Copyright 2020 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by lister-gen. DO NOT EDIT. + +package v1beta1 + +import ( + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" + v1beta1 "knative.dev/eventing/pkg/apis/sources/v1beta1" +) + +// SinkBindingLister helps list SinkBindings. +type SinkBindingLister interface { + // List lists all SinkBindings in the indexer. + List(selector labels.Selector) (ret []*v1beta1.SinkBinding, err error) + // SinkBindings returns an object that can list and get SinkBindings. + SinkBindings(namespace string) SinkBindingNamespaceLister + SinkBindingListerExpansion +} + +// sinkBindingLister implements the SinkBindingLister interface. +type sinkBindingLister struct { + indexer cache.Indexer +} + +// NewSinkBindingLister returns a new SinkBindingLister. +func NewSinkBindingLister(indexer cache.Indexer) SinkBindingLister { + return &sinkBindingLister{indexer: indexer} +} + +// List lists all SinkBindings in the indexer. +func (s *sinkBindingLister) List(selector labels.Selector) (ret []*v1beta1.SinkBinding, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1beta1.SinkBinding)) + }) + return ret, err +} + +// SinkBindings returns an object that can list and get SinkBindings. +func (s *sinkBindingLister) SinkBindings(namespace string) SinkBindingNamespaceLister { + return sinkBindingNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// SinkBindingNamespaceLister helps list and get SinkBindings. +type SinkBindingNamespaceLister interface { + // List lists all SinkBindings in the indexer for a given namespace. + List(selector labels.Selector) (ret []*v1beta1.SinkBinding, err error) + // Get retrieves the SinkBinding from the indexer for a given namespace and name. + Get(name string) (*v1beta1.SinkBinding, error) + SinkBindingNamespaceListerExpansion +} + +// sinkBindingNamespaceLister implements the SinkBindingNamespaceLister +// interface. +type sinkBindingNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all SinkBindings in the indexer for a given namespace. +func (s sinkBindingNamespaceLister) List(selector labels.Selector) (ret []*v1beta1.SinkBinding, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1beta1.SinkBinding)) + }) + return ret, err +} + +// Get retrieves the SinkBinding from the indexer for a given namespace and name. +func (s sinkBindingNamespaceLister) Get(name string) (*v1beta1.SinkBinding, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1beta1.Resource("sinkbinding"), name) + } + return obj.(*v1beta1.SinkBinding), nil +} From a41c8e7f17ed3a00dada6f908f0fd6517b37eb40 Mon Sep 17 00:00:00 2001 From: Nacho Cano Date: Mon, 13 Jul 2020 16:38:06 -0700 Subject: [PATCH 02/11] conversion/defaults --- cmd/webhook/main.go | 12 + config/core/resources/sinkbindings.yaml | 75 ++--- .../v1alpha2/sinkbinding_conversion.go | 33 ++- .../v1alpha2/sinkbinding_conversion_test.go | 269 +++++++++++++++++- 4 files changed, 347 insertions(+), 42 deletions(-) diff --git a/cmd/webhook/main.go b/cmd/webhook/main.go index 92488d9ab8d..076804bac0f 100644 --- a/cmd/webhook/main.go +++ b/cmd/webhook/main.go @@ -55,6 +55,7 @@ import ( "knative.dev/eventing/pkg/apis/sources" sourcesv1alpha1 "knative.dev/eventing/pkg/apis/sources/v1alpha1" sourcesv1alpha2 "knative.dev/eventing/pkg/apis/sources/v1alpha2" + sourcesv1beta1 "knative.dev/eventing/pkg/apis/sources/v1beta1" "knative.dev/eventing/pkg/leaderelection" "knative.dev/eventing/pkg/logconfig" "knative.dev/eventing/pkg/reconciler/sinkbinding" @@ -90,6 +91,8 @@ var ourTypes = map[schema.GroupVersionKind]resourcesemantics.GenericCRD{ sourcesv1alpha2.SchemeGroupVersion.WithKind("PingSource"): &sourcesv1alpha2.PingSource{}, sourcesv1alpha2.SchemeGroupVersion.WithKind("SinkBinding"): &sourcesv1alpha2.SinkBinding{}, sourcesv1alpha2.SchemeGroupVersion.WithKind("ContainerSource"): &sourcesv1alpha2.ContainerSource{}, + // v1beta1 + sourcesv1beta1.SchemeGroupVersion.WithKind("SinkBinding"): &sourcesv1beta1.SinkBinding{}, // For group flows.knative.dev // v1beta1 @@ -235,6 +238,7 @@ func NewConversionController(ctx context.Context, cmw configmap.Watcher) *contro flowsv1_ = flowsv1.SchemeGroupVersion.Version sourcesv1alpha1_ = sourcesv1alpha1.SchemeGroupVersion.Version sourcesv1alpha2_ = sourcesv1alpha2.SchemeGroupVersion.Version + sourcesv1beta1_ = sourcesv1beta1.SchemeGroupVersion.Version ) return conversion.NewConversionController(ctx, @@ -330,6 +334,14 @@ func NewConversionController(ctx context.Context, cmw configmap.Watcher) *contro sourcesv1alpha2_: &sourcesv1alpha2.SinkBinding{}, }, }, + sourcesv1beta1.Kind("SinkBinding"): { + DefinitionName: sources.SinkBindingResource.String(), + HubVersion: sourcesv1alpha2_, + Zygotes: map[string]conversion.ConvertibleObject{ + sourcesv1alpha2_: &sourcesv1alpha2.SinkBinding{}, + sourcesv1beta1_: &sourcesv1beta1.SinkBinding{}, + }, + }, }, // A function that infuses the context passed to ConvertTo/ConvertFrom/SetDefaults with custom metadata. diff --git a/config/core/resources/sinkbindings.yaml b/config/core/resources/sinkbindings.yaml index 85d3cee0bde..c714ae5a544 100644 --- a/config/core/resources/sinkbindings.yaml +++ b/config/core/resources/sinkbindings.yaml @@ -25,43 +25,48 @@ metadata: spec: group: sources.knative.dev versions: - - &version - name: v1alpha1 - served: true - storage: true - subresources: - status: {} - schema: - openAPIV3Schema: - type: object - # this is a work around so we don't need to flush out the - # schema for each version at this time - # - # see issue: https://github.com/knative/serving/issues/912 - x-kubernetes-preserve-unknown-fields: true - additionalPrinterColumns: - - name: Ready - type: string - jsonPath: ".status.conditions[?(@.type=='Ready')].status" - - name: Reason - type: string - jsonPath: ".status.conditions[?(@.type=='Ready')].reason" - - name: Sink - type: string - jsonPath: ".status.sinkUri" - - name: Age - type: date - jsonPath: .metadata.creationTimestamp - - << : *version - name: v1alpha2 - storage: false + - &version + name: v1alpha1 + served: true + storage: true + subresources: + status: {} + schema: + openAPIV3Schema: + type: object + # this is a work around so we don't need to flush out the + # schema for each version at this time + # + # see issue: https://github.com/knative/serving/issues/912 + x-kubernetes-preserve-unknown-fields: true + additionalPrinterColumns: + - name: Ready + type: string + jsonPath: ".status.conditions[?(@.type=='Ready')].status" + - name: Reason + type: string + jsonPath: ".status.conditions[?(@.type=='Ready')].reason" + - name: Sink + type: string + jsonPath: ".status.sinkUri" + - name: Age + type: date + jsonPath: .metadata.creationTimestamp + - <<: *version + name: v1alpha2 + served: true + storage: false + - <<: *version + name: v1beta1 + served: true + storage: false names: categories: - - all - - knative - - eventing - - sources - - bindings + - all + - knative + - eventing + - sources + - bindings kind: SinkBinding plural: sinkbindings scope: Namespaced diff --git a/pkg/apis/sources/v1alpha2/sinkbinding_conversion.go b/pkg/apis/sources/v1alpha2/sinkbinding_conversion.go index 15c63b46312..383debbc252 100644 --- a/pkg/apis/sources/v1alpha2/sinkbinding_conversion.go +++ b/pkg/apis/sources/v1alpha2/sinkbinding_conversion.go @@ -20,15 +20,36 @@ import ( "context" "fmt" + "knative.dev/eventing/pkg/apis/sources/v1beta1" "knative.dev/pkg/apis" ) -// ConvertTo implements apis.Convertible -func (source *SinkBinding) ConvertTo(ctx context.Context, sink apis.Convertible) error { - return fmt.Errorf("v1alpha2 is the highest known version, got: %T", sink) +// ConvertTo implements apis.Convertible. +// Converts source (from v1alpha2.SinkBinding) into v1beta1.SinkBinding. +func (source *SinkBinding) ConvertTo(ctx context.Context, obj apis.Convertible) error { + switch sink := obj.(type) { + case *v1beta1.SinkBinding: + sink.ObjectMeta = source.ObjectMeta + sink.Spec.SourceSpec = source.Spec.SourceSpec + sink.Spec.BindingSpec = source.Spec.BindingSpec + sink.Status.SourceStatus = source.Status.SourceStatus + return nil + default: + return fmt.Errorf("Unknown conversion, got: %T", sink) + } } -// ConvertFrom implements apis.Convertible -func (sink *SinkBinding) ConvertFrom(ctx context.Context, source apis.Convertible) error { - return fmt.Errorf("v1alpha2 is the highest known version, got: %T", source) +// ConvertFrom implements apis.Convertible. +// Converts obj from v1beta1.SinkBinding into v1alpha2.SinkBinding. +func (sink *SinkBinding) ConvertFrom(ctx context.Context, obj apis.Convertible) error { + switch source := obj.(type) { + case *v1beta1.SinkBinding: + sink.ObjectMeta = source.ObjectMeta + sink.Spec.SourceSpec = source.Spec.SourceSpec + sink.Spec.BindingSpec = source.Spec.BindingSpec + sink.Status.SourceStatus = source.Status.SourceStatus + return nil + default: + return fmt.Errorf("Unknown conversion, got: %T", source) + } } diff --git a/pkg/apis/sources/v1alpha2/sinkbinding_conversion_test.go b/pkg/apis/sources/v1alpha2/sinkbinding_conversion_test.go index 410f50e1778..f34e57c2b89 100644 --- a/pkg/apis/sources/v1alpha2/sinkbinding_conversion_test.go +++ b/pkg/apis/sources/v1alpha2/sinkbinding_conversion_test.go @@ -18,11 +18,32 @@ package v1alpha2 import ( "context" + "errors" + "reflect" "testing" + + "knative.dev/pkg/tracker" + + "github.com/google/go-cmp/cmp" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "knative.dev/eventing/pkg/apis/sources/v1beta1" + "knative.dev/pkg/apis" + duckv1 "knative.dev/pkg/apis/duck/v1" + duckv1alpha1 "knative.dev/pkg/apis/duck/v1alpha1" ) +type dummy struct{} + +func (*dummy) ConvertTo(ctx context.Context, obj apis.Convertible) error { + return errors.New("Won't go") +} + +func (*dummy) ConvertFrom(ctx context.Context, obj apis.Convertible) error { + return errors.New("Won't go") +} + func TestSinkBindingConversionBadType(t *testing.T) { - good, bad := &SinkBinding{}, &SinkBinding{} + good, bad := &SinkBinding{}, &dummy{} if err := good.ConvertTo(context.Background(), bad); err == nil { t.Errorf("ConvertTo() = %#v, wanted error", bad) @@ -32,3 +53,249 @@ func TestSinkBindingConversionBadType(t *testing.T) { t.Errorf("ConvertFrom() = %#v, wanted error", good) } } + +func TestSinkBindingConversionRoundTripUp(t *testing.T) { + // Just one for now, just adding the for loop for ease of future changes. + versions := []apis.Convertible{&v1beta1.SinkBinding{}} + + path, _ := apis.ParseURL("/path") + sink := duckv1.Destination{ + Ref: &duckv1.KReference{ + Kind: "Foo", + Namespace: "Bar", + Name: "Baz", + APIVersion: "Baf", + }, + URI: path, + } + sinkUri, _ := apis.ParseURL("http://example.com/path") + + subject := tracker.Reference{ + APIVersion: "API", + Kind: "K", + Namespace: "NS", + Name: "N", + } + + tests := []struct { + name string + in *SinkBinding + }{{name: "empty", + in: &SinkBinding{ + ObjectMeta: metav1.ObjectMeta{ + Name: "ping-name", + Namespace: "ping-ns", + Generation: 17, + }, + Spec: SinkBindingSpec{}, + Status: SinkBindingStatus{ + SourceStatus: duckv1.SourceStatus{ + Status: duckv1.Status{ + ObservedGeneration: 1, + Conditions: duckv1.Conditions{{ + Type: "Ready", + Status: "True", + }}, + }, + }, + }, + }, + }, {name: "simple configuration", + in: &SinkBinding{ + ObjectMeta: metav1.ObjectMeta{ + Name: "ping-name", + Namespace: "ping-ns", + Generation: 17, + }, + Spec: SinkBindingSpec{ + SourceSpec: duckv1.SourceSpec{ + Sink: sink, + }, + BindingSpec: duckv1alpha1.BindingSpec{ + Subject: subject, + }, + }, + Status: SinkBindingStatus{ + SourceStatus: duckv1.SourceStatus{ + Status: duckv1.Status{ + ObservedGeneration: 1, + Conditions: duckv1.Conditions{{ + Type: "Ready", + Status: "Unknown", + }}, + }, + SinkURI: sinkUri, + }, + }, + }, + }, {name: "full", + in: &SinkBinding{ + ObjectMeta: metav1.ObjectMeta{ + Name: "ping-name", + Namespace: "ping-ns", + Generation: 17, + }, + Spec: SinkBindingSpec{ + SourceSpec: duckv1.SourceSpec{ + Sink: sink, + CloudEventOverrides: &duckv1.CloudEventOverrides{ + Extensions: map[string]string{ + "foo": "bar", + "baz": "baf", + }, + }, + }, + BindingSpec: duckv1alpha1.BindingSpec{ + Subject: subject, + }, + }, + Status: SinkBindingStatus{ + SourceStatus: duckv1.SourceStatus{ + Status: duckv1.Status{ + ObservedGeneration: 1, + Conditions: duckv1.Conditions{{ + Type: "Ready", + Status: "True", + }}, + }, + SinkURI: sinkUri, + }, + }, + }, + }} + for _, test := range tests { + for _, version := range versions { + t.Run(test.name, func(t *testing.T) { + ver := version + if err := test.in.ConvertTo(context.Background(), ver); err != nil { + t.Errorf("ConvertTo() = %v", err) + } + + got := &SinkBinding{} + + if err := got.ConvertFrom(context.Background(), ver); err != nil { + t.Errorf("ConvertFrom() = %v", err) + } + if diff := cmp.Diff(test.in, got); diff != "" { + t.Errorf("roundtrip (-want, +got) = %v", diff) + } + }) + } + } +} + +// This tests round tripping from a higher version -> v1alpha2 and back to the higher version. +func TestSinkBindingConversionRoundTripDown(t *testing.T) { + // Just one for now, just adding the for loop for ease of future changes. + + path, _ := apis.ParseURL("/path") + sink := duckv1.Destination{ + Ref: &duckv1.KReference{ + Kind: "Foo", + Namespace: "Bar", + Name: "Baz", + APIVersion: "Baf", + }, + URI: path, + } + sinkURI, _ := apis.ParseURL("http://example.com/path") + + ceOverrides := duckv1.CloudEventOverrides{ + Extensions: map[string]string{ + "foo": "bar", + "baz": "baf", + }, + } + + subject := tracker.Reference{ + APIVersion: "API", + Kind: "K", + Namespace: "NS", + Name: "N", + } + + tests := []struct { + name string + in apis.Convertible + }{{name: "empty", + in: &v1beta1.SinkBinding{ + ObjectMeta: metav1.ObjectMeta{ + Name: "ping-name", + Namespace: "ping-ns", + Generation: 17, + }, + Spec: v1beta1.SinkBindingSpec{}, + Status: v1beta1.SinkBindingStatus{}, + }, + }, {name: "simple configuration", + in: &v1beta1.SinkBinding{ + ObjectMeta: metav1.ObjectMeta{ + Name: "ping-name", + Namespace: "ping-ns", + Generation: 17, + }, + Spec: v1beta1.SinkBindingSpec{ + SourceSpec: duckv1.SourceSpec{ + Sink: sink, + }, + }, + Status: v1beta1.SinkBindingStatus{ + SourceStatus: duckv1.SourceStatus{ + Status: duckv1.Status{ + ObservedGeneration: 1, + Conditions: duckv1.Conditions{{ + Type: "Ready", + Status: "True", + }}, + }, + SinkURI: sinkURI, + }, + }, + }, + }, {name: "full", + in: &v1beta1.SinkBinding{ + ObjectMeta: metav1.ObjectMeta{ + Name: "ping-name", + Namespace: "ping-ns", + Generation: 17, + }, + Spec: v1beta1.SinkBindingSpec{ + SourceSpec: duckv1.SourceSpec{ + Sink: sink, + CloudEventOverrides: &ceOverrides, + }, + BindingSpec: duckv1alpha1.BindingSpec{Subject: subject}, + }, + Status: v1beta1.SinkBindingStatus{ + SourceStatus: duckv1.SourceStatus{ + Status: duckv1.Status{ + ObservedGeneration: 1, + Conditions: duckv1.Conditions{{ + Type: "Ready", + Status: "True", + }}, + }, + SinkURI: sinkURI, + }, + }, + }, + }} + for _, test := range tests { + + t.Run(test.name, func(t *testing.T) { + down := &SinkBinding{} + if err := down.ConvertFrom(context.Background(), test.in); err != nil { + t.Errorf("ConvertTo() = %v", err) + } + + got := (reflect.New(reflect.TypeOf(test.in).Elem()).Interface()).(apis.Convertible) + + if err := down.ConvertTo(context.Background(), got); err != nil { + t.Errorf("ConvertFrom() = %v", err) + } + if diff := cmp.Diff(test.in, got); diff != "" { + t.Errorf("roundtrip (-want, +got) = %v", diff) + } + }) + } +} From ced4fc9ecb428c952c6dc1310c62e8fd6fdb8788 Mon Sep 17 00:00:00 2001 From: Nacho Cano Date: Mon, 13 Jul 2020 17:02:11 -0700 Subject: [PATCH 03/11] storage version, reconciler, e2e test --- config/core/resources/sinkbindings.yaml | 4 +- pkg/reconciler/sinkbinding/controller.go | 10 +- pkg/reconciler/testing/sinkbinding.go | 40 ++++ test/e2e/source_sinkbinding_v1beta1_test.go | 211 ++++++++++++++++++++ test/lib/creation.go | 15 +- 5 files changed, 271 insertions(+), 9 deletions(-) create mode 100644 test/e2e/source_sinkbinding_v1beta1_test.go diff --git a/config/core/resources/sinkbindings.yaml b/config/core/resources/sinkbindings.yaml index c714ae5a544..69fbeaf66d5 100644 --- a/config/core/resources/sinkbindings.yaml +++ b/config/core/resources/sinkbindings.yaml @@ -28,7 +28,7 @@ spec: - &version name: v1alpha1 served: true - storage: true + storage: false subresources: status: {} schema: @@ -59,7 +59,7 @@ spec: - <<: *version name: v1beta1 served: true - storage: false + storage: true names: categories: - all diff --git a/pkg/reconciler/sinkbinding/controller.go b/pkg/reconciler/sinkbinding/controller.go index ec71355734d..bbf9e6ee134 100644 --- a/pkg/reconciler/sinkbinding/controller.go +++ b/pkg/reconciler/sinkbinding/controller.go @@ -19,7 +19,7 @@ package sinkbinding import ( "context" - sbinformer "knative.dev/eventing/pkg/client/injection/informers/sources/v1alpha1/sinkbinding" + sbinformer "knative.dev/eventing/pkg/client/injection/informers/sources/v1beta1/sinkbinding" "knative.dev/pkg/client/injection/ducks/duck/v1/podspecable" "knative.dev/pkg/client/injection/kube/informers/core/v1/namespace" "knative.dev/pkg/reconciler" @@ -31,7 +31,7 @@ import ( "k8s.io/client-go/kubernetes/scheme" "k8s.io/client-go/tools/cache" "k8s.io/client-go/tools/record" - "knative.dev/eventing/pkg/apis/sources/v1alpha1" + "knative.dev/eventing/pkg/apis/sources/v1beta1" "knative.dev/pkg/apis/duck" "knative.dev/pkg/configmap" "knative.dev/pkg/controller" @@ -73,7 +73,7 @@ func NewController( return nil }, }, - GVR: v1alpha1.SchemeGroupVersion.WithResource("sinkbindings"), + GVR: v1beta1.SchemeGroupVersion.WithResource("sinkbindings"), Get: func(namespace string, name string) (psbinding.Bindable, error) { return sbInformer.Lister().SinkBindings(namespace).Get(name) }, @@ -125,12 +125,12 @@ func WithContextFactory(ctx context.Context, handler func(types.NamespacedName)) r := resolver.NewURIResolver(ctx, handler) return func(ctx context.Context, b psbinding.Bindable) (context.Context, error) { - sb := b.(*v1alpha1.SinkBinding) + sb := b.(*v1beta1.SinkBinding) uri, err := r.URIFromDestinationV1(sb.Spec.Sink, sb) if err != nil { return nil, err } sb.Status.SinkURI = uri - return v1alpha1.WithSinkURI(ctx, sb.Status.SinkURI), nil + return v1beta1.WithSinkURI(ctx, sb.Status.SinkURI), nil } } diff --git a/pkg/reconciler/testing/sinkbinding.go b/pkg/reconciler/testing/sinkbinding.go index 6743de2e181..4b14b62a860 100644 --- a/pkg/reconciler/testing/sinkbinding.go +++ b/pkg/reconciler/testing/sinkbinding.go @@ -21,6 +21,7 @@ import ( sourcesv1alpha1 "knative.dev/eventing/pkg/apis/sources/v1alpha1" sourcesv1alpha2 "knative.dev/eventing/pkg/apis/sources/v1alpha2" + sourcesv1beta1 "knative.dev/eventing/pkg/apis/sources/v1beta1" duckv1 "knative.dev/pkg/apis/duck/v1" "knative.dev/pkg/tracker" ) @@ -31,6 +32,9 @@ type SinkBindingV1Alpha1Option func(*sourcesv1alpha1.SinkBinding) // SinkBindingV1Alpha2Option enables further configuration of a SinkBinding. type SinkBindingV1Alpha2Option func(*sourcesv1alpha2.SinkBinding) +// SinkBindingV1Beta1Option enables further configuration of a SinkBinding. +type SinkBindingV1Beta1Option func(*sourcesv1beta1.SinkBinding) + // NewSinkBindingV1Alpha1 creates a SinkBinding with SinkBindingOptions func NewSinkBindingV1Alpha1(name, namespace string, o ...SinkBindingV1Alpha1Option) *sourcesv1alpha1.SinkBinding { c := &sourcesv1alpha1.SinkBinding{ @@ -61,6 +65,21 @@ func NewSinkBindingV1Alpha2(name, namespace string, o ...SinkBindingV1Alpha2Opti return c } +// NewSinkBindingV1Beta1 creates a SinkBinding with SinkBindingOptions +func NewSinkBindingV1Beta1(name, namespace string, o ...SinkBindingV1Beta1Option) *sourcesv1beta1.SinkBinding { + c := &sourcesv1beta1.SinkBinding{ + ObjectMeta: metav1.ObjectMeta{ + Name: name, + Namespace: namespace, + }, + } + for _, opt := range o { + opt(c) + } + //c.SetDefaults(context.Background()) // TODO: We should add defaults and validation. + return c +} + // WithSubjectV1A1 assigns the subject of the SinkBinding. func WithSubjectV1A1(subject tracker.Reference) SinkBindingV1Alpha1Option { return func(sb *sourcesv1alpha1.SinkBinding) { @@ -102,3 +121,24 @@ func WithCloudEventOverridesV1A2(overrides duckv1.CloudEventOverrides) SinkBindi sb.Spec.CloudEventOverrides = &overrides } } + +// WithSubjectV1B1 assigns the subject of the SinkBinding. +func WithSubjectV1B1(subject tracker.Reference) SinkBindingV1Beta1Option { + return func(sb *sourcesv1beta1.SinkBinding) { + sb.Spec.Subject = subject + } +} + +// WithSinkV1B1 assigns the sink of the SinkBinding. +func WithSinkV1B1(sink duckv1.Destination) SinkBindingV1Beta1Option { + return func(sb *sourcesv1beta1.SinkBinding) { + sb.Spec.Sink = sink + } +} + +// WithCloudEventOverridesV1B1 assigns the CloudEventsOverrides of the SinkBinding. +func WithCloudEventOverridesV1B1(overrides duckv1.CloudEventOverrides) SinkBindingV1Beta1Option { + return func(sb *sourcesv1beta1.SinkBinding) { + sb.Spec.CloudEventOverrides = &overrides + } +} diff --git a/test/e2e/source_sinkbinding_v1beta1_test.go b/test/e2e/source_sinkbinding_v1beta1_test.go new file mode 100644 index 00000000000..ad2d8d4fb4d --- /dev/null +++ b/test/e2e/source_sinkbinding_v1beta1_test.go @@ -0,0 +1,211 @@ +// +build e2e + +/* +Copyright 2020 The Knative Authors +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package e2e + +import ( + "fmt" + "testing" + + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/util/uuid" + + . "github.com/cloudevents/sdk-go/v2/test" + appsv1 "k8s.io/api/apps/v1" + batchv1 "k8s.io/api/batch/v1" + batchv1beta1 "k8s.io/api/batch/v1beta1" + duckv1 "knative.dev/pkg/apis/duck/v1" + pkgTest "knative.dev/pkg/test" + "knative.dev/pkg/tracker" + + "knative.dev/eventing/test/lib/recordevents" + "knative.dev/eventing/test/lib/resources" + + eventingtesting "knative.dev/eventing/pkg/reconciler/testing" +) + +func TestSinkBindingV1Beta1Deployment(t *testing.T) { + const ( + sinkBindingName = "e2e-sink-binding" + deploymentName = "e2e-sink-binding-deployment" + // the heartbeats image is built from test_images/heartbeats + imageName = "heartbeats" + + recordEventPodName = "e2e-sink-binding-recordevent-pod-v1beta1dep" + ) + + client := setup(t, true) + defer tearDown(client) + + // create event logger pod and service + eventTracker, _ := recordevents.StartEventRecordOrFail(client, recordEventPodName) + defer eventTracker.Cleanup() + + extensionSecret := string(uuid.NewUUID()) + + // create sink binding + sinkBinding := eventingtesting.NewSinkBindingV1Beta1( + sinkBindingName, + client.Namespace, + eventingtesting.WithSinkV1B1(duckv1.Destination{Ref: resources.KnativeRefForService(recordEventPodName, client.Namespace)}), + eventingtesting.WithSubjectV1B1(tracker.Reference{ + APIVersion: "apps/v1", + Kind: "Deployment", + Namespace: client.Namespace, + Name: deploymentName, + }), + eventingtesting.WithCloudEventOverridesV1B1(duckv1.CloudEventOverrides{Extensions: map[string]string{ + "sinkbinding": extensionSecret, + }}), + ) + client.CreateSinkBindingV1Beta1OrFail(sinkBinding) + + message := fmt.Sprintf("TestSinkBindingDeployment%s", uuid.NewUUID()) + client.CreateDeploymentOrFail(&appsv1.Deployment{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: client.Namespace, + Name: deploymentName, + }, + Spec: appsv1.DeploymentSpec{ + Selector: &metav1.LabelSelector{ + MatchLabels: map[string]string{ + "foo": "bar", + }, + }, + Template: corev1.PodTemplateSpec{ + ObjectMeta: metav1.ObjectMeta{ + Labels: map[string]string{ + "foo": "bar", + }, + }, + Spec: corev1.PodSpec{ + Containers: []corev1.Container{{ + Name: imageName, + Image: pkgTest.ImagePath(imageName), + ImagePullPolicy: corev1.PullAlways, + Args: []string{"--msg=" + message}, + Env: []corev1.EnvVar{{ + Name: "POD_NAME", + Value: deploymentName, + }, { + Name: "POD_NAMESPACE", + Value: client.Namespace, + }}, + }}, + }, + }, + }, + }) + + // wait for all test resources to be ready + client.WaitForAllTestResourcesReadyOrFail() + + // Look for events with expected data, and sinkbinding extension + eventTracker.AssertAtLeast(2, recordevents.MatchEvent( + recordevents.MatchHeartBeatsImageMessage(message), + HasSource(fmt.Sprintf("https://knative.dev/eventing/test/heartbeats/#%s/%s", client.Namespace, deploymentName)), + HasExtension("sinkbinding", extensionSecret), + )) +} + +func TestSinkBindingV1Beta1CronJob(t *testing.T) { + const ( + sinkBindingName = "e2e-sink-binding" + deploymentName = "e2e-sink-binding-cronjob" + // the heartbeats image is built from test_images/heartbeats + imageName = "heartbeats" + + recordEventPodName = "e2e-sink-binding-recordevent-pod-v1beta1c" + ) + + client := setup(t, true) + defer tearDown(client) + + // create event logger pod and service + eventTracker, _ := recordevents.StartEventRecordOrFail(client, recordEventPodName) + defer eventTracker.Cleanup() + + // create sink binding + sinkBinding := eventingtesting.NewSinkBindingV1Beta1( + sinkBindingName, + client.Namespace, + eventingtesting.WithSinkV1B1(duckv1.Destination{Ref: resources.KnativeRefForService(recordEventPodName, client.Namespace)}), + eventingtesting.WithSubjectV1B1(tracker.Reference{ + APIVersion: "batch/v1", + Kind: "Job", + Namespace: client.Namespace, + Selector: &metav1.LabelSelector{ + MatchLabels: map[string]string{ + "foo": "bar", + }, + }, + }), + ) + client.CreateSinkBindingV1Beta1OrFail(sinkBinding) + + message := fmt.Sprintf("TestSinkBindingCronJob%s", uuid.NewUUID()) + client.CreateCronJobOrFail(&batchv1beta1.CronJob{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: client.Namespace, + Name: deploymentName, + }, + Spec: batchv1beta1.CronJobSpec{ + Schedule: "* * * * *", + JobTemplate: batchv1beta1.JobTemplateSpec{ + ObjectMeta: metav1.ObjectMeta{ + Labels: map[string]string{ + "foo": "bar", + }, + }, + Spec: batchv1.JobSpec{ + Template: corev1.PodTemplateSpec{ + Spec: corev1.PodSpec{ + RestartPolicy: corev1.RestartPolicyNever, + Containers: []corev1.Container{{ + Name: imageName, + Image: pkgTest.ImagePath(imageName), + ImagePullPolicy: corev1.PullAlways, + Args: []string{"--msg=" + message}, + Env: []corev1.EnvVar{{ + Name: "ONE_SHOT", + Value: "true", + }, { + Name: "POD_NAME", + Value: deploymentName, + }, { + Name: "POD_NAMESPACE", + Value: client.Namespace, + }}, + }}, + }, + }, + }, + }, + }, + }) + + // wait for all test resources to be ready + client.WaitForAllTestResourcesReadyOrFail() + + // verify the logger service receives the event + eventTracker.AssertAtLeast(2, recordevents.MatchEvent( + recordevents.MatchHeartBeatsImageMessage(message), + HasSource(fmt.Sprintf("https://knative.dev/eventing/test/heartbeats/#%s/%s", client.Namespace, deploymentName)), + )) + +} diff --git a/test/lib/creation.go b/test/lib/creation.go index f0c40a24e58..078192a34a0 100644 --- a/test/lib/creation.go +++ b/test/lib/creation.go @@ -19,8 +19,6 @@ package lib import ( "fmt" - sourcesv1alpha2 "knative.dev/eventing/pkg/apis/sources/v1alpha2" - appsv1 "k8s.io/api/apps/v1" batchv1beta1 "k8s.io/api/batch/v1beta1" corev1 "k8s.io/api/core/v1" @@ -38,6 +36,8 @@ import ( messagingv1 "knative.dev/eventing/pkg/apis/messaging/v1" messagingv1beta1 "knative.dev/eventing/pkg/apis/messaging/v1beta1" sourcesv1alpha1 "knative.dev/eventing/pkg/apis/sources/v1alpha1" + sourcesv1alpha2 "knative.dev/eventing/pkg/apis/sources/v1alpha2" + sourcesv1beta1 "knative.dev/eventing/pkg/apis/sources/v1beta1" "knative.dev/eventing/pkg/utils" "knative.dev/eventing/test/lib/duck" "knative.dev/eventing/test/lib/resources" @@ -322,6 +322,17 @@ func (c *Client) CreateSinkBindingV1Alpha2OrFail(sb *sourcesv1alpha2.SinkBinding c.Tracker.AddObj(sb) } +// CreateSinkBindingV1Beta1OrFail will create a SinkBinding or fail the test if there is an error. +func (c *Client) CreateSinkBindingV1Beta1OrFail(sb *sourcesv1beta1.SinkBinding) { + c.T.Logf("Creating sinkbinding %+v", sb) + sbInterface := c.Eventing.SourcesV1beta1().SinkBindings(c.Namespace) + _, err := sbInterface.Create(sb) + if err != nil { + c.T.Fatalf("Failed to create sinkbinding %q: %v", sb.Name, err) + } + c.Tracker.AddObj(sb) +} + // CreateApiServerSourceOrFail will create an ApiServerSource func (c *Client) CreateApiServerSourceOrFail(apiServerSource *sourcesv1alpha2.ApiServerSource) { c.T.Logf("Creating apiserversource %+v", apiServerSource) From e0466501a82d12002e1c180e312167fe55ad2243 Mon Sep 17 00:00:00 2001 From: Nacho Cano Date: Tue, 14 Jul 2020 09:04:25 -0700 Subject: [PATCH 04/11] Updating deps, moving to duckv1beta1 --- go.mod | 4 +- go.sum | 34 +- .../v1beta1/sinkbinding_defaults_test.go | 10 +- .../v1beta1/sinkbinding_lifecycle_test.go | 6 +- pkg/apis/sources/v1beta1/sinkbinding_types.go | 4 +- .../v1beta1/sinkbinding_validation_test.go | 8 +- .../x/tools/cmd/goimports/goimports.go | 7 +- vendor/golang.org/x/tools/imports/forward.go | 27 +- .../x/tools/internal/imports/fix.go | 71 ++- .../x/tools/internal/imports/imports.go | 88 +--- .../x/tools/internal/imports/sortimports.go | 20 +- .../api/container/v1beta1/container-api.json | 96 +++- .../api/container/v1beta1/container-gen.go | 383 ++++++++++----- .../api/internal/settings.go | 39 +- .../option/internaloption/internaloption.go | 14 + .../api/storage/v1/storage-api.json | 6 +- .../api/storage/v1/storage-gen.go | 114 +++-- .../api/transport/grpc/dial.go | 13 +- .../api/transport/http/dial.go | 25 +- .../devtools/cloudtrace/v2/trace.pb.go | 462 +++++++++++------- .../devtools/cloudtrace/v2/tracing.pb.go | 3 +- .../pkg/apis/duck/ducktypes/ducktypes.go | 43 ++ vendor/knative.dev/pkg/apis/duck/register.go | 6 +- .../pkg/apis/duck/v1/addressable_types.go | 12 +- .../pkg/apis/duck/v1/kresource_type.go | 7 + .../pkg/apis/duck/v1/podspec_types.go | 15 +- .../knative.dev/pkg/apis/duck/v1/register.go | 5 +- .../pkg/apis/duck/v1/source_types.go | 15 +- .../pkg/apis/duck/v1/status_types.go | 11 +- .../apis/duck/v1beta1/addressable_types.go | 15 +- .../pkg/apis/duck/v1beta1/binding_types.go | 92 ++++ .../pkg/apis/duck/v1beta1/register.go | 7 +- .../pkg/apis/duck/v1beta1/source_types.go | 14 +- .../pkg/apis/duck/v1beta1/status_types.go | 18 +- .../duck/v1beta1/zz_generated.deepcopy.go | 77 +++ vendor/knative.dev/pkg/apis/duck/verify.go | 23 +- .../pkg/configmap/hash-gen/main.go | 5 +- .../pkg/injection/sharedmain/main.go | 211 ++------ .../knative.dev/pkg/leaderelection/config.go | 57 +-- vendor/knative.dev/pkg/test/spoof/spoof.go | 2 +- .../pkg/webhook/psbinding/psbinding.go | 2 +- .../test-infra/scripts/e2e-tests.sh | 82 ++-- .../knative.dev/test-infra/scripts/library.sh | 38 +- .../test-infra/scripts/performance-tests.sh | 24 +- .../test-infra/scripts/presubmit-tests.sh | 16 +- .../knative.dev/test-infra/scripts/release.sh | 74 +-- vendor/modules.txt | 15 +- 47 files changed, 1343 insertions(+), 977 deletions(-) create mode 100644 vendor/knative.dev/pkg/apis/duck/ducktypes/ducktypes.go create mode 100644 vendor/knative.dev/pkg/apis/duck/v1beta1/binding_types.go diff --git a/go.mod b/go.mod index e2cfcab3cf9..3a90f5718dc 100644 --- a/go.mod +++ b/go.mod @@ -38,8 +38,8 @@ require ( k8s.io/apiserver v0.17.6 k8s.io/client-go v11.0.1-0.20190805182717-6502b5e7b1b5+incompatible k8s.io/utils v0.0.0-20200124190032-861946025e34 - knative.dev/pkg v0.0.0-20200708171447-5358179e7499 - knative.dev/test-infra v0.0.0-20200708165947-2cd922769fa4 + knative.dev/pkg v0.0.0-20200714153419-27fe4e191080 + knative.dev/test-infra v0.0.0-20200713220518-5a4c4cad5372 sigs.k8s.io/yaml v1.2.0 ) diff --git a/go.sum b/go.sum index 970daa0ffcb..58424e74616 100644 --- a/go.sum +++ b/go.sum @@ -39,7 +39,7 @@ cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+ cloud.google.com/go/pubsub v1.2.0 h1:Lpy6hKgdcl7a3WGSfJIFmxmcdjSpP6OmBEfcOv1Y680= cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA= cloud.google.com/go/pubsub v1.3.1/go.mod h1:i+ucay31+CNRpDW4Lu78I4xXG+O1r/MAHgjpRVR+TSU= -cloud.google.com/go/pubsub v1.4.0/go.mod h1:LFrqilwgdw4X2cJS9ALgzYmMu+ULyrUN6IHV3CPK4TM= +cloud.google.com/go/pubsub v1.5.0/go.mod h1:ZEwJccE3z93Z2HWvstpri00jOg7oO4UZDtKhwDwqF0w= cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw= cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos= cloud.google.com/go/storage v1.6.0 h1:UDpwYIwla4jHGzZJaEJYx1tOejbgSoNqsAfHAUYe2r8= @@ -542,7 +542,7 @@ github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/ github.com/google/gofuzz v1.1.0 h1:Hsa8mG0dQ46ij8Sl2AYJDUv1oA9/d6Vk+3LG99Oe02g= github.com/google/gofuzz v1.1.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/licenseclassifier v0.0.0-20190926221455-842c0d70d702/go.mod h1:qsqn2hxC+vURpyBRygGUuinTO42MFRLcsmQ/P8v94+M= -github.com/google/licenseclassifier v0.0.0-20200402202327-879cb1424de0/go.mod h1:qsqn2hxC+vURpyBRygGUuinTO42MFRLcsmQ/P8v94+M= +github.com/google/licenseclassifier v0.0.0-20200708223521-3d09a0ea2f39/go.mod h1:qsqn2hxC+vURpyBRygGUuinTO42MFRLcsmQ/P8v94+M= github.com/google/mako v0.0.0-20190821191249-122f8dcef9e3 h1:/o5e44nTD/QEEiWPGSFT3bSqcq3Qg7q27N9bv4gKh5M= github.com/google/mako v0.0.0-20190821191249-122f8dcef9e3/go.mod h1:YzLcVlL+NqWnmUEPuhS1LxDDwGO9WNbVlEXaF4IH35g= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= @@ -1075,6 +1075,7 @@ github.com/xlab/handysort v0.0.0-20150421192137-fb3537ed64a1/go.mod h1:QcJo0QPSf github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yvasiyarov/go-metrics v0.0.0-20140926110328-57bccd1ccd43/go.mod h1:aX5oPXxHm3bOH+xeAttToC8pqch2ScQN/JoXYupl6xs= github.com/yvasiyarov/gorelic v0.0.0-20141212073537-a9bba5b9ab50/go.mod h1:NUSPSUX/bi6SeDMUh6brw0nXpxHnc96TguQh0+r/ssA= github.com/yvasiyarov/newrelic_platform_go v0.0.0-20140908184405-b21fdbd4370f/go.mod h1:GlGEuHIJweS1mbCqG+7vt2nvWLzLLnRHbXz5JKd/Qbg= @@ -1144,6 +1145,8 @@ golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 h1:psW17arqaxU48Z5kZ0CQnkZWQJsqcURM6tKiBApRjXI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20200709230013-948cd5f35899 h1:DZhuSZLsGlFL4CmhA8BcRA0mnthyA/nZ00AqCUo7vHg= +golang.org/x/crypto v0.0.0-20200709230013-948cd5f35899/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190125153040-c74c464bbbf2/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -1230,6 +1233,8 @@ golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/ golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200625001655-4c5254603344 h1:vGXIOMxbNfDTk/aXCmfdLgkrSV+Z2tcbze+pEc3v5W4= golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20200707034311-ab3426394381 h1:VXak5I6aEWmAXeQjA+QSZzlgNrpq9mjcfDemuexIKsU= +golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20181106182150-f42d05182288/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -1405,8 +1410,9 @@ golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roY golang.org/x/tools v0.0.0-20200527183253-8e7acdbce89d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200626171337-aa94e735be7f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200701000337-a32c0cb1d5b2 h1:xs+dSrelqXhHGIwIftyT5DHxJKH8hbDQnHc5KZ6i/u8= -golang.org/x/tools v0.0.0-20200701000337-a32c0cb1d5b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200706234117-b22de6825cf7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.0.0-20200710042808-f1c4188a97a1 h1:rD1FcWVsRaMY+l8biE9jbWP5MS/CJJ/90a9TMkMgNrM= +golang.org/x/tools v0.0.0-20200710042808-f1c4188a97a1/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= @@ -1444,6 +1450,8 @@ google.golang.org/api v0.24.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0M google.golang.org/api v0.25.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= google.golang.org/api v0.28.0 h1:jMF5hhVfMkTZwHW1SDpKq5CkgWLXOb31Foaca9Zr3oM= google.golang.org/api v0.28.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= +google.golang.org/api v0.29.0 h1:BaiDisFir8O4IJxvAabCGGkQ6yCJegNQqSVoYUNAnbk= +google.golang.org/api v0.29.0/go.mod h1:Lcubydp8VUV7KeIHD9z2Bys/sm/vGKnG1UHuDBSrHWM= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.3.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= @@ -1488,11 +1496,11 @@ google.golang.org/genproto v0.0.0-20200511104702-f5ebc3bea380/go.mod h1:55QSHmfG google.golang.org/genproto v0.0.0-20200515170657-fc4c6c6a6587/go.mod h1:YsZOwe1myG/8QRHRsmBRE1LrgQY60beZKjly0O1fX9U= google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= google.golang.org/genproto v0.0.0-20200527145253-8367513e4ece/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA= -google.golang.org/genproto v0.0.0-20200528110217-3d3490e7e671/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA= google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA= google.golang.org/genproto v0.0.0-20200626011028-ee7919e894b5/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20200701001935-0939c5918c31 h1:Of4QP8bfRqzDROen6+s2j/p0jCPgzvQRd9nHiactfn4= -google.golang.org/genproto v0.0.0-20200701001935-0939c5918c31/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20200707001353-8e8330bf89df/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20200710124503-20a17af7bd0e h1:k+p/u26/lVeNEpdxSeUrm7rTvoFckBKaf7gTzgmHyDA= +google.golang.org/genproto v0.0.0-20200710124503-20a17af7bd0e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/grpc v0.0.0-20160317175043-d3ddb4469d5a/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= @@ -1634,18 +1642,18 @@ k8s.io/legacy-cloud-providers v0.17.4/go.mod h1:FikRNoD64ECjkxO36gkDgJeiQWwyZTuB k8s.io/metrics v0.17.2/go.mod h1:3TkNHET4ROd+NfzNxkjoVfQ0Ob4iZnaHmSEA4vYpwLw= k8s.io/test-infra v0.0.0-20200514184223-ba32c8aae783/go.mod h1:bW6thaPZfL2hW7ecjx2WYwlP9KQLM47/xIJyttkVk5s= k8s.io/test-infra v0.0.0-20200617221206-ea73eaeab7ff/go.mod h1:L3+cRvwftUq8IW1TrHji5m3msnc4uck/7LsE/GR/aZk= -k8s.io/test-infra v0.0.0-20200630233406-1dca6122872e/go.mod h1:L3+cRvwftUq8IW1TrHji5m3msnc4uck/7LsE/GR/aZk= +k8s.io/test-infra v0.0.0-20200710134549-5891a1a4cc17/go.mod h1:L3+cRvwftUq8IW1TrHji5m3msnc4uck/7LsE/GR/aZk= k8s.io/utils v0.0.0-20191114184206-e782cd3c129f/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew= k8s.io/utils v0.0.0-20200124190032-861946025e34 h1:HjlUD6M0K3P8nRXmr2B9o4F9dUy9TCj/aEpReeyi6+k= k8s.io/utils v0.0.0-20200124190032-861946025e34/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew= knative.dev/caching v0.0.0-20200116200605-67bca2c83dfa/go.mod h1:dHXFU6CGlLlbzaWc32g80cR92iuBSpsslDNBWI8C7eg= knative.dev/eventing-contrib v0.11.2/go.mod h1:SnXZgSGgMSMLNFTwTnpaOH7hXDzTFtw0J8OmHflNx3g= knative.dev/pkg v0.0.0-20200207155214-fef852970f43/go.mod h1:pgODObA1dTyhNoFxPZTTjNWfx6F0aKsKzn+vaT9XO/Q= -knative.dev/pkg v0.0.0-20200708171447-5358179e7499 h1:hmwZWMiH/EZ+DYrBVC4IXEAKqQyQGJlj1oDETXvdsgA= -knative.dev/pkg v0.0.0-20200708171447-5358179e7499/go.mod h1:AqAJV6rYi8IGikDjJ/9ZQd9qKdkXVlesVnVjwx62YB8= -knative.dev/test-infra v0.0.0-20200707183444-aed09e56ddc7/go.mod h1:RjYAhXnZqeHw9+B0zsbqSPlae0lCvjekO/nw5ZMpLCs= -knative.dev/test-infra v0.0.0-20200708165947-2cd922769fa4 h1:FI6tYvlxya3RiA9pqV9h2mk7Rkyc7qvi9QTA4Fguv2I= -knative.dev/test-infra v0.0.0-20200708165947-2cd922769fa4/go.mod h1:RjYAhXnZqeHw9+B0zsbqSPlae0lCvjekO/nw5ZMpLCs= +knative.dev/pkg v0.0.0-20200714153419-27fe4e191080 h1:dS4OvyLd5NUfnHyhLbLuxPmm0pK+IduaJlr3mbdctTQ= +knative.dev/pkg v0.0.0-20200714153419-27fe4e191080/go.mod h1:2xVLIH5SNUripobZvOEz3w/Ta9xqMkw7QmFIa2cbDFY= +knative.dev/test-infra v0.0.0-20200713045417-850e4e37918d/go.mod h1:vtT6dLs/iNj8pKcfag8CSVqHKNMgyCFtU/g1pV7Bovs= +knative.dev/test-infra v0.0.0-20200713220518-5a4c4cad5372 h1:NZzdNmKYP3L7fut/SNOxLgTgXVvQrygXiYpAeIMGMwM= +knative.dev/test-infra v0.0.0-20200713220518-5a4c4cad5372/go.mod h1:vtT6dLs/iNj8pKcfag8CSVqHKNMgyCFtU/g1pV7Bovs= modernc.org/cc v1.0.0/go.mod h1:1Sk4//wdnYJiUIxnW8ddKpaOJCF37yAdqYnkxUpaYxw= modernc.org/golex v1.0.0/go.mod h1:b/QX9oBD/LhixY6NDh+IdGv17hgB+51fET1i2kPSmvk= modernc.org/mathutil v1.0.0/go.mod h1:wU0vUrJsVWBZ4P6e7xtFJEhFSNsfRLJ8H458uRjg03k= diff --git a/pkg/apis/sources/v1beta1/sinkbinding_defaults_test.go b/pkg/apis/sources/v1beta1/sinkbinding_defaults_test.go index 9062c24735e..3afb02d0684 100644 --- a/pkg/apis/sources/v1beta1/sinkbinding_defaults_test.go +++ b/pkg/apis/sources/v1beta1/sinkbinding_defaults_test.go @@ -24,7 +24,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "knative.dev/pkg/apis" duckv1 "knative.dev/pkg/apis/duck/v1" - duckv1alpha1 "knative.dev/pkg/apis/duck/v1alpha1" + duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" "knative.dev/pkg/tracker" ) @@ -41,7 +41,7 @@ func TestSinkBindingDefaulting(t *testing.T) { Namespace: "moore", }, Spec: SinkBindingSpec{ - BindingSpec: duckv1alpha1.BindingSpec{ + BindingSpec: duckv1beta1.BindingSpec{ Subject: tracker.Reference{ APIVersion: "apps/v1", Kind: "Deployment", @@ -65,7 +65,7 @@ func TestSinkBindingDefaulting(t *testing.T) { Namespace: "moore", }, Spec: SinkBindingSpec{ - BindingSpec: duckv1alpha1.BindingSpec{ + BindingSpec: duckv1beta1.BindingSpec{ Subject: tracker.Reference{ APIVersion: "apps/v1", Kind: "Deployment", @@ -95,7 +95,7 @@ func TestSinkBindingDefaulting(t *testing.T) { Namespace: "moore", }, Spec: SinkBindingSpec{ - BindingSpec: duckv1alpha1.BindingSpec{ + BindingSpec: duckv1beta1.BindingSpec{ Subject: tracker.Reference{ APIVersion: "apps/v1", Kind: "Deployment", @@ -119,7 +119,7 @@ func TestSinkBindingDefaulting(t *testing.T) { Namespace: "moore", }, Spec: SinkBindingSpec{ - BindingSpec: duckv1alpha1.BindingSpec{ + BindingSpec: duckv1beta1.BindingSpec{ Subject: tracker.Reference{ APIVersion: "apps/v1", Kind: "Deployment", diff --git a/pkg/apis/sources/v1beta1/sinkbinding_lifecycle_test.go b/pkg/apis/sources/v1beta1/sinkbinding_lifecycle_test.go index c95fa3e11bb..052564ca689 100644 --- a/pkg/apis/sources/v1beta1/sinkbinding_lifecycle_test.go +++ b/pkg/apis/sources/v1beta1/sinkbinding_lifecycle_test.go @@ -26,7 +26,7 @@ import ( "k8s.io/apimachinery/pkg/runtime/schema" "knative.dev/pkg/apis" duckv1 "knative.dev/pkg/apis/duck/v1" - duckv1alpha1 "knative.dev/pkg/apis/duck/v1alpha1" + duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" "knative.dev/pkg/tracker" ) @@ -53,7 +53,7 @@ func TestSinkBindingGetGroupVersionKind(t *testing.T) { func TestSinkBindingGetters(t *testing.T) { r := &SinkBinding{ Spec: SinkBindingSpec{ - BindingSpec: duckv1alpha1.BindingSpec{ + BindingSpec: duckv1beta1.BindingSpec{ Subject: tracker.Reference{ APIVersion: "foo", }, @@ -74,7 +74,7 @@ func TestSinkBindingGetters(t *testing.T) { func TestSinkBindingSetObsGen(t *testing.T) { r := &SinkBinding{ Spec: SinkBindingSpec{ - BindingSpec: duckv1alpha1.BindingSpec{ + BindingSpec: duckv1beta1.BindingSpec{ Subject: tracker.Reference{ APIVersion: "foo", }, diff --git a/pkg/apis/sources/v1beta1/sinkbinding_types.go b/pkg/apis/sources/v1beta1/sinkbinding_types.go index ab45cea688c..29e9cea2c85 100644 --- a/pkg/apis/sources/v1beta1/sinkbinding_types.go +++ b/pkg/apis/sources/v1beta1/sinkbinding_types.go @@ -21,7 +21,7 @@ import ( "k8s.io/apimachinery/pkg/runtime" "knative.dev/pkg/apis" duckv1 "knative.dev/pkg/apis/duck/v1" - duckv1alpha1 "knative.dev/pkg/apis/duck/v1alpha1" + duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" "knative.dev/pkg/kmeta" ) @@ -65,7 +65,7 @@ type SinkBindingSpec struct { // inherits duck/v1alpha1 BindingSpec, which currently provides: // * Subject - Subject references the resource(s) whose "runtime contract" // should be augmented by Binding implementations. - duckv1alpha1.BindingSpec `json:",inline"` + duckv1beta1.BindingSpec `json:",inline"` } const ( diff --git a/pkg/apis/sources/v1beta1/sinkbinding_validation_test.go b/pkg/apis/sources/v1beta1/sinkbinding_validation_test.go index ed8ca73e4f1..25729615dde 100644 --- a/pkg/apis/sources/v1beta1/sinkbinding_validation_test.go +++ b/pkg/apis/sources/v1beta1/sinkbinding_validation_test.go @@ -23,7 +23,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "knative.dev/pkg/apis" duckv1 "knative.dev/pkg/apis/duck/v1" - duckv1alpha1 "knative.dev/pkg/apis/duck/v1alpha1" + duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" "knative.dev/pkg/tracker" ) @@ -40,7 +40,7 @@ func TestSinkBindingValidation(t *testing.T) { Namespace: "moore", }, Spec: SinkBindingSpec{ - BindingSpec: duckv1alpha1.BindingSpec{ + BindingSpec: duckv1beta1.BindingSpec{ Subject: tracker.Reference{ APIVersion: "apps/v1", Kind: "Deployment", @@ -68,7 +68,7 @@ func TestSinkBindingValidation(t *testing.T) { Namespace: "moore", }, Spec: SinkBindingSpec{ - BindingSpec: duckv1alpha1.BindingSpec{ + BindingSpec: duckv1beta1.BindingSpec{ Subject: tracker.Reference{ APIVersion: "apps/v1", Kind: "Deployment", @@ -97,7 +97,7 @@ func TestSinkBindingValidation(t *testing.T) { Namespace: "moore", }, Spec: SinkBindingSpec{ - BindingSpec: duckv1alpha1.BindingSpec{ + BindingSpec: duckv1beta1.BindingSpec{ Subject: tracker.Reference{ APIVersion: "apps/v1", Kind: "Deployment", diff --git a/vendor/golang.org/x/tools/cmd/goimports/goimports.go b/vendor/golang.org/x/tools/cmd/goimports/goimports.go index f177b2d9a46..27708972d1e 100644 --- a/vendor/golang.org/x/tools/cmd/goimports/goimports.go +++ b/vendor/golang.org/x/tools/cmd/goimports/goimports.go @@ -21,6 +21,7 @@ import ( "runtime/pprof" "strings" + "golang.org/x/tools/internal/gocommand" "golang.org/x/tools/internal/imports" ) @@ -42,14 +43,16 @@ var ( TabIndent: true, Comments: true, Fragment: true, - Env: &imports.ProcessEnv{}, + Env: &imports.ProcessEnv{ + GocmdRunner: &gocommand.Runner{}, + }, } exitCode = 0 ) func init() { flag.BoolVar(&options.AllErrors, "e", false, "report all errors (not just the first 10 on different lines)") - flag.StringVar(&options.Env.LocalPrefix, "local", "", "put imports beginning with this string after 3rd-party packages; comma-separated list") + flag.StringVar(&options.LocalPrefix, "local", "", "put imports beginning with this string after 3rd-party packages; comma-separated list") flag.BoolVar(&options.FormatOnly, "format-only", false, "if true, don't fix imports and only format. In this mode, goimports is effectively gofmt, with the addition that imports are grouped into sections.") } diff --git a/vendor/golang.org/x/tools/imports/forward.go b/vendor/golang.org/x/tools/imports/forward.go index 83f4e44731b..a4e40adba0d 100644 --- a/vendor/golang.org/x/tools/imports/forward.go +++ b/vendor/golang.org/x/tools/imports/forward.go @@ -3,8 +3,10 @@ package imports // import "golang.org/x/tools/imports" import ( + "io/ioutil" "log" + "golang.org/x/tools/internal/gocommand" intimp "golang.org/x/tools/internal/imports" ) @@ -29,25 +31,34 @@ var Debug = false var LocalPrefix string // Process formats and adjusts imports for the provided file. -// If opt is nil the defaults are used. +// If opt is nil the defaults are used, and if src is nil the source +// is read from the filesystem. // // Note that filename's directory influences which imports can be chosen, // so it is important that filename be accurate. // To process data ``as if'' it were in filename, pass the data as a non-nil src. func Process(filename string, src []byte, opt *Options) ([]byte, error) { + var err error + if src == nil { + src, err = ioutil.ReadFile(filename) + if err != nil { + return nil, err + } + } if opt == nil { opt = &Options{Comments: true, TabIndent: true, TabWidth: 8} } intopt := &intimp.Options{ Env: &intimp.ProcessEnv{ - LocalPrefix: LocalPrefix, + GocmdRunner: &gocommand.Runner{}, }, - AllErrors: opt.AllErrors, - Comments: opt.Comments, - FormatOnly: opt.FormatOnly, - Fragment: opt.Fragment, - TabIndent: opt.TabIndent, - TabWidth: opt.TabWidth, + LocalPrefix: LocalPrefix, + AllErrors: opt.AllErrors, + Comments: opt.Comments, + FormatOnly: opt.FormatOnly, + Fragment: opt.Fragment, + TabIndent: opt.TabIndent, + TabWidth: opt.TabWidth, } if Debug { intopt.Env.Logf = log.Printf diff --git a/vendor/golang.org/x/tools/internal/imports/fix.go b/vendor/golang.org/x/tools/internal/imports/fix.go index 2c703076561..ecd13e87ad5 100644 --- a/vendor/golang.org/x/tools/internal/imports/fix.go +++ b/vendor/golang.org/x/tools/internal/imports/fix.go @@ -32,25 +32,25 @@ import ( // importToGroup is a list of functions which map from an import path to // a group number. -var importToGroup = []func(env *ProcessEnv, importPath string) (num int, ok bool){ - func(env *ProcessEnv, importPath string) (num int, ok bool) { - if env.LocalPrefix == "" { +var importToGroup = []func(localPrefix, importPath string) (num int, ok bool){ + func(localPrefix, importPath string) (num int, ok bool) { + if localPrefix == "" { return } - for _, p := range strings.Split(env.LocalPrefix, ",") { + for _, p := range strings.Split(localPrefix, ",") { if strings.HasPrefix(importPath, p) || strings.TrimSuffix(p, "/") == importPath { return 3, true } } return }, - func(_ *ProcessEnv, importPath string) (num int, ok bool) { + func(_, importPath string) (num int, ok bool) { if strings.HasPrefix(importPath, "appengine") { return 2, true } return }, - func(_ *ProcessEnv, importPath string) (num int, ok bool) { + func(_, importPath string) (num int, ok bool) { firstComponent := strings.Split(importPath, "/")[0] if strings.Contains(firstComponent, ".") { return 1, true @@ -59,9 +59,9 @@ var importToGroup = []func(env *ProcessEnv, importPath string) (num int, ok bool }, } -func importGroup(env *ProcessEnv, importPath string) int { +func importGroup(localPrefix, importPath string) int { for _, fn := range importToGroup { - if n, ok := fn(env, importPath); ok { + if n, ok := fn(localPrefix, importPath); ok { return n } } @@ -278,7 +278,12 @@ func (p *pass) loadPackageNames(imports []*ImportInfo) error { unknown = append(unknown, imp.ImportPath) } - names, err := p.env.GetResolver().loadPackageNames(unknown, p.srcDir) + resolver, err := p.env.GetResolver() + if err != nil { + return err + } + + names, err := resolver.loadPackageNames(unknown, p.srcDir) if err != nil { return err } @@ -640,15 +645,23 @@ func getCandidatePkgs(ctx context.Context, wrappedCallback *scanCallback, filena wrappedCallback.exportsLoaded(pkg, exports) }, } - return env.GetResolver().scan(ctx, scanFilter) + resolver, err := env.GetResolver() + if err != nil { + return err + } + return resolver.scan(ctx, scanFilter) } -func ScoreImportPaths(ctx context.Context, env *ProcessEnv, paths []string) map[string]int { +func ScoreImportPaths(ctx context.Context, env *ProcessEnv, paths []string) (map[string]int, error) { result := make(map[string]int) + resolver, err := env.GetResolver() + if err != nil { + return nil, err + } for _, path := range paths { - result[path] = env.GetResolver().scoreImportPath(ctx, path) + result[path] = resolver.scoreImportPath(ctx, path) } - return result + return result, nil } func PrimeCache(ctx context.Context, env *ProcessEnv) error { @@ -674,8 +687,9 @@ func candidateImportName(pkg *pkg) string { return "" } -// getAllCandidates gets all of the candidates to be imported, regardless of if they are needed. -func getAllCandidates(ctx context.Context, wrapped func(ImportFix), searchPrefix, filename, filePkg string, env *ProcessEnv) error { +// GetAllCandidates gets all of the packages starting with prefix that can be +// imported by filename, sorted by import path. +func GetAllCandidates(ctx context.Context, wrapped func(ImportFix), searchPrefix, filename, filePkg string, env *ProcessEnv) error { callback := &scanCallback{ rootFound: func(gopathwalk.Root) bool { return true @@ -714,7 +728,8 @@ type PackageExport struct { Exports []string } -func getPackageExports(ctx context.Context, wrapped func(PackageExport), searchPkg, filename, filePkg string, env *ProcessEnv) error { +// GetPackageExports returns all known packages with name pkg and their exports. +func GetPackageExports(ctx context.Context, wrapped func(PackageExport), searchPkg, filename, filePkg string, env *ProcessEnv) error { callback := &scanCallback{ rootFound: func(gopathwalk.Root) bool { return true @@ -749,8 +764,6 @@ var RequiredGoEnvVars = []string{"GO111MODULE", "GOFLAGS", "GOINSECURE", "GOMOD" // ProcessEnv contains environment variables and settings that affect the use of // the go command, the go/build package, etc. type ProcessEnv struct { - LocalPrefix string - GocmdRunner *gocommand.Runner BuildFlags []string @@ -830,16 +843,19 @@ func (e *ProcessEnv) env() []string { return env } -func (e *ProcessEnv) GetResolver() Resolver { +func (e *ProcessEnv) GetResolver() (Resolver, error) { if e.resolver != nil { - return e.resolver + return e.resolver, nil + } + if err := e.init(); err != nil { + return nil, err } if len(e.Env["GOMOD"]) == 0 { e.resolver = newGopathResolver(e) - return e.resolver + return e.resolver, nil } e.resolver = newModuleResolver(e) - return e.resolver + return e.resolver, nil } func (e *ProcessEnv) buildContext() *build.Context { @@ -964,10 +980,13 @@ func addExternalCandidates(pass *pass, refs references, filename string) error { return false // We'll do our own loading after we sort. }, } - err := pass.env.GetResolver().scan(context.Background(), callback) + resolver, err := pass.env.GetResolver() if err != nil { return err } + if err = resolver.scan(context.Background(), callback); err != nil { + return err + } // Search for imports matching potential package references. type result struct { @@ -1408,6 +1427,10 @@ func findImport(ctx context.Context, pass *pass, candidates []pkgDistance, pkgNa pass.env.Logf("%s candidate %d/%d: %v in %v", pkgName, i+1, len(candidates), c.pkg.importPathShort, c.pkg.dir) } } + resolver, err := pass.env.GetResolver() + if err != nil { + return nil, err + } // Collect exports for packages with matching names. rescv := make([]chan *pkg, len(candidates)) @@ -1446,7 +1469,7 @@ func findImport(ctx context.Context, pass *pass, candidates []pkgDistance, pkgNa } // If we're an x_test, load the package under test's test variant. includeTest := strings.HasSuffix(pass.f.Name.Name, "_test") && c.pkg.dir == pass.srcDir - _, exports, err := pass.env.GetResolver().loadExports(ctx, c.pkg, includeTest) + _, exports, err := resolver.loadExports(ctx, c.pkg, includeTest) if err != nil { if pass.env.Logf != nil { pass.env.Logf("loading exports in dir %s (seeking package %s): %v", c.pkg.dir, pkgName, err) diff --git a/vendor/golang.org/x/tools/internal/imports/imports.go b/vendor/golang.org/x/tools/internal/imports/imports.go index 04ecdfda379..2815edc33d7 100644 --- a/vendor/golang.org/x/tools/internal/imports/imports.go +++ b/vendor/golang.org/x/tools/internal/imports/imports.go @@ -11,7 +11,6 @@ package imports import ( "bufio" "bytes" - "context" "fmt" "go/ast" "go/format" @@ -19,19 +18,22 @@ import ( "go/printer" "go/token" "io" - "io/ioutil" "regexp" "strconv" "strings" "golang.org/x/tools/go/ast/astutil" - "golang.org/x/tools/internal/gocommand" ) // Options is golang.org/x/tools/imports.Options with extra internal-only options. type Options struct { Env *ProcessEnv // The environment to use. Note: this contains the cached module and filesystem state. + // LocalPrefix is a comma-separated string of import path prefixes, which, if + // set, instructs Process to sort the import paths with the given prefixes + // into another group after 3rd-party packages. + LocalPrefix string + Fragment bool // Accept fragment of a source file (no package statement) AllErrors bool // Report all errors (not just the first 10 on different lines) @@ -42,13 +44,8 @@ type Options struct { FormatOnly bool // Disable the insertion and deletion of imports } -// Process implements golang.org/x/tools/imports.Process with explicit context in env. +// Process implements golang.org/x/tools/imports.Process with explicit context in opt.Env. func Process(filename string, src []byte, opt *Options) (formatted []byte, err error) { - src, opt, err = initialize(filename, src, opt) - if err != nil { - return nil, err - } - fileSet := token.NewFileSet() file, adjust, err := parse(fileSet, filename, src, opt) if err != nil { @@ -64,16 +61,12 @@ func Process(filename string, src []byte, opt *Options) (formatted []byte, err e } // FixImports returns a list of fixes to the imports that, when applied, -// will leave the imports in the same state as Process. +// will leave the imports in the same state as Process. src and opt must +// be specified. // // Note that filename's directory influences which imports can be chosen, // so it is important that filename be accurate. func FixImports(filename string, src []byte, opt *Options) (fixes []*ImportFix, err error) { - src, opt, err = initialize(filename, src, opt) - if err != nil { - return nil, err - } - fileSet := token.NewFileSet() file, _, err := parse(fileSet, filename, src, opt) if err != nil { @@ -84,13 +77,9 @@ func FixImports(filename string, src []byte, opt *Options) (fixes []*ImportFix, } // ApplyFixes applies all of the fixes to the file and formats it. extraMode -// is added in when parsing the file. +// is added in when parsing the file. src and opts must be specified, but no +// env is needed. func ApplyFixes(fixes []*ImportFix, filename string, src []byte, opt *Options, extraMode parser.Mode) (formatted []byte, err error) { - src, opt, err = initialize(filename, src, opt) - if err != nil { - return nil, err - } - // Don't use parse() -- we don't care about fragments or statement lists // here, and we need to work with unparseable files. fileSet := token.NewFileSet() @@ -114,60 +103,9 @@ func ApplyFixes(fixes []*ImportFix, filename string, src []byte, opt *Options, e return formatFile(fileSet, file, src, nil, opt) } -// GetAllCandidates gets all of the packages starting with prefix that can be -// imported by filename, sorted by import path. -func GetAllCandidates(ctx context.Context, callback func(ImportFix), searchPrefix, filename, filePkg string, opt *Options) error { - _, opt, err := initialize(filename, []byte{}, opt) - if err != nil { - return err - } - return getAllCandidates(ctx, callback, searchPrefix, filename, filePkg, opt.Env) -} - -// GetPackageExports returns all known packages with name pkg and their exports. -func GetPackageExports(ctx context.Context, callback func(PackageExport), searchPkg, filename, filePkg string, opt *Options) error { - _, opt, err := initialize(filename, []byte{}, opt) - if err != nil { - return err - } - return getPackageExports(ctx, callback, searchPkg, filename, filePkg, opt.Env) -} - -// initialize sets the values for opt and src. -// If they are provided, they are not changed. Otherwise opt is set to the -// default values and src is read from the file system. -func initialize(filename string, src []byte, opt *Options) ([]byte, *Options, error) { - // Use defaults if opt is nil. - if opt == nil { - opt = &Options{Comments: true, TabIndent: true, TabWidth: 8} - } - - // Set the env if the user has not provided it. - if opt.Env == nil { - opt.Env = &ProcessEnv{} - } - // Set the gocmdRunner if the user has not provided it. - if opt.Env.GocmdRunner == nil { - opt.Env.GocmdRunner = &gocommand.Runner{} - } - if err := opt.Env.init(); err != nil { - return nil, nil, err - } - - if src == nil { - b, err := ioutil.ReadFile(filename) - if err != nil { - return nil, nil, err - } - src = b - } - - return src, opt, nil -} - func formatFile(fileSet *token.FileSet, file *ast.File, src []byte, adjust func(orig []byte, src []byte) []byte, opt *Options) ([]byte, error) { - mergeImports(opt.Env, fileSet, file) - sortImports(opt.Env, fileSet, file) + mergeImports(fileSet, file) + sortImports(opt.LocalPrefix, fileSet, file) imps := astutil.Imports(fileSet, file) var spacesBefore []string // import paths we need spaces before for _, impSection := range imps { @@ -178,7 +116,7 @@ func formatFile(fileSet *token.FileSet, file *ast.File, src []byte, adjust func( lastGroup := -1 for _, importSpec := range impSection { importPath, _ := strconv.Unquote(importSpec.Path.Value) - groupNum := importGroup(opt.Env, importPath) + groupNum := importGroup(opt.LocalPrefix, importPath) if groupNum != lastGroup && lastGroup != -1 { spacesBefore = append(spacesBefore, importPath) } diff --git a/vendor/golang.org/x/tools/internal/imports/sortimports.go b/vendor/golang.org/x/tools/internal/imports/sortimports.go index 226279471d3..be8ffa25fec 100644 --- a/vendor/golang.org/x/tools/internal/imports/sortimports.go +++ b/vendor/golang.org/x/tools/internal/imports/sortimports.go @@ -15,7 +15,7 @@ import ( // sortImports sorts runs of consecutive import lines in import blocks in f. // It also removes duplicate imports when it is possible to do so without data loss. -func sortImports(env *ProcessEnv, fset *token.FileSet, f *ast.File) { +func sortImports(localPrefix string, fset *token.FileSet, f *ast.File) { for i, d := range f.Decls { d, ok := d.(*ast.GenDecl) if !ok || d.Tok != token.IMPORT { @@ -40,11 +40,11 @@ func sortImports(env *ProcessEnv, fset *token.FileSet, f *ast.File) { for j, s := range d.Specs { if j > i && fset.Position(s.Pos()).Line > 1+fset.Position(d.Specs[j-1].End()).Line { // j begins a new run. End this one. - specs = append(specs, sortSpecs(env, fset, f, d.Specs[i:j])...) + specs = append(specs, sortSpecs(localPrefix, fset, f, d.Specs[i:j])...) i = j } } - specs = append(specs, sortSpecs(env, fset, f, d.Specs[i:])...) + specs = append(specs, sortSpecs(localPrefix, fset, f, d.Specs[i:])...) d.Specs = specs // Deduping can leave a blank line before the rparen; clean that up. @@ -60,7 +60,7 @@ func sortImports(env *ProcessEnv, fset *token.FileSet, f *ast.File) { // mergeImports merges all the import declarations into the first one. // Taken from golang.org/x/tools/ast/astutil. -func mergeImports(env *ProcessEnv, fset *token.FileSet, f *ast.File) { +func mergeImports(fset *token.FileSet, f *ast.File) { if len(f.Decls) <= 1 { return } @@ -142,7 +142,7 @@ type posSpan struct { End token.Pos } -func sortSpecs(env *ProcessEnv, fset *token.FileSet, f *ast.File, specs []ast.Spec) []ast.Spec { +func sortSpecs(localPrefix string, fset *token.FileSet, f *ast.File, specs []ast.Spec) []ast.Spec { // Can't short-circuit here even if specs are already sorted, // since they might yet need deduplication. // A lone import, however, may be safely ignored. @@ -191,7 +191,7 @@ func sortSpecs(env *ProcessEnv, fset *token.FileSet, f *ast.File, specs []ast.Sp // Reassign the import paths to have the same position sequence. // Reassign each comment to abut the end of its spec. // Sort the comments by new position. - sort.Sort(byImportSpec{env, specs}) + sort.Sort(byImportSpec{localPrefix, specs}) // Dedup. Thanks to our sorting, we can just consider // adjacent pairs of imports. @@ -245,8 +245,8 @@ func sortSpecs(env *ProcessEnv, fset *token.FileSet, f *ast.File, specs []ast.Sp } type byImportSpec struct { - env *ProcessEnv - specs []ast.Spec // slice of *ast.ImportSpec + localPrefix string + specs []ast.Spec // slice of *ast.ImportSpec } func (x byImportSpec) Len() int { return len(x.specs) } @@ -255,8 +255,8 @@ func (x byImportSpec) Less(i, j int) bool { ipath := importPath(x.specs[i]) jpath := importPath(x.specs[j]) - igroup := importGroup(x.env, ipath) - jgroup := importGroup(x.env, jpath) + igroup := importGroup(x.localPrefix, ipath) + jgroup := importGroup(x.localPrefix, jpath) if igroup != jgroup { return igroup < jgroup } diff --git a/vendor/google.golang.org/api/container/v1beta1/container-api.json b/vendor/google.golang.org/api/container/v1beta1/container-api.json index c4dc6e3577f..2b98b2950c9 100644 --- a/vendor/google.golang.org/api/container/v1beta1/container-api.json +++ b/vendor/google.golang.org/api/container/v1beta1/container-api.json @@ -2484,7 +2484,7 @@ } } }, - "revision": "20200519", + "revision": "20200619", "rootUrl": "https://container.googleapis.com/", "schemas": { "AcceleratorConfig": { @@ -2586,32 +2586,32 @@ "properties": { "management": { "$ref": "NodeManagement", - "description": "Specifies the node management options for NAP created node-pools." + "description": "NodeManagement configuration for this NodePool." }, "minCpuPlatform": { - "description": "Minimum CPU platform to be used for NAP created node pools.\nThe instance may be scheduled on the specified or newer CPU platform.\nApplicable values are the friendly names of CPU platforms, such as\n\u003ccode\u003eminCpuPlatform: \u0026quot;Intel Haswell\u0026quot;\u003c/code\u003e or\n\u003ccode\u003eminCpuPlatform: \u0026quot;Intel Sandy Bridge\u0026quot;\u003c/code\u003e. For more\ninformation, read [how to specify min CPU\nplatform](https://cloud.google.com/compute/docs/instances/specify-min-cpu-platform)\nTo unset the min cpu platform field pass \"automatic\" as field value.", + "description": "Minimum CPU platform to be used by this instance. The instance may be\nscheduled on the specified or newer CPU platform. Applicable values are the\nfriendly names of CPU platforms, such as\n\u003ccode\u003eminCpuPlatform: \u0026quot;Intel Haswell\u0026quot;\u003c/code\u003e or\n\u003ccode\u003eminCpuPlatform: \u0026quot;Intel Sandy Bridge\u0026quot;\u003c/code\u003e. For more\ninformation, read [how to specify min CPU\nplatform](https://cloud.google.com/compute/docs/instances/specify-min-cpu-platform)\nTo unset the min cpu platform field pass \"automatic\"\nas field value.", "type": "string" }, "oauthScopes": { - "description": "Scopes that are used by NAP when creating node pools.", + "description": "The set of Google API scopes to be made available on all of the\nnode VMs under the \"default\" service account.\n\nThe following scopes are recommended, but not required, and by default are\nnot included:\n\n* `https://www.googleapis.com/auth/compute` is required for mounting\npersistent storage on your nodes.\n* `https://www.googleapis.com/auth/devstorage.read_only` is required for\ncommunicating with **gcr.io**\n(the [Google Container\nRegistry](https://cloud.google.com/container-registry/)).\n\nIf unspecified, no scopes are added, unless Cloud Logging or Cloud\nMonitoring are enabled, in which case their required scopes will be added.", "items": { "type": "string" }, "type": "array" }, "serviceAccount": { - "description": "The Google Cloud Platform Service Account to be used by the node VMs.", + "description": "The Google Cloud Platform Service Account to be used by the node VMs.\nSpecify the email address of the Service Account; otherwise, if no Service\nAccount is specified, the \"default\" service account is used.", "type": "string" }, "upgradeSettings": { "$ref": "UpgradeSettings", - "description": "Specifies the upgrade settings for NAP created node pools" + "description": "Upgrade settings control disruption and speed of the upgrade." } }, "type": "object" }, "AvailableVersion": { - "description": "AvailableVersion is an additional Kubernetes versions offered\nto users who subscribed to the release channel.", + "description": "Deprecated.", "id": "AvailableVersion", "properties": { "reason": { @@ -2792,7 +2792,7 @@ "type": "string" }, "initialNodeCount": { - "description": "The number of nodes to create in this cluster. You must ensure that your\nCompute Engine \u003ca href=\"/compute/docs/resource-quotas\"\u003eresource quota\u003c/a\u003e\nis sufficient for this number of instances. You must also have available\nfirewall and routes quota.\nFor requests, this field should only be used in lieu of a\n\"node_pool\" object, since this configuration (along with the\n\"node_config\") will be used to create a \"NodePool\" object with an\nauto-generated name. Do not use this and a node_pool at the same time.\n\nThis field is deprecated, use node_pool.initial_node_count instead.", + "description": "The number of nodes to create in this cluster. You must ensure that your\nCompute Engine [resource quota](https://cloud.google.com/compute/quotas)\nis sufficient for this number of instances. You must also have available\nfirewall and routes quota.\nFor requests, this field should only be used in lieu of a\n\"node_pool\" object, since this configuration (along with the\n\"node_config\") will be used to create a \"NodePool\" object with an\nauto-generated name. Do not use this and a node_pool at the same time.\n\nThis field is deprecated, use node_pool.initial_node_count instead.", "format": "int32", "type": "integer" }, @@ -3205,7 +3205,7 @@ "properties": { "cluster": { "$ref": "Cluster", - "description": "Required. A [cluster\nresource](https://cloud.google.com/container-engine/reference/rest/v1beta1/projects.zones.clusters)" + "description": "Required. A [cluster\nresource](https://cloud.google.com/container-engine/reference/rest/v1beta1/projects.locations.clusters)" }, "parent": { "description": "The parent (project and location) where the cluster will be created.\nSpecified in the format `projects/*/locations/*`.", @@ -3615,6 +3615,20 @@ }, "type": "object" }, + "LinuxNodeConfig": { + "description": "Parameters that can be configured on Linux nodes.", + "id": "LinuxNodeConfig", + "properties": { + "sysctls": { + "additionalProperties": { + "type": "string" + }, + "description": "The Linux kernel parameters to be applied to the nodes and all pods running\non the nodes.\n\nThe following parameters are supported.\n\nnet.core.netdev_max_backlog\nnet.core.rmem_max\nnet.core.wmem_default\nnet.core.wmem_max\nnet.core.optmem_max\nnet.core.somaxconn\nnet.ipv4.tcp_rmem\nnet.ipv4.tcp_wmem\nnet.ipv4.tcp_tw_reuse", + "type": "object" + } + }, + "type": "object" + }, "ListClustersResponse": { "description": "ListClustersResponse is the result of ListClustersRequest.", "id": "ListClustersResponse", @@ -3949,6 +3963,10 @@ "description": "The image type to use for this node. Note that for a given image type,\nthe latest version of it will be used.", "type": "string" }, + "kubeletConfig": { + "$ref": "NodeKubeletConfig", + "description": "Node kubelet configs." + }, "labels": { "additionalProperties": { "type": "string" @@ -3956,6 +3974,10 @@ "description": "The map of Kubernetes labels (key/value pairs) to be applied to each node.\nThese will added in addition to any default label(s) that\nKubernetes may apply to the node.\nIn case of conflict in label keys, the applied set may differ depending on\nthe Kubernetes version -- it's best to assume the behavior is undefined\nand conflicts should be avoided.\nFor more information, including usage and the valid values, see:\nhttps://kubernetes.io/docs/concepts/overview/working-with-objects/labels/", "type": "object" }, + "linuxNodeConfig": { + "$ref": "LinuxNodeConfig", + "description": "Parameters that can be configured on Linux nodes." + }, "localSsdCount": { "description": "The number of local SSD disks to be attached to the node.\n\nThe limit for this value is dependent upon the maximum number of\ndisks available on a machine per zone. See:\nhttps://cloud.google.com/compute/docs/disks/local-ssd\nfor more information.", "format": "int32", @@ -4024,6 +4046,25 @@ }, "type": "object" }, + "NodeKubeletConfig": { + "description": "Node kubelet configs.", + "id": "NodeKubeletConfig", + "properties": { + "cpuCfsQuota": { + "description": "Enable CPU CFS quota enforcement for containers that specify CPU limits.\n\nIf this option is enabled, kubelet uses CFS quota\n(https://www.kernel.org/doc/Documentation/scheduler/sched-bwc.txt) to\nenforce container CPU limits. Otherwise, CPU limits will not be enforced at\nall.\n\nDisable this option to mitigate CPU throttling problems while still having\nyour pods to be in Guaranteed QoS class by specifying the CPU limits.\n\nThe default value is 'true' if unspecified.", + "type": "boolean" + }, + "cpuCfsQuotaPeriod": { + "description": "Set the CPU CFS quota period value 'cpu.cfs_period_us'.\n\nThe string must be a sequence of decimal numbers, each with optional\nfraction and a unit suffix, such as \"300ms\".\nValid time units are \"ns\", \"us\" (or \"µs\"), \"ms\", \"s\", \"m\", \"h\".\nThe value must be a positive duration.", + "type": "string" + }, + "cpuManagerPolicy": { + "description": "Control the CPU management policy on the node.\nSee\nhttps://kubernetes.io/docs/tasks/administer-cluster/cpu-management-policies/\n\nThe following values are allowed.\n - \"none\": the default, which represents the existing scheduling behavior.\n - \"static\": allows pods with certain resource characteristics to be\n granted increased CPU affinity and exclusivity on the node.", + "type": "string" + } + }, + "type": "object" + }, "NodeManagement": { "description": "NodeManagement defines the set of node management services turned on for the\nnode pool.", "id": "NodeManagement", @@ -4063,7 +4104,7 @@ "description": "The node configuration of the pool." }, "initialNodeCount": { - "description": "The initial node count for the pool. You must ensure that your\nCompute Engine \u003ca href=\"/compute/docs/resource-quotas\"\u003eresource quota\u003c/a\u003e\nis sufficient for this number of instances. You must also have available\nfirewall and routes quota.", + "description": "The initial node count for the pool. You must ensure that your\nCompute Engine [resource quota](https://cloud.google.com/compute/quotas)\nis sufficient for this number of instances. You must also have available\nfirewall and routes quota.", "format": "int32", "type": "integer" }, @@ -4432,7 +4473,7 @@ "type": "object" }, "ReleaseChannel": { - "description": "ReleaseChannel indicates which release channel a cluster is\nsubscribed to. Release channels are arranged in order of risk and\nfrequency of updates.\n\nWhen a cluster is subscribed to a release channel, Google maintains\nboth the master version and the node version. Node auto-upgrade\ndefaults to true and cannot be disabled. Updates to version related\nfields (e.g. current_master_version) return an error.", + "description": "ReleaseChannel indicates which release channel a cluster is\nsubscribed to. Release channels are arranged in order of risk.\n\nWhen a cluster is subscribed to a release channel, Google maintains\nboth the master version and the node version. Node auto-upgrade\ndefaults to true and cannot be disabled.", "id": "ReleaseChannel", "properties": { "channel": { @@ -4445,9 +4486,9 @@ ], "enumDescriptions": [ "No channel specified.", - "RAPID channel is offered on an early access basis for customers who want\nto test new releases before they are qualified for production use or\ngeneral availability. New upgrades will occur roughly weekly.\n\nWARNING: Versions available in the RAPID Channel may be subject to\nunresolved issues with no known workaround and are not for use with\nproduction workloads or subject to any SLAs.", - "Clusters subscribed to REGULAR receive versions that are considered GA\nquality. REGULAR is intended for production users who want to take\nadvantage of new features. New upgrades will occur roughly every few\nweeks.", - "Clusters subscribed to STABLE receive versions that are known to be\nstable and reliable in production. STABLE is intended for production\nusers who need stability above all else, or for whom frequent upgrades\nare too risky. New upgrades will occur roughly every few months." + "RAPID channel is offered on an early access basis for customers who want\nto test new releases.\n\nWARNING: Versions available in the RAPID Channel may be subject to\nunresolved issues with no known workaround and are not subject to any\nSLAs.", + "Clusters subscribed to REGULAR receive versions that are considered GA\nquality. REGULAR is intended for production users who want to take\nadvantage of new features.", + "Clusters subscribed to STABLE receive versions that are known to be\nstable and reliable in production." ], "type": "string" } @@ -4459,7 +4500,7 @@ "id": "ReleaseChannelConfig", "properties": { "availableVersions": { - "description": "List of available versions for the release channel.", + "description": "Deprecated.\nThis field has been deprecated and replaced with the valid_versions\nfield.", "items": { "$ref": "AvailableVersion" }, @@ -4475,15 +4516,22 @@ ], "enumDescriptions": [ "No channel specified.", - "RAPID channel is offered on an early access basis for customers who want\nto test new releases before they are qualified for production use or\ngeneral availability. New upgrades will occur roughly weekly.\n\nWARNING: Versions available in the RAPID Channel may be subject to\nunresolved issues with no known workaround and are not for use with\nproduction workloads or subject to any SLAs.", - "Clusters subscribed to REGULAR receive versions that are considered GA\nquality. REGULAR is intended for production users who want to take\nadvantage of new features. New upgrades will occur roughly every few\nweeks.", - "Clusters subscribed to STABLE receive versions that are known to be\nstable and reliable in production. STABLE is intended for production\nusers who need stability above all else, or for whom frequent upgrades\nare too risky. New upgrades will occur roughly every few months." + "RAPID channel is offered on an early access basis for customers who want\nto test new releases.\n\nWARNING: Versions available in the RAPID Channel may be subject to\nunresolved issues with no known workaround and are not subject to any\nSLAs.", + "Clusters subscribed to REGULAR receive versions that are considered GA\nquality. REGULAR is intended for production users who want to take\nadvantage of new features.", + "Clusters subscribed to STABLE receive versions that are known to be\nstable and reliable in production." ], "type": "string" }, "defaultVersion": { "description": "The default version for newly created clusters on the channel.", "type": "string" + }, + "validVersions": { + "description": "List of valid versions for the channel.", + "items": { + "type": "string" + }, + "type": "array" } }, "type": "object" @@ -4639,14 +4687,14 @@ "type": "array" }, "validMasterVersions": { - "description": "List of valid master versions.", + "description": "List of valid master versions, in descending order.", "items": { "type": "string" }, "type": "array" }, "validNodeVersions": { - "description": "List of valid node upgrade target versions.", + "description": "List of valid node upgrade target versions, in descending order.", "items": { "type": "string" }, @@ -5204,6 +5252,14 @@ "description": "Required. The desired image type for the node pool.", "type": "string" }, + "kubeletConfig": { + "$ref": "NodeKubeletConfig", + "description": "Node kubelet configs." + }, + "linuxNodeConfig": { + "$ref": "LinuxNodeConfig", + "description": "Parameters that can be configured on Linux nodes." + }, "locations": { "description": "The desired list of Google Compute Engine\n[zones](https://cloud.google.com/compute/docs/zones#available) in which the\nnode pool's nodes should be located. Changing the locations for a node pool\nwill result in nodes being either created or removed from the node pool,\ndepending on whether locations are being added or removed.", "items": { diff --git a/vendor/google.golang.org/api/container/v1beta1/container-gen.go b/vendor/google.golang.org/api/container/v1beta1/container-gen.go index ce286294432..c55266ce371 100644 --- a/vendor/google.golang.org/api/container/v1beta1/container-gen.go +++ b/vendor/google.golang.org/api/container/v1beta1/container-gen.go @@ -75,6 +75,7 @@ const apiId = "container:v1beta1" const apiName = "container" const apiVersion = "v1beta1" const basePath = "https://container.googleapis.com/" +const mtlsBasePath = "https://container.mtls.googleapis.com/" // OAuth2 scopes used by this API. const ( @@ -90,6 +91,7 @@ func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, err // NOTE: prepend, so we don't override user-specified scopes. opts = append([]option.ClientOption{scopesOption}, opts...) opts = append(opts, internaloption.WithDefaultEndpoint(basePath)) + opts = append(opts, internaloption.WithDefaultMTLSEndpoint(mtlsBasePath)) client, endpoint, err := htransport.NewClient(ctx, opts...) if err != nil { return nil, err @@ -481,16 +483,14 @@ func (s *AutoUpgradeOptions) MarshalJSON() ([]byte, error) { // contains defaults for a node pool created // by NAP. type AutoprovisioningNodePoolDefaults struct { - // Management: Specifies the node management options for NAP created - // node-pools. + // Management: NodeManagement configuration for this NodePool. Management *NodeManagement `json:"management,omitempty"` - // MinCpuPlatform: Minimum CPU platform to be used for NAP created node - // pools. - // The instance may be scheduled on the specified or newer CPU - // platform. - // Applicable values are the friendly names of CPU platforms, such - // as + // MinCpuPlatform: Minimum CPU platform to be used by this instance. The + // instance may be + // scheduled on the specified or newer CPU platform. Applicable values + // are the + // friendly names of CPU platforms, such as // minCpuPlatform: "Intel Haswell" // or // minCpuPlatform: "Intel Sandy Bridge". For @@ -499,18 +499,44 @@ type AutoprovisioningNodePoolDefaults struct { // CPU // platform](https://cloud.google.com/compute/docs/instances/specify- // min-cpu-platform) - // To unset the min cpu platform field pass "automatic" as field value. + // To unset the min cpu platform field pass "automatic" + // as field value. MinCpuPlatform string `json:"minCpuPlatform,omitempty"` - // OauthScopes: Scopes that are used by NAP when creating node pools. + // OauthScopes: The set of Google API scopes to be made available on all + // of the + // node VMs under the "default" service account. + // + // The following scopes are recommended, but not required, and by + // default are + // not included: + // + // * `https://www.googleapis.com/auth/compute` is required for + // mounting + // persistent storage on your nodes. + // * `https://www.googleapis.com/auth/devstorage.read_only` is required + // for + // communicating with **gcr.io** + // (the [Google + // Container + // Registry](https://cloud.google.com/container-registry/)). + // + // I + // f unspecified, no scopes are added, unless Cloud Logging or + // Cloud + // Monitoring are enabled, in which case their required scopes will be + // added. OauthScopes []string `json:"oauthScopes,omitempty"` // ServiceAccount: The Google Cloud Platform Service Account to be used // by the node VMs. + // Specify the email address of the Service Account; otherwise, if no + // Service + // Account is specified, the "default" service account is used. ServiceAccount string `json:"serviceAccount,omitempty"` - // UpgradeSettings: Specifies the upgrade settings for NAP created node - // pools + // UpgradeSettings: Upgrade settings control disruption and speed of the + // upgrade. UpgradeSettings *UpgradeSettings `json:"upgradeSettings,omitempty"` // ForceSendFields is a list of field names (e.g. "Management") to @@ -536,9 +562,7 @@ func (s *AutoprovisioningNodePoolDefaults) MarshalJSON() ([]byte, error) { return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) } -// AvailableVersion: AvailableVersion is an additional Kubernetes -// versions offered -// to users who subscribed to the release channel. +// AvailableVersion: Deprecated. type AvailableVersion struct { // Reason: Reason for availability. Reason string `json:"reason,omitempty"` @@ -896,8 +920,8 @@ type Cluster struct { // InitialNodeCount: The number of nodes to create in this cluster. You // must ensure that your - // Compute Engine resource - // quota + // Compute Engine [resource + // quota](https://cloud.google.com/compute/quotas) // is sufficient for this number of instances. You must also have // available // firewall and routes quota. @@ -1611,7 +1635,7 @@ type CreateClusterRequest struct { // Cluster: Required. A // [cluster // resource](https://cloud.google.com/container-engine/reference - // /rest/v1beta1/projects.zones.clusters) + // /rest/v1beta1/projects.locations.clusters) Cluster *Cluster `json:"cluster,omitempty"` // Parent: The parent (project and location) where the cluster will be @@ -2518,6 +2542,51 @@ func (s *LegacyAbac) MarshalJSON() ([]byte, error) { return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) } +// LinuxNodeConfig: Parameters that can be configured on Linux nodes. +type LinuxNodeConfig struct { + // Sysctls: The Linux kernel parameters to be applied to the nodes and + // all pods running + // on the nodes. + // + // The following parameters are + // supported. + // + // net.core.netdev_max_backlog + // net.core.rmem_max + // net.core.wme + // m_default + // net.core.wmem_max + // net.core.optmem_max + // net.core.somaxconn + // net + // .ipv4.tcp_rmem + // net.ipv4.tcp_wmem + // net.ipv4.tcp_tw_reuse + Sysctls map[string]string `json:"sysctls,omitempty"` + + // ForceSendFields is a list of field names (e.g. "Sysctls") to + // unconditionally include in API requests. By default, fields with + // empty values are omitted from API requests. However, any non-pointer, + // non-interface field appearing in ForceSendFields will be sent to the + // server regardless of whether the field is empty or not. This may be + // used to include empty fields in Patch requests. + ForceSendFields []string `json:"-"` + + // NullFields is a list of field names (e.g. "Sysctls") to include in + // API requests with the JSON null value. By default, fields with empty + // values are omitted from API requests. However, any field with an + // empty value appearing in NullFields will be sent to the server as + // null. It is an error if a field in this list has a non-empty value. + // This may be used to include null fields in Patch requests. + NullFields []string `json:"-"` +} + +func (s *LinuxNodeConfig) MarshalJSON() ([]byte, error) { + type NoMethod LinuxNodeConfig + raw := NoMethod(*s) + return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) +} + // ListClustersResponse: ListClustersResponse is the result of // ListClustersRequest. type ListClustersResponse struct { @@ -3208,6 +3277,9 @@ type NodeConfig struct { // the latest version of it will be used. ImageType string `json:"imageType,omitempty"` + // KubeletConfig: Node kubelet configs. + KubeletConfig *NodeKubeletConfig `json:"kubeletConfig,omitempty"` + // Labels: The map of Kubernetes labels (key/value pairs) to be applied // to each node. // These will added in addition to any default label(s) that @@ -3223,6 +3295,9 @@ type NodeConfig struct { // /labels/ Labels map[string]string `json:"labels,omitempty"` + // LinuxNodeConfig: Parameters that can be configured on Linux nodes. + LinuxNodeConfig *LinuxNodeConfig `json:"linuxNodeConfig,omitempty"` + // LocalSsdCount: The number of local SSD disks to be attached to the // node. // @@ -3397,6 +3472,75 @@ func (s *NodeConfig) MarshalJSON() ([]byte, error) { return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) } +// NodeKubeletConfig: Node kubelet configs. +type NodeKubeletConfig struct { + // CpuCfsQuota: Enable CPU CFS quota enforcement for containers that + // specify CPU limits. + // + // If this option is enabled, kubelet uses CFS + // quota + // (https://www.kernel.org/doc/Documentation/scheduler/sched-bwc.tx + // t) to + // enforce container CPU limits. Otherwise, CPU limits will not be + // enforced at + // all. + // + // Disable this option to mitigate CPU throttling problems while still + // having + // your pods to be in Guaranteed QoS class by specifying the CPU + // limits. + // + // The default value is 'true' if unspecified. + CpuCfsQuota bool `json:"cpuCfsQuota,omitempty"` + + // CpuCfsQuotaPeriod: Set the CPU CFS quota period value + // 'cpu.cfs_period_us'. + // + // The string must be a sequence of decimal numbers, each with + // optional + // fraction and a unit suffix, such as "300ms". + // Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h". + // The value must be a positive duration. + CpuCfsQuotaPeriod string `json:"cpuCfsQuotaPeriod,omitempty"` + + // CpuManagerPolicy: Control the CPU management policy on the + // node. + // See + // https://kubernetes.io/docs/tasks/administer-cluster/cpu-mana + // gement-policies/ + // + // The following values are allowed. + // - "none": the default, which represents the existing scheduling + // behavior. + // - "static": allows pods with certain resource characteristics to + // be + // granted increased CPU affinity and exclusivity on the + // node. + CpuManagerPolicy string `json:"cpuManagerPolicy,omitempty"` + + // ForceSendFields is a list of field names (e.g. "CpuCfsQuota") to + // unconditionally include in API requests. By default, fields with + // empty values are omitted from API requests. However, any non-pointer, + // non-interface field appearing in ForceSendFields will be sent to the + // server regardless of whether the field is empty or not. This may be + // used to include empty fields in Patch requests. + ForceSendFields []string `json:"-"` + + // NullFields is a list of field names (e.g. "CpuCfsQuota") to include + // in API requests with the JSON null value. By default, fields with + // empty values are omitted from API requests. However, any field with + // an empty value appearing in NullFields will be sent to the server as + // null. It is an error if a field in this list has a non-empty value. + // This may be used to include null fields in Patch requests. + NullFields []string `json:"-"` +} + +func (s *NodeKubeletConfig) MarshalJSON() ([]byte, error) { + type NoMethod NodeKubeletConfig + raw := NoMethod(*s) + return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) +} + // NodeManagement: NodeManagement defines the set of node management // services turned on for the // node pool. @@ -3458,8 +3602,8 @@ type NodePool struct { // InitialNodeCount: The initial node count for the pool. You must // ensure that your - // Compute Engine resource - // quota + // Compute Engine [resource + // quota](https://cloud.google.com/compute/quotas) // is sufficient for this number of instances. You must also have // available // firewall and routes quota. @@ -4015,17 +4159,13 @@ func (s *RecurringTimeWindow) MarshalJSON() ([]byte, error) { // ReleaseChannel: ReleaseChannel indicates which release channel a // cluster is -// subscribed to. Release channels are arranged in order of risk -// and -// frequency of updates. +// subscribed to. Release channels are arranged in order of risk. // // When a cluster is subscribed to a release channel, Google // maintains // both the master version and the node version. Node // auto-upgrade -// defaults to true and cannot be disabled. Updates to version -// related -// fields (e.g. current_master_version) return an error. +// defaults to true and cannot be disabled. type ReleaseChannel struct { // Channel: channel specifies which release channel the cluster is // subscribed to. @@ -4034,30 +4174,21 @@ type ReleaseChannel struct { // "UNSPECIFIED" - No channel specified. // "RAPID" - RAPID channel is offered on an early access basis for // customers who want - // to test new releases before they are qualified for production use - // or - // general availability. New upgrades will occur roughly - // weekly. + // to test new releases. // // WARNING: Versions available in the RAPID Channel may be subject // to - // unresolved issues with no known workaround and are not for use - // with - // production workloads or subject to any SLAs. + // unresolved issues with no known workaround and are not subject to + // any + // SLAs. // "REGULAR" - Clusters subscribed to REGULAR receive versions that // are considered GA // quality. REGULAR is intended for production users who want to // take - // advantage of new features. New upgrades will occur roughly every - // few - // weeks. + // advantage of new features. // "STABLE" - Clusters subscribed to STABLE receive versions that are // known to be - // stable and reliable in production. STABLE is intended for - // production - // users who need stability above all else, or for whom frequent - // upgrades - // are too risky. New upgrades will occur roughly every few months. + // stable and reliable in production. Channel string `json:"channel,omitempty"` // ForceSendFields is a list of field names (e.g. "Channel") to @@ -4086,8 +4217,10 @@ func (s *ReleaseChannel) MarshalJSON() ([]byte, error) { // ReleaseChannelConfig: ReleaseChannelConfig exposes configuration for // a release channel. type ReleaseChannelConfig struct { - // AvailableVersions: List of available versions for the release - // channel. + // AvailableVersions: Deprecated. + // This field has been deprecated and replaced with the + // valid_versions + // field. AvailableVersions []*AvailableVersion `json:"availableVersions,omitempty"` // Channel: The release channel this configuration applies to. @@ -4096,36 +4229,30 @@ type ReleaseChannelConfig struct { // "UNSPECIFIED" - No channel specified. // "RAPID" - RAPID channel is offered on an early access basis for // customers who want - // to test new releases before they are qualified for production use - // or - // general availability. New upgrades will occur roughly - // weekly. + // to test new releases. // // WARNING: Versions available in the RAPID Channel may be subject // to - // unresolved issues with no known workaround and are not for use - // with - // production workloads or subject to any SLAs. + // unresolved issues with no known workaround and are not subject to + // any + // SLAs. // "REGULAR" - Clusters subscribed to REGULAR receive versions that // are considered GA // quality. REGULAR is intended for production users who want to // take - // advantage of new features. New upgrades will occur roughly every - // few - // weeks. + // advantage of new features. // "STABLE" - Clusters subscribed to STABLE receive versions that are // known to be - // stable and reliable in production. STABLE is intended for - // production - // users who need stability above all else, or for whom frequent - // upgrades - // are too risky. New upgrades will occur roughly every few months. + // stable and reliable in production. Channel string `json:"channel,omitempty"` // DefaultVersion: The default version for newly created clusters on the // channel. DefaultVersion string `json:"defaultVersion,omitempty"` + // ValidVersions: List of valid versions for the channel. + ValidVersions []string `json:"validVersions,omitempty"` + // ForceSendFields is a list of field names (e.g. "AvailableVersions") // to unconditionally include in API requests. By default, fields with // empty values are omitted from API requests. However, any non-pointer, @@ -4395,10 +4522,12 @@ type ServerConfig struct { // ValidImageTypes: List of valid image types. ValidImageTypes []string `json:"validImageTypes,omitempty"` - // ValidMasterVersions: List of valid master versions. + // ValidMasterVersions: List of valid master versions, in descending + // order. ValidMasterVersions []string `json:"validMasterVersions,omitempty"` - // ValidNodeVersions: List of valid node upgrade target versions. + // ValidNodeVersions: List of valid node upgrade target versions, in + // descending order. ValidNodeVersions []string `json:"validNodeVersions,omitempty"` // ServerResponse contains the HTTP response code and headers from the @@ -5579,6 +5708,12 @@ type UpdateNodePoolRequest struct { // ImageType: Required. The desired image type for the node pool. ImageType string `json:"imageType,omitempty"` + // KubeletConfig: Node kubelet configs. + KubeletConfig *NodeKubeletConfig `json:"kubeletConfig,omitempty"` + + // LinuxNodeConfig: Parameters that can be configured on Linux nodes. + LinuxNodeConfig *LinuxNodeConfig `json:"linuxNodeConfig,omitempty"` + // Locations: The desired list of Google Compute // Engine // [zones](https://cloud.google.com/compute/docs/zones#available) in @@ -6076,7 +6211,7 @@ func (c *ProjectsAggregatedUsableSubnetworksListCall) Header() http.Header { func (c *ProjectsAggregatedUsableSubnetworksListCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -6282,7 +6417,7 @@ func (c *ProjectsLocationsGetServerConfigCall) Header() http.Header { func (c *ProjectsLocationsGetServerConfigCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -6436,7 +6571,7 @@ func (c *ProjectsLocationsListCall) Header() http.Header { func (c *ProjectsLocationsListCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -6571,7 +6706,7 @@ func (c *ProjectsLocationsClustersCompleteIpRotationCall) Header() http.Header { func (c *ProjectsLocationsClustersCompleteIpRotationCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -6729,7 +6864,7 @@ func (c *ProjectsLocationsClustersCreateCall) Header() http.Header { func (c *ProjectsLocationsClustersCreateCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -6910,7 +7045,7 @@ func (c *ProjectsLocationsClustersDeleteCall) Header() http.Header { func (c *ProjectsLocationsClustersDeleteCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -7098,7 +7233,7 @@ func (c *ProjectsLocationsClustersGetCall) Header() http.Header { func (c *ProjectsLocationsClustersGetCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -7262,7 +7397,7 @@ func (c *ProjectsLocationsClustersGetJwksCall) Header() http.Header { func (c *ProjectsLocationsClustersGetJwksCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -7429,7 +7564,7 @@ func (c *ProjectsLocationsClustersListCall) Header() http.Header { func (c *ProjectsLocationsClustersListCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -7574,7 +7709,7 @@ func (c *ProjectsLocationsClustersSetAddonsCall) Header() http.Header { func (c *ProjectsLocationsClustersSetAddonsCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -7715,7 +7850,7 @@ func (c *ProjectsLocationsClustersSetLegacyAbacCall) Header() http.Header { func (c *ProjectsLocationsClustersSetLegacyAbacCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -7861,7 +7996,7 @@ func (c *ProjectsLocationsClustersSetLocationsCall) Header() http.Header { func (c *ProjectsLocationsClustersSetLocationsCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -8001,7 +8136,7 @@ func (c *ProjectsLocationsClustersSetLoggingCall) Header() http.Header { func (c *ProjectsLocationsClustersSetLoggingCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -8141,7 +8276,7 @@ func (c *ProjectsLocationsClustersSetMaintenancePolicyCall) Header() http.Header func (c *ProjectsLocationsClustersSetMaintenancePolicyCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -8285,7 +8420,7 @@ func (c *ProjectsLocationsClustersSetMasterAuthCall) Header() http.Header { func (c *ProjectsLocationsClustersSetMasterAuthCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -8425,7 +8560,7 @@ func (c *ProjectsLocationsClustersSetMonitoringCall) Header() http.Header { func (c *ProjectsLocationsClustersSetMonitoringCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -8565,7 +8700,7 @@ func (c *ProjectsLocationsClustersSetNetworkPolicyCall) Header() http.Header { func (c *ProjectsLocationsClustersSetNetworkPolicyCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -8705,7 +8840,7 @@ func (c *ProjectsLocationsClustersSetResourceLabelsCall) Header() http.Header { func (c *ProjectsLocationsClustersSetResourceLabelsCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -8845,7 +8980,7 @@ func (c *ProjectsLocationsClustersStartIpRotationCall) Header() http.Header { func (c *ProjectsLocationsClustersStartIpRotationCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -8985,7 +9120,7 @@ func (c *ProjectsLocationsClustersUpdateCall) Header() http.Header { func (c *ProjectsLocationsClustersUpdateCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -9125,7 +9260,7 @@ func (c *ProjectsLocationsClustersUpdateMasterCall) Header() http.Header { func (c *ProjectsLocationsClustersUpdateMasterCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -9265,7 +9400,7 @@ func (c *ProjectsLocationsClustersNodePoolsCreateCall) Header() http.Header { func (c *ProjectsLocationsClustersNodePoolsCreateCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -9443,7 +9578,7 @@ func (c *ProjectsLocationsClustersNodePoolsDeleteCall) Header() http.Header { func (c *ProjectsLocationsClustersNodePoolsDeleteCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -9644,7 +9779,7 @@ func (c *ProjectsLocationsClustersNodePoolsGetCall) Header() http.Header { func (c *ProjectsLocationsClustersNodePoolsGetCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -9840,7 +9975,7 @@ func (c *ProjectsLocationsClustersNodePoolsListCall) Header() http.Header { func (c *ProjectsLocationsClustersNodePoolsListCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -9992,7 +10127,7 @@ func (c *ProjectsLocationsClustersNodePoolsRollbackCall) Header() http.Header { func (c *ProjectsLocationsClustersNodePoolsRollbackCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -10133,7 +10268,7 @@ func (c *ProjectsLocationsClustersNodePoolsSetAutoscalingCall) Header() http.Hea func (c *ProjectsLocationsClustersNodePoolsSetAutoscalingCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -10273,7 +10408,7 @@ func (c *ProjectsLocationsClustersNodePoolsSetManagementCall) Header() http.Head func (c *ProjectsLocationsClustersNodePoolsSetManagementCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -10413,7 +10548,7 @@ func (c *ProjectsLocationsClustersNodePoolsSetSizeCall) Header() http.Header { func (c *ProjectsLocationsClustersNodePoolsSetSizeCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -10554,7 +10689,7 @@ func (c *ProjectsLocationsClustersNodePoolsUpdateCall) Header() http.Header { func (c *ProjectsLocationsClustersNodePoolsUpdateCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -10713,7 +10848,7 @@ func (c *ProjectsLocationsClustersWellKnownGetOpenidConfigurationCall) Header() func (c *ProjectsLocationsClustersWellKnownGetOpenidConfigurationCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -10845,7 +10980,7 @@ func (c *ProjectsLocationsOperationsCancelCall) Header() http.Header { func (c *ProjectsLocationsOperationsCancelCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -11026,7 +11161,7 @@ func (c *ProjectsLocationsOperationsGetCall) Header() http.Header { func (c *ProjectsLocationsOperationsGetCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -11210,7 +11345,7 @@ func (c *ProjectsLocationsOperationsListCall) Header() http.Header { func (c *ProjectsLocationsOperationsListCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -11375,7 +11510,7 @@ func (c *ProjectsZonesGetServerconfigCall) Header() http.Header { func (c *ProjectsZonesGetServerconfigCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -11526,7 +11661,7 @@ func (c *ProjectsZonesClustersAddonsCall) Header() http.Header { func (c *ProjectsZonesClustersAddonsCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -11685,7 +11820,7 @@ func (c *ProjectsZonesClustersCompleteIpRotationCall) Header() http.Header { func (c *ProjectsZonesClustersCompleteIpRotationCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -11860,7 +11995,7 @@ func (c *ProjectsZonesClustersCreateCall) Header() http.Header { func (c *ProjectsZonesClustersCreateCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -12028,7 +12163,7 @@ func (c *ProjectsZonesClustersDeleteCall) Header() http.Header { func (c *ProjectsZonesClustersDeleteCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -12201,7 +12336,7 @@ func (c *ProjectsZonesClustersGetCall) Header() http.Header { func (c *ProjectsZonesClustersGetCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -12361,7 +12496,7 @@ func (c *ProjectsZonesClustersLegacyAbacCall) Header() http.Header { func (c *ProjectsZonesClustersLegacyAbacCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -12538,7 +12673,7 @@ func (c *ProjectsZonesClustersListCall) Header() http.Header { func (c *ProjectsZonesClustersListCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -12695,7 +12830,7 @@ func (c *ProjectsZonesClustersLocationsCall) Header() http.Header { func (c *ProjectsZonesClustersLocationsCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -12854,7 +12989,7 @@ func (c *ProjectsZonesClustersLoggingCall) Header() http.Header { func (c *ProjectsZonesClustersLoggingCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -13013,7 +13148,7 @@ func (c *ProjectsZonesClustersMasterCall) Header() http.Header { func (c *ProjectsZonesClustersMasterCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -13172,7 +13307,7 @@ func (c *ProjectsZonesClustersMonitoringCall) Header() http.Header { func (c *ProjectsZonesClustersMonitoringCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -13331,7 +13466,7 @@ func (c *ProjectsZonesClustersResourceLabelsCall) Header() http.Header { func (c *ProjectsZonesClustersResourceLabelsCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -13490,7 +13625,7 @@ func (c *ProjectsZonesClustersSetMaintenancePolicyCall) Header() http.Header { func (c *ProjectsZonesClustersSetMaintenancePolicyCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -13653,7 +13788,7 @@ func (c *ProjectsZonesClustersSetMasterAuthCall) Header() http.Header { func (c *ProjectsZonesClustersSetMasterAuthCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -13812,7 +13947,7 @@ func (c *ProjectsZonesClustersSetNetworkPolicyCall) Header() http.Header { func (c *ProjectsZonesClustersSetNetworkPolicyCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -13971,7 +14106,7 @@ func (c *ProjectsZonesClustersStartIpRotationCall) Header() http.Header { func (c *ProjectsZonesClustersStartIpRotationCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -14130,7 +14265,7 @@ func (c *ProjectsZonesClustersUpdateCall) Header() http.Header { func (c *ProjectsZonesClustersUpdateCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -14291,7 +14426,7 @@ func (c *ProjectsZonesClustersNodePoolsAutoscalingCall) Header() http.Header { func (c *ProjectsZonesClustersNodePoolsAutoscalingCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -14458,7 +14593,7 @@ func (c *ProjectsZonesClustersNodePoolsCreateCall) Header() http.Header { func (c *ProjectsZonesClustersNodePoolsCreateCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -14627,7 +14762,7 @@ func (c *ProjectsZonesClustersNodePoolsDeleteCall) Header() http.Header { func (c *ProjectsZonesClustersNodePoolsDeleteCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -14812,7 +14947,7 @@ func (c *ProjectsZonesClustersNodePoolsGetCall) Header() http.Header { func (c *ProjectsZonesClustersNodePoolsGetCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -14996,7 +15131,7 @@ func (c *ProjectsZonesClustersNodePoolsListCall) Header() http.Header { func (c *ProjectsZonesClustersNodePoolsListCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -15159,7 +15294,7 @@ func (c *ProjectsZonesClustersNodePoolsRollbackCall) Header() http.Header { func (c *ProjectsZonesClustersNodePoolsRollbackCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -15328,7 +15463,7 @@ func (c *ProjectsZonesClustersNodePoolsSetManagementCall) Header() http.Header { func (c *ProjectsZonesClustersNodePoolsSetManagementCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -15497,7 +15632,7 @@ func (c *ProjectsZonesClustersNodePoolsSetSizeCall) Header() http.Header { func (c *ProjectsZonesClustersNodePoolsSetSizeCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -15667,7 +15802,7 @@ func (c *ProjectsZonesClustersNodePoolsUpdateCall) Header() http.Header { func (c *ProjectsZonesClustersNodePoolsUpdateCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -15834,7 +15969,7 @@ func (c *ProjectsZonesOperationsCancelCall) Header() http.Header { func (c *ProjectsZonesOperationsCancelCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -16010,7 +16145,7 @@ func (c *ProjectsZonesOperationsGetCall) Header() http.Header { func (c *ProjectsZonesOperationsGetCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -16186,7 +16321,7 @@ func (c *ProjectsZonesOperationsListCall) Header() http.Header { func (c *ProjectsZonesOperationsListCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } diff --git a/vendor/google.golang.org/api/internal/settings.go b/vendor/google.golang.org/api/internal/settings.go index 0d8210baa7b..f435519decf 100644 --- a/vendor/google.golang.org/api/internal/settings.go +++ b/vendor/google.golang.org/api/internal/settings.go @@ -18,25 +18,26 @@ import ( // DialSettings holds information needed to establish a connection with a // Google API service. type DialSettings struct { - Endpoint string - DefaultEndpoint string - Scopes []string - TokenSource oauth2.TokenSource - Credentials *google.Credentials - CredentialsFile string // if set, Token Source is ignored. - CredentialsJSON []byte - UserAgent string - APIKey string - Audiences []string - HTTPClient *http.Client - GRPCDialOpts []grpc.DialOption - GRPCConn *grpc.ClientConn - GRPCConnPool ConnPool - GRPCConnPoolSize int - NoAuth bool - TelemetryDisabled bool - ClientCertSource func(*tls.CertificateRequestInfo) (*tls.Certificate, error) - CustomClaims map[string]interface{} + Endpoint string + DefaultEndpoint string + DefaultMTLSEndpoint string + Scopes []string + TokenSource oauth2.TokenSource + Credentials *google.Credentials + CredentialsFile string // if set, Token Source is ignored. + CredentialsJSON []byte + UserAgent string + APIKey string + Audiences []string + HTTPClient *http.Client + GRPCDialOpts []grpc.DialOption + GRPCConn *grpc.ClientConn + GRPCConnPool ConnPool + GRPCConnPoolSize int + NoAuth bool + TelemetryDisabled bool + ClientCertSource func(*tls.CertificateRequestInfo) (*tls.Certificate, error) + CustomClaims map[string]interface{} // Google API system parameters. For more information please read: // https://cloud.google.com/apis/docs/system-parameters diff --git a/vendor/google.golang.org/api/option/internaloption/internaloption.go b/vendor/google.golang.org/api/option/internaloption/internaloption.go index 48121e42f90..ff5b530cfe0 100644 --- a/vendor/google.golang.org/api/option/internaloption/internaloption.go +++ b/vendor/google.golang.org/api/option/internaloption/internaloption.go @@ -24,3 +24,17 @@ func (o defaultEndpointOption) Apply(settings *internal.DialSettings) { func WithDefaultEndpoint(url string) option.ClientOption { return defaultEndpointOption(url) } + +type defaultMTLSEndpointOption string + +func (o defaultMTLSEndpointOption) Apply(settings *internal.DialSettings) { + settings.DefaultMTLSEndpoint = string(o) +} + +// WithDefaultMTLSEndpoint is an option that indicates the default mTLS endpoint. +// +// It should only be used internally by generated clients. +// +func WithDefaultMTLSEndpoint(url string) option.ClientOption { + return defaultMTLSEndpointOption(url) +} diff --git a/vendor/google.golang.org/api/storage/v1/storage-api.json b/vendor/google.golang.org/api/storage/v1/storage-api.json index 8bb2fa6db67..e78776b2be8 100644 --- a/vendor/google.golang.org/api/storage/v1/storage-api.json +++ b/vendor/google.golang.org/api/storage/v1/storage-api.json @@ -26,7 +26,7 @@ "description": "Stores and retrieves potentially large, immutable data objects.", "discoveryVersion": "v1", "documentationLink": "https://developers.google.com/storage/docs/json_api/", - "etag": "\"u9GIe6H63LSGq-9_t39K2Zx_EAc/SMGMLKKvE-TZrla7d9TA_SDVTI0\"", + "etag": "\"u9GIe6H63LSGq-9_t39K2Zx_EAc/5Ir-e9ddNPcr5skzvRsSnJlvTYg\"", "icons": { "x16": "https://www.google.com/images/icons/product/cloud_storage-16.png", "x32": "https://www.google.com/images/icons/product/cloud_storage-32.png" @@ -1781,7 +1781,7 @@ "type": "string" }, "kmsKeyName": { - "description": "Resource name of the Cloud KMS key, of the form projects/my-project/locations/global/keyRings/my-kr/cryptoKeys/my-key, that will be used to encrypt the object. Overrides the object metadata's kms_key_name value, if any.", + "description": "Not currently supported. Specifying the parameter causes the request to fail with status code 400 - Bad Request.", "location": "query", "type": "string" }, @@ -3229,7 +3229,7 @@ } } }, - "revision": "20200430", + "revision": "20200611", "rootUrl": "https://storage.googleapis.com/", "schemas": { "Bucket": { diff --git a/vendor/google.golang.org/api/storage/v1/storage-gen.go b/vendor/google.golang.org/api/storage/v1/storage-gen.go index c47432d3932..dc51a22ede6 100644 --- a/vendor/google.golang.org/api/storage/v1/storage-gen.go +++ b/vendor/google.golang.org/api/storage/v1/storage-gen.go @@ -2442,7 +2442,7 @@ func (c *BucketAccessControlsDeleteCall) Header() http.Header { func (c *BucketAccessControlsDeleteCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -2590,7 +2590,7 @@ func (c *BucketAccessControlsGetCall) Header() http.Header { func (c *BucketAccessControlsGetCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -2757,7 +2757,7 @@ func (c *BucketAccessControlsInsertCall) Header() http.Header { func (c *BucketAccessControlsInsertCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -2930,7 +2930,7 @@ func (c *BucketAccessControlsListCall) Header() http.Header { func (c *BucketAccessControlsListCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -3091,7 +3091,7 @@ func (c *BucketAccessControlsPatchCall) Header() http.Header { func (c *BucketAccessControlsPatchCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -3265,7 +3265,7 @@ func (c *BucketAccessControlsUpdateCall) Header() http.Header { func (c *BucketAccessControlsUpdateCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -3451,7 +3451,7 @@ func (c *BucketsDeleteCall) Header() http.Header { func (c *BucketsDeleteCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -3630,7 +3630,7 @@ func (c *BucketsGetCall) Header() http.Header { func (c *BucketsGetCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -3836,7 +3836,7 @@ func (c *BucketsGetIamPolicyCall) Header() http.Header { func (c *BucketsGetIamPolicyCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -4053,7 +4053,7 @@ func (c *BucketsInsertCall) Header() http.Header { func (c *BucketsInsertCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -4310,7 +4310,7 @@ func (c *BucketsListCall) Header() http.Header { func (c *BucketsListCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -4520,7 +4520,7 @@ func (c *BucketsLockRetentionPolicyCall) Header() http.Header { func (c *BucketsLockRetentionPolicyCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -4755,7 +4755,7 @@ func (c *BucketsPatchCall) Header() http.Header { func (c *BucketsPatchCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -4984,7 +4984,7 @@ func (c *BucketsSetIamPolicyCall) Header() http.Header { func (c *BucketsSetIamPolicyCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -5159,7 +5159,7 @@ func (c *BucketsTestIamPermissionsCall) Header() http.Header { func (c *BucketsTestIamPermissionsCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -5399,7 +5399,7 @@ func (c *BucketsUpdateCall) Header() http.Header { func (c *BucketsUpdateCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -5611,7 +5611,7 @@ func (c *ChannelsStopCall) Header() http.Header { func (c *ChannelsStopCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -5728,7 +5728,7 @@ func (c *DefaultObjectAccessControlsDeleteCall) Header() http.Header { func (c *DefaultObjectAccessControlsDeleteCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -5876,7 +5876,7 @@ func (c *DefaultObjectAccessControlsGetCall) Header() http.Header { func (c *DefaultObjectAccessControlsGetCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -6044,7 +6044,7 @@ func (c *DefaultObjectAccessControlsInsertCall) Header() http.Header { func (c *DefaultObjectAccessControlsInsertCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -6234,7 +6234,7 @@ func (c *DefaultObjectAccessControlsListCall) Header() http.Header { func (c *DefaultObjectAccessControlsListCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -6407,7 +6407,7 @@ func (c *DefaultObjectAccessControlsPatchCall) Header() http.Header { func (c *DefaultObjectAccessControlsPatchCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -6581,7 +6581,7 @@ func (c *DefaultObjectAccessControlsUpdateCall) Header() http.Header { func (c *DefaultObjectAccessControlsUpdateCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -6753,7 +6753,7 @@ func (c *NotificationsDeleteCall) Header() http.Header { func (c *NotificationsDeleteCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -6901,7 +6901,7 @@ func (c *NotificationsGetCall) Header() http.Header { func (c *NotificationsGetCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -7071,7 +7071,7 @@ func (c *NotificationsInsertCall) Header() http.Header { func (c *NotificationsInsertCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -7246,7 +7246,7 @@ func (c *NotificationsListCall) Header() http.Header { func (c *NotificationsListCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -7419,7 +7419,7 @@ func (c *ObjectAccessControlsDeleteCall) Header() http.Header { func (c *ObjectAccessControlsDeleteCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -7591,7 +7591,7 @@ func (c *ObjectAccessControlsGetCall) Header() http.Header { func (c *ObjectAccessControlsGetCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -7782,7 +7782,7 @@ func (c *ObjectAccessControlsInsertCall) Header() http.Header { func (c *ObjectAccessControlsInsertCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -7979,7 +7979,7 @@ func (c *ObjectAccessControlsListCall) Header() http.Header { func (c *ObjectAccessControlsListCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -8164,7 +8164,7 @@ func (c *ObjectAccessControlsPatchCall) Header() http.Header { func (c *ObjectAccessControlsPatchCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -8362,7 +8362,7 @@ func (c *ObjectAccessControlsUpdateCall) Header() http.Header { func (c *ObjectAccessControlsUpdateCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -8547,11 +8547,9 @@ func (c *ObjectsComposeCall) IfMetagenerationMatch(ifMetagenerationMatch int64) return c } -// KmsKeyName sets the optional parameter "kmsKeyName": Resource name of -// the Cloud KMS key, of the form -// projects/my-project/locations/global/keyRings/my-kr/cryptoKeys/my-key, -// that will be used to encrypt the object. Overrides the object -// metadata's kms_key_name value, if any. +// KmsKeyName sets the optional parameter "kmsKeyName": Not currently +// supported. Specifying the parameter causes the request to fail with +// status code 400 - Bad Request. func (c *ObjectsComposeCall) KmsKeyName(kmsKeyName string) *ObjectsComposeCall { c.urlParams_.Set("kmsKeyName", kmsKeyName) return c @@ -8599,7 +8597,7 @@ func (c *ObjectsComposeCall) Header() http.Header { func (c *ObjectsComposeCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -8718,7 +8716,7 @@ func (c *ObjectsComposeCall) Do(opts ...googleapi.CallOption) (*Object, error) { // "type": "string" // }, // "kmsKeyName": { - // "description": "Resource name of the Cloud KMS key, of the form projects/my-project/locations/global/keyRings/my-kr/cryptoKeys/my-key, that will be used to encrypt the object. Overrides the object metadata's kms_key_name value, if any.", + // "description": "Not currently supported. Specifying the parameter causes the request to fail with status code 400 - Bad Request.", // "location": "query", // "type": "string" // }, @@ -8942,7 +8940,7 @@ func (c *ObjectsCopyCall) Header() http.Header { func (c *ObjectsCopyCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -9270,7 +9268,7 @@ func (c *ObjectsDeleteCall) Header() http.Header { func (c *ObjectsDeleteCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -9503,7 +9501,7 @@ func (c *ObjectsGetCall) Header() http.Header { func (c *ObjectsGetCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -9753,7 +9751,7 @@ func (c *ObjectsGetIamPolicyCall) Header() http.Header { func (c *ObjectsGetIamPolicyCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -10070,7 +10068,7 @@ func (c *ObjectsInsertCall) Header() http.Header { func (c *ObjectsInsertCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -10443,7 +10441,7 @@ func (c *ObjectsListCall) Header() http.Header { func (c *ObjectsListCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -10760,7 +10758,7 @@ func (c *ObjectsPatchCall) Header() http.Header { func (c *ObjectsPatchCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -11152,7 +11150,7 @@ func (c *ObjectsRewriteCall) Header() http.Header { func (c *ObjectsRewriteCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -11455,7 +11453,7 @@ func (c *ObjectsSetIamPolicyCall) Header() http.Header { func (c *ObjectsSetIamPolicyCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -11655,7 +11653,7 @@ func (c *ObjectsTestIamPermissionsCall) Header() http.Header { func (c *ObjectsTestIamPermissionsCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -11916,7 +11914,7 @@ func (c *ObjectsUpdateCall) Header() http.Header { func (c *ObjectsUpdateCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -12234,7 +12232,7 @@ func (c *ObjectsWatchAllCall) Header() http.Header { func (c *ObjectsWatchAllCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -12450,7 +12448,7 @@ func (c *ProjectsHmacKeysCreateCall) Header() http.Header { func (c *ProjectsHmacKeysCreateCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -12600,7 +12598,7 @@ func (c *ProjectsHmacKeysDeleteCall) Header() http.Header { func (c *ProjectsHmacKeysDeleteCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -12735,7 +12733,7 @@ func (c *ProjectsHmacKeysGetCall) Header() http.Header { func (c *ProjectsHmacKeysGetCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -12935,7 +12933,7 @@ func (c *ProjectsHmacKeysListCall) Header() http.Header { func (c *ProjectsHmacKeysListCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -13130,7 +13128,7 @@ func (c *ProjectsHmacKeysUpdateCall) Header() http.Header { func (c *ProjectsHmacKeysUpdateCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } @@ -13307,7 +13305,7 @@ func (c *ProjectsServiceAccountGetCall) Header() http.Header { func (c *ProjectsServiceAccountGetCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200617") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") for k, v := range c.header_ { reqHeaders[k] = v } diff --git a/vendor/google.golang.org/api/transport/grpc/dial.go b/vendor/google.golang.org/api/transport/grpc/dial.go index cb73d7eb96e..77ee798e0f7 100644 --- a/vendor/google.golang.org/api/transport/grpc/dial.go +++ b/vendor/google.golang.org/api/transport/grpc/dial.go @@ -184,12 +184,6 @@ func dial(ctx context.Context, insecure bool, o *internal.DialSettings) (*grpc.C grpcOpts = append(grpcOpts, timeoutDialerOption) } - // NOTE(cbro): this is used only by the nightly mtls_smoketest and should - // not otherwise be used. It will be removed or renamed at some point. - if os.Getenv("GOOGLE_API_USE_MTLS") == "always" { - o.Endpoint = generateDefaultMtlsEndpoint(o.Endpoint) - } - return grpc.DialContext(ctx, o.Endpoint, grpcOpts...) } @@ -300,6 +294,13 @@ func processAndValidateOpts(opts []option.ClientOption) (*internal.DialSettings, if err := o.Validate(); err != nil { return nil, err } + + // NOTE(cbro): this is used only by the nightly mtls_smoketest and should + // not otherwise be used. It will be removed or renamed at some point. + if os.Getenv("GOOGLE_API_USE_MTLS") == "always" { + o.Endpoint = generateDefaultMtlsEndpoint(o.Endpoint) + } + return &o, nil } diff --git a/vendor/google.golang.org/api/transport/http/dial.go b/vendor/google.golang.org/api/transport/http/dial.go index 19a4c9a59eb..44503014172 100644 --- a/vendor/google.golang.org/api/transport/http/dial.go +++ b/vendor/google.golang.org/api/transport/http/dial.go @@ -269,7 +269,7 @@ func getEndpoint(settings *internal.DialSettings, clientCertSource cert.Source) if settings.Endpoint == "" { mtlsMode := getMTLSMode() if mtlsMode == mTLSModeAlways || (clientCertSource != nil && mtlsMode == mTLSModeAuto) { - return generateDefaultMtlsEndpoint(settings.DefaultEndpoint), nil + return settings.DefaultMTLSEndpoint, nil } return settings.DefaultEndpoint, nil } @@ -302,26 +302,3 @@ func mergeEndpoints(base, newHost string) (string, error) { u.Host = newHost return u.String(), nil } - -// generateDefaultMtlsEndpoint attempts to derive the mTLS version of the -// defaultEndpoint via regex, and returns defaultEndpoint if unsuccessful. -// -// We need to applying the following 2 transformations: -// 1. pubsub.googleapis.com to pubsub.mtls.googleapis.com -// 2. pubsub.sandbox.googleapis.com to pubsub.mtls.sandbox.googleapis.com -// -// TODO(andyzhao): In the future, the mTLS endpoint will be read from the Discovery Document -// and passed in as defaultMtlsEndpoint instead of generated from defaultEndpoint, -// and this function will be removed. -func generateDefaultMtlsEndpoint(defaultEndpoint string) string { - var domains = []string{ - ".sandbox.googleapis.com", // must come first because .googleapis.com is a substring - ".googleapis.com", - } - for _, domain := range domains { - if strings.Contains(defaultEndpoint, domain) { - return strings.Replace(defaultEndpoint, domain, ".mtls"+domain, -1) - } - } - return defaultEndpoint -} diff --git a/vendor/google.golang.org/genproto/googleapis/devtools/cloudtrace/v2/trace.pb.go b/vendor/google.golang.org/genproto/googleapis/devtools/cloudtrace/v2/trace.pb.go index 7e5c62ed6f7..2882f4f36af 100644 --- a/vendor/google.golang.org/genproto/googleapis/devtools/cloudtrace/v2/trace.pb.go +++ b/vendor/google.golang.org/genproto/googleapis/devtools/cloudtrace/v2/trace.pb.go @@ -1,4 +1,4 @@ -// Copyright 2019 Google LLC. +// Copyright 2020 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -44,6 +44,81 @@ const ( // of the legacy proto package is being used. const _ = proto.ProtoPackageIsVersion4 +// Type of span. Can be used to specify additional relationships between spans +// in addition to a parent/child relationship. +type Span_SpanKind int32 + +const ( + // Unspecified. Do NOT use as default. + // Implementations MAY assume SpanKind.INTERNAL to be default. + Span_SPAN_KIND_UNSPECIFIED Span_SpanKind = 0 + // Indicates that the span is used internally. Default value. + Span_INTERNAL Span_SpanKind = 1 + // Indicates that the span covers server-side handling of an RPC or other + // remote network request. + Span_SERVER Span_SpanKind = 2 + // Indicates that the span covers the client-side wrapper around an RPC or + // other remote request. + Span_CLIENT Span_SpanKind = 3 + // Indicates that the span describes producer sending a message to a broker. + // Unlike client and server, there is no direct critical path latency + // relationship between producer and consumer spans (e.g. publishing a + // message to a pubsub service). + Span_PRODUCER Span_SpanKind = 4 + // Indicates that the span describes consumer receiving a message from a + // broker. Unlike client and server, there is no direct critical path + // latency relationship between producer and consumer spans (e.g. receiving + // a message from a pubsub service subscription). + Span_CONSUMER Span_SpanKind = 5 +) + +// Enum value maps for Span_SpanKind. +var ( + Span_SpanKind_name = map[int32]string{ + 0: "SPAN_KIND_UNSPECIFIED", + 1: "INTERNAL", + 2: "SERVER", + 3: "CLIENT", + 4: "PRODUCER", + 5: "CONSUMER", + } + Span_SpanKind_value = map[string]int32{ + "SPAN_KIND_UNSPECIFIED": 0, + "INTERNAL": 1, + "SERVER": 2, + "CLIENT": 3, + "PRODUCER": 4, + "CONSUMER": 5, + } +) + +func (x Span_SpanKind) Enum() *Span_SpanKind { + p := new(Span_SpanKind) + *p = x + return p +} + +func (x Span_SpanKind) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (Span_SpanKind) Descriptor() protoreflect.EnumDescriptor { + return file_google_devtools_cloudtrace_v2_trace_proto_enumTypes[0].Descriptor() +} + +func (Span_SpanKind) Type() protoreflect.EnumType { + return &file_google_devtools_cloudtrace_v2_trace_proto_enumTypes[0] +} + +func (x Span_SpanKind) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use Span_SpanKind.Descriptor instead. +func (Span_SpanKind) EnumDescriptor() ([]byte, []int) { + return file_google_devtools_cloudtrace_v2_trace_proto_rawDescGZIP(), []int{0, 0} +} + // Indicates whether the message was sent or received. type Span_TimeEvent_MessageEvent_Type int32 @@ -81,11 +156,11 @@ func (x Span_TimeEvent_MessageEvent_Type) String() string { } func (Span_TimeEvent_MessageEvent_Type) Descriptor() protoreflect.EnumDescriptor { - return file_google_devtools_cloudtrace_v2_trace_proto_enumTypes[0].Descriptor() + return file_google_devtools_cloudtrace_v2_trace_proto_enumTypes[1].Descriptor() } func (Span_TimeEvent_MessageEvent_Type) Type() protoreflect.EnumType { - return &file_google_devtools_cloudtrace_v2_trace_proto_enumTypes[0] + return &file_google_devtools_cloudtrace_v2_trace_proto_enumTypes[1] } func (x Span_TimeEvent_MessageEvent_Type) Number() protoreflect.EnumNumber { @@ -135,11 +210,11 @@ func (x Span_Link_Type) String() string { } func (Span_Link_Type) Descriptor() protoreflect.EnumDescriptor { - return file_google_devtools_cloudtrace_v2_trace_proto_enumTypes[1].Descriptor() + return file_google_devtools_cloudtrace_v2_trace_proto_enumTypes[2].Descriptor() } func (Span_Link_Type) Type() protoreflect.EnumType { - return &file_google_devtools_cloudtrace_v2_trace_proto_enumTypes[1] + return &file_google_devtools_cloudtrace_v2_trace_proto_enumTypes[2] } func (x Span_Link_Type) Number() protoreflect.EnumNumber { @@ -162,7 +237,7 @@ type Span struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - // The resource name of the span in the following format: + // Required. The resource name of the span in the following format: // // projects/[PROJECT_ID]/traces/[TRACE_ID]/spans/[SPAN_ID] // @@ -172,12 +247,12 @@ type Span struct { // [SPAN_ID] is a unique identifier for a span within a trace; it // is a 16-character hexadecimal encoding of an 8-byte array. Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` - // The [SPAN_ID] portion of the span's resource name. + // Required. The [SPAN_ID] portion of the span's resource name. SpanId string `protobuf:"bytes,2,opt,name=span_id,json=spanId,proto3" json:"span_id,omitempty"` // The [SPAN_ID] of this span's parent span. If this is a root span, // then this field must be empty. ParentSpanId string `protobuf:"bytes,3,opt,name=parent_span_id,json=parentSpanId,proto3" json:"parent_span_id,omitempty"` - // A description of the span's operation (up to 128 bytes). + // Required. A description of the span's operation (up to 128 bytes). // Stackdriver Trace displays the description in the // Google Cloud Platform Console. // For example, the display name can be a qualified method name or a file name @@ -185,11 +260,11 @@ type Span struct { // the same display name within an application and at the same call point. // This makes it easier to correlate spans in different traces. DisplayName *TruncatableString `protobuf:"bytes,4,opt,name=display_name,json=displayName,proto3" json:"display_name,omitempty"` - // The start time of the span. On the client side, this is the time kept by + // Required. The start time of the span. On the client side, this is the time kept by // the local machine where the span execution starts. On the server side, this // is the time when the server's application handler starts running. StartTime *timestamp.Timestamp `protobuf:"bytes,5,opt,name=start_time,json=startTime,proto3" json:"start_time,omitempty"` - // The end time of the span. On the client side, this is the time kept by + // Required. The end time of the span. On the client side, this is the time kept by // the local machine where the span execution ends. On the server side, this // is the time when the server application handler stops running. EndTime *timestamp.Timestamp `protobuf:"bytes,6,opt,name=end_time,json=endTime,proto3" json:"end_time,omitempty"` @@ -213,6 +288,10 @@ type Span struct { // Optional. The number of child spans that were generated while this span // was active. If set, allows implementation to detect missing child spans. ChildSpanCount *wrappers.Int32Value `protobuf:"bytes,13,opt,name=child_span_count,json=childSpanCount,proto3" json:"child_span_count,omitempty"` + // Optional. Distinguishes between spans generated in a particular context. For example, + // two spans with the same name may be distinguished using `CLIENT` (caller) + // and `SERVER` (callee) to identify an RPC call. + SpanKind Span_SpanKind `protobuf:"varint,14,opt,name=span_kind,json=spanKind,proto3,enum=google.devtools.cloudtrace.v2.Span_SpanKind" json:"span_kind,omitempty"` } func (x *Span) Reset() { @@ -338,6 +417,13 @@ func (x *Span) GetChildSpanCount() *wrappers.Int32Value { return nil } +func (x *Span) GetSpanKind() Span_SpanKind { + if x != nil { + return x.SpanKind + } + return Span_SPAN_KIND_UNSPECIFIED +} + // The allowed types for [VALUE] in a `[KEY]:[VALUE]` attribute. type AttributeValue struct { state protoimpl.MessageState @@ -639,10 +725,9 @@ type Span_Attributes struct { // long. The value can be a string up to 256 bytes, a signed 64-bit integer, // or the Boolean values `true` and `false`. For example: // - // "/instance_id": "my-instance" - // "/http/user_agent": "" - // "/http/request_bytes": 300 - // "abc.com/myattribute": true + // "/instance_id": { "string_value": { "value": "my-instance" } } + // "/http/request_bytes": { "int_value": 300 } + // "abc.com/myattribute": { "bool_value": false } AttributeMap map[string]*AttributeValue `protobuf:"bytes,1,rep,name=attribute_map,json=attributeMap,proto3" json:"attribute_map,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` // The number of attributes that were discarded. Attributes can be discarded // because their keys are too long or because there are too many attributes. @@ -1317,19 +1402,19 @@ var file_google_devtools_cloudtrace_v2_trace_proto_rawDesc = []byte{ 0x73, 0x2f, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x74, 0x72, 0x61, 0x63, 0x65, 0x2f, 0x76, 0x32, 0x2f, 0x74, 0x72, 0x61, 0x63, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x1d, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x64, 0x65, 0x76, 0x74, 0x6f, 0x6f, 0x6c, 0x73, 0x2e, 0x63, 0x6c, 0x6f, - 0x75, 0x64, 0x74, 0x72, 0x61, 0x63, 0x65, 0x2e, 0x76, 0x32, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, - 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, - 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, - 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x5f, 0x62, 0x65, 0x68, 0x61, 0x76, - 0x69, 0x6f, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x19, 0x67, 0x6f, 0x6f, 0x67, 0x6c, - 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x77, 0x72, 0x61, 0x70, 0x70, 0x65, 0x72, 0x73, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x17, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x72, 0x70, - 0x63, 0x2f, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xf7, - 0x13, 0x0a, 0x04, 0x53, 0x70, 0x61, 0x6e, 0x12, 0x17, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, + 0x75, 0x64, 0x74, 0x72, 0x61, 0x63, 0x65, 0x2e, 0x76, 0x32, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, + 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x5f, 0x62, 0x65, 0x68, + 0x61, 0x76, 0x69, 0x6f, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x19, 0x67, 0x6f, 0x6f, + 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, + 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x77, 0x72, 0x61, 0x70, 0x70, 0x65, 0x72, + 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x17, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, + 0x72, 0x70, 0x63, 0x2f, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, + 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xb0, + 0x15, 0x0a, 0x04, 0x53, 0x70, 0x61, 0x6e, 0x12, 0x17, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x03, 0xe0, 0x41, 0x02, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1c, 0x0a, 0x07, 0x73, 0x70, 0x61, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x03, 0xe0, 0x41, 0x02, 0x52, 0x06, 0x73, 0x70, 0x61, 0x6e, 0x49, 0x64, 0x12, 0x24, @@ -1381,7 +1466,12 @@ var file_google_devtools_cloudtrace_v2_trace_proto_rawDesc = []byte{ 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x49, 0x6e, 0x74, 0x33, 0x32, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x42, 0x03, 0xe0, 0x41, 0x01, 0x52, 0x0e, 0x63, 0x68, 0x69, 0x6c, 0x64, 0x53, 0x70, 0x61, 0x6e, 0x43, - 0x6f, 0x75, 0x6e, 0x74, 0x1a, 0x9d, 0x02, 0x0a, 0x0a, 0x41, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, + 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x4e, 0x0a, 0x09, 0x73, 0x70, 0x61, 0x6e, 0x5f, 0x6b, 0x69, 0x6e, + 0x64, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x2c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, + 0x2e, 0x64, 0x65, 0x76, 0x74, 0x6f, 0x6f, 0x6c, 0x73, 0x2e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x74, + 0x72, 0x61, 0x63, 0x65, 0x2e, 0x76, 0x32, 0x2e, 0x53, 0x70, 0x61, 0x6e, 0x2e, 0x53, 0x70, 0x61, + 0x6e, 0x4b, 0x69, 0x6e, 0x64, 0x42, 0x03, 0xe0, 0x41, 0x01, 0x52, 0x08, 0x73, 0x70, 0x61, 0x6e, + 0x4b, 0x69, 0x6e, 0x64, 0x1a, 0x9d, 0x02, 0x0a, 0x0a, 0x41, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x12, 0x65, 0x0a, 0x0d, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x5f, 0x6d, 0x61, 0x70, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x40, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x64, 0x65, 0x76, 0x74, 0x6f, 0x6f, 0x6c, 0x73, 0x2e, 0x63, 0x6c, 0x6f, @@ -1483,103 +1573,109 @@ var file_google_devtools_cloudtrace_v2_trace_proto_rawDesc = []byte{ 0x69, 0x6e, 0x6b, 0x12, 0x2e, 0x0a, 0x13, 0x64, 0x72, 0x6f, 0x70, 0x70, 0x65, 0x64, 0x5f, 0x6c, 0x69, 0x6e, 0x6b, 0x73, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x11, 0x64, 0x72, 0x6f, 0x70, 0x70, 0x65, 0x64, 0x4c, 0x69, 0x6e, 0x6b, 0x73, 0x43, 0x6f, - 0x75, 0x6e, 0x74, 0x3a, 0x53, 0xea, 0x41, 0x50, 0x0a, 0x1e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x74, - 0x72, 0x61, 0x63, 0x65, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x61, 0x70, 0x69, 0x73, 0x2e, - 0x63, 0x6f, 0x6d, 0x2f, 0x53, 0x70, 0x61, 0x6e, 0x12, 0x2e, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, - 0x74, 0x73, 0x2f, 0x7b, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x7d, 0x2f, 0x74, 0x72, 0x61, - 0x63, 0x65, 0x73, 0x2f, 0x7b, 0x74, 0x72, 0x61, 0x63, 0x65, 0x7d, 0x2f, 0x73, 0x70, 0x61, 0x6e, - 0x73, 0x2f, 0x7b, 0x73, 0x70, 0x61, 0x6e, 0x7d, 0x22, 0xb0, 0x01, 0x0a, 0x0e, 0x41, 0x74, 0x74, - 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x55, 0x0a, 0x0c, 0x73, - 0x74, 0x72, 0x69, 0x6e, 0x67, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x30, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x64, 0x65, 0x76, 0x74, 0x6f, - 0x6f, 0x6c, 0x73, 0x2e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x74, 0x72, 0x61, 0x63, 0x65, 0x2e, 0x76, - 0x32, 0x2e, 0x54, 0x72, 0x75, 0x6e, 0x63, 0x61, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x53, 0x74, 0x72, - 0x69, 0x6e, 0x67, 0x48, 0x00, 0x52, 0x0b, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, - 0x75, 0x65, 0x12, 0x1d, 0x0a, 0x09, 0x69, 0x6e, 0x74, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x03, 0x48, 0x00, 0x52, 0x08, 0x69, 0x6e, 0x74, 0x56, 0x61, 0x6c, 0x75, - 0x65, 0x12, 0x1f, 0x0a, 0x0a, 0x62, 0x6f, 0x6f, 0x6c, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, - 0x03, 0x20, 0x01, 0x28, 0x08, 0x48, 0x00, 0x52, 0x09, 0x62, 0x6f, 0x6f, 0x6c, 0x56, 0x61, 0x6c, - 0x75, 0x65, 0x42, 0x07, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0xa7, 0x06, 0x0a, 0x0a, - 0x53, 0x74, 0x61, 0x63, 0x6b, 0x54, 0x72, 0x61, 0x63, 0x65, 0x12, 0x58, 0x0a, 0x0c, 0x73, 0x74, - 0x61, 0x63, 0x6b, 0x5f, 0x66, 0x72, 0x61, 0x6d, 0x65, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x35, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x64, 0x65, 0x76, 0x74, 0x6f, 0x6f, - 0x6c, 0x73, 0x2e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x74, 0x72, 0x61, 0x63, 0x65, 0x2e, 0x76, 0x32, - 0x2e, 0x53, 0x74, 0x61, 0x63, 0x6b, 0x54, 0x72, 0x61, 0x63, 0x65, 0x2e, 0x53, 0x74, 0x61, 0x63, - 0x6b, 0x46, 0x72, 0x61, 0x6d, 0x65, 0x73, 0x52, 0x0b, 0x73, 0x74, 0x61, 0x63, 0x6b, 0x46, 0x72, - 0x61, 0x6d, 0x65, 0x73, 0x12, 0x2d, 0x0a, 0x13, 0x73, 0x74, 0x61, 0x63, 0x6b, 0x5f, 0x74, 0x72, - 0x61, 0x63, 0x65, 0x5f, 0x68, 0x61, 0x73, 0x68, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x03, 0x52, 0x10, 0x73, 0x74, 0x61, 0x63, 0x6b, 0x54, 0x72, 0x61, 0x63, 0x65, 0x48, 0x61, 0x73, - 0x68, 0x49, 0x64, 0x1a, 0x81, 0x04, 0x0a, 0x0a, 0x53, 0x74, 0x61, 0x63, 0x6b, 0x46, 0x72, 0x61, - 0x6d, 0x65, 0x12, 0x55, 0x0a, 0x0d, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x6e, - 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x30, 0x2e, 0x67, 0x6f, 0x6f, 0x67, + 0x75, 0x6e, 0x74, 0x22, 0x67, 0x0a, 0x08, 0x53, 0x70, 0x61, 0x6e, 0x4b, 0x69, 0x6e, 0x64, 0x12, + 0x19, 0x0a, 0x15, 0x53, 0x50, 0x41, 0x4e, 0x5f, 0x4b, 0x49, 0x4e, 0x44, 0x5f, 0x55, 0x4e, 0x53, + 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x0c, 0x0a, 0x08, 0x49, 0x4e, + 0x54, 0x45, 0x52, 0x4e, 0x41, 0x4c, 0x10, 0x01, 0x12, 0x0a, 0x0a, 0x06, 0x53, 0x45, 0x52, 0x56, + 0x45, 0x52, 0x10, 0x02, 0x12, 0x0a, 0x0a, 0x06, 0x43, 0x4c, 0x49, 0x45, 0x4e, 0x54, 0x10, 0x03, + 0x12, 0x0c, 0x0a, 0x08, 0x50, 0x52, 0x4f, 0x44, 0x55, 0x43, 0x45, 0x52, 0x10, 0x04, 0x12, 0x0c, + 0x0a, 0x08, 0x43, 0x4f, 0x4e, 0x53, 0x55, 0x4d, 0x45, 0x52, 0x10, 0x05, 0x3a, 0x53, 0xea, 0x41, + 0x50, 0x0a, 0x1e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x74, 0x72, 0x61, 0x63, 0x65, 0x2e, 0x67, 0x6f, + 0x6f, 0x67, 0x6c, 0x65, 0x61, 0x70, 0x69, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x53, 0x70, 0x61, + 0x6e, 0x12, 0x2e, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x2f, 0x7b, 0x70, 0x72, 0x6f, + 0x6a, 0x65, 0x63, 0x74, 0x7d, 0x2f, 0x74, 0x72, 0x61, 0x63, 0x65, 0x73, 0x2f, 0x7b, 0x74, 0x72, + 0x61, 0x63, 0x65, 0x7d, 0x2f, 0x73, 0x70, 0x61, 0x6e, 0x73, 0x2f, 0x7b, 0x73, 0x70, 0x61, 0x6e, + 0x7d, 0x22, 0xb0, 0x01, 0x0a, 0x0e, 0x41, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x56, + 0x61, 0x6c, 0x75, 0x65, 0x12, 0x55, 0x0a, 0x0c, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x5f, 0x76, + 0x61, 0x6c, 0x75, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x30, 0x2e, 0x67, 0x6f, 0x6f, + 0x67, 0x6c, 0x65, 0x2e, 0x64, 0x65, 0x76, 0x74, 0x6f, 0x6f, 0x6c, 0x73, 0x2e, 0x63, 0x6c, 0x6f, + 0x75, 0x64, 0x74, 0x72, 0x61, 0x63, 0x65, 0x2e, 0x76, 0x32, 0x2e, 0x54, 0x72, 0x75, 0x6e, 0x63, + 0x61, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x48, 0x00, 0x52, 0x0b, + 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x1d, 0x0a, 0x09, 0x69, + 0x6e, 0x74, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x48, 0x00, + 0x52, 0x08, 0x69, 0x6e, 0x74, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x1f, 0x0a, 0x0a, 0x62, 0x6f, + 0x6f, 0x6c, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x48, 0x00, + 0x52, 0x09, 0x62, 0x6f, 0x6f, 0x6c, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x42, 0x07, 0x0a, 0x05, 0x76, + 0x61, 0x6c, 0x75, 0x65, 0x22, 0xa7, 0x06, 0x0a, 0x0a, 0x53, 0x74, 0x61, 0x63, 0x6b, 0x54, 0x72, + 0x61, 0x63, 0x65, 0x12, 0x58, 0x0a, 0x0c, 0x73, 0x74, 0x61, 0x63, 0x6b, 0x5f, 0x66, 0x72, 0x61, + 0x6d, 0x65, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x35, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x64, 0x65, 0x76, 0x74, 0x6f, 0x6f, 0x6c, 0x73, 0x2e, 0x63, 0x6c, 0x6f, 0x75, - 0x64, 0x74, 0x72, 0x61, 0x63, 0x65, 0x2e, 0x76, 0x32, 0x2e, 0x54, 0x72, 0x75, 0x6e, 0x63, 0x61, - 0x74, 0x61, 0x62, 0x6c, 0x65, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x0c, 0x66, 0x75, 0x6e, - 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x66, 0x0a, 0x16, 0x6f, 0x72, 0x69, - 0x67, 0x69, 0x6e, 0x61, 0x6c, 0x5f, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x6e, - 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x30, 0x2e, 0x67, 0x6f, 0x6f, 0x67, + 0x64, 0x74, 0x72, 0x61, 0x63, 0x65, 0x2e, 0x76, 0x32, 0x2e, 0x53, 0x74, 0x61, 0x63, 0x6b, 0x54, + 0x72, 0x61, 0x63, 0x65, 0x2e, 0x53, 0x74, 0x61, 0x63, 0x6b, 0x46, 0x72, 0x61, 0x6d, 0x65, 0x73, + 0x52, 0x0b, 0x73, 0x74, 0x61, 0x63, 0x6b, 0x46, 0x72, 0x61, 0x6d, 0x65, 0x73, 0x12, 0x2d, 0x0a, + 0x13, 0x73, 0x74, 0x61, 0x63, 0x6b, 0x5f, 0x74, 0x72, 0x61, 0x63, 0x65, 0x5f, 0x68, 0x61, 0x73, + 0x68, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x10, 0x73, 0x74, 0x61, 0x63, + 0x6b, 0x54, 0x72, 0x61, 0x63, 0x65, 0x48, 0x61, 0x73, 0x68, 0x49, 0x64, 0x1a, 0x81, 0x04, 0x0a, + 0x0a, 0x53, 0x74, 0x61, 0x63, 0x6b, 0x46, 0x72, 0x61, 0x6d, 0x65, 0x12, 0x55, 0x0a, 0x0d, 0x66, + 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x30, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x64, 0x65, 0x76, 0x74, + 0x6f, 0x6f, 0x6c, 0x73, 0x2e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x74, 0x72, 0x61, 0x63, 0x65, 0x2e, + 0x76, 0x32, 0x2e, 0x54, 0x72, 0x75, 0x6e, 0x63, 0x61, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x53, 0x74, + 0x72, 0x69, 0x6e, 0x67, 0x52, 0x0c, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x4e, 0x61, + 0x6d, 0x65, 0x12, 0x66, 0x0a, 0x16, 0x6f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x61, 0x6c, 0x5f, 0x66, + 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x30, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x64, 0x65, 0x76, 0x74, + 0x6f, 0x6f, 0x6c, 0x73, 0x2e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x74, 0x72, 0x61, 0x63, 0x65, 0x2e, + 0x76, 0x32, 0x2e, 0x54, 0x72, 0x75, 0x6e, 0x63, 0x61, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x53, 0x74, + 0x72, 0x69, 0x6e, 0x67, 0x52, 0x14, 0x6f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x61, 0x6c, 0x46, 0x75, + 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x4d, 0x0a, 0x09, 0x66, 0x69, + 0x6c, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x30, 0x2e, + 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x64, 0x65, 0x76, 0x74, 0x6f, 0x6f, 0x6c, 0x73, 0x2e, + 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x74, 0x72, 0x61, 0x63, 0x65, 0x2e, 0x76, 0x32, 0x2e, 0x54, 0x72, + 0x75, 0x6e, 0x63, 0x61, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, + 0x08, 0x66, 0x69, 0x6c, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x6c, 0x69, 0x6e, + 0x65, 0x5f, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0a, + 0x6c, 0x69, 0x6e, 0x65, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x23, 0x0a, 0x0d, 0x63, 0x6f, + 0x6c, 0x75, 0x6d, 0x6e, 0x5f, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x05, 0x20, 0x01, 0x28, + 0x03, 0x52, 0x0c, 0x63, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, + 0x46, 0x0a, 0x0b, 0x6c, 0x6f, 0x61, 0x64, 0x5f, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x18, 0x06, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x64, 0x65, + 0x76, 0x74, 0x6f, 0x6f, 0x6c, 0x73, 0x2e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x74, 0x72, 0x61, 0x63, + 0x65, 0x2e, 0x76, 0x32, 0x2e, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x52, 0x0a, 0x6c, 0x6f, 0x61, + 0x64, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x12, 0x57, 0x0a, 0x0e, 0x73, 0x6f, 0x75, 0x72, 0x63, + 0x65, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x30, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x64, 0x65, 0x76, 0x74, 0x6f, 0x6f, 0x6c, + 0x73, 0x2e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x74, 0x72, 0x61, 0x63, 0x65, 0x2e, 0x76, 0x32, 0x2e, + 0x54, 0x72, 0x75, 0x6e, 0x63, 0x61, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x53, 0x74, 0x72, 0x69, 0x6e, + 0x67, 0x52, 0x0d, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, + 0x1a, 0x8b, 0x01, 0x0a, 0x0b, 0x53, 0x74, 0x61, 0x63, 0x6b, 0x46, 0x72, 0x61, 0x6d, 0x65, 0x73, + 0x12, 0x4a, 0x0a, 0x05, 0x66, 0x72, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, + 0x34, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x64, 0x65, 0x76, 0x74, 0x6f, 0x6f, 0x6c, + 0x73, 0x2e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x74, 0x72, 0x61, 0x63, 0x65, 0x2e, 0x76, 0x32, 0x2e, + 0x53, 0x74, 0x61, 0x63, 0x6b, 0x54, 0x72, 0x61, 0x63, 0x65, 0x2e, 0x53, 0x74, 0x61, 0x63, 0x6b, + 0x46, 0x72, 0x61, 0x6d, 0x65, 0x52, 0x05, 0x66, 0x72, 0x61, 0x6d, 0x65, 0x12, 0x30, 0x0a, 0x14, + 0x64, 0x72, 0x6f, 0x70, 0x70, 0x65, 0x64, 0x5f, 0x66, 0x72, 0x61, 0x6d, 0x65, 0x73, 0x5f, 0x63, + 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x12, 0x64, 0x72, 0x6f, 0x70, + 0x70, 0x65, 0x64, 0x46, 0x72, 0x61, 0x6d, 0x65, 0x73, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x9f, + 0x01, 0x0a, 0x06, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x12, 0x48, 0x0a, 0x06, 0x6d, 0x6f, 0x64, + 0x75, 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x30, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x64, 0x65, 0x76, 0x74, 0x6f, 0x6f, 0x6c, 0x73, 0x2e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x74, 0x72, 0x61, 0x63, 0x65, 0x2e, 0x76, 0x32, 0x2e, 0x54, 0x72, 0x75, 0x6e, 0x63, 0x61, - 0x74, 0x61, 0x62, 0x6c, 0x65, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x14, 0x6f, 0x72, 0x69, - 0x67, 0x69, 0x6e, 0x61, 0x6c, 0x46, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x4e, 0x61, 0x6d, - 0x65, 0x12, 0x4d, 0x0a, 0x09, 0x66, 0x69, 0x6c, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x30, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x64, 0x65, - 0x76, 0x74, 0x6f, 0x6f, 0x6c, 0x73, 0x2e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x74, 0x72, 0x61, 0x63, - 0x65, 0x2e, 0x76, 0x32, 0x2e, 0x54, 0x72, 0x75, 0x6e, 0x63, 0x61, 0x74, 0x61, 0x62, 0x6c, 0x65, - 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x08, 0x66, 0x69, 0x6c, 0x65, 0x4e, 0x61, 0x6d, 0x65, - 0x12, 0x1f, 0x0a, 0x0b, 0x6c, 0x69, 0x6e, 0x65, 0x5f, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, - 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0a, 0x6c, 0x69, 0x6e, 0x65, 0x4e, 0x75, 0x6d, 0x62, 0x65, - 0x72, 0x12, 0x23, 0x0a, 0x0d, 0x63, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x5f, 0x6e, 0x75, 0x6d, 0x62, - 0x65, 0x72, 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0c, 0x63, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, - 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x46, 0x0a, 0x0b, 0x6c, 0x6f, 0x61, 0x64, 0x5f, 0x6d, - 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x67, 0x6f, - 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x64, 0x65, 0x76, 0x74, 0x6f, 0x6f, 0x6c, 0x73, 0x2e, 0x63, 0x6c, - 0x6f, 0x75, 0x64, 0x74, 0x72, 0x61, 0x63, 0x65, 0x2e, 0x76, 0x32, 0x2e, 0x4d, 0x6f, 0x64, 0x75, - 0x6c, 0x65, 0x52, 0x0a, 0x6c, 0x6f, 0x61, 0x64, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x12, 0x57, - 0x0a, 0x0e, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, - 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x30, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, - 0x64, 0x65, 0x76, 0x74, 0x6f, 0x6f, 0x6c, 0x73, 0x2e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x74, 0x72, - 0x61, 0x63, 0x65, 0x2e, 0x76, 0x32, 0x2e, 0x54, 0x72, 0x75, 0x6e, 0x63, 0x61, 0x74, 0x61, 0x62, - 0x6c, 0x65, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x0d, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, - 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x1a, 0x8b, 0x01, 0x0a, 0x0b, 0x53, 0x74, 0x61, 0x63, - 0x6b, 0x46, 0x72, 0x61, 0x6d, 0x65, 0x73, 0x12, 0x4a, 0x0a, 0x05, 0x66, 0x72, 0x61, 0x6d, 0x65, - 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x34, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, - 0x64, 0x65, 0x76, 0x74, 0x6f, 0x6f, 0x6c, 0x73, 0x2e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x74, 0x72, - 0x61, 0x63, 0x65, 0x2e, 0x76, 0x32, 0x2e, 0x53, 0x74, 0x61, 0x63, 0x6b, 0x54, 0x72, 0x61, 0x63, - 0x65, 0x2e, 0x53, 0x74, 0x61, 0x63, 0x6b, 0x46, 0x72, 0x61, 0x6d, 0x65, 0x52, 0x05, 0x66, 0x72, - 0x61, 0x6d, 0x65, 0x12, 0x30, 0x0a, 0x14, 0x64, 0x72, 0x6f, 0x70, 0x70, 0x65, 0x64, 0x5f, 0x66, - 0x72, 0x61, 0x6d, 0x65, 0x73, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x05, 0x52, 0x12, 0x64, 0x72, 0x6f, 0x70, 0x70, 0x65, 0x64, 0x46, 0x72, 0x61, 0x6d, 0x65, 0x73, - 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x9f, 0x01, 0x0a, 0x06, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, - 0x12, 0x48, 0x0a, 0x06, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x30, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x64, 0x65, 0x76, 0x74, 0x6f, 0x6f, - 0x6c, 0x73, 0x2e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x74, 0x72, 0x61, 0x63, 0x65, 0x2e, 0x76, 0x32, - 0x2e, 0x54, 0x72, 0x75, 0x6e, 0x63, 0x61, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x53, 0x74, 0x72, 0x69, - 0x6e, 0x67, 0x52, 0x06, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x12, 0x4b, 0x0a, 0x08, 0x62, 0x75, - 0x69, 0x6c, 0x64, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x30, 0x2e, 0x67, - 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x64, 0x65, 0x76, 0x74, 0x6f, 0x6f, 0x6c, 0x73, 0x2e, 0x63, - 0x6c, 0x6f, 0x75, 0x64, 0x74, 0x72, 0x61, 0x63, 0x65, 0x2e, 0x76, 0x32, 0x2e, 0x54, 0x72, 0x75, - 0x6e, 0x63, 0x61, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x07, - 0x62, 0x75, 0x69, 0x6c, 0x64, 0x49, 0x64, 0x22, 0x5b, 0x0a, 0x11, 0x54, 0x72, 0x75, 0x6e, 0x63, - 0x61, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x12, 0x14, 0x0a, 0x05, - 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, - 0x75, 0x65, 0x12, 0x30, 0x0a, 0x14, 0x74, 0x72, 0x75, 0x6e, 0x63, 0x61, 0x74, 0x65, 0x64, 0x5f, - 0x62, 0x79, 0x74, 0x65, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, - 0x52, 0x12, 0x74, 0x72, 0x75, 0x6e, 0x63, 0x61, 0x74, 0x65, 0x64, 0x42, 0x79, 0x74, 0x65, 0x43, - 0x6f, 0x75, 0x6e, 0x74, 0x42, 0xc5, 0x01, 0x0a, 0x21, 0x63, 0x6f, 0x6d, 0x2e, 0x67, 0x6f, 0x6f, - 0x67, 0x6c, 0x65, 0x2e, 0x64, 0x65, 0x76, 0x74, 0x6f, 0x6f, 0x6c, 0x73, 0x2e, 0x63, 0x6c, 0x6f, - 0x75, 0x64, 0x74, 0x72, 0x61, 0x63, 0x65, 0x2e, 0x76, 0x32, 0x42, 0x0a, 0x54, 0x72, 0x61, 0x63, - 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x47, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, - 0x2e, 0x67, 0x6f, 0x6c, 0x61, 0x6e, 0x67, 0x2e, 0x6f, 0x72, 0x67, 0x2f, 0x67, 0x65, 0x6e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x61, 0x70, 0x69, 0x73, 0x2f, - 0x64, 0x65, 0x76, 0x74, 0x6f, 0x6f, 0x6c, 0x73, 0x2f, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x74, 0x72, - 0x61, 0x63, 0x65, 0x2f, 0x76, 0x32, 0x3b, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x74, 0x72, 0x61, 0x63, - 0x65, 0xaa, 0x02, 0x15, 0x47, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x43, 0x6c, 0x6f, 0x75, 0x64, - 0x2e, 0x54, 0x72, 0x61, 0x63, 0x65, 0x2e, 0x56, 0x32, 0xca, 0x02, 0x15, 0x47, 0x6f, 0x6f, 0x67, - 0x6c, 0x65, 0x5c, 0x43, 0x6c, 0x6f, 0x75, 0x64, 0x5c, 0x54, 0x72, 0x61, 0x63, 0x65, 0x5c, 0x56, - 0x32, 0xea, 0x02, 0x18, 0x47, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x3a, 0x3a, 0x43, 0x6c, 0x6f, 0x75, - 0x64, 0x3a, 0x3a, 0x54, 0x72, 0x61, 0x63, 0x65, 0x3a, 0x3a, 0x56, 0x32, 0x62, 0x06, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x33, + 0x74, 0x61, 0x62, 0x6c, 0x65, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x06, 0x6d, 0x6f, 0x64, + 0x75, 0x6c, 0x65, 0x12, 0x4b, 0x0a, 0x08, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x5f, 0x69, 0x64, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x30, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x64, + 0x65, 0x76, 0x74, 0x6f, 0x6f, 0x6c, 0x73, 0x2e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x74, 0x72, 0x61, + 0x63, 0x65, 0x2e, 0x76, 0x32, 0x2e, 0x54, 0x72, 0x75, 0x6e, 0x63, 0x61, 0x74, 0x61, 0x62, 0x6c, + 0x65, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x07, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x49, 0x64, + 0x22, 0x5b, 0x0a, 0x11, 0x54, 0x72, 0x75, 0x6e, 0x63, 0x61, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x53, + 0x74, 0x72, 0x69, 0x6e, 0x67, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x30, 0x0a, 0x14, 0x74, + 0x72, 0x75, 0x6e, 0x63, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x62, 0x79, 0x74, 0x65, 0x5f, 0x63, 0x6f, + 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x12, 0x74, 0x72, 0x75, 0x6e, 0x63, + 0x61, 0x74, 0x65, 0x64, 0x42, 0x79, 0x74, 0x65, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x42, 0xc5, 0x01, + 0x0a, 0x21, 0x63, 0x6f, 0x6d, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x64, 0x65, 0x76, + 0x74, 0x6f, 0x6f, 0x6c, 0x73, 0x2e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x74, 0x72, 0x61, 0x63, 0x65, + 0x2e, 0x76, 0x32, 0x42, 0x0a, 0x54, 0x72, 0x61, 0x63, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, + 0x01, 0x5a, 0x47, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x67, 0x6f, 0x6c, 0x61, 0x6e, 0x67, + 0x2e, 0x6f, 0x72, 0x67, 0x2f, 0x67, 0x65, 0x6e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6f, + 0x6f, 0x67, 0x6c, 0x65, 0x61, 0x70, 0x69, 0x73, 0x2f, 0x64, 0x65, 0x76, 0x74, 0x6f, 0x6f, 0x6c, + 0x73, 0x2f, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x74, 0x72, 0x61, 0x63, 0x65, 0x2f, 0x76, 0x32, 0x3b, + 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x74, 0x72, 0x61, 0x63, 0x65, 0xaa, 0x02, 0x15, 0x47, 0x6f, 0x6f, + 0x67, 0x6c, 0x65, 0x2e, 0x43, 0x6c, 0x6f, 0x75, 0x64, 0x2e, 0x54, 0x72, 0x61, 0x63, 0x65, 0x2e, + 0x56, 0x32, 0xca, 0x02, 0x15, 0x47, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x5c, 0x43, 0x6c, 0x6f, 0x75, + 0x64, 0x5c, 0x54, 0x72, 0x61, 0x63, 0x65, 0x5c, 0x56, 0x32, 0xea, 0x02, 0x18, 0x47, 0x6f, 0x6f, + 0x67, 0x6c, 0x65, 0x3a, 0x3a, 0x43, 0x6c, 0x6f, 0x75, 0x64, 0x3a, 0x3a, 0x54, 0x72, 0x61, 0x63, + 0x65, 0x3a, 0x3a, 0x56, 0x32, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -1594,69 +1690,71 @@ func file_google_devtools_cloudtrace_v2_trace_proto_rawDescGZIP() []byte { return file_google_devtools_cloudtrace_v2_trace_proto_rawDescData } -var file_google_devtools_cloudtrace_v2_trace_proto_enumTypes = make([]protoimpl.EnumInfo, 2) +var file_google_devtools_cloudtrace_v2_trace_proto_enumTypes = make([]protoimpl.EnumInfo, 3) var file_google_devtools_cloudtrace_v2_trace_proto_msgTypes = make([]protoimpl.MessageInfo, 15) var file_google_devtools_cloudtrace_v2_trace_proto_goTypes = []interface{}{ - (Span_TimeEvent_MessageEvent_Type)(0), // 0: google.devtools.cloudtrace.v2.Span.TimeEvent.MessageEvent.Type - (Span_Link_Type)(0), // 1: google.devtools.cloudtrace.v2.Span.Link.Type - (*Span)(nil), // 2: google.devtools.cloudtrace.v2.Span - (*AttributeValue)(nil), // 3: google.devtools.cloudtrace.v2.AttributeValue - (*StackTrace)(nil), // 4: google.devtools.cloudtrace.v2.StackTrace - (*Module)(nil), // 5: google.devtools.cloudtrace.v2.Module - (*TruncatableString)(nil), // 6: google.devtools.cloudtrace.v2.TruncatableString - (*Span_Attributes)(nil), // 7: google.devtools.cloudtrace.v2.Span.Attributes - (*Span_TimeEvent)(nil), // 8: google.devtools.cloudtrace.v2.Span.TimeEvent - (*Span_TimeEvents)(nil), // 9: google.devtools.cloudtrace.v2.Span.TimeEvents - (*Span_Link)(nil), // 10: google.devtools.cloudtrace.v2.Span.Link - (*Span_Links)(nil), // 11: google.devtools.cloudtrace.v2.Span.Links - nil, // 12: google.devtools.cloudtrace.v2.Span.Attributes.AttributeMapEntry - (*Span_TimeEvent_Annotation)(nil), // 13: google.devtools.cloudtrace.v2.Span.TimeEvent.Annotation - (*Span_TimeEvent_MessageEvent)(nil), // 14: google.devtools.cloudtrace.v2.Span.TimeEvent.MessageEvent - (*StackTrace_StackFrame)(nil), // 15: google.devtools.cloudtrace.v2.StackTrace.StackFrame - (*StackTrace_StackFrames)(nil), // 16: google.devtools.cloudtrace.v2.StackTrace.StackFrames - (*timestamp.Timestamp)(nil), // 17: google.protobuf.Timestamp - (*status.Status)(nil), // 18: google.rpc.Status - (*wrappers.BoolValue)(nil), // 19: google.protobuf.BoolValue - (*wrappers.Int32Value)(nil), // 20: google.protobuf.Int32Value + (Span_SpanKind)(0), // 0: google.devtools.cloudtrace.v2.Span.SpanKind + (Span_TimeEvent_MessageEvent_Type)(0), // 1: google.devtools.cloudtrace.v2.Span.TimeEvent.MessageEvent.Type + (Span_Link_Type)(0), // 2: google.devtools.cloudtrace.v2.Span.Link.Type + (*Span)(nil), // 3: google.devtools.cloudtrace.v2.Span + (*AttributeValue)(nil), // 4: google.devtools.cloudtrace.v2.AttributeValue + (*StackTrace)(nil), // 5: google.devtools.cloudtrace.v2.StackTrace + (*Module)(nil), // 6: google.devtools.cloudtrace.v2.Module + (*TruncatableString)(nil), // 7: google.devtools.cloudtrace.v2.TruncatableString + (*Span_Attributes)(nil), // 8: google.devtools.cloudtrace.v2.Span.Attributes + (*Span_TimeEvent)(nil), // 9: google.devtools.cloudtrace.v2.Span.TimeEvent + (*Span_TimeEvents)(nil), // 10: google.devtools.cloudtrace.v2.Span.TimeEvents + (*Span_Link)(nil), // 11: google.devtools.cloudtrace.v2.Span.Link + (*Span_Links)(nil), // 12: google.devtools.cloudtrace.v2.Span.Links + nil, // 13: google.devtools.cloudtrace.v2.Span.Attributes.AttributeMapEntry + (*Span_TimeEvent_Annotation)(nil), // 14: google.devtools.cloudtrace.v2.Span.TimeEvent.Annotation + (*Span_TimeEvent_MessageEvent)(nil), // 15: google.devtools.cloudtrace.v2.Span.TimeEvent.MessageEvent + (*StackTrace_StackFrame)(nil), // 16: google.devtools.cloudtrace.v2.StackTrace.StackFrame + (*StackTrace_StackFrames)(nil), // 17: google.devtools.cloudtrace.v2.StackTrace.StackFrames + (*timestamp.Timestamp)(nil), // 18: google.protobuf.Timestamp + (*status.Status)(nil), // 19: google.rpc.Status + (*wrappers.BoolValue)(nil), // 20: google.protobuf.BoolValue + (*wrappers.Int32Value)(nil), // 21: google.protobuf.Int32Value } var file_google_devtools_cloudtrace_v2_trace_proto_depIdxs = []int32{ - 6, // 0: google.devtools.cloudtrace.v2.Span.display_name:type_name -> google.devtools.cloudtrace.v2.TruncatableString - 17, // 1: google.devtools.cloudtrace.v2.Span.start_time:type_name -> google.protobuf.Timestamp - 17, // 2: google.devtools.cloudtrace.v2.Span.end_time:type_name -> google.protobuf.Timestamp - 7, // 3: google.devtools.cloudtrace.v2.Span.attributes:type_name -> google.devtools.cloudtrace.v2.Span.Attributes - 4, // 4: google.devtools.cloudtrace.v2.Span.stack_trace:type_name -> google.devtools.cloudtrace.v2.StackTrace - 9, // 5: google.devtools.cloudtrace.v2.Span.time_events:type_name -> google.devtools.cloudtrace.v2.Span.TimeEvents - 11, // 6: google.devtools.cloudtrace.v2.Span.links:type_name -> google.devtools.cloudtrace.v2.Span.Links - 18, // 7: google.devtools.cloudtrace.v2.Span.status:type_name -> google.rpc.Status - 19, // 8: google.devtools.cloudtrace.v2.Span.same_process_as_parent_span:type_name -> google.protobuf.BoolValue - 20, // 9: google.devtools.cloudtrace.v2.Span.child_span_count:type_name -> google.protobuf.Int32Value - 6, // 10: google.devtools.cloudtrace.v2.AttributeValue.string_value:type_name -> google.devtools.cloudtrace.v2.TruncatableString - 16, // 11: google.devtools.cloudtrace.v2.StackTrace.stack_frames:type_name -> google.devtools.cloudtrace.v2.StackTrace.StackFrames - 6, // 12: google.devtools.cloudtrace.v2.Module.module:type_name -> google.devtools.cloudtrace.v2.TruncatableString - 6, // 13: google.devtools.cloudtrace.v2.Module.build_id:type_name -> google.devtools.cloudtrace.v2.TruncatableString - 12, // 14: google.devtools.cloudtrace.v2.Span.Attributes.attribute_map:type_name -> google.devtools.cloudtrace.v2.Span.Attributes.AttributeMapEntry - 17, // 15: google.devtools.cloudtrace.v2.Span.TimeEvent.time:type_name -> google.protobuf.Timestamp - 13, // 16: google.devtools.cloudtrace.v2.Span.TimeEvent.annotation:type_name -> google.devtools.cloudtrace.v2.Span.TimeEvent.Annotation - 14, // 17: google.devtools.cloudtrace.v2.Span.TimeEvent.message_event:type_name -> google.devtools.cloudtrace.v2.Span.TimeEvent.MessageEvent - 8, // 18: google.devtools.cloudtrace.v2.Span.TimeEvents.time_event:type_name -> google.devtools.cloudtrace.v2.Span.TimeEvent - 1, // 19: google.devtools.cloudtrace.v2.Span.Link.type:type_name -> google.devtools.cloudtrace.v2.Span.Link.Type - 7, // 20: google.devtools.cloudtrace.v2.Span.Link.attributes:type_name -> google.devtools.cloudtrace.v2.Span.Attributes - 10, // 21: google.devtools.cloudtrace.v2.Span.Links.link:type_name -> google.devtools.cloudtrace.v2.Span.Link - 3, // 22: google.devtools.cloudtrace.v2.Span.Attributes.AttributeMapEntry.value:type_name -> google.devtools.cloudtrace.v2.AttributeValue - 6, // 23: google.devtools.cloudtrace.v2.Span.TimeEvent.Annotation.description:type_name -> google.devtools.cloudtrace.v2.TruncatableString - 7, // 24: google.devtools.cloudtrace.v2.Span.TimeEvent.Annotation.attributes:type_name -> google.devtools.cloudtrace.v2.Span.Attributes - 0, // 25: google.devtools.cloudtrace.v2.Span.TimeEvent.MessageEvent.type:type_name -> google.devtools.cloudtrace.v2.Span.TimeEvent.MessageEvent.Type - 6, // 26: google.devtools.cloudtrace.v2.StackTrace.StackFrame.function_name:type_name -> google.devtools.cloudtrace.v2.TruncatableString - 6, // 27: google.devtools.cloudtrace.v2.StackTrace.StackFrame.original_function_name:type_name -> google.devtools.cloudtrace.v2.TruncatableString - 6, // 28: google.devtools.cloudtrace.v2.StackTrace.StackFrame.file_name:type_name -> google.devtools.cloudtrace.v2.TruncatableString - 5, // 29: google.devtools.cloudtrace.v2.StackTrace.StackFrame.load_module:type_name -> google.devtools.cloudtrace.v2.Module - 6, // 30: google.devtools.cloudtrace.v2.StackTrace.StackFrame.source_version:type_name -> google.devtools.cloudtrace.v2.TruncatableString - 15, // 31: google.devtools.cloudtrace.v2.StackTrace.StackFrames.frame:type_name -> google.devtools.cloudtrace.v2.StackTrace.StackFrame - 32, // [32:32] is the sub-list for method output_type - 32, // [32:32] is the sub-list for method input_type - 32, // [32:32] is the sub-list for extension type_name - 32, // [32:32] is the sub-list for extension extendee - 0, // [0:32] is the sub-list for field type_name + 7, // 0: google.devtools.cloudtrace.v2.Span.display_name:type_name -> google.devtools.cloudtrace.v2.TruncatableString + 18, // 1: google.devtools.cloudtrace.v2.Span.start_time:type_name -> google.protobuf.Timestamp + 18, // 2: google.devtools.cloudtrace.v2.Span.end_time:type_name -> google.protobuf.Timestamp + 8, // 3: google.devtools.cloudtrace.v2.Span.attributes:type_name -> google.devtools.cloudtrace.v2.Span.Attributes + 5, // 4: google.devtools.cloudtrace.v2.Span.stack_trace:type_name -> google.devtools.cloudtrace.v2.StackTrace + 10, // 5: google.devtools.cloudtrace.v2.Span.time_events:type_name -> google.devtools.cloudtrace.v2.Span.TimeEvents + 12, // 6: google.devtools.cloudtrace.v2.Span.links:type_name -> google.devtools.cloudtrace.v2.Span.Links + 19, // 7: google.devtools.cloudtrace.v2.Span.status:type_name -> google.rpc.Status + 20, // 8: google.devtools.cloudtrace.v2.Span.same_process_as_parent_span:type_name -> google.protobuf.BoolValue + 21, // 9: google.devtools.cloudtrace.v2.Span.child_span_count:type_name -> google.protobuf.Int32Value + 0, // 10: google.devtools.cloudtrace.v2.Span.span_kind:type_name -> google.devtools.cloudtrace.v2.Span.SpanKind + 7, // 11: google.devtools.cloudtrace.v2.AttributeValue.string_value:type_name -> google.devtools.cloudtrace.v2.TruncatableString + 17, // 12: google.devtools.cloudtrace.v2.StackTrace.stack_frames:type_name -> google.devtools.cloudtrace.v2.StackTrace.StackFrames + 7, // 13: google.devtools.cloudtrace.v2.Module.module:type_name -> google.devtools.cloudtrace.v2.TruncatableString + 7, // 14: google.devtools.cloudtrace.v2.Module.build_id:type_name -> google.devtools.cloudtrace.v2.TruncatableString + 13, // 15: google.devtools.cloudtrace.v2.Span.Attributes.attribute_map:type_name -> google.devtools.cloudtrace.v2.Span.Attributes.AttributeMapEntry + 18, // 16: google.devtools.cloudtrace.v2.Span.TimeEvent.time:type_name -> google.protobuf.Timestamp + 14, // 17: google.devtools.cloudtrace.v2.Span.TimeEvent.annotation:type_name -> google.devtools.cloudtrace.v2.Span.TimeEvent.Annotation + 15, // 18: google.devtools.cloudtrace.v2.Span.TimeEvent.message_event:type_name -> google.devtools.cloudtrace.v2.Span.TimeEvent.MessageEvent + 9, // 19: google.devtools.cloudtrace.v2.Span.TimeEvents.time_event:type_name -> google.devtools.cloudtrace.v2.Span.TimeEvent + 2, // 20: google.devtools.cloudtrace.v2.Span.Link.type:type_name -> google.devtools.cloudtrace.v2.Span.Link.Type + 8, // 21: google.devtools.cloudtrace.v2.Span.Link.attributes:type_name -> google.devtools.cloudtrace.v2.Span.Attributes + 11, // 22: google.devtools.cloudtrace.v2.Span.Links.link:type_name -> google.devtools.cloudtrace.v2.Span.Link + 4, // 23: google.devtools.cloudtrace.v2.Span.Attributes.AttributeMapEntry.value:type_name -> google.devtools.cloudtrace.v2.AttributeValue + 7, // 24: google.devtools.cloudtrace.v2.Span.TimeEvent.Annotation.description:type_name -> google.devtools.cloudtrace.v2.TruncatableString + 8, // 25: google.devtools.cloudtrace.v2.Span.TimeEvent.Annotation.attributes:type_name -> google.devtools.cloudtrace.v2.Span.Attributes + 1, // 26: google.devtools.cloudtrace.v2.Span.TimeEvent.MessageEvent.type:type_name -> google.devtools.cloudtrace.v2.Span.TimeEvent.MessageEvent.Type + 7, // 27: google.devtools.cloudtrace.v2.StackTrace.StackFrame.function_name:type_name -> google.devtools.cloudtrace.v2.TruncatableString + 7, // 28: google.devtools.cloudtrace.v2.StackTrace.StackFrame.original_function_name:type_name -> google.devtools.cloudtrace.v2.TruncatableString + 7, // 29: google.devtools.cloudtrace.v2.StackTrace.StackFrame.file_name:type_name -> google.devtools.cloudtrace.v2.TruncatableString + 6, // 30: google.devtools.cloudtrace.v2.StackTrace.StackFrame.load_module:type_name -> google.devtools.cloudtrace.v2.Module + 7, // 31: google.devtools.cloudtrace.v2.StackTrace.StackFrame.source_version:type_name -> google.devtools.cloudtrace.v2.TruncatableString + 16, // 32: google.devtools.cloudtrace.v2.StackTrace.StackFrames.frame:type_name -> google.devtools.cloudtrace.v2.StackTrace.StackFrame + 33, // [33:33] is the sub-list for method output_type + 33, // [33:33] is the sub-list for method input_type + 33, // [33:33] is the sub-list for extension type_name + 33, // [33:33] is the sub-list for extension extendee + 0, // [0:33] is the sub-list for field type_name } func init() { file_google_devtools_cloudtrace_v2_trace_proto_init() } @@ -1848,7 +1946,7 @@ func file_google_devtools_cloudtrace_v2_trace_proto_init() { File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_google_devtools_cloudtrace_v2_trace_proto_rawDesc, - NumEnums: 2, + NumEnums: 3, NumMessages: 15, NumExtensions: 0, NumServices: 0, diff --git a/vendor/google.golang.org/genproto/googleapis/devtools/cloudtrace/v2/tracing.pb.go b/vendor/google.golang.org/genproto/googleapis/devtools/cloudtrace/v2/tracing.pb.go index 4fa57f28a34..c7d27fd74ab 100644 --- a/vendor/google.golang.org/genproto/googleapis/devtools/cloudtrace/v2/tracing.pb.go +++ b/vendor/google.golang.org/genproto/googleapis/devtools/cloudtrace/v2/tracing.pb.go @@ -1,4 +1,4 @@ -// Copyright 2019 Google LLC. +// Copyright 2020 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -11,7 +11,6 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -// // Code generated by protoc-gen-go. DO NOT EDIT. // versions: diff --git a/vendor/knative.dev/pkg/apis/duck/ducktypes/ducktypes.go b/vendor/knative.dev/pkg/apis/duck/ducktypes/ducktypes.go new file mode 100644 index 00000000000..6f99e088239 --- /dev/null +++ b/vendor/knative.dev/pkg/apis/duck/ducktypes/ducktypes.go @@ -0,0 +1,43 @@ +/* +Copyright 2020 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package ducktypes + +import ( + "knative.dev/pkg/apis" +) + +// Implementable is implemented by the Fooable duck type that consumers +// are expected to embed as a `.status.fooable` field. +type Implementable interface { + // GetFullType returns an instance of a full resource wrapping + // an instance of this Implementable that can populate its fields + // to verify json roundtripping. + GetFullType() Populatable +} + +// Populatable is implemented by a skeleton resource wrapping an Implementable +// duck type. It will generally have TypeMeta, ObjectMeta, and a Status field +// wrapping a Fooable field. +type Populatable interface { + apis.Listable + + // Populate fills in all possible fields, so that we can verify that + // they roundtrip properly through JSON. + Populate() +} + +const GroupName = "duck.knative.dev" diff --git a/vendor/knative.dev/pkg/apis/duck/register.go b/vendor/knative.dev/pkg/apis/duck/register.go index d84cd49d18b..93cf55d7fcc 100644 --- a/vendor/knative.dev/pkg/apis/duck/register.go +++ b/vendor/knative.dev/pkg/apis/duck/register.go @@ -16,8 +16,12 @@ limitations under the License. package duck +import ( + "knative.dev/pkg/apis/duck/ducktypes" +) + const ( - GroupName = "duck.knative.dev" + GroupName = ducktypes.GroupName // AddressableDuckVersionLabel is the label we use to declare // that a type conforms to the Addressable duck type. diff --git a/vendor/knative.dev/pkg/apis/duck/v1/addressable_types.go b/vendor/knative.dev/pkg/apis/duck/v1/addressable_types.go index 579e6976ee8..db39ab862bf 100644 --- a/vendor/knative.dev/pkg/apis/duck/v1/addressable_types.go +++ b/vendor/knative.dev/pkg/apis/duck/v1/addressable_types.go @@ -24,7 +24,7 @@ import ( "k8s.io/apimachinery/pkg/runtime" "knative.dev/pkg/apis" - "knative.dev/pkg/apis/duck" + "knative.dev/pkg/apis/duck/ducktypes" ) // +genduck @@ -40,8 +40,6 @@ type Addressable struct { } var ( - // Addressable is an Implementable "duck type". - _ duck.Implementable = (*Addressable)(nil) // Addressable is a Convertible type. _ apis.Convertible = (*Addressable)(nil) ) @@ -65,14 +63,14 @@ type AddressStatus struct { Address *Addressable `json:"address,omitempty"` } +// Verify AddressableType resources meet duck contracts. var ( - // Verify AddressableType resources meet duck contracts. - _ duck.Populatable = (*AddressableType)(nil) - _ apis.Listable = (*AddressableType)(nil) + _ apis.Listable = (*AddressableType)(nil) + _ ducktypes.Populatable = (*AddressableType)(nil) ) // GetFullType implements duck.Implementable -func (*Addressable) GetFullType() duck.Populatable { +func (*Addressable) GetFullType() ducktypes.Populatable { return &AddressableType{} } diff --git a/vendor/knative.dev/pkg/apis/duck/v1/kresource_type.go b/vendor/knative.dev/pkg/apis/duck/v1/kresource_type.go index 78d8ece66a9..491c13f1f66 100644 --- a/vendor/knative.dev/pkg/apis/duck/v1/kresource_type.go +++ b/vendor/knative.dev/pkg/apis/duck/v1/kresource_type.go @@ -23,6 +23,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" + "knative.dev/pkg/apis/duck/ducktypes" "knative.dev/pkg/apis" ) @@ -66,6 +67,12 @@ func (t *KResource) Populate() { }} } +// Verify KResource resources meet duck contracts. +var ( + _ apis.Listable = (*KResource)(nil) + _ ducktypes.Populatable = (*KResource)(nil) +) + // GetListType implements apis.Listable func (*KResource) GetListType() runtime.Object { return &KResourceList{} diff --git a/vendor/knative.dev/pkg/apis/duck/v1/podspec_types.go b/vendor/knative.dev/pkg/apis/duck/v1/podspec_types.go index 0dd9ec33868..a8d172416dc 100644 --- a/vendor/knative.dev/pkg/apis/duck/v1/podspec_types.go +++ b/vendor/knative.dev/pkg/apis/duck/v1/podspec_types.go @@ -22,7 +22,7 @@ import ( "k8s.io/apimachinery/pkg/runtime" "knative.dev/pkg/apis" - "knative.dev/pkg/apis/duck" + "knative.dev/pkg/apis/duck/ducktypes" ) // +genduck @@ -31,6 +31,9 @@ import ( // in the manner of ReplicaSet, Deployment, DaemonSet, StatefulSet. type PodSpecable corev1.PodTemplateSpec +// PodSpecable is an Implementable duck type. +var _ ducktypes.Implementable = (*PodSpecable)(nil) + // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object // WithPod is the shell that demonstrates how PodSpecable types wrap @@ -47,16 +50,14 @@ type WithPodSpec struct { Template PodSpecable `json:"template,omitempty"` } -// Assert that we implement the interfaces necessary to -// use duck.VerifyType. +// Verify WithPod resources meet duck contracts. var ( - _ duck.Populatable = (*WithPod)(nil) - _ duck.Implementable = (*PodSpecable)(nil) - _ apis.Listable = (*WithPod)(nil) + _ apis.Listable = (*WithPod)(nil) + _ ducktypes.Populatable = (*WithPod)(nil) ) // GetFullType implements duck.Implementable -func (*PodSpecable) GetFullType() duck.Populatable { +func (*PodSpecable) GetFullType() ducktypes.Populatable { return &WithPod{} } diff --git a/vendor/knative.dev/pkg/apis/duck/v1/register.go b/vendor/knative.dev/pkg/apis/duck/v1/register.go index e3af46d6f8d..69bb1157838 100644 --- a/vendor/knative.dev/pkg/apis/duck/v1/register.go +++ b/vendor/knative.dev/pkg/apis/duck/v1/register.go @@ -20,11 +20,12 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" - "knative.dev/pkg/apis/duck" + + "knative.dev/pkg/apis/duck/ducktypes" ) // SchemeGroupVersion is group version used to register these objects -var SchemeGroupVersion = schema.GroupVersion{Group: duck.GroupName, Version: "v1"} +var SchemeGroupVersion = schema.GroupVersion{Group: ducktypes.GroupName, Version: "v1"} // Kind takes an unqualified kind and returns back a Group qualified GroupKind func Kind(kind string) schema.GroupKind { diff --git a/vendor/knative.dev/pkg/apis/duck/v1/source_types.go b/vendor/knative.dev/pkg/apis/duck/v1/source_types.go index 3b378ca3d48..4ce3eaf6052 100644 --- a/vendor/knative.dev/pkg/apis/duck/v1/source_types.go +++ b/vendor/knative.dev/pkg/apis/duck/v1/source_types.go @@ -24,12 +24,9 @@ import ( "k8s.io/apimachinery/pkg/runtime" "knative.dev/pkg/apis" - "knative.dev/pkg/apis/duck" + "knative.dev/pkg/apis/duck/ducktypes" ) -// Source is an Implementable "duck type". -var _ duck.Implementable = (*Source)(nil) - // +genduck // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object @@ -91,7 +88,6 @@ type SourceStatus struct { // CloudEventAttributes specifies the attributes that a Source // uses as part of its CloudEvents. type CloudEventAttributes struct { - // Type refers to the CloudEvent type attribute. Type string `json:"type,omitempty"` @@ -112,10 +108,11 @@ func (ss *SourceStatus) IsReady() bool { return false } +// Verify Source resources meet duck contracts. var ( - // Verify Source resources meet duck contracts. - _ duck.Populatable = (*Source)(nil) - _ apis.Listable = (*Source)(nil) + _ apis.Listable = (*Source)(nil) + _ ducktypes.Implementable = (*Source)(nil) + _ ducktypes.Populatable = (*Source)(nil) ) const ( @@ -125,7 +122,7 @@ const ( ) // GetFullType implements duck.Implementable -func (*Source) GetFullType() duck.Populatable { +func (*Source) GetFullType() ducktypes.Populatable { return &Source{} } diff --git a/vendor/knative.dev/pkg/apis/duck/v1/status_types.go b/vendor/knative.dev/pkg/apis/duck/v1/status_types.go index aab246b1f90..5ea75769482 100644 --- a/vendor/knative.dev/pkg/apis/duck/v1/status_types.go +++ b/vendor/knative.dev/pkg/apis/duck/v1/status_types.go @@ -20,7 +20,7 @@ import ( "context" "knative.dev/pkg/apis" - "knative.dev/pkg/apis/duck" + "knative.dev/pkg/apis/duck/ducktypes" "knative.dev/pkg/kmeta" ) @@ -29,8 +29,8 @@ import ( // Conditions is a simple wrapper around apis.Conditions to implement duck.Implementable. type Conditions apis.Conditions -// Conditions is an Implementable "duck type". -var _ duck.Implementable = (*Conditions)(nil) +// Conditions is an Implementable duck type. +var _ ducktypes.Implementable = (*Conditions)(nil) // Status shows how we expect folks to embed Conditions in // their Status field. @@ -66,14 +66,11 @@ func (s *Status) SetConditions(c apis.Conditions) { s.Conditions = Conditions(c) } -// In order for Conditions to be Implementable, KResource must be Populatable. -var _ duck.Populatable = (*KResource)(nil) - // Ensure KResource satisfies apis.Listable var _ apis.Listable = (*KResource)(nil) // GetFullType implements duck.Implementable -func (*Conditions) GetFullType() duck.Populatable { +func (*Conditions) GetFullType() ducktypes.Populatable { return &KResource{} } diff --git a/vendor/knative.dev/pkg/apis/duck/v1beta1/addressable_types.go b/vendor/knative.dev/pkg/apis/duck/v1beta1/addressable_types.go index 3e3f8286763..ba7bbc85d8b 100644 --- a/vendor/knative.dev/pkg/apis/duck/v1beta1/addressable_types.go +++ b/vendor/knative.dev/pkg/apis/duck/v1beta1/addressable_types.go @@ -24,7 +24,7 @@ import ( "k8s.io/apimachinery/pkg/runtime" "knative.dev/pkg/apis" - "knative.dev/pkg/apis/duck" + "knative.dev/pkg/apis/duck/ducktypes" v1 "knative.dev/pkg/apis/duck/v1" ) @@ -41,10 +41,11 @@ type Addressable struct { } var ( - // Addressable is an Implementable "duck type". - _ duck.Implementable = (*Addressable)(nil) // Addressable is a Convertible type. _ apis.Convertible = (*Addressable)(nil) + + // Addressable is an Implementable "duck type". + _ ducktypes.Implementable = (*Addressable)(nil) ) // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object @@ -66,14 +67,14 @@ type AddressStatus struct { Address *Addressable `json:"address,omitempty"` } +// Verify AddressableType resources meet duck contracts. var ( - // Verify AddressableType resources meet duck contracts. - _ duck.Populatable = (*AddressableType)(nil) - _ apis.Listable = (*AddressableType)(nil) + _ apis.Listable = (*AddressableType)(nil) + _ ducktypes.Populatable = (*AddressableType)(nil) ) // GetFullType implements duck.Implementable -func (*Addressable) GetFullType() duck.Populatable { +func (*Addressable) GetFullType() ducktypes.Populatable { return &AddressableType{} } diff --git a/vendor/knative.dev/pkg/apis/duck/v1beta1/binding_types.go b/vendor/knative.dev/pkg/apis/duck/v1beta1/binding_types.go new file mode 100644 index 00000000000..b9e970b3a2c --- /dev/null +++ b/vendor/knative.dev/pkg/apis/duck/v1beta1/binding_types.go @@ -0,0 +1,92 @@ +/* +Copyright 2020 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1beta1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + + "knative.dev/pkg/apis" + "knative.dev/pkg/apis/duck" + "knative.dev/pkg/tracker" +) + +// +genduck +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// Binding is a duck type that specifies the partial schema to which all +// Binding implementations should adhere. +type Binding struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec BindingSpec `json:"spec"` +} + +// Verify that Binding implements the appropriate interfaces. +var ( + _ duck.Implementable = (*Binding)(nil) + _ duck.Populatable = (*Binding)(nil) + _ apis.Listable = (*Binding)(nil) +) + +// BindingSpec specifies the spec portion of the Binding partial-schema. +type BindingSpec struct { + // Subject references the resource(s) whose "runtime contract" should be + // augmented by Binding implementations. + Subject tracker.Reference `json:"subject"` +} + +// GetFullType implements duck.Implementable +func (*Binding) GetFullType() duck.Populatable { + return &Binding{} +} + +// Populate implements duck.Populatable +func (t *Binding) Populate() { + t.Spec = BindingSpec{ + Subject: tracker.Reference{ + APIVersion: "apps/v1", + Kind: "Deployment", + Namespace: "default", + // Name and Selector are mutually exclusive, + // but we fill them both in for this test. + Name: "bazinga", + Selector: &metav1.LabelSelector{ + MatchLabels: map[string]string{ + "foo": "bar", + "baz": "blah", + }, + }, + }, + } +} + +// GetListType implements apis.Listable +func (*Binding) GetListType() runtime.Object { + return &BindingList{} +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// BindingList is a list of Binding resources +type BindingList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata"` + + Items []Binding `json:"items"` +} diff --git a/vendor/knative.dev/pkg/apis/duck/v1beta1/register.go b/vendor/knative.dev/pkg/apis/duck/v1beta1/register.go index ca8388ad484..160eff56b00 100644 --- a/vendor/knative.dev/pkg/apis/duck/v1beta1/register.go +++ b/vendor/knative.dev/pkg/apis/duck/v1beta1/register.go @@ -20,11 +20,12 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" - "knative.dev/pkg/apis/duck" + + "knative.dev/pkg/apis/duck/ducktypes" ) // SchemeGroupVersion is group version used to register these objects -var SchemeGroupVersion = schema.GroupVersion{Group: duck.GroupName, Version: "v1beta1"} +var SchemeGroupVersion = schema.GroupVersion{Group: ducktypes.GroupName, Version: "v1beta1"} // Kind takes an unqualified kind and returns back a Group qualified GroupKind func Kind(kind string) schema.GroupKind { @@ -49,6 +50,8 @@ func addKnownTypes(scheme *runtime.Scheme) error { (&KResource{}).GetListType(), &AddressableType{}, (&AddressableType{}).GetListType(), + &Binding{}, + (&Binding{}).GetListType(), ) metav1.AddToGroupVersion(scheme, SchemeGroupVersion) return nil diff --git a/vendor/knative.dev/pkg/apis/duck/v1beta1/source_types.go b/vendor/knative.dev/pkg/apis/duck/v1beta1/source_types.go index 5853a1ae410..60a502041aa 100644 --- a/vendor/knative.dev/pkg/apis/duck/v1beta1/source_types.go +++ b/vendor/knative.dev/pkg/apis/duck/v1beta1/source_types.go @@ -24,12 +24,9 @@ import ( "k8s.io/apimachinery/pkg/runtime" "knative.dev/pkg/apis" - "knative.dev/pkg/apis/duck" + "knative.dev/pkg/apis/duck/ducktypes" ) -// Source is an Implementable "duck type". -var _ duck.Implementable = (*Source)(nil) - // +genduck // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object @@ -97,10 +94,11 @@ func (ss *SourceStatus) IsReady() bool { return false } +// Verify Source resources meet duck contracts. var ( - // Verify Source resources meet duck contracts. - _ duck.Populatable = (*Source)(nil) - _ apis.Listable = (*Source)(nil) + _ apis.Listable = (*Source)(nil) + _ ducktypes.Implementable = (*Source)(nil) + _ ducktypes.Populatable = (*Source)(nil) ) const ( @@ -110,7 +108,7 @@ const ( ) // GetFullType implements duck.Implementable -func (*Source) GetFullType() duck.Populatable { +func (*Source) GetFullType() ducktypes.Populatable { return &Source{} } diff --git a/vendor/knative.dev/pkg/apis/duck/v1beta1/status_types.go b/vendor/knative.dev/pkg/apis/duck/v1beta1/status_types.go index 107592e85dd..ff7c68c2690 100644 --- a/vendor/knative.dev/pkg/apis/duck/v1beta1/status_types.go +++ b/vendor/knative.dev/pkg/apis/duck/v1beta1/status_types.go @@ -25,7 +25,7 @@ import ( "k8s.io/apimachinery/pkg/runtime" "knative.dev/pkg/apis" - "knative.dev/pkg/apis/duck" + "knative.dev/pkg/apis/duck/ducktypes" "knative.dev/pkg/kmeta" ) @@ -34,8 +34,8 @@ import ( // Conditions is a simple wrapper around apis.Conditions to implement duck.Implementable. type Conditions apis.Conditions -// Conditions is an Implementable "duck type". -var _ duck.Implementable = (*Conditions)(nil) +// Conditions is an Implementable duck type. +var _ ducktypes.Implementable = (*Conditions)(nil) // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object @@ -84,14 +84,14 @@ func (s *Status) SetConditions(c apis.Conditions) { s.Conditions = Conditions(c) } -// In order for Conditions to be Implementable, KResource must be Populatable. -var _ duck.Populatable = (*KResource)(nil) - -// Ensure KResource satisfies apis.Listable -var _ apis.Listable = (*KResource)(nil) +// Verify KResource resources meet duck contracts. +var ( + _ apis.Listable = (*KResource)(nil) + _ ducktypes.Populatable = (*KResource)(nil) +) // GetFullType implements duck.Implementable -func (*Conditions) GetFullType() duck.Populatable { +func (*Conditions) GetFullType() ducktypes.Populatable { return &KResource{} } diff --git a/vendor/knative.dev/pkg/apis/duck/v1beta1/zz_generated.deepcopy.go b/vendor/knative.dev/pkg/apis/duck/v1beta1/zz_generated.deepcopy.go index 152bb8828b5..d22c6724ac8 100644 --- a/vendor/knative.dev/pkg/apis/duck/v1beta1/zz_generated.deepcopy.go +++ b/vendor/knative.dev/pkg/apis/duck/v1beta1/zz_generated.deepcopy.go @@ -128,6 +128,83 @@ func (in *AddressableTypeList) DeepCopyObject() runtime.Object { return nil } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Binding) DeepCopyInto(out *Binding) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Binding. +func (in *Binding) DeepCopy() *Binding { + if in == nil { + return nil + } + out := new(Binding) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Binding) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *BindingList) DeepCopyInto(out *BindingList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Binding, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BindingList. +func (in *BindingList) DeepCopy() *BindingList { + if in == nil { + return nil + } + out := new(BindingList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *BindingList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *BindingSpec) DeepCopyInto(out *BindingSpec) { + *out = *in + in.Subject.DeepCopyInto(&out.Subject) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BindingSpec. +func (in *BindingSpec) DeepCopy() *BindingSpec { + if in == nil { + return nil + } + out := new(BindingSpec) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *CloudEventOverrides) DeepCopyInto(out *CloudEventOverrides) { *out = *in diff --git a/vendor/knative.dev/pkg/apis/duck/verify.go b/vendor/knative.dev/pkg/apis/duck/verify.go index 3f42330fff2..cbcc51117ce 100644 --- a/vendor/knative.dev/pkg/apis/duck/verify.go +++ b/vendor/knative.dev/pkg/apis/duck/verify.go @@ -20,29 +20,12 @@ import ( "encoding/json" "fmt" - "knative.dev/pkg/apis" + "knative.dev/pkg/apis/duck/ducktypes" "knative.dev/pkg/kmp" ) -// Implementable is implemented by the Fooable duck type that consumers -// are expected to embed as a `.status.fooable` field. -type Implementable interface { - // GetFullType returns an instance of a full resource wrapping - // an instance of this Implementable that can populate its fields - // to verify json roundtripping. - GetFullType() Populatable -} - -// Populatable is implemented by a skeleton resource wrapping an Implementable -// duck type. It will generally have TypeMeta, ObjectMeta, and a Status field -// wrapping a Fooable field. -type Populatable interface { - apis.Listable - - // Populate fills in all possible fields, so that we can verify that - // they roundtrip properly through JSON. - Populate() -} +type Implementable = ducktypes.Implementable +type Populatable = ducktypes.Populatable // VerifyType verifies that a particular concrete resource properly implements // the provided Implementable duck type. It is expected that under the resource diff --git a/vendor/knative.dev/pkg/configmap/hash-gen/main.go b/vendor/knative.dev/pkg/configmap/hash-gen/main.go index 72230b54588..8d9b7bfe032 100644 --- a/vendor/knative.dev/pkg/configmap/hash-gen/main.go +++ b/vendor/knative.dev/pkg/configmap/hash-gen/main.go @@ -85,9 +85,10 @@ func process(data []byte) ([]byte, error) { if existingAnnotation != nil { existingAnnotation.Value = checksum } else { + sumNode := strNode(checksum) + sumNode.Style = yaml.DoubleQuotedStyle annotations.Content = append(annotations.Content, - strNode(configmap.ExampleChecksumAnnotation), - strNode(checksum)) + strNode(configmap.ExampleChecksumAnnotation), sumNode) } var buffer bytes.Buffer diff --git a/vendor/knative.dev/pkg/injection/sharedmain/main.go b/vendor/knative.dev/pkg/injection/sharedmain/main.go index 6c4acf71ec4..676e47de824 100644 --- a/vendor/knative.dev/pkg/injection/sharedmain/main.go +++ b/vendor/knative.dev/pkg/injection/sharedmain/main.go @@ -33,14 +33,8 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/util/wait" - "k8s.io/apimachinery/pkg/watch" - "k8s.io/client-go/kubernetes/scheme" - typedcorev1 "k8s.io/client-go/kubernetes/typed/core/v1" "k8s.io/client-go/rest" "k8s.io/client-go/tools/clientcmd" - "k8s.io/client-go/tools/leaderelection" - "k8s.io/client-go/tools/leaderelection/resourcelock" - "k8s.io/client-go/tools/record" "go.uber.org/zap" apierrors "k8s.io/apimachinery/pkg/api/errors" @@ -48,7 +42,7 @@ import ( "knative.dev/pkg/configmap" "knative.dev/pkg/controller" "knative.dev/pkg/injection" - kle "knative.dev/pkg/leaderelection" + "knative.dev/pkg/leaderelection" "knative.dev/pkg/logging" "knative.dev/pkg/metrics" "knative.dev/pkg/profiling" @@ -108,110 +102,65 @@ func GetLoggingConfig(ctx context.Context) (*logging.Config, error) { } // GetLeaderElectionConfig gets the leader election config. -func GetLeaderElectionConfig(ctx context.Context) (*kle.Config, error) { - leaderElectionConfigMap, err := kubeclient.Get(ctx).CoreV1().ConfigMaps(system.Namespace()).Get(kle.ConfigMapName(), metav1.GetOptions{}) +func GetLeaderElectionConfig(ctx context.Context) (*leaderelection.Config, error) { + leaderElectionConfigMap, err := kubeclient.Get(ctx).CoreV1().ConfigMaps(system.Namespace()).Get(leaderelection.ConfigMapName(), metav1.GetOptions{}) if apierrors.IsNotFound(err) { - return kle.NewConfigFromConfigMap(nil) + return leaderelection.NewConfigFromConfigMap(nil) } else if err != nil { return nil, err } - return kle.NewConfigFromConfigMap(leaderElectionConfigMap) + return leaderelection.NewConfigFromConfigMap(leaderElectionConfigMap) } -// Main runs the generic main flow for non-webhook controllers with a new -// context. Use WebhookMainWith* if you need to serve webhooks. +// Main runs the generic main flow with a new context. +// If any of the contructed controllers are AdmissionControllers or Conversion webhooks, +// then a webhook is started to serve them. func Main(component string, ctors ...injection.ControllerConstructor) { // Set up signals so we handle the first shutdown signal gracefully. MainWithContext(signals.NewContext(), component, ctors...) } -// MainWithContext runs the generic main flow for non-webhook controllers. Use -// WebhookMainWithContext if you need to serve webhooks. -func MainWithContext(ctx context.Context, component string, ctors ...injection.ControllerConstructor) { - MainWithConfig(ctx, component, ParseAndGetConfigOrDie(), ctors...) -} - -// MainWithConfig runs the generic main flow for non-webhook controllers. Use -// WebhookMainWithConfig if you need to serve webhooks. -func MainWithConfig(ctx context.Context, component string, cfg *rest.Config, ctors ...injection.ControllerConstructor) { - log.Printf("Registering %d clients", len(injection.Default.GetClients())) - log.Printf("Registering %d informer factories", len(injection.Default.GetInformerFactories())) - log.Printf("Registering %d informers", len(injection.Default.GetInformers())) - log.Printf("Registering %d controllers", len(ctors)) - - MemStatsOrDie(ctx) - - // Adjust our client's rate limits based on the number of controllers we are running. - cfg.QPS = float32(len(ctors)) * rest.DefaultQPS - cfg.Burst = len(ctors) * rest.DefaultBurst - ctx = injection.WithConfig(ctx, cfg) - - ctx, informers := injection.Default.SetupInformers(ctx, cfg) +// Legacy aliases for back-compat. +var ( + WebhookMainWithContext = MainWithContext + WebhookMainWithConfig = MainWithConfig +) - logger, atomicLevel := SetupLoggerOrDie(ctx, component) - defer flush(logger) - ctx = logging.WithLogger(ctx, logger) - profilingHandler := profiling.NewHandler(logger, false) - profilingServer := profiling.NewServer(profilingHandler) - eg, egCtx := errgroup.WithContext(ctx) - eg.Go(profilingServer.ListenAndServe) - go func() { - // This will block until either a signal arrives or one of the grouped functions - // returns an error. - <-egCtx.Done() - - profilingServer.Shutdown(context.Background()) - if err := eg.Wait(); err != nil && err != http.ErrServerClosed { - logger.Errorw("Error while running server", zap.Error(err)) - } - }() - CheckK8sClientMinimumVersionOrDie(ctx, logger) +// MainWithContext runs the generic main flow for controllers and +// webhooks. Use MainWithContext if you do not need to serve webhooks. +func MainWithContext(ctx context.Context, component string, ctors ...injection.ControllerConstructor) { - run := func(ctx context.Context) { - cmw := SetupConfigMapWatchOrDie(ctx, logger) - controllers, _ := ControllersAndWebhooksFromCtors(ctx, cmw, ctors...) - WatchLoggingConfigOrDie(ctx, cmw, logger, atomicLevel, component) - WatchObservabilityConfigOrDie(ctx, cmw, profilingHandler, logger, component) + // TODO(mattmoor): Remove this once HA is stable. + disableHighAvailability := flag.Bool("disable-ha", false, + "Whether to disable high-availability functionality for this component. This flag will be deprecated "+ + "and removed when we have promoted this feature to stable, so do not pass it without filing an "+ + "issue upstream!") - logger.Info("Starting configuration manager...") - if err := cmw.Start(ctx.Done()); err != nil { - logger.Fatalw("Failed to start configuration manager", zap.Error(err)) - } - logger.Info("Starting informers...") - if err := controller.StartInformers(ctx.Done(), informers...); err != nil { - logger.Fatalw("Failed to start informers", zap.Error(err)) - } - logger.Info("Starting controllers...") - go controller.StartAll(ctx, controllers...) + // HACK: This parses flags, so the above should be set once this runs. + cfg := ParseAndGetConfigOrDie() - <-ctx.Done() + if *disableHighAvailability { + ctx = WithHADisabled(ctx) } - // Set up leader election config - leaderElectionConfig, err := GetLeaderElectionConfig(ctx) - if err != nil { - logger.Fatalw("Error loading leader election configuration", zap.Error(err)) - } - leConfig := leaderElectionConfig.GetComponentConfig(component) + MainWithConfig(ctx, component, cfg, ctors...) +} - if !leConfig.LeaderElect { - logger.Infof("%v will not run in leader-elected mode", component) - run(ctx) - } else { - RunLeaderElected(ctx, logger, run, leConfig) - } +type haDisabledKey struct{} + +// WithHADisabled signals to MainWithConfig that it should not set up an appropriate leader elector for this component. +func WithHADisabled(ctx context.Context) context.Context { + return context.WithValue(ctx, haDisabledKey{}, struct{}{}) } -// WebhookMainWithContext runs the generic main flow for controllers and -// webhooks. Use MainWithContext if you do not need to serve webhooks. -func WebhookMainWithContext(ctx context.Context, component string, ctors ...injection.ControllerConstructor) { - WebhookMainWithConfig(ctx, component, ParseAndGetConfigOrDie(), ctors...) +// IsHADisabled checks the context for the desired to disabled leader elector. +func IsHADisabled(ctx context.Context) bool { + return ctx.Value(haDisabledKey{}) != nil } -// WebhookMainWithConfig runs the generic main flow for controllers and webhooks -// with the given config. Use MainWithConfig if you do not need to serve -// webhooks. -func WebhookMainWithConfig(ctx context.Context, component string, cfg *rest.Config, ctors ...injection.ControllerConstructor) { +// MainWithConfig runs the generic main flow for controllers and webhooks +// with the given config. +func MainWithConfig(ctx context.Context, component string, cfg *rest.Config, ctors ...injection.ControllerConstructor) { log.Printf("Registering %d clients", len(injection.Default.GetClients())) log.Printf("Registering %d informer factories", len(injection.Default.GetInformerFactories())) log.Printf("Registering %d informers", len(injection.Default.GetInformers())) @@ -238,10 +187,11 @@ func WebhookMainWithConfig(ctx context.Context, component string, cfg *rest.Conf if err != nil { logger.Fatalf("Error loading leader election configuration: %v", err) } - leConfig := leaderElectionConfig.GetComponentConfig(component) - if leConfig.LeaderElect { + + if !IsHADisabled(ctx) { // Signal that we are executing in a context with leader election. - ctx = kle.WithDynamicLeaderElectorBuilder(ctx, kubeclient.Get(ctx), leConfig) + ctx = leaderelection.WithDynamicLeaderElectorBuilder(ctx, kubeclient.Get(ctx), + leaderElectionConfig.GetComponentConfig(component)) } controllers, webhooks := ControllersAndWebhooksFromCtors(ctx, cmw, ctors...) @@ -251,6 +201,14 @@ func WebhookMainWithConfig(ctx context.Context, component string, cfg *rest.Conf eg, egCtx := errgroup.WithContext(ctx) eg.Go(profilingServer.ListenAndServe) + // Many of the webhooks rely on configuration, e.g. configurable defaults, feature flags. + // So make sure that we have synchonized our configuration state before launching the + // webhooks, so that things are properly initialized. + logger.Info("Starting configuration manager...") + if err := cmw.Start(ctx.Done()); err != nil { + logger.Fatalw("Failed to start configuration manager", zap.Error(err)) + } + // If we have one or more admission controllers, then start the webhook // and pass them in. var wh *webhook.Webhook @@ -267,10 +225,6 @@ func WebhookMainWithConfig(ctx context.Context, component string, cfg *rest.Conf }) } - logger.Info("Starting configuration manager...") - if err := cmw.Start(ctx.Done()); err != nil { - logger.Fatalw("Failed to start configuration manager", zap.Error(err)) - } logger.Info("Starting informers...") if err := controller.StartInformers(ctx.Done(), informers...); err != nil { logger.Fatalw("Failed to start informers", zap.Error(err)) @@ -414,7 +368,7 @@ func ControllersAndWebhooksFromCtors(ctx context.Context, // Check whether the context has been infused with a leader elector builder. // If it has, then every reconciler we plan to start MUST implement LeaderAware. - leEnabled := kle.HasLeaderElection(ctx) + leEnabled := leaderelection.HasLeaderElection(ctx) controllers := make([]*controller.Impl, 0, len(ctors)) webhooks := make([]interface{}, 0) @@ -437,66 +391,3 @@ func ControllersAndWebhooksFromCtors(ctx context.Context, return controllers, webhooks } - -// RunLeaderElected runs the given function in leader elected mode. The function -// will be run only once the leader election lock is obtained. -func RunLeaderElected(ctx context.Context, logger *zap.SugaredLogger, run func(context.Context), leConfig kle.ComponentConfig) { - recorder := controller.GetEventRecorder(ctx) - if recorder == nil { - // Create event broadcaster - logger.Debug("Creating event broadcaster") - eventBroadcaster := record.NewBroadcaster() - watches := []watch.Interface{ - eventBroadcaster.StartLogging(logger.Named("event-broadcaster").Infof), - eventBroadcaster.StartRecordingToSink( - &typedcorev1.EventSinkImpl{Interface: kubeclient.Get(ctx).CoreV1().Events(system.Namespace())}), - } - recorder = eventBroadcaster.NewRecorder( - scheme.Scheme, corev1.EventSource{Component: leConfig.Component}) - go func() { - <-ctx.Done() - for _, w := range watches { - w.Stop() - } - }() - } - - // Create a unique identifier so that two controllers on the same host don't - // race. - id, err := kle.UniqueID() - if err != nil { - logger.Fatalw("Failed to get unique ID for leader election", zap.Error(err)) - } - logger.Infof("%v will run in leader-elected mode with id %v", leConfig.Component, id) - - // rl is the resource used to hold the leader election lock. - rl, err := resourcelock.New(leConfig.ResourceLock, - system.Namespace(), // use namespace we are running in - leConfig.Component, // component is used as the resource name - kubeclient.Get(ctx).CoreV1(), - kubeclient.Get(ctx).CoordinationV1(), - resourcelock.ResourceLockConfig{ - Identity: id, - EventRecorder: recorder, - }) - if err != nil { - logger.Fatalw("Error creating lock", zap.Error(err)) - } - - // Execute the `run` function when we have the lock. - leaderelection.RunOrDie(ctx, leaderelection.LeaderElectionConfig{ - Lock: rl, - LeaseDuration: leConfig.LeaseDuration, - RenewDeadline: leConfig.RenewDeadline, - RetryPeriod: leConfig.RetryPeriod, - Callbacks: leaderelection.LeaderCallbacks{ - OnStartedLeading: run, - OnStoppedLeading: func() { - logger.Fatal("Leader election lost") - }, - }, - ReleaseOnCancel: true, - // TODO: use health check watchdog, knative/pkg#1048 - Name: leConfig.Component, - }) -} diff --git a/vendor/knative.dev/pkg/leaderelection/config.go b/vendor/knative.dev/pkg/leaderelection/config.go index 880dd8c2b98..b694c4fd206 100644 --- a/vendor/knative.dev/pkg/leaderelection/config.go +++ b/vendor/knative.dev/pkg/leaderelection/config.go @@ -52,11 +52,6 @@ func NewConfigFromMap(data map[string]string) (*Config, error) { cm.AsDuration("retryPeriod", &config.RetryPeriod), cm.AsUint32("buckets", &config.Buckets), - - // enabledComponents are not validated here, because they are dependent on - // the component. Components should provide additional validation for this - // field. - cm.AsStringSet("enabledComponents", &config.EnabledComponents), ); err != nil { return nil, err } @@ -84,45 +79,42 @@ func NewConfigFromConfigMap(configMap *corev1.ConfigMap) (*Config, error) { // contained within a single namespace. Typically these will correspond to a // single source repository, viz: serving or eventing. type Config struct { - ResourceLock string - Buckets uint32 - LeaseDuration time.Duration - RenewDeadline time.Duration - RetryPeriod time.Duration + ResourceLock string + Buckets uint32 + LeaseDuration time.Duration + RenewDeadline time.Duration + RetryPeriod time.Duration + + // This field is deprecated and will be removed once downstream + // repositories have removed their validation of it. + // TODO(https://github.com/knative/pkg/issues/1478): Remove this field. EnabledComponents sets.String } func (c *Config) GetComponentConfig(name string) ComponentConfig { - if c.EnabledComponents.Has(name) { - return ComponentConfig{ - Component: name, - LeaderElect: true, - Buckets: c.Buckets, - ResourceLock: c.ResourceLock, - LeaseDuration: c.LeaseDuration, - RenewDeadline: c.RenewDeadline, - RetryPeriod: c.RetryPeriod, - } + return ComponentConfig{ + Component: name, + Buckets: c.Buckets, + ResourceLock: c.ResourceLock, + LeaseDuration: c.LeaseDuration, + RenewDeadline: c.RenewDeadline, + RetryPeriod: c.RetryPeriod, } - - return defaultComponentConfig(name) } func defaultConfig() *Config { return &Config{ - ResourceLock: "leases", - Buckets: 1, - LeaseDuration: 15 * time.Second, - RenewDeadline: 10 * time.Second, - RetryPeriod: 2 * time.Second, - EnabledComponents: sets.NewString(), + ResourceLock: "leases", + Buckets: 1, + LeaseDuration: 15 * time.Second, + RenewDeadline: 10 * time.Second, + RetryPeriod: 2 * time.Second, } } // ComponentConfig represents the leader election config for a single component. type ComponentConfig struct { Component string - LeaderElect bool Buckets uint32 ResourceLock string LeaseDuration time.Duration @@ -165,13 +157,6 @@ func newStatefulSetConfig() (*statefulSetConfig, error) { return ssc, nil } -func defaultComponentConfig(name string) ComponentConfig { - return ComponentConfig{ - Component: name, - LeaderElect: false, - } -} - // ConfigMapName returns the name of the configmap to read for leader election // settings. func ConfigMapName() string { diff --git a/vendor/knative.dev/pkg/test/spoof/spoof.go b/vendor/knative.dev/pkg/test/spoof/spoof.go index c3a0f7b8779..3fe945cc209 100644 --- a/vendor/knative.dev/pkg/test/spoof/spoof.go +++ b/vendor/knative.dev/pkg/test/spoof/spoof.go @@ -135,7 +135,7 @@ func New( // Enable Zipkin tracing roundTripper := &ochttp.Transport{ Base: transport, - Propagation: tracecontextb3.TraceContextEgress, + Propagation: tracecontextb3.TraceContextB3Egress, } sc := SpoofingClient{ diff --git a/vendor/knative.dev/pkg/webhook/psbinding/psbinding.go b/vendor/knative.dev/pkg/webhook/psbinding/psbinding.go index 0b89705c7e0..9472e16bdad 100644 --- a/vendor/knative.dev/pkg/webhook/psbinding/psbinding.go +++ b/vendor/knative.dev/pkg/webhook/psbinding/psbinding.go @@ -273,7 +273,7 @@ func (ac *Reconciler) reconcileMutatingWebhook(ctx context.Context, caCert []byt } set := gks[gk] if set == nil { - set = sets.NewString() + set = make(sets.String, 1) } set.Insert(gv.Version) gks[gk] = set diff --git a/vendor/knative.dev/test-infra/scripts/e2e-tests.sh b/vendor/knative.dev/test-infra/scripts/e2e-tests.sh index 354819385c5..9f96ce57fb3 100644 --- a/vendor/knative.dev/test-infra/scripts/e2e-tests.sh +++ b/vendor/knative.dev/test-infra/scripts/e2e-tests.sh @@ -17,7 +17,7 @@ # This is a helper script for Knative E2E test scripts. # See README.md for instructions on how to use it. -source $(dirname ${BASH_SOURCE})/library.sh +source $(dirname "${BASH_SOURCE[0]}")/library.sh # Build a resource name based on $E2E_BASE_NAME, a suffix and $BUILD_NUMBER. # Restricts the name length to 40 chars (the limit for resource names in GCP). @@ -82,7 +82,7 @@ function go_test_e2e() { local test_options="" local go_options="" [[ ! " $@" == *" -tags="* ]] && go_options="-tags=e2e" - report_go_test -v -race -count=1 ${go_options} $@ ${test_options} + report_go_test -v -race -count=1 ${go_options} $@ "${test_options}" } # Dump info about the test cluster. If dump_extra_cluster_info() is defined, calls it too. @@ -93,32 +93,32 @@ function dump_cluster_state() { echo "*** Start of information dump ***" echo "***************************************" - local output="${ARTIFACTS}/k8s.dump-$(basename ${E2E_SCRIPT}).txt" + local output="${ARTIFACTS}/k8s.dump-$(basename "${E2E_SCRIPT}").txt" echo ">>> The dump is located at ${output}" for crd in $(kubectl api-resources --verbs=list -o name | sort); do - local count="$(kubectl get $crd --all-namespaces --no-headers 2>/dev/null | wc -l)" + local count="$(kubectl get "$crd" --all-namespaces --no-headers 2>/dev/null | wc -l)" echo ">>> ${crd} (${count} objects)" if [[ "${count}" > "0" ]]; then - echo ">>> ${crd} (${count} objects)" >> ${output} + echo ">>> ${crd} (${count} objects)" >> "${output}" - echo ">>> Listing" >> ${output} - kubectl get ${crd} --all-namespaces >> ${output} + echo ">>> Listing" >> "${output}" + kubectl get "${crd}" --all-namespaces >> "${output}" - echo ">>> Details" >> ${output} + echo ">>> Details" >> "${output}" if [[ "${crd}" == "secrets" ]]; then echo "Secrets are ignored for security reasons" >> ${output} elif [[ "${crd}" == "events" ]]; then echo "events are ignored as making a lot of noise" >> ${output} else - kubectl get ${crd} --all-namespaces -o yaml >> ${output} + kubectl get "${crd}" --all-namespaces -o yaml >> "${output}" fi fi done if function_exists dump_extra_cluster_state; then - echo ">>> Extra dump" >> ${output} - dump_extra_cluster_state >> ${output} + echo ">>> Extra dump" >> "${output}" + dump_extra_cluster_state >> "${output}" fi echo "***************************************" echo "*** E2E TEST FAILED ***" @@ -135,8 +135,8 @@ function save_metadata() { geo_key="Zone" geo_value="${E2E_CLUSTER_REGION}-${E2E_CLUSTER_ZONE}" fi - local cluster_version="$(gcloud container clusters list --project=${E2E_PROJECT_ID} --format='value(currentMasterVersion)')" - cat << EOF > ${ARTIFACTS}/metadata.json + local cluster_version="$(gcloud container clusters list --project="${E2E_PROJECT_ID}" --format='value(currentMasterVersion)')" + cat << EOF > "${ARTIFACTS}"/metadata.json { "E2E:${geo_key}": "${geo_value}", "E2E:Machine": "${E2E_CLUSTER_MACHINE}", @@ -155,7 +155,7 @@ function resolve_k8s_version() { if [[ "${target_version}" == "default" ]]; then local version="$(gcloud container get-server-config \ --format='value(defaultClusterVersion)' \ - --zone=$2)" + --zone="$2")" [[ -z "${version}" ]] && return 1 E2E_CLUSTER_VERSION="${version}" echo "Using default version, ${E2E_CLUSTER_VERSION}" @@ -164,7 +164,7 @@ function resolve_k8s_version() { # Fetch valid versions local versions="$(gcloud container get-server-config \ --format='value(validMasterVersions)' \ - --zone=$2)" + --zone="$2")" [[ -z "${versions}" ]] && return 1 local gke_versions=($(echo -n "${versions//;/ }")) echo "Available GKE versions in $2 are [${versions//;/, }]" @@ -173,7 +173,7 @@ function resolve_k8s_version() { E2E_CLUSTER_VERSION="${gke_versions[0]}" echo "Using latest version, ${E2E_CLUSTER_VERSION}" else - local latest="$(echo "${gke_versions[@]}" | tr ' ' '\n' | grep -E ^${target_version} | sort -V | tail -1)" + local latest="$(echo "${gke_versions[@]}" | tr ' ' '\n' | grep -E "^${target_version}" | sort -V | tail -1)" if [[ -z "${latest}" ]]; then echo "ERROR: version ${target_version} is not available" return 1 @@ -215,9 +215,9 @@ function create_test_cluster() { fi # SSH keys are not used, but kubetest checks for their existence. # Touch them so if they don't exist, empty files are create to satisfy the check. - mkdir -p $HOME/.ssh - touch $HOME/.ssh/google_compute_engine.pub - touch $HOME/.ssh/google_compute_engine + mkdir -p "$HOME"/.ssh + touch "$HOME"/.ssh/google_compute_engine.pub + touch "$HOME"/.ssh/google_compute_engine # Assume test failed (see details in set_test_return_code()). set_test_return_code 1 local gcloud_project="${GCP_PROJECT}" @@ -246,13 +246,13 @@ function create_test_cluster() { # TODO(adrcunha): Remove once https://github.com/kubernetes/test-infra/issues/13029 is fixed. local kubedir="$(mktemp -d -t kubernetes.XXXXXXXXXX)" local test_wrapper="${kubedir}/e2e-test.sh" - mkdir ${kubedir}/cluster - ln -s "$(which kubectl)" ${kubedir}/cluster/kubectl.sh - echo "#!/usr/bin/env bash" > ${test_wrapper} - echo "cd $(pwd) && set -x" >> ${test_wrapper} - echo "${E2E_SCRIPT} ${test_cmd_args}" >> ${test_wrapper} - chmod +x ${test_wrapper} - cd ${kubedir} + mkdir "${kubedir}"/cluster + ln -s "$(which kubectl)" "${kubedir}"/cluster/kubectl.sh + echo "#!/usr/bin/env bash" > "${test_wrapper}" + echo "cd $(pwd) && set -x" >> "${test_wrapper}" + echo "${E2E_SCRIPT} ${test_cmd_args}" >> "${test_wrapper}" + chmod +x "${test_wrapper}" + cd "${kubedir}" # Create cluster and run the tests create_test_cluster_with_retries "${CLUSTER_CREATION_ARGS[@]}" \ @@ -266,7 +266,7 @@ function create_test_cluster() { local result=$(get_test_return_code) echo "Artifacts were written to ${ARTIFACTS}" echo "Test result code is ${result}" - exit ${result} + exit "${result}" } # Retry backup regions/zones if cluster creations failed due to stockout. @@ -296,7 +296,7 @@ function create_test_cluster_with_retries() { [[ "${E2E_CLUSTER_ZONE}" == "${zone_not_provided}" ]] && E2E_CLUSTER_ZONE="" local cluster_creation_zone="${E2E_CLUSTER_REGION}" [[ -n "${E2E_CLUSTER_ZONE}" ]] && cluster_creation_zone="${E2E_CLUSTER_REGION}-${E2E_CLUSTER_ZONE}" - resolve_k8s_version ${e2e_cluster_target_version} ${cluster_creation_zone} || return 1 + resolve_k8s_version "${e2e_cluster_target_version}" "${cluster_creation_zone}" || return 1 header "Creating test cluster ${E2E_CLUSTER_VERSION} in ${cluster_creation_zone}" # Don't fail test for kubetest, as it might incorrectly report test failure @@ -304,17 +304,17 @@ function create_test_cluster_with_retries() { set +o errexit export CLUSTER_API_VERSION=${E2E_CLUSTER_VERSION} run_go_tool k8s.io/test-infra/kubetest \ - kubetest "$@" --gcp-region=${cluster_creation_zone} 2>&1 | tee ${cluster_creation_log} + kubetest "$@" --gcp-region="${cluster_creation_zone}" 2>&1 | tee "${cluster_creation_log}" # Exit if test succeeded [[ "$(get_test_return_code)" == "0" ]] && return 0 # Retry if cluster creation failed because of: # - stockout (https://github.com/knative/test-infra/issues/592) # - latest GKE not available in this region/zone yet (https://github.com/knative/test-infra/issues/694) - [[ -z "$(grep -Fo 'does not have enough resources available to fulfill' ${cluster_creation_log})" \ - && -z "$(grep -Fo 'ResponseError: code=400, message=No valid versions with the prefix' ${cluster_creation_log})" \ - && -z "$(grep -Po 'ResponseError: code=400, message=Master version "[0-9a-z\-\.]+" is unsupported' ${cluster_creation_log})" \ - && -z "$(grep -Po 'only \d+ nodes out of \d+ have registered; this is likely due to Nodes failing to start correctly' ${cluster_creation_log})" ]] \ + [[ -z "$(grep -Fo 'does not have enough resources available to fulfill' "${cluster_creation_log}")" \ + && -z "$(grep -Fo 'ResponseError: code=400, message=No valid versions with the prefix' "${cluster_creation_log}")" \ + && -z "$(grep -Po 'ResponseError: code=400, message=Master version "[0-9a-z\-\.]+" is unsupported' "${cluster_creation_log}")" \ + && -z "$(grep -Po 'only \d+ nodes out of \d+ have registered; this is likely due to Nodes failing to start correctly' "${cluster_creation_log}")" ]] \ && return 1 done done @@ -345,23 +345,23 @@ function setup_test_cluster() { local k8s_user=$(gcloud config get-value core/account) local k8s_cluster=$(kubectl config current-context) - is_protected_cluster ${k8s_cluster} && \ + is_protected_cluster "${k8s_cluster}" && \ abort "kubeconfig context set to ${k8s_cluster}, which is forbidden" # If cluster admin role isn't set, this is a brand new cluster # Setup the admin role and also KO_DOCKER_REPO if it is a GKE cluster if [[ -z "$(kubectl get clusterrolebinding cluster-admin-binding 2> /dev/null)" && "${k8s_cluster}" =~ ^gke_.* ]]; then - acquire_cluster_admin_role ${k8s_user} ${E2E_CLUSTER_NAME} ${E2E_CLUSTER_REGION} ${E2E_CLUSTER_ZONE} + acquire_cluster_admin_role "${k8s_user}" "${E2E_CLUSTER_NAME}" "${E2E_CLUSTER_REGION}" "${E2E_CLUSTER_ZONE}" # Incorporate an element of randomness to ensure that each run properly publishes images. export KO_DOCKER_REPO=gcr.io/${E2E_PROJECT_ID}/${E2E_BASE_NAME}-e2e-img/${RANDOM} fi # Safety checks - is_protected_gcr ${KO_DOCKER_REPO} && \ + is_protected_gcr "${KO_DOCKER_REPO}" && \ abort "\$KO_DOCKER_REPO set to ${KO_DOCKER_REPO}, which is forbidden" # Use default namespace for all subsequent kubectl commands in this context - kubectl config set-context ${k8s_cluster} --namespace=default + kubectl config set-context "${k8s_cluster}" --namespace=default echo "- gcloud project is ${E2E_PROJECT_ID}" echo "- gcloud user is ${k8s_user}" @@ -390,7 +390,7 @@ function setup_test_cluster() { # Gets the exit of the test script. # For more details, see set_test_return_code(). function get_test_return_code() { - echo $(cat ${TEST_RESULT_FILE}) + echo $(cat "${TEST_RESULT_FILE}") } # Set the return code that the test script will return. @@ -401,7 +401,7 @@ function set_test_return_code() { # We store the real test result to return it later, ignoring any teardown # failure in kubetest. # TODO(adrcunha): Get rid of this workaround. - echo -n "$1"> ${TEST_RESULT_FILE} + echo -n "$1"> "${TEST_RESULT_FILE}" } # Signal (as return code and in the logs) that all E2E tests passed. @@ -436,10 +436,10 @@ E2E_SCRIPT_CUSTOM_FLAGS=() # Parse flags and initialize the test cluster. function initialize() { - E2E_SCRIPT="$(get_canonical_path $0)" + E2E_SCRIPT="$(get_canonical_path "$0")" E2E_CLUSTER_VERSION="${SERVING_GKE_VERSION}" - cd ${REPO_ROOT_DIR} + cd "${REPO_ROOT_DIR}" while [[ $# -ne 0 ]]; do local parameter=$1 # Try parsing flag as a custom one. diff --git a/vendor/knative.dev/test-infra/scripts/library.sh b/vendor/knative.dev/test-infra/scripts/library.sh index da54be8b9f9..ab8390f1aeb 100644 --- a/vendor/knative.dev/test-infra/scripts/library.sh +++ b/vendor/knative.dev/test-infra/scripts/library.sh @@ -65,7 +65,7 @@ fi # Print error message and exit 1 # Parameters: $1..$n - error message to be displayed function abort() { - echo "error: $@" + echo "error: $*" exit 1 } @@ -498,6 +498,27 @@ function start_latest_knative_eventing() { start_knative_eventing "${KNATIVE_EVENTING_RELEASE}" } +# Install Knative Eventing extension in the current cluster. +# Parameters: $1 - Knative Eventing extension manifest. +# $2 - Namespace to look for ready pods into +function start_knative_eventing_extension() { + header "Starting Knative Eventing Extension" + echo "Installing Extension CRDs from $1" + kubectl apply -f "$1" + wait_until_pods_running "$2" || return 1 +} + +# Install the stable release of eventing extension sugar controller in the current cluster. +# Parameters: $1 - Knative Eventing release version, e.g. 0.16.0 +function start_release_eventing_sugar_controller() { + start_knative_eventing_extension "https://storage.googleapis.com/knative-releases/eventing/previous/v$1/eventing-sugar-controller.yaml" "knative-eventing" +} + +# Install the sugar cotroller eventing extension +function start_latest_eventing_sugar_controller() { + start_knative_eventing_extension "${KNATIVE_EVENTING_SUGAR_CONTROLLER_RELEASE}" "knative-eventing" +} + # Run a go tool, installing it first if necessary. # Parameters: $1 - tool package/dir for go get/install. # $2 - tool to run. @@ -643,9 +664,9 @@ function remove_broken_symlinks() { local target="$(ls -l ${link})" target="${target##* -> }" [[ ${target} == /* ]] || target="./${target}" - target="$(cd `dirname ${link}` && cd ${target%/*} && echo $PWD/${target##*/})" + target="$(cd `dirname "${link}"` && cd "${target%/*}" && echo "$PWD"/"${target##*/}")" if [[ ${target} != *github.com/knative/* && ${target} != *knative.dev/* ]]; then - unlink ${link} + unlink "${link}" continue fi done @@ -659,7 +680,7 @@ function get_canonical_path() { local path=$1 local pwd=${2:-.} [[ ${path} == /* ]] || path="${pwd}/${path}" - echo "$(cd ${path%/*} && echo $PWD/${path##*/})" + echo "$(cd "${path%/*}" && echo "$PWD"/"${path##*/}")" } # List changed files in the current PR. @@ -670,7 +691,7 @@ function list_changed_files() { # Avoid warning when there are more than 1085 files renamed: # https://stackoverflow.com/questions/7830728/warning-on-diff-renamelimit-variable-when-doing-git-push git config diff.renames 0 - git --no-pager diff --name-only ${PULL_BASE_SHA}..${PULL_PULL_SHA} + git --no-pager diff --name-only "${PULL_BASE_SHA}".."${PULL_PULL_SHA}" else # Do our best if not running in Prow git diff --name-only HEAD^ @@ -705,7 +726,7 @@ function get_latest_knative_yaml_source() { local major_minor="${branch_name##release-}" # Find the latest release manifest with the same major&minor version. local yaml_source_path="$( - gsutil ls gs://knative-releases/${repo_name}/previous/v${major_minor}.*/${yaml_name}.yaml 2> /dev/null \ + gsutil ls "gs://knative-releases/${repo_name}/previous/v${major_minor}.*/${yaml_name}.yaml" 2> /dev/null \ | sort \ | tail -n 1 \ | cut -b6-)" @@ -745,8 +766,8 @@ function shellcheck_new_files() { # Initializations that depend on previous functions. # These MUST come last. -readonly _TEST_INFRA_SCRIPTS_DIR="$(dirname $(get_canonical_path ${BASH_SOURCE[0]}))" -readonly REPO_NAME_FORMATTED="Knative $(capitalize ${REPO_NAME//-/ })" +readonly _TEST_INFRA_SCRIPTS_DIR="$(dirname $(get_canonical_path "${BASH_SOURCE[0]}"))" +readonly REPO_NAME_FORMATTED="Knative $(capitalize "${REPO_NAME//-/ }")" # Public latest nightly or release yaml files. readonly KNATIVE_SERVING_RELEASE_CRDS="$(get_latest_knative_yaml_source "serving" "serving-crds")" @@ -754,3 +775,4 @@ readonly KNATIVE_SERVING_RELEASE_CORE="$(get_latest_knative_yaml_source "serving readonly KNATIVE_NET_ISTIO_RELEASE="$(get_latest_knative_yaml_source "net-istio" "net-istio")" readonly KNATIVE_EVENTING_RELEASE="$(get_latest_knative_yaml_source "eventing" "eventing")" readonly KNATIVE_MONITORING_RELEASE="$(get_latest_knative_yaml_source "serving" "monitoring")" +readonly KNATIVE_EVENTING_SUGAR_CONTROLLER_RELEASE="$(get_latest_knative_yaml_source "eventing" "eventing-sugar-controller")" diff --git a/vendor/knative.dev/test-infra/scripts/performance-tests.sh b/vendor/knative.dev/test-infra/scripts/performance-tests.sh index 9c9c2590007..a56e975decf 100644 --- a/vendor/knative.dev/test-infra/scripts/performance-tests.sh +++ b/vendor/knative.dev/test-infra/scripts/performance-tests.sh @@ -17,7 +17,7 @@ # This is a helper script for Knative performance test scripts. # See README.md for instructions on how to use it. -source $(dirname ${BASH_SOURCE})/library.sh +source $(dirname "${BASH_SOURCE[0]}")/library.sh # Configurable parameters. # If not provided, they will fall back to the default values. @@ -37,9 +37,9 @@ readonly SLACK_WRITE_TOKEN="/etc/performance-test/slack-write-token" function setup_user() { echo ">> Setting up user" echo "Using gcloud user ${SERVICE_ACCOUNT_NAME}" - gcloud config set core/account ${SERVICE_ACCOUNT_NAME} + gcloud config set core/account "${SERVICE_ACCOUNT_NAME}" echo "Using gcloud project ${PROJECT_NAME}" - gcloud config set core/project ${PROJECT_NAME} + gcloud config set core/project "${PROJECT_NAME}" } # Update resources installed on the cluster. @@ -48,7 +48,7 @@ function setup_user() { function update_cluster() { # --zone option can work with both region and zone, (e.g. us-central1 and # us-central1-a), so we don't need to add extra check here. - gcloud container clusters get-credentials $1 --zone=$2 --project=${PROJECT_NAME} || abort "failed to get cluster creds" + gcloud container clusters get-credentials "$1" --zone="$2" --project="${PROJECT_NAME}" || abort "failed to get cluster creds" # Set up the configmap to run benchmarks in production echo ">> Setting up 'prod' config-mako on cluster $1 in zone $2" cat <> Project contains clusters:" ${all_clusters} + echo ">> Project contains clusters:" "${all_clusters}" for cluster in ${all_clusters}; do local name=$(echo "${cluster}" | cut -f1 -d",") # the cluster name is prefixed with "${REPO_NAME}--", here we should only handle clusters belonged to the current repo @@ -101,7 +101,7 @@ function update_clusters() { local zone=$(echo "${cluster}" | cut -f2 -d",") # Update all resources installed on the cluster - update_cluster ${name} ${zone} + update_cluster "${name}" "${zone}" done header "Done updating all clusters" } @@ -109,14 +109,14 @@ function update_clusters() { # Run the perf-tests tool # Parameters: $1..$n - parameters passed to the tool function run_perf_cluster_tool() { - go run ${REPO_ROOT_DIR}/vendor/knative.dev/pkg/testutils/clustermanager/perf-tests $@ + go run "${REPO_ROOT_DIR}"/vendor/knative.dev/pkg/testutils/clustermanager/perf-tests $@ } # Delete the old clusters belonged to the current repo, and recreate them with the same configuration. function recreate_clusters() { header "Recreating clusters for ${REPO_NAME}" run_perf_cluster_tool --recreate \ - --gcp-project=${PROJECT_NAME} --repository=${REPO_NAME} --benchmark-root=${BENCHMARK_ROOT_PATH} \ + --gcp-project="${PROJECT_NAME}" --repository="${REPO_NAME}" --benchmark-root="${BENCHMARK_ROOT_PATH}" \ || abort "failed recreating clusters for ${REPO_NAME}" header "Done recreating clusters" # Update all clusters after they are recreated @@ -128,7 +128,7 @@ function recreate_clusters() { function reconcile_benchmark_clusters() { header "Reconciling clusters for ${REPO_NAME}" run_perf_cluster_tool --reconcile \ - --gcp-project=${PROJECT_NAME} --repository=${REPO_NAME} --benchmark-root=${BENCHMARK_ROOT_PATH} \ + --gcp-project="${PROJECT_NAME}" --repository="${REPO_NAME}" --benchmark-root="${BENCHMARK_ROOT_PATH}" \ || abort "failed reconciling clusters for ${REPO_NAME}" header "Done reconciling clusters" # For now, do nothing after reconciling the clusters, and the next update_clusters job will automatically diff --git a/vendor/knative.dev/test-infra/scripts/presubmit-tests.sh b/vendor/knative.dev/test-infra/scripts/presubmit-tests.sh index 1435a346984..bd0402c51dc 100644 --- a/vendor/knative.dev/test-infra/scripts/presubmit-tests.sh +++ b/vendor/knative.dev/test-infra/scripts/presubmit-tests.sh @@ -17,7 +17,7 @@ # This is a helper script for Knative presubmit test scripts. # See README.md for instructions on how to use it. -source $(dirname ${BASH_SOURCE})/library.sh +source $(dirname "${BASH_SOURCE[0]}")/library.sh # Custom configuration of presubmit tests readonly DISABLE_MD_LINTING=${DISABLE_MD_LINTING:-0} @@ -113,7 +113,7 @@ function report_build_test() { local report_name="$1" shift local errors="" - capture_output "${report}" "$@" || errors="$(cat ${report})" + capture_output "${report}" "$@" || errors="$(cat "${report}")" create_junit_xml _build_tests "${report_name}" "${errors}" [[ -z "${errors}" ]] } @@ -130,11 +130,11 @@ function markdown_build_tests() { local failed=0 if (( ! DISABLE_MD_LINTING )); then subheader "Linting the markdown files" - report_build_test Markdown_Lint lint_markdown ${mdfiles} || failed=1 + report_build_test Markdown_Lint lint_markdown "${mdfiles}" || failed=1 fi if (( ! DISABLE_MD_LINK_CHECK )); then subheader "Checking links in the markdown files" - report_build_test Markdown_Link check_links_in_markdown ${mdfiles} || failed=1 + report_build_test Markdown_Link check_links_in_markdown "${mdfiles}" || failed=1 fi return ${failed} } @@ -181,7 +181,7 @@ function default_build_test_runner() { | sort | uniq | tr '\n' ' ')" for pkg in ${tagged_pkgs}; do # `go test -c` lets us compile the tests but do not run them. - if ! capture_output "${report}" go test -c -tags="${tags}" ${pkg} ; then + if ! capture_output "${report}" go test -c -tags="${tags}" "${pkg}" ; then failed=1 # Consider an error message everything that's not a successful test result. errors_go2+="$(grep -v '^\(ok\|\?\)\s\+\(github\.com\|knative\.dev\)/' "${report}")" @@ -266,6 +266,8 @@ function run_integration_tests() { # Default integration test runner that runs all `test/e2e-*tests.sh`. function default_integration_test_runner() { + # options is always empty. + # TODO: remove it or indeed allow passing options. local options="" local failed=0 for e2e_test in $(find test/ -name e2e-*tests.sh); do @@ -324,7 +326,7 @@ function main() { echo ">> node name" echo "$(curl -H "Metadata-Flavor: Google" 'http://169.254.169.254/computeMetadata/v1/instance/name' 2> /dev/null)" echo ">> pod name" - echo ${HOSTNAME} + echo "${HOSTNAME}" fi [[ -z $1 ]] && set -- "--all-tests" @@ -357,7 +359,7 @@ function main() { readonly RUN_INTEGRATION_TESTS readonly TESTS_TO_RUN - cd ${REPO_ROOT_DIR} + cd "${REPO_ROOT_DIR}" || exit # Tests to be performed, in the right order if --all-tests is passed. diff --git a/vendor/knative.dev/test-infra/scripts/release.sh b/vendor/knative.dev/test-infra/scripts/release.sh index d23c4c33b5f..a10b842f38e 100644 --- a/vendor/knative.dev/test-infra/scripts/release.sh +++ b/vendor/knative.dev/test-infra/scripts/release.sh @@ -17,7 +17,7 @@ # This is a helper script for Knative release scripts. # See README.md for instructions on how to use it. -source $(dirname ${BASH_SOURCE})/library.sh +source $(dirname "${BASH_SOURCE[0]}")/library.sh # Organization name in GitHub; defaults to Knative. readonly ORG_NAME="${ORG_NAME:-knative}" @@ -50,9 +50,9 @@ function tag_images_in_yamls() { for file in $@; do [[ "${file##*.}" != "yaml" ]] && continue echo "Inspecting ${file}" - for image in $(grep -o "${DOCKER_BASE}/[a-z\./-]\+@sha256:[0-9a-f]\+" ${file}); do + for image in $(grep -o "${DOCKER_BASE}/[a-z\./-]\+@sha256:[0-9a-f]\+" "${file}"); do for region in "" ${GEO_REGIONS// /. }; do - gcloud -q container images add-tag ${image} ${region}${image%%@*}:${TAG} + gcloud -q container images add-tag "${image}" "${region}${image%%@*}:${TAG}" done done done @@ -66,16 +66,16 @@ function publish_to_gcs() { local DEST="gs://${RELEASE_GCS_BUCKET}/$1/" shift echo "Publishing [$@] to ${DEST}" - gsutil -m cp $@ ${DEST} + gsutil -m cp $@ "${DEST}" } # Before publishing the files, cleanup the `latest` dir if it exists. local latest_dir="gs://${RELEASE_GCS_BUCKET}/latest" - if [[ -n "$(gsutil ls ${latest_dir} 2> /dev/null)" ]]; then + if [[ -n "$(gsutil ls "${latest_dir}" 2> /dev/null)" ]]; then echo "Cleaning up '${latest_dir}' first" - gsutil -m rm ${latest_dir}/** + gsutil -m rm "${latest_dir}"/** fi verbose_gsutil_cp latest $@ - [[ -n ${TAG} ]] && verbose_gsutil_cp previous/${TAG} $@ + [[ -n ${TAG} ]] && verbose_gsutil_cp previous/"${TAG}" $@ } # These are global environment variables. @@ -113,7 +113,7 @@ function hub_tool() { function git_push() { local repo_url="${REPO_UPSTREAM}" [[ -n "${GITHUB_TOKEN}}" ]] && repo_url="${repo_url/:\/\//:\/\/${GITHUB_TOKEN}@}" - git push ${repo_url} $@ + git push "${repo_url}" $@ } # Return the master version of a release. @@ -148,14 +148,14 @@ function setup_upstream() { echo "Remote upstream URL is '${upstream}'" if [[ -z "${upstream}" ]]; then echo "Setting remote upstream URL to '${REPO_UPSTREAM}'" - git remote add upstream ${REPO_UPSTREAM} + git remote add upstream "${REPO_UPSTREAM}" fi } # Fetch the release branch, so we can check it out. function setup_branch() { [[ -z "${RELEASE_BRANCH}" ]] && return - git fetch ${REPO_UPSTREAM} ${RELEASE_BRANCH}:upstream/${RELEASE_BRANCH} + git fetch "${REPO_UPSTREAM}" "${RELEASE_BRANCH}:upstream/${RELEASE_BRANCH}" } # Setup version, branch and release notes for a auto release. @@ -168,8 +168,8 @@ function prepare_auto_release() { local tags="$(git tag | cut -d 'v' -f2 | cut -d '.' -f1-2 | sort -V | uniq)" local branches="$( { (git branch -r | grep upstream/release-) ; (git branch | grep release-); } | cut -d '-' -f2 | sort -V | uniq)" - echo "Versions released (from tags): [" ${tags} "]" - echo "Versions released (from branches): [" ${branches} "]" + echo "Versions released (from tags): [" "${tags}" "]" + echo "Versions released (from branches): [" "${branches}" "]" local release_number="" for i in ${branches}; do @@ -192,7 +192,7 @@ function prepare_auto_release() { # If --release-notes not used, add a placeholder if [[ -z "${RELEASE_NOTES}" ]]; then RELEASE_NOTES="$(mktemp)" - echo "[add release notes here]" > ${RELEASE_NOTES} + echo "[add release notes here]" > "${RELEASE_NOTES}" fi } @@ -218,7 +218,7 @@ function prepare_dot_release() { if [[ -z "${RELEASE_BRANCH}" ]]; then echo "Last release is ${last_version}" # Determine branch - major_minor_version="$(master_version ${last_version})" + major_minor_version="$(master_version "${last_version}")" RELEASE_BRANCH="release-${major_minor_version}" echo "Last release branch is ${RELEASE_BRANCH}" else @@ -227,8 +227,8 @@ function prepare_dot_release() { [[ -n "${major_minor_version}" ]] || abort "cannot get release major/minor version" # Ensure there are new commits in the branch, otherwise we don't create a new release setup_branch - local last_release_commit="$(git rev-list -n 1 ${last_version})" - local release_branch_commit="$(git rev-list -n 1 upstream/${RELEASE_BRANCH})" + local last_release_commit="$(git rev-list -n 1 "${last_version}")" + local release_branch_commit="$(git rev-list -n 1 upstream/"${RELEASE_BRANCH}")" [[ -n "${last_release_commit}" ]] || abort "cannot get last release commit" [[ -n "${release_branch_commit}" ]] || abort "cannot get release branch last commit" echo "Version ${last_version} is at commit ${last_release_commit}" @@ -239,13 +239,13 @@ function prepare_dot_release() { exit 0 fi # Create new release version number - local last_build="$(release_build_number ${last_version})" + local last_build="$(release_build_number "${last_version}")" RELEASE_VERSION="${major_minor_version}.$(( last_build + 1 ))" echo "Will create release ${RELEASE_VERSION} at commit ${release_branch_commit}" # If --release-notes not used, copy from the latest release if [[ -z "${RELEASE_NOTES}" ]]; then RELEASE_NOTES="$(mktemp)" - hub_tool release show -f "%b" ${last_version} > ${RELEASE_NOTES} + hub_tool release show -f "%b" "${last_version}" > "${RELEASE_NOTES}" echo "Release notes from ${last_version} copied to ${RELEASE_NOTES}" fi } @@ -274,14 +274,14 @@ function build_from_nightly_release() { for yaml in ${yamls_dir}/*.yaml; do sed -i -e "s#${NIGHTLY_GCR}#${RELEASE_GCR}#" "${yaml}" done - ARTIFACTS_TO_PUBLISH="$(find ${yamls_dir} -name '*.yaml' -printf '%p ')" + ARTIFACTS_TO_PUBLISH="$(find "${yamls_dir}" -name '*.yaml' -printf '%p ')" echo "Copying nightly images" copy_nightly_images_to_release_gcr "${NIGHTLY_GCR}" "${FROM_NIGHTLY_RELEASE}" # Create a release branch from the nightly release tag. - local commit="$(hash_from_tag ${FROM_NIGHTLY_RELEASE})" + local commit="$(hash_from_tag "${FROM_NIGHTLY_RELEASE}")" echo "Creating release branch ${RELEASE_BRANCH} at commit ${commit}" - git checkout -b ${RELEASE_BRANCH} ${commit} || abort "cannot create branch" - git_push upstream ${RELEASE_BRANCH} || abort "cannot push branch" + git checkout -b "${RELEASE_BRANCH}" "${commit}" || abort "cannot create branch" + git_push upstream "${RELEASE_BRANCH}" || abort "cannot push branch" } # Build a release from source. @@ -338,7 +338,7 @@ function parse_flags() { local is_dot_release=0 local is_auto_release=0 - cd ${REPO_ROOT_DIR} + cd "${REPO_ROOT_DIR}" while [[ $# -ne 0 ]]; do local parameter=$1 case ${parameter} in @@ -357,7 +357,7 @@ function parse_flags() { --github-token) [[ ! -f "$1" ]] && abort "file $1 doesn't exist" # Remove any trailing newline/space from token - GITHUB_TOKEN="$(echo -n $(cat $1))" + GITHUB_TOKEN="$(echo -n $(cat "$1"))" [[ -n "${GITHUB_TOKEN}" ]] || abort "file $1 is empty" ;; --release-gcr) @@ -416,7 +416,7 @@ function parse_flags() { # TODO(adrcunha): "dot" releases from release branches require releasing nightlies # for such branches, which we don't do yet. [[ "${RELEASE_VERSION}" =~ ^[0-9]+\.[0-9]+\.0$ ]] || abort "version format must be 'X.Y.0'" - RELEASE_BRANCH="release-$(master_version ${RELEASE_VERSION})" + RELEASE_BRANCH="release-$(master_version "${RELEASE_VERSION}")" prepare_from_nightly_release setup_upstream fi @@ -487,12 +487,12 @@ function run_validation_tests() { # Parameters: $1..$n - files to add to the release. function publish_artifacts() { (( ! PUBLISH_RELEASE )) && return - tag_images_in_yamls ${ARTIFACTS_TO_PUBLISH} + tag_images_in_yamls "${ARTIFACTS_TO_PUBLISH}" if [[ -n "${RELEASE_DIR}" ]]; then - cp ${ARTIFACTS_TO_PUBLISH} ${RELEASE_DIR} || abort "cannot copy release to '${RELEASE_DIR}'" + cp "${ARTIFACTS_TO_PUBLISH}" "${RELEASE_DIR}" || abort "cannot copy release to '${RELEASE_DIR}'" fi - [[ -n "${RELEASE_GCS_BUCKET}" ]] && publish_to_gcs ${ARTIFACTS_TO_PUBLISH} - publish_to_github ${ARTIFACTS_TO_PUBLISH} + [[ -n "${RELEASE_GCS_BUCKET}" ]] && publish_to_gcs "${ARTIFACTS_TO_PUBLISH}" + publish_to_github "${ARTIFACTS_TO_PUBLISH}" banner "New release published successfully" } @@ -581,24 +581,24 @@ function publish_to_github() { local commitish="" # Copy files to a separate dir for artifact in $@; do - cp ${artifact} ${attachments_dir}/ + cp ${artifact} "${attachments_dir}"/ attachments+=("--attach=${artifact}#$(basename ${artifact})") done - echo -e "${title}\n" > ${description} + echo -e "${title}\n" > "${description}" if [[ -n "${RELEASE_NOTES}" ]]; then - cat ${RELEASE_NOTES} >> ${description} + cat "${RELEASE_NOTES}" >> "${description}" fi - git tag -a ${TAG} -m "${title}" - git_push tag ${TAG} + git tag -a "${TAG}" -m "${title}" + git_push tag "${TAG}" [[ -n "${RELEASE_BRANCH}" ]] && commitish="--commitish=${RELEASE_BRANCH}" for i in {2..0}; do hub_tool release create \ --prerelease \ ${attachments[@]} \ - --file=${description} \ - ${commitish} \ - ${TAG} && return 0 + --file="${description}" \ + "${commitish}" \ + "${TAG}" && return 0 if [[ "${i}" -gt 0 ]]; then echo "Error publishing the release, retrying in 15s..." sleep 15 diff --git a/vendor/modules.txt b/vendor/modules.txt index aac4251ab33..ea0399163a9 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -317,7 +317,7 @@ go.uber.org/zap/internal/exit go.uber.org/zap/internal/ztest go.uber.org/zap/zapcore go.uber.org/zap/zaptest -# golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 +# golang.org/x/crypto v0.0.0-20200709230013-948cd5f35899 golang.org/x/crypto/cast5 golang.org/x/crypto/openpgp golang.org/x/crypto/openpgp/armor @@ -332,7 +332,7 @@ golang.org/x/lint/golint # golang.org/x/mod v0.3.0 golang.org/x/mod/module golang.org/x/mod/semver -# golang.org/x/net v0.0.0-20200625001655-4c5254603344 +# golang.org/x/net v0.0.0-20200707034311-ab3426394381 golang.org/x/net/context golang.org/x/net/context/ctxhttp golang.org/x/net/http/httpguts @@ -364,7 +364,7 @@ golang.org/x/text/unicode/norm golang.org/x/text/width # golang.org/x/time v0.0.0-20200416051211-89c76fbcd5d1 golang.org/x/time/rate -# golang.org/x/tools v0.0.0-20200701000337-a32c0cb1d5b2 +# golang.org/x/tools v0.0.0-20200710042808-f1c4188a97a1 golang.org/x/tools/cmd/goimports golang.org/x/tools/go/ast/astutil golang.org/x/tools/go/gcexportdata @@ -408,7 +408,7 @@ gonum.org/v1/gonum/lapack gonum.org/v1/gonum/lapack/gonum gonum.org/v1/gonum/lapack/lapack64 gonum.org/v1/gonum/mat -# google.golang.org/api v0.28.0 +# google.golang.org/api v0.29.0 google.golang.org/api/container/v1beta1 google.golang.org/api/googleapi google.golang.org/api/googleapi/transport @@ -437,7 +437,7 @@ google.golang.org/appengine/internal/socket google.golang.org/appengine/internal/urlfetch google.golang.org/appengine/socket google.golang.org/appengine/urlfetch -# google.golang.org/genproto v0.0.0-20200701001935-0939c5918c31 +# google.golang.org/genproto v0.0.0-20200710124503-20a17af7bd0e google.golang.org/genproto/googleapis/api google.golang.org/genproto/googleapis/api/annotations google.golang.org/genproto/googleapis/api/distribution @@ -945,12 +945,13 @@ k8s.io/utils/buffer k8s.io/utils/integer k8s.io/utils/pointer k8s.io/utils/trace -# knative.dev/pkg v0.0.0-20200708171447-5358179e7499 +# knative.dev/pkg v0.0.0-20200714153419-27fe4e191080 ## explicit knative.dev/pkg/apiextensions/storageversion knative.dev/pkg/apiextensions/storageversion/cmd/migrate knative.dev/pkg/apis knative.dev/pkg/apis/duck +knative.dev/pkg/apis/duck/ducktypes knative.dev/pkg/apis/duck/v1 knative.dev/pkg/apis/duck/v1alpha1 knative.dev/pkg/apis/duck/v1beta1 @@ -1063,7 +1064,7 @@ knative.dev/pkg/webhook/resourcesemantics knative.dev/pkg/webhook/resourcesemantics/conversion knative.dev/pkg/webhook/resourcesemantics/defaulting knative.dev/pkg/webhook/resourcesemantics/validation -# knative.dev/test-infra v0.0.0-20200708165947-2cd922769fa4 +# knative.dev/test-infra v0.0.0-20200713220518-5a4c4cad5372 ## explicit knative.dev/test-infra/scripts # sigs.k8s.io/yaml v1.2.0 From 47e5f53723322b0b23414b5eb4da6cf9171aaa16 Mon Sep 17 00:00:00 2001 From: Nacho Cano Date: Tue, 14 Jul 2020 09:09:46 -0700 Subject: [PATCH 05/11] update deps again --- vendor/knative.dev/pkg/apis/duck/v1_tests.go | 78 ------------------- .../pkg/apis/duck/v1beta1_tests.go | 56 ------------- 2 files changed, 134 deletions(-) delete mode 100644 vendor/knative.dev/pkg/apis/duck/v1_tests.go delete mode 100644 vendor/knative.dev/pkg/apis/duck/v1beta1_tests.go diff --git a/vendor/knative.dev/pkg/apis/duck/v1_tests.go b/vendor/knative.dev/pkg/apis/duck/v1_tests.go deleted file mode 100644 index ba56a994cad..00000000000 --- a/vendor/knative.dev/pkg/apis/duck/v1_tests.go +++ /dev/null @@ -1,78 +0,0 @@ -/* -Copyright 2020 The Knative Authors - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package duck - -import ( - "testing" - - appsv1 "k8s.io/api/apps/v1" - batchv1 "k8s.io/api/batch/v1" - - v1 "knative.dev/pkg/apis/duck/v1" -) - -// Conditions is an Implementable "duck type". -var _ Implementable = (*v1.Conditions)(nil) - -// In order for Conditions to be Implementable, KResource must be Populatable. -var _ Populatable = (*v1.KResource)(nil) - -// Source is an Implementable "duck type". -var _ Implementable = (*v1.Source)(nil) - -// Verify Source resources meet duck contracts. -var _ Populatable = (*v1.Source)(nil) - -var _ Populatable = (*v1.WithPod)(nil) -var _ Implementable = (*v1.PodSpecable)(nil) - -func TestV1TypesImplements(t *testing.T) { - testCases := []struct { - instance interface{} - iface Implementable - }{ - {instance: &v1.AddressableType{}, iface: &v1.Addressable{}}, - {instance: &v1.KResource{}, iface: &v1.Conditions{}}, - } - for _, tc := range testCases { - if err := VerifyType(tc.instance, tc.iface); err != nil { - t.Error(err) - } - } -} - -func TestV1ImplementsPodSpecable(t *testing.T) { - instances := []interface{}{ - &v1.WithPod{}, - &appsv1.ReplicaSet{}, - &appsv1.Deployment{}, - &appsv1.StatefulSet{}, - &appsv1.DaemonSet{}, - &batchv1.Job{}, - } - for _, instance := range instances { - if err := VerifyType(instance, &v1.PodSpecable{}); err != nil { - t.Error(err) - } - } -} - -// Addressable is an Implementable "duck type". -var _ Implementable = (*v1.Addressable)(nil) - -// Verify AddressableType resources meet duck contracts. -var _ Populatable = (*v1.AddressableType)(nil) diff --git a/vendor/knative.dev/pkg/apis/duck/v1beta1_tests.go b/vendor/knative.dev/pkg/apis/duck/v1beta1_tests.go deleted file mode 100644 index 23731d8c79e..00000000000 --- a/vendor/knative.dev/pkg/apis/duck/v1beta1_tests.go +++ /dev/null @@ -1,56 +0,0 @@ -/* -Copyright 2020 The Knative Authors - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package duck - -import ( - "testing" - - "knative.dev/pkg/apis/duck/v1beta1" -) - -// v1beta1.Conditions is an Implementable "duck type". -var _ Implementable = (*v1beta1.Conditions)(nil) - -// In order for v1beta1.Conditions to be Implementable, v1beta1.KResource must be Populatable. -var _ Populatable = (*v1beta1.KResource)(nil) - -// v1beta1.Source is an Implementable "duck type". -var _ Implementable = (*v1beta1.Source)(nil) - -// Verify v1beta1.Source resources meet duck contracts. -var _ Populatable = (*v1beta1.Source)(nil) - -// Addressable is an Implementable "duck type". -var _ Implementable = (*v1beta1.Addressable)(nil) - -// Verify AddressableType resources meet duck contracts. -var _ Populatable = (*v1beta1.AddressableType)(nil) - -func TestV1Beta1TypesImplements(t *testing.T) { - testCases := []struct { - instance interface{} - iface Implementable - }{ - {instance: &v1beta1.AddressableType{}, iface: &v1beta1.Addressable{}}, - {instance: &v1beta1.KResource{}, iface: &v1beta1.Conditions{}}, - } - for _, tc := range testCases { - if err := VerifyType(tc.instance, tc.iface); err != nil { - t.Error(err) - } - } -} From 2fa2feb6caa89f6b3a0711fd7c487e89b6c15a2b Mon Sep 17 00:00:00 2001 From: Nacho Cano Date: Tue, 14 Jul 2020 13:03:20 -0700 Subject: [PATCH 06/11] updating deps --- go.mod | 2 +- go.sum | 4 +- vendor/knative.dev/pkg/hash/bucketer.go | 121 +++++++++++++ vendor/knative.dev/pkg/hash/doc.go | 27 +++ vendor/knative.dev/pkg/hash/hash.go | 166 ++++++++++++++++++ .../knative.dev/pkg/leaderelection/context.go | 55 ++++-- .../knative.dev/pkg/leaderelection/ordinal.go | 27 --- vendor/modules.txt | 3 +- 8 files changed, 358 insertions(+), 47 deletions(-) create mode 100644 vendor/knative.dev/pkg/hash/bucketer.go create mode 100644 vendor/knative.dev/pkg/hash/doc.go create mode 100644 vendor/knative.dev/pkg/hash/hash.go delete mode 100644 vendor/knative.dev/pkg/leaderelection/ordinal.go diff --git a/go.mod b/go.mod index da1092d6c84..24a7453d51e 100644 --- a/go.mod +++ b/go.mod @@ -37,7 +37,7 @@ require ( k8s.io/apiserver v0.17.6 k8s.io/client-go v11.0.1-0.20190805182717-6502b5e7b1b5+incompatible k8s.io/utils v0.0.0-20200124190032-861946025e34 - knative.dev/pkg v0.0.0-20200714180919-c49f5b61e264 + knative.dev/pkg v0.0.0-20200714191819-258f5b86c26e knative.dev/test-infra v0.0.0-20200713220518-5a4c4cad5372 sigs.k8s.io/yaml v1.2.0 ) diff --git a/go.sum b/go.sum index 678ecd82c4f..2ff93f1c795 100644 --- a/go.sum +++ b/go.sum @@ -1662,8 +1662,8 @@ k8s.io/utils v0.0.0-20200124190032-861946025e34/go.mod h1:sZAwmy6armz5eXlNoLmJcl knative.dev/caching v0.0.0-20200116200605-67bca2c83dfa/go.mod h1:dHXFU6CGlLlbzaWc32g80cR92iuBSpsslDNBWI8C7eg= knative.dev/eventing-contrib v0.11.2/go.mod h1:SnXZgSGgMSMLNFTwTnpaOH7hXDzTFtw0J8OmHflNx3g= knative.dev/pkg v0.0.0-20200207155214-fef852970f43/go.mod h1:pgODObA1dTyhNoFxPZTTjNWfx6F0aKsKzn+vaT9XO/Q= -knative.dev/pkg v0.0.0-20200714180919-c49f5b61e264 h1:jWAd2WlgkvsJ8ruSZs1SgOheOwaew75z3z+3jta2jcs= -knative.dev/pkg v0.0.0-20200714180919-c49f5b61e264/go.mod h1:yFXTzV2GIB30Qs6pdJNCbtKaIEhxH9fsmrrltAqfjWE= +knative.dev/pkg v0.0.0-20200714191819-258f5b86c26e h1:ArGv5Xtx5A/bkZfK8CNUl/euzRSfo4az2B4qKa25beE= +knative.dev/pkg v0.0.0-20200714191819-258f5b86c26e/go.mod h1:yFXTzV2GIB30Qs6pdJNCbtKaIEhxH9fsmrrltAqfjWE= knative.dev/test-infra v0.0.0-20200713220518-5a4c4cad5372 h1:NZzdNmKYP3L7fut/SNOxLgTgXVvQrygXiYpAeIMGMwM= knative.dev/test-infra v0.0.0-20200713220518-5a4c4cad5372/go.mod h1:vtT6dLs/iNj8pKcfag8CSVqHKNMgyCFtU/g1pV7Bovs= modernc.org/cc v1.0.0/go.mod h1:1Sk4//wdnYJiUIxnW8ddKpaOJCF37yAdqYnkxUpaYxw= diff --git a/vendor/knative.dev/pkg/hash/bucketer.go b/vendor/knative.dev/pkg/hash/bucketer.go new file mode 100644 index 00000000000..bdeeadb4ebf --- /dev/null +++ b/vendor/knative.dev/pkg/hash/bucketer.go @@ -0,0 +1,121 @@ +/* +Copyright 2020 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// This file contains the utilities to make bucketing decisions. + +package hash + +import ( + "sync" + + lru "github.com/hashicorp/golang-lru" + "k8s.io/apimachinery/pkg/types" + "k8s.io/apimachinery/pkg/util/sets" + "knative.dev/pkg/reconciler" +) + +var _ reconciler.Bucket = (*Bucket)(nil) + +// BucketSet answers to what bucket does key X belong in a +// consistent manner (consistent as in consistent hashing). +type BucketSet struct { + // Stores the cached lookups. cache is internally thread safe. + cache *lru.Cache + + // mu guards buckets. + mu sync.RWMutex + // All the bucket names. Needed for building hash universe. + buckets sets.String +} + +// Bucket implements reconciler.Bucket and wraps around BuketSet +// for bucketing functions. +type Bucket struct { + name string + // `name` must be in this BucketSet.buckets. + buckets *BucketSet +} + +// Scientifically inferred preferred cache size. +const cacheSize = 4096 + +func newCache() *lru.Cache { + c, _ := lru.New(cacheSize) + return c +} + +// NewBucketSet creates a new bucket set with the given universe +// of bucket names. +func NewBucketSet(bucketList sets.String) *BucketSet { + return &BucketSet{ + cache: newCache(), + buckets: bucketList, + } +} + +// NewBucket creates a new bucket. Caller MUST make sure that +// the given `name` is in the given `bl.buckets`. +func NewBucket(name string, bl *BucketSet) *Bucket { + return &Bucket{ + name: name, + buckets: bl, + } +} + +// Name implements Bucket. +func (b *Bucket) Name() string { + return b.name +} + +// Has returns true if this bucket owns the key and +// implements reconciler.Bucket interface. +func (b *Bucket) Has(nn types.NamespacedName) bool { + return b.buckets.Owner(nn.String()) == b.name +} + +// Owner returns the owner of the key. +// Owner will cache the results for faster lookup. +func (b *BucketSet) Owner(key string) string { + if v, ok := b.cache.Get(key); ok { + return v.(string) + } + b.mu.RLock() + defer b.mu.RUnlock() + l := ChooseSubset(b.buckets, 1 /*single query wanted*/, key) + ret := l.UnsortedList()[0] + b.cache.Add(key, ret) + return ret +} + +// BucketList returns the bucket names of this BucketSet in random order. +func (b *BucketSet) BucketList() []string { + b.mu.RLock() + defer b.mu.RUnlock() + + return b.buckets.UnsortedList() +} + +// Update updates the universe of buckets. +func (b *BucketSet) Update(newB sets.String) { + b.mu.Lock() + defer b.mu.Unlock() + // In theory we can iterate over the map and + // purge only the keys that moved to a new shard. + // But this might be more expensive than re-build + // the cache as reconciliations happen. + b.cache.Purge() + b.buckets = newB +} diff --git a/vendor/knative.dev/pkg/hash/doc.go b/vendor/knative.dev/pkg/hash/doc.go new file mode 100644 index 00000000000..5cb01faa637 --- /dev/null +++ b/vendor/knative.dev/pkg/hash/doc.go @@ -0,0 +1,27 @@ +/* +Copyright 2020 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Package hash contains various Knative specific hashing utilities. +// +// - ChooseSubset is a consistent hashing/mapping function providing +// a consistent selection of N keys from M (N<=M) keys for a given +// target. +// - BucketSet is a bucketer library which uses ChooseSubset under the +// the hood in order to implement consistent mapping between keys and +// set of buckets, indentified by unique names. Compared to basic bucket +// implementtion which just does hash%num_buckets, when the number of +// buckets change only a small subset of keys are supposed to migrate. +package hash diff --git a/vendor/knative.dev/pkg/hash/hash.go b/vendor/knative.dev/pkg/hash/hash.go new file mode 100644 index 00000000000..b6b6421229c --- /dev/null +++ b/vendor/knative.dev/pkg/hash/hash.go @@ -0,0 +1,166 @@ +/* +Copyright 2020 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package hash + +// This file contains the implementation of the subsetting algorithm for +// choosing a subset of input values in a consistent manner. + +import ( + "bytes" + "hash" + "hash/fnv" + "sort" + "strconv" + + "k8s.io/apimachinery/pkg/util/sets" +) + +const ( + startSalt = "start-angle-salt" + stepSalt = "step-angle-salt" + + // universe represents the possible range of angles [0, universe). + // We want to have universe divide total range evenly to reduce bias. + universe = (1 << 11) +) + +// computeAngle returns a uint64 number which represents +// a hash built off the given `n` string for consistent selection +// algorithm. +// We return uint64 here and cast after computing modulo, since +// int might 32 bits on 32 platforms and that would trim result. +func computeHash(n []byte, h hash.Hash64) uint64 { + h.Reset() + h.Write(n) + return h.Sum64() +} + +type hashData struct { + // The set of all hashes for fast lookup and to name mapping + nameLookup map[int]string + // Sorted set of hashes for selection algorithm. + hashPool []int + // start angle + start int + // step angle + step int +} + +func (hd *hashData) fromIndexSet(s sets.Int) sets.String { + ret := make(sets.String, len(s)) + for v := range s { + ret.Insert(hd.nameForHIndex(v)) + } + return ret +} + +func (hd *hashData) nameForHIndex(hi int) string { + return hd.nameLookup[hd.hashPool[hi]] +} + +func buildHashes(in sets.String, target string) *hashData { + // Any one changing this function must execute + // `go test -run=TestOverlay -count=200`. + // This is to ensure there is no regression in the selection + // algorithm. + + // Sorted list to ensure consistent results every time. + from := in.List() + // Write in two pieces, so we don't allocate temp string which is sum of both. + buf := bytes.NewBufferString(target) + buf.WriteString(startSalt) + hasher := fnv.New64a() + hd := &hashData{ + nameLookup: make(map[int]string, len(from)), + hashPool: make([]int, len(from)), + start: int(computeHash(buf.Bytes(), hasher) % universe), + } + buf.Truncate(len(target)) // Discard the angle salt. + buf.WriteString(stepSalt) + hd.step = int(computeHash(buf.Bytes(), hasher) % universe) + + for i, f := range from { + buf.Reset() // This retains the storage. + // Make unique sets for every target. + buf.WriteString(f) + buf.WriteString(target) + h := computeHash(buf.Bytes(), hasher) + hs := int(h % universe) + // Two values slotted to the same bucket. + // On average should happen with 1/universe probability. + _, ok := hd.nameLookup[hs] + for ok { + // Feed the hash as salt. + buf.WriteString(strconv.FormatUint(h, 16 /*append hex strings for shortness*/)) + h = computeHash(buf.Bytes(), hasher) + hs = int(h % universe) + _, ok = hd.nameLookup[hs] + } + + hd.hashPool[i] = hs + hd.nameLookup[hs] = f + } + // Sort for consistent mapping later. + sort.Slice(hd.hashPool, func(i, j int) bool { + return hd.hashPool[i] < hd.hashPool[j] + }) + return hd +} + +// ChooseSubset consistently chooses n items from `from`, using +// `target` as a seed value. +// ChooseSubset is an internal function and presumes sanitized inputs. +// TODO(vagababov): once initial impl is ready, think about how to cache +// the prepared data. +func ChooseSubset(from sets.String, n int, target string) sets.String { + if n >= len(from) { + return from + } + + hashData := buildHashes(from, target) + + // The algorithm for selection does the following: + // 0. Select angle to be the start angle + // 1. While n candidates are not selected + // 2. Find the index for that angle. + // 2.1. While that index is already selected pick next index + // 3. Advance angle by `step` + // 4. Goto 1. + selection := sets.NewInt() + angle := hashData.start + hpl := len(hashData.hashPool) + for len(selection) < n { + root := sort.Search(hpl, func(i int) bool { + return hashData.hashPool[i] >= angle + }) + // Wrap around. + if root == hpl { + root = 0 + } + // Already matched this one. Continue to the next index. + for selection.Has(root) { + root += 1 + if root == hpl { + root = 0 + } + } + selection.Insert(root) + angle = (angle + hashData.step) % universe + } + + return hashData.fromIndexSet(selection) +} diff --git a/vendor/knative.dev/pkg/leaderelection/context.go b/vendor/knative.dev/pkg/leaderelection/context.go index 18f7e23eb69..eaae67a7788 100644 --- a/vendor/knative.dev/pkg/leaderelection/context.go +++ b/vendor/knative.dev/pkg/leaderelection/context.go @@ -24,9 +24,11 @@ import ( "sync" "k8s.io/apimachinery/pkg/types" + "k8s.io/apimachinery/pkg/util/sets" "k8s.io/client-go/kubernetes" "k8s.io/client-go/tools/leaderelection" "k8s.io/client-go/tools/leaderelection/resourcelock" + "knative.dev/pkg/hash" "knative.dev/pkg/logging" "knative.dev/pkg/network" "knative.dev/pkg/reconciler" @@ -37,10 +39,10 @@ import ( // falling back on the standard elector. func WithDynamicLeaderElectorBuilder(ctx context.Context, kc kubernetes.Interface, cc ComponentConfig) context.Context { logger := logging.FromContext(ctx) - ssc, err := newStatefulSetConfig() + b, _, err := NewStatefulSetBucketAndSet(int(cc.Buckets)) if err == nil { logger.Info("Running with StatefulSet leader election") - return withStatefulSetElectorBuilder(ctx, cc, *ssc) + return withStatefulSetElectorBuilder(ctx, cc, b) } logger.Info("Running with Standard leader election") return WithStandardLeaderElectorBuilder(ctx, kc, cc) @@ -59,10 +61,10 @@ func WithStandardLeaderElectorBuilder(ctx context.Context, kc kubernetes.Interfa // withStatefulSetElectorBuilder infuses a context with the ability to build // Electors which are assigned leadership based on the StatefulSet ordinal from // the provided component configuration. -func withStatefulSetElectorBuilder(ctx context.Context, cc ComponentConfig, ssc statefulSetConfig) context.Context { +func withStatefulSetElectorBuilder(ctx context.Context, cc ComponentConfig, bkt reconciler.Bucket) context.Context { return context.WithValue(ctx, builderKey{}, &statefulSetBuilder{ lec: cc, - ssc: ssc, + bkt: bkt, }) } @@ -173,29 +175,50 @@ func (b *standardBuilder) buildElector(ctx context.Context, la reconciler.Leader type statefulSetBuilder struct { lec ComponentConfig - ssc statefulSetConfig + bkt reconciler.Bucket } func (b *statefulSetBuilder) buildElector(ctx context.Context, la reconciler.LeaderAware, enq func(reconciler.Bucket, types.NamespacedName)) (Elector, error) { logger := logging.FromContext(ctx) - ordinal := uint32(b.ssc.StatefulSetID.ordinal) - logger.Infof("%s will run in StatefulSet ordinal assignement mode with ordinal %d", - b.lec.Component, ordinal) + logger.Infof("%s will run in StatefulSet ordinal assignement mode with bucket name %s", + b.lec.Component, b.bkt.Name()) return &unopposedElector{ - bkt: &bucket{ - // The name is the full pod DNS of the owner pod of this bucket. - name: fmt.Sprintf("%s://%s-%d.%s.%s.svc.%s:%s", b.ssc.Protocol, - b.ssc.StatefulSetID.ssName, ordinal, b.ssc.ServiceName, - system.Namespace(), network.GetClusterDomainName(), b.ssc.Port), - index: ordinal, - total: b.lec.Buckets, - }, + bkt: b.bkt, la: la, enq: enq, }, nil } +// NewStatefulSetBucketAndSet creates a BucketSet for StatefulSet controller with +// the given bucket size and the information from environment variables. Then uses +// the created BucketSet to create a Bucket for this StatefulSet Pod. +func NewStatefulSetBucketAndSet(buckets int) (reconciler.Bucket, *hash.BucketSet, error) { + ssc, err := newStatefulSetConfig() + if err != nil { + return nil, nil, err + } + + if ssc.StatefulSetID.ordinal >= buckets { + return nil, nil, fmt.Errorf("ordinal %d is out of range [0, %d)", + ssc.StatefulSetID.ordinal, buckets) + } + + names := make(sets.String, buckets) + for i := 0; i < buckets; i++ { + names.Insert(statefulSetPodDNS(i, ssc)) + } + + bs := hash.NewBucketSet(names) + return hash.NewBucket(statefulSetPodDNS(ssc.StatefulSetID.ordinal, ssc), bs), bs, nil +} + +func statefulSetPodDNS(ordinal int, ssc *statefulSetConfig) string { + return fmt.Sprintf("%s://%s-%d.%s.%s.svc.%s:%s", ssc.Protocol, + ssc.StatefulSetID.ssName, ordinal, ssc.ServiceName, + system.Namespace(), network.GetClusterDomainName(), ssc.Port) +} + // unopposedElector promotes when run without needing to be elected. type unopposedElector struct { bkt reconciler.Bucket diff --git a/vendor/knative.dev/pkg/leaderelection/ordinal.go b/vendor/knative.dev/pkg/leaderelection/ordinal.go deleted file mode 100644 index 6ed95738521..00000000000 --- a/vendor/knative.dev/pkg/leaderelection/ordinal.go +++ /dev/null @@ -1,27 +0,0 @@ -/* -Copyright 2020 The Knative Authors - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package leaderelection - -// ControllerOrdinal tries to get ordinal from the pod name of a StatefulSet, -// which is provided from the environment variable CONTROLLER_ORDINAL. -func ControllerOrdinal() (int, error) { - ssc, err := newStatefulSetConfig() - if err != nil { - return 0, err - } - return ssc.StatefulSetID.ordinal, nil -} diff --git a/vendor/modules.txt b/vendor/modules.txt index 850f6c9d9ab..b9da2a95d9e 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -961,7 +961,7 @@ k8s.io/utils/buffer k8s.io/utils/integer k8s.io/utils/pointer k8s.io/utils/trace -# knative.dev/pkg v0.0.0-20200714180919-c49f5b61e264 +# knative.dev/pkg v0.0.0-20200714191819-258f5b86c26e ## explicit knative.dev/pkg/apiextensions/storageversion knative.dev/pkg/apiextensions/storageversion/cmd/migrate @@ -1020,6 +1020,7 @@ knative.dev/pkg/configmap/hash-gen knative.dev/pkg/configmap/testing knative.dev/pkg/controller knative.dev/pkg/hack +knative.dev/pkg/hash knative.dev/pkg/injection knative.dev/pkg/injection/clients/dynamicclient knative.dev/pkg/injection/clients/dynamicclient/fake From bd93157b9dc9cc24e00a4607750b2c9b91c63b6b Mon Sep 17 00:00:00 2001 From: Nacho Cano Date: Tue, 14 Jul 2020 13:57:20 -0700 Subject: [PATCH 07/11] fixing conversion --- pkg/apis/sources/v1alpha2/sinkbinding_conversion.go | 10 ++++++++-- .../sources/v1alpha2/sinkbinding_conversion_test.go | 3 ++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/pkg/apis/sources/v1alpha2/sinkbinding_conversion.go b/pkg/apis/sources/v1alpha2/sinkbinding_conversion.go index 383debbc252..8ceb2bad42a 100644 --- a/pkg/apis/sources/v1alpha2/sinkbinding_conversion.go +++ b/pkg/apis/sources/v1alpha2/sinkbinding_conversion.go @@ -22,6 +22,8 @@ import ( "knative.dev/eventing/pkg/apis/sources/v1beta1" "knative.dev/pkg/apis" + duckv1alpha1 "knative.dev/pkg/apis/duck/v1alpha1" + duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" ) // ConvertTo implements apis.Convertible. @@ -31,7 +33,9 @@ func (source *SinkBinding) ConvertTo(ctx context.Context, obj apis.Convertible) case *v1beta1.SinkBinding: sink.ObjectMeta = source.ObjectMeta sink.Spec.SourceSpec = source.Spec.SourceSpec - sink.Spec.BindingSpec = source.Spec.BindingSpec + sink.Spec.BindingSpec = duckv1beta1.BindingSpec{ + Subject: source.Spec.BindingSpec.Subject, + } sink.Status.SourceStatus = source.Status.SourceStatus return nil default: @@ -46,7 +50,9 @@ func (sink *SinkBinding) ConvertFrom(ctx context.Context, obj apis.Convertible) case *v1beta1.SinkBinding: sink.ObjectMeta = source.ObjectMeta sink.Spec.SourceSpec = source.Spec.SourceSpec - sink.Spec.BindingSpec = source.Spec.BindingSpec + sink.Spec.BindingSpec = duckv1alpha1.BindingSpec{ + Subject: source.Spec.BindingSpec.Subject, + } sink.Status.SourceStatus = source.Status.SourceStatus return nil default: diff --git a/pkg/apis/sources/v1alpha2/sinkbinding_conversion_test.go b/pkg/apis/sources/v1alpha2/sinkbinding_conversion_test.go index f34e57c2b89..90965da36b1 100644 --- a/pkg/apis/sources/v1alpha2/sinkbinding_conversion_test.go +++ b/pkg/apis/sources/v1alpha2/sinkbinding_conversion_test.go @@ -30,6 +30,7 @@ import ( "knative.dev/pkg/apis" duckv1 "knative.dev/pkg/apis/duck/v1" duckv1alpha1 "knative.dev/pkg/apis/duck/v1alpha1" + duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" ) type dummy struct{} @@ -264,7 +265,7 @@ func TestSinkBindingConversionRoundTripDown(t *testing.T) { Sink: sink, CloudEventOverrides: &ceOverrides, }, - BindingSpec: duckv1alpha1.BindingSpec{Subject: subject}, + BindingSpec: duckv1beta1.BindingSpec{Subject: subject}, }, Status: v1beta1.SinkBindingStatus{ SourceStatus: duckv1.SourceStatus{ From 9f653d08b420b95aa484e7a3b99895f2a28bbb67 Mon Sep 17 00:00:00 2001 From: Nacho Cano Date: Tue, 14 Jul 2020 14:53:30 -0700 Subject: [PATCH 08/11] do not serve it to see if the e2e test passes, might need to do it together with container source --- config/core/resources/sinkbindings.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/core/resources/sinkbindings.yaml b/config/core/resources/sinkbindings.yaml index c714ae5a544..1f8df32c45d 100644 --- a/config/core/resources/sinkbindings.yaml +++ b/config/core/resources/sinkbindings.yaml @@ -58,7 +58,7 @@ spec: storage: false - <<: *version name: v1beta1 - served: true + served: false storage: false names: categories: From 1e1ead11ebf297953b1cb4a962726b0ae3c7ab8c Mon Sep 17 00:00:00 2001 From: Nacho Cano Date: Wed, 15 Jul 2020 00:24:27 -0700 Subject: [PATCH 09/11] attempt to fix conversion --- cmd/webhook/main.go | 9 +- config/core/resources/sinkbindings.yaml | 2 +- .../v1alpha1/sinkbinding_conversion.go | 10 +- .../v1alpha1/sinkbinding_conversion_test.go | 24 +- .../v1alpha2/sinkbinding_conversion.go | 9 +- .../v1alpha2/sinkbinding_conversion_test.go | 255 ------------------ 6 files changed, 22 insertions(+), 287 deletions(-) diff --git a/cmd/webhook/main.go b/cmd/webhook/main.go index f0ce250237a..8275835f2f8 100644 --- a/cmd/webhook/main.go +++ b/cmd/webhook/main.go @@ -325,19 +325,12 @@ func NewConversionController(ctx context.Context, cmw configmap.Watcher) *contro sourcesv1alpha2_: &sourcesv1alpha2.PingSource{}, }, }, - sourcesv1alpha2.Kind("SinkBinding"): { + sourcesv1beta1.Kind("SinkBinding"): { DefinitionName: sources.SinkBindingResource.String(), HubVersion: sourcesv1alpha1_, Zygotes: map[string]conversion.ConvertibleObject{ sourcesv1alpha1_: &sourcesv1alpha1.SinkBinding{}, sourcesv1alpha2_: &sourcesv1alpha2.SinkBinding{}, - }, - }, - sourcesv1beta1.Kind("SinkBinding"): { - DefinitionName: sources.SinkBindingResource.String(), - HubVersion: sourcesv1alpha2_, - Zygotes: map[string]conversion.ConvertibleObject{ - sourcesv1alpha2_: &sourcesv1alpha2.SinkBinding{}, sourcesv1beta1_: &sourcesv1beta1.SinkBinding{}, }, }, diff --git a/config/core/resources/sinkbindings.yaml b/config/core/resources/sinkbindings.yaml index 1f8df32c45d..c714ae5a544 100644 --- a/config/core/resources/sinkbindings.yaml +++ b/config/core/resources/sinkbindings.yaml @@ -58,7 +58,7 @@ spec: storage: false - <<: *version name: v1beta1 - served: false + served: true storage: false names: categories: diff --git a/pkg/apis/sources/v1alpha1/sinkbinding_conversion.go b/pkg/apis/sources/v1alpha1/sinkbinding_conversion.go index fd5794b4d6d..c08141ae900 100644 --- a/pkg/apis/sources/v1alpha1/sinkbinding_conversion.go +++ b/pkg/apis/sources/v1alpha1/sinkbinding_conversion.go @@ -18,14 +18,13 @@ package v1alpha1 import ( "context" - "fmt" "knative.dev/eventing/pkg/apis/sources/v1alpha2" "knative.dev/pkg/apis" ) // ConvertTo implements apis.Convertible. -// Converts source (from v1alpha1.SinkBinding) into v1alpha2.SinkBinding +// Converts source from v1alpha1.SinkBinding into a higher version. func (source *SinkBinding) ConvertTo(ctx context.Context, obj apis.Convertible) error { switch sink := obj.(type) { case *v1alpha2.SinkBinding: @@ -35,21 +34,22 @@ func (source *SinkBinding) ConvertTo(ctx context.Context, obj apis.Convertible) sink.Status.SourceStatus = source.Status.SourceStatus return nil default: - return fmt.Errorf("Unknown conversion, got: %T", sink) + return apis.ConvertToViaProxy(ctx, source, &v1alpha2.SinkBinding{}, sink) } } // ConvertFrom implements apis.Convertible. -// Converts obj from v1alpha2.SinkBinding into v1alpha1.SinkBinding +// Converts obj from higher versions into v1alpha1.SinkBinding. func (sink *SinkBinding) ConvertFrom(ctx context.Context, obj apis.Convertible) error { switch source := obj.(type) { case *v1alpha2.SinkBinding: sink.ObjectMeta = source.ObjectMeta + sink.Spec.Subject = source.Spec.Subject sink.Spec.SourceSpec = source.Spec.SourceSpec sink.Spec.BindingSpec = source.Spec.BindingSpec sink.Status.SourceStatus = source.Status.SourceStatus return nil default: - return fmt.Errorf("Unknown conversion, got: %T", source) + return apis.ConvertFromViaProxy(ctx, source, &v1alpha2.SinkBinding{}, sink) } } diff --git a/pkg/apis/sources/v1alpha1/sinkbinding_conversion_test.go b/pkg/apis/sources/v1alpha1/sinkbinding_conversion_test.go index 2cd5fc421cd..3bc72326cf2 100644 --- a/pkg/apis/sources/v1alpha1/sinkbinding_conversion_test.go +++ b/pkg/apis/sources/v1alpha1/sinkbinding_conversion_test.go @@ -21,15 +21,16 @@ import ( "reflect" "testing" - "knative.dev/pkg/apis/duck/v1alpha1" "knative.dev/pkg/tracker" - "knative.dev/eventing/pkg/apis/sources/v1alpha2" - "github.com/google/go-cmp/cmp" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "knative.dev/eventing/pkg/apis/sources/v1alpha2" + "knative.dev/eventing/pkg/apis/sources/v1beta1" "knative.dev/pkg/apis" duckv1 "knative.dev/pkg/apis/duck/v1" + duckv1alpha1 "knative.dev/pkg/apis/duck/v1alpha1" + duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" ) func TestSinkBindingConversionBadType(t *testing.T) { @@ -45,8 +46,7 @@ func TestSinkBindingConversionBadType(t *testing.T) { } func TestSinkBindingConversionRoundTripUp(t *testing.T) { - // Just one for now, just adding the for loop for ease of future changes. - versions := []apis.Convertible{&v1alpha2.SinkBinding{}} + versions := []apis.Convertible{&v1beta1.SinkBinding{}, &v1alpha2.SinkBinding{}} path, _ := apis.ParseURL("/path") sink := duckv1.Destination{ @@ -101,7 +101,7 @@ func TestSinkBindingConversionRoundTripUp(t *testing.T) { SourceSpec: duckv1.SourceSpec{ Sink: sink, }, - BindingSpec: v1alpha1.BindingSpec{ + BindingSpec: duckv1alpha1.BindingSpec{ Subject: subject, }, }, @@ -135,7 +135,7 @@ func TestSinkBindingConversionRoundTripUp(t *testing.T) { }, }, }, - BindingSpec: v1alpha1.BindingSpec{ + BindingSpec: duckv1alpha1.BindingSpec{ Subject: subject, }, }, @@ -176,8 +176,6 @@ func TestSinkBindingConversionRoundTripUp(t *testing.T) { // This tests round tripping from a higher version -> v1alpha1 and back to the higher version. func TestSinkBindingConversionRoundTripDown(t *testing.T) { - // Just one for now, just adding the for loop for ease of future changes. - path, _ := apis.ParseURL("/path") sink := duckv1.Destination{ Ref: &duckv1.KReference{ @@ -243,20 +241,20 @@ func TestSinkBindingConversionRoundTripDown(t *testing.T) { }, }, }, {name: "full", - in: &v1alpha2.SinkBinding{ + in: &v1beta1.SinkBinding{ ObjectMeta: metav1.ObjectMeta{ Name: "ping-name", Namespace: "ping-ns", Generation: 17, }, - Spec: v1alpha2.SinkBindingSpec{ + Spec: v1beta1.SinkBindingSpec{ SourceSpec: duckv1.SourceSpec{ Sink: sink, CloudEventOverrides: &ceOverrides, }, - BindingSpec: v1alpha1.BindingSpec{Subject: subject}, + BindingSpec: duckv1beta1.BindingSpec{Subject: subject}, }, - Status: v1alpha2.SinkBindingStatus{ + Status: v1beta1.SinkBindingStatus{ SourceStatus: duckv1.SourceStatus{ Status: duckv1.Status{ ObservedGeneration: 1, diff --git a/pkg/apis/sources/v1alpha2/sinkbinding_conversion.go b/pkg/apis/sources/v1alpha2/sinkbinding_conversion.go index 8ceb2bad42a..e45519863e6 100644 --- a/pkg/apis/sources/v1alpha2/sinkbinding_conversion.go +++ b/pkg/apis/sources/v1alpha2/sinkbinding_conversion.go @@ -18,7 +18,6 @@ package v1alpha2 import ( "context" - "fmt" "knative.dev/eventing/pkg/apis/sources/v1beta1" "knative.dev/pkg/apis" @@ -27,7 +26,7 @@ import ( ) // ConvertTo implements apis.Convertible. -// Converts source (from v1alpha2.SinkBinding) into v1beta1.SinkBinding. +// Converts source (from v1alpha2.SinkBinding) into v1alpha1 or v1beta1. func (source *SinkBinding) ConvertTo(ctx context.Context, obj apis.Convertible) error { switch sink := obj.(type) { case *v1beta1.SinkBinding: @@ -39,12 +38,12 @@ func (source *SinkBinding) ConvertTo(ctx context.Context, obj apis.Convertible) sink.Status.SourceStatus = source.Status.SourceStatus return nil default: - return fmt.Errorf("Unknown conversion, got: %T", sink) + return apis.ConvertToViaProxy(ctx, source, &v1beta1.SinkBinding{}, sink) } } // ConvertFrom implements apis.Convertible. -// Converts obj from v1beta1.SinkBinding into v1alpha2.SinkBinding. +// Converts obj from v1alpha1 or v1beta1 into v1alpha2.SinkBinding. func (sink *SinkBinding) ConvertFrom(ctx context.Context, obj apis.Convertible) error { switch source := obj.(type) { case *v1beta1.SinkBinding: @@ -56,6 +55,6 @@ func (sink *SinkBinding) ConvertFrom(ctx context.Context, obj apis.Convertible) sink.Status.SourceStatus = source.Status.SourceStatus return nil default: - return fmt.Errorf("Unknown conversion, got: %T", source) + return apis.ConvertToViaProxy(ctx, source, &v1beta1.SinkBinding{}, sink) } } diff --git a/pkg/apis/sources/v1alpha2/sinkbinding_conversion_test.go b/pkg/apis/sources/v1alpha2/sinkbinding_conversion_test.go index 90965da36b1..d6d62487a18 100644 --- a/pkg/apis/sources/v1alpha2/sinkbinding_conversion_test.go +++ b/pkg/apis/sources/v1alpha2/sinkbinding_conversion_test.go @@ -19,18 +19,9 @@ package v1alpha2 import ( "context" "errors" - "reflect" "testing" - "knative.dev/pkg/tracker" - - "github.com/google/go-cmp/cmp" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "knative.dev/eventing/pkg/apis/sources/v1beta1" "knative.dev/pkg/apis" - duckv1 "knative.dev/pkg/apis/duck/v1" - duckv1alpha1 "knative.dev/pkg/apis/duck/v1alpha1" - duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" ) type dummy struct{} @@ -54,249 +45,3 @@ func TestSinkBindingConversionBadType(t *testing.T) { t.Errorf("ConvertFrom() = %#v, wanted error", good) } } - -func TestSinkBindingConversionRoundTripUp(t *testing.T) { - // Just one for now, just adding the for loop for ease of future changes. - versions := []apis.Convertible{&v1beta1.SinkBinding{}} - - path, _ := apis.ParseURL("/path") - sink := duckv1.Destination{ - Ref: &duckv1.KReference{ - Kind: "Foo", - Namespace: "Bar", - Name: "Baz", - APIVersion: "Baf", - }, - URI: path, - } - sinkUri, _ := apis.ParseURL("http://example.com/path") - - subject := tracker.Reference{ - APIVersion: "API", - Kind: "K", - Namespace: "NS", - Name: "N", - } - - tests := []struct { - name string - in *SinkBinding - }{{name: "empty", - in: &SinkBinding{ - ObjectMeta: metav1.ObjectMeta{ - Name: "ping-name", - Namespace: "ping-ns", - Generation: 17, - }, - Spec: SinkBindingSpec{}, - Status: SinkBindingStatus{ - SourceStatus: duckv1.SourceStatus{ - Status: duckv1.Status{ - ObservedGeneration: 1, - Conditions: duckv1.Conditions{{ - Type: "Ready", - Status: "True", - }}, - }, - }, - }, - }, - }, {name: "simple configuration", - in: &SinkBinding{ - ObjectMeta: metav1.ObjectMeta{ - Name: "ping-name", - Namespace: "ping-ns", - Generation: 17, - }, - Spec: SinkBindingSpec{ - SourceSpec: duckv1.SourceSpec{ - Sink: sink, - }, - BindingSpec: duckv1alpha1.BindingSpec{ - Subject: subject, - }, - }, - Status: SinkBindingStatus{ - SourceStatus: duckv1.SourceStatus{ - Status: duckv1.Status{ - ObservedGeneration: 1, - Conditions: duckv1.Conditions{{ - Type: "Ready", - Status: "Unknown", - }}, - }, - SinkURI: sinkUri, - }, - }, - }, - }, {name: "full", - in: &SinkBinding{ - ObjectMeta: metav1.ObjectMeta{ - Name: "ping-name", - Namespace: "ping-ns", - Generation: 17, - }, - Spec: SinkBindingSpec{ - SourceSpec: duckv1.SourceSpec{ - Sink: sink, - CloudEventOverrides: &duckv1.CloudEventOverrides{ - Extensions: map[string]string{ - "foo": "bar", - "baz": "baf", - }, - }, - }, - BindingSpec: duckv1alpha1.BindingSpec{ - Subject: subject, - }, - }, - Status: SinkBindingStatus{ - SourceStatus: duckv1.SourceStatus{ - Status: duckv1.Status{ - ObservedGeneration: 1, - Conditions: duckv1.Conditions{{ - Type: "Ready", - Status: "True", - }}, - }, - SinkURI: sinkUri, - }, - }, - }, - }} - for _, test := range tests { - for _, version := range versions { - t.Run(test.name, func(t *testing.T) { - ver := version - if err := test.in.ConvertTo(context.Background(), ver); err != nil { - t.Errorf("ConvertTo() = %v", err) - } - - got := &SinkBinding{} - - if err := got.ConvertFrom(context.Background(), ver); err != nil { - t.Errorf("ConvertFrom() = %v", err) - } - if diff := cmp.Diff(test.in, got); diff != "" { - t.Errorf("roundtrip (-want, +got) = %v", diff) - } - }) - } - } -} - -// This tests round tripping from a higher version -> v1alpha2 and back to the higher version. -func TestSinkBindingConversionRoundTripDown(t *testing.T) { - // Just one for now, just adding the for loop for ease of future changes. - - path, _ := apis.ParseURL("/path") - sink := duckv1.Destination{ - Ref: &duckv1.KReference{ - Kind: "Foo", - Namespace: "Bar", - Name: "Baz", - APIVersion: "Baf", - }, - URI: path, - } - sinkURI, _ := apis.ParseURL("http://example.com/path") - - ceOverrides := duckv1.CloudEventOverrides{ - Extensions: map[string]string{ - "foo": "bar", - "baz": "baf", - }, - } - - subject := tracker.Reference{ - APIVersion: "API", - Kind: "K", - Namespace: "NS", - Name: "N", - } - - tests := []struct { - name string - in apis.Convertible - }{{name: "empty", - in: &v1beta1.SinkBinding{ - ObjectMeta: metav1.ObjectMeta{ - Name: "ping-name", - Namespace: "ping-ns", - Generation: 17, - }, - Spec: v1beta1.SinkBindingSpec{}, - Status: v1beta1.SinkBindingStatus{}, - }, - }, {name: "simple configuration", - in: &v1beta1.SinkBinding{ - ObjectMeta: metav1.ObjectMeta{ - Name: "ping-name", - Namespace: "ping-ns", - Generation: 17, - }, - Spec: v1beta1.SinkBindingSpec{ - SourceSpec: duckv1.SourceSpec{ - Sink: sink, - }, - }, - Status: v1beta1.SinkBindingStatus{ - SourceStatus: duckv1.SourceStatus{ - Status: duckv1.Status{ - ObservedGeneration: 1, - Conditions: duckv1.Conditions{{ - Type: "Ready", - Status: "True", - }}, - }, - SinkURI: sinkURI, - }, - }, - }, - }, {name: "full", - in: &v1beta1.SinkBinding{ - ObjectMeta: metav1.ObjectMeta{ - Name: "ping-name", - Namespace: "ping-ns", - Generation: 17, - }, - Spec: v1beta1.SinkBindingSpec{ - SourceSpec: duckv1.SourceSpec{ - Sink: sink, - CloudEventOverrides: &ceOverrides, - }, - BindingSpec: duckv1beta1.BindingSpec{Subject: subject}, - }, - Status: v1beta1.SinkBindingStatus{ - SourceStatus: duckv1.SourceStatus{ - Status: duckv1.Status{ - ObservedGeneration: 1, - Conditions: duckv1.Conditions{{ - Type: "Ready", - Status: "True", - }}, - }, - SinkURI: sinkURI, - }, - }, - }, - }} - for _, test := range tests { - - t.Run(test.name, func(t *testing.T) { - down := &SinkBinding{} - if err := down.ConvertFrom(context.Background(), test.in); err != nil { - t.Errorf("ConvertTo() = %v", err) - } - - got := (reflect.New(reflect.TypeOf(test.in).Elem()).Interface()).(apis.Convertible) - - if err := down.ConvertTo(context.Background(), got); err != nil { - t.Errorf("ConvertFrom() = %v", err) - } - if diff := cmp.Diff(test.in, got); diff != "" { - t.Errorf("roundtrip (-want, +got) = %v", diff) - } - }) - } -} From b4d56a813de501ae4998fddff6d3d84a2bc772cc Mon Sep 17 00:00:00 2001 From: Nacho Cano Date: Wed, 15 Jul 2020 17:03:34 -0700 Subject: [PATCH 10/11] making v1beta1 the stored version --- config/core/resources/sinkbindings.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/config/core/resources/sinkbindings.yaml b/config/core/resources/sinkbindings.yaml index c714ae5a544..e20afb3c5c9 100644 --- a/config/core/resources/sinkbindings.yaml +++ b/config/core/resources/sinkbindings.yaml @@ -26,7 +26,7 @@ spec: group: sources.knative.dev versions: - &version - name: v1alpha1 + name: v1beta1 served: true storage: true subresources: @@ -53,11 +53,11 @@ spec: type: date jsonPath: .metadata.creationTimestamp - <<: *version - name: v1alpha2 + name: v1alpha1 served: true storage: false - <<: *version - name: v1beta1 + name: v1alpha2 served: true storage: false names: From 0cf813aa013c78241e1a5857be9bbc0c5bb6f457 Mon Sep 17 00:00:00 2001 From: Nacho Cano Date: Wed, 15 Jul 2020 18:49:16 -0700 Subject: [PATCH 11/11] avoid flipping the storage bit --- config/core/resources/sinkbindings.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/config/core/resources/sinkbindings.yaml b/config/core/resources/sinkbindings.yaml index e20afb3c5c9..c714ae5a544 100644 --- a/config/core/resources/sinkbindings.yaml +++ b/config/core/resources/sinkbindings.yaml @@ -26,7 +26,7 @@ spec: group: sources.knative.dev versions: - &version - name: v1beta1 + name: v1alpha1 served: true storage: true subresources: @@ -53,11 +53,11 @@ spec: type: date jsonPath: .metadata.creationTimestamp - <<: *version - name: v1alpha1 + name: v1alpha2 served: true storage: false - <<: *version - name: v1alpha2 + name: v1beta1 served: true storage: false names: