Add [setup.products] support to fastly compute deploy/publish#1617
Add [setup.products] support to fastly compute deploy/publish#1617
Conversation
philippschulte
left a comment
There was a problem hiding this comment.
LGTM!
I would only suggest adding more tests:
- to trigger a validation failure
- that verifies disabled or omitted products are ignored
But I keep this up to you! Thanks!
41a1898 to
8c72c4f
Compare
|
I've reverted this to draft, so I can add some tests. |
9a1b749 to
90a95d7
Compare
90a95d7 to
48b9b2c
Compare
|
In order to work with some of the newer These mocks provide an object that implements I've now added new test cases to make sure that when Products is provided then the appropriate API calls are made. There are no validation checks because users are free to write anything in their toml files, except if there are type mismatches then those should be enforced during reading. DetailsThe new mocks can be used like this: Create a This can then be passed to This can be safely passed to functions like And, as After running tests, you can assert on requests that have been recorded: I've also made a Then you can use it perhaps in a loop like this: NoteThe existing It may be desirable to migrate tests to |
philippschulte
left a comment
There was a problem hiding this comment.
TestDeploy_ActivateBeacon fails with:
want "error activating version:", have "failed to convert interface to a fastly client"
In pkg/commands/compute/deploy.go, you added:
if err := sr.products.Create(); err != nil { ... }The problem is that this statement is unconditional!
| "Service Version": serviceVersion, | ||
| }) | ||
| return err | ||
| } |
There was a problem hiding this comment.
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
}
}There was a problem hiding this comment.
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
pkg/mock/client.go
Outdated
| } | ||
|
|
||
| // NewHTTPClientWithErrors returns a mock HTTP Client that returns stubbed response and | ||
| // no errors, and saves requests. |
There was a problem hiding this comment.
I don't think the comment matches the function's signature.
ddf9b80 to
6d6d1cc
Compare
This PR adds first-class support for enabling Fastly Products during the initial
fastly compute publish, driven by a new[setup.products]section infastly.toml.What this enables
On first publish (service creation only), users can now declaratively enable products such as Fanout, API Discovery, NGWAF, etc., alongside other
[setup]resources.Example:
Key points
New manifest schema
SetupProductsunder[setup]workspace_id)New setup resource
setup.Products, integrated into the existing setup lifecycle[setup]resources)Clean, table-driven implementation
Activation via go-fastly product APIs
fastly/products/*enable APIsSafe defaults
enable = true[setup.products]Review notes
pkg/commands/compute/setup/products.gopkg/manifest/setup.goWhy this change
We already support declarative setup for backends, KV stores, secret stores, etc.
Products are a natural extension of that model, and this removes the need for manual post-deploy steps or separate CLI invocations when bootstrapping a new service.