diff --git a/pkg/porter/lifecycle.go b/pkg/porter/lifecycle.go index 6f04eef21..3f3c21bce 100644 --- a/pkg/porter/lifecycle.go +++ b/pkg/porter/lifecycle.go @@ -4,6 +4,7 @@ import ( "context" "errors" "fmt" + "io" "strings" "get.porter.sh/porter/pkg/cache" @@ -198,7 +199,7 @@ func (p *Porter) resolveBundleReference(ctx context.Context, opts *BundleReferen pullOpts := *opts // make a copy just to do the pull pullOpts.Reference = ref.String() - err := ensureVPrefix(&pullOpts) + err := ensureVPrefix(&pullOpts, p.Out) if err != nil { return err } @@ -309,7 +310,7 @@ func (p *Porter) BuildActionArgs(ctx context.Context, installation storage.Insta // Version tag should always be prefixed with a "v", see https://github.com/getporter/porter/issues/2886. // This is safe because "porter publish" adds a "v", see // https://github.com/getporter/porter/blob/17bd7816ef6bde856793f6122e32274aa9d01d1b/pkg/storage/installation.go#L350 -func ensureVPrefix(opts *BundleReferenceOptions) error { +func ensureVPrefix(opts *BundleReferenceOptions, out io.Writer) error { var ociRef *cnab.OCIReference if opts._ref != nil { ociRef = opts._ref @@ -332,6 +333,7 @@ func ensureVPrefix(opts *BundleReferenceOptions) error { } // always update the .Reference string, but don't add the _ref field unless it was already there (non-nil) + fmt.Fprintf(out, "WARNING: using reference %q instead of %q because missing v-prefix on tag\n", vRef.String(), ociRef.String()) opts.Reference = vRef.String() if opts._ref != nil { opts._ref = &vRef diff --git a/pkg/porter/lifecycle_test.go b/pkg/porter/lifecycle_test.go index 60fd2963d..b44cb22f0 100644 --- a/pkg/porter/lifecycle_test.go +++ b/pkg/porter/lifecycle_test.go @@ -3,6 +3,7 @@ package porter import ( "context" "fmt" + "os" "strings" "testing" @@ -585,7 +586,7 @@ func Test_ensureVPrefix(t *testing.T) { assert.False(t, tt.args.opts._ref.Tag()[0] == 'v') } - err := ensureVPrefix(tt.args.opts) + err := ensureVPrefix(tt.args.opts, os.Stdout) // after tt.wantErr(t, err, fmt.Sprintf("ensureVPrefix(%v)", tt.args.opts)) @@ -653,7 +654,7 @@ func Test_ensureVPrefix_idempotent(t *testing.T) { assert.True(t, tt.args.opts._ref.Tag()[1] != 'v') } - err := ensureVPrefix(tt.args.opts) + err := ensureVPrefix(tt.args.opts, os.Stdout) // after tt.wantErr(t, err, fmt.Sprintf("ensureVPrefix(%v)", tt.args.opts)) @@ -686,7 +687,7 @@ func Test_ensureVPrefix_latest(t *testing.T) { bundleRef: nil, } - err := ensureVPrefix(&opts) + err := ensureVPrefix(&opts, os.Stdout) assert.NoError(t, err) // should be unchanged @@ -711,7 +712,7 @@ func Test_ensureVPrefix_missing_tag(t *testing.T) { bundleRef: nil, } - err := ensureVPrefix(&opts) + err := ensureVPrefix(&opts, os.Stdout) assert.NoError(t, err) // should be unchanged