From f7a7233811ca5f12dc8552ba9ffe821e207108c7 Mon Sep 17 00:00:00 2001 From: Aldo Lacuku Date: Thu, 31 Aug 2023 15:06:21 +0200 Subject: [PATCH 1/2] fix(cmd/info): handle "context canceled" errors The command should exit when the context is canceled by a termination signal. In such case the command prints the reason why it exited. Furthermore, the table header is printed to stdout only when data is found for the artifacts. Signed-off-by: Aldo Lacuku --- cmd/artifact/info/info.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/cmd/artifact/info/info.go b/cmd/artifact/info/info.go index f1bf2a62..45b78097 100644 --- a/cmd/artifact/info/info.go +++ b/cmd/artifact/info/info.go @@ -16,6 +16,7 @@ package info import ( "context" + "errors" "fmt" "strings" @@ -90,14 +91,22 @@ func (o *artifactInfoOptions) RunArtifactInfo(ctx context.Context, args []string } tags, err := repo.Tags(ctx) - if err != nil { - o.Printer.Warning.Printfln("cannot retrieve tags from %q, %v", ref, err) + if err != nil && !errors.Is(err, context.Canceled) { + o.Printer.Warning.Printfln("cannot retrieve tags from t %q, %v", ref, err) continue + } else if errors.Is(err, context.Canceled) { + // When the context is canceled we exit, since we receive a termination signal. + return err } joinedTags := strings.Join(tags, ", ") data = append(data, []string{ref, joinedTags}) } - return o.Printer.PrintTable(output.ArtifactInfo, data) + // Print the table header + data only if there is data. + if len(data) > 0 { + return o.Printer.PrintTable(output.ArtifactInfo, data) + } + + return nil } From 69e39f4342f011276f747b4d4e437131d1bfc888 Mon Sep 17 00:00:00 2001 From: Aldo Lacuku Date: Thu, 31 Aug 2023 16:05:31 +0200 Subject: [PATCH 2/2] update(linter): bump golangci-lint action to v3.7.0 Signed-off-by: Aldo Lacuku --- .github/workflows/lint.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index c0ba718e..f6b3638a 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -22,10 +22,10 @@ jobs: cache: 'false' - name: golangci-lint - uses: golangci/golangci-lint-action@08e2f20817b15149a52b5b3ebe7de50aff2ba8c5 # v3.4.0 + uses: golangci/golangci-lint-action@3a919529898de77ec3da873e3063ca4b10e7f5cc # v3.7.0 with: only-new-issues: true - version: v1.52 + version: v1.54.2 args: --timeout=900s gomodtidy: