From 21d3705dcf20f55ab82f884f2fb281fffbce71a7 Mon Sep 17 00:00:00 2001 From: Dave Protasowski Date: Mon, 24 Feb 2020 11:57:32 -0500 Subject: [PATCH 1/2] bump knative.dev/pkg --- Gopkg.lock | 4 +- vendor/knative.dev/pkg/Gopkg.lock | 2 - vendor/knative.dev/pkg/apis/condition_set.go | 13 ++-- vendor/knative.dev/pkg/apis/convert.go | 16 ++--- .../pkg/apis/duck/v1/addressable_types.go | 8 +-- .../apis/duck/v1alpha1/addressable_types.go | 8 +-- .../apis/duck/v1beta1/addressable_types.go | 8 +-- vendor/knative.dev/pkg/apis/interfaces.go | 8 +-- .../pkg/apis/testing/conditions.go | 21 +++---- .../pkg/apis/testing/roundtrip/roundtrip.go | 4 +- .../pkg/apis/testing/v1/conditions.go | 61 ------------------- .../pkg/apis/testing/v1beta1/conditions.go | 61 ------------------- .../knative.dev/pkg/test/presubmit-tests.sh | 11 ++-- ...-codegen.sh => test-reconciler-codegen.sh} | 15 +++-- .../conversion/controller.go | 4 +- .../conversion/conversion.go | 4 +- .../conversion/internal/types.go | 52 ++++++++-------- 17 files changed, 93 insertions(+), 207 deletions(-) delete mode 100644 vendor/knative.dev/pkg/apis/testing/v1/conditions.go delete mode 100644 vendor/knative.dev/pkg/apis/testing/v1beta1/conditions.go rename vendor/knative.dev/pkg/test/{update-test-codegen.sh => test-reconciler-codegen.sh} (87%) diff --git a/Gopkg.lock b/Gopkg.lock index f7bd7cdf1cc..c57c0cff97d 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -1312,7 +1312,7 @@ [[projects]] branch = "master" - digest = "1:cc94fa80f6e4903c1c5b2fc8673156762b2ab2dfe3be11486fea0307e9de71b8" + digest = "1:efd99f16d7b5337b1cce9ac8576e2f65c2c2f7b759f64cd235b82f42e0f86f09" name = "knative.dev/pkg" packages = [ "apis", @@ -1415,7 +1415,7 @@ "webhook/resourcesemantics/validation", ] pruneopts = "T" - revision = "a2e3b66654c1bcd82df07f8b4c45b19bad7ab21a" + revision = "d771641c9192ee2ce1e54c3d9af2cc7f692cb7ab" [[projects]] branch = "master" diff --git a/vendor/knative.dev/pkg/Gopkg.lock b/vendor/knative.dev/pkg/Gopkg.lock index 2cb02a32192..1a008c57dda 100644 --- a/vendor/knative.dev/pkg/Gopkg.lock +++ b/vendor/knative.dev/pkg/Gopkg.lock @@ -1461,7 +1461,6 @@ "k8s.io/apimachinery/pkg/version", "k8s.io/apimachinery/pkg/watch", "k8s.io/client-go/discovery", - "k8s.io/client-go/discovery/fake", "k8s.io/client-go/dynamic", "k8s.io/client-go/dynamic/fake", "k8s.io/client-go/informers", @@ -1489,7 +1488,6 @@ "k8s.io/client-go/tools/clientcmd", "k8s.io/client-go/tools/metrics", "k8s.io/client-go/tools/record", - "k8s.io/client-go/util/flowcontrol", "k8s.io/client-go/util/retry", "k8s.io/client-go/util/workqueue", "k8s.io/code-generator/cmd/client-gen", diff --git a/vendor/knative.dev/pkg/apis/condition_set.go b/vendor/knative.dev/pkg/apis/condition_set.go index 1e90aa9eae0..2691dcf0fae 100644 --- a/vendor/knative.dev/pkg/apis/condition_set.go +++ b/vendor/knative.dev/pkg/apis/condition_set.go @@ -35,6 +35,13 @@ type ConditionsAccessor interface { SetConditions(Conditions) } +// ConditionAccessor is used to access a condition through it's type +type ConditionAccessor interface { + // GetCondition finds and returns the Condition that matches the ConditionType + // It should return nil if the condition type is not present + GetCondition(t ConditionType) *Condition +} + // ConditionSet is an abstract collection of the possible ConditionType values // that a particular resource might expose. It also holds the "happy condition" // for that resource, which we define to be one of Ready or Succeeded depending @@ -48,6 +55,8 @@ type ConditionSet struct { // ConditionManager allows a resource to operate on its Conditions using higher // order operations. type ConditionManager interface { + ConditionAccessor + // IsHappy looks at the happy condition and returns true if that condition is // set to true. IsHappy() bool @@ -55,10 +64,6 @@ type ConditionManager interface { // GetTopLevelCondition finds and returns the top level Condition (happy Condition). GetTopLevelCondition() *Condition - // GetCondition finds and returns the Condition that matches the ConditionType - // previously set on Conditions. - GetCondition(t ConditionType) *Condition - // SetCondition sets or updates the Condition on Conditions for Condition.Type. // If there is an update, Conditions are stored back sorted. SetCondition(new Condition) diff --git a/vendor/knative.dev/pkg/apis/convert.go b/vendor/knative.dev/pkg/apis/convert.go index e67a379303b..d6a28a0727f 100644 --- a/vendor/knative.dev/pkg/apis/convert.go +++ b/vendor/knative.dev/pkg/apis/convert.go @@ -18,30 +18,30 @@ package apis import "context" -// ConvertUpViaProxy attempts to convert a specific source to a sink +// ConvertToViaProxy attempts to convert a specific source to a sink // through a proxy -func ConvertUpViaProxy( +func ConvertToViaProxy( ctx context.Context, source, proxy, sink Convertible, ) error { - if err := source.ConvertUp(ctx, proxy); err != nil { + if err := source.ConvertTo(ctx, proxy); err != nil { return err } - return proxy.ConvertUp(ctx, sink) + return proxy.ConvertTo(ctx, sink) } -// ConvertDownViaProxy attempts to convert a specific sink from a source +// ConvertFromViaProxy attempts to convert a specific sink from a source // through a proxy -func ConvertDownViaProxy( +func ConvertFromViaProxy( ctx context.Context, source, proxy, sink Convertible, ) error { - if err := proxy.ConvertDown(ctx, source); err != nil { + if err := proxy.ConvertFrom(ctx, source); err != nil { return err } - return sink.ConvertDown(ctx, proxy) + return sink.ConvertFrom(ctx, proxy) } 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 e5955aeb69f..579e6976ee8 100644 --- a/vendor/knative.dev/pkg/apis/duck/v1/addressable_types.go +++ b/vendor/knative.dev/pkg/apis/duck/v1/addressable_types.go @@ -76,13 +76,13 @@ func (*Addressable) GetFullType() duck.Populatable { return &AddressableType{} } -// ConvertUp implements apis.Convertible -func (a *Addressable) ConvertUp(ctx context.Context, to apis.Convertible) error { +// ConvertTo implements apis.Convertible +func (a *Addressable) ConvertTo(ctx context.Context, to apis.Convertible) error { return fmt.Errorf("v1 is the highest known version, got: %T", to) } -// ConvertDown implements apis.Convertible -func (a *Addressable) ConvertDown(ctx context.Context, from apis.Convertible) error { +// ConvertFrom implements apis.Convertible +func (a *Addressable) ConvertFrom(ctx context.Context, from apis.Convertible) error { return fmt.Errorf("v1 is the highest known version, got: %T", from) } diff --git a/vendor/knative.dev/pkg/apis/duck/v1alpha1/addressable_types.go b/vendor/knative.dev/pkg/apis/duck/v1alpha1/addressable_types.go index d0a81db8fc2..70c9b0135ce 100644 --- a/vendor/knative.dev/pkg/apis/duck/v1alpha1/addressable_types.go +++ b/vendor/knative.dev/pkg/apis/duck/v1alpha1/addressable_types.go @@ -80,8 +80,8 @@ func (*Addressable) GetFullType() duck.Populatable { return &AddressableType{} } -// ConvertUp implements apis.Convertible -func (a *Addressable) ConvertUp(ctx context.Context, to apis.Convertible) error { +// ConvertTo implements apis.Convertible +func (a *Addressable) ConvertTo(ctx context.Context, to apis.Convertible) error { var url *apis.URL if a.URL != nil { url = a.URL @@ -101,8 +101,8 @@ func (a *Addressable) ConvertUp(ctx context.Context, to apis.Convertible) error } } -// ConvertDown implements apis.Convertible -func (a *Addressable) ConvertDown(ctx context.Context, from apis.Convertible) error { +// ConvertFrom implements apis.Convertible +func (a *Addressable) ConvertFrom(ctx context.Context, from apis.Convertible) error { switch source := from.(type) { case *v1.Addressable: a.URL = source.URL.DeepCopy() 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 6093bd03382..3e3f8286763 100644 --- a/vendor/knative.dev/pkg/apis/duck/v1beta1/addressable_types.go +++ b/vendor/knative.dev/pkg/apis/duck/v1beta1/addressable_types.go @@ -77,8 +77,8 @@ func (*Addressable) GetFullType() duck.Populatable { return &AddressableType{} } -// ConvertUp implements apis.Convertible -func (a *Addressable) ConvertUp(ctx context.Context, to apis.Convertible) error { +// ConvertTo implements apis.Convertible +func (a *Addressable) ConvertTo(ctx context.Context, to apis.Convertible) error { switch sink := to.(type) { case *v1.Addressable: sink.URL = a.URL.DeepCopy() @@ -88,8 +88,8 @@ func (a *Addressable) ConvertUp(ctx context.Context, to apis.Convertible) error } } -// ConvertDown implements apis.Convertible -func (a *Addressable) ConvertDown(ctx context.Context, from apis.Convertible) error { +// ConvertFrom implements apis.Convertible +func (a *Addressable) ConvertFrom(ctx context.Context, from apis.Convertible) error { switch source := from.(type) { case *v1.Addressable: a.URL = source.URL.DeepCopy() diff --git a/vendor/knative.dev/pkg/apis/interfaces.go b/vendor/knative.dev/pkg/apis/interfaces.go index fef69d8b315..b4d350f88f9 100644 --- a/vendor/knative.dev/pkg/apis/interfaces.go +++ b/vendor/knative.dev/pkg/apis/interfaces.go @@ -37,11 +37,11 @@ type Validatable interface { // Convertible indicates that a particular type supports conversions to/from // "higher" versions of the same type. type Convertible interface { - // ConvertUp up-converts the receiver into `to`. - ConvertUp(ctx context.Context, to Convertible) error + // ConvertTo converts the receiver into `to`. + ConvertTo(ctx context.Context, to Convertible) error - // ConvertDown down-converts from `from` into the receiver. - ConvertDown(ctx context.Context, from Convertible) error + // ConvertFrom converts `from` into the receiver. + ConvertFrom(ctx context.Context, from Convertible) error } // Listable indicates that a particular type can be returned via the returned diff --git a/vendor/knative.dev/pkg/apis/testing/conditions.go b/vendor/knative.dev/pkg/apis/testing/conditions.go index 02d1fe8b0a0..68b0018ab6b 100644 --- a/vendor/knative.dev/pkg/apis/testing/conditions.go +++ b/vendor/knative.dev/pkg/apis/testing/conditions.go @@ -20,14 +20,12 @@ import ( corev1 "k8s.io/api/core/v1" "knative.dev/pkg/apis" - duckv1b1 "knative.dev/pkg/apis/duck/v1beta1" "knative.dev/pkg/test" ) // CheckCondition checks if condition `c` on `cc` has value `cs`. -// DEPRECATED: Use versioned test helper -func CheckCondition(s *duckv1b1.Status, c apis.ConditionType, cs corev1.ConditionStatus) error { - cond := s.GetCondition(c) +func CheckCondition(a apis.ConditionAccessor, c apis.ConditionType, cs corev1.ConditionStatus) error { + cond := a.GetCondition(c) if cond == nil { return fmt.Errorf("condition %v is nil", c) } @@ -38,28 +36,25 @@ func CheckCondition(s *duckv1b1.Status, c apis.ConditionType, cs corev1.Conditio } // CheckConditionOngoing checks if the condition is in state `Unknown`. -// DEPRECATED: Use versioned test helper -func CheckConditionOngoing(s *duckv1b1.Status, c apis.ConditionType, t test.T) { +func CheckConditionOngoing(a apis.ConditionAccessor, c apis.ConditionType, t test.T) { t.Helper() - if err := CheckCondition(s, c, corev1.ConditionUnknown); err != nil { + if err := CheckCondition(a, c, corev1.ConditionUnknown); err != nil { t.Error(err) } } // CheckConditionFailed checks if the condition is in state `False`. -// DEPRECATED: Use versioned test helper -func CheckConditionFailed(s *duckv1b1.Status, c apis.ConditionType, t test.T) { +func CheckConditionFailed(a apis.ConditionAccessor, c apis.ConditionType, t test.T) { t.Helper() - if err := CheckCondition(s, c, corev1.ConditionFalse); err != nil { + if err := CheckCondition(a, c, corev1.ConditionFalse); err != nil { t.Error(err) } } // CheckConditionSucceeded checks if the condition is in state `True`. -// DEPRECATED: Use versioned test helper -func CheckConditionSucceeded(s *duckv1b1.Status, c apis.ConditionType, t test.T) { +func CheckConditionSucceeded(a apis.ConditionAccessor, c apis.ConditionType, t test.T) { t.Helper() - if err := CheckCondition(s, c, corev1.ConditionTrue); err != nil { + if err := CheckCondition(a, c, corev1.ConditionTrue); err != nil { t.Error(err) } } diff --git a/vendor/knative.dev/pkg/apis/testing/roundtrip/roundtrip.go b/vendor/knative.dev/pkg/apis/testing/roundtrip/roundtrip.go index 9410d99422b..ccc030f7ebb 100644 --- a/vendor/knative.dev/pkg/apis/testing/roundtrip/roundtrip.go +++ b/vendor/knative.dev/pkg/apis/testing/roundtrip/roundtrip.go @@ -173,7 +173,7 @@ func roundTripViaHub(t *testing.T, gvk schema.GroupVersionKind, scheme, hubs *ru return } - if err := hub.ConvertDown(ctx, obj); err != nil { + if err := hub.ConvertFrom(ctx, obj); err != nil { t.Errorf("Conversion to hub (%s) failed: %s", hubGVK, err) } @@ -183,7 +183,7 @@ func roundTripViaHub(t *testing.T, gvk schema.GroupVersionKind, scheme, hubs *ru } newObj := objForGVK(t, gvk, scheme) - if err := hub.ConvertUp(ctx, newObj); err != nil { + if err := hub.ConvertTo(ctx, newObj); err != nil { t.Errorf("Conversion from hub (%s) failed: %s", hubGVK, err) t.Errorf("object: %#v", obj) return diff --git a/vendor/knative.dev/pkg/apis/testing/v1/conditions.go b/vendor/knative.dev/pkg/apis/testing/v1/conditions.go deleted file mode 100644 index 6ace88eb5cc..00000000000 --- a/vendor/knative.dev/pkg/apis/testing/v1/conditions.go +++ /dev/null @@ -1,61 +0,0 @@ -/* -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 v1 - -import ( - "fmt" - - corev1 "k8s.io/api/core/v1" - "knative.dev/pkg/apis" - duckv1 "knative.dev/pkg/apis/duck/v1" - "knative.dev/pkg/test" -) - -// CheckCondition checks if condition `c` on `cc` has value `cs`. -func CheckCondition(s *duckv1.Status, c apis.ConditionType, cs corev1.ConditionStatus) error { - cond := s.GetCondition(c) - if cond == nil { - return fmt.Errorf("condition %v is nil", c) - } - if cond.Status != cs { - return fmt.Errorf("condition(%v) = %v, wanted: %v", c, cond, cs) - } - return nil -} - -// CheckConditionOngoing checks if the condition is in state `Unknown`. -func CheckConditionOngoing(s *duckv1.Status, c apis.ConditionType, t test.T) { - t.Helper() - if err := CheckCondition(s, c, corev1.ConditionUnknown); err != nil { - t.Error(err) - } -} - -// CheckConditionFailed checks if the condition is in state `False`. -func CheckConditionFailed(s *duckv1.Status, c apis.ConditionType, t test.T) { - t.Helper() - if err := CheckCondition(s, c, corev1.ConditionFalse); err != nil { - t.Error(err) - } -} - -// CheckConditionSucceeded checks if the condition is in state `True`. -func CheckConditionSucceeded(s *duckv1.Status, c apis.ConditionType, t test.T) { - t.Helper() - if err := CheckCondition(s, c, corev1.ConditionTrue); err != nil { - t.Error(err) - } -} diff --git a/vendor/knative.dev/pkg/apis/testing/v1beta1/conditions.go b/vendor/knative.dev/pkg/apis/testing/v1beta1/conditions.go deleted file mode 100644 index 74aa26b2adf..00000000000 --- a/vendor/knative.dev/pkg/apis/testing/v1beta1/conditions.go +++ /dev/null @@ -1,61 +0,0 @@ -/* -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 testing - -import ( - "fmt" - - corev1 "k8s.io/api/core/v1" - "knative.dev/pkg/apis" - duckv1b1 "knative.dev/pkg/apis/duck/v1beta1" - "knative.dev/pkg/test" -) - -// CheckCondition checks if condition `c` on `cc` has value `cs`. -func CheckCondition(s *duckv1b1.Status, c apis.ConditionType, cs corev1.ConditionStatus) error { - cond := s.GetCondition(c) - if cond == nil { - return fmt.Errorf("condition %v is nil", c) - } - if cond.Status != cs { - return fmt.Errorf("condition(%v) = %v, wanted: %v", c, cond, cs) - } - return nil -} - -// CheckConditionOngoing checks if the condition is in state `Unknown`. -func CheckConditionOngoing(s *duckv1b1.Status, c apis.ConditionType, t test.T) { - t.Helper() - if err := CheckCondition(s, c, corev1.ConditionUnknown); err != nil { - t.Error(err) - } -} - -// CheckConditionFailed checks if the condition is in state `False`. -func CheckConditionFailed(s *duckv1b1.Status, c apis.ConditionType, t test.T) { - t.Helper() - if err := CheckCondition(s, c, corev1.ConditionFalse); err != nil { - t.Error(err) - } -} - -// CheckConditionSucceeded checks if the condition is in state `True`. -func CheckConditionSucceeded(s *duckv1b1.Status, c apis.ConditionType, t test.T) { - t.Helper() - if err := CheckCondition(s, c, corev1.ConditionTrue); err != nil { - t.Error(err) - } -} diff --git a/vendor/knative.dev/pkg/test/presubmit-tests.sh b/vendor/knative.dev/pkg/test/presubmit-tests.sh index 5bcb6262004..7c10a5e0a56 100755 --- a/vendor/knative.dev/pkg/test/presubmit-tests.sh +++ b/vendor/knative.dev/pkg/test/presubmit-tests.sh @@ -24,12 +24,15 @@ export DISABLE_MD_LINTING=1 source $(dirname $0)/../vendor/knative.dev/test-infra/scripts/presubmit-tests.sh -# Test the custom code generators. This makes sure we can compile the output -# of the injection generators. -$(dirname $0)/update-test-codegen.sh - # TODO(#17): Write integration tests. # We use the default build, unit and integration test runners. +function pre_build_tests() { + # Test the custom code generators. This makes sure we can compile the output + # of the injection generators. + $(dirname $0)/test-reconciler-codegen.sh + return 0 +} + main $@ diff --git a/vendor/knative.dev/pkg/test/update-test-codegen.sh b/vendor/knative.dev/pkg/test/test-reconciler-codegen.sh similarity index 87% rename from vendor/knative.dev/pkg/test/update-test-codegen.sh rename to vendor/knative.dev/pkg/test/test-reconciler-codegen.sh index 470576378d0..598de24fbec 100755 --- a/vendor/knative.dev/pkg/test/update-test-codegen.sh +++ b/vendor/knative.dev/pkg/test/test-reconciler-codegen.sh @@ -24,10 +24,11 @@ CODEGEN_PKG=${CODEGEN_PKG:-$(cd ${REPO_ROOT_DIR}; ls -d -1 $(dirname $0)/../vend KNATIVE_CODEGEN_PKG=${KNATIVE_CODEGEN_PKG:-$(cd ${REPO_ROOT_DIR}; ls -d -1 $(dirname $0)/../vendor/knative.dev/pkg 2>/dev/null || echo ../pkg)} GENCLIENT_PKG=knative.dev/pkg/test/genclient -( - cd ${REPO_ROOT_DIR} - rm -rf ${REPO_ROOT_DIR}/pkg/test/genclient -) + +echo "Pre-deleting $(dirname $0)/genclient" +rm -rf $(dirname $0)/genclient + +header "Test Generated Reconciler Builds." ${CODEGEN_PKG}/generate-groups.sh "deepcopy,client,informer,lister" \ ${GENCLIENT_PKG} knative.dev/pkg/apis/test \ @@ -52,3 +53,9 @@ ${KNATIVE_CODEGEN_PKG}/hack/generate-knative.sh "injection" \ --go-header-file ${REPO_ROOT_DIR}/hack/boilerplate/boilerplate.go.txt +if ! go build -v $(dirname $0)/genclient/... ; then + exit 1 +fi + +echo "Finished, deleting $(dirname $0)/genclient" +rm -rf $(dirname $0)/genclient diff --git a/vendor/knative.dev/pkg/webhook/resourcesemantics/conversion/controller.go b/vendor/knative.dev/pkg/webhook/resourcesemantics/conversion/controller.go index bb06f2e2160..b21003e0a8f 100644 --- a/vendor/knative.dev/pkg/webhook/resourcesemantics/conversion/controller.go +++ b/vendor/knative.dev/pkg/webhook/resourcesemantics/conversion/controller.go @@ -41,8 +41,8 @@ import ( // ConversionController will apply defaults before returning // the response type ConvertibleObject interface { - // ConvertUp(ctx) - // ConvertDown(ctx) + // ConvertTo(ctx, to) + // ConvertFrom(ctx, from) apis.Convertible // DeepCopyObject() diff --git a/vendor/knative.dev/pkg/webhook/resourcesemantics/conversion/conversion.go b/vendor/knative.dev/pkg/webhook/resourcesemantics/conversion/conversion.go index afc3915f128..e829ed75cf2 100644 --- a/vendor/knative.dev/pkg/webhook/resourcesemantics/conversion/conversion.go +++ b/vendor/knative.dev/pkg/webhook/resourcesemantics/conversion/conversion.go @@ -133,14 +133,14 @@ func (r *reconciler) convert( if inGVK.Version == conv.HubVersion { hub = in - } else if err = hub.ConvertDown(ctx, in); err != nil { + } else if err = hub.ConvertFrom(ctx, in); err != nil { err = fmt.Errorf("conversion failed to version %s for type %s - %s", outGVK.Version, formatGVK(inGVK), err) return } if outGVK.Version == conv.HubVersion { out = hub - } else if err = hub.ConvertUp(ctx, out); err != nil { + } else if err = hub.ConvertTo(ctx, out); err != nil { err = fmt.Errorf("conversion failed to version %s for type %s - %s", outGVK.Version, formatGVK(inGVK), err) return } diff --git a/vendor/knative.dev/pkg/webhook/resourcesemantics/conversion/internal/types.go b/vendor/knative.dev/pkg/webhook/resourcesemantics/conversion/internal/types.go index 764ddc92574..52f67006ac3 100644 --- a/vendor/knative.dev/pkg/webhook/resourcesemantics/conversion/internal/types.go +++ b/vendor/knative.dev/pkg/webhook/resourcesemantics/conversion/internal/types.go @@ -42,13 +42,13 @@ const ( // will cause json unmarshalling of the resource to fail ErrorUnmarshal = "unmarshal" - // ErrorConvertUp when assigned to the Spec.Property of the ErrorResource - // will cause ConvertUp to fail - ErrorConvertUp = "convertUp" + // ErrorConvertTo when assigned to the Spec.Property of the ErrorResource + // will cause ConvertTo to fail + ErrorConvertTo = "convertTo" - // ErrorConvertDown when assigned to the Spec.Property of the ErrorResource - // will cause ConvertDown to fail - ErrorConvertDown = "convertDown" + // ErrorConvertFrom when assigned to the Spec.Property of the ErrorResource + // will cause ConvertFrom to fail + ErrorConvertFrom = "convertFrom" ) type ( @@ -180,8 +180,8 @@ func NewErrorResource(failure string) *ErrorResource { } } -// ConvertUp implements apis.Convertible -func (r *V1Resource) ConvertUp(ctx context.Context, to apis.Convertible) error { +// ConvertTo implements apis.Convertible +func (r *V1Resource) ConvertTo(ctx context.Context, to apis.Convertible) error { switch sink := to.(type) { case *V2Resource: sink.Spec.Property = "prefix/" + r.Spec.Property @@ -197,8 +197,8 @@ func (r *V1Resource) ConvertUp(ctx context.Context, to apis.Convertible) error { return nil } -// ConvertDown implements apis.Convertible -func (r *V1Resource) ConvertDown(ctx context.Context, from apis.Convertible) error { +// ConvertFrom implements apis.Convertible +func (r *V1Resource) ConvertFrom(ctx context.Context, from apis.Convertible) error { switch source := from.(type) { case *V2Resource: r.Spec.Property = strings.TrimPrefix(source.Spec.Property, "prefix/") @@ -221,40 +221,40 @@ func (r *V3Resource) SetDefaults(ctx context.Context) { } } -// ConvertUp implements apis.Convertible -func (*V2Resource) ConvertUp(ctx context.Context, to apis.Convertible) error { +// ConvertTo implements apis.Convertible +func (*V2Resource) ConvertTo(ctx context.Context, to apis.Convertible) error { panic("unimplemented") } -// ConvertDown implements apis.Convertible -func (*V2Resource) ConvertDown(ctx context.Context, from apis.Convertible) error { +// ConvertFrom implements apis.Convertible +func (*V2Resource) ConvertFrom(ctx context.Context, from apis.Convertible) error { panic("unimplemented") } -// ConvertUp implements apis.Convertible -func (*V3Resource) ConvertUp(ctx context.Context, to apis.Convertible) error { +// ConvertTo implements apis.Convertible +func (*V3Resource) ConvertTo(ctx context.Context, to apis.Convertible) error { panic("unimplemented") } -// ConvertDown implements apis.Convertible -func (*V3Resource) ConvertDown(ctx context.Context, from apis.Convertible) error { +// ConvertFrom implements apis.Convertible +func (*V3Resource) ConvertFrom(ctx context.Context, from apis.Convertible) error { panic("unimplemented") } -// ConvertUp implements apis.Convertible -func (e *ErrorResource) ConvertUp(ctx context.Context, to apis.Convertible) error { - if e.Spec.Property == ErrorConvertUp { +// ConvertTo implements apis.Convertible +func (e *ErrorResource) ConvertTo(ctx context.Context, to apis.Convertible) error { + if e.Spec.Property == ErrorConvertTo { return errors.New("boooom - convert up") } - return e.V1Resource.ConvertUp(ctx, to) + return e.V1Resource.ConvertTo(ctx, to) } -// ConvertDown implements apis.Convertible -func (e *ErrorResource) ConvertDown(ctx context.Context, from apis.Convertible) error { - err := e.V1Resource.ConvertDown(ctx, from) +// ConvertFrom implements apis.Convertible +func (e *ErrorResource) ConvertFrom(ctx context.Context, from apis.Convertible) error { + err := e.V1Resource.ConvertFrom(ctx, from) - if err == nil && e.Spec.Property == ErrorConvertDown { + if err == nil && e.Spec.Property == ErrorConvertFrom { err = errors.New("boooom - convert down") } return err From 9eb2371b52122b800829f9e6f9a7dc4449f8f0fd Mon Sep 17 00:00:00 2001 From: Dave Protasowski Date: Mon, 24 Feb 2020 12:01:48 -0500 Subject: [PATCH 2/2] Rename ConvertUp/Down to ConvertTo/From Replacing done via the commands: ``` rg -l ConvertDown | xargs -n1 sed -i '' 's/ConvertDown/ConvertFrom/g' rg -l ConvertUp | xargs -n1 sed -i '' 's/ConvertUp/ConvertTo/g' ``` --- cmd/webhook/main.go | 2 +- pkg/apis/duck/v1beta1/delivery_conversion.go | 16 ++++----- .../duck/v1beta1/delivery_conversion_test.go | 16 ++++----- .../eventing/v1alpha1/broker_conversion.go | 12 +++---- .../v1alpha1/broker_conversion_test.go | 16 ++++----- .../eventing/v1alpha1/eventtype_conversion.go | 8 ++--- .../v1alpha1/eventtype_conversion_test.go | 16 ++++----- .../eventing/v1alpha1/trigger_conversion.go | 8 ++--- .../v1alpha1/trigger_conversion_test.go | 20 +++++------ .../eventing/v1beta1/broker_conversion.go | 8 ++--- .../v1beta1/broker_conversion_test.go | 8 ++--- .../eventing/v1beta1/eventtype_conversion.go | 8 ++--- .../v1beta1/eventtype_conversion_test.go | 8 ++--- .../eventing/v1beta1/trigger_conversion.go | 8 ++--- .../v1beta1/trigger_conversion_test.go | 8 ++--- .../flows/v1alpha1/parallel_conversion.go | 8 ++--- .../v1alpha1/parallel_conversion_test.go | 24 ++++++------- pkg/apis/flows/v1alpha1/parallel_lifecycle.go | 4 +-- .../flows/v1alpha1/sequence_conversion.go | 8 ++--- .../v1alpha1/sequence_conversion_test.go | 24 ++++++------- pkg/apis/flows/v1alpha1/sequence_lifecycle.go | 4 +-- pkg/apis/flows/v1beta1/parallel_conversion.go | 8 ++--- .../flows/v1beta1/parallel_conversion_test.go | 8 ++--- pkg/apis/flows/v1beta1/sequence_conversion.go | 8 ++--- .../flows/v1beta1/sequence_conversion_test.go | 8 ++--- .../messaging/v1alpha1/channel_conversion.go | 36 +++++++++---------- .../v1alpha1/channel_conversion_test.go | 24 ++++++------- .../v1alpha1/in_memory_channel_conversion.go | 36 +++++++++---------- .../in_memory_channel_conversion_test.go | 24 ++++++------- .../v1alpha1/subscription_conversion.go | 8 ++--- .../v1alpha1/subscription_conversion_test.go | 16 ++++----- .../messaging/v1beta1/channel_conversion.go | 8 ++--- .../v1beta1/channel_conversion_test.go | 8 ++--- .../v1beta1/in_memory_channel_conversion.go | 8 ++--- .../in_memory_channel_conversion_test.go | 8 ++--- .../v1beta1/subscription_conversion.go | 8 ++--- .../v1beta1/subscription_conversion_test.go | 8 ++--- 37 files changed, 229 insertions(+), 229 deletions(-) diff --git a/cmd/webhook/main.go b/cmd/webhook/main.go index 7628bc271ea..2abe9cef026 100644 --- a/cmd/webhook/main.go +++ b/cmd/webhook/main.go @@ -278,7 +278,7 @@ func NewConversionController(ctx context.Context, cmw configmap.Watcher) *contro }, }, - // A function that infuses the context passed to ConvertUp/ConvertDown/SetDefaults with custom metadata. + // A function that infuses the context passed to ConvertTo/ConvertFrom/SetDefaults with custom metadata. func(ctx context.Context) context.Context { return ctx }, diff --git a/pkg/apis/duck/v1beta1/delivery_conversion.go b/pkg/apis/duck/v1beta1/delivery_conversion.go index 0a7cb7cbdd0..07a729884cc 100644 --- a/pkg/apis/duck/v1beta1/delivery_conversion.go +++ b/pkg/apis/duck/v1beta1/delivery_conversion.go @@ -23,22 +23,22 @@ import ( "knative.dev/pkg/apis" ) -// ConvertUp implements apis.Convertible -func (source *DeliverySpec) ConvertUp(ctx context.Context, sink apis.Convertible) error { +// ConvertTo implements apis.Convertible +func (source *DeliverySpec) ConvertTo(ctx context.Context, sink apis.Convertible) error { return fmt.Errorf("v1beta1 is the highest known version, got: %T", sink) } -// ConvertDown implements apis.Convertible -func (sink *DeliverySpec) ConvertDown(ctx context.Context, source apis.Convertible) error { +// ConvertFrom implements apis.Convertible +func (sink *DeliverySpec) ConvertFrom(ctx context.Context, source apis.Convertible) error { return fmt.Errorf("v1beta1 is the highest known version, got: %T", source) } -// ConvertUp implements apis.Convertible -func (source *DeliveryStatus) ConvertUp(ctx context.Context, sink apis.Convertible) error { +// ConvertTo implements apis.Convertible +func (source *DeliveryStatus) ConvertTo(ctx context.Context, sink apis.Convertible) error { return fmt.Errorf("v1beta1 is the highest known version, got: %T", sink) } -// ConvertDown implements apis.Convertible -func (sink *DeliveryStatus) ConvertDown(ctx context.Context, source apis.Convertible) error { +// ConvertFrom implements apis.Convertible +func (sink *DeliveryStatus) 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/duck/v1beta1/delivery_conversion_test.go b/pkg/apis/duck/v1beta1/delivery_conversion_test.go index 25f41abc7e2..8672a158037 100644 --- a/pkg/apis/duck/v1beta1/delivery_conversion_test.go +++ b/pkg/apis/duck/v1beta1/delivery_conversion_test.go @@ -24,23 +24,23 @@ import ( func TestDeliverySpecConversionBadType(t *testing.T) { good, bad := &DeliverySpec{}, &DeliverySpec{} - if err := good.ConvertUp(context.Background(), bad); err == nil { - t.Errorf("ConvertUp() = %#v, wanted error", bad) + if err := good.ConvertTo(context.Background(), bad); err == nil { + t.Errorf("ConvertTo() = %#v, wanted error", bad) } - if err := good.ConvertDown(context.Background(), bad); err == nil { - t.Errorf("ConvertDown() = %#v, wanted error", good) + if err := good.ConvertFrom(context.Background(), bad); err == nil { + t.Errorf("ConvertFrom() = %#v, wanted error", good) } } func TestDeliveryStatusConversionBadType(t *testing.T) { good, bad := &DeliveryStatus{}, &DeliveryStatus{} - if err := good.ConvertUp(context.Background(), bad); err == nil { - t.Errorf("ConvertUp() = %#v, wanted error", bad) + if err := good.ConvertTo(context.Background(), bad); err == nil { + t.Errorf("ConvertTo() = %#v, wanted error", bad) } - if err := good.ConvertDown(context.Background(), bad); err == nil { - t.Errorf("ConvertDown() = %#v, wanted error", good) + if err := good.ConvertFrom(context.Background(), bad); err == nil { + t.Errorf("ConvertFrom() = %#v, wanted error", good) } } diff --git a/pkg/apis/eventing/v1alpha1/broker_conversion.go b/pkg/apis/eventing/v1alpha1/broker_conversion.go index e5d90cf1dfa..ed7be4fb216 100644 --- a/pkg/apis/eventing/v1alpha1/broker_conversion.go +++ b/pkg/apis/eventing/v1alpha1/broker_conversion.go @@ -24,16 +24,16 @@ import ( "knative.dev/pkg/apis" ) -// ConvertUp implements apis.Convertible. +// ConvertTo implements apis.Convertible. // Converts source (from v1alpha1.Broker) into v1beta1.Broker -func (source *Broker) ConvertUp(ctx context.Context, obj apis.Convertible) error { +func (source *Broker) ConvertTo(ctx context.Context, obj apis.Convertible) error { switch sink := obj.(type) { case *v1beta1.Broker: sink.ObjectMeta = source.ObjectMeta sink.Spec.Config = source.Spec.Config sink.Spec.Delivery = source.Spec.Delivery sink.Status.Status = source.Status.Status - if err := source.Status.Address.ConvertUp(ctx, &sink.Status.Address); err != nil { + if err := source.Status.Address.ConvertTo(ctx, &sink.Status.Address); err != nil { return err } return nil @@ -43,15 +43,15 @@ func (source *Broker) ConvertUp(ctx context.Context, obj apis.Convertible) error } } -// ConvertDown implements apis.Convertible. +// ConvertFrom implements apis.Convertible. // Converts obj from v1beta1.Broker into v1alpha1.Broker -func (sink *Broker) ConvertDown(ctx context.Context, obj apis.Convertible) error { +func (sink *Broker) ConvertFrom(ctx context.Context, obj apis.Convertible) error { switch source := obj.(type) { case *v1beta1.Broker: sink.ObjectMeta = source.ObjectMeta sink.Spec.Delivery = source.Spec.Delivery sink.Status.Status = source.Status.Status - if err := sink.Status.Address.ConvertDown(ctx, &source.Status.Address); err != nil { + if err := sink.Status.Address.ConvertFrom(ctx, &source.Status.Address); err != nil { return err } sink.Spec.Config = source.Spec.Config diff --git a/pkg/apis/eventing/v1alpha1/broker_conversion_test.go b/pkg/apis/eventing/v1alpha1/broker_conversion_test.go index ddaf5fd19fb..645fe7aad3b 100644 --- a/pkg/apis/eventing/v1alpha1/broker_conversion_test.go +++ b/pkg/apis/eventing/v1alpha1/broker_conversion_test.go @@ -36,12 +36,12 @@ import ( func TestBrokerConversionBadType(t *testing.T) { good, bad := &Broker{}, &dummy{} - if err := good.ConvertUp(context.Background(), bad); err == nil { - t.Errorf("ConvertUp() = %#v, wanted error", bad) + if err := good.ConvertTo(context.Background(), bad); err == nil { + t.Errorf("ConvertTo() = %#v, wanted error", bad) } - if err := good.ConvertDown(context.Background(), bad); err == nil { - t.Errorf("ConvertDown() = %#v, wanted error", good) + if err := good.ConvertFrom(context.Background(), bad); err == nil { + t.Errorf("ConvertFrom() = %#v, wanted error", good) } } @@ -129,12 +129,12 @@ func TestBrokerConversion(t *testing.T) { for _, version := range versions { t.Run(test.name, func(t *testing.T) { ver := version - if err := test.in.ConvertUp(context.Background(), ver); err != nil { - t.Errorf("ConvertUp() = %v", err) + if err := test.in.ConvertTo(context.Background(), ver); err != nil { + t.Errorf("ConvertTo() = %v", err) } got := &Broker{} - if err := got.ConvertDown(context.Background(), ver); err != nil { - t.Errorf("ConvertDown() = %v", err) + if err := got.ConvertFrom(context.Background(), ver); err != nil { + t.Errorf("ConvertFrom() = %v", err) } // Since on the way down, we lose the DeprecatedSourceAndType, // convert the in to equivalent out. diff --git a/pkg/apis/eventing/v1alpha1/eventtype_conversion.go b/pkg/apis/eventing/v1alpha1/eventtype_conversion.go index 6ef937ecbf3..ac45f268b1f 100644 --- a/pkg/apis/eventing/v1alpha1/eventtype_conversion.go +++ b/pkg/apis/eventing/v1alpha1/eventtype_conversion.go @@ -25,9 +25,9 @@ import ( "knative.dev/pkg/apis" ) -// ConvertUp implements apis.Convertible. +// ConvertTo implements apis.Convertible. // Converts source (from v1alpha1.EventType) into v1beta1.EventType -func (source *EventType) ConvertUp(ctx context.Context, obj apis.Convertible) error { +func (source *EventType) ConvertTo(ctx context.Context, obj apis.Convertible) error { switch sink := obj.(type) { case *v1beta1.EventType: b, err := json.Marshal(source) @@ -41,9 +41,9 @@ func (source *EventType) ConvertUp(ctx context.Context, obj apis.Convertible) er } } -// ConvertDown implements apis.Convertible. +// ConvertFrom implements apis.Convertible. // Converts obj from v1beta1.EventType into v1alpha1.EventType -func (sink *EventType) ConvertDown(ctx context.Context, obj apis.Convertible) error { +func (sink *EventType) ConvertFrom(ctx context.Context, obj apis.Convertible) error { switch source := obj.(type) { case *v1beta1.EventType: b, err := json.Marshal(source) diff --git a/pkg/apis/eventing/v1alpha1/eventtype_conversion_test.go b/pkg/apis/eventing/v1alpha1/eventtype_conversion_test.go index b2a4ea833b8..976f6d16bdd 100644 --- a/pkg/apis/eventing/v1alpha1/eventtype_conversion_test.go +++ b/pkg/apis/eventing/v1alpha1/eventtype_conversion_test.go @@ -30,12 +30,12 @@ import ( func TestEventTypeConversionBadType(t *testing.T) { good, bad := &EventType{}, &dummy{} - if err := good.ConvertUp(context.Background(), bad); err == nil { - t.Errorf("ConvertUp() = %#v, wanted error", bad) + if err := good.ConvertTo(context.Background(), bad); err == nil { + t.Errorf("ConvertTo() = %#v, wanted error", bad) } - if err := good.ConvertDown(context.Background(), bad); err == nil { - t.Errorf("ConvertDown() = %#v, wanted error", good) + if err := good.ConvertFrom(context.Background(), bad); err == nil { + t.Errorf("ConvertFrom() = %#v, wanted error", good) } } @@ -93,12 +93,12 @@ func TestEventTypeConversion(t *testing.T) { for _, version := range versions { t.Run(test.name, func(t *testing.T) { ver := version - if err := test.in.ConvertUp(context.Background(), ver); err != nil { - t.Errorf("ConvertUp() = %v", err) + if err := test.in.ConvertTo(context.Background(), ver); err != nil { + t.Errorf("ConvertTo() = %v", err) } got := &EventType{} - if err := got.ConvertDown(context.Background(), ver); err != nil { - t.Errorf("ConvertDown() = %v", err) + 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) diff --git a/pkg/apis/eventing/v1alpha1/trigger_conversion.go b/pkg/apis/eventing/v1alpha1/trigger_conversion.go index c257c8751b0..fb9c0631809 100644 --- a/pkg/apis/eventing/v1alpha1/trigger_conversion.go +++ b/pkg/apis/eventing/v1alpha1/trigger_conversion.go @@ -24,9 +24,9 @@ import ( "knative.dev/pkg/apis" ) -// ConvertUp implements apis.Convertible. +// ConvertTo implements apis.Convertible. // Converts source (from v1alpha1.Trigger) into v1beta1.Trigger -func (source *Trigger) ConvertUp(ctx context.Context, obj apis.Convertible) error { +func (source *Trigger) ConvertTo(ctx context.Context, obj apis.Convertible) error { switch sink := obj.(type) { case *v1beta1.Trigger: sink.ObjectMeta = source.ObjectMeta @@ -55,9 +55,9 @@ func (source *Trigger) ConvertUp(ctx context.Context, obj apis.Convertible) erro } } -// ConvertDown implements apis.Convertible. +// ConvertFrom implements apis.Convertible. // Converts obj from v1beta1.Trigger into v1alpha1.Trigger -func (sink *Trigger) ConvertDown(ctx context.Context, obj apis.Convertible) error { +func (sink *Trigger) ConvertFrom(ctx context.Context, obj apis.Convertible) error { switch source := obj.(type) { case *v1beta1.Trigger: sink.ObjectMeta = source.ObjectMeta diff --git a/pkg/apis/eventing/v1alpha1/trigger_conversion_test.go b/pkg/apis/eventing/v1alpha1/trigger_conversion_test.go index 2bbe5a766fe..2c48a5523bb 100644 --- a/pkg/apis/eventing/v1alpha1/trigger_conversion_test.go +++ b/pkg/apis/eventing/v1alpha1/trigger_conversion_test.go @@ -32,23 +32,23 @@ import ( // implement apis.Convertible type dummy struct{} -func (*dummy) ConvertUp(ctx context.Context, obj apis.Convertible) error { +func (*dummy) ConvertTo(ctx context.Context, obj apis.Convertible) error { return errors.New("Won't go") } -func (*dummy) ConvertDown(ctx context.Context, obj apis.Convertible) error { +func (*dummy) ConvertFrom(ctx context.Context, obj apis.Convertible) error { return errors.New("Won't go") } func TestTriggerConversionBadType(t *testing.T) { good, bad := &Trigger{}, &dummy{} - if err := good.ConvertUp(context.Background(), bad); err == nil { - t.Errorf("ConvertUp() = %#v, wanted error", bad) + if err := good.ConvertTo(context.Background(), bad); err == nil { + t.Errorf("ConvertTo() = %#v, wanted error", bad) } - if err := good.ConvertDown(context.Background(), bad); err == nil { - t.Errorf("ConvertDown() = %#v, wanted error", good) + if err := good.ConvertFrom(context.Background(), bad); err == nil { + t.Errorf("ConvertFrom() = %#v, wanted error", good) } } @@ -156,12 +156,12 @@ func TestTriggerConversion(t *testing.T) { for _, version := range versions { t.Run(test.name, func(t *testing.T) { ver := version - if err := test.in.ConvertUp(context.Background(), ver); err != nil { - t.Errorf("ConvertUp() = %v", err) + if err := test.in.ConvertTo(context.Background(), ver); err != nil { + t.Errorf("ConvertTo() = %v", err) } got := &Trigger{} - if err := got.ConvertDown(context.Background(), ver); err != nil { - t.Errorf("ConvertDown() = %v", err) + if err := got.ConvertFrom(context.Background(), ver); err != nil { + t.Errorf("ConvertFrom() = %v", err) } // Since on the way down, we lose the DeprecatedSourceAndType, // convert the in to equivalent out. diff --git a/pkg/apis/eventing/v1beta1/broker_conversion.go b/pkg/apis/eventing/v1beta1/broker_conversion.go index dd8f9f6f14e..f0c61ca95c9 100644 --- a/pkg/apis/eventing/v1beta1/broker_conversion.go +++ b/pkg/apis/eventing/v1beta1/broker_conversion.go @@ -23,12 +23,12 @@ import ( "knative.dev/pkg/apis" ) -// ConvertUp implements apis.Convertible -func (source *Broker) ConvertUp(ctx context.Context, sink apis.Convertible) error { +// ConvertTo implements apis.Convertible +func (source *Broker) ConvertTo(ctx context.Context, sink apis.Convertible) error { return fmt.Errorf("v1beta1 is the highest known version, got: %T", sink) } -// ConvertDown implements apis.Convertible -func (sink *Broker) ConvertDown(ctx context.Context, source apis.Convertible) error { +// ConvertFrom implements apis.Convertible +func (sink *Broker) 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/eventing/v1beta1/broker_conversion_test.go b/pkg/apis/eventing/v1beta1/broker_conversion_test.go index e68f350ecac..aeb8b28969e 100644 --- a/pkg/apis/eventing/v1beta1/broker_conversion_test.go +++ b/pkg/apis/eventing/v1beta1/broker_conversion_test.go @@ -24,11 +24,11 @@ import ( func TestBrokerConversionBadType(t *testing.T) { good, bad := &Broker{}, &Broker{} - if err := good.ConvertUp(context.Background(), bad); err == nil { - t.Errorf("ConvertUp() = %#v, wanted error", bad) + if err := good.ConvertTo(context.Background(), bad); err == nil { + t.Errorf("ConvertTo() = %#v, wanted error", bad) } - if err := good.ConvertDown(context.Background(), bad); err == nil { - t.Errorf("ConvertDown() = %#v, wanted error", good) + if err := good.ConvertFrom(context.Background(), bad); err == nil { + t.Errorf("ConvertFrom() = %#v, wanted error", good) } } diff --git a/pkg/apis/eventing/v1beta1/eventtype_conversion.go b/pkg/apis/eventing/v1beta1/eventtype_conversion.go index b60a58500cd..6ef342c8739 100644 --- a/pkg/apis/eventing/v1beta1/eventtype_conversion.go +++ b/pkg/apis/eventing/v1beta1/eventtype_conversion.go @@ -23,12 +23,12 @@ import ( "knative.dev/pkg/apis" ) -// ConvertUp implements apis.Convertible -func (source *EventType) ConvertUp(ctx context.Context, sink apis.Convertible) error { +// ConvertTo implements apis.Convertible +func (source *EventType) ConvertTo(ctx context.Context, sink apis.Convertible) error { return fmt.Errorf("v1beta1 is the highest known version, got: %T", sink) } -// ConvertDown implements apis.Convertible -func (sink *EventType) ConvertDown(ctx context.Context, source apis.Convertible) error { +// ConvertFrom implements apis.Convertible +func (sink *EventType) 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/eventing/v1beta1/eventtype_conversion_test.go b/pkg/apis/eventing/v1beta1/eventtype_conversion_test.go index abd7e215be4..d316610a05a 100644 --- a/pkg/apis/eventing/v1beta1/eventtype_conversion_test.go +++ b/pkg/apis/eventing/v1beta1/eventtype_conversion_test.go @@ -24,11 +24,11 @@ import ( func TestEventTypeConversionBadType(t *testing.T) { good, bad := &EventType{}, &EventType{} - if err := good.ConvertUp(context.Background(), bad); err == nil { - t.Errorf("ConvertUp() = %#v, wanted error", bad) + if err := good.ConvertTo(context.Background(), bad); err == nil { + t.Errorf("ConvertTo() = %#v, wanted error", bad) } - if err := good.ConvertDown(context.Background(), bad); err == nil { - t.Errorf("ConvertDown() = %#v, wanted error", good) + if err := good.ConvertFrom(context.Background(), bad); err == nil { + t.Errorf("ConvertFrom() = %#v, wanted error", good) } } diff --git a/pkg/apis/eventing/v1beta1/trigger_conversion.go b/pkg/apis/eventing/v1beta1/trigger_conversion.go index abe1f59acb7..dc96d461d1e 100644 --- a/pkg/apis/eventing/v1beta1/trigger_conversion.go +++ b/pkg/apis/eventing/v1beta1/trigger_conversion.go @@ -23,12 +23,12 @@ import ( "knative.dev/pkg/apis" ) -// ConvertUp implements apis.Convertible -func (source *Trigger) ConvertUp(ctx context.Context, sink apis.Convertible) error { +// ConvertTo implements apis.Convertible +func (source *Trigger) ConvertTo(ctx context.Context, sink apis.Convertible) error { return fmt.Errorf("v1beta1 is the highest known version, got: %T", sink) } -// ConvertDown implements apis.Convertible -func (sink *Trigger) ConvertDown(ctx context.Context, source apis.Convertible) error { +// ConvertFrom implements apis.Convertible +func (sink *Trigger) 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/eventing/v1beta1/trigger_conversion_test.go b/pkg/apis/eventing/v1beta1/trigger_conversion_test.go index 79b9dc75e54..acb94918207 100644 --- a/pkg/apis/eventing/v1beta1/trigger_conversion_test.go +++ b/pkg/apis/eventing/v1beta1/trigger_conversion_test.go @@ -24,11 +24,11 @@ import ( func TestTriggerConversionBadType(t *testing.T) { good, bad := &Trigger{}, &Trigger{} - if err := good.ConvertUp(context.Background(), bad); err == nil { - t.Errorf("ConvertUp() = %#v, wanted error", bad) + if err := good.ConvertTo(context.Background(), bad); err == nil { + t.Errorf("ConvertTo() = %#v, wanted error", bad) } - if err := good.ConvertDown(context.Background(), bad); err == nil { - t.Errorf("ConvertDown() = %#v, wanted error", good) + if err := good.ConvertFrom(context.Background(), bad); err == nil { + t.Errorf("ConvertFrom() = %#v, wanted error", good) } } diff --git a/pkg/apis/flows/v1alpha1/parallel_conversion.go b/pkg/apis/flows/v1alpha1/parallel_conversion.go index 818186a8aa5..dc73f4e1823 100644 --- a/pkg/apis/flows/v1alpha1/parallel_conversion.go +++ b/pkg/apis/flows/v1alpha1/parallel_conversion.go @@ -25,9 +25,9 @@ import ( "knative.dev/eventing/pkg/apis/flows/v1beta1" ) -// ConvertUp implements apis.Convertible +// ConvertTo implements apis.Convertible // Converts obj from v1alpha1.Parallel into v1beta1.Parallel -func (source *Parallel) ConvertUp(ctx context.Context, obj apis.Convertible) error { +func (source *Parallel) ConvertTo(ctx context.Context, obj apis.Convertible) error { switch sink := obj.(type) { case *v1beta1.Parallel: sink.ObjectMeta = source.ObjectMeta @@ -78,9 +78,9 @@ func (source *Parallel) ConvertUp(ctx context.Context, obj apis.Convertible) err } } -// ConvertDown implements apis.Convertible +// ConvertFrom implements apis.Convertible // Converts obj from v1beta1.Sequence into v1alpha1.Sequence -func (sink *Parallel) ConvertDown(ctx context.Context, obj apis.Convertible) error { +func (sink *Parallel) ConvertFrom(ctx context.Context, obj apis.Convertible) error { switch source := obj.(type) { case *v1beta1.Parallel: sink.ObjectMeta = source.ObjectMeta diff --git a/pkg/apis/flows/v1alpha1/parallel_conversion_test.go b/pkg/apis/flows/v1alpha1/parallel_conversion_test.go index c4497862bea..80fa2fede32 100644 --- a/pkg/apis/flows/v1alpha1/parallel_conversion_test.go +++ b/pkg/apis/flows/v1alpha1/parallel_conversion_test.go @@ -32,12 +32,12 @@ import ( func TestParallelConversionBadType(t *testing.T) { good, bad := &Parallel{}, &Parallel{} - if err := good.ConvertUp(context.Background(), bad); err == nil { - t.Errorf("ConvertUp() = %#v, wanted error", bad) + if err := good.ConvertTo(context.Background(), bad); err == nil { + t.Errorf("ConvertTo() = %#v, wanted error", bad) } - if err := good.ConvertDown(context.Background(), bad); err == nil { - t.Errorf("ConvertDown() = %#v, wanted error", good) + if err := good.ConvertFrom(context.Background(), bad); err == nil { + t.Errorf("ConvertFrom() = %#v, wanted error", good) } } @@ -207,12 +207,12 @@ func TestParallelRoundTripV1alpha1(t *testing.T) { for _, version := range versions { t.Run(test.name, func(t *testing.T) { ver := version - if err := test.in.ConvertUp(context.Background(), ver); err != nil { - t.Errorf("ConvertUp() = %v", err) + if err := test.in.ConvertTo(context.Background(), ver); err != nil { + t.Errorf("ConvertTo() = %v", err) } got := &Parallel{} - if err := got.ConvertDown(context.Background(), ver); err != nil { - t.Errorf("ConvertDown() = %v", err) + if err := got.ConvertFrom(context.Background(), ver); err != nil { + t.Errorf("ConvertFrom() = %v", err) } if diff := cmp.Diff(test.in, got); diff != "" { @@ -389,12 +389,12 @@ func TestParallelRoundTripV1beta1(t *testing.T) { for _, version := range versions { t.Run(test.name, func(t *testing.T) { ver := version - if err := ver.ConvertDown(context.Background(), test.in); err != nil { - t.Errorf("ConvertDown() = %v", err) + if err := ver.ConvertFrom(context.Background(), test.in); err != nil { + t.Errorf("ConvertFrom() = %v", err) } got := &v1beta1.Parallel{} - if err := ver.ConvertUp(context.Background(), got); err != nil { - t.Errorf("ConvertUp() = %v", err) + if err := ver.ConvertTo(context.Background(), got); err != nil { + t.Errorf("ConvertTo() = %v", err) } if diff := cmp.Diff(test.in, got); diff != "" { diff --git a/pkg/apis/flows/v1alpha1/parallel_lifecycle.go b/pkg/apis/flows/v1alpha1/parallel_lifecycle.go index 064151f5896..be382531aea 100644 --- a/pkg/apis/flows/v1alpha1/parallel_lifecycle.go +++ b/pkg/apis/flows/v1alpha1/parallel_lifecycle.go @@ -198,11 +198,11 @@ func (ps *ParallelStatus) setAddress(address *pkgduckv1alpha1.Addressable) { } if address.URL != nil || address.Hostname != "" { // But, first, convert it to V1, since Channel Status - // is using v1alpha1 Address. Note that ConvertUp does + // is using v1alpha1 Address. Note that ConvertTo does // not do anything with the passed in Context, so // just make one up here. v1Address := pkgduckv1.Addressable{} - if err := address.ConvertUp(context.TODO(), &v1Address); err != nil { + if err := address.ConvertTo(context.TODO(), &v1Address); err != nil { pCondSet.Manage(ps).MarkFalse(SequenceConditionAddressable, "emptyAddress", "unable to convert channel address up to v1") return } diff --git a/pkg/apis/flows/v1alpha1/sequence_conversion.go b/pkg/apis/flows/v1alpha1/sequence_conversion.go index 253c42c72c0..fe139f91bf3 100644 --- a/pkg/apis/flows/v1alpha1/sequence_conversion.go +++ b/pkg/apis/flows/v1alpha1/sequence_conversion.go @@ -25,9 +25,9 @@ import ( "knative.dev/eventing/pkg/apis/flows/v1beta1" ) -// ConvertUp implements apis.Convertible +// ConvertTo implements apis.Convertible // Converts obj from v1alpha1.Sequence into v1beta1.Sequence -func (source *Sequence) ConvertUp(ctx context.Context, obj apis.Convertible) error { +func (source *Sequence) ConvertTo(ctx context.Context, obj apis.Convertible) error { switch sink := obj.(type) { case *v1beta1.Sequence: sink.ObjectMeta = source.ObjectMeta @@ -72,9 +72,9 @@ func (source *Sequence) ConvertUp(ctx context.Context, obj apis.Convertible) err } } -// ConvertDown implements apis.Convertible +// ConvertFrom implements apis.Convertible // Converts obj from v1beta1.Sequence into v1alpha1.Sequence -func (sink *Sequence) ConvertDown(ctx context.Context, obj apis.Convertible) error { +func (sink *Sequence) ConvertFrom(ctx context.Context, obj apis.Convertible) error { switch source := obj.(type) { case *v1beta1.Sequence: sink.ObjectMeta = source.ObjectMeta diff --git a/pkg/apis/flows/v1alpha1/sequence_conversion_test.go b/pkg/apis/flows/v1alpha1/sequence_conversion_test.go index 7c2ca7b7de9..1e26572efce 100644 --- a/pkg/apis/flows/v1alpha1/sequence_conversion_test.go +++ b/pkg/apis/flows/v1alpha1/sequence_conversion_test.go @@ -35,12 +35,12 @@ import ( func TestSequenceConversionBadType(t *testing.T) { good, bad := &Sequence{}, &Sequence{} - if err := good.ConvertUp(context.Background(), bad); err == nil { - t.Errorf("ConvertUp() = %#v, wanted error", bad) + if err := good.ConvertTo(context.Background(), bad); err == nil { + t.Errorf("ConvertTo() = %#v, wanted error", bad) } - if err := good.ConvertDown(context.Background(), bad); err == nil { - t.Errorf("ConvertDown() = %#v, wanted error", good) + if err := good.ConvertFrom(context.Background(), bad); err == nil { + t.Errorf("ConvertFrom() = %#v, wanted error", good) } } @@ -201,12 +201,12 @@ func TestSequenceRoundTripV1alpha1(t *testing.T) { for _, version := range versions { t.Run(test.name, func(t *testing.T) { ver := version - if err := test.in.ConvertUp(context.Background(), ver); err != nil { - t.Errorf("ConvertUp() = %v", err) + if err := test.in.ConvertTo(context.Background(), ver); err != nil { + t.Errorf("ConvertTo() = %v", err) } got := &Sequence{} - if err := got.ConvertDown(context.Background(), ver); err != nil { - t.Errorf("ConvertDown() = %v", err) + if err := got.ConvertFrom(context.Background(), ver); err != nil { + t.Errorf("ConvertFrom() = %v", err) } if diff := cmp.Diff(test.in, got); diff != "" { @@ -374,12 +374,12 @@ func TestSequenceRoundTripV1beta1(t *testing.T) { for _, version := range versions { t.Run(test.name, func(t *testing.T) { ver := version - if err := ver.ConvertDown(context.Background(), test.in); err != nil { - t.Errorf("ConvertDown() = %v", err) + if err := ver.ConvertFrom(context.Background(), test.in); err != nil { + t.Errorf("ConvertFrom() = %v", err) } got := &v1beta1.Sequence{} - if err := ver.ConvertUp(context.Background(), got); err != nil { - t.Errorf("ConvertDown() = %v", err) + if err := ver.ConvertTo(context.Background(), got); err != nil { + t.Errorf("ConvertFrom() = %v", err) } if diff := cmp.Diff(test.in, got); diff != "" { diff --git a/pkg/apis/flows/v1alpha1/sequence_lifecycle.go b/pkg/apis/flows/v1alpha1/sequence_lifecycle.go index 015a7ecaa8d..8773bbcf589 100644 --- a/pkg/apis/flows/v1alpha1/sequence_lifecycle.go +++ b/pkg/apis/flows/v1alpha1/sequence_lifecycle.go @@ -160,11 +160,11 @@ func (ss *SequenceStatus) setAddress(address *pkgduckv1alpha1.Addressable) { if address.URL != nil || address.Hostname != "" { // But, first, convert it to V1, since Channel Status - // is using v1alpha1 Address. Note that ConvertUp does + // is using v1alpha1 Address. Note that ConvertTo does // not do anything with the passed in Context, so // just make one up here. v1Address := pkgduckv1.Addressable{} - if err := address.ConvertUp(context.TODO(), &v1Address); err != nil { + if err := address.ConvertTo(context.TODO(), &v1Address); err != nil { pCondSet.Manage(ss).MarkFalse(SequenceConditionAddressable, "emptyAddress", "unable to convert channel address up to v1") return } diff --git a/pkg/apis/flows/v1beta1/parallel_conversion.go b/pkg/apis/flows/v1beta1/parallel_conversion.go index 3f5238e0897..4324ba79b2c 100644 --- a/pkg/apis/flows/v1beta1/parallel_conversion.go +++ b/pkg/apis/flows/v1beta1/parallel_conversion.go @@ -23,12 +23,12 @@ import ( "knative.dev/pkg/apis" ) -// ConvertUp implements apis.Convertible -func (source *Parallel) ConvertUp(ctx context.Context, sink apis.Convertible) error { +// ConvertTo implements apis.Convertible +func (source *Parallel) ConvertTo(ctx context.Context, sink apis.Convertible) error { return fmt.Errorf("v1beta1 is the highest known version, got: %T", sink) } -// ConvertDown implements apis.Convertible -func (sink *Parallel) ConvertDown(ctx context.Context, source apis.Convertible) error { +// ConvertFrom implements apis.Convertible +func (sink *Parallel) 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/flows/v1beta1/parallel_conversion_test.go b/pkg/apis/flows/v1beta1/parallel_conversion_test.go index fcac77681ec..5063422aaed 100644 --- a/pkg/apis/flows/v1beta1/parallel_conversion_test.go +++ b/pkg/apis/flows/v1beta1/parallel_conversion_test.go @@ -24,11 +24,11 @@ import ( func TestParallelConversionBadType(t *testing.T) { good, bad := &Parallel{}, &Parallel{} - if err := good.ConvertUp(context.Background(), bad); err == nil { - t.Errorf("ConvertUp() = %#v, wanted error", bad) + if err := good.ConvertTo(context.Background(), bad); err == nil { + t.Errorf("ConvertTo() = %#v, wanted error", bad) } - if err := good.ConvertDown(context.Background(), bad); err == nil { - t.Errorf("ConvertDown() = %#v, wanted error", good) + if err := good.ConvertFrom(context.Background(), bad); err == nil { + t.Errorf("ConvertFrom() = %#v, wanted error", good) } } diff --git a/pkg/apis/flows/v1beta1/sequence_conversion.go b/pkg/apis/flows/v1beta1/sequence_conversion.go index 189c45d7c6c..8e9aad9a515 100644 --- a/pkg/apis/flows/v1beta1/sequence_conversion.go +++ b/pkg/apis/flows/v1beta1/sequence_conversion.go @@ -23,12 +23,12 @@ import ( "knative.dev/pkg/apis" ) -// ConvertUp implements apis.Convertible -func (source *Sequence) ConvertUp(ctx context.Context, sink apis.Convertible) error { +// ConvertTo implements apis.Convertible +func (source *Sequence) ConvertTo(ctx context.Context, sink apis.Convertible) error { return fmt.Errorf("v1beta1 is the highest known version, got: %T", sink) } -// ConvertDown implements apis.Convertible -func (sink *Sequence) ConvertDown(ctx context.Context, source apis.Convertible) error { +// ConvertFrom implements apis.Convertible +func (sink *Sequence) 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/flows/v1beta1/sequence_conversion_test.go b/pkg/apis/flows/v1beta1/sequence_conversion_test.go index 9719ca54d5b..1e600bc4180 100644 --- a/pkg/apis/flows/v1beta1/sequence_conversion_test.go +++ b/pkg/apis/flows/v1beta1/sequence_conversion_test.go @@ -24,11 +24,11 @@ import ( func TestSequenceConversionBadType(t *testing.T) { good, bad := &Sequence{}, &Sequence{} - if err := good.ConvertUp(context.Background(), bad); err == nil { - t.Errorf("ConvertUp() = %#v, wanted error", bad) + if err := good.ConvertTo(context.Background(), bad); err == nil { + t.Errorf("ConvertTo() = %#v, wanted error", bad) } - if err := good.ConvertDown(context.Background(), bad); err == nil { - t.Errorf("ConvertDown() = %#v, wanted error", good) + if err := good.ConvertFrom(context.Background(), bad); err == nil { + t.Errorf("ConvertFrom() = %#v, wanted error", good) } } diff --git a/pkg/apis/messaging/v1alpha1/channel_conversion.go b/pkg/apis/messaging/v1alpha1/channel_conversion.go index 2bb9f179a4f..13e1d41b386 100644 --- a/pkg/apis/messaging/v1alpha1/channel_conversion.go +++ b/pkg/apis/messaging/v1alpha1/channel_conversion.go @@ -30,21 +30,21 @@ import ( pkgduckv1alpha1 "knative.dev/pkg/apis/duck/v1alpha1" ) -// ConvertUp implements apis.Convertible +// ConvertTo implements apis.Convertible // Converts source (from v1alpha1.Channel) into v1beta1.Channel -func (source *Channel) ConvertUp(ctx context.Context, obj apis.Convertible) error { +func (source *Channel) ConvertTo(ctx context.Context, obj apis.Convertible) error { switch sink := obj.(type) { case *v1beta1.Channel: sink.ObjectMeta = source.ObjectMeta - source.Status.ConvertUp(ctx, &sink.Status) - return source.Spec.ConvertUp(ctx, &sink.Spec) + source.Status.ConvertTo(ctx, &sink.Status) + return source.Spec.ConvertTo(ctx, &sink.Spec) default: return fmt.Errorf("unknown version, got: %T", sink) } } -// ConvertUp helps implement apis.Convertible -func (source *ChannelSpec) ConvertUp(ctx context.Context, sink *v1beta1.ChannelSpec) error { +// ConvertTo helps implement apis.Convertible +func (source *ChannelSpec) ConvertTo(ctx context.Context, sink *v1beta1.ChannelSpec) error { sink.ChannelTemplate = source.ChannelTemplate sink.ChannelableSpec.Delivery = source.Delivery if source.Subscribable != nil { @@ -73,12 +73,12 @@ func (source *ChannelSpec) ConvertUp(ctx context.Context, sink *v1beta1.ChannelS return nil } -// ConvertUp helps implement apis.Convertible -func (source *ChannelStatus) ConvertUp(ctx context.Context, sink *v1beta1.ChannelStatus) { +// ConvertTo helps implement apis.Convertible +func (source *ChannelStatus) ConvertTo(ctx context.Context, sink *v1beta1.ChannelStatus) { source.Status.ConvertTo(ctx, &sink.Status) if source.AddressStatus.Address != nil { sink.AddressStatus.Address = &duckv1.Addressable{} - source.AddressStatus.Address.ConvertUp(ctx, sink.AddressStatus.Address) + source.AddressStatus.Address.ConvertTo(ctx, sink.AddressStatus.Address) } if source.SubscribableTypeStatus.SubscribableStatus != nil && len(source.SubscribableTypeStatus.SubscribableStatus.Subscribers) > 0 { @@ -102,22 +102,22 @@ func (source *ChannelStatus) ConvertUp(ctx context.Context, sink *v1beta1.Channe } } -// ConvertDown implements apis.Convertible. +// ConvertFrom implements apis.Convertible. // Converts obj v1beta1.Channel into v1alpha1.Channel -func (sink *Channel) ConvertDown(ctx context.Context, obj apis.Convertible) error { +func (sink *Channel) ConvertFrom(ctx context.Context, obj apis.Convertible) error { switch source := obj.(type) { case *v1beta1.Channel: sink.ObjectMeta = source.ObjectMeta - sink.Status.ConvertDown(ctx, source.Status) - sink.Spec.ConvertDown(ctx, source.Spec) + sink.Status.ConvertFrom(ctx, source.Status) + sink.Spec.ConvertFrom(ctx, source.Spec) return nil default: return fmt.Errorf("unknown version, got: %T", source) } } -// ConvertDown helps implement apis.Convertible -func (sink *ChannelSpec) ConvertDown(ctx context.Context, source v1beta1.ChannelSpec) { +// ConvertFrom helps implement apis.Convertible +func (sink *ChannelSpec) ConvertFrom(ctx context.Context, source v1beta1.ChannelSpec) { sink.ChannelTemplate = source.ChannelTemplate sink.Delivery = source.ChannelableSpec.Delivery if len(source.ChannelableSpec.Subscribers) > 0 { @@ -136,12 +136,12 @@ func (sink *ChannelSpec) ConvertDown(ctx context.Context, source v1beta1.Channel } } -// ConvertDown helps implement apis.Convertible -func (sink *ChannelStatus) ConvertDown(ctx context.Context, source v1beta1.ChannelStatus) error { +// ConvertFrom helps implement apis.Convertible +func (sink *ChannelStatus) ConvertFrom(ctx context.Context, source v1beta1.ChannelStatus) error { source.Status.ConvertTo(ctx, &sink.Status) if source.AddressStatus.Address != nil { sink.AddressStatus.Address = &pkgduckv1alpha1.Addressable{} - if err := sink.AddressStatus.Address.ConvertDown(ctx, source.AddressStatus.Address); err != nil { + if err := sink.AddressStatus.Address.ConvertFrom(ctx, source.AddressStatus.Address); err != nil { return err } } diff --git a/pkg/apis/messaging/v1alpha1/channel_conversion_test.go b/pkg/apis/messaging/v1alpha1/channel_conversion_test.go index 3992173c9fa..39801d50840 100644 --- a/pkg/apis/messaging/v1alpha1/channel_conversion_test.go +++ b/pkg/apis/messaging/v1alpha1/channel_conversion_test.go @@ -36,12 +36,12 @@ import ( func TestChannelConversionBadType(t *testing.T) { good, bad := &Channel{}, &Subscription{} - if err := good.ConvertUp(context.Background(), bad); err == nil { - t.Errorf("ConvertUp() = %#v, wanted error", bad) + if err := good.ConvertTo(context.Background(), bad); err == nil { + t.Errorf("ConvertTo() = %#v, wanted error", bad) } - if err := good.ConvertDown(context.Background(), bad); err == nil { - t.Errorf("ConvertDown() = %#v, wanted error", good) + if err := good.ConvertFrom(context.Background(), bad); err == nil { + t.Errorf("ConvertFrom() = %#v, wanted error", good) } } @@ -166,12 +166,12 @@ func TestChannelConversion(t *testing.T) { for _, version := range versions { t.Run(test.name, func(t *testing.T) { ver := version - if err := test.in.ConvertUp(context.Background(), ver); err != nil { - t.Errorf("ConvertUp() = %v", err) + if err := test.in.ConvertTo(context.Background(), ver); err != nil { + t.Errorf("ConvertTo() = %v", err) } got := &Channel{} - if err := got.ConvertDown(context.Background(), ver); err != nil { - t.Errorf("ConvertDown() = %v", err) + 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) @@ -304,12 +304,12 @@ func TestChannelConversionWithV1Beta1(t *testing.T) { for _, version := range versions { t.Run(test.name, func(t *testing.T) { ver := version - if err := version.ConvertDown(context.Background(), test.in); err != nil { - t.Errorf("ConvertUp() = %v", err) + if err := version.ConvertFrom(context.Background(), test.in); err != nil { + t.Errorf("ConvertTo() = %v", err) } got := &v1beta1.Channel{} - if err := ver.ConvertUp(context.Background(), got); err != nil { - t.Errorf("ConvertDown() = %v", err) + if err := ver.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) diff --git a/pkg/apis/messaging/v1alpha1/in_memory_channel_conversion.go b/pkg/apis/messaging/v1alpha1/in_memory_channel_conversion.go index 4df3543e10d..d0b3e0b6ad0 100644 --- a/pkg/apis/messaging/v1alpha1/in_memory_channel_conversion.go +++ b/pkg/apis/messaging/v1alpha1/in_memory_channel_conversion.go @@ -29,21 +29,21 @@ import ( pkgduckv1alpha1 "knative.dev/pkg/apis/duck/v1alpha1" ) -// ConvertUp implements apis.Convertible +// ConvertTo implements apis.Convertible // Converts source (from v1alpha1.InMemoryChannel) into v1beta1.InMemoryChannel -func (source *InMemoryChannel) ConvertUp(ctx context.Context, obj apis.Convertible) error { +func (source *InMemoryChannel) ConvertTo(ctx context.Context, obj apis.Convertible) error { switch sink := obj.(type) { case *v1beta1.InMemoryChannel: sink.ObjectMeta = source.ObjectMeta - source.Status.ConvertUp(ctx, &sink.Status) - return source.Spec.ConvertUp(ctx, &sink.Spec) + source.Status.ConvertTo(ctx, &sink.Status) + return source.Spec.ConvertTo(ctx, &sink.Spec) default: return fmt.Errorf("unknown version, got: %T", sink) } } -// ConvertUp helps implement apis.Convertible -func (source *InMemoryChannelSpec) ConvertUp(ctx context.Context, sink *v1beta1.InMemoryChannelSpec) error { +// ConvertTo helps implement apis.Convertible +func (source *InMemoryChannelSpec) ConvertTo(ctx context.Context, sink *v1beta1.InMemoryChannelSpec) error { sink.Delivery = source.Delivery if source.Subscribable != nil { sink.Subscribers = make([]duckv1beta1.SubscriberSpec, len(source.Subscribable.Subscribers)) @@ -71,12 +71,12 @@ func (source *InMemoryChannelSpec) ConvertUp(ctx context.Context, sink *v1beta1. return nil } -// ConvertUp helps implement apis.Convertible -func (source *InMemoryChannelStatus) ConvertUp(ctx context.Context, sink *v1beta1.InMemoryChannelStatus) { +// ConvertTo helps implement apis.Convertible +func (source *InMemoryChannelStatus) ConvertTo(ctx context.Context, sink *v1beta1.InMemoryChannelStatus) { source.Status.ConvertTo(ctx, &sink.Status) if source.AddressStatus.Address != nil { sink.AddressStatus.Address = &duckv1.Addressable{} - source.AddressStatus.Address.ConvertUp(ctx, sink.AddressStatus.Address) + source.AddressStatus.Address.ConvertTo(ctx, sink.AddressStatus.Address) } if source.SubscribableTypeStatus.SubscribableStatus != nil && len(source.SubscribableTypeStatus.SubscribableStatus.Subscribers) > 0 { @@ -92,22 +92,22 @@ func (source *InMemoryChannelStatus) ConvertUp(ctx context.Context, sink *v1beta } } -// ConvertDown implements apis.Convertible. +// ConvertFrom implements apis.Convertible. // Converts obj v1beta1.InMemoryChannel into v1alpha1.InMemoryChannel -func (sink *InMemoryChannel) ConvertDown(ctx context.Context, obj apis.Convertible) error { +func (sink *InMemoryChannel) ConvertFrom(ctx context.Context, obj apis.Convertible) error { switch source := obj.(type) { case *v1beta1.InMemoryChannel: sink.ObjectMeta = source.ObjectMeta - sink.Status.ConvertDown(ctx, source.Status) - sink.Spec.ConvertDown(ctx, source.Spec) + sink.Status.ConvertFrom(ctx, source.Status) + sink.Spec.ConvertFrom(ctx, source.Spec) return nil default: return fmt.Errorf("unknown version, got: %T", source) } } -// ConvertDown helps implement apis.Convertible -func (sink *InMemoryChannelSpec) ConvertDown(ctx context.Context, source v1beta1.InMemoryChannelSpec) { +// ConvertFrom helps implement apis.Convertible +func (sink *InMemoryChannelSpec) ConvertFrom(ctx context.Context, source v1beta1.InMemoryChannelSpec) { sink.Delivery = source.Delivery if len(source.Subscribers) > 0 { sink.Subscribable = &eventingduck.Subscribable{ @@ -125,12 +125,12 @@ func (sink *InMemoryChannelSpec) ConvertDown(ctx context.Context, source v1beta1 } } -// ConvertDown helps implement apis.Convertible -func (sink *InMemoryChannelStatus) ConvertDown(ctx context.Context, source v1beta1.InMemoryChannelStatus) error { +// ConvertFrom helps implement apis.Convertible +func (sink *InMemoryChannelStatus) ConvertFrom(ctx context.Context, source v1beta1.InMemoryChannelStatus) error { source.Status.ConvertTo(ctx, &sink.Status) if source.AddressStatus.Address != nil { sink.AddressStatus.Address = &pkgduckv1alpha1.Addressable{} - if err := sink.AddressStatus.Address.ConvertDown(ctx, source.AddressStatus.Address); err != nil { + if err := sink.AddressStatus.Address.ConvertFrom(ctx, source.AddressStatus.Address); err != nil { return err } } diff --git a/pkg/apis/messaging/v1alpha1/in_memory_channel_conversion_test.go b/pkg/apis/messaging/v1alpha1/in_memory_channel_conversion_test.go index a98c5d3b3b6..13ba9feace6 100644 --- a/pkg/apis/messaging/v1alpha1/in_memory_channel_conversion_test.go +++ b/pkg/apis/messaging/v1alpha1/in_memory_channel_conversion_test.go @@ -36,12 +36,12 @@ import ( func TestInMemoryChannelConversionBadType(t *testing.T) { good, bad := &InMemoryChannel{}, &Subscription{} - if err := good.ConvertUp(context.Background(), bad); err == nil { - t.Errorf("ConvertUp() = %#v, wanted error", bad) + if err := good.ConvertTo(context.Background(), bad); err == nil { + t.Errorf("ConvertTo() = %#v, wanted error", bad) } - if err := good.ConvertDown(context.Background(), bad); err == nil { - t.Errorf("ConvertDown() = %#v, wanted error", good) + if err := good.ConvertFrom(context.Background(), bad); err == nil { + t.Errorf("ConvertFrom() = %#v, wanted error", good) } } @@ -153,12 +153,12 @@ func TestInMemoryChannelConversion(t *testing.T) { for _, version := range versions { t.Run(test.name, func(t *testing.T) { ver := version - if err := test.in.ConvertUp(context.Background(), ver); err != nil { - t.Errorf("ConvertUp() = %v", err) + if err := test.in.ConvertTo(context.Background(), ver); err != nil { + t.Errorf("ConvertTo() = %v", err) } got := &InMemoryChannel{} - if err := got.ConvertDown(context.Background(), ver); err != nil { - t.Errorf("ConvertDown() = %v", err) + 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) @@ -278,12 +278,12 @@ func TestInMemoryChannelConversionWithV1Beta1(t *testing.T) { for _, version := range versions { t.Run(test.name, func(t *testing.T) { ver := version - if err := version.ConvertDown(context.Background(), test.in); err != nil { - t.Errorf("ConvertUp() = %v", err) + if err := version.ConvertFrom(context.Background(), test.in); err != nil { + t.Errorf("ConvertTo() = %v", err) } got := &v1beta1.InMemoryChannel{} - if err := ver.ConvertUp(context.Background(), got); err != nil { - t.Errorf("ConvertDown() = %v", err) + if err := ver.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) diff --git a/pkg/apis/messaging/v1alpha1/subscription_conversion.go b/pkg/apis/messaging/v1alpha1/subscription_conversion.go index 62bda66fb59..e54e6123494 100644 --- a/pkg/apis/messaging/v1alpha1/subscription_conversion.go +++ b/pkg/apis/messaging/v1alpha1/subscription_conversion.go @@ -24,9 +24,9 @@ import ( "knative.dev/pkg/apis" ) -// ConvertUp implements apis.Convertible. +// ConvertTo implements apis.Convertible. // Converts source (from v1alpha1.Subscription) into v1beta1.Subscription -func (source *Subscription) ConvertUp(ctx context.Context, obj apis.Convertible) error { +func (source *Subscription) ConvertTo(ctx context.Context, obj apis.Convertible) error { switch sink := obj.(type) { case *v1beta1.Subscription: sink.ObjectMeta = source.ObjectMeta @@ -46,9 +46,9 @@ func (source *Subscription) ConvertUp(ctx context.Context, obj apis.Convertible) } } -// ConvertDown implements apis.Convertible. +// ConvertFrom implements apis.Convertible. // Converts obj from v1beta1.Subscription into v1alpha1.Subscription -func (sink *Subscription) ConvertDown(ctx context.Context, obj apis.Convertible) error { +func (sink *Subscription) ConvertFrom(ctx context.Context, obj apis.Convertible) error { switch source := obj.(type) { case *v1beta1.Subscription: sink.ObjectMeta = source.ObjectMeta diff --git a/pkg/apis/messaging/v1alpha1/subscription_conversion_test.go b/pkg/apis/messaging/v1alpha1/subscription_conversion_test.go index bc20bb55594..eae08d49556 100644 --- a/pkg/apis/messaging/v1alpha1/subscription_conversion_test.go +++ b/pkg/apis/messaging/v1alpha1/subscription_conversion_test.go @@ -33,12 +33,12 @@ import ( func TestSubscriptionConversionBadType(t *testing.T) { good, bad := &Subscription{}, &Channel{} - if err := good.ConvertUp(context.Background(), bad); err == nil { - t.Errorf("ConvertUp() = %#v, wanted error", bad) + if err := good.ConvertTo(context.Background(), bad); err == nil { + t.Errorf("ConvertTo() = %#v, wanted error", bad) } - if err := good.ConvertDown(context.Background(), bad); err == nil { - t.Errorf("ConvertDown() = %#v, wanted error", good) + if err := good.ConvertFrom(context.Background(), bad); err == nil { + t.Errorf("ConvertFrom() = %#v, wanted error", good) } } @@ -111,12 +111,12 @@ func TestSubscriptionConversion(t *testing.T) { for _, version := range versions { t.Run(test.name, func(t *testing.T) { ver := version - if err := test.in.ConvertUp(context.Background(), ver); err != nil { - t.Errorf("ConvertUp() = %v", err) + if err := test.in.ConvertTo(context.Background(), ver); err != nil { + t.Errorf("ConvertTo() = %v", err) } got := &Subscription{} - if err := got.ConvertDown(context.Background(), ver); err != nil { - t.Errorf("ConvertDown() = %v", err) + 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) diff --git a/pkg/apis/messaging/v1beta1/channel_conversion.go b/pkg/apis/messaging/v1beta1/channel_conversion.go index f88ad8aa171..de642bd8738 100644 --- a/pkg/apis/messaging/v1beta1/channel_conversion.go +++ b/pkg/apis/messaging/v1beta1/channel_conversion.go @@ -23,12 +23,12 @@ import ( "knative.dev/pkg/apis" ) -// ConvertUp implements apis.Convertible -func (source *Channel) ConvertUp(ctx context.Context, sink apis.Convertible) error { +// ConvertTo implements apis.Convertible +func (source *Channel) ConvertTo(ctx context.Context, sink apis.Convertible) error { return fmt.Errorf("v1beta1 is the highest known version, got: %T", sink) } -// ConvertDown implements apis.Convertible -func (sink *Channel) ConvertDown(ctx context.Context, source apis.Convertible) error { +// ConvertFrom implements apis.Convertible +func (sink *Channel) 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/messaging/v1beta1/channel_conversion_test.go b/pkg/apis/messaging/v1beta1/channel_conversion_test.go index b98a63c5cff..c38d4f048fa 100644 --- a/pkg/apis/messaging/v1beta1/channel_conversion_test.go +++ b/pkg/apis/messaging/v1beta1/channel_conversion_test.go @@ -24,11 +24,11 @@ import ( func TestChannelConversionBadType(t *testing.T) { good, bad := &Channel{}, &Channel{} - if err := good.ConvertUp(context.Background(), bad); err == nil { - t.Errorf("ConvertUp() = %#v, wanted error", bad) + if err := good.ConvertTo(context.Background(), bad); err == nil { + t.Errorf("ConvertTo() = %#v, wanted error", bad) } - if err := good.ConvertDown(context.Background(), bad); err == nil { - t.Errorf("ConvertDown() = %#v, wanted error", good) + if err := good.ConvertFrom(context.Background(), bad); err == nil { + t.Errorf("ConvertFrom() = %#v, wanted error", good) } } diff --git a/pkg/apis/messaging/v1beta1/in_memory_channel_conversion.go b/pkg/apis/messaging/v1beta1/in_memory_channel_conversion.go index 6f2182f26ca..a9d8e3f2737 100644 --- a/pkg/apis/messaging/v1beta1/in_memory_channel_conversion.go +++ b/pkg/apis/messaging/v1beta1/in_memory_channel_conversion.go @@ -23,12 +23,12 @@ import ( "knative.dev/pkg/apis" ) -// ConvertUp implements apis.Convertible -func (source *InMemoryChannel) ConvertUp(ctx context.Context, sink apis.Convertible) error { +// ConvertTo implements apis.Convertible +func (source *InMemoryChannel) ConvertTo(ctx context.Context, sink apis.Convertible) error { return fmt.Errorf("v1beta1 is the highest known version, got: %T", sink) } -// ConvertDown implements apis.Convertible -func (sink *InMemoryChannel) ConvertDown(ctx context.Context, source apis.Convertible) error { +// ConvertFrom implements apis.Convertible +func (sink *InMemoryChannel) 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/messaging/v1beta1/in_memory_channel_conversion_test.go b/pkg/apis/messaging/v1beta1/in_memory_channel_conversion_test.go index d67fa200eec..0ea99b69081 100644 --- a/pkg/apis/messaging/v1beta1/in_memory_channel_conversion_test.go +++ b/pkg/apis/messaging/v1beta1/in_memory_channel_conversion_test.go @@ -24,11 +24,11 @@ import ( func TestInMemoryChannelConversionBadType(t *testing.T) { good, bad := &InMemoryChannel{}, &InMemoryChannel{} - if err := good.ConvertUp(context.Background(), bad); err == nil { - t.Errorf("ConvertUp() = %#v, wanted error", bad) + if err := good.ConvertTo(context.Background(), bad); err == nil { + t.Errorf("ConvertTo() = %#v, wanted error", bad) } - if err := good.ConvertDown(context.Background(), bad); err == nil { - t.Errorf("ConvertDown() = %#v, wanted error", good) + if err := good.ConvertFrom(context.Background(), bad); err == nil { + t.Errorf("ConvertFrom() = %#v, wanted error", good) } } diff --git a/pkg/apis/messaging/v1beta1/subscription_conversion.go b/pkg/apis/messaging/v1beta1/subscription_conversion.go index 915d3ee111e..568bf41b56b 100644 --- a/pkg/apis/messaging/v1beta1/subscription_conversion.go +++ b/pkg/apis/messaging/v1beta1/subscription_conversion.go @@ -23,12 +23,12 @@ import ( "knative.dev/pkg/apis" ) -// ConvertUp implements apis.Convertible -func (source *Subscription) ConvertUp(ctx context.Context, sink apis.Convertible) error { +// ConvertTo implements apis.Convertible +func (source *Subscription) ConvertTo(ctx context.Context, sink apis.Convertible) error { return fmt.Errorf("v1beta1 is the highest known version, got: %T", sink) } -// ConvertDown implements apis.Convertible -func (sink *Subscription) ConvertDown(ctx context.Context, source apis.Convertible) error { +// ConvertFrom implements apis.Convertible +func (sink *Subscription) 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/messaging/v1beta1/subscription_conversion_test.go b/pkg/apis/messaging/v1beta1/subscription_conversion_test.go index d733ff2a527..5205e9a2223 100644 --- a/pkg/apis/messaging/v1beta1/subscription_conversion_test.go +++ b/pkg/apis/messaging/v1beta1/subscription_conversion_test.go @@ -24,11 +24,11 @@ import ( func TestSubscriptionConversionBadType(t *testing.T) { good, bad := &Subscription{}, &Subscription{} - if err := good.ConvertUp(context.Background(), bad); err == nil { - t.Errorf("ConvertUp() = %#v, wanted error", bad) + if err := good.ConvertTo(context.Background(), bad); err == nil { + t.Errorf("ConvertTo() = %#v, wanted error", bad) } - if err := good.ConvertDown(context.Background(), bad); err == nil { - t.Errorf("ConvertDown() = %#v, wanted error", good) + if err := good.ConvertFrom(context.Background(), bad); err == nil { + t.Errorf("ConvertFrom() = %#v, wanted error", good) } }