Skip to content

Commit

Permalink
Update knative.dev/pkg to 0.13, fix breaking Convertible change
Browse files Browse the repository at this point in the history
  • Loading branch information
mattmoor committed Mar 3, 2020
1 parent 20f4068 commit 8e8f9d1
Show file tree
Hide file tree
Showing 173 changed files with 23,159 additions and 1,497 deletions.
20 changes: 9 additions & 11 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ require (
contrib.go.opencensus.io/exporter/stackdriver v0.12.8 // indirect
github.com/GoogleCloudPlatform/cloud-builders/gcs-fetcher v0.0.0-20191203181535-308b93ad1f39
github.com/cloudevents/sdk-go v1.0.0
github.com/evanphx/json-patch v4.5.0+incompatible // indirect
github.com/ghodss/yaml v1.0.0
github.com/go-openapi/spec v0.19.4 // indirect
github.com/gogo/protobuf v1.3.1 // indirect
Expand All @@ -22,15 +21,13 @@ require (
github.com/jenkins-x/go-scm v1.5.73
github.com/json-iterator/go v1.1.8 // indirect
github.com/markbates/inflect v1.0.4 // indirect
github.com/mattbaird/jsonpatch v0.0.0-20171005235357-81af80346b1a // indirect
github.com/mitchellh/go-homedir v1.1.0
github.com/nbio/st v0.0.0-20140626010706-e9e8d9816f32 // indirect
github.com/onsi/ginkgo v1.10.1 // indirect
github.com/onsi/gomega v1.7.0 // indirect
github.com/pkg/errors v0.8.1
github.com/prometheus/common v0.7.0 // indirect
github.com/prometheus/procfs v0.0.5 // indirect
github.com/rogpeppe/go-internal v1.3.2 // indirect
github.com/shurcooL/githubv4 v0.0.0-20191102174205-af46314aec7b // indirect
github.com/tektoncd/plumbing v0.0.0-20200217163359-cd0db6e567d2
github.com/vdemeester/k8s-pkg-credentialprovider v1.13.12-1 // indirect
Expand All @@ -44,25 +41,26 @@ require (
golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4 // indirect
golang.org/x/time v0.0.0-20191024005414-555d28b269f0 // indirect
golang.org/x/tools v0.0.0-20200214144324-88be01311a71 // indirect
gomodules.xyz/jsonpatch/v2 v2.1.0 // indirect
google.golang.org/appengine v1.6.5 // indirect
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
gopkg.in/yaml.v2 v2.2.5 // indirect
k8s.io/api v0.17.2
k8s.io/apimachinery v0.17.2
k8s.io/client-go v0.17.0
k8s.io/code-generator v0.17.1
k8s.io/api v0.17.3
k8s.io/apiextensions-apiserver v0.17.3 // indirect
k8s.io/apimachinery v0.17.3
k8s.io/client-go v0.17.3
k8s.io/code-generator v0.17.3
k8s.io/gengo v0.0.0-20191108084044-e500ee069b5c // indirect
k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a
knative.dev/caching v0.0.0-20200116200605-67bca2c83dfa
knative.dev/eventing-contrib v0.11.2
knative.dev/pkg v0.0.0-20200207155214-fef852970f43
knative.dev/pkg v0.0.0-20200227193851-2fe8db300072
)

// Knative deps (release-0.12)
// Knative deps (release-0.13)
replace (
contrib.go.opencensus.io/exporter/stackdriver => contrib.go.opencensus.io/exporter/stackdriver v0.12.9-0.20191108183826-59d068f8d8ff
knative.dev/caching => knative.dev/caching v0.0.0-20200116200605-67bca2c83dfa
knative.dev/pkg => knative.dev/pkg v0.0.0-20200113182502-b8dc5fbc6d2f
knative.dev/pkg => knative.dev/pkg v0.0.0-20200227193851-2fe8db300072
knative.dev/pkg/vendor/github.com/spf13/pflag => github.com/spf13/pflag v1.0.5
)

Expand Down
74 changes: 66 additions & 8 deletions go.sum

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions pkg/apis/pipeline/v1alpha1/cluster_task_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,23 @@ import (

var _ apis.Convertible = (*ClusterTask)(nil)

// ConvertUp implements api.Convertible
func (source *ClusterTask) ConvertUp(ctx context.Context, obj apis.Convertible) error {
// ConvertTo implements api.Convertible
func (source *ClusterTask) ConvertTo(ctx context.Context, obj apis.Convertible) error {
switch sink := obj.(type) {
case *v1beta1.ClusterTask:
sink.ObjectMeta = source.ObjectMeta
return source.Spec.ConvertUp(ctx, &sink.Spec)
return source.Spec.ConvertTo(ctx, &sink.Spec)
default:
return fmt.Errorf("unknown version, got: %T", sink)
}
}

// ConvertDown implements api.Convertible
func (sink *ClusterTask) ConvertDown(ctx context.Context, obj apis.Convertible) error {
// ConvertFrom implements api.Convertible
func (sink *ClusterTask) ConvertFrom(ctx context.Context, obj apis.Convertible) error {
switch source := obj.(type) {
case *v1beta1.ClusterTask:
sink.ObjectMeta = source.ObjectMeta
return sink.Spec.ConvertDown(ctx, &source.Spec)
return sink.Spec.ConvertFrom(ctx, &source.Spec)
default:
return fmt.Errorf("unknown version, got: %T", sink)
}
Expand Down
32 changes: 16 additions & 16 deletions pkg/apis/pipeline/v1alpha1/cluster_task_conversion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ import (
func TestClusterTaskConversionBadType(t *testing.T) {
good, bad := &ClusterTask{}, &Pipeline{}

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("ConvertUp() = %#v, wanted error", bad)
if err := good.ConvertFrom(context.Background(), bad); err == nil {
t.Errorf("ConvertTo() = %#v, wanted error", bad)
}
}

Expand Down Expand Up @@ -163,18 +163,18 @@ func TestClusterTaskConversion(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.wantErr {
t.Errorf("ConvertUp() = %v", err)
t.Errorf("ConvertTo() = %v", err)
}
return
}
t.Logf("ConvertUp() = %#v", ver)
t.Logf("ConvertTo() = %#v", ver)
got := &ClusterTask{}
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)
}
Expand Down Expand Up @@ -297,21 +297,21 @@ func TestClusterTaskConversionFromDeprecated(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 := &ClusterTask{}
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)
}
Expand Down
28 changes: 14 additions & 14 deletions pkg/apis/pipeline/v1alpha1/pipeline_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,38 +27,38 @@ import (

var _ apis.Convertible = (*Pipeline)(nil)

// ConvertUp implements api.Convertible
func (source *Pipeline) ConvertUp(ctx context.Context, obj apis.Convertible) error {
// ConvertTo implements api.Convertible
func (source *Pipeline) ConvertTo(ctx context.Context, obj apis.Convertible) error {
switch sink := obj.(type) {
case *v1beta1.Pipeline:
sink.ObjectMeta = source.ObjectMeta
return source.Spec.ConvertUp(ctx, &sink.Spec)
return source.Spec.ConvertTo(ctx, &sink.Spec)
default:
return fmt.Errorf("unknown version, got: %T", sink)
}
}

func (source *PipelineSpec) ConvertUp(ctx context.Context, sink *v1beta1.PipelineSpec) error {
func (source *PipelineSpec) ConvertTo(ctx context.Context, sink *v1beta1.PipelineSpec) error {
sink.Resources = source.Resources
sink.Params = source.Params
sink.Workspaces = source.Workspaces
if len(source.Tasks) > 0 {
sink.Tasks = make([]v1beta1.PipelineTask, len(source.Tasks))
for i := range source.Tasks {
if err := source.Tasks[i].ConvertUp(ctx, &sink.Tasks[i]); err != nil {
if err := source.Tasks[i].ConvertTo(ctx, &sink.Tasks[i]); err != nil {
return err
}
}
}
return nil
}

func (source *PipelineTask) ConvertUp(ctx context.Context, sink *v1beta1.PipelineTask) error {
func (source *PipelineTask) ConvertTo(ctx context.Context, sink *v1beta1.PipelineTask) error {
sink.Name = source.Name
sink.TaskRef = source.TaskRef
if source.TaskSpec != nil {
sink.TaskSpec = &v1beta1.TaskSpec{}
if err := source.TaskSpec.ConvertUp(ctx, sink.TaskSpec); err != nil {
if err := source.TaskSpec.ConvertTo(ctx, sink.TaskSpec); err != nil {
return err
}
}
Expand All @@ -71,38 +71,38 @@ func (source *PipelineTask) ConvertUp(ctx context.Context, sink *v1beta1.Pipelin
return nil
}

// ConvertDown implements api.Convertible
func (sink *Pipeline) ConvertDown(ctx context.Context, obj apis.Convertible) error {
// ConvertFrom implements api.Convertible
func (sink *Pipeline) ConvertFrom(ctx context.Context, obj apis.Convertible) error {
switch source := obj.(type) {
case *v1beta1.Pipeline:
sink.ObjectMeta = source.ObjectMeta
return sink.Spec.ConvertDown(ctx, source.Spec)
return sink.Spec.ConvertFrom(ctx, source.Spec)
default:
return fmt.Errorf("unknown version, got: %T", sink)
}
}

func (sink *PipelineSpec) ConvertDown(ctx context.Context, source v1beta1.PipelineSpec) error {
func (sink *PipelineSpec) ConvertFrom(ctx context.Context, source v1beta1.PipelineSpec) error {
sink.Resources = source.Resources
sink.Params = source.Params
sink.Workspaces = source.Workspaces
if len(source.Tasks) > 0 {
sink.Tasks = make([]PipelineTask, len(source.Tasks))
for i := range source.Tasks {
if err := sink.Tasks[i].ConvertDown(ctx, source.Tasks[i]); err != nil {
if err := sink.Tasks[i].ConvertFrom(ctx, source.Tasks[i]); err != nil {
return err
}
}
}
return nil
}

func (sink *PipelineTask) ConvertDown(ctx context.Context, source v1beta1.PipelineTask) error {
func (sink *PipelineTask) ConvertFrom(ctx context.Context, source v1beta1.PipelineTask) error {
sink.Name = source.Name
sink.TaskRef = source.TaskRef
if source.TaskSpec != nil {
sink.TaskSpec = &TaskSpec{}
if err := sink.TaskSpec.ConvertDown(ctx, source.TaskSpec); err != nil {
if err := sink.TaskSpec.ConvertFrom(ctx, source.TaskSpec); err != nil {
return err
}
}
Expand Down
20 changes: 10 additions & 10 deletions pkg/apis/pipeline/v1alpha1/pipeline_conversion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ import (
func TestPipelineConversionBadType(t *testing.T) {
good, bad := &Pipeline{}, &Task{}

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("ConvertUp() = %#v, wanted error", bad)
if err := good.ConvertFrom(context.Background(), bad); err == nil {
t.Errorf("ConvertTo() = %#v, wanted error", bad)
}
}

Expand Down Expand Up @@ -155,18 +155,18 @@ func TestPipelineConversion(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.wantErr {
t.Errorf("ConvertUp() = %v", err)
t.Errorf("ConvertTo() = %v", err)
}
return
}
t.Logf("ConvertUp() = %#v", ver)
t.Logf("ConvertTo() = %#v", ver)
got := &Pipeline{}
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)
}
Expand Down
20 changes: 10 additions & 10 deletions pkg/apis/pipeline/v1alpha1/pipelinerun_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ import (

var _ apis.Convertible = (*PipelineRun)(nil)

// ConvertUp implements api.Convertible
func (source *PipelineRun) ConvertUp(ctx context.Context, obj apis.Convertible) error {
// ConvertTo implements api.Convertible
func (source *PipelineRun) ConvertTo(ctx context.Context, obj apis.Convertible) error {
switch sink := obj.(type) {
case *v1beta1.PipelineRun:
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
}
sink.Status = source.Status
Expand All @@ -42,11 +42,11 @@ func (source *PipelineRun) ConvertUp(ctx context.Context, obj apis.Convertible)
}
}

func (source *PipelineRunSpec) ConvertUp(ctx context.Context, sink *v1beta1.PipelineRunSpec) error {
func (source *PipelineRunSpec) ConvertTo(ctx context.Context, sink *v1beta1.PipelineRunSpec) error {
sink.PipelineRef = source.PipelineRef
if source.PipelineSpec != nil {
sink.PipelineSpec = &v1beta1.PipelineSpec{}
if err := source.PipelineSpec.ConvertUp(ctx, sink.PipelineSpec); err != nil {
if err := source.PipelineSpec.ConvertTo(ctx, sink.PipelineSpec); err != nil {
return err
}
}
Expand All @@ -61,12 +61,12 @@ func (source *PipelineRunSpec) ConvertUp(ctx context.Context, sink *v1beta1.Pipe
return nil
}

// ConvertDown implements api.Convertible
func (sink *PipelineRun) ConvertDown(ctx context.Context, obj apis.Convertible) error {
// ConvertFrom implements api.Convertible
func (sink *PipelineRun) ConvertFrom(ctx context.Context, obj apis.Convertible) error {
switch source := obj.(type) {
case *v1beta1.PipelineRun:
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
}
sink.Status = source.Status
Expand All @@ -76,11 +76,11 @@ func (sink *PipelineRun) ConvertDown(ctx context.Context, obj apis.Convertible)
}
}

func (sink *PipelineRunSpec) ConvertDown(ctx context.Context, source *v1beta1.PipelineRunSpec) error {
func (sink *PipelineRunSpec) ConvertFrom(ctx context.Context, source *v1beta1.PipelineRunSpec) error {
sink.PipelineRef = source.PipelineRef
if source.PipelineSpec != nil {
sink.PipelineSpec = &PipelineSpec{}
if err := sink.PipelineSpec.ConvertDown(ctx, *source.PipelineSpec); err != nil {
if err := sink.PipelineSpec.ConvertFrom(ctx, *source.PipelineSpec); err != nil {
return err
}
}
Expand Down
20 changes: 10 additions & 10 deletions pkg/apis/pipeline/v1alpha1/pipelinerun_conversion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ import (
func TestPipelineRunConversionBadType(t *testing.T) {
good, bad := &PipelineRun{}, &Pipeline{}

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("ConvertUp() = %#v, wanted error", bad)
if err := good.ConvertFrom(context.Background(), bad); err == nil {
t.Errorf("ConvertTo() = %#v, wanted error", bad)
}
}

Expand Down Expand Up @@ -160,18 +160,18 @@ func TestPipelineRunConversion(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.wantErr {
t.Errorf("ConvertUp() = %v", err)
t.Errorf("ConvertTo() = %v", err)
}
return
}
t.Logf("ConvertUp() = %#v", ver)
t.Logf("ConvertTo() = %#v", ver)
got := &PipelineRun{}
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)
}
Expand Down
Loading

0 comments on commit 8e8f9d1

Please sign in to comment.