Skip to content
This repository was archived by the owner on Mar 24, 2025. It is now read-only.
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
17 changes: 12 additions & 5 deletions cmd/rig/cmd/capsule/list_builds.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,12 @@ func CapsuleListBuilds(ctx context.Context, cmd *cobra.Command, capsuleID Capsul
}

t := table.NewWriter()
t.AppendHeader(table.Row{fmt.Sprintf("Builds (%d)", resp.Msg.GetTotal()), "Created At", "Repository", "Tag", "Created By"})
t.AppendHeader(table.Row{fmt.Sprintf("Builds (%d)", resp.Msg.GetTotal()), "Digest", "Age", "Created By"})
for _, b := range resp.Msg.GetBuilds() {
t.AppendRow(table.Row{
b.GetBuildId(),
b.GetCreatedAt().AsTime().Format(time.RFC822),
truncated(b.GetRepository(), 64),
truncated(b.GetTag(), 64),
fmt.Sprint(b.GetRepository(), ":", b.GetTag()),
truncatedFixed(b.GetDigest(), 19),
time.Since(b.GetCreatedAt().AsTime()).Truncate(time.Second),
b.GetCreatedBy().GetPrintableName(),
})
}
Expand All @@ -60,3 +59,11 @@ func truncated(str string, max int) string {

return str
}

func truncatedFixed(str string, max int) string {
if len(str) > max {
return str[:max] + "..."
}

return str
}
15 changes: 12 additions & 3 deletions internal/service/capsule/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package capsule

import (
"context"
"fmt"

"github.com/google/go-containerregistry/pkg/authn"
"github.com/google/go-containerregistry/pkg/name"
Expand Down Expand Up @@ -46,10 +47,18 @@ func (s *Service) CreateBuild(ctx context.Context, capsuleID string, image, dige
return "", err
}

idRef := ref
if digest != "" {
idRef, err = name.NewDigest(fmt.Sprintf("%s@%s", ref.Context().String(), digest))
if err != nil {
return "", err
}
}

b := &capsule.Build{
BuildId: ref.Name(),
BuildId: idRef.Name(),
Digest: digest,
Repository: ref.Context().RepositoryStr(),
Repository: ref.Context().String(),
Tag: ref.Identifier(),
CreatedBy: by,
CreatedAt: timestamppb.Now(),
Expand All @@ -61,7 +70,7 @@ func (s *Service) CreateBuild(ctx context.Context, capsuleID string, image, dige
return "", err
}

return ref.Name(), nil
return idRef.Name(), nil
}

func (s *Service) ListBuilds(ctx context.Context, capsuleID string, pagination *model.Pagination) (iterator.Iterator[*capsule.Build], uint64, error) {
Expand Down
5 changes: 5 additions & 0 deletions pkg/api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.