From 65884ef0398c45d0ac47831b089e90c1238d55f8 Mon Sep 17 00:00:00 2001 From: Ville Aikas Date: Fri, 6 Mar 2020 17:18:22 -0800 Subject: [PATCH 1/2] Default broker annotations from the broker defaults configmap --- Gopkg.lock | 4 +- pkg/apis/config/defaults.go | 37 ++- pkg/apis/config/defaults_test.go | 240 ++++++++++++++++-- .../config/testdata/config-br-defaults.yaml | 2 + pkg/apis/config/zz_generated.deepcopy.go | 33 ++- pkg/apis/eventing/register.go | 4 + pkg/apis/eventing/v1beta1/broker_defaults.go | 17 +- .../eventing/v1beta1/broker_defaults_test.go | 191 ++++++++++++++ vendor/knative.dev/pkg/Gopkg.lock | 4 +- vendor/knative.dev/pkg/injection/README.md | 4 +- .../pkg/injection/sharedmain/main.go | 2 +- 11 files changed, 490 insertions(+), 48 deletions(-) create mode 100644 pkg/apis/eventing/v1beta1/broker_defaults_test.go diff --git a/Gopkg.lock b/Gopkg.lock index 95a57a0dc82..966d8dcc843 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -1314,7 +1314,7 @@ [[projects]] branch = "master" - digest = "1:594e2e8f9e26efdd32cef30b5c099d422bbe23ac6a9f38f3aed473b610351268" + digest = "1:54440beb15b5090023808ac49ba0fc895cebde34b9cebac9f5ca0ddb5f52dc75" name = "knative.dev/pkg" packages = [ "apis", @@ -1418,7 +1418,7 @@ "webhook/resourcesemantics/validation", ] pruneopts = "T" - revision = "5605ade5242dbce408f2d2e5cf6bbc43355dfd6c" + revision = "fc857aa77f79902f0099e5e4ef403a18c31b45ea" [[projects]] branch = "master" diff --git a/pkg/apis/config/defaults.go b/pkg/apis/config/defaults.go index d067ad44b27..c78b42a7005 100644 --- a/pkg/apis/config/defaults.go +++ b/pkg/apis/config/defaults.go @@ -70,11 +70,19 @@ func NewDefaultsConfigFromConfigMap(config *corev1.ConfigMap) (*Defaults, error) type Defaults struct { // NamespaceDefaultsConfig are the default Broker Configs for each namespace. // Namespace is the key, the value is the KReference to the config. - NamespaceDefaultsConfig map[string]*duckv1.KReference `json:"namespaceDefaults,omitempty"` + NamespaceDefaultsConfig map[string]*ClassAndKRef `json:"namespaceDefaults,omitempty"` // ClusterDefaultBrokerConfig is the default broker config for all the namespaces that // are not in NamespaceDefaultBrokerConfigs. - ClusterDefault *duckv1.KReference `json:"clusterDefault,omitempty"` + ClusterDefault *ClassAndKRef `json:"clusterDefault,omitempty"` +} + +// ClassAndKRef contains configuration for a given namespace for broker. Allows +// configuring both the Class of the Broker as well as the reference to the +// config it should use +type ClassAndKRef struct { + BrokerClass string `json:"brokerClass,omitempty"` + *duckv1.KReference `json:",inline"` } // GetBrokerConfig returns a namespace specific Broker Configuration, and if @@ -85,11 +93,28 @@ func (d *Defaults) GetBrokerConfig(ns string) (*duckv1.KReference, error) { return nil, errors.New("Defaults are nil") } value, present := d.NamespaceDefaultsConfig[ns] - if present { - return value, nil + if present && value.KReference != nil { + return value.KReference, nil } - if d.ClusterDefault != nil { - return d.ClusterDefault, nil + if d.ClusterDefault != nil && d.ClusterDefault.KReference != nil { + return d.ClusterDefault.KReference, nil } return nil, errors.New("Defaults for Broker Configurations have not been set up.") } + +// GetBrokerClass returns a namespace specific Broker Class, and if +// that doesn't exist, return a Cluster Default and if that doesn't exist +// return an error. +func (d *Defaults) GetBrokerClass(ns string) (string, error) { + if d == nil { + return "", errors.New("Defaults are nil") + } + value, present := d.NamespaceDefaultsConfig[ns] + if present && value.BrokerClass != "" { + return value.BrokerClass, nil + } + if d.ClusterDefault != nil && d.ClusterDefault.BrokerClass != "" { + return d.ClusterDefault.BrokerClass, nil + } + return "", errors.New("Defaults for Broker Configurations have not been set up.") +} diff --git a/pkg/apis/config/defaults_test.go b/pkg/apis/config/defaults_test.go index e01c9e896db..df8b47b1700 100644 --- a/pkg/apis/config/defaults_test.go +++ b/pkg/apis/config/defaults_test.go @@ -25,6 +25,8 @@ import ( "knative.dev/pkg/kmp" "knative.dev/pkg/system" + "knative.dev/eventing/pkg/apis/eventing" + . "knative.dev/pkg/configmap/testing" _ "knative.dev/pkg/system/testing" ) @@ -56,6 +58,64 @@ func TestGetBrokerConfig(t *testing.T) { if c.Name != "someothername" { t.Errorf("GetBrokerConfig Failed, wanted someothername, got: %s", c.Name) } + + // Nil and empty tests + var nilDefaults *Defaults + _, err = nilDefaults.GetBrokerConfig("rando") + if err == nil { + t.Errorf("GetBrokerConfig did not fail with nil") + } + if err.Error() != "Defaults are nil" { + t.Errorf("GetBrokerConfig did not fail with nil msg, got %v", err) + } + emptyDefaults := Defaults{} + _, err = emptyDefaults.GetBrokerConfig("rando") + if err == nil { + t.Errorf("GetBrokerConfig did not fail with empty") + } + if err.Error() != "Defaults for Broker Configurations have not been set up." { + t.Errorf("GetBrokerConfig did not fail with non-setup msg, got %v", err) + } +} + +func TestGetBrokerClass(t *testing.T) { + _, example := ConfigMapsFromTestFile(t, DefaultsConfigName) + defaults, err := NewDefaultsConfigFromConfigMap(example) + if err != nil { + t.Errorf("NewDefaultsConfigFromConfigMap(example) = %v", err) + } + c, err := defaults.GetBrokerClass("rando") + if err != nil { + t.Errorf("GetBrokerClass Failed = %v", err) + } + if c != eventing.ChannelBrokerClassValue { + t.Errorf("GetBrokerClass Failed, wanted somename, got: %s", c) + } + c, err = defaults.GetBrokerClass("some-namespace") + if err != nil { + t.Errorf("GetBrokerClass Failed = %v", err) + } + if c != "someotherbrokerclass" { + t.Errorf("GetBrokerClass Failed, wanted someothername, got: %s", c) + } + + // Nil and empty tests + var nilDefaults *Defaults + _, err = nilDefaults.GetBrokerClass("rando") + if err == nil { + t.Errorf("GetBrokerClass did not fail with nil") + } + if err.Error() != "Defaults are nil" { + t.Errorf("GetBrokerClass did not fail with nil msg, got %v", err) + } + emptyDefaults := Defaults{} + _, err = emptyDefaults.GetBrokerClass("rando") + if err == nil { + t.Errorf("GetBrokerClass did not fail with empty") + } + if err.Error() != "Defaults for Broker Configurations have not been set up." { + t.Errorf("GetBrokerClass did not fail with non-setup msg, got %v", err) + } } func TestDefaultsConfiguration(t *testing.T) { @@ -78,25 +138,34 @@ func TestDefaultsConfiguration(t *testing.T) { name: "all specified values", wantErr: false, wantDefaults: &Defaults{ - NamespaceDefaultsConfig: map[string]*duckv1.KReference{ + NamespaceDefaultsConfig: map[string]*ClassAndKRef{ "some-namespace": { - APIVersion: "v1", - Kind: "ConfigMap", - Name: "someothername", - Namespace: "someothernamespace", + BrokerClass: "somenamespaceclass", + KReference: &duckv1.KReference{ + APIVersion: "v1", + Kind: "ConfigMap", + Name: "someothername", + Namespace: "someothernamespace", + }, }, "some-namespace-too": { - APIVersion: "v1", - Kind: "ConfigMap", - Name: "someothernametoo", - Namespace: "someothernamespacetoo", + BrokerClass: "somenamespaceclasstoo", + KReference: &duckv1.KReference{ + APIVersion: "v1", + Kind: "ConfigMap", + Name: "someothernametoo", + Namespace: "someothernamespacetoo", + }, }, }, - ClusterDefault: &duckv1.KReference{ - Kind: "ConfigMap", - APIVersion: "v1", - Namespace: "knative-eventing", - Name: "somename", + ClusterDefault: &ClassAndKRef{ + BrokerClass: "clusterbrokerclass", + KReference: &duckv1.KReference{ + Kind: "ConfigMap", + APIVersion: "v1", + Namespace: "knative-eventing", + Name: "somename", + }, }, }, config: &corev1.ConfigMap{ @@ -107,17 +176,20 @@ func TestDefaultsConfiguration(t *testing.T) { Data: map[string]string{ "default-br-config": ` clusterDefault: + brokerClass: clusterbrokerclass apiVersion: v1 kind: ConfigMap name: somename namespace: knative-eventing namespaceDefaults: some-namespace: + brokerClass: somenamespaceclass apiVersion: v1 kind: ConfigMap name: someothername namespace: someothernamespace some-namespace-too: + brokerClass: somenamespaceclasstoo apiVersion: v1 kind: ConfigMap name: someothernametoo @@ -130,11 +202,14 @@ func TestDefaultsConfiguration(t *testing.T) { wantErr: false, wantDefaults: &Defaults{ // NamespaceDefaultsConfig: map[string]*duckv1.KReference{}, - ClusterDefault: &duckv1.KReference{ - Kind: "ConfigMap", - APIVersion: "v1", - Namespace: "knative-eventing", - Name: "somename", + ClusterDefault: &ClassAndKRef{ + BrokerClass: "clusterbrokerclass", + KReference: &duckv1.KReference{ + Kind: "ConfigMap", + APIVersion: "v1", + Namespace: "knative-eventing", + Name: "somename", + }, }, }, config: &corev1.ConfigMap{ @@ -145,6 +220,7 @@ func TestDefaultsConfiguration(t *testing.T) { Data: map[string]string{ "default-br-config": ` clusterDefault: + brokerClass: clusterbrokerclass apiVersion: v1 kind: ConfigMap name: somename @@ -156,18 +232,73 @@ func TestDefaultsConfiguration(t *testing.T) { name: "only namespace defaults", wantErr: false, wantDefaults: &Defaults{ - NamespaceDefaultsConfig: map[string]*duckv1.KReference{ + NamespaceDefaultsConfig: map[string]*ClassAndKRef{ "some-namespace": { - APIVersion: "v1", - Kind: "ConfigMap", - Name: "someothername", - Namespace: "someothernamespace", + BrokerClass: "brokerclassnamespace", + KReference: &duckv1.KReference{ + APIVersion: "v1", + Kind: "ConfigMap", + Name: "someothername", + Namespace: "someothernamespace", + }, }, "some-namespace-too": { - APIVersion: "v1", - Kind: "ConfigMap", - Name: "someothernametoo", - Namespace: "someothernamespacetoo", + BrokerClass: "brokerclassnamespacetoo", + KReference: &duckv1.KReference{ + APIVersion: "v1", + Kind: "ConfigMap", + Name: "someothernametoo", + Namespace: "someothernamespacetoo", + }, + }, + }, + }, + config: &corev1.ConfigMap{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: system.Namespace(), + Name: DefaultsConfigName, + }, + Data: map[string]string{ + "default-br-config": ` + namespaceDefaults: + some-namespace: + brokerClass: brokerclassnamespace + apiVersion: v1 + kind: ConfigMap + name: someothername + namespace: someothernamespace + some-namespace-too: + brokerClass: brokerclassnamespacetoo + apiVersion: v1 + kind: ConfigMap + name: someothernametoo + namespace: someothernamespacetoo +`, + }, + }, + }, { + name: "only namespace config default, cluster brokerclass", + wantErr: false, + wantDefaults: &Defaults{ + ClusterDefault: &ClassAndKRef{ + BrokerClass: "clusterbrokerclass", + }, + NamespaceDefaultsConfig: map[string]*ClassAndKRef{ + "some-namespace": { + KReference: &duckv1.KReference{ + APIVersion: "v1", + Kind: "ConfigMap", + Name: "someothername", + Namespace: "someothernamespace", + }, + }, + "some-namespace-too": { + KReference: &duckv1.KReference{ + APIVersion: "v1", + Kind: "ConfigMap", + Name: "someothernametoo", + Namespace: "someothernamespacetoo", + }, }, }, }, @@ -178,8 +309,61 @@ func TestDefaultsConfiguration(t *testing.T) { }, Data: map[string]string{ "default-br-config": ` + clusterDefault: + brokerClass: clusterbrokerclass + namespaceDefaults: + some-namespace: + apiVersion: v1 + kind: ConfigMap + name: someothername + namespace: someothernamespace + some-namespace-too: + apiVersion: v1 + kind: ConfigMap + name: someothernametoo + namespace: someothernamespacetoo +`, + }, + }, + }, { + name: "one namespace config default, namespace config default with class, cluster brokerclass", + wantErr: false, + wantDefaults: &Defaults{ + ClusterDefault: &ClassAndKRef{ + BrokerClass: "clusterbrokerclass", + }, + NamespaceDefaultsConfig: map[string]*ClassAndKRef{ + "some-namespace": { + BrokerClass: "namespacebrokerclass", + KReference: &duckv1.KReference{ + APIVersion: "v1", + Kind: "ConfigMap", + Name: "someothername", + Namespace: "someothernamespace", + }, + }, + "some-namespace-too": { + KReference: &duckv1.KReference{ + APIVersion: "v1", + Kind: "ConfigMap", + Name: "someothernametoo", + Namespace: "someothernamespacetoo", + }, + }, + }, + }, + config: &corev1.ConfigMap{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: system.Namespace(), + Name: DefaultsConfigName, + }, + Data: map[string]string{ + "default-br-config": ` + clusterDefault: + brokerClass: clusterbrokerclass namespaceDefaults: some-namespace: + brokerClass: namespacebrokerclass apiVersion: v1 kind: ConfigMap name: someothername diff --git a/pkg/apis/config/testdata/config-br-defaults.yaml b/pkg/apis/config/testdata/config-br-defaults.yaml index e2f9c93d53f..e1adf63dce4 100644 --- a/pkg/apis/config/testdata/config-br-defaults.yaml +++ b/pkg/apis/config/testdata/config-br-defaults.yaml @@ -29,12 +29,14 @@ data: ################################ default-br-config: | clusterDefault: + brokerClass: ChannelBasedBroker apiVersion: v1 kind: ConfigMap name: somename namespace: knative-eventing namespaceDefaults: some-namespace: + brokerClass: someotherbrokerclass apiVersion: v1 kind: ConfigMap name: someothername diff --git a/pkg/apis/config/zz_generated.deepcopy.go b/pkg/apis/config/zz_generated.deepcopy.go index 59abf30784e..bb1f1cb1a33 100644 --- a/pkg/apis/config/zz_generated.deepcopy.go +++ b/pkg/apis/config/zz_generated.deepcopy.go @@ -24,28 +24,49 @@ import ( v1 "knative.dev/pkg/apis/duck/v1" ) +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ClassAndKRef) DeepCopyInto(out *ClassAndKRef) { + *out = *in + if in.KReference != nil { + in, out := &in.KReference, &out.KReference + *out = new(v1.KReference) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClassAndKRef. +func (in *ClassAndKRef) DeepCopy() *ClassAndKRef { + if in == nil { + return nil + } + out := new(ClassAndKRef) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Defaults) DeepCopyInto(out *Defaults) { *out = *in if in.NamespaceDefaultsConfig != nil { in, out := &in.NamespaceDefaultsConfig, &out.NamespaceDefaultsConfig - *out = make(map[string]*v1.KReference, len(*in)) + *out = make(map[string]*ClassAndKRef, len(*in)) for key, val := range *in { - var outVal *v1.KReference + var outVal *ClassAndKRef if val == nil { (*out)[key] = nil } else { in, out := &val, &outVal - *out = new(v1.KReference) - **out = **in + *out = new(ClassAndKRef) + (*in).DeepCopyInto(*out) } (*out)[key] = outVal } } if in.ClusterDefault != nil { in, out := &in.ClusterDefault, &out.ClusterDefault - *out = new(v1.KReference) - **out = **in + *out = new(ClassAndKRef) + (*in).DeepCopyInto(*out) } return } diff --git a/pkg/apis/eventing/register.go b/pkg/apis/eventing/register.go index c789e7a0d20..64ecc37c641 100644 --- a/pkg/apis/eventing/register.go +++ b/pkg/apis/eventing/register.go @@ -33,6 +33,10 @@ const ( // the scope of the component handling a given resource. // Valid values are: cluster, namespace, resource. ScopeAnnotationKey = GroupName + "/scope" + + // ChannelBrokerClassValue is the value we use to specify the + // Broker using channels. As in Broker from this repository. + ChannelBrokerClassValue = "ChannelBasedBroker" ) var ( diff --git a/pkg/apis/eventing/v1beta1/broker_defaults.go b/pkg/apis/eventing/v1beta1/broker_defaults.go index 217bda3ddc4..90cebee31de 100644 --- a/pkg/apis/eventing/v1beta1/broker_defaults.go +++ b/pkg/apis/eventing/v1beta1/broker_defaults.go @@ -20,13 +20,28 @@ import ( "context" "knative.dev/eventing/pkg/apis/config" + "knative.dev/eventing/pkg/apis/eventing" "knative.dev/pkg/apis" ) func (b *Broker) SetDefaults(ctx context.Context) { - // TODO(vaikas): Set the default class annotation if not specified + // Default Spec fields. withNS := apis.WithinParent(ctx, b.ObjectMeta) b.Spec.SetDefaults(withNS) + + // Check the annotation and default if necessary + annotations := b.GetAnnotations() + if annotations == nil { + annotations = make(map[string]string, 1) + } + if _, present := annotations[eventing.BrokerClassKey]; !present { + cfg := config.FromContextOrDefaults(withNS) + c, err := cfg.Defaults.GetBrokerClass(b.Namespace) + if err == nil { + annotations[eventing.BrokerClassKey] = c + b.SetAnnotations(annotations) + } + } } func (bs *BrokerSpec) SetDefaults(ctx context.Context) { diff --git a/pkg/apis/eventing/v1beta1/broker_defaults_test.go b/pkg/apis/eventing/v1beta1/broker_defaults_test.go new file mode 100644 index 00000000000..3df1666a8e8 --- /dev/null +++ b/pkg/apis/eventing/v1beta1/broker_defaults_test.go @@ -0,0 +1,191 @@ +/* +Copyright 2019 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/eventing/pkg/apis/config" + "knative.dev/eventing/pkg/apis/eventing" + duckv1 "knative.dev/pkg/apis/duck/v1" +) + +var ( + defaultConfig = &config.Config{ + Defaults: &config.Defaults{ + // NamespaceDefaultsConfig are the default Broker Configs for each namespace. + // Namespace is the key, the value is the KReference to the config. + NamespaceDefaultsConfig: map[string]*config.ClassAndKRef{ + "mynamespace": &config.ClassAndKRef{ + KReference: &duckv1.KReference{ + APIVersion: "v1", + Kind: "ConfigMap", + Namespace: "knative-eventing", + Name: "kafka-channel", + }, + }, + "mynamespace2": &config.ClassAndKRef{ + BrokerClass: "mynamespace2class", + KReference: &duckv1.KReference{ + APIVersion: "v1", + Kind: "ConfigMap", + Namespace: "knative-eventing", + Name: "natss-channel", + }, + }, + }, + ClusterDefault: &config.ClassAndKRef{ + BrokerClass: eventing.ChannelBrokerClassValue, + KReference: &duckv1.KReference{ + APIVersion: "v1", + Kind: "ConfigMap", + Namespace: "knative-eventing", + Name: "imc-channel", + }, + }, + }, + } +) + +func TestBrokerSetDefaults(t *testing.T) { + testCases := map[string]struct { + initial Broker + expected Broker + }{ + "default everything from cluster": { + expected: Broker{ + ObjectMeta: metav1.ObjectMeta{ + Annotations: map[string]string{ + eventing.BrokerClassKey: eventing.ChannelBrokerClassValue, + }, + }, + Spec: BrokerSpec{ + Config: &duckv1.KReference{ + APIVersion: "v1", + Kind: "ConfigMap", + Namespace: "knative-eventing", + Name: "imc-channel", + }, + }, + }, + }, + "default annotation from cluster": { + expected: Broker{ + ObjectMeta: metav1.ObjectMeta{ + Annotations: map[string]string{ + eventing.BrokerClassKey: eventing.ChannelBrokerClassValue, + }, + }, + Spec: BrokerSpec{ + Config: &duckv1.KReference{ + APIVersion: "v1", + Kind: "ConfigMap", + Namespace: "knative-eventing", + Name: "imc-channel", + }, + }, + }, + initial: Broker{ + Spec: BrokerSpec{ + Config: &duckv1.KReference{ + APIVersion: "v1", + Kind: "ConfigMap", + Namespace: "knative-eventing", + Name: "imc-channel", + }, + }, + }, + }, + "config already specified, adds annotation": { + initial: Broker{ + Spec: BrokerSpec{ + Config: &duckv1.KReference{ + APIVersion: SchemeGroupVersion.String(), + Kind: "OtherChannel", + }, + }, + }, + expected: Broker{ + ObjectMeta: metav1.ObjectMeta{ + Annotations: map[string]string{ + eventing.BrokerClassKey: eventing.ChannelBrokerClassValue, + }, + }, + Spec: BrokerSpec{ + Config: &duckv1.KReference{ + APIVersion: SchemeGroupVersion.String(), + Kind: "OtherChannel", + }, + }, + }, + }, + "no config, uses namespace broker config, cluster class": { + initial: Broker{ + ObjectMeta: metav1.ObjectMeta{Namespace: "mynamespace"}, + }, + expected: Broker{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: "mynamespace", + Annotations: map[string]string{ + eventing.BrokerClassKey: eventing.ChannelBrokerClassValue, + }, + }, + Spec: BrokerSpec{ + Config: &duckv1.KReference{ + Kind: "ConfigMap", + Namespace: "knative-eventing", + Name: "kafka-channel", + APIVersion: "v1", + }, + }, + }, + }, + "no config, uses namespace broker config and class": { + initial: Broker{ + ObjectMeta: metav1.ObjectMeta{Namespace: "mynamespace2"}, + }, + expected: Broker{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: "mynamespace2", + Annotations: map[string]string{ + eventing.BrokerClassKey: "mynamespace2class", + }, + }, + Spec: BrokerSpec{ + Config: &duckv1.KReference{ + Kind: "ConfigMap", + Namespace: "knative-eventing", + Name: "natss-channel", + APIVersion: "v1", + }, + }, + }, + }, + } + for n, tc := range testCases { + t.Run(n, func(t *testing.T) { + tc.initial.SetDefaults(config.ToContext(context.Background(), defaultConfig)) + if diff := cmp.Diff(tc.expected, tc.initial); diff != "" { + t.Fatalf("Unexpected defaults (-want, +got): %s", diff) + } + }) + } +} diff --git a/vendor/knative.dev/pkg/Gopkg.lock b/vendor/knative.dev/pkg/Gopkg.lock index ae0a987a3b2..e4e14b97e2a 100644 --- a/vendor/knative.dev/pkg/Gopkg.lock +++ b/vendor/knative.dev/pkg/Gopkg.lock @@ -1342,14 +1342,14 @@ [[projects]] branch = "master" - digest = "1:e7ea104eff9c91ce48f1730ab8b4098faa1ea519162ccbbbca68c205428f0e21" + digest = "1:dd8432987142e8a917e58bac0137c287f54399fa68b0760936d52dce04eb639b" name = "knative.dev/test-infra" packages = [ "scripts", "tools/dep-collector", ] pruneopts = "UT" - revision = "908ad6cdb8e4aab96cdf0d94f766db7caf4fe129" + revision = "0c681e1f1df96322a62976d05d0add50bd50632e" [[projects]] digest = "1:8730e0150dfb2b7e173890c8b9868e7a273082ef8e39f4940e3506a481cf895c" diff --git a/vendor/knative.dev/pkg/injection/README.md b/vendor/knative.dev/pkg/injection/README.md index 259f0267b67..ab452b6e579 100644 --- a/vendor/knative.dev/pkg/injection/README.md +++ b/vendor/knative.dev/pkg/injection/README.md @@ -317,8 +317,8 @@ Optionally, support for finalizers: ``` - `ReconcileKind` is only called if the resource's deletion timestamp is empty. -- `FinalizeKind` is optional, and if implemented by the reconciler will be called - when the resource's deletion timestamp is set. +- `FinalizeKind` is optional, and if implemented by the reconciler will be + called when the resource's deletion timestamp is set. The responsibility and consequences of using the generated `ReconcileKind(resource)` method are as follows: diff --git a/vendor/knative.dev/pkg/injection/sharedmain/main.go b/vendor/knative.dev/pkg/injection/sharedmain/main.go index 1b159338e54..0eb16ecd14a 100644 --- a/vendor/knative.dev/pkg/injection/sharedmain/main.go +++ b/vendor/knative.dev/pkg/injection/sharedmain/main.go @@ -106,7 +106,7 @@ func GetLeaderElectionConfig(ctx context.Context) (*kle.Config, error) { leaderElectionConfigMap, err := kubeclient.Get(ctx).CoreV1().ConfigMaps(system.Namespace()).Get(kle.ConfigMapName(), metav1.GetOptions{}) if err != nil { if apierrors.IsNotFound(err) { - return kle.NewConfigFromMap(nil) + return kle.NewConfigFromConfigMap(nil) } return nil, err From 9e2a9871de478e323d0751dc9d11612254fa6258 Mon Sep 17 00:00:00 2001 From: Ville Aikas Date: Fri, 6 Mar 2020 17:27:21 -0800 Subject: [PATCH 2/2] appease the robot overlord --- pkg/apis/eventing/v1beta1/broker_defaults_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/apis/eventing/v1beta1/broker_defaults_test.go b/pkg/apis/eventing/v1beta1/broker_defaults_test.go index 3df1666a8e8..072b41a8c92 100644 --- a/pkg/apis/eventing/v1beta1/broker_defaults_test.go +++ b/pkg/apis/eventing/v1beta1/broker_defaults_test.go @@ -1,5 +1,5 @@ /* -Copyright 2019 The Knative Authors +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. @@ -34,7 +34,7 @@ var ( // NamespaceDefaultsConfig are the default Broker Configs for each namespace. // Namespace is the key, the value is the KReference to the config. NamespaceDefaultsConfig: map[string]*config.ClassAndKRef{ - "mynamespace": &config.ClassAndKRef{ + "mynamespace": { KReference: &duckv1.KReference{ APIVersion: "v1", Kind: "ConfigMap", @@ -42,7 +42,7 @@ var ( Name: "kafka-channel", }, }, - "mynamespace2": &config.ClassAndKRef{ + "mynamespace2": { BrokerClass: "mynamespace2class", KReference: &duckv1.KReference{ APIVersion: "v1",