-
Notifications
You must be signed in to change notification settings - Fork 70
fix: reinstate support for [setup.object_stores] #918
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
31f2977
bda2be6
1236c41
ad0662b
46ae879
c66ece1
1930d4c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -854,6 +854,7 @@ type setupObjects struct { | |
| backends *setup.Backends | ||
| configStores *setup.ConfigStores | ||
| loggers *setup.Loggers | ||
| objectStores *setup.KVStores | ||
| kvStores *setup.KVStores | ||
| secretStores *setup.SecretStores | ||
| } | ||
|
|
@@ -929,6 +930,17 @@ func constructSetupObjects( | |
| Stdout: out, | ||
| } | ||
|
|
||
| so.objectStores = &setup.KVStores{ | ||
| APIClient: c.Globals.APIClient, | ||
| AcceptDefaults: c.Globals.Flags.AcceptDefaults, | ||
| NonInteractive: c.Globals.Flags.NonInteractive, | ||
| ServiceID: serviceID, | ||
| ServiceVersion: serviceVersion, | ||
| Setup: c.Manifest.File.Setup.ObjectStores, | ||
| Stdin: in, | ||
| Stdout: out, | ||
| } | ||
|
|
||
| so.kvStores = &setup.KVStores{ | ||
| APIClient: c.Globals.APIClient, | ||
| AcceptDefaults: c.Globals.Flags.AcceptDefaults, | ||
|
|
@@ -999,6 +1011,13 @@ func processSetupConfig( | |
| _ = so.loggers.Configure() | ||
| } | ||
|
|
||
| if so.objectStores.Predefined() { | ||
| if err := so.objectStores.Configure(); err != nil { | ||
| errLogService(c.Globals.ErrLog, err, serviceID, serviceVersion) | ||
| return fmt.Errorf("error configuring service object stores: %w", err) | ||
| } | ||
| } | ||
|
|
||
| if so.kvStores.Predefined() { | ||
| if err := so.kvStores.Configure(); err != nil { | ||
| errLogService(c.Globals.ErrLog, err, serviceID, serviceVersion) | ||
|
|
@@ -1045,6 +1064,7 @@ func processSetupCreation( | |
| if newService { | ||
| so.backends.Spinner = spinner | ||
| so.configStores.Spinner = spinner | ||
| so.objectStores.Spinner = spinner | ||
| so.kvStores.Spinner = spinner | ||
| so.secretStores.Spinner = spinner | ||
|
|
||
|
|
@@ -1070,6 +1090,17 @@ func processSetupCreation( | |
| return err | ||
| } | ||
|
|
||
| if err := so.objectStores.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 | ||
| } | ||
|
|
||
| if err := so.kvStores.Create(); err != nil { | ||
| c.Globals.ErrLog.AddWithContext(err, map[string]any{ | ||
| "Accept defaults": c.Globals.Flags.AcceptDefaults, | ||
|
|
@@ -1282,6 +1313,9 @@ func pingServiceURL(serviceURL string, httpClient api.HTTPClient, expectedStatus | |
| if err != nil { | ||
| return false, 0, err | ||
| } | ||
| defer func() { | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The gosec CI tool started complaining. |
||
| _ = resp.Body.Close() | ||
| }() | ||
|
|
||
| // We check for the user's defined status code expectation. | ||
| // Otherwise we'll default to checking for a non-500. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,12 +6,13 @@ import ( | |
| "net" | ||
| "strconv" | ||
|
|
||
| "github.com/fastly/go-fastly/v8/fastly" | ||
|
|
||
| "github.com/fastly/cli/pkg/api" | ||
| "github.com/fastly/cli/pkg/commands/backend" | ||
| "github.com/fastly/cli/pkg/errors" | ||
| "github.com/fastly/cli/pkg/manifest" | ||
| "github.com/fastly/cli/pkg/text" | ||
| "github.com/fastly/go-fastly/v8/fastly" | ||
| ) | ||
|
|
||
| // Backends represents the service state related to backends defined within the | ||
|
|
@@ -98,9 +99,9 @@ func (b *Backends) Create() error { | |
| if err != nil { | ||
| if !b.isOriginless() { | ||
| b.Spinner.StopFailMessage(msg) | ||
| err := b.Spinner.StopFail() | ||
| if err != nil { | ||
| return err | ||
| spinErr := b.Spinner.StopFail() | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I discovered a bunch of these issues where the actual API error was being accidentally overridden by a separate error and so (as a user) you wouldn't see an error related to what had gone wrong. |
||
| if spinErr != nil { | ||
| return spinErr | ||
| } | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,11 +4,12 @@ import ( | |
| "fmt" | ||
| "io" | ||
|
|
||
| "github.com/fastly/go-fastly/v8/fastly" | ||
|
|
||
| "github.com/fastly/cli/pkg/api" | ||
| "github.com/fastly/cli/pkg/errors" | ||
| "github.com/fastly/cli/pkg/manifest" | ||
| "github.com/fastly/cli/pkg/text" | ||
| "github.com/fastly/go-fastly/v8/fastly" | ||
| ) | ||
|
|
||
| // KVStores represents the service state related to kv stores defined | ||
|
|
@@ -107,7 +108,7 @@ func (o *KVStores) Configure() error { | |
| func (o *KVStores) Create() error { | ||
| if o.Spinner == nil { | ||
| return errors.RemediationError{ | ||
| Inner: fmt.Errorf("internal logic error: no text.Progress configured for setup.KVStores"), | ||
| Inner: fmt.Errorf("internal logic error: no spinner configured for setup.KVStores"), | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should have been fixed in an older PR but I think a bad rebase meant this old implementation detail was left in. |
||
| Remediation: errors.BugRemediation, | ||
| } | ||
| } | ||
|
|
@@ -125,9 +126,9 @@ func (o *KVStores) Create() error { | |
| }) | ||
| if err != nil { | ||
| o.Spinner.StopFailMessage(msg) | ||
| err := o.Spinner.StopFail() | ||
| if err != nil { | ||
| return err | ||
| spinErr := o.Spinner.StopFail() | ||
| if spinErr != nil { | ||
| return spinErr | ||
| } | ||
| return fmt.Errorf("error creating kv store: %w", err) | ||
| } | ||
|
|
@@ -154,9 +155,9 @@ func (o *KVStores) Create() error { | |
| }) | ||
| if err != nil { | ||
| o.Spinner.StopFailMessage(msg) | ||
| err := o.Spinner.StopFail() | ||
| if err != nil { | ||
| return err | ||
| spinErr := o.Spinner.StopFail() | ||
| if spinErr != nil { | ||
| return spinErr | ||
| } | ||
| return fmt.Errorf("error creating kv store key: %w", err) | ||
| } | ||
|
|
@@ -185,9 +186,9 @@ func (o *KVStores) Create() error { | |
| }) | ||
| if err != nil { | ||
| o.Spinner.StopFailMessage(msg) | ||
| err := o.Spinner.StopFail() | ||
| if err != nil { | ||
| return err | ||
| spinErr := o.Spinner.StopFail() | ||
| if spinErr != nil { | ||
| return spinErr | ||
| } | ||
| return fmt.Errorf("error creating resource link between the service '%s' and the kv store '%s': %w", o.ServiceID, store.Name, err) | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,7 @@ type Setup struct { | |
| Backends map[string]*SetupBackend `toml:"backends,omitempty"` | ||
| ConfigStores map[string]*SetupConfigStore `toml:"config_stores,omitempty"` | ||
| Loggers map[string]*SetupLogger `toml:"log_endpoints,omitempty"` | ||
| ObjectStores map[string]*SetupKVStore `toml:"object_stores,omitempty"` | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here is where we're again parsing |
||
| KVStores map[string]*SetupKVStore `toml:"kv_stores,omitempty"` | ||
| SecretStores map[string]*SetupSecretStore `toml:"secret_stores,omitempty"` | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're effectively aliasing
[setup.object_stores]to the kv_stores implementation. Discussed internally, and it was decided this was OK to do as an interim solution.