Thanks to visit codestin.com
Credit goes to github.com

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
7 changes: 5 additions & 2 deletions pkg/commands/compute/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ func (c *DeployCommand) Exec(in io.Reader, out io.Writer) (err error) {
domains := &setup.Domains{
APIClient: apiClient,
AcceptDefaults: c.Globals.Flag.AcceptDefaults,
NonInteractive: c.Globals.Flag.NonInteractive,
PackageDomain: c.Domain,
ServiceID: serviceID,
ServiceVersion: serviceVersion.Number,
Expand All @@ -177,6 +178,7 @@ func (c *DeployCommand) Exec(in io.Reader, out io.Writer) (err error) {
backends = &setup.Backends{
APIClient: apiClient,
AcceptDefaults: c.Globals.Flag.AcceptDefaults,
NonInteractive: c.Globals.Flag.NonInteractive,
ServiceID: serviceID,
ServiceVersion: serviceVersion.Number,
Setup: c.Manifest.File.Setup.Backends,
Expand All @@ -187,6 +189,7 @@ func (c *DeployCommand) Exec(in io.Reader, out io.Writer) (err error) {
dictionaries = &setup.Dictionaries{
APIClient: apiClient,
AcceptDefaults: c.Globals.Flag.AcceptDefaults,
NonInteractive: c.Globals.Flag.NonInteractive,
ServiceID: serviceID,
ServiceVersion: serviceVersion.Number,
Setup: c.Manifest.File.Setup.Dictionaries,
Expand Down Expand Up @@ -416,8 +419,8 @@ func validatePackage(data manifest.Data, packageFlag string, errLog fsterr.LogIn
}
}
contents := map[string]*bytes.Buffer{
"fastly.toml": &bytes.Buffer{},
"main.wasm": &bytes.Buffer{},
"fastly.toml": {},
"main.wasm": {},
}
if err := validate(pkgPath, func(f archiver.File) error {
switch fname := f.Name(); fname {
Expand Down
2 changes: 1 addition & 1 deletion pkg/commands/compute/deploy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,7 @@ func TestDeploy(t *testing.T) {
// The following test validates no prompts are displayed to the user due to
// the use of the --non-interactive flag.
{
name: "success with setup.backends configuration and accept-defaults",
name: "success with setup.backends configuration and non-interactive",
args: args("compute deploy --non-interactive --token 123"),
api: mock.API{
ActivateVersionFn: activateVersionOk,
Expand Down
9 changes: 5 additions & 4 deletions pkg/commands/compute/setup/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ type Backends struct {
// Public
APIClient api.Interface
AcceptDefaults bool
NonInteractive bool
Progress text.Progress
ServiceID string
ServiceVersion int
Expand Down Expand Up @@ -104,7 +105,7 @@ func (b *Backends) isOriginless() bool {
func (b *Backends) checkPredefined() error {
var i int
for name, settings := range b.Setup {
if !b.AcceptDefaults {
if !b.AcceptDefaults && !b.NonInteractive {
if i > 0 {
text.Break(b.Stdout)
}
Expand All @@ -128,7 +129,7 @@ func (b *Backends) checkPredefined() error {

prompt := text.BoldYellow(fmt.Sprintf("Hostname or IP address: [%s] ", defaultAddress))

if !b.AcceptDefaults {
if !b.AcceptDefaults && !b.NonInteractive {
addr, err = text.Input(b.Stdout, prompt, b.Stdin, b.validateAddress)
if err != nil {
return fmt.Errorf("error reading prompt input: %w", err)
Expand All @@ -142,7 +143,7 @@ func (b *Backends) checkPredefined() error {
if settings.Port > 0 {
port = settings.Port
}
if !b.AcceptDefaults {
if !b.AcceptDefaults && !b.NonInteractive {
input, err := text.Input(b.Stdout, text.BoldYellow(fmt.Sprintf("Port: [%d] ", port)), b.Stdin)
if err != nil {
return fmt.Errorf("error reading prompt input: %w", err)
Expand Down Expand Up @@ -173,7 +174,7 @@ func (b *Backends) checkPredefined() error {
// promptForBackend issues a prompt requesting one or more Backends that will
// be created within the user's service.
func (b *Backends) promptForBackend() error {
if b.AcceptDefaults {
if b.AcceptDefaults || b.NonInteractive {
b.required = append(b.required, b.createOriginlessBackend())
return nil
}
Expand Down
5 changes: 3 additions & 2 deletions pkg/commands/compute/setup/dictionary.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type Dictionaries struct {
// Public
APIClient api.Interface
AcceptDefaults bool
NonInteractive bool
Progress text.Progress
ServiceID string
ServiceVersion int
Expand Down Expand Up @@ -49,7 +50,7 @@ type DictionaryItem struct {
// Configure prompts the user for specific values related to the service resource.
func (d *Dictionaries) Configure() error {
for name, settings := range d.Setup {
if !d.AcceptDefaults {
if !d.AcceptDefaults && !d.NonInteractive {
text.Break(d.Stdout)
text.Output(d.Stdout, "Configuring dictionary '%s'", name)
if settings.Description != "" {
Expand All @@ -71,7 +72,7 @@ func (d *Dictionaries) Configure() error {
err error
)

if !d.AcceptDefaults {
if !d.AcceptDefaults && !d.NonInteractive {
text.Break(d.Stdout)
text.Output(d.Stdout, "Create a dictionary key called '%s'", key)
if item.Description != "" {
Expand Down
3 changes: 2 additions & 1 deletion pkg/commands/compute/setup/domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ type Domains struct {
// Public
APIClient api.Interface
AcceptDefaults bool
NonInteractive bool
PackageDomain string
Progress text.Progress
ServiceID string
Expand Down Expand Up @@ -64,7 +65,7 @@ func (d *Domains) Configure() error {
domain string
err error
)
if !d.AcceptDefaults {
if !d.AcceptDefaults && !d.NonInteractive {
domain, err = text.Input(d.Stdout, text.BoldYellow(fmt.Sprintf("Domain: [%s] ", defaultDomain)), d.Stdin, d.validateDomain)
if err != nil {
return fmt.Errorf("error reading input %w", err)
Expand Down