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

Surface better error messages in crane index #1722

Merged
merged 1 commit into from
Jun 5, 2023
Merged
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
18 changes: 16 additions & 2 deletions cmd/crane/cmd/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,17 @@ func NewCmdIndexFilter(options *[]crane.Option) *cobra.Command {
if err != nil {
return err
}
base, err := remote.Index(ref, o.Remote...)
desc, err := remote.Get(ref, o.Remote...)
if err != nil {
return fmt.Errorf("pulling %s: %w", baseRef, err)
}
if !desc.MediaType.IsIndex() {
return fmt.Errorf("expected %s to be an index, got %q", baseRef, desc.MediaType)
}
base, err := desc.ImageIndex()
if err != nil {
return nil
}

idx := filterIndex(base, platforms.platforms)

Expand Down Expand Up @@ -153,10 +160,17 @@ The platform for appended manifests is inferred from the config file or omitted
if err != nil {
return err
}
base, err = remote.Index(ref, o.Remote...)
desc, err := remote.Get(ref, o.Remote...)
if err != nil {
return fmt.Errorf("pulling %s: %w", baseRef, err)
}
if !desc.MediaType.IsIndex() {
return fmt.Errorf("expected %s to be an index, got %q", baseRef, desc.MediaType)
}
base, err = desc.ImageIndex()
if err != nil {
return err
}
}

adds := make([]mutate.IndexAddendum, 0, len(newManifests))
Expand Down
Loading