Skip to content

Commit

Permalink
Add some verbosity for CLI (#244)
Browse files Browse the repository at this point in the history
In some case it could be not trivial why CLI could fail. So adding some
verbosity to logs

Signed-off-by: Igor Shishkin <me@teran.dev>
  • Loading branch information
teran authored Oct 5, 2024
1 parent 330e70c commit 3b4b80c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cli/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ func (s *service) DeleteContainer(namespaceName, containerName string) func(ctx

func (s *service) CreateVersion(namespaceName, containerName string, shouldPublish bool, fromDir, fromYumRepo, rpmGPGKey, rpmGPGKeyChecksum *string) func(ctx context.Context) error {
return func(ctx context.Context) error {
log.Tracef("creating version ...")
resp, err := s.cli.CreateVersion(ctx, &v1proto.CreateVersionRequest{
Namespace: namespaceName,
Container: containerName,
Expand All @@ -202,6 +203,7 @@ func (s *service) CreateVersion(namespaceName, containerName string, shouldPubli
}

versionID := resp.GetVersion()
log.Tracef("version created: `%s`", versionID)

if fromDir != nil && *fromDir != "" {
log.Tracef("--from-dir is requested with `%s`", *fromDir)
Expand All @@ -213,6 +215,7 @@ func (s *service) CreateVersion(namespaceName, containerName string, shouldPubli
log.Tracef("--from-yum-repo is requested with `%s`", *fromYumRepo)
var gpgKeyring openpgp.EntityList = nil
if *rpmGPGKey != "" {
log.Tracef("RPM GPG Key was passed so initialing GPG keyring ...")
gpgKeyring, err = getGPGKey(ctx, *rpmGPGKey, rpmGPGKeyChecksum)
if err != nil {
return err
Expand All @@ -226,6 +229,7 @@ func (s *service) CreateVersion(namespaceName, containerName string, shouldPubli
}

if shouldPublish {
log.Tracef("publishing is requested so publishing version ...")
_, err = s.cli.PublishVersion(ctx, &v1proto.PublishVersionRequest{
Namespace: namespaceName,
Container: containerName,
Expand Down
5 changes: 5 additions & 0 deletions cmd/cli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,5 +265,10 @@ func normalizeHomeDir(in string) (out string) {
if strings.HasPrefix(in, "~/") {
out = filepath.Join(dir, in[2:])
}

log.WithFields(log.Fields{
"function": "normalizeHomeDir",
}).Tracef("`%s` resolved to `%s`", in, out)

return out
}

0 comments on commit 3b4b80c

Please sign in to comment.