Skip to content

Commit

Permalink
refactor: logic clean-up (#955)
Browse files Browse the repository at this point in the history
* refactor(manifest): remove unused Load method

* refactor(main): rename file variable to cfg
  • Loading branch information
Integralist authored Jun 19, 2023
1 parent 8ad6829 commit 45a40df
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 18 deletions.
10 changes: 5 additions & 5 deletions cmd/fastly/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ func main() {
}

// Extract a subset of configuration options from the local application directory.
var file config.File
file.SetAutoYes(autoYes)
file.SetNonInteractive(nonInteractive)
var cfg config.File
cfg.SetAutoYes(autoYes)
cfg.SetNonInteractive(nonInteractive)

// The CLI relies on a valid configuration, otherwise we can't continue.
err := file.Read(config.FilePath, in, out, fsterr.Log, verboseOutput)
err := cfg.Read(config.FilePath, in, out, fsterr.Log, verboseOutput)
if err != nil {
fsterr.Deduce(err).Print(color.Error)

Expand All @@ -88,7 +88,7 @@ func main() {
opts := app.RunOpts{
APIClient: clientFactory,
Args: args,
ConfigFile: file,
ConfigFile: cfg,
ConfigPath: config.FilePath,
Env: env,
ErrLog: fsterr.Log,
Expand Down
13 changes: 0 additions & 13 deletions pkg/manifest/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,6 @@ func (f *File) Exists() bool {
return f.exists
}

// Load parses the input data into the File struct and persists it to disk.
//
// NOTE: This is used by the `compute build` command logic.
// Which has to modify the toml tree for supporting a v4.0.0 migration path.
// e.g. if user manifest is missing [scripts.build] then add a default value.
func (f *File) Load(data []byte) error {
err := toml.Unmarshal(data, f)
if err != nil {
return fmt.Errorf("error unmarshaling fastly.toml: %w", err)
}
return f.Write(Filename)
}

// Read loads the manifest file content from disk.
func (f *File) Read(path string) (err error) {
defer func() {
Expand Down

0 comments on commit 45a40df

Please sign in to comment.