diff --git a/Gopkg.lock b/Gopkg.lock index bd5c296d8fdb..1a2e8d2564a7 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -1810,7 +1810,7 @@ [[projects]] branch = "master" - digest = "1:2f22005f6915f0dd6bc45479507601547a369ed1da0982ed454a76207894e876" + digest = "1:efd99f16d7b5337b1cce9ac8576e2f65c2c2f7b759f64cd235b82f42e0f86f09" name = "knative.dev/pkg" packages = [ "apis", @@ -1917,7 +1917,7 @@ "websocket", ] pruneopts = "T" - revision = "5bc49f27e690d0c30bdd079e473d5419998b3259" + revision = "d771641c9192ee2ce1e54c3d9af2cc7f692cb7ab" [[projects]] branch = "master" diff --git a/cmd/webhook/main.go b/cmd/webhook/main.go index 4025a96d6ea8..8a5adbf04d6a 100644 --- a/cmd/webhook/main.go +++ b/cmd/webhook/main.go @@ -205,7 +205,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/serving/v1/configuration_conversion.go b/pkg/apis/serving/v1/configuration_conversion.go index 05d012ce5554..ff3d1644cb5e 100644 --- a/pkg/apis/serving/v1/configuration_conversion.go +++ b/pkg/apis/serving/v1/configuration_conversion.go @@ -23,12 +23,12 @@ import ( "knative.dev/pkg/apis" ) -// ConvertUp implements apis.Convertible -func (source *Configuration) ConvertUp(ctx context.Context, sink apis.Convertible) error { +// ConvertTo implements apis.Convertible +func (source *Configuration) ConvertTo(ctx context.Context, sink apis.Convertible) error { return fmt.Errorf("v1 is the highest known version, got: %T", sink) } -// ConvertDown implements apis.Convertible -func (sink *Configuration) ConvertDown(ctx context.Context, source apis.Convertible) error { +// ConvertFrom implements apis.Convertible +func (sink *Configuration) ConvertFrom(ctx context.Context, source apis.Convertible) error { return fmt.Errorf("v1 is the highest known version, got: %T", source) } diff --git a/pkg/apis/serving/v1/configuration_conversion_test.go b/pkg/apis/serving/v1/configuration_conversion_test.go index 054cf5a73ecd..c013978c5157 100644 --- a/pkg/apis/serving/v1/configuration_conversion_test.go +++ b/pkg/apis/serving/v1/configuration_conversion_test.go @@ -24,11 +24,11 @@ import ( func TestConfigurationConversionBadType(t *testing.T) { good, bad := &Configuration{}, &Service{} - 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/serving/v1/revision_conversion.go b/pkg/apis/serving/v1/revision_conversion.go index 89ed8e5a0400..cae0252f27ad 100644 --- a/pkg/apis/serving/v1/revision_conversion.go +++ b/pkg/apis/serving/v1/revision_conversion.go @@ -23,12 +23,12 @@ import ( "knative.dev/pkg/apis" ) -// ConvertUp implements apis.Convertible -func (source *Revision) ConvertUp(ctx context.Context, sink apis.Convertible) error { +// ConvertTo implements apis.Convertible +func (source *Revision) ConvertTo(ctx context.Context, sink apis.Convertible) error { return fmt.Errorf("v1 is the highest known version, got: %T", sink) } -// ConvertDown implements apis.Convertible -func (sink *Revision) ConvertDown(ctx context.Context, source apis.Convertible) error { +// ConvertFrom implements apis.Convertible +func (sink *Revision) ConvertFrom(ctx context.Context, source apis.Convertible) error { return fmt.Errorf("v1 is the highest known version, got: %T", source) } diff --git a/pkg/apis/serving/v1/revision_conversion_test.go b/pkg/apis/serving/v1/revision_conversion_test.go index 71e4b75d906d..8efdeb6051f6 100644 --- a/pkg/apis/serving/v1/revision_conversion_test.go +++ b/pkg/apis/serving/v1/revision_conversion_test.go @@ -24,11 +24,11 @@ import ( func TestRevisionConversionBadType(t *testing.T) { good, bad := &Revision{}, &Service{} - 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/serving/v1/route_conversion.go b/pkg/apis/serving/v1/route_conversion.go index 7ef3cb1ae515..84e20cbc361d 100644 --- a/pkg/apis/serving/v1/route_conversion.go +++ b/pkg/apis/serving/v1/route_conversion.go @@ -23,12 +23,12 @@ import ( "knative.dev/pkg/apis" ) -// ConvertUp implements apis.Convertible -func (source *Route) ConvertUp(ctx context.Context, sink apis.Convertible) error { +// ConvertTo implements apis.Convertible +func (source *Route) ConvertTo(ctx context.Context, sink apis.Convertible) error { return fmt.Errorf("v1 is the highest known version, got: %T", sink) } -// ConvertDown implements apis.Convertible -func (sink *Route) ConvertDown(ctx context.Context, source apis.Convertible) error { +// ConvertFrom implements apis.Convertible +func (sink *Route) ConvertFrom(ctx context.Context, source apis.Convertible) error { return fmt.Errorf("v1 is the highest known version, got: %T", source) } diff --git a/pkg/apis/serving/v1/route_conversion_test.go b/pkg/apis/serving/v1/route_conversion_test.go index c5e98dfe317a..cb23274950ef 100644 --- a/pkg/apis/serving/v1/route_conversion_test.go +++ b/pkg/apis/serving/v1/route_conversion_test.go @@ -24,11 +24,11 @@ import ( func TestRouteConversionBadType(t *testing.T) { good, bad := &Route{}, &Service{} - 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/serving/v1/service_conversion.go b/pkg/apis/serving/v1/service_conversion.go index efb6605f338a..c36db5d41c0a 100644 --- a/pkg/apis/serving/v1/service_conversion.go +++ b/pkg/apis/serving/v1/service_conversion.go @@ -23,12 +23,12 @@ import ( "knative.dev/pkg/apis" ) -// ConvertUp implements apis.Convertible -func (source *Service) ConvertUp(ctx context.Context, sink apis.Convertible) error { +// ConvertTo implements apis.Convertible +func (source *Service) ConvertTo(ctx context.Context, sink apis.Convertible) error { return fmt.Errorf("v1 is the highest known version, got: %T", sink) } -// ConvertDown implements apis.Convertible -func (sink *Service) ConvertDown(ctx context.Context, source apis.Convertible) error { +// ConvertFrom implements apis.Convertible +func (sink *Service) ConvertFrom(ctx context.Context, source apis.Convertible) error { return fmt.Errorf("v1 is the highest known version, got: %T", source) } diff --git a/pkg/apis/serving/v1/service_conversion_test.go b/pkg/apis/serving/v1/service_conversion_test.go index 0158818ec732..949a8fcf1ce2 100644 --- a/pkg/apis/serving/v1/service_conversion_test.go +++ b/pkg/apis/serving/v1/service_conversion_test.go @@ -24,11 +24,11 @@ import ( func TestServiceConversionBadType(t *testing.T) { good, bad := &Service{}, &Revision{} - 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/serving/v1alpha1/configuration_conversion.go b/pkg/apis/serving/v1alpha1/configuration_conversion.go index cce9e281588c..74d5bcf2c46a 100644 --- a/pkg/apis/serving/v1alpha1/configuration_conversion.go +++ b/pkg/apis/serving/v1alpha1/configuration_conversion.go @@ -24,22 +24,22 @@ import ( "knative.dev/serving/pkg/apis/serving/v1beta1" ) -// ConvertUp implements apis.Convertible -func (source *Configuration) ConvertUp(ctx context.Context, obj apis.Convertible) error { +// ConvertTo implements apis.Convertible +func (source *Configuration) ConvertTo(ctx context.Context, obj apis.Convertible) error { switch sink := obj.(type) { case *v1beta1.Configuration: sink.ObjectMeta = source.ObjectMeta - if err := source.Spec.ConvertUp(ctx, &sink.Spec); err != nil { + if err := source.Spec.ConvertTo(ctx, &sink.Spec); err != nil { return err } - return source.Status.ConvertUp(ctx, &sink.Status) + return source.Status.ConvertTo(ctx, &sink.Status) default: - return apis.ConvertUpViaProxy(ctx, source, &v1beta1.Configuration{}, sink) + return apis.ConvertToViaProxy(ctx, source, &v1beta1.Configuration{}, sink) } } -// ConvertUp helps implement apis.Convertible -func (source *ConfigurationSpec) ConvertUp(ctx context.Context, sink *v1.ConfigurationSpec) error { +// ConvertTo helps implement apis.Convertible +func (source *ConfigurationSpec) ConvertTo(ctx context.Context, sink *v1.ConfigurationSpec) error { if source.DeprecatedBuild != nil { return ConvertErrorf("build", "build cannot be migrated forward.") } @@ -47,56 +47,56 @@ func (source *ConfigurationSpec) ConvertUp(ctx context.Context, sink *v1.Configu case source.DeprecatedRevisionTemplate != nil && source.Template != nil: return apis.ErrMultipleOneOf("revisionTemplate", "template") case source.DeprecatedRevisionTemplate != nil: - return source.DeprecatedRevisionTemplate.ConvertUp(ctx, &sink.Template) + return source.DeprecatedRevisionTemplate.ConvertTo(ctx, &sink.Template) case source.Template != nil: - return source.Template.ConvertUp(ctx, &sink.Template) + return source.Template.ConvertTo(ctx, &sink.Template) default: return apis.ErrMissingOneOf("revisionTemplate", "template") } } -// ConvertUp helps implement apis.Convertible -func (source *ConfigurationStatus) ConvertUp(ctx context.Context, sink *v1.ConfigurationStatus) error { +// ConvertTo helps implement apis.Convertible +func (source *ConfigurationStatus) ConvertTo(ctx context.Context, sink *v1.ConfigurationStatus) error { source.Status.ConvertTo(ctx, &sink.Status, v1.IsConfigurationCondition) - return source.ConfigurationStatusFields.ConvertUp(ctx, &sink.ConfigurationStatusFields) + return source.ConfigurationStatusFields.ConvertTo(ctx, &sink.ConfigurationStatusFields) } -// ConvertUp helps implement apis.Convertible -func (source *ConfigurationStatusFields) ConvertUp(ctx context.Context, sink *v1.ConfigurationStatusFields) error { +// ConvertTo helps implement apis.Convertible +func (source *ConfigurationStatusFields) ConvertTo(ctx context.Context, sink *v1.ConfigurationStatusFields) error { sink.LatestReadyRevisionName = source.LatestReadyRevisionName sink.LatestCreatedRevisionName = source.LatestCreatedRevisionName return nil } -// ConvertDown implements apis.Convertible -func (sink *Configuration) ConvertDown(ctx context.Context, obj apis.Convertible) error { +// ConvertFrom implements apis.Convertible +func (sink *Configuration) ConvertFrom(ctx context.Context, obj apis.Convertible) error { switch source := obj.(type) { case *v1beta1.Configuration: sink.ObjectMeta = source.ObjectMeta - if err := sink.Spec.ConvertDown(ctx, source.Spec); err != nil { + if err := sink.Spec.ConvertFrom(ctx, source.Spec); err != nil { return err } - return sink.Status.ConvertDown(ctx, source.Status) + return sink.Status.ConvertFrom(ctx, source.Status) default: - return apis.ConvertDownViaProxy(ctx, source, &v1beta1.Configuration{}, sink) + return apis.ConvertFromViaProxy(ctx, source, &v1beta1.Configuration{}, sink) } } -// ConvertDown helps implement apis.Convertible -func (sink *ConfigurationSpec) ConvertDown(ctx context.Context, source v1.ConfigurationSpec) error { +// ConvertFrom helps implement apis.Convertible +func (sink *ConfigurationSpec) ConvertFrom(ctx context.Context, source v1.ConfigurationSpec) error { sink.Template = &RevisionTemplateSpec{} - return sink.Template.ConvertDown(ctx, source.Template) + return sink.Template.ConvertFrom(ctx, source.Template) } -// ConvertDown helps implement apis.Convertible -func (sink *ConfigurationStatus) ConvertDown(ctx context.Context, source v1.ConfigurationStatus) error { +// ConvertFrom helps implement apis.Convertible +func (sink *ConfigurationStatus) ConvertFrom(ctx context.Context, source v1.ConfigurationStatus) error { source.Status.ConvertTo(ctx, &sink.Status, v1.IsConfigurationCondition) - return sink.ConfigurationStatusFields.ConvertDown(ctx, source.ConfigurationStatusFields) + return sink.ConfigurationStatusFields.ConvertFrom(ctx, source.ConfigurationStatusFields) } -// ConvertDown helps implement apis.Convertible -func (sink *ConfigurationStatusFields) ConvertDown(ctx context.Context, source v1.ConfigurationStatusFields) error { +// ConvertFrom helps implement apis.Convertible +func (sink *ConfigurationStatusFields) ConvertFrom(ctx context.Context, source v1.ConfigurationStatusFields) error { sink.LatestReadyRevisionName = source.LatestReadyRevisionName sink.LatestCreatedRevisionName = source.LatestCreatedRevisionName return nil diff --git a/pkg/apis/serving/v1alpha1/configuration_conversion_test.go b/pkg/apis/serving/v1alpha1/configuration_conversion_test.go index a6108efcdcee..e9371ff20bdc 100644 --- a/pkg/apis/serving/v1alpha1/configuration_conversion_test.go +++ b/pkg/apis/serving/v1alpha1/configuration_conversion_test.go @@ -35,12 +35,12 @@ import ( func TestConfigurationConversionBadType(t *testing.T) { good, bad := &Configuration{}, &Service{} - 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) } } @@ -62,8 +62,8 @@ func TestConfigurationConversionTemplateError(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { result := &v1.ConfigurationSpec{} - if err := test.cs.ConvertUp(context.Background(), result); err == nil { - t.Errorf("ConvertUp() = %#v, wanted error", result) + if err := test.cs.ConvertTo(context.Background(), result); err == nil { + t.Errorf("ConvertTo() = %#v, wanted error", result) } }) } @@ -184,22 +184,22 @@ func TestConfigurationConversion(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 { + if err := test.in.ConvertTo(context.Background(), ver); err != nil { if test.badField != "" { cce, ok := err.(*CannotConvertError) if ok && cce.Field == test.badField { return } } - t.Errorf("ConvertUp() = %v", err) + t.Errorf("ConvertTo() = %v", err) } else if test.badField != "" { - t.Errorf("ConvertUp() = %#v, wanted bad field %q", ver, + t.Errorf("ConvertTo() = %#v, wanted bad field %q", ver, test.badField) return } got := &Configuration{} - 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) @@ -211,22 +211,22 @@ func TestConfigurationConversion(t *testing.T) { t.Run(test.name+" (deprecated)", func(t *testing.T) { ver := version start := toDeprecated(test.in) - if err := start.ConvertUp(context.Background(), ver); err != nil { + if err := start.ConvertTo(context.Background(), ver); err != nil { if test.badField != "" { cce, ok := err.(*CannotConvertError) if ok && cce.Field == test.badField { return } } - t.Errorf("ConvertUp() = %v", err) + t.Errorf("ConvertTo() = %v", err) } else if test.badField != "" { t.Errorf("CovnertUp() = %#v, wanted bad field %q", ver, test.badField) return } got := &Configuration{} - 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/serving/v1alpha1/configuration_defaults.go b/pkg/apis/serving/v1alpha1/configuration_defaults.go index 56ef58c06226..1e1b121c2ebe 100644 --- a/pkg/apis/serving/v1alpha1/configuration_defaults.go +++ b/pkg/apis/serving/v1alpha1/configuration_defaults.go @@ -40,9 +40,9 @@ func (c *Configuration) SetDefaults(ctx context.Context) { func (cs *ConfigurationSpec) SetDefaults(ctx context.Context) { if v1.IsUpgradeViaDefaulting(ctx) { v := v1.ConfigurationSpec{} - if cs.ConvertUp(ctx, &v) == nil { + if cs.ConvertTo(ctx, &v) == nil { alpha := ConfigurationSpec{} - if alpha.ConvertDown(ctx, v) == nil { + if alpha.ConvertFrom(ctx, v) == nil { *cs = alpha } } diff --git a/pkg/apis/serving/v1alpha1/revision_conversion.go b/pkg/apis/serving/v1alpha1/revision_conversion.go index 64930be8a0d2..c6314d33f402 100644 --- a/pkg/apis/serving/v1alpha1/revision_conversion.go +++ b/pkg/apis/serving/v1alpha1/revision_conversion.go @@ -26,26 +26,26 @@ import ( "knative.dev/serving/pkg/apis/serving/v1beta1" ) -// ConvertUp implements apis.Convertible -func (source *Revision) ConvertUp(ctx context.Context, obj apis.Convertible) error { +// ConvertTo implements apis.Convertible +func (source *Revision) ConvertTo(ctx context.Context, obj apis.Convertible) error { switch sink := obj.(type) { case *v1beta1.Revision: 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 apis.ConvertUpViaProxy(ctx, source, &v1beta1.Revision{}, sink) + return apis.ConvertToViaProxy(ctx, source, &v1beta1.Revision{}, sink) } } -// ConvertUp helps implement apis.Convertible -func (source *RevisionTemplateSpec) ConvertUp(ctx context.Context, sink *v1.RevisionTemplateSpec) error { +// ConvertTo helps implement apis.Convertible +func (source *RevisionTemplateSpec) ConvertTo(ctx context.Context, sink *v1.RevisionTemplateSpec) error { sink.ObjectMeta = source.ObjectMeta - return source.Spec.ConvertUp(ctx, &sink.Spec) + return source.Spec.ConvertTo(ctx, &sink.Spec) } -// ConvertUp helps implement apis.Convertible -func (source *RevisionSpec) ConvertUp(ctx context.Context, sink *v1.RevisionSpec) error { +// ConvertTo helps implement apis.Convertible +func (source *RevisionSpec) ConvertTo(ctx context.Context, sink *v1.RevisionSpec) error { if source.TimeoutSeconds != nil { sink.TimeoutSeconds = ptr.Int64(*source.TimeoutSeconds) } @@ -76,40 +76,40 @@ func (source *RevisionSpec) ConvertUp(ctx context.Context, sink *v1.RevisionSpec return nil } -// ConvertUp helps implement apis.Convertible -func (source *RevisionStatus) ConvertUp(ctx context.Context, sink *v1.RevisionStatus) { +// ConvertTo helps implement apis.Convertible +func (source *RevisionStatus) ConvertTo(ctx context.Context, sink *v1.RevisionStatus) { source.Status.ConvertTo(ctx, &sink.Status, v1.IsRevisionCondition) sink.ServiceName = source.ServiceName sink.LogURL = source.LogURL sink.ImageDigest = source.ImageDigest } -// ConvertDown implements apis.Convertible -func (sink *Revision) ConvertDown(ctx context.Context, obj apis.Convertible) error { +// ConvertFrom implements apis.Convertible +func (sink *Revision) ConvertFrom(ctx context.Context, obj apis.Convertible) error { switch source := obj.(type) { case *v1beta1.Revision: sink.ObjectMeta = source.ObjectMeta - sink.Status.ConvertDown(ctx, source.Status) - return sink.Spec.ConvertDown(ctx, source.Spec) + sink.Status.ConvertFrom(ctx, source.Status) + return sink.Spec.ConvertFrom(ctx, source.Spec) default: - return apis.ConvertDownViaProxy(ctx, source, &v1beta1.Revision{}, sink) + return apis.ConvertFromViaProxy(ctx, source, &v1beta1.Revision{}, sink) } } -// ConvertDown helps implement apis.Convertible -func (sink *RevisionTemplateSpec) ConvertDown(ctx context.Context, source v1.RevisionTemplateSpec) error { +// ConvertFrom helps implement apis.Convertible +func (sink *RevisionTemplateSpec) ConvertFrom(ctx context.Context, source v1.RevisionTemplateSpec) error { sink.ObjectMeta = source.ObjectMeta - return sink.Spec.ConvertDown(ctx, source.Spec) + return sink.Spec.ConvertFrom(ctx, source.Spec) } -// ConvertDown helps implement apis.Convertible -func (sink *RevisionSpec) ConvertDown(ctx context.Context, source v1.RevisionSpec) error { +// ConvertFrom helps implement apis.Convertible +func (sink *RevisionSpec) ConvertFrom(ctx context.Context, source v1.RevisionSpec) error { sink.RevisionSpec = *source.DeepCopy() return nil } -// ConvertDown helps implement apis.Convertible -func (sink *RevisionStatus) ConvertDown(ctx context.Context, source v1.RevisionStatus) { +// ConvertFrom helps implement apis.Convertible +func (sink *RevisionStatus) ConvertFrom(ctx context.Context, source v1.RevisionStatus) { source.Status.ConvertTo(ctx, &sink.Status, v1.IsRevisionCondition) sink.ServiceName = source.ServiceName sink.LogURL = source.LogURL diff --git a/pkg/apis/serving/v1alpha1/revision_conversion_test.go b/pkg/apis/serving/v1alpha1/revision_conversion_test.go index e2d43101d9ba..87a2fa553069 100644 --- a/pkg/apis/serving/v1alpha1/revision_conversion_test.go +++ b/pkg/apis/serving/v1alpha1/revision_conversion_test.go @@ -34,12 +34,12 @@ import ( func TestRevisionConversionBadType(t *testing.T) { good, bad := &Revision{}, &Service{} - 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) } } @@ -154,22 +154,22 @@ func TestRevisionConversion(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { beta := &v1beta1.Revision{} - if err := test.in.ConvertUp(context.Background(), beta); err != nil { + if err := test.in.ConvertTo(context.Background(), beta); err != nil { if test.badField != "" { cce, ok := err.(*CannotConvertError) if ok && cce.Field == test.badField { return } } - t.Errorf("ConvertUp() = %v", err) + t.Errorf("ConvertTo() = %v", err) } else if test.badField != "" { t.Errorf("CovnertUp() = %#v, wanted bad field %q", beta, test.badField) return } got := &Revision{} - if err := got.ConvertDown(context.Background(), beta); err != nil { - t.Errorf("ConvertDown() = %v", err) + if err := got.ConvertFrom(context.Background(), beta); err != nil { + t.Errorf("ConvertFrom() = %v", err) } if diff := cmp.Diff(test.in, got); diff != "" { t.Errorf("roundtrip (-want, +got) = %v", diff) @@ -181,22 +181,22 @@ func TestRevisionConversion(t *testing.T) { t.Run(test.name+" (deprecated)", func(t *testing.T) { start := toDeprecated(test.in) beta := &v1beta1.Revision{} - if err := start.ConvertUp(context.Background(), beta); err != nil { + if err := start.ConvertTo(context.Background(), beta); err != nil { if test.badField != "" { cce, ok := err.(*CannotConvertError) if ok && cce.Field == test.badField { return } } - t.Errorf("ConvertUp() = %v", err) + t.Errorf("ConvertTo() = %v", err) } else if test.badField != "" { t.Errorf("CovnertUp() = %#v, wanted bad field %q", beta, test.badField) return } got := &Revision{} - if err := got.ConvertDown(context.Background(), beta); err != nil { - t.Errorf("ConvertDown() = %v", err) + if err := got.ConvertFrom(context.Background(), beta); err != nil { + t.Errorf("ConvertFrom() = %v", err) } if diff := cmp.Diff(test.in, got); diff != "" { t.Errorf("roundtrip (-want, +got) = %v", diff) @@ -281,9 +281,9 @@ func TestRevisionConversionError(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { beta := &v1beta1.Revision{} - got := test.in.ConvertUp(context.Background(), beta) + got := test.in.ConvertTo(context.Background(), beta) if got == nil { - t.Errorf("ConvertUp() = %#v, wanted %v", beta, test.want) + t.Errorf("ConvertTo() = %#v, wanted %v", beta, test.want) } if diff := cmp.Diff(test.want.Error(), got.Error()); diff != "" { t.Errorf("roundtrip (-want, +got) = %v", diff) diff --git a/pkg/apis/serving/v1alpha1/revision_defaults.go b/pkg/apis/serving/v1alpha1/revision_defaults.go index 887487fa95af..237f01d4934d 100644 --- a/pkg/apis/serving/v1alpha1/revision_defaults.go +++ b/pkg/apis/serving/v1alpha1/revision_defaults.go @@ -37,9 +37,9 @@ func (rts *RevisionTemplateSpec) SetDefaults(ctx context.Context) { func (rs *RevisionSpec) SetDefaults(ctx context.Context) { if v1.IsUpgradeViaDefaulting(ctx) { v1 := v1.RevisionSpec{} - if rs.ConvertUp(ctx, &v1) == nil { + if rs.ConvertTo(ctx, &v1) == nil { alpha := RevisionSpec{} - if alpha.ConvertDown(ctx, v1) == nil { + if alpha.ConvertFrom(ctx, v1) == nil { *rs = alpha } } diff --git a/pkg/apis/serving/v1alpha1/route_conversion.go b/pkg/apis/serving/v1alpha1/route_conversion.go index d427679ffa65..8d4128744556 100644 --- a/pkg/apis/serving/v1alpha1/route_conversion.go +++ b/pkg/apis/serving/v1alpha1/route_conversion.go @@ -26,31 +26,31 @@ import ( "knative.dev/serving/pkg/apis/serving/v1beta1" ) -// ConvertUp implements apis.Convertible -func (source *Route) ConvertUp(ctx context.Context, obj apis.Convertible) error { +// ConvertTo implements apis.Convertible +func (source *Route) ConvertTo(ctx context.Context, obj apis.Convertible) error { switch sink := obj.(type) { case *v1beta1.Route: sink.ObjectMeta = source.ObjectMeta - source.Status.ConvertUp(apis.WithinStatus(ctx), &sink.Status) - return source.Spec.ConvertUp(apis.WithinSpec(ctx), &sink.Spec) + source.Status.ConvertTo(apis.WithinStatus(ctx), &sink.Status) + return source.Spec.ConvertTo(apis.WithinSpec(ctx), &sink.Spec) default: - return apis.ConvertUpViaProxy(ctx, source, &v1beta1.Route{}, sink) + return apis.ConvertToViaProxy(ctx, source, &v1beta1.Route{}, sink) } } -// ConvertUp helps implement apis.Convertible -func (source *RouteSpec) ConvertUp(ctx context.Context, sink *v1.RouteSpec) error { +// ConvertTo helps implement apis.Convertible +func (source *RouteSpec) ConvertTo(ctx context.Context, sink *v1.RouteSpec) error { sink.Traffic = make([]v1.TrafficTarget, len(source.Traffic)) for i := range source.Traffic { - if err := source.Traffic[i].ConvertUp(ctx, &sink.Traffic[i]); err != nil { + if err := source.Traffic[i].ConvertTo(ctx, &sink.Traffic[i]); err != nil { return err } } return nil } -// ConvertUp helps implement apis.Convertible -func (source *TrafficTarget) ConvertUp(ctx context.Context, sink *v1.TrafficTarget) error { +// ConvertTo helps implement apis.Convertible +func (source *TrafficTarget) ConvertTo(ctx context.Context, sink *v1.TrafficTarget) error { *sink = source.TrafficTarget switch { case source.Tag != "" && source.DeprecatedName != "": @@ -63,14 +63,14 @@ func (source *TrafficTarget) ConvertUp(ctx context.Context, sink *v1.TrafficTarg return nil } -// ConvertUp helps implement apis.Convertible -func (source *RouteStatus) ConvertUp(ctx context.Context, sink *v1.RouteStatus) { - source.ConvertTo(ctx, &sink.Status, v1.IsRouteCondition) - source.RouteStatusFields.ConvertUp(ctx, &sink.RouteStatusFields) +// ConvertTo helps implement apis.Convertible +func (source *RouteStatus) ConvertTo(ctx context.Context, sink *v1.RouteStatus) { + source.Status.ConvertTo(ctx, &sink.Status, v1.IsRouteCondition) + source.RouteStatusFields.ConvertTo(ctx, &sink.RouteStatusFields) } -// ConvertUp helps implement apis.Convertible -func (source *RouteStatusFields) ConvertUp(ctx context.Context, sink *v1.RouteStatusFields) { +// ConvertTo helps implement apis.Convertible +func (source *RouteStatusFields) ConvertTo(ctx context.Context, sink *v1.RouteStatusFields) { if source.URL != nil { sink.URL = source.URL.DeepCopy() } @@ -79,49 +79,49 @@ func (source *RouteStatusFields) ConvertUp(ctx context.Context, sink *v1.RouteSt if sink.Address == nil { sink.Address = &duckv1.Addressable{} } - source.Address.ConvertUp(ctx, sink.Address) + source.Address.ConvertTo(ctx, sink.Address) } sink.Traffic = make([]v1.TrafficTarget, len(source.Traffic)) for i := range source.Traffic { - source.Traffic[i].ConvertUp(ctx, &sink.Traffic[i]) + source.Traffic[i].ConvertTo(ctx, &sink.Traffic[i]) } } -// ConvertDown implements apis.Convertible -func (sink *Route) ConvertDown(ctx context.Context, obj apis.Convertible) error { +// ConvertFrom implements apis.Convertible +func (sink *Route) ConvertFrom(ctx context.Context, obj apis.Convertible) error { switch source := obj.(type) { case *v1beta1.Route: sink.ObjectMeta = source.ObjectMeta - sink.Spec.ConvertDown(ctx, source.Spec) - sink.Status.ConvertDown(ctx, source.Status) + sink.Spec.ConvertFrom(ctx, source.Spec) + sink.Status.ConvertFrom(ctx, source.Status) return nil default: - return apis.ConvertDownViaProxy(ctx, source, &v1beta1.Route{}, sink) + return apis.ConvertFromViaProxy(ctx, source, &v1beta1.Route{}, sink) } } -// ConvertDown helps implement apis.Convertible -func (sink *RouteSpec) ConvertDown(ctx context.Context, source v1.RouteSpec) { +// ConvertFrom helps implement apis.Convertible +func (sink *RouteSpec) ConvertFrom(ctx context.Context, source v1.RouteSpec) { sink.Traffic = make([]TrafficTarget, len(source.Traffic)) for i := range source.Traffic { - sink.Traffic[i].ConvertDown(ctx, source.Traffic[i]) + sink.Traffic[i].ConvertFrom(ctx, source.Traffic[i]) } } -// ConvertDown helps implement apis.Convertible -func (sink *TrafficTarget) ConvertDown(ctx context.Context, source v1.TrafficTarget) { +// ConvertFrom helps implement apis.Convertible +func (sink *TrafficTarget) ConvertFrom(ctx context.Context, source v1.TrafficTarget) { sink.TrafficTarget = source } -// ConvertDown helps implement apis.Convertible -func (sink *RouteStatus) ConvertDown(ctx context.Context, source v1.RouteStatus) { +// ConvertFrom helps implement apis.Convertible +func (sink *RouteStatus) ConvertFrom(ctx context.Context, source v1.RouteStatus) { source.ConvertTo(ctx, &sink.Status, v1.IsRouteCondition) - sink.RouteStatusFields.ConvertDown(ctx, source.RouteStatusFields) + sink.RouteStatusFields.ConvertFrom(ctx, source.RouteStatusFields) } -// ConvertDown helps implement apis.Convertible -func (sink *RouteStatusFields) ConvertDown(ctx context.Context, source v1.RouteStatusFields) { +// ConvertFrom helps implement apis.Convertible +func (sink *RouteStatusFields) ConvertFrom(ctx context.Context, source v1.RouteStatusFields) { if source.URL != nil { sink.URL = source.URL.DeepCopy() } @@ -130,11 +130,11 @@ func (sink *RouteStatusFields) ConvertDown(ctx context.Context, source v1.RouteS if sink.Address == nil { sink.Address = &duckv1alpha1.Addressable{} } - sink.Address.ConvertDown(ctx, source.Address) + sink.Address.ConvertFrom(ctx, source.Address) } sink.Traffic = make([]TrafficTarget, len(source.Traffic)) for i := range source.Traffic { - sink.Traffic[i].ConvertDown(ctx, source.Traffic[i]) + sink.Traffic[i].ConvertFrom(ctx, source.Traffic[i]) } } diff --git a/pkg/apis/serving/v1alpha1/route_conversion_test.go b/pkg/apis/serving/v1alpha1/route_conversion_test.go index d879425534ae..3f5bd0644f42 100644 --- a/pkg/apis/serving/v1alpha1/route_conversion_test.go +++ b/pkg/apis/serving/v1alpha1/route_conversion_test.go @@ -35,12 +35,12 @@ import ( func TestRouteConversionBadType(t *testing.T) { good, bad := &Route{}, &Service{} - 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) } } @@ -286,17 +286,17 @@ func TestRouteConversion(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { beta := &v1beta1.Route{} - if err := test.in.ConvertUp(context.Background(), beta); err != nil { + if err := test.in.ConvertTo(context.Background(), beta); err != nil { if !test.wantErr { - t.Errorf("ConvertUp() = %v", err) + t.Errorf("ConvertTo() = %v", err) } return } else if test.wantErr { - t.Errorf("ConvertUp() = %#v, wanted error", beta) + t.Errorf("ConvertTo() = %#v, wanted error", beta) } got := &Route{} - if err := got.ConvertDown(context.Background(), beta); err != nil { - t.Errorf("ConvertDown() = %v", err) + if err := got.ConvertFrom(context.Background(), beta); err != nil { + t.Errorf("ConvertFrom() = %v", err) } if diff := cmp.Diff(test.in, got); diff != "" { t.Errorf("roundtrip (-want, +got) = %v", diff) @@ -311,12 +311,12 @@ func TestRouteConversion(t *testing.T) { } start := toDeprecated(test.in) beta := &v1beta1.Route{} - if err := start.ConvertUp(context.Background(), beta); err != nil { - t.Errorf("ConvertUp() = %v", err) + if err := start.ConvertTo(context.Background(), beta); err != nil { + t.Errorf("ConvertTo() = %v", err) } got := &Route{} - if err := got.ConvertDown(context.Background(), beta); err != nil { - t.Errorf("ConvertDown() = %v", err) + if err := got.ConvertFrom(context.Background(), beta); 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/serving/v1alpha1/route_defaults.go b/pkg/apis/serving/v1alpha1/route_defaults.go index fab2d8ce4963..26a46bc68801 100644 --- a/pkg/apis/serving/v1alpha1/route_defaults.go +++ b/pkg/apis/serving/v1alpha1/route_defaults.go @@ -40,9 +40,9 @@ func (r *Route) SetDefaults(ctx context.Context) { func (rs *RouteSpec) SetDefaults(ctx context.Context) { if v1.IsUpgradeViaDefaulting(ctx) { v := v1.RouteSpec{} - if rs.ConvertUp(ctx, &v) == nil { + if rs.ConvertTo(ctx, &v) == nil { alpha := RouteSpec{} - alpha.ConvertDown(ctx, v) + alpha.ConvertFrom(ctx, v) *rs = alpha } } diff --git a/pkg/apis/serving/v1alpha1/service_conversion.go b/pkg/apis/serving/v1alpha1/service_conversion.go index bb1a3410084d..b8062bbb8ce4 100644 --- a/pkg/apis/serving/v1alpha1/service_conversion.go +++ b/pkg/apis/serving/v1alpha1/service_conversion.go @@ -25,22 +25,22 @@ import ( "knative.dev/serving/pkg/apis/serving/v1beta1" ) -// ConvertUp implements apis.Convertible -func (source *Service) ConvertUp(ctx context.Context, obj apis.Convertible) error { +// ConvertTo implements apis.Convertible +func (source *Service) ConvertTo(ctx context.Context, obj apis.Convertible) error { switch sink := obj.(type) { case *v1beta1.Service: sink.ObjectMeta = source.ObjectMeta - if err := source.Spec.ConvertUp(ctx, &sink.Spec); err != nil { + if err := source.Spec.ConvertTo(ctx, &sink.Spec); err != nil { return err } - return source.Status.ConvertUp(ctx, &sink.Status) + return source.Status.ConvertTo(ctx, &sink.Status) default: - return apis.ConvertUpViaProxy(ctx, source, &v1beta1.Service{}, sink) + return apis.ConvertToViaProxy(ctx, source, &v1beta1.Service{}, sink) } } -// ConvertUp helps implement apis.Convertible -func (source *ServiceSpec) ConvertUp(ctx context.Context, sink *v1.ServiceSpec) error { +// ConvertTo helps implement apis.Convertible +func (source *ServiceSpec) ConvertTo(ctx context.Context, sink *v1.ServiceSpec) error { switch { case source.DeprecatedRunLatest != nil: sink.RouteSpec = v1.RouteSpec{ @@ -49,7 +49,7 @@ func (source *ServiceSpec) ConvertUp(ctx context.Context, sink *v1.ServiceSpec) LatestRevision: ptr.Bool(true), }}, } - return source.DeprecatedRunLatest.Configuration.ConvertUp(ctx, &sink.ConfigurationSpec) + return source.DeprecatedRunLatest.Configuration.ConvertTo(ctx, &sink.ConfigurationSpec) case source.DeprecatedRelease != nil: if len(source.DeprecatedRelease.Revisions) == 2 { @@ -87,7 +87,7 @@ func (source *ServiceSpec) ConvertUp(ctx context.Context, sink *v1.ServiceSpec) sink.RouteSpec.Traffic[i].LatestRevision = ptr.Bool(true) } } - return source.DeprecatedRelease.Configuration.ConvertUp(ctx, &sink.ConfigurationSpec) + return source.DeprecatedRelease.Configuration.ConvertTo(ctx, &sink.ConfigurationSpec) case source.DeprecatedPinned != nil: sink.RouteSpec = v1.RouteSpec{ @@ -96,47 +96,47 @@ func (source *ServiceSpec) ConvertUp(ctx context.Context, sink *v1.ServiceSpec) Percent: ptr.Int64(100), }}, } - return source.DeprecatedPinned.Configuration.ConvertUp(ctx, &sink.ConfigurationSpec) + return source.DeprecatedPinned.Configuration.ConvertTo(ctx, &sink.ConfigurationSpec) case source.DeprecatedManual != nil: return ConvertErrorf("manual", "manual mode cannot be migrated forward.") default: - source.RouteSpec.ConvertUp(ctx, &sink.RouteSpec) - return source.ConfigurationSpec.ConvertUp(ctx, &sink.ConfigurationSpec) + source.RouteSpec.ConvertTo(ctx, &sink.RouteSpec) + return source.ConfigurationSpec.ConvertTo(ctx, &sink.ConfigurationSpec) } } -// ConvertUp helps implement apis.Convertible -func (source *ServiceStatus) ConvertUp(ctx context.Context, sink *v1.ServiceStatus) error { - source.ConvertTo(ctx, &sink.Status, v1.IsServiceCondition) - source.RouteStatusFields.ConvertUp(ctx, &sink.RouteStatusFields) - return source.ConfigurationStatusFields.ConvertUp(ctx, &sink.ConfigurationStatusFields) +// ConvertTo helps implement apis.Convertible +func (source *ServiceStatus) ConvertTo(ctx context.Context, sink *v1.ServiceStatus) error { + source.Status.ConvertTo(ctx, &sink.Status, v1.IsServiceCondition) + source.RouteStatusFields.ConvertTo(ctx, &sink.RouteStatusFields) + return source.ConfigurationStatusFields.ConvertTo(ctx, &sink.ConfigurationStatusFields) } -// ConvertDown implements apis.Convertible -func (sink *Service) ConvertDown(ctx context.Context, obj apis.Convertible) error { +// ConvertFrom implements apis.Convertible +func (sink *Service) ConvertFrom(ctx context.Context, obj apis.Convertible) error { switch source := obj.(type) { case *v1beta1.Service: sink.ObjectMeta = source.ObjectMeta - if err := sink.Spec.ConvertDown(ctx, source.Spec); err != nil { + if err := sink.Spec.ConvertFrom(ctx, source.Spec); err != nil { return err } - return sink.Status.ConvertDown(ctx, source.Status) + return sink.Status.ConvertFrom(ctx, source.Status) default: - return apis.ConvertDownViaProxy(ctx, source, &v1beta1.Service{}, sink) + return apis.ConvertFromViaProxy(ctx, source, &v1beta1.Service{}, sink) } } -// ConvertDown helps implement apis.Convertible -func (sink *ServiceSpec) ConvertDown(ctx context.Context, source v1.ServiceSpec) error { - sink.RouteSpec.ConvertDown(ctx, source.RouteSpec) - return sink.ConfigurationSpec.ConvertDown(ctx, source.ConfigurationSpec) +// ConvertFrom helps implement apis.Convertible +func (sink *ServiceSpec) ConvertFrom(ctx context.Context, source v1.ServiceSpec) error { + sink.RouteSpec.ConvertFrom(ctx, source.RouteSpec) + return sink.ConfigurationSpec.ConvertFrom(ctx, source.ConfigurationSpec) } -// ConvertDown helps implement apis.Convertible -func (sink *ServiceStatus) ConvertDown(ctx context.Context, source v1.ServiceStatus) error { +// ConvertFrom helps implement apis.Convertible +func (sink *ServiceStatus) ConvertFrom(ctx context.Context, source v1.ServiceStatus) error { source.ConvertTo(ctx, &sink.Status, v1.IsServiceCondition) - sink.RouteStatusFields.ConvertDown(ctx, source.RouteStatusFields) - return sink.ConfigurationStatusFields.ConvertDown(ctx, source.ConfigurationStatusFields) + sink.RouteStatusFields.ConvertFrom(ctx, source.RouteStatusFields) + return sink.ConfigurationStatusFields.ConvertFrom(ctx, source.ConfigurationStatusFields) } diff --git a/pkg/apis/serving/v1alpha1/service_conversion_test.go b/pkg/apis/serving/v1alpha1/service_conversion_test.go index 9ecda37b5cb4..d57dfc2aaa10 100644 --- a/pkg/apis/serving/v1alpha1/service_conversion_test.go +++ b/pkg/apis/serving/v1alpha1/service_conversion_test.go @@ -34,12 +34,12 @@ import ( func TestServiceConversionBadType(t *testing.T) { good, bad := &Service{}, &Revision{} - 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) } } @@ -127,15 +127,15 @@ func TestServiceConversion(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) } - t.Logf("ConvertUp() = %#v", ver) + t.Logf("ConvertTo() = %#v", ver) got := &Service{} - 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) } - t.Logf("ConvertDown() = %#v", got) + t.Logf("ConvertFrom() = %#v", got) if diff := cmp.Diff(test.in, got); diff != "" { t.Errorf("roundtrip (-want, +got) = %v", diff) } @@ -682,21 +682,21 @@ func TestServiceConversionFromDeprecated(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 { + if err := test.in.ConvertTo(context.Background(), ver); err != nil { if test.badField != "" { cce, ok := err.(*CannotConvertError) if ok && cce.Field == test.badField { return } } - t.Errorf("ConvertUp() = %v", err) + t.Errorf("ConvertTo() = %v", err) } - t.Logf("ConvertUp() = %#v", ver) + t.Logf("ConvertTo() = %#v", ver) got := &Service{} - 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) } - t.Logf("ConvertDown() = %#v", got) + t.Logf("ConvertFrom() = %#v", got) if diff := cmp.Diff(test.want, got); diff != "" { t.Errorf("roundtrip (-want, +got) = %v", diff) } diff --git a/pkg/apis/serving/v1alpha1/service_defaults.go b/pkg/apis/serving/v1alpha1/service_defaults.go index 8e7b77c1554e..2e5a71cb6cd8 100644 --- a/pkg/apis/serving/v1alpha1/service_defaults.go +++ b/pkg/apis/serving/v1alpha1/service_defaults.go @@ -38,9 +38,9 @@ func (s *Service) SetDefaults(ctx context.Context) { func (ss *ServiceSpec) SetDefaults(ctx context.Context) { if v1.IsUpgradeViaDefaulting(ctx) { v := v1.ServiceSpec{} - if ss.ConvertUp(ctx, &v) == nil { + if ss.ConvertTo(ctx, &v) == nil { alpha := ServiceSpec{} - if alpha.ConvertDown(ctx, v) == nil { + if alpha.ConvertFrom(ctx, v) == nil { *ss = alpha } } diff --git a/pkg/apis/serving/v1beta1/configuration_conversion.go b/pkg/apis/serving/v1beta1/configuration_conversion.go index c41d5412bb2c..62f709897c3e 100644 --- a/pkg/apis/serving/v1beta1/configuration_conversion.go +++ b/pkg/apis/serving/v1beta1/configuration_conversion.go @@ -23,8 +23,8 @@ import ( v1 "knative.dev/serving/pkg/apis/serving/v1" ) -// ConvertUp implements apis.Convertible -func (source *Configuration) ConvertUp(ctx context.Context, obj apis.Convertible) error { +// ConvertTo implements apis.Convertible +func (source *Configuration) ConvertTo(ctx context.Context, obj apis.Convertible) error { switch sink := obj.(type) { case *v1.Configuration: sink.ObjectMeta = source.ObjectMeta @@ -32,12 +32,12 @@ func (source *Configuration) ConvertUp(ctx context.Context, obj apis.Convertible sink.Status = source.Status return nil default: - return apis.ConvertUpViaProxy(ctx, source, &v1.Configuration{}, sink) + return apis.ConvertToViaProxy(ctx, source, &v1.Configuration{}, sink) } } -// ConvertDown implements apis.Convertible -func (sink *Configuration) ConvertDown(ctx context.Context, obj apis.Convertible) error { +// ConvertFrom implements apis.Convertible +func (sink *Configuration) ConvertFrom(ctx context.Context, obj apis.Convertible) error { switch source := obj.(type) { case *v1.Configuration: sink.ObjectMeta = source.ObjectMeta @@ -45,6 +45,6 @@ func (sink *Configuration) ConvertDown(ctx context.Context, obj apis.Convertible sink.Status = source.Status return nil default: - return apis.ConvertDownViaProxy(ctx, source, &v1.Configuration{}, sink) + return apis.ConvertFromViaProxy(ctx, source, &v1.Configuration{}, sink) } } diff --git a/pkg/apis/serving/v1beta1/configuration_conversion_test.go b/pkg/apis/serving/v1beta1/configuration_conversion_test.go index 0e4ec0117482..653e16579dbc 100644 --- a/pkg/apis/serving/v1beta1/configuration_conversion_test.go +++ b/pkg/apis/serving/v1beta1/configuration_conversion_test.go @@ -24,11 +24,11 @@ import ( func TestConfigurationConversionBadType(t *testing.T) { good, bad := &Configuration{}, &Service{} - 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/serving/v1beta1/revision_conversion.go b/pkg/apis/serving/v1beta1/revision_conversion.go index 6a02f0e74c45..cc45724734a3 100644 --- a/pkg/apis/serving/v1beta1/revision_conversion.go +++ b/pkg/apis/serving/v1beta1/revision_conversion.go @@ -23,8 +23,8 @@ import ( v1 "knative.dev/serving/pkg/apis/serving/v1" ) -// ConvertUp implements apis.Convertible -func (source *Revision) ConvertUp(ctx context.Context, obj apis.Convertible) error { +// ConvertTo implements apis.Convertible +func (source *Revision) ConvertTo(ctx context.Context, obj apis.Convertible) error { switch sink := obj.(type) { case *v1.Revision: sink.ObjectMeta = source.ObjectMeta @@ -32,12 +32,12 @@ func (source *Revision) ConvertUp(ctx context.Context, obj apis.Convertible) err sink.Status = source.Status return nil default: - return apis.ConvertUpViaProxy(ctx, source, &v1.Revision{}, sink) + return apis.ConvertToViaProxy(ctx, source, &v1.Revision{}, sink) } } -// ConvertDown implements apis.Convertible -func (sink *Revision) ConvertDown(ctx context.Context, obj apis.Convertible) error { +// ConvertFrom implements apis.Convertible +func (sink *Revision) ConvertFrom(ctx context.Context, obj apis.Convertible) error { switch source := obj.(type) { case *v1.Revision: sink.ObjectMeta = source.ObjectMeta @@ -45,6 +45,6 @@ func (sink *Revision) ConvertDown(ctx context.Context, obj apis.Convertible) err sink.Status = source.Status return nil default: - return apis.ConvertDownViaProxy(ctx, source, &v1.Revision{}, sink) + return apis.ConvertFromViaProxy(ctx, source, &v1.Revision{}, sink) } } diff --git a/pkg/apis/serving/v1beta1/revision_conversion_test.go b/pkg/apis/serving/v1beta1/revision_conversion_test.go index 601996b23256..0631ac0549ee 100644 --- a/pkg/apis/serving/v1beta1/revision_conversion_test.go +++ b/pkg/apis/serving/v1beta1/revision_conversion_test.go @@ -24,11 +24,11 @@ import ( func TestRevisionConversionBadType(t *testing.T) { good, bad := &Revision{}, &Service{} - 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/serving/v1beta1/route_conversion.go b/pkg/apis/serving/v1beta1/route_conversion.go index 5a1d328fbd70..2044f956f46e 100644 --- a/pkg/apis/serving/v1beta1/route_conversion.go +++ b/pkg/apis/serving/v1beta1/route_conversion.go @@ -23,8 +23,8 @@ import ( v1 "knative.dev/serving/pkg/apis/serving/v1" ) -// ConvertUp implements apis.Convertible -func (source *Route) ConvertUp(ctx context.Context, obj apis.Convertible) error { +// ConvertTo implements apis.Convertible +func (source *Route) ConvertTo(ctx context.Context, obj apis.Convertible) error { switch sink := obj.(type) { case *v1.Route: sink.ObjectMeta = source.ObjectMeta @@ -32,12 +32,12 @@ func (source *Route) ConvertUp(ctx context.Context, obj apis.Convertible) error sink.Status = source.Status return nil default: - return apis.ConvertUpViaProxy(ctx, source, &v1.Route{}, sink) + return apis.ConvertToViaProxy(ctx, source, &v1.Route{}, sink) } } -// ConvertDown implements apis.Convertible -func (sink *Route) ConvertDown(ctx context.Context, obj apis.Convertible) error { +// ConvertFrom implements apis.Convertible +func (sink *Route) ConvertFrom(ctx context.Context, obj apis.Convertible) error { switch source := obj.(type) { case *v1.Route: sink.ObjectMeta = source.ObjectMeta @@ -45,6 +45,6 @@ func (sink *Route) ConvertDown(ctx context.Context, obj apis.Convertible) error sink.Status = source.Status return nil default: - return apis.ConvertDownViaProxy(ctx, source, &v1.Route{}, sink) + return apis.ConvertFromViaProxy(ctx, source, &v1.Route{}, sink) } } diff --git a/pkg/apis/serving/v1beta1/route_conversion_test.go b/pkg/apis/serving/v1beta1/route_conversion_test.go index 350ba7f846ed..45e49d08d716 100644 --- a/pkg/apis/serving/v1beta1/route_conversion_test.go +++ b/pkg/apis/serving/v1beta1/route_conversion_test.go @@ -24,11 +24,11 @@ import ( func TestRouteConversionBadType(t *testing.T) { good, bad := &Route{}, &Service{} - 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/serving/v1beta1/service_conversion.go b/pkg/apis/serving/v1beta1/service_conversion.go index ae9ae52c86a1..c28d9703f6c8 100644 --- a/pkg/apis/serving/v1beta1/service_conversion.go +++ b/pkg/apis/serving/v1beta1/service_conversion.go @@ -23,8 +23,8 @@ import ( v1 "knative.dev/serving/pkg/apis/serving/v1" ) -// ConvertUp implements apis.Convertible -func (source *Service) ConvertUp(ctx context.Context, obj apis.Convertible) error { +// ConvertTo implements apis.Convertible +func (source *Service) ConvertTo(ctx context.Context, obj apis.Convertible) error { switch sink := obj.(type) { case *v1.Service: sink.ObjectMeta = source.ObjectMeta @@ -32,12 +32,12 @@ func (source *Service) ConvertUp(ctx context.Context, obj apis.Convertible) erro sink.Status = source.Status return nil default: - return apis.ConvertUpViaProxy(ctx, source, &v1.Service{}, sink) + return apis.ConvertToViaProxy(ctx, source, &v1.Service{}, sink) } } -// ConvertDown implements apis.Convertible -func (sink *Service) ConvertDown(ctx context.Context, obj apis.Convertible) error { +// ConvertFrom implements apis.Convertible +func (sink *Service) ConvertFrom(ctx context.Context, obj apis.Convertible) error { switch source := obj.(type) { case *v1.Service: sink.ObjectMeta = source.ObjectMeta @@ -45,6 +45,6 @@ func (sink *Service) ConvertDown(ctx context.Context, obj apis.Convertible) erro sink.Status = source.Status return nil default: - return apis.ConvertDownViaProxy(ctx, source, &v1.Service{}, sink) + return apis.ConvertFromViaProxy(ctx, source, &v1.Service{}, sink) } } diff --git a/pkg/apis/serving/v1beta1/service_conversion_test.go b/pkg/apis/serving/v1beta1/service_conversion_test.go index 0768535cff5c..f4ac73288e1e 100644 --- a/pkg/apis/serving/v1beta1/service_conversion_test.go +++ b/pkg/apis/serving/v1beta1/service_conversion_test.go @@ -24,11 +24,11 @@ import ( func TestServiceConversionBadType(t *testing.T) { good, bad := &Service{}, &Revision{} - 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/vendor/knative.dev/pkg/apis/convert.go b/vendor/knative.dev/pkg/apis/convert.go index e67a379303b0..d6a28a0727fe 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 e5955aeb69fc..579e6976ee85 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 d0a81db8fc2d..70c9b0135ce5 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 6093bd033828..3e3f8286763f 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 fef69d8b315f..b4d350f88f9f 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/roundtrip/roundtrip.go b/vendor/knative.dev/pkg/apis/testing/roundtrip/roundtrip.go index 9410d99422be..ccc030f7ebb7 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/webhook/resourcesemantics/conversion/controller.go b/vendor/knative.dev/pkg/webhook/resourcesemantics/conversion/controller.go index bb06f2e2160d..b21003e0a8fd 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 afc3915f1287..e829ed75cf2d 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 764ddc92574d..52f67006ac3d 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