Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix duplicate warning messages and missing SetOutput(). #216

Merged
merged 2 commits into from Mar 16, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions pkg/compute/build.go
Expand Up @@ -103,6 +103,7 @@ func (c *BuildCommand) Exec(in io.Reader, out io.Writer) (err error) {
progress.Step("Verifying package manifest...")

var m manifest.File
m.SetOutput(c.Globals.Output)
if err := m.Read(ManifestFilename); err != nil {
return fmt.Errorf("error reading package manifest: %w", err)
}
Expand Down
12 changes: 11 additions & 1 deletion pkg/compute/manifest/manifest.go
Expand Up @@ -5,6 +5,7 @@ import (
"os"
"strconv"
"strings"
"sync"

"github.com/fastly/cli/pkg/errors"
"github.com/fastly/cli/pkg/text"
Expand Down Expand Up @@ -34,6 +35,8 @@ const (
SourceFlag
)

var once sync.Once

// Data holds global-ish manifest data from manifest files, and flag sources.
// It has methods to give each parameter to the components that need it,
// including the place the parameter came from, which is a requirement.
Expand Down Expand Up @@ -218,7 +221,14 @@ func (f *File) Read(fpath string) error {
f.ManifestVersion.int = 1

// TODO: Provide link to v1 schema once published publicly.
text.Warning(f.output, "The fastly.toml was missing a `manifest_version` field. A default schema version of `1` will be used.")
//
// NOTE: the use of once is a quick-fix to side-step duplicate outputs.
// To fix this properly will require a refactor of the structure of how our
// global output is passed around.
once.Do(func() {
text.Warning(f.output, "The fastly.toml was missing a `manifest_version` field. A default schema version of `1` will be used.")
text.Break(f.output)
})
}

return nil
Expand Down