Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix bugs related to the spec --distribution-spec #772

Merged
merged 2 commits into from
Jan 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cmd/oras/attach.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ Example - Attach file to the manifest tagged 'v1' in an OCI layout folder 'layou
cmd.Flags().StringVarP(&opts.artifactType, "artifact-type", "", "", "artifact type")
cmd.Flags().IntVarP(&opts.concurrency, "concurrency", "", 5, "concurrency level")
cmd.MarkFlagRequired("artifact-type")
opts.EnableDistributionSpecFlag()
option.ApplyFlags(&opts, cmd.Flags())
return cmd
}
Expand Down
5 changes: 4 additions & 1 deletion cmd/oras/internal/option/remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,10 @@ func (opts *Remote) ApplyFlagsWithPrefix(fs *pflag.FlagSet, prefix, description

// Parse tries to read password with optional cmd prompt.
func (opts *Remote) Parse() error {
return opts.readPassword()
if err := opts.readPassword(); err != nil {
return err
}
return opts.distributionSpec.Parse()
}

// readPassword tries to read password with optional cmd prompt.
Expand Down
7 changes: 2 additions & 5 deletions cmd/oras/internal/option/target.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ package option

import (
"context"
"errors"
"fmt"
"os"
"strings"
Expand Down Expand Up @@ -84,13 +83,11 @@ func (opts *Target) Parse() error {
switch {
case opts.isOCILayout:
opts.Type = TargetTypeOCILayout
if opts.Remote.distributionSpec.referrersAPI != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this check cause any bug?

return errors.New("cannot enforce referrers API for image layout target")
}
return nil
default:
opts.Type = TargetTypeRemote
return opts.Remote.Parse()
}
return nil
}

// parseOCILayoutReference parses the raw in format of <path>[:<tag>|@<digest>]
Expand Down