diff --git a/pkg/commands/compute/build.go b/pkg/commands/compute/build.go index a89584dd4..6520e359c 100644 --- a/pkg/commands/compute/build.go +++ b/pkg/commands/compute/build.go @@ -181,7 +181,7 @@ func (c *BuildCommand) Exec(in io.Reader, out io.Writer) (err error) { progress.Done() if toolchain == "custom" { - if !c.Globals.Flag.AutoYes || !c.Globals.Flag.NonInteractive { + if !c.Globals.Flag.AutoYes && !c.Globals.Flag.NonInteractive { // NOTE: A third-party could share a project with a build command for a // language that wouldn't normally require one (e.g. Rust), and do evil // things. So we should notify the user and confirm they would like to @@ -193,7 +193,7 @@ func (c *BuildCommand) Exec(in io.Reader, out io.Writer) (err error) { } } - if c.Globals.Verbose() && (!c.Globals.Flag.AutoYes || !c.Globals.Flag.NonInteractive) { + if c.Globals.Verbose() && (!c.Globals.Flag.AutoYes && !c.Globals.Flag.NonInteractive) { text.Break(out) } @@ -201,7 +201,7 @@ func (c *BuildCommand) Exec(in io.Reader, out io.Writer) (err error) { progress.Step(fmt.Sprintf("Building package using %s toolchain...", toolchain)) postBuildCallback := func() error { - if !c.Globals.Flag.AutoYes || !c.Globals.Flag.NonInteractive { + if !c.Globals.Flag.AutoYes && !c.Globals.Flag.NonInteractive { err := promptForBuildContinue(CustomPostBuildScriptMessage, c.Manifest.File.Scripts.PostBuild, out, in, c.Globals.Verbose()) if err != nil { return err diff --git a/pkg/commands/compute/build_test.go b/pkg/commands/compute/build_test.go index fc8b8ffd8..39a5e8db7 100644 --- a/pkg/commands/compute/build_test.go +++ b/pkg/commands/compute/build_test.go @@ -689,7 +689,7 @@ func TestCustomBuild(t *testing.T) { }, { name: "avoid prompt confirmation", - args: args("compute build --accept-custom-build --language other"), + args: args("compute build --auto-yes --language other"), fastlyManifest: ` manifest_version = 2 name = "test" @@ -856,7 +856,7 @@ func TestCustomPostBuild(t *testing.T) { }, { name: "avoid prompt confirmation", - args: args("compute build --accept-custom-build"), + args: args("compute build --auto-yes"), applicationConfig: config.File{ Language: config.Language{ Rust: config.Rust{ diff --git a/pkg/commands/compute/deploy.go b/pkg/commands/compute/deploy.go index f8b9aba1e..d494bb5fa 100644 --- a/pkg/commands/compute/deploy.go +++ b/pkg/commands/compute/deploy.go @@ -194,9 +194,8 @@ func (c *DeployCommand) Exec(in io.Reader, out io.Writer) (err error) { } loggers = &setup.Loggers{ - AcceptDefaults: c.Globals.Flag.AcceptDefaults, - Setup: c.Manifest.File.Setup.Loggers, - Stdout: out, + Setup: c.Manifest.File.Setup.Loggers, + Stdout: out, } } @@ -558,7 +557,7 @@ func manageNoServiceIDFlow( manifestFile *manifest.File, activateTrial activator, ) (serviceID string, serviceVersion *fastly.Version, err error) { - if !globalFlags.AutoYes || !globalFlags.NonInteractive { + if !globalFlags.AutoYes && !globalFlags.NonInteractive { text.Break(out) text.Output(out, "There is no Fastly service associated with this package. To connect to an existing service add the Service ID to the fastly.toml file, otherwise follow the prompts to create a service now.") text.Break(out) diff --git a/pkg/commands/compute/deploy_test.go b/pkg/commands/compute/deploy_test.go index 814b9c0bc..c19dc90f8 100644 --- a/pkg/commands/compute/deploy_test.go +++ b/pkg/commands/compute/deploy_test.go @@ -694,10 +694,10 @@ func TestDeploy(t *testing.T) { }, }, // The following test validates no prompts are displayed to the user due to - // the use of the --accept-defaults flag. + // the use of the --non-interactive flag. { name: "success with setup.backends configuration and accept-defaults", - args: args("compute deploy --accept-defaults --token 123"), + args: args("compute deploy --non-interactive --token 123"), api: mock.API{ ActivateVersionFn: activateVersionOk, CreateBackendFn: createBackendOK, @@ -740,13 +740,13 @@ func TestDeploy(t *testing.T) { }, // The following test validates that a new 'originless' backend is created // when the user has no [setup] configuration and they also pass the - // --accept-defaults flag. This is done by ensuring we DON'T see the + // --non-interactive flag. This is done by ensuring we DON'T see the // standard 'Creating backend' output because we want to conceal the fact // that we require a backend for compute services because it's a temporary // implementation detail. { - name: "success with no setup.backends configuration and --accept-defaults for new service creation", - args: args("compute deploy --accept-defaults --token 123"), + name: "success with no setup.backends configuration and non-interactive for new service creation", + args: args("compute deploy --non-interactive --token 123"), api: mock.API{ ActivateVersionFn: activateVersionOk, CreateBackendFn: createBackendOK, @@ -852,10 +852,10 @@ func TestDeploy(t *testing.T) { }, }, // The following test is the same setup as above, but if the user provides - // the --accept-defaults flag we won't prompt for any backends. + // the --non-interactive flag we won't prompt for any backends. { - name: "success with no setup.backends configuration and use of --accept-defaults", - args: args("compute deploy --accept-defaults --token 123"), + name: "success with no setup.backends configuration and use of --non-interactive", + args: args("compute deploy --non-interactive --token 123"), api: mock.API{ ActivateVersionFn: activateVersionOk, CreateBackendFn: createBackendOK, @@ -1012,8 +1012,8 @@ func TestDeploy(t *testing.T) { }, }, { - name: "success with setup.dictionaries configuration and no existing service and --accept-defaults", - args: args("compute deploy --accept-defaults --token 123"), + name: "success with setup.dictionaries configuration and no existing service and --non-interactive", + args: args("compute deploy --non-interactive --token 123"), api: mock.API{ ActivateVersionFn: activateVersionOk, CreateBackendFn: createBackendOK, @@ -1218,8 +1218,8 @@ func TestDeploy(t *testing.T) { }, }, { - name: "success with setup.log_entries configuration and no existing service and --accept-defaults", - args: args("compute deploy --accept-defaults --token 123"), + name: "success with setup.log_entries configuration and no existing service, but a provider defined", + args: args("compute deploy --token 123"), api: mock.API{ ActivateVersionFn: activateVersionOk, CreateBackendFn: createBackendOK, @@ -1246,16 +1246,14 @@ func TestDeploy(t *testing.T) { "Y", // when prompted to create a new service }, wantOutput: []string{ - "Uploading package...", - "Activating version...", - "SUCCESS: Deployed package (service 12345, version 1)", - }, - dontWantOutput: []string{ "The package code requires the following log endpoints to be created.", "Name: foo", "Provider: BigQuery", "Refer to the help documentation for each provider (if no provider shown, then select your own):", "fastly logging create --help", + "Uploading package...", + "Activating version...", + "SUCCESS: Deployed package (service 12345, version 1)", }, }, } { @@ -1268,7 +1266,7 @@ func TestDeploy(t *testing.T) { if testcase.manifest != "" { manifestContent = testcase.manifest } - if err := os.WriteFile(filepath.Join(rootdir, manifest.Filename), []byte(manifestContent), 0777); err != nil { + if err := os.WriteFile(filepath.Join(rootdir, manifest.Filename), []byte(manifestContent), 0o777); err != nil { t.Fatal(err) } diff --git a/pkg/commands/compute/setup/loggers.go b/pkg/commands/compute/setup/loggers.go index c0e60621e..73cac3b15 100644 --- a/pkg/commands/compute/setup/loggers.go +++ b/pkg/commands/compute/setup/loggers.go @@ -12,9 +12,8 @@ import ( // // NOTE: It implements the setup.Interface interface. type Loggers struct { - AcceptDefaults bool - Setup map[string]*manifest.SetupLogger - Stdout io.Writer + Setup map[string]*manifest.SetupLogger + Stdout io.Writer } // Logger represents the configuration parameters for creating a dictionary @@ -25,26 +24,24 @@ type Logger struct { // Configure prompts the user for specific values related to the service resource. func (l *Loggers) Configure() error { - if !l.AcceptDefaults { - text.Break(l.Stdout) - text.Info(l.Stdout, "The package code requires the following log endpoints to be created.") - text.Break(l.Stdout) - - for name, settings := range l.Setup { - text.Output(l.Stdout, "%s %s", text.Bold("Name:"), name) - if settings.Provider != "" { - text.Output(l.Stdout, "%s %s", text.Bold("Provider:"), settings.Provider) - } - text.Break(l.Stdout) + text.Break(l.Stdout) + text.Info(l.Stdout, "The package code requires the following log endpoints to be created.") + text.Break(l.Stdout) + + for name, settings := range l.Setup { + text.Output(l.Stdout, "%s %s", text.Bold("Name:"), name) + if settings.Provider != "" { + text.Output(l.Stdout, "%s %s", text.Bold("Provider:"), settings.Provider) } - - text.Description( - l.Stdout, - "Refer to the help documentation for each provider (if no provider shown, then select your own)", - "fastly logging create --help", - ) + text.Break(l.Stdout) } + text.Description( + l.Stdout, + "Refer to the help documentation for each provider (if no provider shown, then select your own)", + "fastly logging create --help", + ) + return nil }