Skip to content
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
4 changes: 4 additions & 0 deletions .golangci.yaml
Original file line numberDiff line numberDiff line change
Expand Up@@ -16,6 +16,7 @@ linters:
- unused
- exhaustruct
- copyloopvar
- forbidigo
settings:
copyloopvar:
check-alias: true
Expand DownExpand Up@@ -72,6 +73,9 @@ linters:
- path: bundle/terranova/tnresources/all_test.go
linters:
- exhaustruct
- path-except: ^cmd

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can this be enabled on libs? That's where you don't want print to stdout/stderr typically (outside of debugging).

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can, but it adds a few more failures. I'd like to keep this small/focused.

linters:
- forbidigo
issues:
max-issues-per-linter: 1000
max-same-issues: 1000
Expand Down
14 changes: 11 additions & 3 deletions cmd/bundle/generate/dashboard.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,6 +6,7 @@ import (
"encoding/json"
"errors"
"fmt"
"io"
"os"
"path"
"path/filepath"
Expand DownExpand Up@@ -53,6 +54,10 @@ type dashboard struct {

// Relative path from the resource directory to the dashboard directory.
relativeDashboardDir string

// Output and error streams.
out io.Writer
err io.Writer
}

func (d *dashboard) resolveID(ctx context.Context, b *bundle.Bundle) string {
Expand DownExpand Up@@ -185,7 +190,7 @@ func (d *dashboard) saveSerializedDashboard(_ context.Context, b *bundle.Bundle,
}
}

fmt.Printf("Writing dashboard to %q\n", rel)
fmt.Fprintf(d.out, "Writing dashboard to %q\n", rel)
return os.WriteFile(filename, data, 0o644)
}

Expand DownExpand Up@@ -229,7 +234,7 @@ func (d *dashboard) saveConfiguration(ctx context.Context, b *bundle.Bundle, das
rel = resourcePath
}

fmt.Printf("Writing configuration to %q\n", rel)
fmt.Fprintf(d.out, "Writing configuration to %q\n", rel)
err = saver.SaveAsYAML(result, resourcePath, d.force)
if err != nil {
return err
Expand DownExpand Up@@ -462,7 +467,10 @@ The --watch flag continuously polls for remote changes and updates your local
bundle files automatically, useful during active dashboard development.`,
}

d := &dashboard{}
d := &dashboard{
out: cmd.OutOrStdout(),
err: cmd.ErrOrStderr(),
}

// Lookup flags.
cmd.Flags().StringVar(&d.existingPath, "existing-path", "", `workspace path of the dashboard to generate configuration for`)
Expand Down
Loading