Skip to content

Commit

Permalink
band-aid for store info... needs love
Browse files Browse the repository at this point in the history
Signed-off-by: Adam Martin <[email protected]>
  • Loading branch information
amartin120 committed Oct 21, 2023
1 parent d9f2b23 commit e0a1d13
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions cmd/hauler/cli/store/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ func InfoCmd(ctx context.Context, o *InfoOpts, s *store.Layout) error {
if _, ok := desc.Annotations[ocispec.AnnotationRefName]; !ok {
return nil
}

rc, err := s.Fetch(ctx, desc)
if err != nil {
return err
Expand All @@ -49,9 +48,11 @@ func InfoCmd(ctx context.Context, o *InfoOpts, s *store.Layout) error {
if err := json.NewDecoder(rc).Decode(&m); err != nil {
return err
}

i := newItem(s, desc, m)
items = append(items, i)
var emptyItem item
if i != emptyItem {
items = append(items, i)
}

return nil
}); err != nil {
Expand All @@ -78,7 +79,7 @@ func buildTable(items ...item) string {
fmt.Fprintf(tw, "---------\t----\t--------\t----\n")

for _, i := range items {
if i.Type != "unknown" {
if i.Type != "" {
fmt.Fprintf(tw, "%s\t%s\t%d\t%s\n",
i.Reference, i.Type, i.Layers, i.Size,
)
Expand All @@ -104,6 +105,10 @@ type item struct {
}

func newItem(s *store.Layout, desc ocispec.Descriptor, m ocispec.Manifest) item {
if desc.Annotations["kind"] == "dev.cosignproject.cosign/atts" || desc.Annotations["kind"] == "dev.cosignproject.cosign/sigs" {
return item{}
}

var size int64 = 0
for _, l := range m.Layers {
size = +l.Size
Expand All @@ -116,10 +121,10 @@ func newItem(s *store.Layout, desc ocispec.Descriptor, m ocispec.Manifest) item
ctype = "image"
case consts.ChartConfigMediaType:
ctype = "chart"
case consts.FileLocalConfigMediaType, consts.FileHttpConfigMediaType, consts.OCIArtifact:
case consts.FileLocalConfigMediaType, consts.FileHttpConfigMediaType:
ctype = "file"
default:
ctype = "unknown"
ctype = "image"
}

ref, err := reference.Parse(desc.Annotations[ocispec.AnnotationRefName])
Expand Down

0 comments on commit e0a1d13

Please sign in to comment.