Skip to content
Open
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
- feat(stats): add `stats domain-inspector` subcommand for domain-level metrics. [#1678](https://github.com/fastly/cli/pull/1678)
- feat(stats): add `stats origin-inspector` subcommand for origin-level metrics. [#1678](https://github.com/fastly/cli/pull/1678)

- feat(compute/deploy): Apply \[setup.products] for enabling products during initial deploy ([#1617](https://github.com/fastly/cli/pull/1617))

### Dependencies:
- build(deps): `golang.org/x/net` from 0.50.0 to 0.51.0 ([#1674](https://github.com/fastly/cli/pull/1674))
- build(deps): `actions/upload-artifact` from 6 to 7 ([#1675](https://github.com/fastly/cli/pull/1675))
Expand Down
31 changes: 31 additions & 0 deletions pkg/commands/compute/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -817,6 +817,7 @@ type ServiceResources struct {
objectStores *setup.KVStores
kvStores *setup.KVStores
secretStores *setup.SecretStores
products *setup.Products
}

// ConstructNewServiceResources instantiates multiple [setup] config resources for a
Expand Down Expand Up @@ -887,6 +888,17 @@ func (c *DeployCommand) ConstructNewServiceResources(
Stdin: in,
Stdout: out,
}

sr.products = &setup.Products{
APIClient: c.Globals.APIClient,
AcceptDefaults: c.Globals.Flags.AcceptDefaults,
NonInteractive: c.Globals.Flags.NonInteractive,
ServiceID: serviceID,
ServiceVersion: serviceVersion,
Setup: c.Globals.Manifest.File.Setup.Products,
Stdin: in,
Stdout: out,
}
}

// ConfigureServiceResources calls the .Predefined() and .Configure() methods
Expand Down Expand Up @@ -941,6 +953,13 @@ func (c *DeployCommand) ConfigureServiceResources(sr ServiceResources, serviceID
}
}

if sr.products.Predefined() {
if err := sr.products.Configure(); err != nil {
errLogService(c.Globals.ErrLog, err, serviceID, serviceVersion)
return fmt.Errorf("error configuring service products: %w", err)
}
}

return nil
}

Expand All @@ -957,6 +976,7 @@ func (c *DeployCommand) CreateServiceResources(
sr.objectStores.Spinner = spinner
sr.kvStores.Spinner = spinner
sr.secretStores.Spinner = spinner
sr.products.Spinner = spinner

if err := sr.backends.Create(); err != nil {
c.Globals.ErrLog.AddWithContext(err, map[string]any{
Expand Down Expand Up @@ -1013,6 +1033,17 @@ func (c *DeployCommand) CreateServiceResources(
return err
}

if err := sr.products.Create(); err != nil {
c.Globals.ErrLog.AddWithContext(err, map[string]any{
"Accept defaults": c.Globals.Flags.AcceptDefaults,
"Auto-yes": c.Globals.Flags.AutoYes,
"Non-interactive": c.Globals.Flags.NonInteractive,
"Service ID": serviceID,
"Service Version": serviceVersion,
})
return err
}
Copy link
Member

Choose a reason for hiding this comment

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

This fixes the test and passes CI:

if sr.products.Predefined() {
	if err := sr.products.Create(); err != nil {
		c.Globals.ErrLog.AddWithContext(err, map[string]any{
			"Accept defaults": c.Globals.Flags.AcceptDefaults,
			"Auto-yes":        c.Globals.Flags.AutoYes,
			"Non-interactive": c.Globals.Flags.NonInteractive,
			"Service ID":      serviceID,
			"Service Version": serviceVersion,
		})
		return err
	}
}

Copy link
Member Author

Choose a reason for hiding this comment

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

I looked at it again and I think that's actually not the problem. The problem is that in a test,
p.APIClient is not *fastly.Client, so this cast fails:

fc, ok := p.APIClient.(*fastly.Client)

For this particular test, the anyEnabled I'm adding next should fix it


return nil
}

Expand Down
Loading
Loading