From e92c8628ae227946eb03f96a8c078c450564dafb Mon Sep 17 00:00:00 2001 From: Mark McDonnell Date: Mon, 7 Feb 2022 15:26:57 +0000 Subject: [PATCH 1/5] implement trial activation --- cmd/fastly/main.go | 4 +- pkg/api/undocumented/undocumented.go | 57 +++++ pkg/app/commands.go | 12 +- pkg/app/run.go | 13 +- pkg/cmd/cmd.go | 8 +- pkg/commands/acl/create.go | 4 +- pkg/commands/acl/delete.go | 4 +- pkg/commands/acl/describe.go | 4 +- pkg/commands/acl/list.go | 4 +- pkg/commands/acl/update.go | 4 +- pkg/commands/aclentry/create.go | 4 +- pkg/commands/aclentry/delete.go | 4 +- pkg/commands/aclentry/describe.go | 4 +- pkg/commands/aclentry/list.go | 4 +- pkg/commands/aclentry/update.go | 6 +- pkg/commands/authtoken/create.go | 2 +- pkg/commands/authtoken/delete.go | 6 +- pkg/commands/authtoken/describe.go | 2 +- pkg/commands/authtoken/list.go | 4 +- pkg/commands/backend/create.go | 4 +- pkg/commands/backend/delete.go | 4 +- pkg/commands/backend/describe.go | 4 +- pkg/commands/backend/list.go | 4 +- pkg/commands/backend/update.go | 4 +- pkg/commands/compute/build.go | 7 +- pkg/commands/compute/compute_mocks_test.go | 6 + pkg/commands/compute/compute_test.go | 13 +- pkg/commands/compute/deploy.go | 97 +++++++-- pkg/commands/compute/deploy_test.go | 205 ++++++++++-------- pkg/commands/compute/init.go | 8 +- pkg/commands/compute/language.go | 5 +- pkg/commands/compute/update.go | 7 +- pkg/commands/dictionary/create.go | 4 +- pkg/commands/dictionary/delete.go | 4 +- pkg/commands/dictionary/describe.go | 8 +- pkg/commands/dictionary/list.go | 4 +- pkg/commands/dictionary/update.go | 4 +- pkg/commands/dictionaryitem/create.go | 4 +- pkg/commands/dictionaryitem/delete.go | 4 +- pkg/commands/dictionaryitem/describe.go | 4 +- pkg/commands/dictionaryitem/list.go | 4 +- pkg/commands/dictionaryitem/update.go | 6 +- pkg/commands/domain/create.go | 4 +- pkg/commands/domain/delete.go | 4 +- pkg/commands/domain/describe.go | 4 +- pkg/commands/domain/list.go | 4 +- pkg/commands/domain/update.go | 4 +- pkg/commands/domain/validate.go | 6 +- pkg/commands/healthcheck/create.go | 4 +- pkg/commands/healthcheck/delete.go | 4 +- pkg/commands/healthcheck/describe.go | 4 +- pkg/commands/healthcheck/list.go | 4 +- pkg/commands/healthcheck/update.go | 4 +- pkg/commands/ip/root.go | 2 +- .../logging/azureblob/azureblob_test.go | 10 +- pkg/commands/logging/azureblob/create.go | 4 +- pkg/commands/logging/azureblob/delete.go | 4 +- pkg/commands/logging/azureblob/describe.go | 4 +- pkg/commands/logging/azureblob/list.go | 4 +- pkg/commands/logging/azureblob/update.go | 4 +- .../logging/bigquery/bigquery_test.go | 10 +- pkg/commands/logging/bigquery/create.go | 4 +- pkg/commands/logging/bigquery/delete.go | 4 +- pkg/commands/logging/bigquery/describe.go | 4 +- pkg/commands/logging/bigquery/list.go | 4 +- pkg/commands/logging/bigquery/update.go | 4 +- .../logging/cloudfiles/cloudfiles_test.go | 10 +- pkg/commands/logging/cloudfiles/create.go | 4 +- pkg/commands/logging/cloudfiles/delete.go | 4 +- pkg/commands/logging/cloudfiles/describe.go | 4 +- pkg/commands/logging/cloudfiles/list.go | 4 +- pkg/commands/logging/cloudfiles/update.go | 4 +- pkg/commands/logging/datadog/create.go | 4 +- pkg/commands/logging/datadog/datadog_test.go | 10 +- pkg/commands/logging/datadog/delete.go | 4 +- pkg/commands/logging/datadog/describe.go | 4 +- pkg/commands/logging/datadog/list.go | 4 +- pkg/commands/logging/datadog/update.go | 4 +- pkg/commands/logging/digitalocean/create.go | 4 +- pkg/commands/logging/digitalocean/delete.go | 4 +- pkg/commands/logging/digitalocean/describe.go | 4 +- .../logging/digitalocean/digitalocean_test.go | 10 +- pkg/commands/logging/digitalocean/list.go | 4 +- pkg/commands/logging/digitalocean/update.go | 4 +- pkg/commands/logging/elasticsearch/create.go | 4 +- pkg/commands/logging/elasticsearch/delete.go | 4 +- .../logging/elasticsearch/describe.go | 4 +- .../elasticsearch/elasticsearch_test.go | 10 +- pkg/commands/logging/elasticsearch/list.go | 4 +- pkg/commands/logging/elasticsearch/update.go | 4 +- pkg/commands/logging/ftp/create.go | 4 +- pkg/commands/logging/ftp/delete.go | 4 +- pkg/commands/logging/ftp/describe.go | 4 +- pkg/commands/logging/ftp/ftp_test.go | 10 +- pkg/commands/logging/ftp/list.go | 4 +- pkg/commands/logging/ftp/update.go | 4 +- pkg/commands/logging/gcs/create.go | 4 +- pkg/commands/logging/gcs/delete.go | 4 +- pkg/commands/logging/gcs/describe.go | 4 +- pkg/commands/logging/gcs/gcs_test.go | 10 +- pkg/commands/logging/gcs/list.go | 4 +- pkg/commands/logging/gcs/update.go | 4 +- pkg/commands/logging/googlepubsub/create.go | 4 +- pkg/commands/logging/googlepubsub/delete.go | 4 +- pkg/commands/logging/googlepubsub/describe.go | 4 +- .../logging/googlepubsub/googlepubsub_test.go | 10 +- pkg/commands/logging/googlepubsub/list.go | 4 +- pkg/commands/logging/googlepubsub/update.go | 4 +- pkg/commands/logging/heroku/create.go | 4 +- pkg/commands/logging/heroku/delete.go | 4 +- pkg/commands/logging/heroku/describe.go | 4 +- pkg/commands/logging/heroku/heroku_test.go | 10 +- pkg/commands/logging/heroku/list.go | 4 +- pkg/commands/logging/heroku/update.go | 4 +- pkg/commands/logging/honeycomb/create.go | 4 +- pkg/commands/logging/honeycomb/delete.go | 4 +- pkg/commands/logging/honeycomb/describe.go | 4 +- .../logging/honeycomb/honeycomb_test.go | 10 +- pkg/commands/logging/honeycomb/list.go | 4 +- pkg/commands/logging/honeycomb/update.go | 4 +- pkg/commands/logging/https/create.go | 4 +- pkg/commands/logging/https/delete.go | 4 +- pkg/commands/logging/https/describe.go | 4 +- pkg/commands/logging/https/https_test.go | 10 +- pkg/commands/logging/https/list.go | 4 +- pkg/commands/logging/https/update.go | 4 +- pkg/commands/logging/kafka/create.go | 4 +- pkg/commands/logging/kafka/delete.go | 4 +- pkg/commands/logging/kafka/describe.go | 4 +- pkg/commands/logging/kafka/kafka_test.go | 14 +- pkg/commands/logging/kafka/list.go | 4 +- pkg/commands/logging/kafka/update.go | 4 +- pkg/commands/logging/kinesis/create.go | 4 +- pkg/commands/logging/kinesis/delete.go | 4 +- pkg/commands/logging/kinesis/describe.go | 4 +- pkg/commands/logging/kinesis/kinesis_test.go | 12 +- pkg/commands/logging/kinesis/list.go | 4 +- pkg/commands/logging/kinesis/update.go | 4 +- pkg/commands/logging/logentries/create.go | 4 +- pkg/commands/logging/logentries/delete.go | 4 +- pkg/commands/logging/logentries/describe.go | 4 +- pkg/commands/logging/logentries/list.go | 4 +- .../logging/logentries/logentries_test.go | 10 +- pkg/commands/logging/logentries/update.go | 4 +- pkg/commands/logging/loggly/create.go | 4 +- pkg/commands/logging/loggly/delete.go | 4 +- pkg/commands/logging/loggly/describe.go | 4 +- pkg/commands/logging/loggly/list.go | 4 +- pkg/commands/logging/loggly/loggly_test.go | 10 +- pkg/commands/logging/loggly/update.go | 4 +- pkg/commands/logging/logshuttle/create.go | 4 +- pkg/commands/logging/logshuttle/delete.go | 4 +- pkg/commands/logging/logshuttle/describe.go | 4 +- pkg/commands/logging/logshuttle/list.go | 4 +- .../logging/logshuttle/logshuttle_test.go | 10 +- pkg/commands/logging/logshuttle/update.go | 4 +- pkg/commands/logging/newrelic/create.go | 4 +- pkg/commands/logging/newrelic/delete.go | 4 +- pkg/commands/logging/newrelic/describe.go | 4 +- pkg/commands/logging/newrelic/list.go | 4 +- pkg/commands/logging/newrelic/update.go | 4 +- pkg/commands/logging/openstack/create.go | 4 +- pkg/commands/logging/openstack/delete.go | 4 +- pkg/commands/logging/openstack/describe.go | 4 +- pkg/commands/logging/openstack/list.go | 4 +- .../logging/openstack/openstack_test.go | 10 +- pkg/commands/logging/openstack/update.go | 4 +- pkg/commands/logging/papertrail/create.go | 4 +- pkg/commands/logging/papertrail/delete.go | 4 +- pkg/commands/logging/papertrail/describe.go | 4 +- pkg/commands/logging/papertrail/list.go | 4 +- .../logging/papertrail/papertrail_test.go | 10 +- pkg/commands/logging/papertrail/update.go | 4 +- pkg/commands/logging/s3/create.go | 4 +- pkg/commands/logging/s3/delete.go | 4 +- pkg/commands/logging/s3/describe.go | 4 +- pkg/commands/logging/s3/list.go | 4 +- pkg/commands/logging/s3/s3_test.go | 12 +- pkg/commands/logging/s3/update.go | 4 +- pkg/commands/logging/scalyr/create.go | 4 +- pkg/commands/logging/scalyr/delete.go | 4 +- pkg/commands/logging/scalyr/describe.go | 4 +- pkg/commands/logging/scalyr/list.go | 4 +- pkg/commands/logging/scalyr/scalyr_test.go | 10 +- pkg/commands/logging/scalyr/update.go | 4 +- pkg/commands/logging/sftp/create.go | 4 +- pkg/commands/logging/sftp/delete.go | 4 +- pkg/commands/logging/sftp/describe.go | 4 +- pkg/commands/logging/sftp/list.go | 4 +- pkg/commands/logging/sftp/sftp_test.go | 10 +- pkg/commands/logging/sftp/update.go | 4 +- pkg/commands/logging/splunk/create.go | 4 +- pkg/commands/logging/splunk/delete.go | 4 +- pkg/commands/logging/splunk/describe.go | 4 +- pkg/commands/logging/splunk/list.go | 4 +- pkg/commands/logging/splunk/splunk_test.go | 10 +- pkg/commands/logging/splunk/update.go | 4 +- pkg/commands/logging/sumologic/create.go | 4 +- pkg/commands/logging/sumologic/delete.go | 4 +- pkg/commands/logging/sumologic/describe.go | 4 +- pkg/commands/logging/sumologic/list.go | 4 +- .../logging/sumologic/sumologic_test.go | 10 +- pkg/commands/logging/sumologic/update.go | 4 +- pkg/commands/logging/syslog/create.go | 4 +- pkg/commands/logging/syslog/delete.go | 4 +- pkg/commands/logging/syslog/describe.go | 4 +- pkg/commands/logging/syslog/list.go | 4 +- pkg/commands/logging/syslog/syslog_test.go | 10 +- pkg/commands/logging/syslog/update.go | 4 +- pkg/commands/logtail/root.go | 4 +- pkg/commands/pop/root.go | 2 +- pkg/commands/purge/root.go | 10 +- pkg/commands/service/create.go | 2 +- pkg/commands/service/delete.go | 8 +- pkg/commands/service/describe.go | 4 +- pkg/commands/service/list.go | 2 +- pkg/commands/service/search.go | 2 +- pkg/commands/service/update.go | 4 +- pkg/commands/serviceversion/activate.go | 4 +- pkg/commands/serviceversion/clone.go | 4 +- pkg/commands/serviceversion/deactivate.go | 4 +- pkg/commands/serviceversion/list.go | 4 +- pkg/commands/serviceversion/lock.go | 4 +- pkg/commands/serviceversion/update.go | 4 +- pkg/commands/stats/historical.go | 4 +- pkg/commands/stats/realtime.go | 2 +- pkg/commands/stats/regions.go | 2 +- pkg/commands/update/root.go | 7 +- pkg/commands/user/create.go | 2 +- pkg/commands/user/delete.go | 2 +- pkg/commands/user/describe.go | 4 +- pkg/commands/user/list.go | 2 +- pkg/commands/user/update.go | 4 +- pkg/commands/vcl/custom/create.go | 4 +- pkg/commands/vcl/custom/delete.go | 4 +- pkg/commands/vcl/custom/describe.go | 4 +- pkg/commands/vcl/custom/list.go | 4 +- pkg/commands/vcl/custom/update.go | 4 +- pkg/commands/vcl/snippet/create.go | 4 +- pkg/commands/vcl/snippet/delete.go | 4 +- pkg/commands/vcl/snippet/describe.go | 6 +- pkg/commands/vcl/snippet/list.go | 4 +- pkg/commands/vcl/snippet/update.go | 6 +- pkg/commands/whoami/root.go | 7 +- pkg/config/data.go | 20 +- pkg/config/data_test.go | 11 +- pkg/errors/remediation_error.go | 4 + 247 files changed, 846 insertions(+), 721 deletions(-) create mode 100644 pkg/api/undocumented/undocumented.go diff --git a/cmd/fastly/main.go b/cmd/fastly/main.go index ec75edcb1..054dda7e8 100644 --- a/cmd/fastly/main.go +++ b/cmd/fastly/main.go @@ -59,7 +59,7 @@ func main() { var ( args = os.Args[1:] clientFactory = app.FastlyAPIClient - httpClient = http.DefaultClient + httpClient = &http.Client{Timeout: time.Second * 5} in io.Reader = os.Stdin out io.Writer = sync.NewWriter(color.Output) versionerCLI = update.NewGitHub(update.GitHubOpts{ @@ -143,7 +143,7 @@ Compatibility and versioning information for the Fastly CLI is being updated in // NOTE: we no longer use the hardcoded config.RemoteEndpoint constant. // Instead we rely on the values inside of the application // configuration file to determine where to load the config from. - err := file.Load(file.CLI.RemoteConfig, httpClient, config.ConfigRequestTimeout, config.FilePath) + err := file.Load(file.CLI.RemoteConfig, config.FilePath, httpClient) if err != nil { errLoadConfig = fsterr.RemediationError{ Inner: fmt.Errorf("there was a problem updating the versioning information for the Fastly CLI:\n\n%w", err), diff --git a/pkg/api/undocumented/undocumented.go b/pkg/api/undocumented/undocumented.go new file mode 100644 index 000000000..c3e5f144a --- /dev/null +++ b/pkg/api/undocumented/undocumented.go @@ -0,0 +1,57 @@ +package undocumented + +import ( + "fmt" + "io" + "net/http" + "net/url" + "strings" + "time" + + "github.com/fastly/cli/pkg/api" + fsterr "github.com/fastly/cli/pkg/errors" + "github.com/fastly/cli/pkg/useragent" +) + +// EdgeComputeTrial is the API endpoint for activating a compute trial. +const EdgeComputeTrial = "/customer/%s/edge-compute-trial" + +// RequestTimeout is the timeout for the API network request. +const RequestTimeout = 5 * time.Second + +// Get calls the given API endpoint and returns its response data. +func Get(host, path, token string, c api.HTTPClient) (data []byte, statusCode int, err error) { + host = strings.TrimSuffix(host, "/") + endpoint := fmt.Sprintf("%s%s", host, path) + + req, err := http.NewRequest(http.MethodPost, endpoint, nil) + if err != nil { + return data, statusCode, err + } + + req.Header.Set("Fastly-Key", token) + req.Header.Set("User-Agent", useragent.Name) + + res, err := c.Do(req) + if err != nil { + if urlErr, ok := err.(*url.Error); ok && urlErr.Timeout() { + return data, statusCode, fsterr.RemediationError{ + Inner: err, + Remediation: fsterr.NetworkRemediation, + } + } + return data, statusCode, err + } + defer res.Body.Close() + + if res.StatusCode != http.StatusOK { + return data, res.StatusCode, fmt.Errorf("error from API: '%s'", res.Status) + } + + data, err = io.ReadAll(res.Body) + if err != nil { + return data, res.StatusCode, err + } + + return data, res.StatusCode, nil +} diff --git a/pkg/app/commands.go b/pkg/app/commands.go index 2d63be6d4..8a1504575 100644 --- a/pkg/app/commands.go +++ b/pkg/app/commands.go @@ -89,13 +89,13 @@ func defineCommands( backendList := backend.NewListCommand(backendCmdRoot.CmdClause, globals, data) backendUpdate := backend.NewUpdateCommand(backendCmdRoot.CmdClause, globals, data) computeCmdRoot := compute.NewRootCommand(app, globals) - computeBuild := compute.NewBuildCommand(computeCmdRoot.CmdClause, opts.HTTPClient, globals, data) - computeDeploy := compute.NewDeployCommand(computeCmdRoot.CmdClause, opts.HTTPClient, globals, data) - computeInit := compute.NewInitCommand(computeCmdRoot.CmdClause, opts.HTTPClient, globals, data) + computeBuild := compute.NewBuildCommand(computeCmdRoot.CmdClause, globals, data) + computeDeploy := compute.NewDeployCommand(computeCmdRoot.CmdClause, globals, data) + computeInit := compute.NewInitCommand(computeCmdRoot.CmdClause, globals, data) computePack := compute.NewPackCommand(computeCmdRoot.CmdClause, globals, data) computePublish := compute.NewPublishCommand(computeCmdRoot.CmdClause, globals, computeBuild, computeDeploy, data) computeServe := compute.NewServeCommand(computeCmdRoot.CmdClause, globals, computeBuild, opts.Versioners.Viceroy, data) - computeUpdate := compute.NewUpdateCommand(computeCmdRoot.CmdClause, opts.HTTPClient, globals, data) + computeUpdate := compute.NewUpdateCommand(computeCmdRoot.CmdClause, globals, data) computeValidate := compute.NewValidateCommand(computeCmdRoot.CmdClause, globals) configureCmdRoot := configure.NewRootCommand(app, opts.ConfigPath, configure.APIClientFactory(opts.APIClient), globals) dictionaryCmdRoot := dictionary.NewRootCommand(app, globals) @@ -302,7 +302,7 @@ func defineCommands( statsHistorical := stats.NewHistoricalCommand(statsCmdRoot.CmdClause, globals, data) statsRealtime := stats.NewRealtimeCommand(statsCmdRoot.CmdClause, globals, data) statsRegions := stats.NewRegionsCommand(statsCmdRoot.CmdClause, globals) - updateRoot := update.NewRootCommand(app, opts.ConfigPath, opts.Versioners.CLI, opts.HTTPClient, globals) + updateRoot := update.NewRootCommand(app, opts.ConfigPath, opts.Versioners.CLI, globals) userCmdRoot := user.NewRootCommand(app, globals) userCreate := user.NewCreateCommand(userCmdRoot.CmdClause, globals, data) userDelete := user.NewDeleteCommand(userCmdRoot.CmdClause, globals, data) @@ -323,7 +323,7 @@ func defineCommands( vclSnippetList := snippet.NewListCommand(vclSnippetCmdRoot.CmdClause, globals, data) vclSnippetUpdate := snippet.NewUpdateCommand(vclSnippetCmdRoot.CmdClause, globals, data) versionCmdRoot := version.NewRootCommand(app, opts.Versioners.Viceroy) - whoamiCmdRoot := whoami.NewRootCommand(app, opts.HTTPClient, globals) + whoamiCmdRoot := whoami.NewRootCommand(app, globals) return []cmd.Command{ shellcompleteCmdRoot, diff --git a/pkg/app/run.go b/pkg/app/run.go index 4503061e3..68d8638c0 100644 --- a/pkg/app/run.go +++ b/pkg/app/run.go @@ -54,11 +54,12 @@ func Run(opts RunOpts) error { // The globals will hold generally-applicable configuration parameters // from a variety of sources, and is provided to each concrete command. globals := config.Data{ - File: opts.ConfigFile, - Path: opts.ConfigPath, - Env: opts.Env, - Output: opts.Stdout, - ErrLog: opts.ErrLog, + File: opts.ConfigFile, + Path: opts.ConfigPath, + Env: opts.Env, + Output: opts.Stdout, + ErrLog: opts.ErrLog, + HTTPClient: opts.HTTPClient, } // Set up the main application root, including global flags, and then each @@ -148,7 +149,7 @@ func Run(opts RunOpts) error { } } - globals.Client, err = opts.APIClient(token, endpoint) + globals.APIClient, err = opts.APIClient(token, endpoint) if err != nil { globals.ErrLog.Add(err) return fmt.Errorf("error constructing Fastly API client: %w", err) diff --git a/pkg/cmd/cmd.go b/pkg/cmd/cmd.go index f34676326..28b587ae0 100644 --- a/pkg/cmd/cmd.go +++ b/pkg/cmd/cmd.go @@ -115,7 +115,7 @@ type OptionalInt struct { type ServiceDetailsOpts struct { AllowActiveLocked bool AutoCloneFlag OptionalAutoClone - Client api.Interface + APIClient api.Interface Manifest manifest.Data Out io.Writer ServiceNameFlag OptionalServiceNameID @@ -126,7 +126,7 @@ type ServiceDetailsOpts struct { // ServiceDetails returns the Service ID and Service Version. func ServiceDetails(opts ServiceDetailsOpts) (serviceID string, serviceVersion *fastly.Version, err error) { - serviceID, source, flag, err := ServiceID(opts.ServiceNameFlag, opts.Manifest, opts.Client, opts.ErrLog) + serviceID, source, flag, err := ServiceID(opts.ServiceNameFlag, opts.Manifest, opts.APIClient, opts.ErrLog) if err != nil { return serviceID, serviceVersion, err } @@ -134,14 +134,14 @@ func ServiceDetails(opts ServiceDetailsOpts) (serviceID string, serviceVersion * DisplayServiceID(serviceID, flag, source, opts.Out) } - v, err := opts.ServiceVersionFlag.Parse(serviceID, opts.Client) + v, err := opts.ServiceVersionFlag.Parse(serviceID, opts.APIClient) if err != nil { return serviceID, serviceVersion, err } if opts.AutoCloneFlag.WasSet { currentVersion := v - v, err = opts.AutoCloneFlag.Parse(currentVersion, serviceID, opts.VerboseMode, opts.Out, opts.Client) + v, err = opts.AutoCloneFlag.Parse(currentVersion, serviceID, opts.VerboseMode, opts.Out, opts.APIClient) if err != nil { return serviceID, currentVersion, err } diff --git a/pkg/commands/acl/create.go b/pkg/commands/acl/create.go index b808dbd81..aea67898b 100644 --- a/pkg/commands/acl/create.go +++ b/pkg/commands/acl/create.go @@ -63,7 +63,7 @@ type CreateCommand struct { func (c *CreateCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.autoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, ErrLog: c.Globals.ErrLog, Manifest: c.manifest, Out: out, @@ -81,7 +81,7 @@ func (c *CreateCommand) Exec(in io.Reader, out io.Writer) error { input := c.constructInput(serviceID, serviceVersion.Number) - a, err := c.Globals.Client.CreateACL(input) + a, err := c.Globals.APIClient.CreateACL(input) if err != nil { c.Globals.ErrLog.AddWithContext(err, map[string]interface{}{ "Service ID": serviceID, diff --git a/pkg/commands/acl/delete.go b/pkg/commands/acl/delete.go index f88cda8bf..c50b26e99 100644 --- a/pkg/commands/acl/delete.go +++ b/pkg/commands/acl/delete.go @@ -63,7 +63,7 @@ type DeleteCommand struct { func (c *DeleteCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.autoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -80,7 +80,7 @@ func (c *DeleteCommand) Exec(in io.Reader, out io.Writer) error { input := c.constructInput(serviceID, serviceVersion.Number) - err = c.Globals.Client.DeleteACL(input) + err = c.Globals.APIClient.DeleteACL(input) if err != nil { c.Globals.ErrLog.AddWithContext(err, map[string]interface{}{ "Service ID": serviceID, diff --git a/pkg/commands/acl/describe.go b/pkg/commands/acl/describe.go index 9598430d5..ed80e06a7 100644 --- a/pkg/commands/acl/describe.go +++ b/pkg/commands/acl/describe.go @@ -70,7 +70,7 @@ func (c *DescribeCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AllowActiveLocked: true, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -87,7 +87,7 @@ func (c *DescribeCommand) Exec(in io.Reader, out io.Writer) error { input := c.constructInput(serviceID, serviceVersion.Number) - a, err := c.Globals.Client.GetACL(input) + a, err := c.Globals.APIClient.GetACL(input) if err != nil { c.Globals.ErrLog.AddWithContext(err, map[string]interface{}{ "Service ID": serviceID, diff --git a/pkg/commands/acl/list.go b/pkg/commands/acl/list.go index 3aceb8d03..6763c4c9f 100644 --- a/pkg/commands/acl/list.go +++ b/pkg/commands/acl/list.go @@ -69,7 +69,7 @@ func (c *ListCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AllowActiveLocked: true, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -86,7 +86,7 @@ func (c *ListCommand) Exec(in io.Reader, out io.Writer) error { input := c.constructInput(serviceID, serviceVersion.Number) - as, err := c.Globals.Client.ListACLs(input) + as, err := c.Globals.APIClient.ListACLs(input) if err != nil { c.Globals.ErrLog.AddWithContext(err, map[string]interface{}{ "Service ID": serviceID, diff --git a/pkg/commands/acl/update.go b/pkg/commands/acl/update.go index 069ae33c1..6039d8445 100644 --- a/pkg/commands/acl/update.go +++ b/pkg/commands/acl/update.go @@ -65,7 +65,7 @@ type UpdateCommand struct { func (c *UpdateCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.autoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -82,7 +82,7 @@ func (c *UpdateCommand) Exec(in io.Reader, out io.Writer) error { input := c.constructInput(serviceID, serviceVersion.Number) - a, err := c.Globals.Client.UpdateACL(input) + a, err := c.Globals.APIClient.UpdateACL(input) if err != nil { c.Globals.ErrLog.AddWithContext(err, map[string]interface{}{ "Service ID": serviceID, diff --git a/pkg/commands/aclentry/create.go b/pkg/commands/aclentry/create.go index 78b8bf35a..32ef86bb8 100644 --- a/pkg/commands/aclentry/create.go +++ b/pkg/commands/aclentry/create.go @@ -56,7 +56,7 @@ type CreateCommand struct { // Exec invokes the application logic for the command. func (c *CreateCommand) Exec(in io.Reader, out io.Writer) error { - serviceID, source, flag, err := cmd.ServiceID(c.serviceName, c.manifest, c.Globals.Client, c.Globals.ErrLog) + serviceID, source, flag, err := cmd.ServiceID(c.serviceName, c.manifest, c.Globals.APIClient, c.Globals.ErrLog) if err != nil { return err } @@ -66,7 +66,7 @@ func (c *CreateCommand) Exec(in io.Reader, out io.Writer) error { input := c.constructInput(serviceID) - a, err := c.Globals.Client.CreateACLEntry(input) + a, err := c.Globals.APIClient.CreateACLEntry(input) if err != nil { c.Globals.ErrLog.AddWithContext(err, map[string]interface{}{ "Service ID": serviceID, diff --git a/pkg/commands/aclentry/delete.go b/pkg/commands/aclentry/delete.go index 4c566cf95..a9cb81f55 100644 --- a/pkg/commands/aclentry/delete.go +++ b/pkg/commands/aclentry/delete.go @@ -50,7 +50,7 @@ type DeleteCommand struct { // Exec invokes the application logic for the command. func (c *DeleteCommand) Exec(in io.Reader, out io.Writer) error { - serviceID, source, flag, err := cmd.ServiceID(c.serviceName, c.manifest, c.Globals.Client, c.Globals.ErrLog) + serviceID, source, flag, err := cmd.ServiceID(c.serviceName, c.manifest, c.Globals.APIClient, c.Globals.ErrLog) if err != nil { return err } @@ -60,7 +60,7 @@ func (c *DeleteCommand) Exec(in io.Reader, out io.Writer) error { input := c.constructInput(serviceID) - err = c.Globals.Client.DeleteACLEntry(input) + err = c.Globals.APIClient.DeleteACLEntry(input) if err != nil { c.Globals.ErrLog.AddWithContext(err, map[string]interface{}{ "Service ID": serviceID, diff --git a/pkg/commands/aclentry/describe.go b/pkg/commands/aclentry/describe.go index 5e2dc7b2e..714b0fe67 100644 --- a/pkg/commands/aclentry/describe.go +++ b/pkg/commands/aclentry/describe.go @@ -63,7 +63,7 @@ func (c *DescribeCommand) Exec(in io.Reader, out io.Writer) error { return fsterr.ErrInvalidVerboseJSONCombo } - serviceID, source, flag, err := cmd.ServiceID(c.serviceName, c.manifest, c.Globals.Client, c.Globals.ErrLog) + serviceID, source, flag, err := cmd.ServiceID(c.serviceName, c.manifest, c.Globals.APIClient, c.Globals.ErrLog) if err != nil { return err } @@ -73,7 +73,7 @@ func (c *DescribeCommand) Exec(in io.Reader, out io.Writer) error { input := c.constructInput(serviceID) - a, err := c.Globals.Client.GetACLEntry(input) + a, err := c.Globals.APIClient.GetACLEntry(input) if err != nil { c.Globals.ErrLog.AddWithContext(err, map[string]interface{}{ "Service ID": serviceID, diff --git a/pkg/commands/aclentry/list.go b/pkg/commands/aclentry/list.go index a3744acb5..663af1dbf 100644 --- a/pkg/commands/aclentry/list.go +++ b/pkg/commands/aclentry/list.go @@ -70,7 +70,7 @@ func (c *ListCommand) Exec(in io.Reader, out io.Writer) error { return fsterr.ErrInvalidVerboseJSONCombo } - serviceID, source, flag, err := cmd.ServiceID(c.serviceName, c.manifest, c.Globals.Client, c.Globals.ErrLog) + serviceID, source, flag, err := cmd.ServiceID(c.serviceName, c.manifest, c.Globals.APIClient, c.Globals.ErrLog) if err != nil { return err } @@ -79,7 +79,7 @@ func (c *ListCommand) Exec(in io.Reader, out io.Writer) error { } input := c.constructInput(serviceID) - paginator := c.Globals.Client.NewListACLEntriesPaginator(input) + paginator := c.Globals.APIClient.NewListACLEntriesPaginator(input) // TODO: Use generics support in go 1.18 to replace this almost identical // logic inside of 'dictionary-item list' and 'service list'. diff --git a/pkg/commands/aclentry/update.go b/pkg/commands/aclentry/update.go index 124c620a2..b7519f31e 100644 --- a/pkg/commands/aclentry/update.go +++ b/pkg/commands/aclentry/update.go @@ -63,7 +63,7 @@ type UpdateCommand struct { // Exec invokes the application logic for the command. func (c *UpdateCommand) Exec(in io.Reader, out io.Writer) error { - serviceID, source, flag, err := cmd.ServiceID(c.serviceName, c.manifest, c.Globals.Client, c.Globals.ErrLog) + serviceID, source, flag, err := cmd.ServiceID(c.serviceName, c.manifest, c.Globals.APIClient, c.Globals.ErrLog) if err != nil { return err } @@ -77,7 +77,7 @@ func (c *UpdateCommand) Exec(in io.Reader, out io.Writer) error { return err } - err = c.Globals.Client.BatchModifyACLEntries(input) + err = c.Globals.APIClient.BatchModifyACLEntries(input) if err != nil { c.Globals.ErrLog.AddWithContext(err, map[string]interface{}{ "Service ID": serviceID, @@ -94,7 +94,7 @@ func (c *UpdateCommand) Exec(in io.Reader, out io.Writer) error { return err } - a, err := c.Globals.Client.UpdateACLEntry(input) + a, err := c.Globals.APIClient.UpdateACLEntry(input) if err != nil { c.Globals.ErrLog.AddWithContext(err, map[string]interface{}{ "Service ID": serviceID, diff --git a/pkg/commands/authtoken/create.go b/pkg/commands/authtoken/create.go index c5c45fd97..c1432a779 100644 --- a/pkg/commands/authtoken/create.go +++ b/pkg/commands/authtoken/create.go @@ -67,7 +67,7 @@ func (c *CreateCommand) Exec(in io.Reader, out io.Writer) error { input := c.constructInput() - r, err := c.Globals.Client.CreateToken(input) + r, err := c.Globals.APIClient.CreateToken(input) if err != nil { c.Globals.ErrLog.Add(err) return err diff --git a/pkg/commands/authtoken/delete.go b/pkg/commands/authtoken/delete.go index ec9119140..bee0ff756 100644 --- a/pkg/commands/authtoken/delete.go +++ b/pkg/commands/authtoken/delete.go @@ -49,7 +49,7 @@ func (c *DeleteCommand) Exec(in io.Reader, out io.Writer) error { } if c.current { - err := c.Globals.Client.DeleteTokenSelf() + err := c.Globals.APIClient.DeleteTokenSelf() if err != nil { c.Globals.ErrLog.Add(err) return err @@ -66,7 +66,7 @@ func (c *DeleteCommand) Exec(in io.Reader, out io.Writer) error { return err } - err = c.Globals.Client.BatchDeleteTokens(input) + err = c.Globals.APIClient.BatchDeleteTokens(input) if err != nil { c.Globals.ErrLog.Add(err) return err @@ -82,7 +82,7 @@ func (c *DeleteCommand) Exec(in io.Reader, out io.Writer) error { if c.id != "" { input := c.constructInput() - err := c.Globals.Client.DeleteToken(input) + err := c.Globals.APIClient.DeleteToken(input) if err != nil { c.Globals.ErrLog.Add(err) return err diff --git a/pkg/commands/authtoken/describe.go b/pkg/commands/authtoken/describe.go index 95e9aca76..6f1e05251 100644 --- a/pkg/commands/authtoken/describe.go +++ b/pkg/commands/authtoken/describe.go @@ -46,7 +46,7 @@ func (c *DescribeCommand) Exec(in io.Reader, out io.Writer) error { return fsterr.ErrInvalidVerboseJSONCombo } - r, err := c.Globals.Client.GetTokenSelf() + r, err := c.Globals.APIClient.GetTokenSelf() if err != nil { c.Globals.ErrLog.Add(err) return err diff --git a/pkg/commands/authtoken/list.go b/pkg/commands/authtoken/list.go index b94748b69..07e60bca0 100644 --- a/pkg/commands/authtoken/list.go +++ b/pkg/commands/authtoken/list.go @@ -67,13 +67,13 @@ func (c *ListCommand) Exec(in io.Reader, out io.Writer) error { input := c.constructInput() - rs, err = c.Globals.Client.ListCustomerTokens(input) + rs, err = c.Globals.APIClient.ListCustomerTokens(input) if err != nil { c.Globals.ErrLog.Add(err) return err } } else { - rs, err = c.Globals.Client.ListTokens() + rs, err = c.Globals.APIClient.ListTokens() if err != nil { c.Globals.ErrLog.Add(err) return err diff --git a/pkg/commands/backend/create.go b/pkg/commands/backend/create.go index c76d192aa..98a876c44 100644 --- a/pkg/commands/backend/create.go +++ b/pkg/commands/backend/create.go @@ -93,7 +93,7 @@ func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest func (c *CreateCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.autoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -142,7 +142,7 @@ func (c *CreateCommand) Exec(in io.Reader, out io.Writer) error { } } - b, err := c.Globals.Client.CreateBackend(&c.Input) + b, err := c.Globals.APIClient.CreateBackend(&c.Input) if err != nil { c.Globals.ErrLog.AddWithContext(err, map[string]interface{}{ "Service ID": serviceID, diff --git a/pkg/commands/backend/delete.go b/pkg/commands/backend/delete.go index b258c0426..dfe20b5ff 100644 --- a/pkg/commands/backend/delete.go +++ b/pkg/commands/backend/delete.go @@ -57,7 +57,7 @@ func NewDeleteCommand(parent cmd.Registerer, globals *config.Data, data manifest func (c *DeleteCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.autoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -75,7 +75,7 @@ func (c *DeleteCommand) Exec(in io.Reader, out io.Writer) error { c.Input.ServiceID = serviceID c.Input.ServiceVersion = serviceVersion.Number - if err := c.Globals.Client.DeleteBackend(&c.Input); err != nil { + if err := c.Globals.APIClient.DeleteBackend(&c.Input); err != nil { c.Globals.ErrLog.AddWithContext(err, map[string]interface{}{ "Service ID": serviceID, "Service Version": serviceVersion.Number, diff --git a/pkg/commands/backend/describe.go b/pkg/commands/backend/describe.go index 2cecd4ee7..a9a5cd773 100644 --- a/pkg/commands/backend/describe.go +++ b/pkg/commands/backend/describe.go @@ -64,7 +64,7 @@ func (c *DescribeCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AllowActiveLocked: true, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -82,7 +82,7 @@ func (c *DescribeCommand) Exec(in io.Reader, out io.Writer) error { c.Input.ServiceID = serviceID c.Input.ServiceVersion = serviceVersion.Number - backend, err := c.Globals.Client.GetBackend(&c.Input) + backend, err := c.Globals.APIClient.GetBackend(&c.Input) if err != nil { c.Globals.ErrLog.AddWithContext(err, map[string]interface{}{ "Service ID": serviceID, diff --git a/pkg/commands/backend/list.go b/pkg/commands/backend/list.go index 70664d94c..66927916d 100644 --- a/pkg/commands/backend/list.go +++ b/pkg/commands/backend/list.go @@ -64,7 +64,7 @@ func (c *ListCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AllowActiveLocked: true, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -82,7 +82,7 @@ func (c *ListCommand) Exec(in io.Reader, out io.Writer) error { c.Input.ServiceID = serviceID c.Input.ServiceVersion = serviceVersion.Number - backends, err := c.Globals.Client.ListBackends(&c.Input) + backends, err := c.Globals.APIClient.ListBackends(&c.Input) if err != nil { c.Globals.ErrLog.AddWithContext(err, map[string]interface{}{ "Service ID": serviceID, diff --git a/pkg/commands/backend/update.go b/pkg/commands/backend/update.go index 3e8460f0a..5db92e83c 100644 --- a/pkg/commands/backend/update.go +++ b/pkg/commands/backend/update.go @@ -107,7 +107,7 @@ func NewUpdateCommand(parent cmd.Registerer, globals *config.Data, data manifest func (c *UpdateCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.autoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -224,7 +224,7 @@ func (c *UpdateCommand) Exec(in io.Reader, out io.Writer) error { input.SSLCiphers = c.SSLCiphers.Value } - b, err := c.Globals.Client.UpdateBackend(input) + b, err := c.Globals.APIClient.UpdateBackend(input) if err != nil { c.Globals.ErrLog.AddWithContext(err, map[string]interface{}{ "Service ID": serviceID, diff --git a/pkg/commands/compute/build.go b/pkg/commands/compute/build.go index f5fbaaacc..f14359aab 100644 --- a/pkg/commands/compute/build.go +++ b/pkg/commands/compute/build.go @@ -10,7 +10,6 @@ import ( "path/filepath" "strings" - "github.com/fastly/cli/pkg/api" "github.com/fastly/cli/pkg/cmd" "github.com/fastly/cli/pkg/config" fsterr "github.com/fastly/cli/pkg/errors" @@ -44,7 +43,6 @@ type Flags struct { // BuildCommand produces a deployable artifact from files on the local disk. type BuildCommand struct { cmd.Base - client api.HTTPClient // NOTE: these are public so that the "serve" and "publish" composite // commands can set the values appropriately before calling Exec(). @@ -53,9 +51,8 @@ type BuildCommand struct { } // NewBuildCommand returns a usable command registered under the parent. -func NewBuildCommand(parent cmd.Registerer, client api.HTTPClient, globals *config.Data, data manifest.Data) *BuildCommand { +func NewBuildCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *BuildCommand { var c BuildCommand - c.client = client c.Globals = globals c.Manifest = data c.CmdClause = parent.Command("build", "Build a Compute@Edge package locally") @@ -140,7 +137,7 @@ func (c *BuildCommand) Exec(in io.Reader, out io.Writer) (err error) { Name: "rust", SourceDirectory: RustSourceDirectory, IncludeFiles: []string{"Cargo.toml"}, - Toolchain: NewRust(c.client, c.Globals.File.Language.Rust, c.Globals.ErrLog, c.Flags.Timeout, name, c.Manifest.File.Scripts.Build), + Toolchain: NewRust(c.Globals.HTTPClient, c.Globals.File.Language.Rust, c.Globals.ErrLog, c.Flags.Timeout, name, c.Manifest.File.Scripts.Build), }) case "other": language = NewLanguage(&LanguageOptions{ diff --git a/pkg/commands/compute/compute_mocks_test.go b/pkg/commands/compute/compute_mocks_test.go index 9e7615e90..fd43b9b10 100644 --- a/pkg/commands/compute/compute_mocks_test.go +++ b/pkg/commands/compute/compute_mocks_test.go @@ -80,6 +80,12 @@ func listDomainsOk(i *fastly.ListDomainsInput) ([]*fastly.Domain, error) { }, nil } +func getServiceDetailsWasm(i *fastly.GetServiceInput) (*fastly.ServiceDetail, error) { + return &fastly.ServiceDetail{ + Type: "wasm", + }, nil +} + type versionClient struct { fastlyVersions []string fastlySysVersions []string diff --git a/pkg/commands/compute/compute_test.go b/pkg/commands/compute/compute_test.go index 706f14f34..085d56f56 100644 --- a/pkg/commands/compute/compute_test.go +++ b/pkg/commands/compute/compute_test.go @@ -33,8 +33,8 @@ func TestPublishFlagDivergence(t *testing.T) { acmd := kingpin.New("foo", "bar") rcmd := compute.NewRootCommand(acmd, &cfg) - bcmd := compute.NewBuildCommand(rcmd.CmdClause, client{}, &cfg, data) - dcmd := compute.NewDeployCommand(rcmd.CmdClause, client{}, &cfg, data) + bcmd := compute.NewBuildCommand(rcmd.CmdClause, &cfg, data) + dcmd := compute.NewDeployCommand(rcmd.CmdClause, &cfg, data) pcmd := compute.NewPublishCommand(rcmd.CmdClause, &cfg, bcmd, dcmd, data) buildFlags := getFlags(bcmd.CmdClause) @@ -81,7 +81,7 @@ func TestServeFlagDivergence(t *testing.T) { acmd := kingpin.New("foo", "bar") rcmd := compute.NewRootCommand(acmd, &cfg) - bcmd := compute.NewBuildCommand(rcmd.CmdClause, client{}, &cfg, data) + bcmd := compute.NewBuildCommand(rcmd.CmdClause, &cfg, data) scmd := compute.NewServeCommand(rcmd.CmdClause, &cfg, bcmd, versioner, data) buildFlags := getFlags(bcmd.CmdClause) @@ -130,13 +130,6 @@ func ignoreFlag(ignore []string, flag string) bool { return false } -type client struct{} - -func (c client) Do(*http.Request) (*http.Response, error) { - var resp http.Response - return &resp, nil -} - func getFlags(cmd *kingpin.CmdClause) reflect.Value { return reflect.ValueOf(cmd).Elem().FieldByName("cmdMixin").FieldByName("flagGroup").Elem().FieldByName("long") } diff --git a/pkg/commands/compute/deploy.go b/pkg/commands/compute/deploy.go index 3678c55ef..d40e15c14 100644 --- a/pkg/commands/compute/deploy.go +++ b/pkg/commands/compute/deploy.go @@ -6,11 +6,13 @@ import ( "fmt" "io" "io/fs" + "net/http" "os" "path/filepath" "strings" "github.com/fastly/cli/pkg/api" + "github.com/fastly/cli/pkg/api/undocumented" "github.com/fastly/cli/pkg/cmd" "github.com/fastly/cli/pkg/commands/compute/setup" "github.com/fastly/cli/pkg/config" @@ -25,6 +27,7 @@ import ( const ( manageServiceBaseURL = "https://manage.fastly.com/configure/services/" + trialNotActivated = "Valid values for 'type' are: 'vcl'" ) // PackageSizeLimit describes the package size limit in bytes (currently 50mb) @@ -47,7 +50,7 @@ type DeployCommand struct { } // NewDeployCommand returns a usable command registered under the parent. -func NewDeployCommand(parent cmd.Registerer, client api.HTTPClient, globals *config.Data, data manifest.Data) *DeployCommand { +func NewDeployCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *DeployCommand { var c DeployCommand c.Globals = globals c.Manifest = data @@ -83,12 +86,12 @@ func NewDeployCommand(parent cmd.Registerer, client api.HTTPClient, globals *con // Exec implements the command interface. func (c *DeployCommand) Exec(in io.Reader, out io.Writer) (err error) { - _, s := c.Globals.Token() + token, s := c.Globals.Token() if s == config.SourceUndefined { return fsterr.ErrNoToken } - serviceID, source, flag, err := cmd.ServiceID(c.ServiceName, c.Manifest, c.Globals.Client, c.Globals.ErrLog) + serviceID, source, flag, err := cmd.ServiceID(c.ServiceName, c.Manifest, c.Globals.APIClient, c.Globals.ErrLog) if err == nil && c.Globals.Verbose() { cmd.DisplayServiceID(serviceID, flag, source, out) } @@ -96,7 +99,7 @@ func (c *DeployCommand) Exec(in io.Reader, out io.Writer) (err error) { // Alias' for otherwise long definitions errLog := c.Globals.ErrLog verbose := c.Globals.Verbose() - apiClient := c.Globals.Client + apiClient := c.Globals.APIClient // VALIDATE PACKAGE... @@ -105,6 +108,11 @@ func (c *DeployCommand) Exec(in io.Reader, out io.Writer) (err error) { return err } + // FREE TRIAL ACTIVATION + + endpoint, _ := c.Globals.Endpoint() + activateTrial := preconfigureActivateTrial(endpoint, token, c.Globals.HTTPClient) + // SERVICE MANAGEMENT... var ( @@ -114,7 +122,7 @@ func (c *DeployCommand) Exec(in io.Reader, out io.Writer) (err error) { if source == manifest.SourceUndefined { newService = true - serviceID, serviceVersion, err = manageNoServiceIDFlow(c.AcceptDefaults, in, out, verbose, apiClient, pkgName, errLog, &c.Manifest.File) + serviceID, serviceVersion, err = manageNoServiceIDFlow(c.AcceptDefaults, in, out, verbose, apiClient, pkgName, errLog, &c.Manifest.File, activateTrial) if err != nil { return err } @@ -505,6 +513,32 @@ func packageSize(path string) (size int64, err error) { return fi.Size(), nil } +// activator represents a function that calls an undocumented API endpoint for +// activating a Compute@Edge free trial on the given customer account. +// +// It is preconfigured with the Fastly API endpoint, a user token and a simple +// HTTP Client. +// +// This design allows us to pass an activator rather than passing multiple +// unrelated arguments through several nested functions. +type activator func(customerID string) error + +// preconfigureActivateTrial forms a closure around an activator. +func preconfigureActivateTrial(endpoint, token string, httpClient api.HTTPClient) activator { + return func(customerID string) error { + path := fmt.Sprintf(undocumented.EdgeComputeTrial, customerID) + _, statusCode, err := undocumented.Get(endpoint, path, token, httpClient) + if err != nil { + // 409 Conflict == The Compute@Edge trial has already been created. + if statusCode != http.StatusConflict { + return err + } + } + + return nil + } +} + // manageNoServiceIDFlow handles creating a new service when no Service ID is found. func manageNoServiceIDFlow( acceptDefaults bool, @@ -514,7 +548,8 @@ func manageNoServiceIDFlow( apiClient api.Interface, pkgName string, errLog fsterr.LogInterface, - manifestFile *manifest.File) (serviceID string, serviceVersion *fastly.Version, err error) { + manifestFile *manifest.File, + activateTrial activator) (serviceID string, serviceVersion *fastly.Version, err error) { if !acceptDefaults { text.Break(out) @@ -539,7 +574,7 @@ func manageNoServiceIDFlow( // There is no service and so we'll do a one time creation of the service // // NOTE: we're shadowing the `serviceVersion` and `serviceID` variables. - serviceID, serviceVersion, err = createService(apiClient, pkgName, progress) + serviceID, serviceVersion, err = createService(pkgName, apiClient, activateTrial, progress) if err != nil { progress.Fail() errLog.AddWithContext(err, map[string]interface{}{ @@ -563,27 +598,40 @@ func manageNoServiceIDFlow( } // createService creates a service to associate with the compute package. -func createService(client api.Interface, name string, progress text.Progress) (string, *fastly.Version, error) { +// +// NOTE: If the creation of the service fails because the user has not +// activated a free trial, then we'll trigger the trial for their account. +func createService(name string, apiClient api.Interface, activateTrial activator, progress text.Progress) (serviceID string, serviceVersion *fastly.Version, err error) { progress.Step("Creating service...") - service, err := client.CreateService(&fastly.CreateServiceInput{ + service, err := apiClient.CreateService(&fastly.CreateServiceInput{ Name: name, Type: "wasm", }) if err != nil { - if strings.Contains(err.Error(), "Valid values for 'type' are: 'vcl'") { - return "", nil, fsterr.RemediationError{ - Inner: fmt.Errorf("error creating service: you do not have the Compute@Edge feature flag enabled on your Fastly account"), - Remediation: "For more help with this error see fastly.help/cli/ecp-feature", + if strings.Contains(err.Error(), trialNotActivated) { + user, err := apiClient.GetCurrentUser() + if err != nil { + return serviceID, serviceVersion, fsterr.RemediationError{ + Inner: fmt.Errorf("unable to identify user associated with the given token: %w", err), + Remediation: "To ensure you have access to the Compute@Edge platform we need your Customer ID. " + fsterr.AuthRemediation, + } + } + + err = activateTrial(user.CustomerID) + if err != nil { + return serviceID, serviceVersion, fsterr.RemediationError{ + Inner: fmt.Errorf("error creating service: you do not have the Compute@Edge free trial enabled on your Fastly account"), + Remediation: fsterr.ComputeTrialRemediation, + } } + + return createService(name, apiClient, activateTrial, progress) } - return "", nil, fmt.Errorf("error creating service: %w", err) + return serviceID, serviceVersion, fmt.Errorf("error creating service: %w", err) } - serviceID := service.ID - serviceVersion := &fastly.Version{Number: 1} - - return serviceID, serviceVersion, nil + return service.ID, &fastly.Version{Number: 1}, nil } // updateManifestServiceID updates the Service ID in the manifest. @@ -624,6 +672,19 @@ func manageExistingServiceFlow( return serviceVersion, err } + // Validate that we're dealing with a Compute@Edge 'wasm' service and not a + // VCL service, for which we cannot upload a wasm package format to. + serviceDetails, err := apiClient.GetServiceDetails(&fastly.GetServiceInput{ID: serviceID}) + if err != nil { + return serviceVersion, err + } + if serviceDetails.Type != "wasm" { + return serviceVersion, fsterr.RemediationError{ + Inner: fmt.Errorf("invalid service type: %s", serviceDetails.Type), + Remediation: "Ensure the provided Service ID is associated with a 'Wasm' Fastly Service and not a 'VCL' Fastly service. " + fsterr.ComputeTrialRemediation, + } + } + // Unlike other CLI commands that are a direct mapping to an API endpoint, // the compute deploy command is a composite of behaviours, and so as we // already automatically activate a version we should autoclone without diff --git a/pkg/commands/compute/deploy_test.go b/pkg/commands/compute/deploy_test.go index 2280b9ae4..34e6c8419 100644 --- a/pkg/commands/compute/deploy_test.go +++ b/pkg/commands/compute/deploy_test.go @@ -160,8 +160,9 @@ func TestDeploy(t *testing.T) { name: "service version is active, clone version error", args: args("compute deploy --service-id 123 --token 123 --version 1"), api: mock.API{ - CloneVersionFn: testutil.CloneVersionError, - ListVersionsFn: testutil.ListVersions, + CloneVersionFn: testutil.CloneVersionError, + GetServiceDetailsFn: getServiceDetailsWasm, + ListVersionsFn: testutil.ListVersions, }, wantError: fmt.Sprintf("error cloning service version: %s", testutil.Err.Error()), }, @@ -169,9 +170,10 @@ func TestDeploy(t *testing.T) { name: "list domains error", args: args("compute deploy --service-id 123 --token 123"), api: mock.API{ - GetServiceFn: getServiceOK, - ListDomainsFn: listDomainsError, - ListVersionsFn: testutil.ListVersions, + GetServiceDetailsFn: getServiceDetailsWasm, + GetServiceFn: getServiceOK, + ListDomainsFn: listDomainsError, + ListVersionsFn: testutil.ListVersions, }, wantError: fmt.Sprintf("error fetching service domains: %s", testutil.Err.Error()), }, @@ -283,14 +285,15 @@ func TestDeploy(t *testing.T) { name: "activate error", args: args("compute deploy --service-id 123 --token 123"), api: mock.API{ - ActivateVersionFn: activateVersionError, - CreateDomainFn: createDomainOK, - DeleteDomainFn: deleteDomainOK, - GetPackageFn: getPackageOk, - GetServiceFn: getServiceOK, - ListDomainsFn: listDomainsNone, - ListVersionsFn: testutil.ListVersions, - UpdatePackageFn: updatePackageOk, + ActivateVersionFn: activateVersionError, + CreateDomainFn: createDomainOK, + DeleteDomainFn: deleteDomainOK, + GetPackageFn: getPackageOk, + GetServiceFn: getServiceOK, + GetServiceDetailsFn: getServiceDetailsWasm, + ListDomainsFn: listDomainsNone, + ListVersionsFn: testutil.ListVersions, + UpdatePackageFn: updatePackageOk, }, wantError: fmt.Sprintf("error activating version: %s", testutil.Err.Error()), wantOutput: []string{ @@ -303,10 +306,11 @@ func TestDeploy(t *testing.T) { name: "identical package", args: args("compute deploy --service-id 123 --token 123"), api: mock.API{ - GetPackageFn: getPackageIdentical, - GetServiceFn: getServiceOK, - ListDomainsFn: listDomainsOk, - ListVersionsFn: testutil.ListVersions, + GetPackageFn: getPackageIdentical, + GetServiceFn: getServiceOK, + GetServiceDetailsFn: getServiceDetailsWasm, + ListDomainsFn: listDomainsOk, + ListVersionsFn: testutil.ListVersions, }, wantOutput: []string{ "Skipping package deployment", @@ -316,12 +320,13 @@ func TestDeploy(t *testing.T) { name: "success", args: args("compute deploy --service-id 123 --token 123"), api: mock.API{ - ActivateVersionFn: activateVersionOk, - GetPackageFn: getPackageOk, - GetServiceFn: getServiceOK, - ListDomainsFn: listDomainsOk, - ListVersionsFn: testutil.ListVersions, - UpdatePackageFn: updatePackageOk, + ActivateVersionFn: activateVersionOk, + GetPackageFn: getPackageOk, + GetServiceFn: getServiceOK, + GetServiceDetailsFn: getServiceDetailsWasm, + ListDomainsFn: listDomainsOk, + ListVersionsFn: testutil.ListVersions, + UpdatePackageFn: updatePackageOk, }, wantOutput: []string{ "Uploading package...", @@ -337,12 +342,13 @@ func TestDeploy(t *testing.T) { name: "success with path", args: args("compute deploy --service-id 123 --token 123 --package pkg/package.tar.gz --version latest"), api: mock.API{ - ActivateVersionFn: activateVersionOk, - GetPackageFn: getPackageOk, - GetServiceFn: getServiceOK, - ListDomainsFn: listDomainsOk, - ListVersionsFn: testutil.ListVersions, - UpdatePackageFn: updatePackageOk, + ActivateVersionFn: activateVersionOk, + GetPackageFn: getPackageOk, + GetServiceFn: getServiceOK, + GetServiceDetailsFn: getServiceDetailsWasm, + ListDomainsFn: listDomainsOk, + ListVersionsFn: testutil.ListVersions, + UpdatePackageFn: updatePackageOk, }, wantOutput: []string{ "Uploading package...", @@ -362,12 +368,13 @@ func TestDeploy(t *testing.T) { name: "success with path called from non project directory", args: args("compute deploy --service-id 123 --token 123 --package pkg/package.tar.gz --version latest"), api: mock.API{ - ActivateVersionFn: activateVersionOk, - GetPackageFn: getPackageOk, - GetServiceFn: getServiceOK, - ListDomainsFn: listDomainsOk, - ListVersionsFn: testutil.ListVersions, - UpdatePackageFn: updatePackageOk, + ActivateVersionFn: activateVersionOk, + GetPackageFn: getPackageOk, + GetServiceFn: getServiceOK, + GetServiceDetailsFn: getServiceDetailsWasm, + ListDomainsFn: listDomainsOk, + ListVersionsFn: testutil.ListVersions, + UpdatePackageFn: updatePackageOk, }, noManifest: true, wantOutput: []string{ @@ -385,12 +392,13 @@ func TestDeploy(t *testing.T) { name: "success with inactive version", args: args("compute deploy --service-id 123 --token 123 --package pkg/package.tar.gz"), api: mock.API{ - ActivateVersionFn: activateVersionOk, - GetPackageFn: getPackageOk, - GetServiceFn: getServiceOK, - ListDomainsFn: listDomainsOk, - ListVersionsFn: testutil.ListVersions, - UpdatePackageFn: updatePackageOk, + ActivateVersionFn: activateVersionOk, + GetPackageFn: getPackageOk, + GetServiceFn: getServiceOK, + GetServiceDetailsFn: getServiceDetailsWasm, + ListDomainsFn: listDomainsOk, + ListVersionsFn: testutil.ListVersions, + UpdatePackageFn: updatePackageOk, }, wantOutput: []string{ "Uploading package...", @@ -402,13 +410,14 @@ func TestDeploy(t *testing.T) { name: "success with specific locked version", args: args("compute deploy --service-id 123 --token 123 --package pkg/package.tar.gz --version 2"), api: mock.API{ - ActivateVersionFn: activateVersionOk, - CloneVersionFn: testutil.CloneVersionResult(4), - GetPackageFn: getPackageOk, - GetServiceFn: getServiceOK, - ListDomainsFn: listDomainsOk, - ListVersionsFn: testutil.ListVersions, - UpdatePackageFn: updatePackageOk, + ActivateVersionFn: activateVersionOk, + CloneVersionFn: testutil.CloneVersionResult(4), + GetPackageFn: getPackageOk, + GetServiceFn: getServiceOK, + GetServiceDetailsFn: getServiceDetailsWasm, + ListDomainsFn: listDomainsOk, + ListVersionsFn: testutil.ListVersions, + UpdatePackageFn: updatePackageOk, }, wantOutput: []string{ "Uploading package...", @@ -420,13 +429,14 @@ func TestDeploy(t *testing.T) { name: "success with active version", args: args("compute deploy --service-id 123 --token 123 --package pkg/package.tar.gz --version active"), api: mock.API{ - ActivateVersionFn: activateVersionOk, - CloneVersionFn: testutil.CloneVersionResult(4), - GetPackageFn: getPackageOk, - GetServiceFn: getServiceOK, - ListDomainsFn: listDomainsOk, - ListVersionsFn: testutil.ListVersions, - UpdatePackageFn: updatePackageOk, + ActivateVersionFn: activateVersionOk, + CloneVersionFn: testutil.CloneVersionResult(4), + GetPackageFn: getPackageOk, + GetServiceFn: getServiceOK, + GetServiceDetailsFn: getServiceDetailsWasm, + ListDomainsFn: listDomainsOk, + ListVersionsFn: testutil.ListVersions, + UpdatePackageFn: updatePackageOk, }, wantOutput: []string{ "Uploading package...", @@ -438,14 +448,15 @@ func TestDeploy(t *testing.T) { name: "success with comment", args: args("compute deploy --service-id 123 --token 123 --package pkg/package.tar.gz --version 2 --comment foo"), api: mock.API{ - ActivateVersionFn: activateVersionOk, - CloneVersionFn: testutil.CloneVersionResult(4), - GetPackageFn: getPackageOk, - GetServiceFn: getServiceOK, - ListDomainsFn: listDomainsOk, - ListVersionsFn: testutil.ListVersions, - UpdatePackageFn: updatePackageOk, - UpdateVersionFn: updateVersionOk, + ActivateVersionFn: activateVersionOk, + CloneVersionFn: testutil.CloneVersionResult(4), + GetPackageFn: getPackageOk, + GetServiceFn: getServiceOK, + GetServiceDetailsFn: getServiceDetailsWasm, + ListDomainsFn: listDomainsOk, + ListVersionsFn: testutil.ListVersions, + UpdatePackageFn: updatePackageOk, + UpdateVersionFn: updateVersionOk, }, wantOutput: []string{ "Uploading package...", @@ -747,14 +758,15 @@ func TestDeploy(t *testing.T) { name: "success with no setup.backends configuration and use of --accept-defaults", args: args("compute deploy --accept-defaults --token 123"), api: mock.API{ - ActivateVersionFn: activateVersionOk, - CreateBackendFn: createBackendOK, - CreateServiceFn: createServiceOK, - GetPackageFn: getPackageOk, - GetServiceFn: getServiceOK, - ListDomainsFn: listDomainsOk, - ListVersionsFn: testutil.ListVersions, - UpdatePackageFn: updatePackageOk, + ActivateVersionFn: activateVersionOk, + CreateBackendFn: createBackendOK, + CreateServiceFn: createServiceOK, + GetPackageFn: getPackageOk, + GetServiceFn: getServiceOK, + GetServiceDetailsFn: getServiceDetailsWasm, + ListDomainsFn: listDomainsOk, + ListVersionsFn: testutil.ListVersions, + UpdatePackageFn: updatePackageOk, }, wantOutput: []string{ "SUCCESS: Deployed package (service 12345, version 1)", @@ -773,13 +785,14 @@ func TestDeploy(t *testing.T) { name: "success with setup.backends configuration and existing service", args: args("compute deploy --service-id 123 --token 123"), api: mock.API{ - ActivateVersionFn: activateVersionOk, - CreateBackendFn: createBackendOK, - GetPackageFn: getPackageOk, - GetServiceFn: getServiceOK, - ListDomainsFn: listDomainsOk, - ListVersionsFn: testutil.ListVersions, - UpdatePackageFn: updatePackageOk, + ActivateVersionFn: activateVersionOk, + CreateBackendFn: createBackendOK, + GetPackageFn: getPackageOk, + GetServiceFn: getServiceOK, + GetServiceDetailsFn: getServiceDetailsWasm, + ListDomainsFn: listDomainsOk, + ListVersionsFn: testutil.ListVersions, + UpdatePackageFn: updatePackageOk, }, manifest: ` name = "package" @@ -813,13 +826,14 @@ func TestDeploy(t *testing.T) { name: "success with setup.dictionaries configuration and existing service", args: args("compute deploy --service-id 123 --token 123"), api: mock.API{ - ActivateVersionFn: activateVersionOk, - CreateBackendFn: createBackendOK, - GetPackageFn: getPackageOk, - GetServiceFn: getServiceOK, - ListDomainsFn: listDomainsOk, - ListVersionsFn: testutil.ListVersions, - UpdatePackageFn: updatePackageOk, + ActivateVersionFn: activateVersionOk, + CreateBackendFn: createBackendOK, + GetPackageFn: getPackageOk, + GetServiceFn: getServiceOK, + GetServiceDetailsFn: getServiceDetailsWasm, + ListDomainsFn: listDomainsOk, + ListVersionsFn: testutil.ListVersions, + UpdatePackageFn: updatePackageOk, }, manifest: ` name = "package" @@ -861,6 +875,7 @@ func TestDeploy(t *testing.T) { CreateServiceFn: createServiceOK, GetPackageFn: getPackageOk, GetServiceFn: getServiceOK, + GetServiceDetailsFn: getServiceDetailsWasm, ListDomainsFn: listDomainsOk, ListVersionsFn: testutil.ListVersions, UpdatePackageFn: updatePackageOk, @@ -909,6 +924,7 @@ func TestDeploy(t *testing.T) { CreateServiceFn: createServiceOK, GetPackageFn: getPackageOk, GetServiceFn: getServiceOK, + GetServiceDetailsFn: getServiceDetailsWasm, ListDomainsFn: listDomainsOk, ListVersionsFn: testutil.ListVersions, UpdatePackageFn: updatePackageOk, @@ -951,6 +967,7 @@ func TestDeploy(t *testing.T) { CreateServiceFn: createServiceOK, GetPackageFn: getPackageOk, GetServiceFn: getServiceOK, + GetServiceDetailsFn: getServiceDetailsWasm, ListDomainsFn: listDomainsOk, ListVersionsFn: testutil.ListVersions, UpdatePackageFn: updatePackageOk, @@ -992,13 +1009,14 @@ func TestDeploy(t *testing.T) { name: "success with setup.log_entries configuration and existing service", args: args("compute deploy --service-id 123 --token 123"), api: mock.API{ - ActivateVersionFn: activateVersionOk, - CreateBackendFn: createBackendOK, - GetPackageFn: getPackageOk, - GetServiceFn: getServiceOK, - ListDomainsFn: listDomainsOk, - ListVersionsFn: testutil.ListVersions, - UpdatePackageFn: updatePackageOk, + ActivateVersionFn: activateVersionOk, + CreateBackendFn: createBackendOK, + GetPackageFn: getPackageOk, + GetServiceFn: getServiceOK, + GetServiceDetailsFn: getServiceDetailsWasm, + ListDomainsFn: listDomainsOk, + ListVersionsFn: testutil.ListVersions, + UpdatePackageFn: updatePackageOk, }, manifest: ` name = "package" @@ -1033,6 +1051,7 @@ func TestDeploy(t *testing.T) { CreateServiceFn: createServiceOK, GetPackageFn: getPackageOk, GetServiceFn: getServiceOK, + GetServiceDetailsFn: getServiceDetailsWasm, ListDomainsFn: listDomainsOk, ListVersionsFn: testutil.ListVersions, UpdatePackageFn: updatePackageOk, @@ -1071,6 +1090,7 @@ func TestDeploy(t *testing.T) { CreateServiceFn: createServiceOK, GetPackageFn: getPackageOk, GetServiceFn: getServiceOK, + GetServiceDetailsFn: getServiceDetailsWasm, ListDomainsFn: listDomainsOk, ListVersionsFn: testutil.ListVersions, UpdatePackageFn: updatePackageOk, @@ -1110,6 +1130,7 @@ func TestDeploy(t *testing.T) { CreateServiceFn: createServiceOK, GetPackageFn: getPackageOk, GetServiceFn: getServiceOK, + GetServiceDetailsFn: getServiceDetailsWasm, ListDomainsFn: listDomainsOk, ListVersionsFn: testutil.ListVersions, UpdatePackageFn: updatePackageOk, diff --git a/pkg/commands/compute/init.go b/pkg/commands/compute/init.go index e1a2bcf1c..433cf81f9 100644 --- a/pkg/commands/compute/init.go +++ b/pkg/commands/compute/init.go @@ -34,7 +34,6 @@ type InitCommand struct { cmd.Base branch string - client api.HTTPClient dir string from string language string @@ -46,10 +45,9 @@ type InitCommand struct { var Languages = []string{"rust", "assemblyscript", "javascript", "other"} // NewInitCommand returns a usable command registered under the parent. -func NewInitCommand(parent cmd.Registerer, client api.HTTPClient, globals *config.Data, data manifest.Data) *InitCommand { +func NewInitCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *InitCommand { var c InitCommand c.Globals = globals - c.client = client c.manifest = data c.CmdClause = parent.Command("init", "Initialize a new Compute@Edge package locally") c.CmdClause.Flag("name", "Name of package, falls back to --directory").Short('n').StringVar(&c.manifest.File.Name) @@ -135,7 +133,7 @@ func (c *InitCommand) Exec(in io.Reader, out io.Writer) (err error) { return err } - languages := NewLanguages(c.Globals.File.StarterKits, c.client, c.Globals, name, mf.Scripts.Build) + languages := NewLanguages(c.Globals.File.StarterKits, c.Globals, name, mf.Scripts.Build) language, err := selectLanguage(c.from, c.language, languages, mf, in, out) if err != nil { c.Globals.ErrLog.AddWithContext(err, map[string]interface{}{ @@ -166,7 +164,7 @@ func (c *InitCommand) Exec(in io.Reader, out io.Writer) (err error) { // whether --verbose was set or not. progress = text.NewProgress(out, c.Globals.Verbose()) - err = fetchPackageTemplate(language, c.from, branch, tag, c.dir, mf, file.Archives, progress, c.client, out, c.Globals.ErrLog) + err = fetchPackageTemplate(language, c.from, branch, tag, c.dir, mf, file.Archives, progress, c.Globals.HTTPClient, out, c.Globals.ErrLog) if err != nil { c.Globals.ErrLog.AddWithContext(err, map[string]interface{}{ "From": from, diff --git a/pkg/commands/compute/language.go b/pkg/commands/compute/language.go index de69351d9..6a0d9f04b 100644 --- a/pkg/commands/compute/language.go +++ b/pkg/commands/compute/language.go @@ -6,7 +6,6 @@ import ( "sort" "strings" - "github.com/fastly/cli/pkg/api" "github.com/fastly/cli/pkg/config" ) @@ -15,13 +14,13 @@ import ( // NOTE: The 'timeout' value zero is passed into each New call as it's // only useful during the `compute build` phase and is expected to be // provided by the user via a flag on the build command. -func NewLanguages(kits config.StarterKitLanguages, c api.HTTPClient, d *config.Data, pkgName, customBuild string) []*Language { +func NewLanguages(kits config.StarterKitLanguages, d *config.Data, pkgName, customBuild string) []*Language { return []*Language{ NewLanguage(&LanguageOptions{ Name: "rust", DisplayName: "Rust", StarterKits: kits.Rust, - Toolchain: NewRust(c, d.File.Language.Rust, d.ErrLog, 0, pkgName, customBuild), + Toolchain: NewRust(d.HTTPClient, d.File.Language.Rust, d.ErrLog, 0, pkgName, customBuild), }), NewLanguage(&LanguageOptions{ Name: "assemblyscript", diff --git a/pkg/commands/compute/update.go b/pkg/commands/compute/update.go index fcb9a4adf..741c90bd3 100644 --- a/pkg/commands/compute/update.go +++ b/pkg/commands/compute/update.go @@ -4,7 +4,6 @@ import ( "fmt" "io" - "github.com/fastly/cli/pkg/api" "github.com/fastly/cli/pkg/cmd" "github.com/fastly/cli/pkg/config" "github.com/fastly/cli/pkg/errors" @@ -24,7 +23,7 @@ type UpdateCommand struct { } // NewUpdateCommand returns a usable command registered under the parent. -func NewUpdateCommand(parent cmd.Registerer, client api.HTTPClient, globals *config.Data, data manifest.Data) *UpdateCommand { +func NewUpdateCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *UpdateCommand { var c UpdateCommand c.Globals = globals c.manifest = data @@ -64,7 +63,7 @@ func (c *UpdateCommand) Exec(in io.Reader, out io.Writer) (err error) { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.autoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -91,7 +90,7 @@ func (c *UpdateCommand) Exec(in io.Reader, out io.Writer) (err error) { }() progress.Step("Uploading package...") - _, err = c.Globals.Client.UpdatePackage(&fastly.UpdatePackageInput{ + _, err = c.Globals.APIClient.UpdatePackage(&fastly.UpdatePackageInput{ ServiceID: serviceID, ServiceVersion: serviceVersion.Number, PackagePath: c.path, diff --git a/pkg/commands/dictionary/create.go b/pkg/commands/dictionary/create.go index 887d71249..e16d609fb 100644 --- a/pkg/commands/dictionary/create.go +++ b/pkg/commands/dictionary/create.go @@ -61,7 +61,7 @@ func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest func (c *CreateCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.autoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -91,7 +91,7 @@ func (c *CreateCommand) Exec(in io.Reader, out io.Writer) error { c.Input.WriteOnly = fastly.Compatibool(writeOnly) } - d, err := c.Globals.Client.CreateDictionary(&c.Input) + d, err := c.Globals.APIClient.CreateDictionary(&c.Input) if err != nil { c.Globals.ErrLog.AddWithContext(err, map[string]interface{}{ "Service ID": serviceID, diff --git a/pkg/commands/dictionary/delete.go b/pkg/commands/dictionary/delete.go index a0664fc0a..2da8e21be 100644 --- a/pkg/commands/dictionary/delete.go +++ b/pkg/commands/dictionary/delete.go @@ -57,7 +57,7 @@ func NewDeleteCommand(parent cmd.Registerer, globals *config.Data, data manifest func (c *DeleteCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.autoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -75,7 +75,7 @@ func (c *DeleteCommand) Exec(in io.Reader, out io.Writer) error { c.Input.ServiceID = serviceID c.Input.ServiceVersion = serviceVersion.Number - err = c.Globals.Client.DeleteDictionary(&c.Input) + err = c.Globals.APIClient.DeleteDictionary(&c.Input) if err != nil { c.Globals.ErrLog.AddWithContext(err, map[string]interface{}{ "Service ID": serviceID, diff --git a/pkg/commands/dictionary/describe.go b/pkg/commands/dictionary/describe.go index 34f94eacd..da68efd1a 100644 --- a/pkg/commands/dictionary/describe.go +++ b/pkg/commands/dictionary/describe.go @@ -65,7 +65,7 @@ func (c *DescribeCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AllowActiveLocked: true, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -83,7 +83,7 @@ func (c *DescribeCommand) Exec(in io.Reader, out io.Writer) error { c.Input.ServiceID = serviceID c.Input.ServiceVersion = serviceVersion.Number - dictionary, err := c.Globals.Client.GetDictionary(&c.Input) + dictionary, err := c.Globals.APIClient.GetDictionary(&c.Input) if err != nil { c.Globals.ErrLog.AddWithContext(err, map[string]interface{}{ "Service ID": serviceID, @@ -102,7 +102,7 @@ func (c *DescribeCommand) Exec(in io.Reader, out io.Writer) error { ServiceVersion: c.Input.ServiceVersion, ID: dictionary.ID, } - info, err = c.Globals.Client.GetDictionaryInfo(&infoInput) + info, err = c.Globals.APIClient.GetDictionaryInfo(&infoInput) if err != nil { c.Globals.ErrLog.AddWithContext(err, map[string]interface{}{ "Service ID": serviceID, @@ -114,7 +114,7 @@ func (c *DescribeCommand) Exec(in io.Reader, out io.Writer) error { ServiceID: c.Input.ServiceID, DictionaryID: dictionary.ID, } - items, err = c.Globals.Client.ListDictionaryItems(&itemInput) + items, err = c.Globals.APIClient.ListDictionaryItems(&itemInput) if err != nil { c.Globals.ErrLog.AddWithContext(err, map[string]interface{}{ "Service ID": serviceID, diff --git a/pkg/commands/dictionary/list.go b/pkg/commands/dictionary/list.go index 83189f2fc..f08c0718a 100644 --- a/pkg/commands/dictionary/list.go +++ b/pkg/commands/dictionary/list.go @@ -63,7 +63,7 @@ func (c *ListCommand) Exec(in io.Reader, out io.Writer) error { } serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AllowActiveLocked: true, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -81,7 +81,7 @@ func (c *ListCommand) Exec(in io.Reader, out io.Writer) error { c.Input.ServiceID = serviceID c.Input.ServiceVersion = serviceVersion.Number - dictionaries, err := c.Globals.Client.ListDictionaries(&c.Input) + dictionaries, err := c.Globals.APIClient.ListDictionaries(&c.Input) if err != nil { c.Globals.ErrLog.AddWithContext(err, map[string]interface{}{ "Service ID": serviceID, diff --git a/pkg/commands/dictionary/update.go b/pkg/commands/dictionary/update.go index 4bf67b430..51e13334c 100644 --- a/pkg/commands/dictionary/update.go +++ b/pkg/commands/dictionary/update.go @@ -65,7 +65,7 @@ func NewUpdateCommand(parent cmd.Registerer, globals *config.Data, data manifest func (c *UpdateCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.autoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -103,7 +103,7 @@ func (c *UpdateCommand) Exec(in io.Reader, out io.Writer) error { c.input.WriteOnly = fastly.CBool(writeOnly) } - d, err := c.Globals.Client.UpdateDictionary(&c.input) + d, err := c.Globals.APIClient.UpdateDictionary(&c.input) if err != nil { c.Globals.ErrLog.AddWithContext(err, map[string]interface{}{ "Service ID": serviceID, diff --git a/pkg/commands/dictionaryitem/create.go b/pkg/commands/dictionaryitem/create.go index c7e88b870..e110c2f43 100644 --- a/pkg/commands/dictionaryitem/create.go +++ b/pkg/commands/dictionaryitem/create.go @@ -44,7 +44,7 @@ func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest // Exec invokes the application logic for the command. func (c *CreateCommand) Exec(in io.Reader, out io.Writer) error { - serviceID, source, flag, err := cmd.ServiceID(c.serviceName, c.manifest, c.Globals.Client, c.Globals.ErrLog) + serviceID, source, flag, err := cmd.ServiceID(c.serviceName, c.manifest, c.Globals.APIClient, c.Globals.ErrLog) if err != nil { return err } @@ -54,7 +54,7 @@ func (c *CreateCommand) Exec(in io.Reader, out io.Writer) error { c.Input.ServiceID = serviceID - _, err = c.Globals.Client.CreateDictionaryItem(&c.Input) + _, err = c.Globals.APIClient.CreateDictionaryItem(&c.Input) if err != nil { c.Globals.ErrLog.AddWithContext(err, map[string]interface{}{ "Service ID": serviceID, diff --git a/pkg/commands/dictionaryitem/delete.go b/pkg/commands/dictionaryitem/delete.go index 7c0af6272..9322dcb5d 100644 --- a/pkg/commands/dictionaryitem/delete.go +++ b/pkg/commands/dictionaryitem/delete.go @@ -43,7 +43,7 @@ func NewDeleteCommand(parent cmd.Registerer, globals *config.Data, data manifest // Exec invokes the application logic for the command. func (c *DeleteCommand) Exec(in io.Reader, out io.Writer) error { - serviceID, source, flag, err := cmd.ServiceID(c.serviceName, c.manifest, c.Globals.Client, c.Globals.ErrLog) + serviceID, source, flag, err := cmd.ServiceID(c.serviceName, c.manifest, c.Globals.APIClient, c.Globals.ErrLog) if err != nil { return err } @@ -53,7 +53,7 @@ func (c *DeleteCommand) Exec(in io.Reader, out io.Writer) error { c.Input.ServiceID = serviceID - err = c.Globals.Client.DeleteDictionaryItem(&c.Input) + err = c.Globals.APIClient.DeleteDictionaryItem(&c.Input) if err != nil { c.Globals.ErrLog.AddWithContext(err, map[string]interface{}{ "Service ID": serviceID, diff --git a/pkg/commands/dictionaryitem/describe.go b/pkg/commands/dictionaryitem/describe.go index c581d7515..0713c8602 100644 --- a/pkg/commands/dictionaryitem/describe.go +++ b/pkg/commands/dictionaryitem/describe.go @@ -57,7 +57,7 @@ func (c *DescribeCommand) Exec(in io.Reader, out io.Writer) error { return fsterr.ErrInvalidVerboseJSONCombo } - serviceID, source, flag, err := cmd.ServiceID(c.serviceName, c.manifest, c.Globals.Client, c.Globals.ErrLog) + serviceID, source, flag, err := cmd.ServiceID(c.serviceName, c.manifest, c.Globals.APIClient, c.Globals.ErrLog) if err != nil { return err } @@ -67,7 +67,7 @@ func (c *DescribeCommand) Exec(in io.Reader, out io.Writer) error { c.Input.ServiceID = serviceID - item, err := c.Globals.Client.GetDictionaryItem(&c.Input) + item, err := c.Globals.APIClient.GetDictionaryItem(&c.Input) if err != nil { c.Globals.ErrLog.AddWithContext(err, map[string]interface{}{ "Service ID": serviceID, diff --git a/pkg/commands/dictionaryitem/list.go b/pkg/commands/dictionaryitem/list.go index 17e8b8ba2..50da94f77 100644 --- a/pkg/commands/dictionaryitem/list.go +++ b/pkg/commands/dictionaryitem/list.go @@ -60,7 +60,7 @@ func (c *ListCommand) Exec(in io.Reader, out io.Writer) error { return fsterr.ErrInvalidVerboseJSONCombo } - serviceID, source, flag, err := cmd.ServiceID(c.serviceName, c.manifest, c.Globals.Client, c.Globals.ErrLog) + serviceID, source, flag, err := cmd.ServiceID(c.serviceName, c.manifest, c.Globals.APIClient, c.Globals.ErrLog) if err != nil { return err } @@ -69,7 +69,7 @@ func (c *ListCommand) Exec(in io.Reader, out io.Writer) error { } c.input.ServiceID = serviceID - paginator := c.Globals.Client.NewListDictionaryItemsPaginator(&c.input) + paginator := c.Globals.APIClient.NewListDictionaryItemsPaginator(&c.input) var ds []*fastly.DictionaryItem for paginator.HasNext() { diff --git a/pkg/commands/dictionaryitem/update.go b/pkg/commands/dictionaryitem/update.go index b039d604f..3d50dd43a 100644 --- a/pkg/commands/dictionaryitem/update.go +++ b/pkg/commands/dictionaryitem/update.go @@ -51,7 +51,7 @@ func NewUpdateCommand(parent cmd.Registerer, globals *config.Data, data manifest // Exec invokes the application logic for the command. func (c *UpdateCommand) Exec(in io.Reader, out io.Writer) error { - serviceID, source, flag, err := cmd.ServiceID(c.serviceName, c.manifest, c.Globals.Client, c.Globals.ErrLog) + serviceID, source, flag, err := cmd.ServiceID(c.serviceName, c.manifest, c.Globals.APIClient, c.Globals.ErrLog) if err != nil { return err } @@ -76,7 +76,7 @@ func (c *UpdateCommand) Exec(in io.Reader, out io.Writer) error { return fmt.Errorf("an empty value is not allowed for either the '--key' or '--value' flags") } - d, err := c.Globals.Client.UpdateDictionaryItem(&c.Input) + d, err := c.Globals.APIClient.UpdateDictionaryItem(&c.Input) if err != nil { c.Globals.ErrLog.Add(err) return err @@ -111,7 +111,7 @@ func (c *UpdateCommand) batchModify(out io.Writer) error { return fmt.Errorf("item key not found in file %s", c.file.Value) } - err = c.Globals.Client.BatchModifyDictionaryItems(&c.InputBatch) + err = c.Globals.APIClient.BatchModifyDictionaryItems(&c.InputBatch) if err != nil { c.Globals.ErrLog.Add(err) return err diff --git a/pkg/commands/domain/create.go b/pkg/commands/domain/create.go index 76899c6e9..72232d951 100644 --- a/pkg/commands/domain/create.go +++ b/pkg/commands/domain/create.go @@ -58,7 +58,7 @@ func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest func (c *CreateCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.autoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -76,7 +76,7 @@ func (c *CreateCommand) Exec(in io.Reader, out io.Writer) error { c.Input.ServiceID = serviceID c.Input.ServiceVersion = serviceVersion.Number - d, err := c.Globals.Client.CreateDomain(&c.Input) + d, err := c.Globals.APIClient.CreateDomain(&c.Input) if err != nil { c.Globals.ErrLog.AddWithContext(err, map[string]interface{}{ "Service ID": serviceID, diff --git a/pkg/commands/domain/delete.go b/pkg/commands/domain/delete.go index 71219b71d..39de63cb1 100644 --- a/pkg/commands/domain/delete.go +++ b/pkg/commands/domain/delete.go @@ -57,7 +57,7 @@ func NewDeleteCommand(parent cmd.Registerer, globals *config.Data, data manifest func (c *DeleteCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.autoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -75,7 +75,7 @@ func (c *DeleteCommand) Exec(in io.Reader, out io.Writer) error { c.Input.ServiceID = serviceID c.Input.ServiceVersion = serviceVersion.Number - if err := c.Globals.Client.DeleteDomain(&c.Input); err != nil { + if err := c.Globals.APIClient.DeleteDomain(&c.Input); err != nil { c.Globals.ErrLog.AddWithContext(err, map[string]interface{}{ "Service ID": serviceID, "Service Version": serviceVersion.Number, diff --git a/pkg/commands/domain/describe.go b/pkg/commands/domain/describe.go index d9d2b832a..4c40aa1dc 100644 --- a/pkg/commands/domain/describe.go +++ b/pkg/commands/domain/describe.go @@ -64,7 +64,7 @@ func (c *DescribeCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AllowActiveLocked: true, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -82,7 +82,7 @@ func (c *DescribeCommand) Exec(in io.Reader, out io.Writer) error { c.Input.ServiceID = serviceID c.Input.ServiceVersion = serviceVersion.Number - domain, err := c.Globals.Client.GetDomain(&c.Input) + domain, err := c.Globals.APIClient.GetDomain(&c.Input) if err != nil { c.Globals.ErrLog.AddWithContext(err, map[string]interface{}{ "Service ID": serviceID, diff --git a/pkg/commands/domain/list.go b/pkg/commands/domain/list.go index 4f2d5ddf9..c631c4374 100644 --- a/pkg/commands/domain/list.go +++ b/pkg/commands/domain/list.go @@ -64,7 +64,7 @@ func (c *ListCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AllowActiveLocked: true, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -82,7 +82,7 @@ func (c *ListCommand) Exec(in io.Reader, out io.Writer) error { c.Input.ServiceID = serviceID c.Input.ServiceVersion = serviceVersion.Number - domains, err := c.Globals.Client.ListDomains(&c.Input) + domains, err := c.Globals.APIClient.ListDomains(&c.Input) if err != nil { c.Globals.ErrLog.AddWithContext(err, map[string]interface{}{ "Service ID": serviceID, diff --git a/pkg/commands/domain/update.go b/pkg/commands/domain/update.go index 2c419b7bd..501218f3c 100644 --- a/pkg/commands/domain/update.go +++ b/pkg/commands/domain/update.go @@ -63,7 +63,7 @@ func NewUpdateCommand(parent cmd.Registerer, globals *config.Data, data manifest func (c *UpdateCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.autoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -93,7 +93,7 @@ func (c *UpdateCommand) Exec(in io.Reader, out io.Writer) error { c.input.Comment = fastly.String(c.Comment.Value) } - d, err := c.Globals.Client.UpdateDomain(&c.input) + d, err := c.Globals.APIClient.UpdateDomain(&c.input) if err != nil { c.Globals.ErrLog.AddWithContext(err, map[string]interface{}{ "Service ID": serviceID, diff --git a/pkg/commands/domain/validate.go b/pkg/commands/domain/validate.go index 80ba4a834..22893f254 100644 --- a/pkg/commands/domain/validate.go +++ b/pkg/commands/domain/validate.go @@ -65,7 +65,7 @@ func (c *ValidateCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AllowActiveLocked: true, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -83,7 +83,7 @@ func (c *ValidateCommand) Exec(in io.Reader, out io.Writer) error { if c.all { input := c.constructInputAll(serviceID, serviceVersion.Number) - r, err := c.Globals.Client.ValidateAllDomains(input) + r, err := c.Globals.APIClient.ValidateAllDomains(input) if err != nil { c.Globals.ErrLog.AddWithContext(err, map[string]interface{}{ "Service ID": serviceID, @@ -101,7 +101,7 @@ func (c *ValidateCommand) Exec(in io.Reader, out io.Writer) error { return err } - r, err := c.Globals.Client.ValidateDomain(input) + r, err := c.Globals.APIClient.ValidateDomain(input) if err != nil { c.Globals.ErrLog.AddWithContext(err, map[string]interface{}{ "Service ID": serviceID, diff --git a/pkg/commands/healthcheck/create.go b/pkg/commands/healthcheck/create.go index d13073818..dec0d8d96 100644 --- a/pkg/commands/healthcheck/create.go +++ b/pkg/commands/healthcheck/create.go @@ -68,7 +68,7 @@ func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest func (c *CreateCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.autoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -86,7 +86,7 @@ func (c *CreateCommand) Exec(in io.Reader, out io.Writer) error { c.Input.ServiceID = serviceID c.Input.ServiceVersion = serviceVersion.Number - h, err := c.Globals.Client.CreateHealthCheck(&c.Input) + h, err := c.Globals.APIClient.CreateHealthCheck(&c.Input) if err != nil { c.Globals.ErrLog.AddWithContext(err, map[string]interface{}{ "Service ID": serviceID, diff --git a/pkg/commands/healthcheck/delete.go b/pkg/commands/healthcheck/delete.go index 014cc304d..61a97839b 100644 --- a/pkg/commands/healthcheck/delete.go +++ b/pkg/commands/healthcheck/delete.go @@ -57,7 +57,7 @@ func NewDeleteCommand(parent cmd.Registerer, globals *config.Data, data manifest func (c *DeleteCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.autoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -75,7 +75,7 @@ func (c *DeleteCommand) Exec(in io.Reader, out io.Writer) error { c.Input.ServiceID = serviceID c.Input.ServiceVersion = serviceVersion.Number - if err := c.Globals.Client.DeleteHealthCheck(&c.Input); err != nil { + if err := c.Globals.APIClient.DeleteHealthCheck(&c.Input); err != nil { c.Globals.ErrLog.AddWithContext(err, map[string]interface{}{ "Service ID": serviceID, "Service Version": serviceVersion.Number, diff --git a/pkg/commands/healthcheck/describe.go b/pkg/commands/healthcheck/describe.go index 4ecdfbbb9..6e3774945 100644 --- a/pkg/commands/healthcheck/describe.go +++ b/pkg/commands/healthcheck/describe.go @@ -65,7 +65,7 @@ func (c *DescribeCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AllowActiveLocked: true, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -83,7 +83,7 @@ func (c *DescribeCommand) Exec(in io.Reader, out io.Writer) error { c.Input.ServiceID = serviceID c.Input.ServiceVersion = serviceVersion.Number - healthCheck, err := c.Globals.Client.GetHealthCheck(&c.Input) + healthCheck, err := c.Globals.APIClient.GetHealthCheck(&c.Input) if err != nil { c.Globals.ErrLog.AddWithContext(err, map[string]interface{}{ "Service ID": serviceID, diff --git a/pkg/commands/healthcheck/list.go b/pkg/commands/healthcheck/list.go index 73cd0fd6d..d2dfd2491 100644 --- a/pkg/commands/healthcheck/list.go +++ b/pkg/commands/healthcheck/list.go @@ -64,7 +64,7 @@ func (c *ListCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AllowActiveLocked: true, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -82,7 +82,7 @@ func (c *ListCommand) Exec(in io.Reader, out io.Writer) error { c.Input.ServiceID = serviceID c.Input.ServiceVersion = serviceVersion.Number - healthChecks, err := c.Globals.Client.ListHealthChecks(&c.Input) + healthChecks, err := c.Globals.APIClient.ListHealthChecks(&c.Input) if err != nil { c.Globals.ErrLog.AddWithContext(err, map[string]interface{}{ "Service ID": serviceID, diff --git a/pkg/commands/healthcheck/update.go b/pkg/commands/healthcheck/update.go index 313bddcaf..f37177ed9 100644 --- a/pkg/commands/healthcheck/update.go +++ b/pkg/commands/healthcheck/update.go @@ -82,7 +82,7 @@ func NewUpdateCommand(parent cmd.Registerer, globals *config.Data, data manifest func (c *UpdateCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.autoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -148,7 +148,7 @@ func (c *UpdateCommand) Exec(in io.Reader, out io.Writer) error { c.input.Initial = fastly.Uint(c.Initial.Value) } - h, err := c.Globals.Client.UpdateHealthCheck(&c.input) + h, err := c.Globals.APIClient.UpdateHealthCheck(&c.input) if err != nil { c.Globals.ErrLog.AddWithContext(err, map[string]interface{}{ "Service ID": serviceID, diff --git a/pkg/commands/ip/root.go b/pkg/commands/ip/root.go index ef11350bb..ad879641f 100644 --- a/pkg/commands/ip/root.go +++ b/pkg/commands/ip/root.go @@ -31,7 +31,7 @@ func (c *RootCommand) Exec(in io.Reader, out io.Writer) error { return errors.ErrNoToken } - ipv4, ipv6, err := c.Globals.Client.AllIPs() + ipv4, ipv6, err := c.Globals.APIClient.AllIPs() if err != nil { c.Globals.ErrLog.Add(err) return err diff --git a/pkg/commands/logging/azureblob/azureblob_test.go b/pkg/commands/logging/azureblob/azureblob_test.go index 0bc29cd1e..cfc62a791 100644 --- a/pkg/commands/logging/azureblob/azureblob_test.go +++ b/pkg/commands/logging/azureblob/azureblob_test.go @@ -70,7 +70,7 @@ func TestCreateBlobStorageInput(t *testing.T) { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: testcase.cmd.AutoClone, - Client: testcase.cmd.Base.Globals.Client, + APIClient: testcase.cmd.Base.Globals.APIClient, Manifest: testcase.cmd.Manifest, Out: out, ServiceVersionFlag: testcase.cmd.ServiceVersion, @@ -155,7 +155,7 @@ func TestUpdateBlobStorageInput(t *testing.T) { }, } { t.Run(testcase.name, func(t *testing.T) { - testcase.cmd.Base.Globals.Client = testcase.api + testcase.cmd.Base.Globals.APIClient = testcase.api var bs []byte out := bytes.NewBuffer(bs) @@ -163,7 +163,7 @@ func TestUpdateBlobStorageInput(t *testing.T) { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: testcase.cmd.AutoClone, - Client: testcase.api, + APIClient: testcase.api, Manifest: testcase.cmd.Manifest, Out: out, ServiceVersionFlag: testcase.cmd.ServiceVersion, @@ -199,7 +199,7 @@ func createCommandRequired() *azureblob.CreateCommand { } // TODO: make consistent (in all other logging files) with syslog_test which // uses a testcase.api field to assign the mock API to the global client. - globals.Client, _ = mock.APIClient(mock.API{ + globals.APIClient, _ = mock.APIClient(mock.API{ ListVersionsFn: testutil.ListVersions, CloneVersionFn: testutil.CloneVersionResult(4), })("token", "endpoint") @@ -239,7 +239,7 @@ func createCommandAll() *azureblob.CreateCommand { Env: config.Environment{}, Output: &b, } - globals.Client, _ = mock.APIClient(mock.API{ + globals.APIClient, _ = mock.APIClient(mock.API{ ListVersionsFn: testutil.ListVersions, CloneVersionFn: testutil.CloneVersionResult(4), })("token", "endpoint") diff --git a/pkg/commands/logging/azureblob/create.go b/pkg/commands/logging/azureblob/create.go index 09a486e37..9e5130a54 100644 --- a/pkg/commands/logging/azureblob/create.go +++ b/pkg/commands/logging/azureblob/create.go @@ -160,7 +160,7 @@ func (c *CreateCommand) ConstructInput(serviceID string, serviceVersion int) (*f func (c *CreateCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.AutoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.Manifest, Out: out, ServiceNameFlag: c.ServiceName, @@ -184,7 +184,7 @@ func (c *CreateCommand) Exec(in io.Reader, out io.Writer) error { return err } - d, err := c.Globals.Client.CreateBlobStorage(input) + d, err := c.Globals.APIClient.CreateBlobStorage(input) if err != nil { c.Globals.ErrLog.AddWithContext(err, map[string]interface{}{ "Service ID": serviceID, diff --git a/pkg/commands/logging/azureblob/delete.go b/pkg/commands/logging/azureblob/delete.go index de1498b87..9db1cad95 100644 --- a/pkg/commands/logging/azureblob/delete.go +++ b/pkg/commands/logging/azureblob/delete.go @@ -57,7 +57,7 @@ func NewDeleteCommand(parent cmd.Registerer, globals *config.Data, data manifest func (c *DeleteCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.autoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -75,7 +75,7 @@ func (c *DeleteCommand) Exec(in io.Reader, out io.Writer) error { c.Input.ServiceID = serviceID c.Input.ServiceVersion = serviceVersion.Number - if err := c.Globals.Client.DeleteBlobStorage(&c.Input); err != nil { + if err := c.Globals.APIClient.DeleteBlobStorage(&c.Input); err != nil { c.Globals.ErrLog.AddWithContext(err, map[string]interface{}{ "Service ID": serviceID, "Service Version": serviceVersion.Number, diff --git a/pkg/commands/logging/azureblob/describe.go b/pkg/commands/logging/azureblob/describe.go index 1c1601151..7fa1f46d3 100644 --- a/pkg/commands/logging/azureblob/describe.go +++ b/pkg/commands/logging/azureblob/describe.go @@ -64,7 +64,7 @@ func (c *DescribeCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AllowActiveLocked: true, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -82,7 +82,7 @@ func (c *DescribeCommand) Exec(in io.Reader, out io.Writer) error { c.Input.ServiceID = serviceID c.Input.ServiceVersion = serviceVersion.Number - azureblob, err := c.Globals.Client.GetBlobStorage(&c.Input) + azureblob, err := c.Globals.APIClient.GetBlobStorage(&c.Input) if err != nil { c.Globals.ErrLog.AddWithContext(err, map[string]interface{}{ "Service ID": serviceID, diff --git a/pkg/commands/logging/azureblob/list.go b/pkg/commands/logging/azureblob/list.go index 68c023e40..ab185c76f 100644 --- a/pkg/commands/logging/azureblob/list.go +++ b/pkg/commands/logging/azureblob/list.go @@ -64,7 +64,7 @@ func (c *ListCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AllowActiveLocked: true, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -82,7 +82,7 @@ func (c *ListCommand) Exec(in io.Reader, out io.Writer) error { c.Input.ServiceID = serviceID c.Input.ServiceVersion = serviceVersion.Number - azureblobs, err := c.Globals.Client.ListBlobStorages(&c.Input) + azureblobs, err := c.Globals.APIClient.ListBlobStorages(&c.Input) if err != nil { c.Globals.ErrLog.AddWithContext(err, map[string]interface{}{ "Service ID": serviceID, diff --git a/pkg/commands/logging/azureblob/update.go b/pkg/commands/logging/azureblob/update.go index feefdf7cd..6170a9437 100644 --- a/pkg/commands/logging/azureblob/update.go +++ b/pkg/commands/logging/azureblob/update.go @@ -169,7 +169,7 @@ func (c *UpdateCommand) ConstructInput(serviceID string, serviceVersion int) (*f func (c *UpdateCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.AutoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.Manifest, Out: out, ServiceNameFlag: c.ServiceName, @@ -193,7 +193,7 @@ func (c *UpdateCommand) Exec(in io.Reader, out io.Writer) error { return err } - azureblob, err := c.Globals.Client.UpdateBlobStorage(input) + azureblob, err := c.Globals.APIClient.UpdateBlobStorage(input) if err != nil { c.Globals.ErrLog.AddWithContext(err, map[string]interface{}{ "Service ID": serviceID, diff --git a/pkg/commands/logging/bigquery/bigquery_test.go b/pkg/commands/logging/bigquery/bigquery_test.go index 2013b8235..fa3627d01 100644 --- a/pkg/commands/logging/bigquery/bigquery_test.go +++ b/pkg/commands/logging/bigquery/bigquery_test.go @@ -68,7 +68,7 @@ func TestCreateBigQueryInput(t *testing.T) { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: testcase.cmd.AutoClone, - Client: testcase.cmd.Base.Globals.Client, + APIClient: testcase.cmd.Base.Globals.APIClient, Manifest: testcase.cmd.Manifest, Out: out, ServiceVersionFlag: testcase.cmd.ServiceVersion, @@ -149,7 +149,7 @@ func TestUpdateBigQueryInput(t *testing.T) { }, } { t.Run(testcase.name, func(t *testing.T) { - testcase.cmd.Base.Globals.Client = testcase.api + testcase.cmd.Base.Globals.APIClient = testcase.api var bs []byte out := bytes.NewBuffer(bs) @@ -157,7 +157,7 @@ func TestUpdateBigQueryInput(t *testing.T) { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: testcase.cmd.AutoClone, - Client: testcase.api, + APIClient: testcase.api, Manifest: testcase.cmd.Manifest, Out: out, ServiceVersionFlag: testcase.cmd.ServiceVersion, @@ -191,7 +191,7 @@ func createCommandRequired() *bigquery.CreateCommand { Env: config.Environment{}, Output: &b, } - globals.Client, _ = mock.APIClient(mock.API{ + globals.APIClient, _ = mock.APIClient(mock.API{ ListVersionsFn: testutil.ListVersions, CloneVersionFn: testutil.CloneVersionResult(4), })("token", "endpoint") @@ -233,7 +233,7 @@ func createCommandAll() *bigquery.CreateCommand { Env: config.Environment{}, Output: &b, } - globals.Client, _ = mock.APIClient(mock.API{ + globals.APIClient, _ = mock.APIClient(mock.API{ ListVersionsFn: testutil.ListVersions, CloneVersionFn: testutil.CloneVersionResult(4), })("token", "endpoint") diff --git a/pkg/commands/logging/bigquery/create.go b/pkg/commands/logging/bigquery/create.go index 6a8bf5519..a7a4ee8af 100644 --- a/pkg/commands/logging/bigquery/create.go +++ b/pkg/commands/logging/bigquery/create.go @@ -117,7 +117,7 @@ func (c *CreateCommand) ConstructInput(serviceID string, serviceVersion int) (*f func (c *CreateCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.AutoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.Manifest, Out: out, ServiceNameFlag: c.ServiceName, @@ -141,7 +141,7 @@ func (c *CreateCommand) Exec(in io.Reader, out io.Writer) error { return err } - d, err := c.Globals.Client.CreateBigQuery(input) + d, err := c.Globals.APIClient.CreateBigQuery(input) if err != nil { c.Globals.ErrLog.AddWithContext(err, map[string]interface{}{ "Service ID": serviceID, diff --git a/pkg/commands/logging/bigquery/delete.go b/pkg/commands/logging/bigquery/delete.go index 92a90f47c..f988b33b8 100644 --- a/pkg/commands/logging/bigquery/delete.go +++ b/pkg/commands/logging/bigquery/delete.go @@ -57,7 +57,7 @@ func NewDeleteCommand(parent cmd.Registerer, globals *config.Data, data manifest func (c *DeleteCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.autoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -75,7 +75,7 @@ func (c *DeleteCommand) Exec(in io.Reader, out io.Writer) error { c.Input.ServiceID = serviceID c.Input.ServiceVersion = serviceVersion.Number - if err := c.Globals.Client.DeleteBigQuery(&c.Input); err != nil { + if err := c.Globals.APIClient.DeleteBigQuery(&c.Input); err != nil { c.Globals.ErrLog.AddWithContext(err, map[string]interface{}{ "Service ID": serviceID, "Service Version": serviceVersion.Number, diff --git a/pkg/commands/logging/bigquery/describe.go b/pkg/commands/logging/bigquery/describe.go index 9cb224c59..418cb8b77 100644 --- a/pkg/commands/logging/bigquery/describe.go +++ b/pkg/commands/logging/bigquery/describe.go @@ -64,7 +64,7 @@ func (c *DescribeCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AllowActiveLocked: true, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -82,7 +82,7 @@ func (c *DescribeCommand) Exec(in io.Reader, out io.Writer) error { c.Input.ServiceID = serviceID c.Input.ServiceVersion = serviceVersion.Number - bq, err := c.Globals.Client.GetBigQuery(&c.Input) + bq, err := c.Globals.APIClient.GetBigQuery(&c.Input) if err != nil { c.Globals.ErrLog.AddWithContext(err, map[string]interface{}{ "Service ID": serviceID, diff --git a/pkg/commands/logging/bigquery/list.go b/pkg/commands/logging/bigquery/list.go index 5646d57b0..12fd291b4 100644 --- a/pkg/commands/logging/bigquery/list.go +++ b/pkg/commands/logging/bigquery/list.go @@ -64,7 +64,7 @@ func (c *ListCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AllowActiveLocked: true, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -82,7 +82,7 @@ func (c *ListCommand) Exec(in io.Reader, out io.Writer) error { c.Input.ServiceID = serviceID c.Input.ServiceVersion = serviceVersion.Number - bqs, err := c.Globals.Client.ListBigQueries(&c.Input) + bqs, err := c.Globals.APIClient.ListBigQueries(&c.Input) if err != nil { c.Globals.ErrLog.AddWithContext(err, map[string]interface{}{ "Service ID": serviceID, diff --git a/pkg/commands/logging/bigquery/update.go b/pkg/commands/logging/bigquery/update.go index 826961c88..976eb29c1 100644 --- a/pkg/commands/logging/bigquery/update.go +++ b/pkg/commands/logging/bigquery/update.go @@ -138,7 +138,7 @@ func (c *UpdateCommand) ConstructInput(serviceID string, serviceVersion int) (*f func (c *UpdateCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.AutoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.Manifest, Out: out, ServiceNameFlag: c.ServiceName, @@ -162,7 +162,7 @@ func (c *UpdateCommand) Exec(in io.Reader, out io.Writer) error { return err } - bq, err := c.Globals.Client.UpdateBigQuery(input) + bq, err := c.Globals.APIClient.UpdateBigQuery(input) if err != nil { c.Globals.ErrLog.AddWithContext(err, map[string]interface{}{ "Service ID": serviceID, diff --git a/pkg/commands/logging/cloudfiles/cloudfiles_test.go b/pkg/commands/logging/cloudfiles/cloudfiles_test.go index 240b3199e..b4b317d1b 100644 --- a/pkg/commands/logging/cloudfiles/cloudfiles_test.go +++ b/pkg/commands/logging/cloudfiles/cloudfiles_test.go @@ -71,7 +71,7 @@ func TestCreateCloudfilesInput(t *testing.T) { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: testcase.cmd.AutoClone, - Client: testcase.cmd.Base.Globals.Client, + APIClient: testcase.cmd.Base.Globals.APIClient, Manifest: testcase.cmd.Manifest, Out: out, ServiceVersionFlag: testcase.cmd.ServiceVersion, @@ -157,7 +157,7 @@ func TestUpdateCloudfilesInput(t *testing.T) { }, } { t.Run(testcase.name, func(t *testing.T) { - testcase.cmd.Base.Globals.Client = testcase.api + testcase.cmd.Base.Globals.APIClient = testcase.api var bs []byte out := bytes.NewBuffer(bs) @@ -165,7 +165,7 @@ func TestUpdateCloudfilesInput(t *testing.T) { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: testcase.cmd.AutoClone, - Client: testcase.api, + APIClient: testcase.api, Manifest: testcase.cmd.Manifest, Out: out, ServiceVersionFlag: testcase.cmd.ServiceVersion, @@ -199,7 +199,7 @@ func createCommandRequired() *cloudfiles.CreateCommand { Env: config.Environment{}, Output: &b, } - globals.Client, _ = mock.APIClient(mock.API{ + globals.APIClient, _ = mock.APIClient(mock.API{ ListVersionsFn: testutil.ListVersions, CloneVersionFn: testutil.CloneVersionResult(4), })("token", "endpoint") @@ -239,7 +239,7 @@ func createCommandAll() *cloudfiles.CreateCommand { Env: config.Environment{}, Output: &b, } - globals.Client, _ = mock.APIClient(mock.API{ + globals.APIClient, _ = mock.APIClient(mock.API{ ListVersionsFn: testutil.ListVersions, CloneVersionFn: testutil.CloneVersionResult(4), })("token", "endpoint") diff --git a/pkg/commands/logging/cloudfiles/create.go b/pkg/commands/logging/cloudfiles/create.go index 030ad32e8..723eaa7da 100644 --- a/pkg/commands/logging/cloudfiles/create.go +++ b/pkg/commands/logging/cloudfiles/create.go @@ -161,7 +161,7 @@ func (c *CreateCommand) ConstructInput(serviceID string, serviceVersion int) (*f func (c *CreateCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.AutoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.Manifest, Out: out, ServiceNameFlag: c.ServiceName, @@ -185,7 +185,7 @@ func (c *CreateCommand) Exec(in io.Reader, out io.Writer) error { return err } - d, err := c.Globals.Client.CreateCloudfiles(input) + d, err := c.Globals.APIClient.CreateCloudfiles(input) if err != nil { c.Globals.ErrLog.AddWithContext(err, map[string]interface{}{ "Service ID": serviceID, diff --git a/pkg/commands/logging/cloudfiles/delete.go b/pkg/commands/logging/cloudfiles/delete.go index 247b750e5..8445104e3 100644 --- a/pkg/commands/logging/cloudfiles/delete.go +++ b/pkg/commands/logging/cloudfiles/delete.go @@ -57,7 +57,7 @@ func NewDeleteCommand(parent cmd.Registerer, globals *config.Data, data manifest func (c *DeleteCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.autoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -75,7 +75,7 @@ func (c *DeleteCommand) Exec(in io.Reader, out io.Writer) error { c.Input.ServiceID = serviceID c.Input.ServiceVersion = serviceVersion.Number - if err := c.Globals.Client.DeleteCloudfiles(&c.Input); err != nil { + if err := c.Globals.APIClient.DeleteCloudfiles(&c.Input); err != nil { c.Globals.ErrLog.AddWithContext(err, map[string]interface{}{ "Service ID": serviceID, "Service Version": serviceVersion.Number, diff --git a/pkg/commands/logging/cloudfiles/describe.go b/pkg/commands/logging/cloudfiles/describe.go index b453f0608..f31cb013f 100644 --- a/pkg/commands/logging/cloudfiles/describe.go +++ b/pkg/commands/logging/cloudfiles/describe.go @@ -64,7 +64,7 @@ func (c *DescribeCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AllowActiveLocked: true, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -82,7 +82,7 @@ func (c *DescribeCommand) Exec(in io.Reader, out io.Writer) error { c.Input.ServiceID = serviceID c.Input.ServiceVersion = serviceVersion.Number - cloudfiles, err := c.Globals.Client.GetCloudfiles(&c.Input) + cloudfiles, err := c.Globals.APIClient.GetCloudfiles(&c.Input) if err != nil { c.Globals.ErrLog.AddWithContext(err, map[string]interface{}{ "Service ID": serviceID, diff --git a/pkg/commands/logging/cloudfiles/list.go b/pkg/commands/logging/cloudfiles/list.go index 69fec04f4..3a224094e 100644 --- a/pkg/commands/logging/cloudfiles/list.go +++ b/pkg/commands/logging/cloudfiles/list.go @@ -64,7 +64,7 @@ func (c *ListCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AllowActiveLocked: true, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -82,7 +82,7 @@ func (c *ListCommand) Exec(in io.Reader, out io.Writer) error { c.Input.ServiceID = serviceID c.Input.ServiceVersion = serviceVersion.Number - cloudfiles, err := c.Globals.Client.ListCloudfiles(&c.Input) + cloudfiles, err := c.Globals.APIClient.ListCloudfiles(&c.Input) if err != nil { c.Globals.ErrLog.AddWithContext(err, map[string]interface{}{ "Service ID": serviceID, diff --git a/pkg/commands/logging/cloudfiles/update.go b/pkg/commands/logging/cloudfiles/update.go index c40ca8455..1dfd5fc87 100644 --- a/pkg/commands/logging/cloudfiles/update.go +++ b/pkg/commands/logging/cloudfiles/update.go @@ -169,7 +169,7 @@ func (c *UpdateCommand) ConstructInput(serviceID string, serviceVersion int) (*f func (c *UpdateCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.AutoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.Manifest, Out: out, ServiceNameFlag: c.ServiceName, @@ -193,7 +193,7 @@ func (c *UpdateCommand) Exec(in io.Reader, out io.Writer) error { return err } - cloudfiles, err := c.Globals.Client.UpdateCloudfiles(input) + cloudfiles, err := c.Globals.APIClient.UpdateCloudfiles(input) if err != nil { c.Globals.ErrLog.AddWithContext(err, map[string]interface{}{ "Service ID": serviceID, diff --git a/pkg/commands/logging/datadog/create.go b/pkg/commands/logging/datadog/create.go index 1d61e0bf1..4c35a7b50 100644 --- a/pkg/commands/logging/datadog/create.go +++ b/pkg/commands/logging/datadog/create.go @@ -105,7 +105,7 @@ func (c *CreateCommand) ConstructInput(serviceID string, serviceVersion int) (*f func (c *CreateCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.AutoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.Manifest, Out: out, ServiceNameFlag: c.ServiceName, @@ -126,7 +126,7 @@ func (c *CreateCommand) Exec(in io.Reader, out io.Writer) error { return err } - d, err := c.Globals.Client.CreateDatadog(input) + d, err := c.Globals.APIClient.CreateDatadog(input) if err != nil { c.Globals.ErrLog.Add(err) return err diff --git a/pkg/commands/logging/datadog/datadog_test.go b/pkg/commands/logging/datadog/datadog_test.go index 18f7f6eac..674941ab3 100644 --- a/pkg/commands/logging/datadog/datadog_test.go +++ b/pkg/commands/logging/datadog/datadog_test.go @@ -60,7 +60,7 @@ func TestCreateDatadogInput(t *testing.T) { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: testcase.cmd.AutoClone, - Client: testcase.cmd.Base.Globals.Client, + APIClient: testcase.cmd.Base.Globals.APIClient, Manifest: testcase.cmd.Manifest, Out: out, ServiceVersionFlag: testcase.cmd.ServiceVersion, @@ -137,7 +137,7 @@ func TestUpdateDatadogInput(t *testing.T) { }, } { t.Run(testcase.name, func(t *testing.T) { - testcase.cmd.Base.Globals.Client = testcase.api + testcase.cmd.Base.Globals.APIClient = testcase.api var bs []byte out := bytes.NewBuffer(bs) @@ -145,7 +145,7 @@ func TestUpdateDatadogInput(t *testing.T) { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: testcase.cmd.AutoClone, - Client: testcase.api, + APIClient: testcase.api, Manifest: testcase.cmd.Manifest, Out: out, ServiceVersionFlag: testcase.cmd.ServiceVersion, @@ -179,7 +179,7 @@ func createCommandOK() *datadog.CreateCommand { Env: config.Environment{}, Output: &b, } - globals.Client, _ = mock.APIClient(mock.API{ + globals.APIClient, _ = mock.APIClient(mock.API{ ListVersionsFn: testutil.ListVersions, CloneVersionFn: testutil.CloneVersionResult(4), })("token", "endpoint") @@ -222,7 +222,7 @@ func createCommandRequired() *datadog.CreateCommand { Env: config.Environment{}, Output: &b, } - globals.Client, _ = mock.APIClient(mock.API{ + globals.APIClient, _ = mock.APIClient(mock.API{ ListVersionsFn: testutil.ListVersions, CloneVersionFn: testutil.CloneVersionResult(4), })("token", "endpoint") diff --git a/pkg/commands/logging/datadog/delete.go b/pkg/commands/logging/datadog/delete.go index 9e9bc4b4f..7d81f092c 100644 --- a/pkg/commands/logging/datadog/delete.go +++ b/pkg/commands/logging/datadog/delete.go @@ -57,7 +57,7 @@ func NewDeleteCommand(parent cmd.Registerer, globals *config.Data, data manifest func (c *DeleteCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.autoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -75,7 +75,7 @@ func (c *DeleteCommand) Exec(in io.Reader, out io.Writer) error { c.Input.ServiceID = serviceID c.Input.ServiceVersion = serviceVersion.Number - if err := c.Globals.Client.DeleteDatadog(&c.Input); err != nil { + if err := c.Globals.APIClient.DeleteDatadog(&c.Input); err != nil { c.Globals.ErrLog.Add(err) return err } diff --git a/pkg/commands/logging/datadog/describe.go b/pkg/commands/logging/datadog/describe.go index b40a29d20..6fed4e7d9 100644 --- a/pkg/commands/logging/datadog/describe.go +++ b/pkg/commands/logging/datadog/describe.go @@ -64,7 +64,7 @@ func (c *DescribeCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AllowActiveLocked: true, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -82,7 +82,7 @@ func (c *DescribeCommand) Exec(in io.Reader, out io.Writer) error { c.Input.ServiceID = serviceID c.Input.ServiceVersion = serviceVersion.Number - datadog, err := c.Globals.Client.GetDatadog(&c.Input) + datadog, err := c.Globals.APIClient.GetDatadog(&c.Input) if err != nil { c.Globals.ErrLog.Add(err) return err diff --git a/pkg/commands/logging/datadog/list.go b/pkg/commands/logging/datadog/list.go index 0195bbab7..c8d01e91a 100644 --- a/pkg/commands/logging/datadog/list.go +++ b/pkg/commands/logging/datadog/list.go @@ -64,7 +64,7 @@ func (c *ListCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AllowActiveLocked: true, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -82,7 +82,7 @@ func (c *ListCommand) Exec(in io.Reader, out io.Writer) error { c.Input.ServiceID = serviceID c.Input.ServiceVersion = serviceVersion.Number - datadogs, err := c.Globals.Client.ListDatadog(&c.Input) + datadogs, err := c.Globals.APIClient.ListDatadog(&c.Input) if err != nil { c.Globals.ErrLog.Add(err) return err diff --git a/pkg/commands/logging/datadog/update.go b/pkg/commands/logging/datadog/update.go index 747d549a3..1d8f0b672 100644 --- a/pkg/commands/logging/datadog/update.go +++ b/pkg/commands/logging/datadog/update.go @@ -114,7 +114,7 @@ func (c *UpdateCommand) ConstructInput(serviceID string, serviceVersion int) (*f func (c *UpdateCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.AutoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.Manifest, Out: out, ServiceNameFlag: c.ServiceName, @@ -135,7 +135,7 @@ func (c *UpdateCommand) Exec(in io.Reader, out io.Writer) error { return err } - datadog, err := c.Globals.Client.UpdateDatadog(input) + datadog, err := c.Globals.APIClient.UpdateDatadog(input) if err != nil { c.Globals.ErrLog.Add(err) return err diff --git a/pkg/commands/logging/digitalocean/create.go b/pkg/commands/logging/digitalocean/create.go index fc5c195f9..4a2b40166 100644 --- a/pkg/commands/logging/digitalocean/create.go +++ b/pkg/commands/logging/digitalocean/create.go @@ -160,7 +160,7 @@ func (c *CreateCommand) ConstructInput(serviceID string, serviceVersion int) (*f func (c *CreateCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.AutoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.Manifest, Out: out, ServiceNameFlag: c.ServiceName, @@ -181,7 +181,7 @@ func (c *CreateCommand) Exec(in io.Reader, out io.Writer) error { return err } - d, err := c.Globals.Client.CreateDigitalOcean(input) + d, err := c.Globals.APIClient.CreateDigitalOcean(input) if err != nil { c.Globals.ErrLog.Add(err) return err diff --git a/pkg/commands/logging/digitalocean/delete.go b/pkg/commands/logging/digitalocean/delete.go index aca534f1e..78ac8c696 100644 --- a/pkg/commands/logging/digitalocean/delete.go +++ b/pkg/commands/logging/digitalocean/delete.go @@ -57,7 +57,7 @@ func NewDeleteCommand(parent cmd.Registerer, globals *config.Data, data manifest func (c *DeleteCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.autoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -75,7 +75,7 @@ func (c *DeleteCommand) Exec(in io.Reader, out io.Writer) error { c.Input.ServiceID = serviceID c.Input.ServiceVersion = serviceVersion.Number - if err := c.Globals.Client.DeleteDigitalOcean(&c.Input); err != nil { + if err := c.Globals.APIClient.DeleteDigitalOcean(&c.Input); err != nil { c.Globals.ErrLog.Add(err) return err } diff --git a/pkg/commands/logging/digitalocean/describe.go b/pkg/commands/logging/digitalocean/describe.go index fc0550959..ab75eb1ea 100644 --- a/pkg/commands/logging/digitalocean/describe.go +++ b/pkg/commands/logging/digitalocean/describe.go @@ -64,7 +64,7 @@ func (c *DescribeCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AllowActiveLocked: true, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -82,7 +82,7 @@ func (c *DescribeCommand) Exec(in io.Reader, out io.Writer) error { c.Input.ServiceID = serviceID c.Input.ServiceVersion = serviceVersion.Number - digitalocean, err := c.Globals.Client.GetDigitalOcean(&c.Input) + digitalocean, err := c.Globals.APIClient.GetDigitalOcean(&c.Input) if err != nil { c.Globals.ErrLog.Add(err) return err diff --git a/pkg/commands/logging/digitalocean/digitalocean_test.go b/pkg/commands/logging/digitalocean/digitalocean_test.go index 27e14f945..57ad54caa 100644 --- a/pkg/commands/logging/digitalocean/digitalocean_test.go +++ b/pkg/commands/logging/digitalocean/digitalocean_test.go @@ -71,7 +71,7 @@ func TestCreateDigitalOceanInput(t *testing.T) { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: testcase.cmd.AutoClone, - Client: testcase.cmd.Base.Globals.Client, + APIClient: testcase.cmd.Base.Globals.APIClient, Manifest: testcase.cmd.Manifest, Out: out, ServiceVersionFlag: testcase.cmd.ServiceVersion, @@ -157,7 +157,7 @@ func TestUpdateDigitalOceanInput(t *testing.T) { }, } { t.Run(testcase.name, func(t *testing.T) { - testcase.cmd.Base.Globals.Client = testcase.api + testcase.cmd.Base.Globals.APIClient = testcase.api var bs []byte out := bytes.NewBuffer(bs) @@ -165,7 +165,7 @@ func TestUpdateDigitalOceanInput(t *testing.T) { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: testcase.cmd.AutoClone, - Client: testcase.api, + APIClient: testcase.api, Manifest: testcase.cmd.Manifest, Out: out, ServiceVersionFlag: testcase.cmd.ServiceVersion, @@ -199,7 +199,7 @@ func createCommandRequired() *digitalocean.CreateCommand { Env: config.Environment{}, Output: &b, } - globals.Client, _ = mock.APIClient(mock.API{ + globals.APIClient, _ = mock.APIClient(mock.API{ ListVersionsFn: testutil.ListVersions, CloneVersionFn: testutil.CloneVersionResult(4), })("token", "endpoint") @@ -239,7 +239,7 @@ func createCommandAll() *digitalocean.CreateCommand { Env: config.Environment{}, Output: &b, } - globals.Client, _ = mock.APIClient(mock.API{ + globals.APIClient, _ = mock.APIClient(mock.API{ ListVersionsFn: testutil.ListVersions, CloneVersionFn: testutil.CloneVersionResult(4), })("token", "endpoint") diff --git a/pkg/commands/logging/digitalocean/list.go b/pkg/commands/logging/digitalocean/list.go index b26ac7c5d..84927e1c6 100644 --- a/pkg/commands/logging/digitalocean/list.go +++ b/pkg/commands/logging/digitalocean/list.go @@ -64,7 +64,7 @@ func (c *ListCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AllowActiveLocked: true, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -82,7 +82,7 @@ func (c *ListCommand) Exec(in io.Reader, out io.Writer) error { c.Input.ServiceID = serviceID c.Input.ServiceVersion = serviceVersion.Number - digitaloceans, err := c.Globals.Client.ListDigitalOceans(&c.Input) + digitaloceans, err := c.Globals.APIClient.ListDigitalOceans(&c.Input) if err != nil { c.Globals.ErrLog.Add(err) return err diff --git a/pkg/commands/logging/digitalocean/update.go b/pkg/commands/logging/digitalocean/update.go index 8efcb9a09..79b3ab637 100644 --- a/pkg/commands/logging/digitalocean/update.go +++ b/pkg/commands/logging/digitalocean/update.go @@ -169,7 +169,7 @@ func (c *UpdateCommand) ConstructInput(serviceID string, serviceVersion int) (*f func (c *UpdateCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.AutoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.Manifest, Out: out, ServiceNameFlag: c.ServiceName, @@ -190,7 +190,7 @@ func (c *UpdateCommand) Exec(in io.Reader, out io.Writer) error { return err } - digitalocean, err := c.Globals.Client.UpdateDigitalOcean(input) + digitalocean, err := c.Globals.APIClient.UpdateDigitalOcean(input) if err != nil { c.Globals.ErrLog.Add(err) return err diff --git a/pkg/commands/logging/elasticsearch/create.go b/pkg/commands/logging/elasticsearch/create.go index fbf7759df..5f6aee3aa 100644 --- a/pkg/commands/logging/elasticsearch/create.go +++ b/pkg/commands/logging/elasticsearch/create.go @@ -154,7 +154,7 @@ func (c *CreateCommand) ConstructInput(serviceID string, serviceVersion int) (*f func (c *CreateCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.AutoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.Manifest, Out: out, ServiceNameFlag: c.ServiceName, @@ -175,7 +175,7 @@ func (c *CreateCommand) Exec(in io.Reader, out io.Writer) error { return err } - d, err := c.Globals.Client.CreateElasticsearch(input) + d, err := c.Globals.APIClient.CreateElasticsearch(input) if err != nil { c.Globals.ErrLog.Add(err) return err diff --git a/pkg/commands/logging/elasticsearch/delete.go b/pkg/commands/logging/elasticsearch/delete.go index b652e6dfe..cfb0f248e 100644 --- a/pkg/commands/logging/elasticsearch/delete.go +++ b/pkg/commands/logging/elasticsearch/delete.go @@ -57,7 +57,7 @@ func NewDeleteCommand(parent cmd.Registerer, globals *config.Data, data manifest func (c *DeleteCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.autoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -75,7 +75,7 @@ func (c *DeleteCommand) Exec(in io.Reader, out io.Writer) error { c.Input.ServiceID = serviceID c.Input.ServiceVersion = serviceVersion.Number - if err := c.Globals.Client.DeleteElasticsearch(&c.Input); err != nil { + if err := c.Globals.APIClient.DeleteElasticsearch(&c.Input); err != nil { c.Globals.ErrLog.Add(err) return err } diff --git a/pkg/commands/logging/elasticsearch/describe.go b/pkg/commands/logging/elasticsearch/describe.go index 524015c9d..6468279b8 100644 --- a/pkg/commands/logging/elasticsearch/describe.go +++ b/pkg/commands/logging/elasticsearch/describe.go @@ -64,7 +64,7 @@ func (c *DescribeCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AllowActiveLocked: true, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -82,7 +82,7 @@ func (c *DescribeCommand) Exec(in io.Reader, out io.Writer) error { c.Input.ServiceID = serviceID c.Input.ServiceVersion = serviceVersion.Number - elasticsearch, err := c.Globals.Client.GetElasticsearch(&c.Input) + elasticsearch, err := c.Globals.APIClient.GetElasticsearch(&c.Input) if err != nil { c.Globals.ErrLog.Add(err) return err diff --git a/pkg/commands/logging/elasticsearch/elasticsearch_test.go b/pkg/commands/logging/elasticsearch/elasticsearch_test.go index f6852735c..fadbc51e5 100644 --- a/pkg/commands/logging/elasticsearch/elasticsearch_test.go +++ b/pkg/commands/logging/elasticsearch/elasticsearch_test.go @@ -70,7 +70,7 @@ func TestCreateElasticsearchInput(t *testing.T) { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: testcase.cmd.AutoClone, - Client: testcase.cmd.Base.Globals.Client, + APIClient: testcase.cmd.Base.Globals.APIClient, Manifest: testcase.cmd.Manifest, Out: out, ServiceVersionFlag: testcase.cmd.ServiceVersion, @@ -156,7 +156,7 @@ func TestUpdateElasticsearchInput(t *testing.T) { }, } { t.Run(testcase.name, func(t *testing.T) { - testcase.cmd.Base.Globals.Client = testcase.api + testcase.cmd.Base.Globals.APIClient = testcase.api var bs []byte out := bytes.NewBuffer(bs) @@ -164,7 +164,7 @@ func TestUpdateElasticsearchInput(t *testing.T) { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: testcase.cmd.AutoClone, - Client: testcase.api, + APIClient: testcase.api, Manifest: testcase.cmd.Manifest, Out: out, ServiceVersionFlag: testcase.cmd.ServiceVersion, @@ -198,7 +198,7 @@ func createCommandRequired() *elasticsearch.CreateCommand { Env: config.Environment{}, Output: &b, } - globals.Client, _ = mock.APIClient(mock.API{ + globals.APIClient, _ = mock.APIClient(mock.API{ ListVersionsFn: testutil.ListVersions, CloneVersionFn: testutil.CloneVersionResult(4), })("token", "endpoint") @@ -237,7 +237,7 @@ func createCommandAll() *elasticsearch.CreateCommand { Env: config.Environment{}, Output: &b, } - globals.Client, _ = mock.APIClient(mock.API{ + globals.APIClient, _ = mock.APIClient(mock.API{ ListVersionsFn: testutil.ListVersions, CloneVersionFn: testutil.CloneVersionResult(4), })("token", "endpoint") diff --git a/pkg/commands/logging/elasticsearch/list.go b/pkg/commands/logging/elasticsearch/list.go index df87cd932..c97bbc811 100644 --- a/pkg/commands/logging/elasticsearch/list.go +++ b/pkg/commands/logging/elasticsearch/list.go @@ -64,7 +64,7 @@ func (c *ListCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AllowActiveLocked: true, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -82,7 +82,7 @@ func (c *ListCommand) Exec(in io.Reader, out io.Writer) error { c.Input.ServiceID = serviceID c.Input.ServiceVersion = serviceVersion.Number - elasticsearchs, err := c.Globals.Client.ListElasticsearch(&c.Input) + elasticsearchs, err := c.Globals.APIClient.ListElasticsearch(&c.Input) if err != nil { c.Globals.ErrLog.Add(err) return err diff --git a/pkg/commands/logging/elasticsearch/update.go b/pkg/commands/logging/elasticsearch/update.go index 4188b5f88..4ca8f3293 100644 --- a/pkg/commands/logging/elasticsearch/update.go +++ b/pkg/commands/logging/elasticsearch/update.go @@ -166,7 +166,7 @@ func (c *UpdateCommand) ConstructInput(serviceID string, serviceVersion int) (*f func (c *UpdateCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.AutoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.Manifest, Out: out, ServiceNameFlag: c.ServiceName, @@ -187,7 +187,7 @@ func (c *UpdateCommand) Exec(in io.Reader, out io.Writer) error { return err } - elasticsearch, err := c.Globals.Client.UpdateElasticsearch(input) + elasticsearch, err := c.Globals.APIClient.UpdateElasticsearch(input) if err != nil { c.Globals.ErrLog.Add(err) return err diff --git a/pkg/commands/logging/ftp/create.go b/pkg/commands/logging/ftp/create.go index 30b6ff635..6eb8d50bf 100644 --- a/pkg/commands/logging/ftp/create.go +++ b/pkg/commands/logging/ftp/create.go @@ -148,7 +148,7 @@ func (c *CreateCommand) ConstructInput(serviceID string, serviceVersion int) (*f func (c *CreateCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.AutoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.Manifest, Out: out, ServiceNameFlag: c.ServiceName, @@ -169,7 +169,7 @@ func (c *CreateCommand) Exec(in io.Reader, out io.Writer) error { return err } - d, err := c.Globals.Client.CreateFTP(input) + d, err := c.Globals.APIClient.CreateFTP(input) if err != nil { c.Globals.ErrLog.Add(err) return err diff --git a/pkg/commands/logging/ftp/delete.go b/pkg/commands/logging/ftp/delete.go index ff0c534af..1e670afa5 100644 --- a/pkg/commands/logging/ftp/delete.go +++ b/pkg/commands/logging/ftp/delete.go @@ -57,7 +57,7 @@ func NewDeleteCommand(parent cmd.Registerer, globals *config.Data, data manifest func (c *DeleteCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.autoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -75,7 +75,7 @@ func (c *DeleteCommand) Exec(in io.Reader, out io.Writer) error { c.Input.ServiceID = serviceID c.Input.ServiceVersion = serviceVersion.Number - if err := c.Globals.Client.DeleteFTP(&c.Input); err != nil { + if err := c.Globals.APIClient.DeleteFTP(&c.Input); err != nil { c.Globals.ErrLog.Add(err) return err } diff --git a/pkg/commands/logging/ftp/describe.go b/pkg/commands/logging/ftp/describe.go index 5fdd5258c..4c9014107 100644 --- a/pkg/commands/logging/ftp/describe.go +++ b/pkg/commands/logging/ftp/describe.go @@ -64,7 +64,7 @@ func (c *DescribeCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AllowActiveLocked: true, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -82,7 +82,7 @@ func (c *DescribeCommand) Exec(in io.Reader, out io.Writer) error { c.Input.ServiceID = serviceID c.Input.ServiceVersion = serviceVersion.Number - ftp, err := c.Globals.Client.GetFTP(&c.Input) + ftp, err := c.Globals.APIClient.GetFTP(&c.Input) if err != nil { c.Globals.ErrLog.Add(err) return err diff --git a/pkg/commands/logging/ftp/ftp_test.go b/pkg/commands/logging/ftp/ftp_test.go index 59f158cbf..fbc0f009d 100644 --- a/pkg/commands/logging/ftp/ftp_test.go +++ b/pkg/commands/logging/ftp/ftp_test.go @@ -68,7 +68,7 @@ func TestCreateFTPInput(t *testing.T) { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: testcase.cmd.AutoClone, - Client: testcase.cmd.Base.Globals.Client, + APIClient: testcase.cmd.Base.Globals.APIClient, Manifest: testcase.cmd.Manifest, Out: out, ServiceVersionFlag: testcase.cmd.ServiceVersion, @@ -153,7 +153,7 @@ func TestUpdateFTPInput(t *testing.T) { }, } { t.Run(testcase.name, func(t *testing.T) { - testcase.cmd.Base.Globals.Client = testcase.api + testcase.cmd.Base.Globals.APIClient = testcase.api var bs []byte out := bytes.NewBuffer(bs) @@ -161,7 +161,7 @@ func TestUpdateFTPInput(t *testing.T) { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: testcase.cmd.AutoClone, - Client: testcase.api, + APIClient: testcase.api, Manifest: testcase.cmd.Manifest, Out: out, ServiceVersionFlag: testcase.cmd.ServiceVersion, @@ -195,7 +195,7 @@ func createCommandRequired() *ftp.CreateCommand { Env: config.Environment{}, Output: &b, } - globals.Client, _ = mock.APIClient(mock.API{ + globals.APIClient, _ = mock.APIClient(mock.API{ ListVersionsFn: testutil.ListVersions, CloneVersionFn: testutil.CloneVersionResult(4), })("token", "endpoint") @@ -235,7 +235,7 @@ func createCommandAll() *ftp.CreateCommand { Env: config.Environment{}, Output: &b, } - globals.Client, _ = mock.APIClient(mock.API{ + globals.APIClient, _ = mock.APIClient(mock.API{ ListVersionsFn: testutil.ListVersions, CloneVersionFn: testutil.CloneVersionResult(4), })("token", "endpoint") diff --git a/pkg/commands/logging/ftp/list.go b/pkg/commands/logging/ftp/list.go index 0eb72edcb..63fea9920 100644 --- a/pkg/commands/logging/ftp/list.go +++ b/pkg/commands/logging/ftp/list.go @@ -64,7 +64,7 @@ func (c *ListCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AllowActiveLocked: true, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -82,7 +82,7 @@ func (c *ListCommand) Exec(in io.Reader, out io.Writer) error { c.Input.ServiceID = serviceID c.Input.ServiceVersion = serviceVersion.Number - ftps, err := c.Globals.Client.ListFTPs(&c.Input) + ftps, err := c.Globals.APIClient.ListFTPs(&c.Input) if err != nil { c.Globals.ErrLog.Add(err) return err diff --git a/pkg/commands/logging/ftp/update.go b/pkg/commands/logging/ftp/update.go index 20a4b3833..2ac6cf8b4 100644 --- a/pkg/commands/logging/ftp/update.go +++ b/pkg/commands/logging/ftp/update.go @@ -163,7 +163,7 @@ func (c *UpdateCommand) ConstructInput(serviceID string, serviceVersion int) (*f func (c *UpdateCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.AutoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.Manifest, Out: out, ServiceNameFlag: c.ServiceName, @@ -184,7 +184,7 @@ func (c *UpdateCommand) Exec(in io.Reader, out io.Writer) error { return err } - ftp, err := c.Globals.Client.UpdateFTP(input) + ftp, err := c.Globals.APIClient.UpdateFTP(input) if err != nil { c.Globals.ErrLog.Add(err) return err diff --git a/pkg/commands/logging/gcs/create.go b/pkg/commands/logging/gcs/create.go index 38b4ef562..e81a798bc 100644 --- a/pkg/commands/logging/gcs/create.go +++ b/pkg/commands/logging/gcs/create.go @@ -148,7 +148,7 @@ func (c *CreateCommand) ConstructInput(serviceID string, serviceVersion int) (*f func (c *CreateCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.AutoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.Manifest, Out: out, ServiceNameFlag: c.ServiceName, @@ -169,7 +169,7 @@ func (c *CreateCommand) Exec(in io.Reader, out io.Writer) error { return err } - d, err := c.Globals.Client.CreateGCS(input) + d, err := c.Globals.APIClient.CreateGCS(input) if err != nil { c.Globals.ErrLog.Add(err) return err diff --git a/pkg/commands/logging/gcs/delete.go b/pkg/commands/logging/gcs/delete.go index 0cda5595e..b0a7baee0 100644 --- a/pkg/commands/logging/gcs/delete.go +++ b/pkg/commands/logging/gcs/delete.go @@ -57,7 +57,7 @@ func NewDeleteCommand(parent cmd.Registerer, globals *config.Data, data manifest func (c *DeleteCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.autoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -75,7 +75,7 @@ func (c *DeleteCommand) Exec(in io.Reader, out io.Writer) error { c.Input.ServiceID = serviceID c.Input.ServiceVersion = serviceVersion.Number - if err := c.Globals.Client.DeleteGCS(&c.Input); err != nil { + if err := c.Globals.APIClient.DeleteGCS(&c.Input); err != nil { c.Globals.ErrLog.Add(err) return err } diff --git a/pkg/commands/logging/gcs/describe.go b/pkg/commands/logging/gcs/describe.go index ac58ab895..392105ba3 100644 --- a/pkg/commands/logging/gcs/describe.go +++ b/pkg/commands/logging/gcs/describe.go @@ -64,7 +64,7 @@ func (c *DescribeCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AllowActiveLocked: true, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -82,7 +82,7 @@ func (c *DescribeCommand) Exec(in io.Reader, out io.Writer) error { c.Input.ServiceID = serviceID c.Input.ServiceVersion = serviceVersion.Number - gcs, err := c.Globals.Client.GetGCS(&c.Input) + gcs, err := c.Globals.APIClient.GetGCS(&c.Input) if err != nil { c.Globals.ErrLog.Add(err) return err diff --git a/pkg/commands/logging/gcs/gcs_test.go b/pkg/commands/logging/gcs/gcs_test.go index 69e99dde6..ca4c69b7c 100644 --- a/pkg/commands/logging/gcs/gcs_test.go +++ b/pkg/commands/logging/gcs/gcs_test.go @@ -67,7 +67,7 @@ func TestCreateGCSInput(t *testing.T) { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: testcase.cmd.AutoClone, - Client: testcase.cmd.Base.Globals.Client, + APIClient: testcase.cmd.Base.Globals.APIClient, Manifest: testcase.cmd.Manifest, Out: out, ServiceVersionFlag: testcase.cmd.ServiceVersion, @@ -151,7 +151,7 @@ func TestUpdateGCSInput(t *testing.T) { }, } { t.Run(testcase.name, func(t *testing.T) { - testcase.cmd.Base.Globals.Client = testcase.api + testcase.cmd.Base.Globals.APIClient = testcase.api var bs []byte out := bytes.NewBuffer(bs) @@ -159,7 +159,7 @@ func TestUpdateGCSInput(t *testing.T) { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: testcase.cmd.AutoClone, - Client: testcase.api, + APIClient: testcase.api, Manifest: testcase.cmd.Manifest, Out: out, ServiceVersionFlag: testcase.cmd.ServiceVersion, @@ -193,7 +193,7 @@ func createCommandRequired() *gcs.CreateCommand { Env: config.Environment{}, Output: &b, } - globals.Client, _ = mock.APIClient(mock.API{ + globals.APIClient, _ = mock.APIClient(mock.API{ ListVersionsFn: testutil.ListVersions, CloneVersionFn: testutil.CloneVersionResult(4), })("token", "endpoint") @@ -233,7 +233,7 @@ func createCommandAll() *gcs.CreateCommand { Env: config.Environment{}, Output: &b, } - globals.Client, _ = mock.APIClient(mock.API{ + globals.APIClient, _ = mock.APIClient(mock.API{ ListVersionsFn: testutil.ListVersions, CloneVersionFn: testutil.CloneVersionResult(4), })("token", "endpoint") diff --git a/pkg/commands/logging/gcs/list.go b/pkg/commands/logging/gcs/list.go index ec3597f72..1d646d137 100644 --- a/pkg/commands/logging/gcs/list.go +++ b/pkg/commands/logging/gcs/list.go @@ -64,7 +64,7 @@ func (c *ListCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AllowActiveLocked: true, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -82,7 +82,7 @@ func (c *ListCommand) Exec(in io.Reader, out io.Writer) error { c.Input.ServiceID = serviceID c.Input.ServiceVersion = serviceVersion.Number - gcss, err := c.Globals.Client.ListGCSs(&c.Input) + gcss, err := c.Globals.APIClient.ListGCSs(&c.Input) if err != nil { c.Globals.ErrLog.Add(err) return err diff --git a/pkg/commands/logging/gcs/update.go b/pkg/commands/logging/gcs/update.go index 360e0e848..db2b79b05 100644 --- a/pkg/commands/logging/gcs/update.go +++ b/pkg/commands/logging/gcs/update.go @@ -157,7 +157,7 @@ func (c *UpdateCommand) ConstructInput(serviceID string, serviceVersion int) (*f func (c *UpdateCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.AutoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.Manifest, Out: out, ServiceNameFlag: c.ServiceName, @@ -178,7 +178,7 @@ func (c *UpdateCommand) Exec(in io.Reader, out io.Writer) error { return err } - gcs, err := c.Globals.Client.UpdateGCS(input) + gcs, err := c.Globals.APIClient.UpdateGCS(input) if err != nil { c.Globals.ErrLog.Add(err) return err diff --git a/pkg/commands/logging/googlepubsub/create.go b/pkg/commands/logging/googlepubsub/create.go index 37d6a4b35..a93f6c380 100644 --- a/pkg/commands/logging/googlepubsub/create.go +++ b/pkg/commands/logging/googlepubsub/create.go @@ -108,7 +108,7 @@ func (c *CreateCommand) ConstructInput(serviceID string, serviceVersion int) (*f func (c *CreateCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.AutoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.Manifest, Out: out, ServiceNameFlag: c.ServiceName, @@ -129,7 +129,7 @@ func (c *CreateCommand) Exec(in io.Reader, out io.Writer) error { return err } - d, err := c.Globals.Client.CreatePubsub(input) + d, err := c.Globals.APIClient.CreatePubsub(input) if err != nil { c.Globals.ErrLog.Add(err) return err diff --git a/pkg/commands/logging/googlepubsub/delete.go b/pkg/commands/logging/googlepubsub/delete.go index 30b3b4023..55218f0de 100644 --- a/pkg/commands/logging/googlepubsub/delete.go +++ b/pkg/commands/logging/googlepubsub/delete.go @@ -57,7 +57,7 @@ func NewDeleteCommand(parent cmd.Registerer, globals *config.Data, data manifest func (c *DeleteCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.autoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -75,7 +75,7 @@ func (c *DeleteCommand) Exec(in io.Reader, out io.Writer) error { c.Input.ServiceID = serviceID c.Input.ServiceVersion = serviceVersion.Number - if err := c.Globals.Client.DeletePubsub(&c.Input); err != nil { + if err := c.Globals.APIClient.DeletePubsub(&c.Input); err != nil { c.Globals.ErrLog.Add(err) return err } diff --git a/pkg/commands/logging/googlepubsub/describe.go b/pkg/commands/logging/googlepubsub/describe.go index 83e9c40ca..d6cfc677c 100644 --- a/pkg/commands/logging/googlepubsub/describe.go +++ b/pkg/commands/logging/googlepubsub/describe.go @@ -64,7 +64,7 @@ func (c *DescribeCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AllowActiveLocked: true, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -82,7 +82,7 @@ func (c *DescribeCommand) Exec(in io.Reader, out io.Writer) error { c.Input.ServiceID = serviceID c.Input.ServiceVersion = serviceVersion.Number - googlepubsub, err := c.Globals.Client.GetPubsub(&c.Input) + googlepubsub, err := c.Globals.APIClient.GetPubsub(&c.Input) if err != nil { c.Globals.ErrLog.Add(err) return err diff --git a/pkg/commands/logging/googlepubsub/googlepubsub_test.go b/pkg/commands/logging/googlepubsub/googlepubsub_test.go index 23814779d..866cfe501 100644 --- a/pkg/commands/logging/googlepubsub/googlepubsub_test.go +++ b/pkg/commands/logging/googlepubsub/googlepubsub_test.go @@ -65,7 +65,7 @@ func TestCreateGooglePubSubInput(t *testing.T) { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: testcase.cmd.AutoClone, - Client: testcase.cmd.Base.Globals.Client, + APIClient: testcase.cmd.Base.Globals.APIClient, Manifest: testcase.cmd.Manifest, Out: out, ServiceVersionFlag: testcase.cmd.ServiceVersion, @@ -144,7 +144,7 @@ func TestUpdateGooglePubSubInput(t *testing.T) { }, } { t.Run(testcase.name, func(t *testing.T) { - testcase.cmd.Base.Globals.Client = testcase.api + testcase.cmd.Base.Globals.APIClient = testcase.api var bs []byte out := bytes.NewBuffer(bs) @@ -152,7 +152,7 @@ func TestUpdateGooglePubSubInput(t *testing.T) { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: testcase.cmd.AutoClone, - Client: testcase.api, + APIClient: testcase.api, Manifest: testcase.cmd.Manifest, Out: out, ServiceVersionFlag: testcase.cmd.ServiceVersion, @@ -186,7 +186,7 @@ func createCommandRequired() *googlepubsub.CreateCommand { Env: config.Environment{}, Output: &b, } - globals.Client, _ = mock.APIClient(mock.API{ + globals.APIClient, _ = mock.APIClient(mock.API{ ListVersionsFn: testutil.ListVersions, CloneVersionFn: testutil.CloneVersionResult(4), })("token", "endpoint") @@ -227,7 +227,7 @@ func createCommandAll() *googlepubsub.CreateCommand { Env: config.Environment{}, Output: &b, } - globals.Client, _ = mock.APIClient(mock.API{ + globals.APIClient, _ = mock.APIClient(mock.API{ ListVersionsFn: testutil.ListVersions, CloneVersionFn: testutil.CloneVersionResult(4), })("token", "endpoint") diff --git a/pkg/commands/logging/googlepubsub/list.go b/pkg/commands/logging/googlepubsub/list.go index 5fee23f7b..c4a5ec26b 100644 --- a/pkg/commands/logging/googlepubsub/list.go +++ b/pkg/commands/logging/googlepubsub/list.go @@ -64,7 +64,7 @@ func (c *ListCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AllowActiveLocked: true, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -82,7 +82,7 @@ func (c *ListCommand) Exec(in io.Reader, out io.Writer) error { c.Input.ServiceID = serviceID c.Input.ServiceVersion = serviceVersion.Number - googlepubsubs, err := c.Globals.Client.ListPubsubs(&c.Input) + googlepubsubs, err := c.Globals.APIClient.ListPubsubs(&c.Input) if err != nil { c.Globals.ErrLog.Add(err) return err diff --git a/pkg/commands/logging/googlepubsub/update.go b/pkg/commands/logging/googlepubsub/update.go index 083fae5bf..10a7aa4aa 100644 --- a/pkg/commands/logging/googlepubsub/update.go +++ b/pkg/commands/logging/googlepubsub/update.go @@ -126,7 +126,7 @@ func (c *UpdateCommand) ConstructInput(serviceID string, serviceVersion int) (*f func (c *UpdateCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.AutoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.Manifest, Out: out, ServiceNameFlag: c.ServiceName, @@ -147,7 +147,7 @@ func (c *UpdateCommand) Exec(in io.Reader, out io.Writer) error { return err } - googlepubsub, err := c.Globals.Client.UpdatePubsub(input) + googlepubsub, err := c.Globals.APIClient.UpdatePubsub(input) if err != nil { c.Globals.ErrLog.Add(err) return err diff --git a/pkg/commands/logging/heroku/create.go b/pkg/commands/logging/heroku/create.go index f3b5afb03..7a2f61772 100644 --- a/pkg/commands/logging/heroku/create.go +++ b/pkg/commands/logging/heroku/create.go @@ -102,7 +102,7 @@ func (c *CreateCommand) ConstructInput(serviceID string, serviceVersion int) (*f func (c *CreateCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.AutoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.Manifest, Out: out, ServiceNameFlag: c.ServiceName, @@ -123,7 +123,7 @@ func (c *CreateCommand) Exec(in io.Reader, out io.Writer) error { return err } - d, err := c.Globals.Client.CreateHeroku(input) + d, err := c.Globals.APIClient.CreateHeroku(input) if err != nil { c.Globals.ErrLog.Add(err) return err diff --git a/pkg/commands/logging/heroku/delete.go b/pkg/commands/logging/heroku/delete.go index f098096e2..666393d0f 100644 --- a/pkg/commands/logging/heroku/delete.go +++ b/pkg/commands/logging/heroku/delete.go @@ -57,7 +57,7 @@ func NewDeleteCommand(parent cmd.Registerer, globals *config.Data, data manifest func (c *DeleteCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.autoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -75,7 +75,7 @@ func (c *DeleteCommand) Exec(in io.Reader, out io.Writer) error { c.Input.ServiceID = serviceID c.Input.ServiceVersion = serviceVersion.Number - if err := c.Globals.Client.DeleteHeroku(&c.Input); err != nil { + if err := c.Globals.APIClient.DeleteHeroku(&c.Input); err != nil { c.Globals.ErrLog.Add(err) return err } diff --git a/pkg/commands/logging/heroku/describe.go b/pkg/commands/logging/heroku/describe.go index 9b7e972ea..f517fca70 100644 --- a/pkg/commands/logging/heroku/describe.go +++ b/pkg/commands/logging/heroku/describe.go @@ -64,7 +64,7 @@ func (c *DescribeCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AllowActiveLocked: true, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -82,7 +82,7 @@ func (c *DescribeCommand) Exec(in io.Reader, out io.Writer) error { c.Input.ServiceID = serviceID c.Input.ServiceVersion = serviceVersion.Number - heroku, err := c.Globals.Client.GetHeroku(&c.Input) + heroku, err := c.Globals.APIClient.GetHeroku(&c.Input) if err != nil { c.Globals.ErrLog.Add(err) return err diff --git a/pkg/commands/logging/heroku/heroku_test.go b/pkg/commands/logging/heroku/heroku_test.go index 613a557e2..c5f620420 100644 --- a/pkg/commands/logging/heroku/heroku_test.go +++ b/pkg/commands/logging/heroku/heroku_test.go @@ -61,7 +61,7 @@ func TestCreateHerokuInput(t *testing.T) { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: testcase.cmd.AutoClone, - Client: testcase.cmd.Base.Globals.Client, + APIClient: testcase.cmd.Base.Globals.APIClient, Manifest: testcase.cmd.Manifest, Out: out, ServiceVersionFlag: testcase.cmd.ServiceVersion, @@ -138,7 +138,7 @@ func TestUpdateHerokuInput(t *testing.T) { }, } { t.Run(testcase.name, func(t *testing.T) { - testcase.cmd.Base.Globals.Client = testcase.api + testcase.cmd.Base.Globals.APIClient = testcase.api var bs []byte out := bytes.NewBuffer(bs) @@ -146,7 +146,7 @@ func TestUpdateHerokuInput(t *testing.T) { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: testcase.cmd.AutoClone, - Client: testcase.api, + APIClient: testcase.api, Manifest: testcase.cmd.Manifest, Out: out, ServiceVersionFlag: testcase.cmd.ServiceVersion, @@ -180,7 +180,7 @@ func createCommandRequired() *heroku.CreateCommand { Env: config.Environment{}, Output: &b, } - globals.Client, _ = mock.APIClient(mock.API{ + globals.APIClient, _ = mock.APIClient(mock.API{ ListVersionsFn: testutil.ListVersions, CloneVersionFn: testutil.CloneVersionResult(4), })("token", "endpoint") @@ -219,7 +219,7 @@ func createCommandAll() *heroku.CreateCommand { Env: config.Environment{}, Output: &b, } - globals.Client, _ = mock.APIClient(mock.API{ + globals.APIClient, _ = mock.APIClient(mock.API{ ListVersionsFn: testutil.ListVersions, CloneVersionFn: testutil.CloneVersionResult(4), })("token", "endpoint") diff --git a/pkg/commands/logging/heroku/list.go b/pkg/commands/logging/heroku/list.go index 15331cfa7..c37c5e8eb 100644 --- a/pkg/commands/logging/heroku/list.go +++ b/pkg/commands/logging/heroku/list.go @@ -64,7 +64,7 @@ func (c *ListCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AllowActiveLocked: true, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -82,7 +82,7 @@ func (c *ListCommand) Exec(in io.Reader, out io.Writer) error { c.Input.ServiceID = serviceID c.Input.ServiceVersion = serviceVersion.Number - herokus, err := c.Globals.Client.ListHerokus(&c.Input) + herokus, err := c.Globals.APIClient.ListHerokus(&c.Input) if err != nil { c.Globals.ErrLog.Add(err) return err diff --git a/pkg/commands/logging/heroku/update.go b/pkg/commands/logging/heroku/update.go index 88042c9b6..d263b855b 100644 --- a/pkg/commands/logging/heroku/update.go +++ b/pkg/commands/logging/heroku/update.go @@ -114,7 +114,7 @@ func (c *UpdateCommand) ConstructInput(serviceID string, serviceVersion int) (*f func (c *UpdateCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.AutoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.Manifest, Out: out, ServiceNameFlag: c.ServiceName, @@ -135,7 +135,7 @@ func (c *UpdateCommand) Exec(in io.Reader, out io.Writer) error { return err } - heroku, err := c.Globals.Client.UpdateHeroku(input) + heroku, err := c.Globals.APIClient.UpdateHeroku(input) if err != nil { c.Globals.ErrLog.Add(err) return err diff --git a/pkg/commands/logging/honeycomb/create.go b/pkg/commands/logging/honeycomb/create.go index e45e2ce4d..810ec1b02 100644 --- a/pkg/commands/logging/honeycomb/create.go +++ b/pkg/commands/logging/honeycomb/create.go @@ -102,7 +102,7 @@ func (c *CreateCommand) ConstructInput(serviceID string, serviceVersion int) (*f func (c *CreateCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.AutoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.Manifest, Out: out, ServiceNameFlag: c.ServiceName, @@ -123,7 +123,7 @@ func (c *CreateCommand) Exec(in io.Reader, out io.Writer) error { return err } - d, err := c.Globals.Client.CreateHoneycomb(input) + d, err := c.Globals.APIClient.CreateHoneycomb(input) if err != nil { c.Globals.ErrLog.Add(err) return err diff --git a/pkg/commands/logging/honeycomb/delete.go b/pkg/commands/logging/honeycomb/delete.go index 9baa6ad04..41d89600c 100644 --- a/pkg/commands/logging/honeycomb/delete.go +++ b/pkg/commands/logging/honeycomb/delete.go @@ -57,7 +57,7 @@ func NewDeleteCommand(parent cmd.Registerer, globals *config.Data, data manifest func (c *DeleteCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.autoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -75,7 +75,7 @@ func (c *DeleteCommand) Exec(in io.Reader, out io.Writer) error { c.Input.ServiceID = serviceID c.Input.ServiceVersion = serviceVersion.Number - if err := c.Globals.Client.DeleteHoneycomb(&c.Input); err != nil { + if err := c.Globals.APIClient.DeleteHoneycomb(&c.Input); err != nil { c.Globals.ErrLog.Add(err) return err } diff --git a/pkg/commands/logging/honeycomb/describe.go b/pkg/commands/logging/honeycomb/describe.go index 30fcedf35..2b79eee24 100644 --- a/pkg/commands/logging/honeycomb/describe.go +++ b/pkg/commands/logging/honeycomb/describe.go @@ -64,7 +64,7 @@ func (c *DescribeCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AllowActiveLocked: true, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -82,7 +82,7 @@ func (c *DescribeCommand) Exec(in io.Reader, out io.Writer) error { c.Input.ServiceID = serviceID c.Input.ServiceVersion = serviceVersion.Number - honeycomb, err := c.Globals.Client.GetHoneycomb(&c.Input) + honeycomb, err := c.Globals.APIClient.GetHoneycomb(&c.Input) if err != nil { c.Globals.ErrLog.Add(err) return err diff --git a/pkg/commands/logging/honeycomb/honeycomb_test.go b/pkg/commands/logging/honeycomb/honeycomb_test.go index 254313f37..1f0eca763 100644 --- a/pkg/commands/logging/honeycomb/honeycomb_test.go +++ b/pkg/commands/logging/honeycomb/honeycomb_test.go @@ -61,7 +61,7 @@ func TestCreateHoneycombInput(t *testing.T) { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: testcase.cmd.AutoClone, - Client: testcase.cmd.Base.Globals.Client, + APIClient: testcase.cmd.Base.Globals.APIClient, Manifest: testcase.cmd.Manifest, Out: out, ServiceVersionFlag: testcase.cmd.ServiceVersion, @@ -137,7 +137,7 @@ func TestUpdateHoneycombInput(t *testing.T) { }, } { t.Run(testcase.name, func(t *testing.T) { - testcase.cmd.Base.Globals.Client = testcase.api + testcase.cmd.Base.Globals.APIClient = testcase.api var bs []byte out := bytes.NewBuffer(bs) @@ -145,7 +145,7 @@ func TestUpdateHoneycombInput(t *testing.T) { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: testcase.cmd.AutoClone, - Client: testcase.api, + APIClient: testcase.api, Manifest: testcase.cmd.Manifest, Out: out, ServiceVersionFlag: testcase.cmd.ServiceVersion, @@ -179,7 +179,7 @@ func createCommandRequired() *honeycomb.CreateCommand { Env: config.Environment{}, Output: &b, } - globals.Client, _ = mock.APIClient(mock.API{ + globals.APIClient, _ = mock.APIClient(mock.API{ ListVersionsFn: testutil.ListVersions, CloneVersionFn: testutil.CloneVersionResult(4), })("token", "endpoint") @@ -218,7 +218,7 @@ func createCommandAll() *honeycomb.CreateCommand { Env: config.Environment{}, Output: &b, } - globals.Client, _ = mock.APIClient(mock.API{ + globals.APIClient, _ = mock.APIClient(mock.API{ ListVersionsFn: testutil.ListVersions, CloneVersionFn: testutil.CloneVersionResult(4), })("token", "endpoint") diff --git a/pkg/commands/logging/honeycomb/list.go b/pkg/commands/logging/honeycomb/list.go index 0b578bbb1..727c9041e 100644 --- a/pkg/commands/logging/honeycomb/list.go +++ b/pkg/commands/logging/honeycomb/list.go @@ -64,7 +64,7 @@ func (c *ListCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AllowActiveLocked: true, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -82,7 +82,7 @@ func (c *ListCommand) Exec(in io.Reader, out io.Writer) error { c.Input.ServiceID = serviceID c.Input.ServiceVersion = serviceVersion.Number - honeycombs, err := c.Globals.Client.ListHoneycombs(&c.Input) + honeycombs, err := c.Globals.APIClient.ListHoneycombs(&c.Input) if err != nil { c.Globals.ErrLog.Add(err) return err diff --git a/pkg/commands/logging/honeycomb/update.go b/pkg/commands/logging/honeycomb/update.go index f9a82abe9..f555408be 100644 --- a/pkg/commands/logging/honeycomb/update.go +++ b/pkg/commands/logging/honeycomb/update.go @@ -114,7 +114,7 @@ func (c *UpdateCommand) ConstructInput(serviceID string, serviceVersion int) (*f func (c *UpdateCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.AutoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.Manifest, Out: out, ServiceNameFlag: c.ServiceName, @@ -135,7 +135,7 @@ func (c *UpdateCommand) Exec(in io.Reader, out io.Writer) error { return err } - honeycomb, err := c.Globals.Client.UpdateHoneycomb(input) + honeycomb, err := c.Globals.APIClient.UpdateHoneycomb(input) if err != nil { c.Globals.ErrLog.Add(err) return err diff --git a/pkg/commands/logging/https/create.go b/pkg/commands/logging/https/create.go index c0313986c..94ae5da63 100644 --- a/pkg/commands/logging/https/create.go +++ b/pkg/commands/logging/https/create.go @@ -171,7 +171,7 @@ func (c *CreateCommand) ConstructInput(serviceID string, serviceVersion int) (*f func (c *CreateCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.AutoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.Manifest, Out: out, ServiceNameFlag: c.ServiceName, @@ -192,7 +192,7 @@ func (c *CreateCommand) Exec(in io.Reader, out io.Writer) error { return err } - d, err := c.Globals.Client.CreateHTTPS(input) + d, err := c.Globals.APIClient.CreateHTTPS(input) if err != nil { c.Globals.ErrLog.Add(err) return err diff --git a/pkg/commands/logging/https/delete.go b/pkg/commands/logging/https/delete.go index 567a6d836..d8cd8d268 100644 --- a/pkg/commands/logging/https/delete.go +++ b/pkg/commands/logging/https/delete.go @@ -57,7 +57,7 @@ func NewDeleteCommand(parent cmd.Registerer, globals *config.Data, data manifest func (c *DeleteCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.autoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -75,7 +75,7 @@ func (c *DeleteCommand) Exec(in io.Reader, out io.Writer) error { c.Input.ServiceID = serviceID c.Input.ServiceVersion = serviceVersion.Number - if err := c.Globals.Client.DeleteHTTPS(&c.Input); err != nil { + if err := c.Globals.APIClient.DeleteHTTPS(&c.Input); err != nil { c.Globals.ErrLog.Add(err) return err } diff --git a/pkg/commands/logging/https/describe.go b/pkg/commands/logging/https/describe.go index 123382a55..62044fbd2 100644 --- a/pkg/commands/logging/https/describe.go +++ b/pkg/commands/logging/https/describe.go @@ -64,7 +64,7 @@ func (c *DescribeCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AllowActiveLocked: true, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -82,7 +82,7 @@ func (c *DescribeCommand) Exec(in io.Reader, out io.Writer) error { c.Input.ServiceID = serviceID c.Input.ServiceVersion = serviceVersion.Number - https, err := c.Globals.Client.GetHTTPS(&c.Input) + https, err := c.Globals.APIClient.GetHTTPS(&c.Input) if err != nil { c.Globals.ErrLog.Add(err) return err diff --git a/pkg/commands/logging/https/https_test.go b/pkg/commands/logging/https/https_test.go index 093d73503..6fcec82d6 100644 --- a/pkg/commands/logging/https/https_test.go +++ b/pkg/commands/logging/https/https_test.go @@ -71,7 +71,7 @@ func TestCreateHTTPSInput(t *testing.T) { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: testcase.cmd.AutoClone, - Client: testcase.cmd.Base.Globals.Client, + APIClient: testcase.cmd.Base.Globals.APIClient, Manifest: testcase.cmd.Manifest, Out: out, ServiceVersionFlag: testcase.cmd.ServiceVersion, @@ -159,7 +159,7 @@ func TestUpdateHTTPSInput(t *testing.T) { }, } { t.Run(testcase.name, func(t *testing.T) { - testcase.cmd.Base.Globals.Client = testcase.api + testcase.cmd.Base.Globals.APIClient = testcase.api var bs []byte out := bytes.NewBuffer(bs) @@ -167,7 +167,7 @@ func TestUpdateHTTPSInput(t *testing.T) { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: testcase.cmd.AutoClone, - Client: testcase.api, + APIClient: testcase.api, Manifest: testcase.cmd.Manifest, Out: out, ServiceVersionFlag: testcase.cmd.ServiceVersion, @@ -201,7 +201,7 @@ func createCommandRequired() *https.CreateCommand { Env: config.Environment{}, Output: &b, } - globals.Client, _ = mock.APIClient(mock.API{ + globals.APIClient, _ = mock.APIClient(mock.API{ ListVersionsFn: testutil.ListVersions, CloneVersionFn: testutil.CloneVersionResult(4), })("token", "endpoint") @@ -239,7 +239,7 @@ func createCommandAll() *https.CreateCommand { Env: config.Environment{}, Output: &b, } - globals.Client, _ = mock.APIClient(mock.API{ + globals.APIClient, _ = mock.APIClient(mock.API{ ListVersionsFn: testutil.ListVersions, CloneVersionFn: testutil.CloneVersionResult(4), })("token", "endpoint") diff --git a/pkg/commands/logging/https/list.go b/pkg/commands/logging/https/list.go index 373d95ba3..0d6eeaa0c 100644 --- a/pkg/commands/logging/https/list.go +++ b/pkg/commands/logging/https/list.go @@ -64,7 +64,7 @@ func (c *ListCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AllowActiveLocked: true, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -82,7 +82,7 @@ func (c *ListCommand) Exec(in io.Reader, out io.Writer) error { c.Input.ServiceID = serviceID c.Input.ServiceVersion = serviceVersion.Number - httpss, err := c.Globals.Client.ListHTTPS(&c.Input) + httpss, err := c.Globals.APIClient.ListHTTPS(&c.Input) if err != nil { c.Globals.ErrLog.Add(err) return err diff --git a/pkg/commands/logging/https/update.go b/pkg/commands/logging/https/update.go index 202a91c04..354176515 100644 --- a/pkg/commands/logging/https/update.go +++ b/pkg/commands/logging/https/update.go @@ -180,7 +180,7 @@ func (c *UpdateCommand) ConstructInput(serviceID string, serviceVersion int) (*f func (c *UpdateCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.AutoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.Manifest, Out: out, ServiceNameFlag: c.ServiceName, @@ -201,7 +201,7 @@ func (c *UpdateCommand) Exec(in io.Reader, out io.Writer) error { return err } - https, err := c.Globals.Client.UpdateHTTPS(input) + https, err := c.Globals.APIClient.UpdateHTTPS(input) if err != nil { c.Globals.ErrLog.Add(err) return err diff --git a/pkg/commands/logging/kafka/create.go b/pkg/commands/logging/kafka/create.go index c3176eea5..6b3db6cdb 100644 --- a/pkg/commands/logging/kafka/create.go +++ b/pkg/commands/logging/kafka/create.go @@ -185,7 +185,7 @@ func (c *CreateCommand) ConstructInput(serviceID string, serviceVersion int) (*f func (c *CreateCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.AutoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.Manifest, Out: out, ServiceNameFlag: c.ServiceName, @@ -206,7 +206,7 @@ func (c *CreateCommand) Exec(in io.Reader, out io.Writer) error { return err } - d, err := c.Globals.Client.CreateKafka(input) + d, err := c.Globals.APIClient.CreateKafka(input) if err != nil { c.Globals.ErrLog.Add(err) return err diff --git a/pkg/commands/logging/kafka/delete.go b/pkg/commands/logging/kafka/delete.go index 2c9859b7c..020a4ccac 100644 --- a/pkg/commands/logging/kafka/delete.go +++ b/pkg/commands/logging/kafka/delete.go @@ -57,7 +57,7 @@ func NewDeleteCommand(parent cmd.Registerer, globals *config.Data, data manifest func (c *DeleteCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.autoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -75,7 +75,7 @@ func (c *DeleteCommand) Exec(in io.Reader, out io.Writer) error { c.Input.ServiceID = serviceID c.Input.ServiceVersion = serviceVersion.Number - if err := c.Globals.Client.DeleteKafka(&c.Input); err != nil { + if err := c.Globals.APIClient.DeleteKafka(&c.Input); err != nil { c.Globals.ErrLog.Add(err) return err } diff --git a/pkg/commands/logging/kafka/describe.go b/pkg/commands/logging/kafka/describe.go index 2e88e3f01..bf1336d35 100644 --- a/pkg/commands/logging/kafka/describe.go +++ b/pkg/commands/logging/kafka/describe.go @@ -64,7 +64,7 @@ func (c *DescribeCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AllowActiveLocked: true, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -82,7 +82,7 @@ func (c *DescribeCommand) Exec(in io.Reader, out io.Writer) error { c.Input.ServiceID = serviceID c.Input.ServiceVersion = serviceVersion.Number - kafka, err := c.Globals.Client.GetKafka(&c.Input) + kafka, err := c.Globals.APIClient.GetKafka(&c.Input) if err != nil { c.Globals.ErrLog.Add(err) return err diff --git a/pkg/commands/logging/kafka/kafka_test.go b/pkg/commands/logging/kafka/kafka_test.go index 7e98da7c6..8b547b6e8 100644 --- a/pkg/commands/logging/kafka/kafka_test.go +++ b/pkg/commands/logging/kafka/kafka_test.go @@ -128,7 +128,7 @@ func TestCreateKafkaInput(t *testing.T) { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: testcase.cmd.AutoClone, - Client: testcase.cmd.Base.Globals.Client, + APIClient: testcase.cmd.Base.Globals.APIClient, Manifest: testcase.cmd.Manifest, Out: out, ServiceVersionFlag: testcase.cmd.ServiceVersion, @@ -304,7 +304,7 @@ func TestUpdateKafkaInput(t *testing.T) { }, } { t.Run(testcase.name, func(t *testing.T) { - testcase.cmd.Base.Globals.Client = testcase.api + testcase.cmd.Base.Globals.APIClient = testcase.api var bs []byte out := bytes.NewBuffer(bs) @@ -312,7 +312,7 @@ func TestUpdateKafkaInput(t *testing.T) { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: testcase.cmd.AutoClone, - Client: testcase.api, + APIClient: testcase.api, Manifest: testcase.cmd.Manifest, Out: out, ServiceVersionFlag: testcase.cmd.ServiceVersion, @@ -346,7 +346,7 @@ func createCommandRequired() *kafka.CreateCommand { Env: config.Environment{}, Output: &b, } - globals.Client, _ = mock.APIClient(mock.API{ + globals.APIClient, _ = mock.APIClient(mock.API{ ListVersionsFn: testutil.ListVersions, CloneVersionFn: testutil.CloneVersionResult(4), })("token", "endpoint") @@ -385,7 +385,7 @@ func createCommandAll() *kafka.CreateCommand { Env: config.Environment{}, Output: &b, } - globals.Client, _ = mock.APIClient(mock.API{ + globals.APIClient, _ = mock.APIClient(mock.API{ ListVersionsFn: testutil.ListVersions, CloneVersionFn: testutil.CloneVersionResult(4), })("token", "endpoint") @@ -435,7 +435,7 @@ func createCommandSASL(authMethod, user, password string) *kafka.CreateCommand { Env: config.Environment{}, Output: &b, } - globals.Client, _ = mock.APIClient(mock.API{ + globals.APIClient, _ = mock.APIClient(mock.API{ ListVersionsFn: testutil.ListVersions, CloneVersionFn: testutil.CloneVersionResult(4), })("token", "endpoint") @@ -480,7 +480,7 @@ func createCommandNoSASL(authMethod, user, password string) *kafka.CreateCommand Env: config.Environment{}, Output: &b, } - globals.Client, _ = mock.APIClient(mock.API{ + globals.APIClient, _ = mock.APIClient(mock.API{ ListVersionsFn: testutil.ListVersions, CloneVersionFn: testutil.CloneVersionResult(4), })("token", "endpoint") diff --git a/pkg/commands/logging/kafka/list.go b/pkg/commands/logging/kafka/list.go index f66a58963..53f83bb13 100644 --- a/pkg/commands/logging/kafka/list.go +++ b/pkg/commands/logging/kafka/list.go @@ -64,7 +64,7 @@ func (c *ListCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AllowActiveLocked: true, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -82,7 +82,7 @@ func (c *ListCommand) Exec(in io.Reader, out io.Writer) error { c.Input.ServiceID = serviceID c.Input.ServiceVersion = serviceVersion.Number - kafkas, err := c.Globals.Client.ListKafkas(&c.Input) + kafkas, err := c.Globals.APIClient.ListKafkas(&c.Input) if err != nil { c.Globals.ErrLog.Add(err) return err diff --git a/pkg/commands/logging/kafka/update.go b/pkg/commands/logging/kafka/update.go index 6c7dfe0a7..177fb972c 100644 --- a/pkg/commands/logging/kafka/update.go +++ b/pkg/commands/logging/kafka/update.go @@ -205,7 +205,7 @@ func (c *UpdateCommand) ConstructInput(serviceID string, serviceVersion int) (*f func (c *UpdateCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.AutoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.Manifest, Out: out, ServiceNameFlag: c.ServiceName, @@ -226,7 +226,7 @@ func (c *UpdateCommand) Exec(in io.Reader, out io.Writer) error { return err } - kafka, err := c.Globals.Client.UpdateKafka(input) + kafka, err := c.Globals.APIClient.UpdateKafka(input) if err != nil { c.Globals.ErrLog.Add(err) return err diff --git a/pkg/commands/logging/kinesis/create.go b/pkg/commands/logging/kinesis/create.go index 322b7c7f9..30d9cb5e4 100644 --- a/pkg/commands/logging/kinesis/create.go +++ b/pkg/commands/logging/kinesis/create.go @@ -150,7 +150,7 @@ func (c *CreateCommand) ConstructInput(serviceID string, serviceVersion int) (*f func (c *CreateCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.AutoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.Manifest, Out: out, ServiceNameFlag: c.ServiceName, @@ -171,7 +171,7 @@ func (c *CreateCommand) Exec(in io.Reader, out io.Writer) error { return err } - d, err := c.Globals.Client.CreateKinesis(input) + d, err := c.Globals.APIClient.CreateKinesis(input) if err != nil { c.Globals.ErrLog.Add(err) return err diff --git a/pkg/commands/logging/kinesis/delete.go b/pkg/commands/logging/kinesis/delete.go index f49f3f996..42203bf9c 100644 --- a/pkg/commands/logging/kinesis/delete.go +++ b/pkg/commands/logging/kinesis/delete.go @@ -58,7 +58,7 @@ func NewDeleteCommand(parent cmd.Registerer, globals *config.Data, data manifest func (c *DeleteCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.autoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -76,7 +76,7 @@ func (c *DeleteCommand) Exec(in io.Reader, out io.Writer) error { c.Input.ServiceID = serviceID c.Input.ServiceVersion = serviceVersion.Number - if err := c.Globals.Client.DeleteKinesis(&c.Input); err != nil { + if err := c.Globals.APIClient.DeleteKinesis(&c.Input); err != nil { c.Globals.ErrLog.Add(err) return err } diff --git a/pkg/commands/logging/kinesis/describe.go b/pkg/commands/logging/kinesis/describe.go index 2341a735b..4411e3add 100644 --- a/pkg/commands/logging/kinesis/describe.go +++ b/pkg/commands/logging/kinesis/describe.go @@ -64,7 +64,7 @@ func (c *DescribeCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AllowActiveLocked: true, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -82,7 +82,7 @@ func (c *DescribeCommand) Exec(in io.Reader, out io.Writer) error { c.Input.ServiceID = serviceID c.Input.ServiceVersion = serviceVersion.Number - kinesis, err := c.Globals.Client.GetKinesis(&c.Input) + kinesis, err := c.Globals.APIClient.GetKinesis(&c.Input) if err != nil { c.Globals.ErrLog.Add(err) return err diff --git a/pkg/commands/logging/kinesis/kinesis_test.go b/pkg/commands/logging/kinesis/kinesis_test.go index ab48cc947..29e4788cb 100644 --- a/pkg/commands/logging/kinesis/kinesis_test.go +++ b/pkg/commands/logging/kinesis/kinesis_test.go @@ -75,7 +75,7 @@ func TestCreateKinesisInput(t *testing.T) { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: testcase.cmd.AutoClone, - Client: testcase.cmd.Base.Globals.Client, + APIClient: testcase.cmd.Base.Globals.APIClient, Manifest: testcase.cmd.Manifest, Out: out, ServiceVersionFlag: testcase.cmd.ServiceVersion, @@ -155,7 +155,7 @@ func TestUpdateKinesisInput(t *testing.T) { }, } { t.Run(testcase.name, func(t *testing.T) { - testcase.cmd.Base.Globals.Client = testcase.api + testcase.cmd.Base.Globals.APIClient = testcase.api var bs []byte out := bytes.NewBuffer(bs) @@ -163,7 +163,7 @@ func TestUpdateKinesisInput(t *testing.T) { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: testcase.cmd.AutoClone, - Client: testcase.api, + APIClient: testcase.api, Manifest: testcase.cmd.Manifest, Out: out, ServiceVersionFlag: testcase.cmd.ServiceVersion, @@ -197,7 +197,7 @@ func createCommandRequired() *kinesis.CreateCommand { Env: config.Environment{}, Output: &b, } - globals.Client, _ = mock.APIClient(mock.API{ + globals.APIClient, _ = mock.APIClient(mock.API{ ListVersionsFn: testutil.ListVersions, CloneVersionFn: testutil.CloneVersionResult(4), })("token", "endpoint") @@ -237,7 +237,7 @@ func createCommandRequiredIAMRole() *kinesis.CreateCommand { Env: config.Environment{}, Output: &b, } - globals.Client, _ = mock.APIClient(mock.API{ + globals.APIClient, _ = mock.APIClient(mock.API{ ListVersionsFn: testutil.ListVersions, CloneVersionFn: testutil.CloneVersionResult(4), })("token", "endpoint") @@ -276,7 +276,7 @@ func createCommandAll() *kinesis.CreateCommand { Env: config.Environment{}, Output: &b, } - globals.Client, _ = mock.APIClient(mock.API{ + globals.APIClient, _ = mock.APIClient(mock.API{ ListVersionsFn: testutil.ListVersions, CloneVersionFn: testutil.CloneVersionResult(4), })("token", "endpoint") diff --git a/pkg/commands/logging/kinesis/list.go b/pkg/commands/logging/kinesis/list.go index ebbb954ea..1a62dec2f 100644 --- a/pkg/commands/logging/kinesis/list.go +++ b/pkg/commands/logging/kinesis/list.go @@ -64,7 +64,7 @@ func (c *ListCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AllowActiveLocked: true, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -82,7 +82,7 @@ func (c *ListCommand) Exec(in io.Reader, out io.Writer) error { c.Input.ServiceID = serviceID c.Input.ServiceVersion = serviceVersion.Number - kineses, err := c.Globals.Client.ListKinesis(&c.Input) + kineses, err := c.Globals.APIClient.ListKinesis(&c.Input) if err != nil { c.Globals.ErrLog.Add(err) return err diff --git a/pkg/commands/logging/kinesis/update.go b/pkg/commands/logging/kinesis/update.go index 791e37e7c..50396491a 100644 --- a/pkg/commands/logging/kinesis/update.go +++ b/pkg/commands/logging/kinesis/update.go @@ -132,7 +132,7 @@ func (c *UpdateCommand) ConstructInput(serviceID string, serviceVersion int) (*f func (c *UpdateCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.AutoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.Manifest, Out: out, ServiceNameFlag: c.ServiceName, @@ -153,7 +153,7 @@ func (c *UpdateCommand) Exec(in io.Reader, out io.Writer) error { return err } - kinesis, err := c.Globals.Client.UpdateKinesis(input) + kinesis, err := c.Globals.APIClient.UpdateKinesis(input) if err != nil { c.Globals.ErrLog.Add(err) return err diff --git a/pkg/commands/logging/logentries/create.go b/pkg/commands/logging/logentries/create.go index fe4636a8c..de7ceab42 100644 --- a/pkg/commands/logging/logentries/create.go +++ b/pkg/commands/logging/logentries/create.go @@ -120,7 +120,7 @@ func (c *CreateCommand) ConstructInput(serviceID string, serviceVersion int) (*f func (c *CreateCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.AutoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.Manifest, Out: out, ServiceNameFlag: c.ServiceName, @@ -141,7 +141,7 @@ func (c *CreateCommand) Exec(in io.Reader, out io.Writer) error { return err } - d, err := c.Globals.Client.CreateLogentries(input) + d, err := c.Globals.APIClient.CreateLogentries(input) if err != nil { c.Globals.ErrLog.Add(err) return err diff --git a/pkg/commands/logging/logentries/delete.go b/pkg/commands/logging/logentries/delete.go index af3878579..57835dcc4 100644 --- a/pkg/commands/logging/logentries/delete.go +++ b/pkg/commands/logging/logentries/delete.go @@ -57,7 +57,7 @@ func NewDeleteCommand(parent cmd.Registerer, globals *config.Data, data manifest func (c *DeleteCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.autoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -75,7 +75,7 @@ func (c *DeleteCommand) Exec(in io.Reader, out io.Writer) error { c.Input.ServiceID = serviceID c.Input.ServiceVersion = serviceVersion.Number - if err := c.Globals.Client.DeleteLogentries(&c.Input); err != nil { + if err := c.Globals.APIClient.DeleteLogentries(&c.Input); err != nil { c.Globals.ErrLog.Add(err) return err } diff --git a/pkg/commands/logging/logentries/describe.go b/pkg/commands/logging/logentries/describe.go index c88335b2e..11e0509c8 100644 --- a/pkg/commands/logging/logentries/describe.go +++ b/pkg/commands/logging/logentries/describe.go @@ -64,7 +64,7 @@ func (c *DescribeCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AllowActiveLocked: true, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -82,7 +82,7 @@ func (c *DescribeCommand) Exec(in io.Reader, out io.Writer) error { c.Input.ServiceID = serviceID c.Input.ServiceVersion = serviceVersion.Number - logentries, err := c.Globals.Client.GetLogentries(&c.Input) + logentries, err := c.Globals.APIClient.GetLogentries(&c.Input) if err != nil { c.Globals.ErrLog.Add(err) return err diff --git a/pkg/commands/logging/logentries/list.go b/pkg/commands/logging/logentries/list.go index 00de4220e..a8fd74713 100644 --- a/pkg/commands/logging/logentries/list.go +++ b/pkg/commands/logging/logentries/list.go @@ -64,7 +64,7 @@ func (c *ListCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AllowActiveLocked: true, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -82,7 +82,7 @@ func (c *ListCommand) Exec(in io.Reader, out io.Writer) error { c.Input.ServiceID = serviceID c.Input.ServiceVersion = serviceVersion.Number - logentriess, err := c.Globals.Client.ListLogentries(&c.Input) + logentriess, err := c.Globals.APIClient.ListLogentries(&c.Input) if err != nil { c.Globals.ErrLog.Add(err) return err diff --git a/pkg/commands/logging/logentries/logentries_test.go b/pkg/commands/logging/logentries/logentries_test.go index f3fd808e2..0614c85c9 100644 --- a/pkg/commands/logging/logentries/logentries_test.go +++ b/pkg/commands/logging/logentries/logentries_test.go @@ -61,7 +61,7 @@ func TestCreateLogentriesInput(t *testing.T) { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: testcase.cmd.AutoClone, - Client: testcase.cmd.Base.Globals.Client, + APIClient: testcase.cmd.Base.Globals.APIClient, Manifest: testcase.cmd.Manifest, Out: out, ServiceVersionFlag: testcase.cmd.ServiceVersion, @@ -140,7 +140,7 @@ func TestUpdateLogentriesInput(t *testing.T) { }, } { t.Run(testcase.name, func(t *testing.T) { - testcase.cmd.Base.Globals.Client = testcase.api + testcase.cmd.Base.Globals.APIClient = testcase.api var bs []byte out := bytes.NewBuffer(bs) @@ -148,7 +148,7 @@ func TestUpdateLogentriesInput(t *testing.T) { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: testcase.cmd.AutoClone, - Client: testcase.api, + APIClient: testcase.api, Manifest: testcase.cmd.Manifest, Out: out, ServiceVersionFlag: testcase.cmd.ServiceVersion, @@ -182,7 +182,7 @@ func createCommandOK() *logentries.CreateCommand { Env: config.Environment{}, Output: &b, } - globals.Client, _ = mock.APIClient(mock.API{ + globals.APIClient, _ = mock.APIClient(mock.API{ ListVersionsFn: testutil.ListVersions, CloneVersionFn: testutil.CloneVersionResult(4), })("token", "endpoint") @@ -227,7 +227,7 @@ func createCommandRequired() *logentries.CreateCommand { Env: config.Environment{}, Output: &b, } - globals.Client, _ = mock.APIClient(mock.API{ + globals.APIClient, _ = mock.APIClient(mock.API{ ListVersionsFn: testutil.ListVersions, CloneVersionFn: testutil.CloneVersionResult(4), })("token", "endpoint") diff --git a/pkg/commands/logging/logentries/update.go b/pkg/commands/logging/logentries/update.go index bbb741787..2170a1686 100644 --- a/pkg/commands/logging/logentries/update.go +++ b/pkg/commands/logging/logentries/update.go @@ -127,7 +127,7 @@ func (c *UpdateCommand) ConstructInput(serviceID string, serviceVersion int) (*f func (c *UpdateCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.AutoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.Manifest, Out: out, ServiceNameFlag: c.ServiceName, @@ -148,7 +148,7 @@ func (c *UpdateCommand) Exec(in io.Reader, out io.Writer) error { return err } - logentries, err := c.Globals.Client.UpdateLogentries(input) + logentries, err := c.Globals.APIClient.UpdateLogentries(input) if err != nil { c.Globals.ErrLog.Add(err) return err diff --git a/pkg/commands/logging/loggly/create.go b/pkg/commands/logging/loggly/create.go index 8f9322c82..41ac3087b 100644 --- a/pkg/commands/logging/loggly/create.go +++ b/pkg/commands/logging/loggly/create.go @@ -99,7 +99,7 @@ func (c *CreateCommand) ConstructInput(serviceID string, serviceVersion int) (*f func (c *CreateCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.AutoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.Manifest, Out: out, ServiceNameFlag: c.ServiceName, @@ -120,7 +120,7 @@ func (c *CreateCommand) Exec(in io.Reader, out io.Writer) error { return err } - d, err := c.Globals.Client.CreateLoggly(input) + d, err := c.Globals.APIClient.CreateLoggly(input) if err != nil { c.Globals.ErrLog.Add(err) return err diff --git a/pkg/commands/logging/loggly/delete.go b/pkg/commands/logging/loggly/delete.go index e3ef4331a..6f45fd79d 100644 --- a/pkg/commands/logging/loggly/delete.go +++ b/pkg/commands/logging/loggly/delete.go @@ -57,7 +57,7 @@ func NewDeleteCommand(parent cmd.Registerer, globals *config.Data, data manifest func (c *DeleteCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.autoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -75,7 +75,7 @@ func (c *DeleteCommand) Exec(in io.Reader, out io.Writer) error { c.Input.ServiceID = serviceID c.Input.ServiceVersion = serviceVersion.Number - if err := c.Globals.Client.DeleteLoggly(&c.Input); err != nil { + if err := c.Globals.APIClient.DeleteLoggly(&c.Input); err != nil { c.Globals.ErrLog.Add(err) return err } diff --git a/pkg/commands/logging/loggly/describe.go b/pkg/commands/logging/loggly/describe.go index 815f0613a..b6e991400 100644 --- a/pkg/commands/logging/loggly/describe.go +++ b/pkg/commands/logging/loggly/describe.go @@ -64,7 +64,7 @@ func (c *DescribeCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AllowActiveLocked: true, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -82,7 +82,7 @@ func (c *DescribeCommand) Exec(in io.Reader, out io.Writer) error { c.Input.ServiceID = serviceID c.Input.ServiceVersion = serviceVersion.Number - loggly, err := c.Globals.Client.GetLoggly(&c.Input) + loggly, err := c.Globals.APIClient.GetLoggly(&c.Input) if err != nil { c.Globals.ErrLog.Add(err) return err diff --git a/pkg/commands/logging/loggly/list.go b/pkg/commands/logging/loggly/list.go index d7d0cf93d..a19ff865c 100644 --- a/pkg/commands/logging/loggly/list.go +++ b/pkg/commands/logging/loggly/list.go @@ -64,7 +64,7 @@ func (c *ListCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AllowActiveLocked: true, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -82,7 +82,7 @@ func (c *ListCommand) Exec(in io.Reader, out io.Writer) error { c.Input.ServiceID = serviceID c.Input.ServiceVersion = serviceVersion.Number - logglys, err := c.Globals.Client.ListLoggly(&c.Input) + logglys, err := c.Globals.APIClient.ListLoggly(&c.Input) if err != nil { c.Globals.ErrLog.Add(err) return err diff --git a/pkg/commands/logging/loggly/loggly_test.go b/pkg/commands/logging/loggly/loggly_test.go index 217498c08..da4bbeee7 100644 --- a/pkg/commands/logging/loggly/loggly_test.go +++ b/pkg/commands/logging/loggly/loggly_test.go @@ -59,7 +59,7 @@ func TestCreateLogglyInput(t *testing.T) { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: testcase.cmd.AutoClone, - Client: testcase.cmd.Base.Globals.Client, + APIClient: testcase.cmd.Base.Globals.APIClient, Manifest: testcase.cmd.Manifest, Out: out, ServiceVersionFlag: testcase.cmd.ServiceVersion, @@ -135,7 +135,7 @@ func TestUpdateLogglyInput(t *testing.T) { }, } { t.Run(testcase.name, func(t *testing.T) { - testcase.cmd.Base.Globals.Client = testcase.api + testcase.cmd.Base.Globals.APIClient = testcase.api var bs []byte out := bytes.NewBuffer(bs) @@ -143,7 +143,7 @@ func TestUpdateLogglyInput(t *testing.T) { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: testcase.cmd.AutoClone, - Client: testcase.api, + APIClient: testcase.api, Manifest: testcase.cmd.Manifest, Out: out, ServiceVersionFlag: testcase.cmd.ServiceVersion, @@ -177,7 +177,7 @@ func createCommandOK() *loggly.CreateCommand { Env: config.Environment{}, Output: &b, } - globals.Client, _ = mock.APIClient(mock.API{ + globals.APIClient, _ = mock.APIClient(mock.API{ ListVersionsFn: testutil.ListVersions, CloneVersionFn: testutil.CloneVersionResult(4), })("token", "endpoint") @@ -219,7 +219,7 @@ func createCommandRequired() *loggly.CreateCommand { Env: config.Environment{}, Output: &b, } - globals.Client, _ = mock.APIClient(mock.API{ + globals.APIClient, _ = mock.APIClient(mock.API{ ListVersionsFn: testutil.ListVersions, CloneVersionFn: testutil.CloneVersionResult(4), })("token", "endpoint") diff --git a/pkg/commands/logging/loggly/update.go b/pkg/commands/logging/loggly/update.go index f1ada6f69..cda0e049c 100644 --- a/pkg/commands/logging/loggly/update.go +++ b/pkg/commands/logging/loggly/update.go @@ -108,7 +108,7 @@ func (c *UpdateCommand) ConstructInput(serviceID string, serviceVersion int) (*f func (c *UpdateCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.AutoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.Manifest, Out: out, ServiceNameFlag: c.ServiceName, @@ -129,7 +129,7 @@ func (c *UpdateCommand) Exec(in io.Reader, out io.Writer) error { return err } - loggly, err := c.Globals.Client.UpdateLoggly(input) + loggly, err := c.Globals.APIClient.UpdateLoggly(input) if err != nil { c.Globals.ErrLog.Add(err) return err diff --git a/pkg/commands/logging/logshuttle/create.go b/pkg/commands/logging/logshuttle/create.go index 517f3d4c0..8112df529 100644 --- a/pkg/commands/logging/logshuttle/create.go +++ b/pkg/commands/logging/logshuttle/create.go @@ -102,7 +102,7 @@ func (c *CreateCommand) ConstructInput(serviceID string, serviceVersion int) (*f func (c *CreateCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.AutoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.Manifest, Out: out, ServiceNameFlag: c.ServiceName, @@ -123,7 +123,7 @@ func (c *CreateCommand) Exec(in io.Reader, out io.Writer) error { return err } - d, err := c.Globals.Client.CreateLogshuttle(input) + d, err := c.Globals.APIClient.CreateLogshuttle(input) if err != nil { c.Globals.ErrLog.Add(err) return err diff --git a/pkg/commands/logging/logshuttle/delete.go b/pkg/commands/logging/logshuttle/delete.go index 7117196f8..840d70208 100644 --- a/pkg/commands/logging/logshuttle/delete.go +++ b/pkg/commands/logging/logshuttle/delete.go @@ -57,7 +57,7 @@ func NewDeleteCommand(parent cmd.Registerer, globals *config.Data, data manifest func (c *DeleteCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.autoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -75,7 +75,7 @@ func (c *DeleteCommand) Exec(in io.Reader, out io.Writer) error { c.Input.ServiceID = serviceID c.Input.ServiceVersion = serviceVersion.Number - if err := c.Globals.Client.DeleteLogshuttle(&c.Input); err != nil { + if err := c.Globals.APIClient.DeleteLogshuttle(&c.Input); err != nil { c.Globals.ErrLog.Add(err) return err } diff --git a/pkg/commands/logging/logshuttle/describe.go b/pkg/commands/logging/logshuttle/describe.go index a50d6d5c8..143bc2449 100644 --- a/pkg/commands/logging/logshuttle/describe.go +++ b/pkg/commands/logging/logshuttle/describe.go @@ -64,7 +64,7 @@ func (c *DescribeCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AllowActiveLocked: true, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -82,7 +82,7 @@ func (c *DescribeCommand) Exec(in io.Reader, out io.Writer) error { c.Input.ServiceID = serviceID c.Input.ServiceVersion = serviceVersion.Number - logshuttle, err := c.Globals.Client.GetLogshuttle(&c.Input) + logshuttle, err := c.Globals.APIClient.GetLogshuttle(&c.Input) if err != nil { c.Globals.ErrLog.Add(err) return err diff --git a/pkg/commands/logging/logshuttle/list.go b/pkg/commands/logging/logshuttle/list.go index 3ee5a1e51..791dbcb42 100644 --- a/pkg/commands/logging/logshuttle/list.go +++ b/pkg/commands/logging/logshuttle/list.go @@ -64,7 +64,7 @@ func (c *ListCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AllowActiveLocked: true, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -82,7 +82,7 @@ func (c *ListCommand) Exec(in io.Reader, out io.Writer) error { c.Input.ServiceID = serviceID c.Input.ServiceVersion = serviceVersion.Number - logshuttles, err := c.Globals.Client.ListLogshuttles(&c.Input) + logshuttles, err := c.Globals.APIClient.ListLogshuttles(&c.Input) if err != nil { c.Globals.ErrLog.Add(err) return err diff --git a/pkg/commands/logging/logshuttle/logshuttle_test.go b/pkg/commands/logging/logshuttle/logshuttle_test.go index 7fcf608cb..f4eadda64 100644 --- a/pkg/commands/logging/logshuttle/logshuttle_test.go +++ b/pkg/commands/logging/logshuttle/logshuttle_test.go @@ -61,7 +61,7 @@ func TestCreateLogshuttleInput(t *testing.T) { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: testcase.cmd.AutoClone, - Client: testcase.cmd.Base.Globals.Client, + APIClient: testcase.cmd.Base.Globals.APIClient, Manifest: testcase.cmd.Manifest, Out: out, ServiceVersionFlag: testcase.cmd.ServiceVersion, @@ -138,7 +138,7 @@ func TestUpdateLogshuttleInput(t *testing.T) { }, } { t.Run(testcase.name, func(t *testing.T) { - testcase.cmd.Base.Globals.Client = testcase.api + testcase.cmd.Base.Globals.APIClient = testcase.api var bs []byte out := bytes.NewBuffer(bs) @@ -146,7 +146,7 @@ func TestUpdateLogshuttleInput(t *testing.T) { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: testcase.cmd.AutoClone, - Client: testcase.api, + APIClient: testcase.api, Manifest: testcase.cmd.Manifest, Out: out, ServiceVersionFlag: testcase.cmd.ServiceVersion, @@ -180,7 +180,7 @@ func createCommandRequired() *logshuttle.CreateCommand { Env: config.Environment{}, Output: &b, } - globals.Client, _ = mock.APIClient(mock.API{ + globals.APIClient, _ = mock.APIClient(mock.API{ ListVersionsFn: testutil.ListVersions, CloneVersionFn: testutil.CloneVersionResult(4), })("token", "endpoint") @@ -219,7 +219,7 @@ func createCommandAll() *logshuttle.CreateCommand { Env: config.Environment{}, Output: &b, } - globals.Client, _ = mock.APIClient(mock.API{ + globals.APIClient, _ = mock.APIClient(mock.API{ ListVersionsFn: testutil.ListVersions, CloneVersionFn: testutil.CloneVersionResult(4), })("token", "endpoint") diff --git a/pkg/commands/logging/logshuttle/update.go b/pkg/commands/logging/logshuttle/update.go index 2caeb3fcb..0f4deca2a 100644 --- a/pkg/commands/logging/logshuttle/update.go +++ b/pkg/commands/logging/logshuttle/update.go @@ -115,7 +115,7 @@ func (c *UpdateCommand) ConstructInput(serviceID string, serviceVersion int) (*f func (c *UpdateCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.AutoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.Manifest, Out: out, ServiceNameFlag: c.ServiceName, @@ -136,7 +136,7 @@ func (c *UpdateCommand) Exec(in io.Reader, out io.Writer) error { return err } - logshuttle, err := c.Globals.Client.UpdateLogshuttle(input) + logshuttle, err := c.Globals.APIClient.UpdateLogshuttle(input) if err != nil { c.Globals.ErrLog.Add(err) return err diff --git a/pkg/commands/logging/newrelic/create.go b/pkg/commands/logging/newrelic/create.go index 3620dfc4f..fa75a74ad 100644 --- a/pkg/commands/logging/newrelic/create.go +++ b/pkg/commands/logging/newrelic/create.go @@ -75,7 +75,7 @@ type CreateCommand struct { func (c *CreateCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.autoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -92,7 +92,7 @@ func (c *CreateCommand) Exec(in io.Reader, out io.Writer) error { input := c.constructInput(serviceID, serviceVersion.Number) - l, err := c.Globals.Client.CreateNewRelic(input) + l, err := c.Globals.APIClient.CreateNewRelic(input) if err != nil { c.Globals.ErrLog.AddWithContext(err, map[string]interface{}{ "Service ID": serviceID, diff --git a/pkg/commands/logging/newrelic/delete.go b/pkg/commands/logging/newrelic/delete.go index 3c9a5ff17..e212d3eee 100644 --- a/pkg/commands/logging/newrelic/delete.go +++ b/pkg/commands/logging/newrelic/delete.go @@ -63,7 +63,7 @@ type DeleteCommand struct { func (c *DeleteCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.autoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -80,7 +80,7 @@ func (c *DeleteCommand) Exec(in io.Reader, out io.Writer) error { input := c.constructInput(serviceID, serviceVersion.Number) - err = c.Globals.Client.DeleteNewRelic(input) + err = c.Globals.APIClient.DeleteNewRelic(input) if err != nil { c.Globals.ErrLog.AddWithContext(err, map[string]interface{}{ "Service ID": serviceID, diff --git a/pkg/commands/logging/newrelic/describe.go b/pkg/commands/logging/newrelic/describe.go index c235bf48f..8522b1fb5 100644 --- a/pkg/commands/logging/newrelic/describe.go +++ b/pkg/commands/logging/newrelic/describe.go @@ -70,7 +70,7 @@ func (c *DescribeCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AllowActiveLocked: true, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -87,7 +87,7 @@ func (c *DescribeCommand) Exec(in io.Reader, out io.Writer) error { input := c.constructInput(serviceID, serviceVersion.Number) - a, err := c.Globals.Client.GetNewRelic(input) + a, err := c.Globals.APIClient.GetNewRelic(input) if err != nil { c.Globals.ErrLog.AddWithContext(err, map[string]interface{}{ "Service ID": serviceID, diff --git a/pkg/commands/logging/newrelic/list.go b/pkg/commands/logging/newrelic/list.go index 5f0ecc305..33c98dd3d 100644 --- a/pkg/commands/logging/newrelic/list.go +++ b/pkg/commands/logging/newrelic/list.go @@ -69,7 +69,7 @@ func (c *ListCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AllowActiveLocked: true, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -86,7 +86,7 @@ func (c *ListCommand) Exec(in io.Reader, out io.Writer) error { input := c.constructInput(serviceID, serviceVersion.Number) - l, err := c.Globals.Client.ListNewRelic(input) + l, err := c.Globals.APIClient.ListNewRelic(input) if err != nil { c.Globals.ErrLog.AddWithContext(err, map[string]interface{}{ "Service ID": serviceID, diff --git a/pkg/commands/logging/newrelic/update.go b/pkg/commands/logging/newrelic/update.go index f356bc58c..83fc18b33 100644 --- a/pkg/commands/logging/newrelic/update.go +++ b/pkg/commands/logging/newrelic/update.go @@ -78,7 +78,7 @@ type UpdateCommand struct { func (c *UpdateCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.autoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -95,7 +95,7 @@ func (c *UpdateCommand) Exec(in io.Reader, out io.Writer) error { input := c.constructInput(serviceID, serviceVersion.Number) - l, err := c.Globals.Client.UpdateNewRelic(input) + l, err := c.Globals.APIClient.UpdateNewRelic(input) if err != nil { c.Globals.ErrLog.AddWithContext(err, map[string]interface{}{ "Service ID": serviceID, diff --git a/pkg/commands/logging/openstack/create.go b/pkg/commands/logging/openstack/create.go index b54caa065..c6df26e1c 100644 --- a/pkg/commands/logging/openstack/create.go +++ b/pkg/commands/logging/openstack/create.go @@ -157,7 +157,7 @@ func (c *CreateCommand) ConstructInput(serviceID string, serviceVersion int) (*f func (c *CreateCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.AutoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.Manifest, Out: out, ServiceNameFlag: c.ServiceName, @@ -178,7 +178,7 @@ func (c *CreateCommand) Exec(in io.Reader, out io.Writer) error { return err } - d, err := c.Globals.Client.CreateOpenstack(input) + d, err := c.Globals.APIClient.CreateOpenstack(input) if err != nil { c.Globals.ErrLog.Add(err) return err diff --git a/pkg/commands/logging/openstack/delete.go b/pkg/commands/logging/openstack/delete.go index fa28a9d92..78c6dacdf 100644 --- a/pkg/commands/logging/openstack/delete.go +++ b/pkg/commands/logging/openstack/delete.go @@ -57,7 +57,7 @@ func NewDeleteCommand(parent cmd.Registerer, globals *config.Data, data manifest func (c *DeleteCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.autoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -75,7 +75,7 @@ func (c *DeleteCommand) Exec(in io.Reader, out io.Writer) error { c.Input.ServiceID = serviceID c.Input.ServiceVersion = serviceVersion.Number - if err := c.Globals.Client.DeleteOpenstack(&c.Input); err != nil { + if err := c.Globals.APIClient.DeleteOpenstack(&c.Input); err != nil { c.Globals.ErrLog.Add(err) return err } diff --git a/pkg/commands/logging/openstack/describe.go b/pkg/commands/logging/openstack/describe.go index fed2a262b..573e9ba38 100644 --- a/pkg/commands/logging/openstack/describe.go +++ b/pkg/commands/logging/openstack/describe.go @@ -64,7 +64,7 @@ func (c *DescribeCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AllowActiveLocked: true, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -82,7 +82,7 @@ func (c *DescribeCommand) Exec(in io.Reader, out io.Writer) error { c.Input.ServiceID = serviceID c.Input.ServiceVersion = serviceVersion.Number - openstack, err := c.Globals.Client.GetOpenstack(&c.Input) + openstack, err := c.Globals.APIClient.GetOpenstack(&c.Input) if err != nil { c.Globals.ErrLog.Add(err) return err diff --git a/pkg/commands/logging/openstack/list.go b/pkg/commands/logging/openstack/list.go index 1fbc4300b..3116a892a 100644 --- a/pkg/commands/logging/openstack/list.go +++ b/pkg/commands/logging/openstack/list.go @@ -64,7 +64,7 @@ func (c *ListCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AllowActiveLocked: true, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -82,7 +82,7 @@ func (c *ListCommand) Exec(in io.Reader, out io.Writer) error { c.Input.ServiceID = serviceID c.Input.ServiceVersion = serviceVersion.Number - openstacks, err := c.Globals.Client.ListOpenstack(&c.Input) + openstacks, err := c.Globals.APIClient.ListOpenstack(&c.Input) if err != nil { c.Globals.ErrLog.Add(err) return err diff --git a/pkg/commands/logging/openstack/openstack_test.go b/pkg/commands/logging/openstack/openstack_test.go index a6043e7e0..f84b16c7f 100644 --- a/pkg/commands/logging/openstack/openstack_test.go +++ b/pkg/commands/logging/openstack/openstack_test.go @@ -71,7 +71,7 @@ func TestCreateOpenstackInput(t *testing.T) { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: testcase.cmd.AutoClone, - Client: testcase.cmd.Base.Globals.Client, + APIClient: testcase.cmd.Base.Globals.APIClient, Manifest: testcase.cmd.Manifest, Out: out, ServiceVersionFlag: testcase.cmd.ServiceVersion, @@ -157,7 +157,7 @@ func TestUpdateOpenstackInput(t *testing.T) { }, } { t.Run(testcase.name, func(t *testing.T) { - testcase.cmd.Base.Globals.Client = testcase.api + testcase.cmd.Base.Globals.APIClient = testcase.api var bs []byte out := bytes.NewBuffer(bs) @@ -165,7 +165,7 @@ func TestUpdateOpenstackInput(t *testing.T) { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: testcase.cmd.AutoClone, - Client: testcase.api, + APIClient: testcase.api, Manifest: testcase.cmd.Manifest, Out: out, ServiceVersionFlag: testcase.cmd.ServiceVersion, @@ -199,7 +199,7 @@ func createCommandRequired() *openstack.CreateCommand { Env: config.Environment{}, Output: &b, } - globals.Client, _ = mock.APIClient(mock.API{ + globals.APIClient, _ = mock.APIClient(mock.API{ ListVersionsFn: testutil.ListVersions, CloneVersionFn: testutil.CloneVersionResult(4), })("token", "endpoint") @@ -240,7 +240,7 @@ func createCommandAll() *openstack.CreateCommand { Env: config.Environment{}, Output: &b, } - globals.Client, _ = mock.APIClient(mock.API{ + globals.APIClient, _ = mock.APIClient(mock.API{ ListVersionsFn: testutil.ListVersions, CloneVersionFn: testutil.CloneVersionResult(4), })("token", "endpoint") diff --git a/pkg/commands/logging/openstack/update.go b/pkg/commands/logging/openstack/update.go index fac547f31..9922b32db 100644 --- a/pkg/commands/logging/openstack/update.go +++ b/pkg/commands/logging/openstack/update.go @@ -172,7 +172,7 @@ func (c *UpdateCommand) ConstructInput(serviceID string, serviceVersion int) (*f func (c *UpdateCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.AutoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.Manifest, Out: out, ServiceNameFlag: c.ServiceName, @@ -193,7 +193,7 @@ func (c *UpdateCommand) Exec(in io.Reader, out io.Writer) error { return err } - openstack, err := c.Globals.Client.UpdateOpenstack(input) + openstack, err := c.Globals.APIClient.UpdateOpenstack(input) if err != nil { c.Globals.ErrLog.Add(err) return err diff --git a/pkg/commands/logging/papertrail/create.go b/pkg/commands/logging/papertrail/create.go index 5acc3b269..5c5359204 100644 --- a/pkg/commands/logging/papertrail/create.go +++ b/pkg/commands/logging/papertrail/create.go @@ -105,7 +105,7 @@ func (c *CreateCommand) ConstructInput(serviceID string, serviceVersion int) (*f func (c *CreateCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.AutoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.Manifest, Out: out, ServiceNameFlag: c.ServiceName, @@ -126,7 +126,7 @@ func (c *CreateCommand) Exec(in io.Reader, out io.Writer) error { return err } - d, err := c.Globals.Client.CreatePapertrail(input) + d, err := c.Globals.APIClient.CreatePapertrail(input) if err != nil { c.Globals.ErrLog.Add(err) return err diff --git a/pkg/commands/logging/papertrail/delete.go b/pkg/commands/logging/papertrail/delete.go index c19147ed9..0ab8a626d 100644 --- a/pkg/commands/logging/papertrail/delete.go +++ b/pkg/commands/logging/papertrail/delete.go @@ -57,7 +57,7 @@ func NewDeleteCommand(parent cmd.Registerer, globals *config.Data, data manifest func (c *DeleteCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.autoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -75,7 +75,7 @@ func (c *DeleteCommand) Exec(in io.Reader, out io.Writer) error { c.Input.ServiceID = serviceID c.Input.ServiceVersion = serviceVersion.Number - if err := c.Globals.Client.DeletePapertrail(&c.Input); err != nil { + if err := c.Globals.APIClient.DeletePapertrail(&c.Input); err != nil { c.Globals.ErrLog.Add(err) return err } diff --git a/pkg/commands/logging/papertrail/describe.go b/pkg/commands/logging/papertrail/describe.go index fce9ab4f9..f0a608348 100644 --- a/pkg/commands/logging/papertrail/describe.go +++ b/pkg/commands/logging/papertrail/describe.go @@ -64,7 +64,7 @@ func (c *DescribeCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AllowActiveLocked: true, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -82,7 +82,7 @@ func (c *DescribeCommand) Exec(in io.Reader, out io.Writer) error { c.Input.ServiceID = serviceID c.Input.ServiceVersion = serviceVersion.Number - papertrail, err := c.Globals.Client.GetPapertrail(&c.Input) + papertrail, err := c.Globals.APIClient.GetPapertrail(&c.Input) if err != nil { c.Globals.ErrLog.Add(err) return err diff --git a/pkg/commands/logging/papertrail/list.go b/pkg/commands/logging/papertrail/list.go index 09c19650f..72972dc33 100644 --- a/pkg/commands/logging/papertrail/list.go +++ b/pkg/commands/logging/papertrail/list.go @@ -64,7 +64,7 @@ func (c *ListCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AllowActiveLocked: true, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -82,7 +82,7 @@ func (c *ListCommand) Exec(in io.Reader, out io.Writer) error { c.Input.ServiceID = serviceID c.Input.ServiceVersion = serviceVersion.Number - papertrails, err := c.Globals.Client.ListPapertrails(&c.Input) + papertrails, err := c.Globals.APIClient.ListPapertrails(&c.Input) if err != nil { c.Globals.ErrLog.Add(err) return err diff --git a/pkg/commands/logging/papertrail/papertrail_test.go b/pkg/commands/logging/papertrail/papertrail_test.go index 8ae7cc937..5d47e8333 100644 --- a/pkg/commands/logging/papertrail/papertrail_test.go +++ b/pkg/commands/logging/papertrail/papertrail_test.go @@ -60,7 +60,7 @@ func TestCreatePapertrailInput(t *testing.T) { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: testcase.cmd.AutoClone, - Client: testcase.cmd.Base.Globals.Client, + APIClient: testcase.cmd.Base.Globals.APIClient, Manifest: testcase.cmd.Manifest, Out: out, ServiceVersionFlag: testcase.cmd.ServiceVersion, @@ -137,7 +137,7 @@ func TestUpdatePapertrailInput(t *testing.T) { }, } { t.Run(testcase.name, func(t *testing.T) { - testcase.cmd.Base.Globals.Client = testcase.api + testcase.cmd.Base.Globals.APIClient = testcase.api var bs []byte out := bytes.NewBuffer(bs) @@ -145,7 +145,7 @@ func TestUpdatePapertrailInput(t *testing.T) { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: testcase.cmd.AutoClone, - Client: testcase.api, + APIClient: testcase.api, Manifest: testcase.cmd.Manifest, Out: out, ServiceVersionFlag: testcase.cmd.ServiceVersion, @@ -179,7 +179,7 @@ func createCommandRequired() *papertrail.CreateCommand { Env: config.Environment{}, Output: &b, } - globals.Client, _ = mock.APIClient(mock.API{ + globals.APIClient, _ = mock.APIClient(mock.API{ ListVersionsFn: testutil.ListVersions, CloneVersionFn: testutil.CloneVersionResult(4), })("token", "endpoint") @@ -217,7 +217,7 @@ func createCommandAll() *papertrail.CreateCommand { Env: config.Environment{}, Output: &b, } - globals.Client, _ = mock.APIClient(mock.API{ + globals.APIClient, _ = mock.APIClient(mock.API{ ListVersionsFn: testutil.ListVersions, CloneVersionFn: testutil.CloneVersionResult(4), })("token", "endpoint") diff --git a/pkg/commands/logging/papertrail/update.go b/pkg/commands/logging/papertrail/update.go index 1382bae67..7291d70f1 100644 --- a/pkg/commands/logging/papertrail/update.go +++ b/pkg/commands/logging/papertrail/update.go @@ -119,7 +119,7 @@ func (c *UpdateCommand) ConstructInput(serviceID string, serviceVersion int) (*f func (c *UpdateCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.AutoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.Manifest, Out: out, ServiceNameFlag: c.ServiceName, @@ -140,7 +140,7 @@ func (c *UpdateCommand) Exec(in io.Reader, out io.Writer) error { return err } - papertrail, err := c.Globals.Client.UpdatePapertrail(input) + papertrail, err := c.Globals.APIClient.UpdatePapertrail(input) if err != nil { c.Globals.ErrLog.Add(err) return err diff --git a/pkg/commands/logging/s3/create.go b/pkg/commands/logging/s3/create.go index 90c17a079..c7a907b11 100644 --- a/pkg/commands/logging/s3/create.go +++ b/pkg/commands/logging/s3/create.go @@ -222,7 +222,7 @@ func (c *CreateCommand) ConstructInput(serviceID string, serviceVersion int) (*f func (c *CreateCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.AutoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.Manifest, Out: out, ServiceNameFlag: c.ServiceName, @@ -243,7 +243,7 @@ func (c *CreateCommand) Exec(in io.Reader, out io.Writer) error { return err } - d, err := c.Globals.Client.CreateS3(input) + d, err := c.Globals.APIClient.CreateS3(input) if err != nil { c.Globals.ErrLog.Add(err) return err diff --git a/pkg/commands/logging/s3/delete.go b/pkg/commands/logging/s3/delete.go index 9624661fb..6c8378290 100644 --- a/pkg/commands/logging/s3/delete.go +++ b/pkg/commands/logging/s3/delete.go @@ -57,7 +57,7 @@ func NewDeleteCommand(parent cmd.Registerer, globals *config.Data, data manifest func (c *DeleteCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.autoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -75,7 +75,7 @@ func (c *DeleteCommand) Exec(in io.Reader, out io.Writer) error { c.Input.ServiceID = serviceID c.Input.ServiceVersion = serviceVersion.Number - if err := c.Globals.Client.DeleteS3(&c.Input); err != nil { + if err := c.Globals.APIClient.DeleteS3(&c.Input); err != nil { c.Globals.ErrLog.Add(err) return err } diff --git a/pkg/commands/logging/s3/describe.go b/pkg/commands/logging/s3/describe.go index e1e978e70..5861e6ab4 100644 --- a/pkg/commands/logging/s3/describe.go +++ b/pkg/commands/logging/s3/describe.go @@ -64,7 +64,7 @@ func (c *DescribeCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AllowActiveLocked: true, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -82,7 +82,7 @@ func (c *DescribeCommand) Exec(in io.Reader, out io.Writer) error { c.Input.ServiceID = serviceID c.Input.ServiceVersion = serviceVersion.Number - s3, err := c.Globals.Client.GetS3(&c.Input) + s3, err := c.Globals.APIClient.GetS3(&c.Input) if err != nil { c.Globals.ErrLog.Add(err) return err diff --git a/pkg/commands/logging/s3/list.go b/pkg/commands/logging/s3/list.go index e3afbd1e3..315ae54b4 100644 --- a/pkg/commands/logging/s3/list.go +++ b/pkg/commands/logging/s3/list.go @@ -64,7 +64,7 @@ func (c *ListCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AllowActiveLocked: true, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -82,7 +82,7 @@ func (c *ListCommand) Exec(in io.Reader, out io.Writer) error { c.Input.ServiceID = serviceID c.Input.ServiceVersion = serviceVersion.Number - s3s, err := c.Globals.Client.ListS3s(&c.Input) + s3s, err := c.Globals.APIClient.ListS3s(&c.Input) if err != nil { c.Globals.ErrLog.Add(err) return err diff --git a/pkg/commands/logging/s3/s3_test.go b/pkg/commands/logging/s3/s3_test.go index 78fd96d4e..34d27f693 100644 --- a/pkg/commands/logging/s3/s3_test.go +++ b/pkg/commands/logging/s3/s3_test.go @@ -84,7 +84,7 @@ func TestCreateS3Input(t *testing.T) { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: testcase.cmd.AutoClone, - Client: testcase.cmd.Base.Globals.Client, + APIClient: testcase.cmd.Base.Globals.APIClient, Manifest: testcase.cmd.Manifest, Out: out, ServiceVersionFlag: testcase.cmd.ServiceVersion, @@ -174,7 +174,7 @@ func TestUpdateS3Input(t *testing.T) { }, } { t.Run(testcase.name, func(t *testing.T) { - testcase.cmd.Base.Globals.Client = testcase.api + testcase.cmd.Base.Globals.APIClient = testcase.api var bs []byte out := bytes.NewBuffer(bs) @@ -182,7 +182,7 @@ func TestUpdateS3Input(t *testing.T) { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: testcase.cmd.AutoClone, - Client: testcase.api, + APIClient: testcase.api, Manifest: testcase.cmd.Manifest, Out: out, ServiceVersionFlag: testcase.cmd.ServiceVersion, @@ -216,7 +216,7 @@ func createCommandRequired() *s3.CreateCommand { Env: config.Environment{}, Output: &b, } - globals.Client, _ = mock.APIClient(mock.API{ + globals.APIClient, _ = mock.APIClient(mock.API{ ListVersionsFn: testutil.ListVersions, CloneVersionFn: testutil.CloneVersionResult(4), })("token", "endpoint") @@ -256,7 +256,7 @@ func createCommandRequiredIAMRole() *s3.CreateCommand { Env: config.Environment{}, Output: &b, } - globals.Client, _ = mock.APIClient(mock.API{ + globals.APIClient, _ = mock.APIClient(mock.API{ ListVersionsFn: testutil.ListVersions, CloneVersionFn: testutil.CloneVersionResult(4), })("token", "endpoint") @@ -295,7 +295,7 @@ func createCommandAll() *s3.CreateCommand { Env: config.Environment{}, Output: &b, } - globals.Client, _ = mock.APIClient(mock.API{ + globals.APIClient, _ = mock.APIClient(mock.API{ ListVersionsFn: testutil.ListVersions, CloneVersionFn: testutil.CloneVersionResult(4), })("token", "endpoint") diff --git a/pkg/commands/logging/s3/update.go b/pkg/commands/logging/s3/update.go index 309aaf757..9b9fafa00 100644 --- a/pkg/commands/logging/s3/update.go +++ b/pkg/commands/logging/s3/update.go @@ -203,7 +203,7 @@ func (c *UpdateCommand) ConstructInput(serviceID string, serviceVersion int) (*f func (c *UpdateCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.AutoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.Manifest, Out: out, ServiceNameFlag: c.ServiceName, @@ -224,7 +224,7 @@ func (c *UpdateCommand) Exec(in io.Reader, out io.Writer) error { return err } - s3, err := c.Globals.Client.UpdateS3(input) + s3, err := c.Globals.APIClient.UpdateS3(input) if err != nil { c.Globals.ErrLog.Add(err) return err diff --git a/pkg/commands/logging/scalyr/create.go b/pkg/commands/logging/scalyr/create.go index c4fd74f33..252865a29 100644 --- a/pkg/commands/logging/scalyr/create.go +++ b/pkg/commands/logging/scalyr/create.go @@ -105,7 +105,7 @@ func (c *CreateCommand) ConstructInput(serviceID string, serviceVersion int) (*f func (c *CreateCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.AutoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.Manifest, Out: out, ServiceNameFlag: c.ServiceName, @@ -126,7 +126,7 @@ func (c *CreateCommand) Exec(in io.Reader, out io.Writer) error { return err } - d, err := c.Globals.Client.CreateScalyr(input) + d, err := c.Globals.APIClient.CreateScalyr(input) if err != nil { c.Globals.ErrLog.Add(err) return err diff --git a/pkg/commands/logging/scalyr/delete.go b/pkg/commands/logging/scalyr/delete.go index fb7ff104b..1cd5e409a 100644 --- a/pkg/commands/logging/scalyr/delete.go +++ b/pkg/commands/logging/scalyr/delete.go @@ -57,7 +57,7 @@ func NewDeleteCommand(parent cmd.Registerer, globals *config.Data, data manifest func (c *DeleteCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.autoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -75,7 +75,7 @@ func (c *DeleteCommand) Exec(in io.Reader, out io.Writer) error { c.Input.ServiceID = serviceID c.Input.ServiceVersion = serviceVersion.Number - if err := c.Globals.Client.DeleteScalyr(&c.Input); err != nil { + if err := c.Globals.APIClient.DeleteScalyr(&c.Input); err != nil { c.Globals.ErrLog.Add(err) return err } diff --git a/pkg/commands/logging/scalyr/describe.go b/pkg/commands/logging/scalyr/describe.go index 351b03c86..dfa5ad6f2 100644 --- a/pkg/commands/logging/scalyr/describe.go +++ b/pkg/commands/logging/scalyr/describe.go @@ -64,7 +64,7 @@ func (c *DescribeCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AllowActiveLocked: true, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -82,7 +82,7 @@ func (c *DescribeCommand) Exec(in io.Reader, out io.Writer) error { c.Input.ServiceID = serviceID c.Input.ServiceVersion = serviceVersion.Number - scalyr, err := c.Globals.Client.GetScalyr(&c.Input) + scalyr, err := c.Globals.APIClient.GetScalyr(&c.Input) if err != nil { c.Globals.ErrLog.Add(err) return err diff --git a/pkg/commands/logging/scalyr/list.go b/pkg/commands/logging/scalyr/list.go index c927a80c5..de7a4ca66 100644 --- a/pkg/commands/logging/scalyr/list.go +++ b/pkg/commands/logging/scalyr/list.go @@ -64,7 +64,7 @@ func (c *ListCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AllowActiveLocked: true, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -82,7 +82,7 @@ func (c *ListCommand) Exec(in io.Reader, out io.Writer) error { c.Input.ServiceID = serviceID c.Input.ServiceVersion = serviceVersion.Number - scalyrs, err := c.Globals.Client.ListScalyrs(&c.Input) + scalyrs, err := c.Globals.APIClient.ListScalyrs(&c.Input) if err != nil { c.Globals.ErrLog.Add(err) return err diff --git a/pkg/commands/logging/scalyr/scalyr_test.go b/pkg/commands/logging/scalyr/scalyr_test.go index 980d84564..b677fb730 100644 --- a/pkg/commands/logging/scalyr/scalyr_test.go +++ b/pkg/commands/logging/scalyr/scalyr_test.go @@ -60,7 +60,7 @@ func TestCreateScalyrInput(t *testing.T) { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: testcase.cmd.AutoClone, - Client: testcase.cmd.Base.Globals.Client, + APIClient: testcase.cmd.Base.Globals.APIClient, Manifest: testcase.cmd.Manifest, Out: out, ServiceVersionFlag: testcase.cmd.ServiceVersion, @@ -137,7 +137,7 @@ func TestUpdateScalyrInput(t *testing.T) { }, } { t.Run(testcase.name, func(t *testing.T) { - testcase.cmd.Base.Globals.Client = testcase.api + testcase.cmd.Base.Globals.APIClient = testcase.api var bs []byte out := bytes.NewBuffer(bs) @@ -145,7 +145,7 @@ func TestUpdateScalyrInput(t *testing.T) { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: testcase.cmd.AutoClone, - Client: testcase.api, + APIClient: testcase.api, Manifest: testcase.cmd.Manifest, Out: out, ServiceVersionFlag: testcase.cmd.ServiceVersion, @@ -179,7 +179,7 @@ func createCommandRequired() *scalyr.CreateCommand { Env: config.Environment{}, Output: &b, } - globals.Client, _ = mock.APIClient(mock.API{ + globals.APIClient, _ = mock.APIClient(mock.API{ ListVersionsFn: testutil.ListVersions, CloneVersionFn: testutil.CloneVersionResult(4), })("token", "endpoint") @@ -217,7 +217,7 @@ func createCommandAll() *scalyr.CreateCommand { Env: config.Environment{}, Output: &b, } - globals.Client, _ = mock.APIClient(mock.API{ + globals.APIClient, _ = mock.APIClient(mock.API{ ListVersionsFn: testutil.ListVersions, CloneVersionFn: testutil.CloneVersionResult(4), })("token", "endpoint") diff --git a/pkg/commands/logging/scalyr/update.go b/pkg/commands/logging/scalyr/update.go index 8aed3216c..7dcb12325 100644 --- a/pkg/commands/logging/scalyr/update.go +++ b/pkg/commands/logging/scalyr/update.go @@ -114,7 +114,7 @@ func (c *UpdateCommand) ConstructInput(serviceID string, serviceVersion int) (*f func (c *UpdateCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.AutoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.Manifest, Out: out, ServiceNameFlag: c.ServiceName, @@ -135,7 +135,7 @@ func (c *UpdateCommand) Exec(in io.Reader, out io.Writer) error { return err } - scalyr, err := c.Globals.Client.UpdateScalyr(input) + scalyr, err := c.Globals.APIClient.UpdateScalyr(input) if err != nil { c.Globals.ErrLog.Add(err) return err diff --git a/pkg/commands/logging/sftp/create.go b/pkg/commands/logging/sftp/create.go index c056c8eb1..4d3dfd87b 100644 --- a/pkg/commands/logging/sftp/create.go +++ b/pkg/commands/logging/sftp/create.go @@ -172,7 +172,7 @@ func (c *CreateCommand) ConstructInput(serviceID string, serviceVersion int) (*f func (c *CreateCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.AutoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.Manifest, Out: out, ServiceNameFlag: c.ServiceName, @@ -193,7 +193,7 @@ func (c *CreateCommand) Exec(in io.Reader, out io.Writer) error { return err } - d, err := c.Globals.Client.CreateSFTP(input) + d, err := c.Globals.APIClient.CreateSFTP(input) if err != nil { c.Globals.ErrLog.Add(err) return err diff --git a/pkg/commands/logging/sftp/delete.go b/pkg/commands/logging/sftp/delete.go index d5653e054..5f46bfccc 100644 --- a/pkg/commands/logging/sftp/delete.go +++ b/pkg/commands/logging/sftp/delete.go @@ -57,7 +57,7 @@ func NewDeleteCommand(parent cmd.Registerer, globals *config.Data, data manifest func (c *DeleteCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.autoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -75,7 +75,7 @@ func (c *DeleteCommand) Exec(in io.Reader, out io.Writer) error { c.Input.ServiceID = serviceID c.Input.ServiceVersion = serviceVersion.Number - if err := c.Globals.Client.DeleteSFTP(&c.Input); err != nil { + if err := c.Globals.APIClient.DeleteSFTP(&c.Input); err != nil { c.Globals.ErrLog.Add(err) return err } diff --git a/pkg/commands/logging/sftp/describe.go b/pkg/commands/logging/sftp/describe.go index 88e4f45cc..2caa7e1cf 100644 --- a/pkg/commands/logging/sftp/describe.go +++ b/pkg/commands/logging/sftp/describe.go @@ -64,7 +64,7 @@ func (c *DescribeCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AllowActiveLocked: true, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -82,7 +82,7 @@ func (c *DescribeCommand) Exec(in io.Reader, out io.Writer) error { c.Input.ServiceID = serviceID c.Input.ServiceVersion = serviceVersion.Number - sftp, err := c.Globals.Client.GetSFTP(&c.Input) + sftp, err := c.Globals.APIClient.GetSFTP(&c.Input) if err != nil { c.Globals.ErrLog.Add(err) return err diff --git a/pkg/commands/logging/sftp/list.go b/pkg/commands/logging/sftp/list.go index f4a28efde..e1b9993ba 100644 --- a/pkg/commands/logging/sftp/list.go +++ b/pkg/commands/logging/sftp/list.go @@ -64,7 +64,7 @@ func (c *ListCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AllowActiveLocked: true, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -82,7 +82,7 @@ func (c *ListCommand) Exec(in io.Reader, out io.Writer) error { c.Input.ServiceID = serviceID c.Input.ServiceVersion = serviceVersion.Number - sftps, err := c.Globals.Client.ListSFTPs(&c.Input) + sftps, err := c.Globals.APIClient.ListSFTPs(&c.Input) if err != nil { c.Globals.ErrLog.Add(err) return err diff --git a/pkg/commands/logging/sftp/sftp_test.go b/pkg/commands/logging/sftp/sftp_test.go index d1fcf8c28..0c0adbcb7 100644 --- a/pkg/commands/logging/sftp/sftp_test.go +++ b/pkg/commands/logging/sftp/sftp_test.go @@ -72,7 +72,7 @@ func TestCreateSFTPInput(t *testing.T) { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: testcase.cmd.AutoClone, - Client: testcase.cmd.Base.Globals.Client, + APIClient: testcase.cmd.Base.Globals.APIClient, Manifest: testcase.cmd.Manifest, Out: out, ServiceVersionFlag: testcase.cmd.ServiceVersion, @@ -160,7 +160,7 @@ func TestUpdateSFTPInput(t *testing.T) { }, } { t.Run(testcase.name, func(t *testing.T) { - testcase.cmd.Base.Globals.Client = testcase.api + testcase.cmd.Base.Globals.APIClient = testcase.api var bs []byte out := bytes.NewBuffer(bs) @@ -168,7 +168,7 @@ func TestUpdateSFTPInput(t *testing.T) { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: testcase.cmd.AutoClone, - Client: testcase.api, + APIClient: testcase.api, Manifest: testcase.cmd.Manifest, Out: out, ServiceVersionFlag: testcase.cmd.ServiceVersion, @@ -202,7 +202,7 @@ func createCommandRequired() *sftp.CreateCommand { Env: config.Environment{}, Output: &b, } - globals.Client, _ = mock.APIClient(mock.API{ + globals.APIClient, _ = mock.APIClient(mock.API{ ListVersionsFn: testutil.ListVersions, CloneVersionFn: testutil.CloneVersionResult(4), })("token", "endpoint") @@ -242,7 +242,7 @@ func createCommandAll() *sftp.CreateCommand { Env: config.Environment{}, Output: &b, } - globals.Client, _ = mock.APIClient(mock.API{ + globals.APIClient, _ = mock.APIClient(mock.API{ ListVersionsFn: testutil.ListVersions, CloneVersionFn: testutil.CloneVersionResult(4), })("token", "endpoint") diff --git a/pkg/commands/logging/sftp/update.go b/pkg/commands/logging/sftp/update.go index b5cc0fafa..3423d6d8b 100644 --- a/pkg/commands/logging/sftp/update.go +++ b/pkg/commands/logging/sftp/update.go @@ -180,7 +180,7 @@ func (c *UpdateCommand) ConstructInput(serviceID string, serviceVersion int) (*f func (c *UpdateCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.AutoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.Manifest, Out: out, ServiceNameFlag: c.ServiceName, @@ -201,7 +201,7 @@ func (c *UpdateCommand) Exec(in io.Reader, out io.Writer) error { return err } - sftp, err := c.Globals.Client.UpdateSFTP(input) + sftp, err := c.Globals.APIClient.UpdateSFTP(input) if err != nil { c.Globals.ErrLog.Add(err) return err diff --git a/pkg/commands/logging/splunk/create.go b/pkg/commands/logging/splunk/create.go index 3c2a79bfe..c32d06725 100644 --- a/pkg/commands/logging/splunk/create.go +++ b/pkg/commands/logging/splunk/create.go @@ -130,7 +130,7 @@ func (c *CreateCommand) ConstructInput(serviceID string, serviceVersion int) (*f func (c *CreateCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.AutoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.Manifest, Out: out, ServiceNameFlag: c.ServiceName, @@ -151,7 +151,7 @@ func (c *CreateCommand) Exec(in io.Reader, out io.Writer) error { return err } - d, err := c.Globals.Client.CreateSplunk(input) + d, err := c.Globals.APIClient.CreateSplunk(input) if err != nil { c.Globals.ErrLog.Add(err) return err diff --git a/pkg/commands/logging/splunk/delete.go b/pkg/commands/logging/splunk/delete.go index f56a45c98..90708f167 100644 --- a/pkg/commands/logging/splunk/delete.go +++ b/pkg/commands/logging/splunk/delete.go @@ -57,7 +57,7 @@ func NewDeleteCommand(parent cmd.Registerer, globals *config.Data, data manifest func (c *DeleteCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.autoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -75,7 +75,7 @@ func (c *DeleteCommand) Exec(in io.Reader, out io.Writer) error { c.Input.ServiceID = serviceID c.Input.ServiceVersion = serviceVersion.Number - if err := c.Globals.Client.DeleteSplunk(&c.Input); err != nil { + if err := c.Globals.APIClient.DeleteSplunk(&c.Input); err != nil { c.Globals.ErrLog.Add(err) return err } diff --git a/pkg/commands/logging/splunk/describe.go b/pkg/commands/logging/splunk/describe.go index 76b6aee70..f5aa59682 100644 --- a/pkg/commands/logging/splunk/describe.go +++ b/pkg/commands/logging/splunk/describe.go @@ -64,7 +64,7 @@ func (c *DescribeCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AllowActiveLocked: true, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -82,7 +82,7 @@ func (c *DescribeCommand) Exec(in io.Reader, out io.Writer) error { c.Input.ServiceID = serviceID c.Input.ServiceVersion = serviceVersion.Number - splunk, err := c.Globals.Client.GetSplunk(&c.Input) + splunk, err := c.Globals.APIClient.GetSplunk(&c.Input) if err != nil { c.Globals.ErrLog.Add(err) return err diff --git a/pkg/commands/logging/splunk/list.go b/pkg/commands/logging/splunk/list.go index d6dae518e..33dcf758a 100644 --- a/pkg/commands/logging/splunk/list.go +++ b/pkg/commands/logging/splunk/list.go @@ -64,7 +64,7 @@ func (c *ListCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AllowActiveLocked: true, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -82,7 +82,7 @@ func (c *ListCommand) Exec(in io.Reader, out io.Writer) error { c.Input.ServiceID = serviceID c.Input.ServiceVersion = serviceVersion.Number - splunks, err := c.Globals.Client.ListSplunks(&c.Input) + splunks, err := c.Globals.APIClient.ListSplunks(&c.Input) if err != nil { c.Globals.ErrLog.Add(err) return err diff --git a/pkg/commands/logging/splunk/splunk_test.go b/pkg/commands/logging/splunk/splunk_test.go index b4a3426e4..e870904fb 100644 --- a/pkg/commands/logging/splunk/splunk_test.go +++ b/pkg/commands/logging/splunk/splunk_test.go @@ -64,7 +64,7 @@ func TestCreateSplunkInput(t *testing.T) { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: testcase.cmd.AutoClone, - Client: testcase.cmd.Base.Globals.Client, + APIClient: testcase.cmd.Base.Globals.APIClient, Manifest: testcase.cmd.Manifest, Out: out, ServiceVersionFlag: testcase.cmd.ServiceVersion, @@ -145,7 +145,7 @@ func TestUpdateSplunkInput(t *testing.T) { }, } { t.Run(testcase.name, func(t *testing.T) { - testcase.cmd.Base.Globals.Client = testcase.api + testcase.cmd.Base.Globals.APIClient = testcase.api var bs []byte out := bytes.NewBuffer(bs) @@ -153,7 +153,7 @@ func TestUpdateSplunkInput(t *testing.T) { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: testcase.cmd.AutoClone, - Client: testcase.api, + APIClient: testcase.api, Manifest: testcase.cmd.Manifest, Out: out, ServiceVersionFlag: testcase.cmd.ServiceVersion, @@ -187,7 +187,7 @@ func createCommandRequired() *splunk.CreateCommand { Env: config.Environment{}, Output: &b, } - globals.Client, _ = mock.APIClient(mock.API{ + globals.APIClient, _ = mock.APIClient(mock.API{ ListVersionsFn: testutil.ListVersions, CloneVersionFn: testutil.CloneVersionResult(4), })("token", "endpoint") @@ -225,7 +225,7 @@ func createCommandAll() *splunk.CreateCommand { Env: config.Environment{}, Output: &b, } - globals.Client, _ = mock.APIClient(mock.API{ + globals.APIClient, _ = mock.APIClient(mock.API{ ListVersionsFn: testutil.ListVersions, CloneVersionFn: testutil.CloneVersionResult(4), })("token", "endpoint") diff --git a/pkg/commands/logging/splunk/update.go b/pkg/commands/logging/splunk/update.go index 4856fa7f8..6a3c3aa9e 100644 --- a/pkg/commands/logging/splunk/update.go +++ b/pkg/commands/logging/splunk/update.go @@ -139,7 +139,7 @@ func (c *UpdateCommand) ConstructInput(serviceID string, serviceVersion int) (*f func (c *UpdateCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.AutoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.Manifest, Out: out, ServiceNameFlag: c.ServiceName, @@ -160,7 +160,7 @@ func (c *UpdateCommand) Exec(in io.Reader, out io.Writer) error { return err } - splunk, err := c.Globals.Client.UpdateSplunk(input) + splunk, err := c.Globals.APIClient.UpdateSplunk(input) if err != nil { c.Globals.ErrLog.Add(err) return err diff --git a/pkg/commands/logging/sumologic/create.go b/pkg/commands/logging/sumologic/create.go index 85925cee0..5a27cc513 100644 --- a/pkg/commands/logging/sumologic/create.go +++ b/pkg/commands/logging/sumologic/create.go @@ -105,7 +105,7 @@ func (c *CreateCommand) ConstructInput(serviceID string, serviceVersion int) (*f func (c *CreateCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.AutoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.Manifest, Out: out, ServiceNameFlag: c.ServiceName, @@ -126,7 +126,7 @@ func (c *CreateCommand) Exec(in io.Reader, out io.Writer) error { return err } - d, err := c.Globals.Client.CreateSumologic(input) + d, err := c.Globals.APIClient.CreateSumologic(input) if err != nil { c.Globals.ErrLog.Add(err) return err diff --git a/pkg/commands/logging/sumologic/delete.go b/pkg/commands/logging/sumologic/delete.go index 016528364..459e5bd13 100644 --- a/pkg/commands/logging/sumologic/delete.go +++ b/pkg/commands/logging/sumologic/delete.go @@ -57,7 +57,7 @@ func NewDeleteCommand(parent cmd.Registerer, globals *config.Data, data manifest func (c *DeleteCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.autoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -75,7 +75,7 @@ func (c *DeleteCommand) Exec(in io.Reader, out io.Writer) error { c.Input.ServiceID = serviceID c.Input.ServiceVersion = serviceVersion.Number - if err := c.Globals.Client.DeleteSumologic(&c.Input); err != nil { + if err := c.Globals.APIClient.DeleteSumologic(&c.Input); err != nil { c.Globals.ErrLog.Add(err) return err } diff --git a/pkg/commands/logging/sumologic/describe.go b/pkg/commands/logging/sumologic/describe.go index 077db788e..f098acbf3 100644 --- a/pkg/commands/logging/sumologic/describe.go +++ b/pkg/commands/logging/sumologic/describe.go @@ -64,7 +64,7 @@ func (c *DescribeCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AllowActiveLocked: true, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -82,7 +82,7 @@ func (c *DescribeCommand) Exec(in io.Reader, out io.Writer) error { c.Input.ServiceID = serviceID c.Input.ServiceVersion = serviceVersion.Number - sumologic, err := c.Globals.Client.GetSumologic(&c.Input) + sumologic, err := c.Globals.APIClient.GetSumologic(&c.Input) if err != nil { c.Globals.ErrLog.Add(err) return err diff --git a/pkg/commands/logging/sumologic/list.go b/pkg/commands/logging/sumologic/list.go index e9091a110..7e7151665 100644 --- a/pkg/commands/logging/sumologic/list.go +++ b/pkg/commands/logging/sumologic/list.go @@ -64,7 +64,7 @@ func (c *ListCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AllowActiveLocked: true, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -82,7 +82,7 @@ func (c *ListCommand) Exec(in io.Reader, out io.Writer) error { c.Input.ServiceID = serviceID c.Input.ServiceVersion = serviceVersion.Number - sumologics, err := c.Globals.Client.ListSumologics(&c.Input) + sumologics, err := c.Globals.APIClient.ListSumologics(&c.Input) if err != nil { c.Globals.ErrLog.Add(err) return err diff --git a/pkg/commands/logging/sumologic/sumologic_test.go b/pkg/commands/logging/sumologic/sumologic_test.go index a4a39f216..332f2fa24 100644 --- a/pkg/commands/logging/sumologic/sumologic_test.go +++ b/pkg/commands/logging/sumologic/sumologic_test.go @@ -60,7 +60,7 @@ func TestCreateSumologicInput(t *testing.T) { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: testcase.cmd.AutoClone, - Client: testcase.cmd.Base.Globals.Client, + APIClient: testcase.cmd.Base.Globals.APIClient, Manifest: testcase.cmd.Manifest, Out: out, ServiceVersionFlag: testcase.cmd.ServiceVersion, @@ -137,7 +137,7 @@ func TestUpdateSumologicInput(t *testing.T) { }, } { t.Run(testcase.name, func(t *testing.T) { - testcase.cmd.Base.Globals.Client = testcase.api + testcase.cmd.Base.Globals.APIClient = testcase.api var bs []byte out := bytes.NewBuffer(bs) @@ -145,7 +145,7 @@ func TestUpdateSumologicInput(t *testing.T) { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: testcase.cmd.AutoClone, - Client: testcase.api, + APIClient: testcase.api, Manifest: testcase.cmd.Manifest, Out: out, ServiceVersionFlag: testcase.cmd.ServiceVersion, @@ -179,7 +179,7 @@ func createCommandOK() *sumologic.CreateCommand { Env: config.Environment{}, Output: &b, } - globals.Client, _ = mock.APIClient(mock.API{ + globals.APIClient, _ = mock.APIClient(mock.API{ ListVersionsFn: testutil.ListVersions, CloneVersionFn: testutil.CloneVersionResult(4), })("token", "endpoint") @@ -222,7 +222,7 @@ func createCommandRequired() *sumologic.CreateCommand { Env: config.Environment{}, Output: &b, } - globals.Client, _ = mock.APIClient(mock.API{ + globals.APIClient, _ = mock.APIClient(mock.API{ ListVersionsFn: testutil.ListVersions, CloneVersionFn: testutil.CloneVersionResult(4), })("token", "endpoint") diff --git a/pkg/commands/logging/sumologic/update.go b/pkg/commands/logging/sumologic/update.go index 94ac4edb2..94ff26a63 100644 --- a/pkg/commands/logging/sumologic/update.go +++ b/pkg/commands/logging/sumologic/update.go @@ -115,7 +115,7 @@ func (c *UpdateCommand) ConstructInput(serviceID string, serviceVersion int) (*f func (c *UpdateCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.AutoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.Manifest, Out: out, ServiceNameFlag: c.ServiceName, @@ -135,7 +135,7 @@ func (c *UpdateCommand) Exec(in io.Reader, out io.Writer) error { c.Globals.ErrLog.Add(err) return err } - sumologic, err := c.Globals.Client.UpdateSumologic(input) + sumologic, err := c.Globals.APIClient.UpdateSumologic(input) if err != nil { c.Globals.ErrLog.Add(err) return err diff --git a/pkg/commands/logging/syslog/create.go b/pkg/commands/logging/syslog/create.go index 094bc6d23..53944c94a 100644 --- a/pkg/commands/logging/syslog/create.go +++ b/pkg/commands/logging/syslog/create.go @@ -147,7 +147,7 @@ func (c *CreateCommand) ConstructInput(serviceID string, serviceVersion int) (*f func (c *CreateCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.AutoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.Manifest, Out: out, ServiceNameFlag: c.ServiceName, @@ -168,7 +168,7 @@ func (c *CreateCommand) Exec(in io.Reader, out io.Writer) error { return err } - d, err := c.Globals.Client.CreateSyslog(input) + d, err := c.Globals.APIClient.CreateSyslog(input) if err != nil { c.Globals.ErrLog.Add(err) return err diff --git a/pkg/commands/logging/syslog/delete.go b/pkg/commands/logging/syslog/delete.go index 02099d8ea..2e0606057 100644 --- a/pkg/commands/logging/syslog/delete.go +++ b/pkg/commands/logging/syslog/delete.go @@ -57,7 +57,7 @@ func NewDeleteCommand(parent cmd.Registerer, globals *config.Data, data manifest func (c *DeleteCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.autoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -75,7 +75,7 @@ func (c *DeleteCommand) Exec(in io.Reader, out io.Writer) error { c.Input.ServiceID = serviceID c.Input.ServiceVersion = serviceVersion.Number - if err := c.Globals.Client.DeleteSyslog(&c.Input); err != nil { + if err := c.Globals.APIClient.DeleteSyslog(&c.Input); err != nil { c.Globals.ErrLog.Add(err) return err } diff --git a/pkg/commands/logging/syslog/describe.go b/pkg/commands/logging/syslog/describe.go index a78fa27d1..987a6a09e 100644 --- a/pkg/commands/logging/syslog/describe.go +++ b/pkg/commands/logging/syslog/describe.go @@ -64,7 +64,7 @@ func (c *DescribeCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AllowActiveLocked: true, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -82,7 +82,7 @@ func (c *DescribeCommand) Exec(in io.Reader, out io.Writer) error { c.Input.ServiceID = serviceID c.Input.ServiceVersion = serviceVersion.Number - syslog, err := c.Globals.Client.GetSyslog(&c.Input) + syslog, err := c.Globals.APIClient.GetSyslog(&c.Input) if err != nil { c.Globals.ErrLog.Add(err) return err diff --git a/pkg/commands/logging/syslog/list.go b/pkg/commands/logging/syslog/list.go index a2f608ee4..44c3b07f0 100644 --- a/pkg/commands/logging/syslog/list.go +++ b/pkg/commands/logging/syslog/list.go @@ -64,7 +64,7 @@ func (c *ListCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AllowActiveLocked: true, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -82,7 +82,7 @@ func (c *ListCommand) Exec(in io.Reader, out io.Writer) error { c.Input.ServiceID = serviceID c.Input.ServiceVersion = serviceVersion.Number - syslogs, err := c.Globals.Client.ListSyslogs(&c.Input) + syslogs, err := c.Globals.APIClient.ListSyslogs(&c.Input) if err != nil { c.Globals.ErrLog.Add(err) return err diff --git a/pkg/commands/logging/syslog/syslog_test.go b/pkg/commands/logging/syslog/syslog_test.go index 159f76f70..d0034093e 100644 --- a/pkg/commands/logging/syslog/syslog_test.go +++ b/pkg/commands/logging/syslog/syslog_test.go @@ -67,7 +67,7 @@ func TestCreateSyslogInput(t *testing.T) { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: testcase.cmd.AutoClone, - Client: testcase.cmd.Base.Globals.Client, + APIClient: testcase.cmd.Base.Globals.APIClient, Manifest: testcase.cmd.Manifest, Out: out, ServiceVersionFlag: testcase.cmd.ServiceVersion, @@ -151,7 +151,7 @@ func TestUpdateSyslogInput(t *testing.T) { }, } { t.Run(testcase.name, func(t *testing.T) { - testcase.cmd.Base.Globals.Client = testcase.api + testcase.cmd.Base.Globals.APIClient = testcase.api var bs []byte out := bytes.NewBuffer(bs) @@ -159,7 +159,7 @@ func TestUpdateSyslogInput(t *testing.T) { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: testcase.cmd.AutoClone, - Client: testcase.api, + APIClient: testcase.api, Manifest: testcase.cmd.Manifest, Out: out, ServiceVersionFlag: testcase.cmd.ServiceVersion, @@ -193,7 +193,7 @@ func createCommandRequired() *syslog.CreateCommand { Env: config.Environment{}, Output: &b, } - globals.Client, _ = mock.APIClient(mock.API{ + globals.APIClient, _ = mock.APIClient(mock.API{ ListVersionsFn: testutil.ListVersions, CloneVersionFn: testutil.CloneVersionResult(4), })("token", "endpoint") @@ -231,7 +231,7 @@ func createCommandAll() *syslog.CreateCommand { Env: config.Environment{}, Output: &b, } - globals.Client, _ = mock.APIClient(mock.API{ + globals.APIClient, _ = mock.APIClient(mock.API{ ListVersionsFn: testutil.ListVersions, CloneVersionFn: testutil.CloneVersionResult(4), })("token", "endpoint") diff --git a/pkg/commands/logging/syslog/update.go b/pkg/commands/logging/syslog/update.go index 8100604b3..f3afe6cf1 100644 --- a/pkg/commands/logging/syslog/update.go +++ b/pkg/commands/logging/syslog/update.go @@ -157,7 +157,7 @@ func (c *UpdateCommand) ConstructInput(serviceID string, serviceVersion int) (*f func (c *UpdateCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.AutoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.Manifest, Out: out, ServiceNameFlag: c.ServiceName, @@ -178,7 +178,7 @@ func (c *UpdateCommand) Exec(in io.Reader, out io.Writer) error { return err } - syslog, err := c.Globals.Client.UpdateSyslog(input) + syslog, err := c.Globals.APIClient.UpdateSyslog(input) if err != nil { c.Globals.ErrLog.Add(err) return err diff --git a/pkg/commands/logtail/root.go b/pkg/commands/logtail/root.go index 944664043..b2a60964b 100644 --- a/pkg/commands/logtail/root.go +++ b/pkg/commands/logtail/root.go @@ -69,7 +69,7 @@ func NewRootCommand(parent cmd.Registerer, globals *config.Data, data manifest.D // Exec implements the command interface. func (c *RootCommand) Exec(in io.Reader, out io.Writer) error { - serviceID, source, flag, err := cmd.ServiceID(c.serviceName, c.manifest, c.Globals.Client, c.Globals.ErrLog) + serviceID, source, flag, err := cmd.ServiceID(c.serviceName, c.manifest, c.Globals.APIClient, c.Globals.ErrLog) if err != nil { return err } @@ -274,7 +274,7 @@ func (c *RootCommand) adjustTimes() { // enableManagedLogging enables managed logging in our API. func (c *RootCommand) enableManagedLogging(out io.Writer) error { - _, err := c.Globals.Client.CreateManagedLogging(&c.Input) + _, err := c.Globals.APIClient.CreateManagedLogging(&c.Input) if err != nil && err != fastly.ErrManagedLoggingEnabled { c.Globals.ErrLog.Add(err) return err diff --git a/pkg/commands/pop/root.go b/pkg/commands/pop/root.go index 91671d9e9..07fa8e93f 100644 --- a/pkg/commands/pop/root.go +++ b/pkg/commands/pop/root.go @@ -31,7 +31,7 @@ func (c *RootCommand) Exec(in io.Reader, out io.Writer) error { return errors.ErrNoToken } - dcs, err := c.Globals.Client.AllDatacenters() + dcs, err := c.Globals.APIClient.AllDatacenters() if err != nil { c.Globals.ErrLog.Add(err) return err diff --git a/pkg/commands/purge/root.go b/pkg/commands/purge/root.go index 97eb989f6..754e98b99 100644 --- a/pkg/commands/purge/root.go +++ b/pkg/commands/purge/root.go @@ -66,7 +66,7 @@ func (c *RootCommand) Exec(in io.Reader, out io.Writer) error { return errors.ErrNoToken } - serviceID, source, flag, err := cmd.ServiceID(c.serviceName, c.manifest, c.Globals.Client, c.Globals.ErrLog) + serviceID, source, flag, err := cmd.ServiceID(c.serviceName, c.manifest, c.Globals.APIClient, c.Globals.ErrLog) if err != nil { return err } @@ -138,7 +138,7 @@ func (c *RootCommand) Exec(in io.Reader, out io.Writer) error { } func (c *RootCommand) purgeAll(serviceID string, out io.Writer) error { - p, err := c.Globals.Client.PurgeAll(&fastly.PurgeAllInput{ + p, err := c.Globals.APIClient.PurgeAll(&fastly.PurgeAllInput{ ServiceID: serviceID, }) if err != nil { @@ -160,7 +160,7 @@ func (c *RootCommand) purgeKeys(serviceID string, out io.Writer) error { return err } - m, err := c.Globals.Client.PurgeKeys(&fastly.PurgeKeysInput{ + m, err := c.Globals.APIClient.PurgeKeys(&fastly.PurgeKeysInput{ ServiceID: serviceID, Keys: keys, Soft: c.soft, @@ -191,7 +191,7 @@ func (c *RootCommand) purgeKeys(serviceID string, out io.Writer) error { } func (c *RootCommand) purgeKey(serviceID string, out io.Writer) error { - p, err := c.Globals.Client.PurgeKey(&fastly.PurgeKeyInput{ + p, err := c.Globals.APIClient.PurgeKey(&fastly.PurgeKeyInput{ ServiceID: serviceID, Key: c.key, Soft: c.soft, @@ -209,7 +209,7 @@ func (c *RootCommand) purgeKey(serviceID string, out io.Writer) error { } func (c *RootCommand) purgeURL(out io.Writer) error { - p, err := c.Globals.Client.Purge(&fastly.PurgeInput{ + p, err := c.Globals.APIClient.Purge(&fastly.PurgeInput{ URL: c.url, Soft: c.soft, }) diff --git a/pkg/commands/service/create.go b/pkg/commands/service/create.go index 16e009790..cda24667a 100644 --- a/pkg/commands/service/create.go +++ b/pkg/commands/service/create.go @@ -28,7 +28,7 @@ func NewCreateCommand(parent cmd.Registerer, globals *config.Data) *CreateComman // Exec invokes the application logic for the command. func (c *CreateCommand) Exec(in io.Reader, out io.Writer) error { - s, err := c.Globals.Client.CreateService(&c.Input) + s, err := c.Globals.APIClient.CreateService(&c.Input) if err != nil { c.Globals.ErrLog.AddWithContext(err, map[string]interface{}{ "Name": c.Input.Name, diff --git a/pkg/commands/service/delete.go b/pkg/commands/service/delete.go index a49e392ac..2b6706a83 100644 --- a/pkg/commands/service/delete.go +++ b/pkg/commands/service/delete.go @@ -45,7 +45,7 @@ func NewDeleteCommand(parent cmd.Registerer, globals *config.Data, data manifest // Exec invokes the application logic for the command. func (c *DeleteCommand) Exec(in io.Reader, out io.Writer) error { - serviceID, source, flag, err := cmd.ServiceID(c.serviceName, c.manifest, c.Globals.Client, c.Globals.ErrLog) + serviceID, source, flag, err := cmd.ServiceID(c.serviceName, c.manifest, c.Globals.APIClient, c.Globals.ErrLog) if err != nil { return err } @@ -56,7 +56,7 @@ func (c *DeleteCommand) Exec(in io.Reader, out io.Writer) error { c.Input.ID = serviceID if c.force { - s, err := c.Globals.Client.GetServiceDetails(&fastly.GetServiceInput{ + s, err := c.Globals.APIClient.GetServiceDetails(&fastly.GetServiceInput{ ID: serviceID, }) if err != nil { @@ -67,7 +67,7 @@ func (c *DeleteCommand) Exec(in io.Reader, out io.Writer) error { } if s.ActiveVersion.Number != 0 { - _, err := c.Globals.Client.DeactivateVersion(&fastly.DeactivateVersionInput{ + _, err := c.Globals.APIClient.DeactivateVersion(&fastly.DeactivateVersionInput{ ServiceID: serviceID, ServiceVersion: s.ActiveVersion.Number, }) @@ -81,7 +81,7 @@ func (c *DeleteCommand) Exec(in io.Reader, out io.Writer) error { } } - if err := c.Globals.Client.DeleteService(&c.Input); err != nil { + if err := c.Globals.APIClient.DeleteService(&c.Input); err != nil { c.Globals.ErrLog.AddWithContext(err, map[string]interface{}{ "Service ID": serviceID, }) diff --git a/pkg/commands/service/describe.go b/pkg/commands/service/describe.go index 427bfc353..5a6ac6340 100644 --- a/pkg/commands/service/describe.go +++ b/pkg/commands/service/describe.go @@ -57,7 +57,7 @@ func (c *DescribeCommand) Exec(in io.Reader, out io.Writer) error { return fsterr.ErrInvalidVerboseJSONCombo } - serviceID, source, flag, err := cmd.ServiceID(c.serviceName, c.manifest, c.Globals.Client, c.Globals.ErrLog) + serviceID, source, flag, err := cmd.ServiceID(c.serviceName, c.manifest, c.Globals.APIClient, c.Globals.ErrLog) if err != nil { return err } @@ -73,7 +73,7 @@ func (c *DescribeCommand) Exec(in io.Reader, out io.Writer) error { c.Input.ID = serviceID - service, err := c.Globals.Client.GetServiceDetails(&c.Input) + service, err := c.Globals.APIClient.GetServiceDetails(&c.Input) if err != nil { c.Globals.ErrLog.AddWithContext(err, map[string]interface{}{ "Service ID": serviceID, diff --git a/pkg/commands/service/list.go b/pkg/commands/service/list.go index be0326d21..291de59dc 100644 --- a/pkg/commands/service/list.go +++ b/pkg/commands/service/list.go @@ -44,7 +44,7 @@ func (c *ListCommand) Exec(in io.Reader, out io.Writer) error { return fsterr.ErrInvalidVerboseJSONCombo } - paginator := c.Globals.Client.NewListServicesPaginator(&c.input) + paginator := c.Globals.APIClient.NewListServicesPaginator(&c.input) var ss []*fastly.Service for paginator.HasNext() { diff --git a/pkg/commands/service/search.go b/pkg/commands/service/search.go index 3f04e6538..567341557 100644 --- a/pkg/commands/service/search.go +++ b/pkg/commands/service/search.go @@ -29,7 +29,7 @@ func NewSearchCommand(parent cmd.Registerer, globals *config.Data, data manifest // Exec invokes the application logic for the command. func (c *SearchCommand) Exec(in io.Reader, out io.Writer) error { - service, err := c.Globals.Client.SearchService(&c.Input) + service, err := c.Globals.APIClient.SearchService(&c.Input) if err != nil { c.Globals.ErrLog.AddWithContext(err, map[string]interface{}{ "Name": c.Input.Name, diff --git a/pkg/commands/service/update.go b/pkg/commands/service/update.go index 07595b5c7..2344671e1 100644 --- a/pkg/commands/service/update.go +++ b/pkg/commands/service/update.go @@ -47,7 +47,7 @@ func NewUpdateCommand(parent cmd.Registerer, globals *config.Data, data manifest // Exec invokes the application logic for the command. func (c *UpdateCommand) Exec(in io.Reader, out io.Writer) error { - serviceID, source, flag, err := cmd.ServiceID(c.serviceName, c.manifest, c.Globals.Client, c.Globals.ErrLog) + serviceID, source, flag, err := cmd.ServiceID(c.serviceName, c.manifest, c.Globals.APIClient, c.Globals.ErrLog) if err != nil { return err } @@ -77,7 +77,7 @@ func (c *UpdateCommand) Exec(in io.Reader, out io.Writer) error { c.input.Comment = fastly.String(c.comment.Value) } - s, err := c.Globals.Client.UpdateService(&c.input) + s, err := c.Globals.APIClient.UpdateService(&c.input) if err != nil { c.Globals.ErrLog.AddWithContext(err, map[string]interface{}{ "Service ID": serviceID, diff --git a/pkg/commands/serviceversion/activate.go b/pkg/commands/serviceversion/activate.go index 9d2381a85..290faa46a 100644 --- a/pkg/commands/serviceversion/activate.go +++ b/pkg/commands/serviceversion/activate.go @@ -56,7 +56,7 @@ func NewActivateCommand(parent cmd.Registerer, globals *config.Data, data manife func (c *ActivateCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.autoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -74,7 +74,7 @@ func (c *ActivateCommand) Exec(in io.Reader, out io.Writer) error { c.Input.ServiceID = serviceID c.Input.ServiceVersion = serviceVersion.Number - ver, err := c.Globals.Client.ActivateVersion(&c.Input) + ver, err := c.Globals.APIClient.ActivateVersion(&c.Input) if err != nil { c.Globals.ErrLog.AddWithContext(err, map[string]interface{}{ "Service ID": serviceID, diff --git a/pkg/commands/serviceversion/clone.go b/pkg/commands/serviceversion/clone.go index 6faee764e..f97ef06a6 100644 --- a/pkg/commands/serviceversion/clone.go +++ b/pkg/commands/serviceversion/clone.go @@ -51,7 +51,7 @@ func NewCloneCommand(parent cmd.Registerer, globals *config.Data, data manifest. func (c *CloneCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AllowActiveLocked: true, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -69,7 +69,7 @@ func (c *CloneCommand) Exec(in io.Reader, out io.Writer) error { c.Input.ServiceID = serviceID c.Input.ServiceVersion = serviceVersion.Number - ver, err := c.Globals.Client.CloneVersion(&c.Input) + ver, err := c.Globals.APIClient.CloneVersion(&c.Input) if err != nil { c.Globals.ErrLog.AddWithContext(err, map[string]interface{}{ "Service ID": serviceID, diff --git a/pkg/commands/serviceversion/deactivate.go b/pkg/commands/serviceversion/deactivate.go index e979d7139..54998e46c 100644 --- a/pkg/commands/serviceversion/deactivate.go +++ b/pkg/commands/serviceversion/deactivate.go @@ -51,7 +51,7 @@ func NewDeactivateCommand(parent cmd.Registerer, globals *config.Data, data mani func (c *DeactivateCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AllowActiveLocked: true, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -69,7 +69,7 @@ func (c *DeactivateCommand) Exec(in io.Reader, out io.Writer) error { c.Input.ServiceID = serviceID c.Input.ServiceVersion = serviceVersion.Number - ver, err := c.Globals.Client.DeactivateVersion(&c.Input) + ver, err := c.Globals.APIClient.DeactivateVersion(&c.Input) if err != nil { c.Globals.ErrLog.AddWithContext(err, map[string]interface{}{ "Service ID": serviceID, diff --git a/pkg/commands/serviceversion/list.go b/pkg/commands/serviceversion/list.go index ced50383a..e5ce4f436 100644 --- a/pkg/commands/serviceversion/list.go +++ b/pkg/commands/serviceversion/list.go @@ -56,7 +56,7 @@ func (c *ListCommand) Exec(in io.Reader, out io.Writer) error { return fsterr.ErrInvalidVerboseJSONCombo } - serviceID, source, flag, err := cmd.ServiceID(c.serviceName, c.manifest, c.Globals.Client, c.Globals.ErrLog) + serviceID, source, flag, err := cmd.ServiceID(c.serviceName, c.manifest, c.Globals.APIClient, c.Globals.ErrLog) if err != nil { return err } @@ -66,7 +66,7 @@ func (c *ListCommand) Exec(in io.Reader, out io.Writer) error { c.Input.ServiceID = serviceID - versions, err := c.Globals.Client.ListVersions(&c.Input) + versions, err := c.Globals.APIClient.ListVersions(&c.Input) if err != nil { c.Globals.ErrLog.AddWithContext(err, map[string]interface{}{ "Service ID": serviceID, diff --git a/pkg/commands/serviceversion/lock.go b/pkg/commands/serviceversion/lock.go index 00ecddfb2..7cbb20fc5 100644 --- a/pkg/commands/serviceversion/lock.go +++ b/pkg/commands/serviceversion/lock.go @@ -51,7 +51,7 @@ func NewLockCommand(parent cmd.Registerer, globals *config.Data, data manifest.D func (c *LockCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AllowActiveLocked: true, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -69,7 +69,7 @@ func (c *LockCommand) Exec(in io.Reader, out io.Writer) error { c.Input.ServiceID = serviceID c.Input.ServiceVersion = serviceVersion.Number - ver, err := c.Globals.Client.LockVersion(&c.Input) + ver, err := c.Globals.APIClient.LockVersion(&c.Input) if err != nil { c.Globals.ErrLog.AddWithContext(err, map[string]interface{}{ "Service ID": serviceID, diff --git a/pkg/commands/serviceversion/update.go b/pkg/commands/serviceversion/update.go index f80f31984..a604d0d7f 100644 --- a/pkg/commands/serviceversion/update.go +++ b/pkg/commands/serviceversion/update.go @@ -66,7 +66,7 @@ func NewUpdateCommand(parent cmd.Registerer, globals *config.Data, data manifest func (c *UpdateCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.autoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -92,7 +92,7 @@ func (c *UpdateCommand) Exec(in io.Reader, out io.Writer) error { c.input.Comment = fastly.String(c.comment.Value) } - ver, err := c.Globals.Client.UpdateVersion(&c.input) + ver, err := c.Globals.APIClient.UpdateVersion(&c.input) if err != nil { c.Globals.ErrLog.AddWithContext(err, map[string]interface{}{ "Service ID": serviceID, diff --git a/pkg/commands/stats/historical.go b/pkg/commands/stats/historical.go index 30dc47d67..375c672fd 100644 --- a/pkg/commands/stats/historical.go +++ b/pkg/commands/stats/historical.go @@ -55,7 +55,7 @@ func NewHistoricalCommand(parent cmd.Registerer, globals *config.Data, data mani // Exec implements the command interface. func (c *HistoricalCommand) Exec(in io.Reader, out io.Writer) error { - serviceID, source, flag, err := cmd.ServiceID(c.serviceName, c.manifest, c.Globals.Client, c.Globals.ErrLog) + serviceID, source, flag, err := cmd.ServiceID(c.serviceName, c.manifest, c.Globals.APIClient, c.Globals.ErrLog) if err != nil { return err } @@ -66,7 +66,7 @@ func (c *HistoricalCommand) Exec(in io.Reader, out io.Writer) error { c.Input.Service = serviceID var envelope statsResponse - err = c.Globals.Client.GetStatsJSON(&c.Input, &envelope) + err = c.Globals.APIClient.GetStatsJSON(&c.Input, &envelope) if err != nil { c.Globals.ErrLog.AddWithContext(err, map[string]interface{}{ "Service ID": serviceID, diff --git a/pkg/commands/stats/realtime.go b/pkg/commands/stats/realtime.go index c4ee8994a..f47506b60 100644 --- a/pkg/commands/stats/realtime.go +++ b/pkg/commands/stats/realtime.go @@ -48,7 +48,7 @@ func NewRealtimeCommand(parent cmd.Registerer, globals *config.Data, data manife // Exec implements the command interface. func (c *RealtimeCommand) Exec(in io.Reader, out io.Writer) error { - serviceID, source, flag, err := cmd.ServiceID(c.serviceName, c.manifest, c.Globals.Client, c.Globals.ErrLog) + serviceID, source, flag, err := cmd.ServiceID(c.serviceName, c.manifest, c.Globals.APIClient, c.Globals.ErrLog) if err != nil { return err } diff --git a/pkg/commands/stats/regions.go b/pkg/commands/stats/regions.go index 82ca64a40..dee358187 100644 --- a/pkg/commands/stats/regions.go +++ b/pkg/commands/stats/regions.go @@ -24,7 +24,7 @@ func NewRegionsCommand(parent cmd.Registerer, globals *config.Data) *RegionsComm // Exec implements the command interface. func (c *RegionsCommand) Exec(in io.Reader, out io.Writer) error { - resp, err := c.Globals.Client.GetRegions() + resp, err := c.Globals.APIClient.GetRegions() if err != nil { c.Globals.ErrLog.Add(err) return fmt.Errorf("fetching regions: %w", err) diff --git a/pkg/commands/update/root.go b/pkg/commands/update/root.go index 0273708cc..d83286105 100644 --- a/pkg/commands/update/root.go +++ b/pkg/commands/update/root.go @@ -7,7 +7,6 @@ import ( "os" "path/filepath" - "github.com/fastly/cli/pkg/api" "github.com/fastly/cli/pkg/cmd" "github.com/fastly/cli/pkg/config" "github.com/fastly/cli/pkg/errors" @@ -22,17 +21,15 @@ import ( type RootCommand struct { cmd.Base cliVersioner Versioner - client api.HTTPClient configFilePath string } // NewRootCommand returns a new command registered in the parent. -func NewRootCommand(parent cmd.Registerer, configFilePath string, cliVersioner Versioner, client api.HTTPClient, globals *config.Data) *RootCommand { +func NewRootCommand(parent cmd.Registerer, configFilePath string, cliVersioner Versioner, globals *config.Data) *RootCommand { var c RootCommand c.Globals = globals c.CmdClause = parent.Command("update", "Update the CLI to the latest version") c.cliVersioner = cliVersioner - c.client = client c.configFilePath = configFilePath return &c } @@ -55,7 +52,7 @@ func (c *RootCommand) Exec(in io.Reader, out io.Writer) error { progress := text.NewProgress(out, c.Globals.Verbose()) progress.Step("Updating versioning information...") - err = c.Globals.File.Load(c.Globals.File.CLI.RemoteConfig, c.client, config.ConfigRequestTimeout, config.FilePath) + err = c.Globals.File.Load(c.Globals.File.CLI.RemoteConfig, config.FilePath, c.Globals.HTTPClient) if err != nil { progress.Fail() return errors.RemediationError{ diff --git a/pkg/commands/user/create.go b/pkg/commands/user/create.go index cfbffa4b6..a047ff632 100644 --- a/pkg/commands/user/create.go +++ b/pkg/commands/user/create.go @@ -47,7 +47,7 @@ func (c *CreateCommand) Exec(in io.Reader, out io.Writer) error { input := c.constructInput() - r, err := c.Globals.Client.CreateUser(input) + r, err := c.Globals.APIClient.CreateUser(input) if err != nil { c.Globals.ErrLog.AddWithContext(err, map[string]interface{}{ "User Login": c.login, diff --git a/pkg/commands/user/delete.go b/pkg/commands/user/delete.go index 96465f582..94a37df97 100644 --- a/pkg/commands/user/delete.go +++ b/pkg/commands/user/delete.go @@ -38,7 +38,7 @@ func (c *DeleteCommand) Exec(in io.Reader, out io.Writer) error { input := c.constructInput() - err := c.Globals.Client.DeleteUser(input) + err := c.Globals.APIClient.DeleteUser(input) if err != nil { c.Globals.ErrLog.AddWithContext(err, map[string]interface{}{ "User ID": c.id, diff --git a/pkg/commands/user/describe.go b/pkg/commands/user/describe.go index ed6ec2305..4db779a19 100644 --- a/pkg/commands/user/describe.go +++ b/pkg/commands/user/describe.go @@ -46,7 +46,7 @@ func (c *DescribeCommand) Exec(in io.Reader, out io.Writer) error { } if c.current { - r, err := c.Globals.Client.GetCurrentUser() + r, err := c.Globals.APIClient.GetCurrentUser() if err != nil { c.Globals.ErrLog.Add(err) return err @@ -61,7 +61,7 @@ func (c *DescribeCommand) Exec(in io.Reader, out io.Writer) error { return err } - r, err := c.Globals.Client.GetUser(input) + r, err := c.Globals.APIClient.GetUser(input) if err != nil { c.Globals.ErrLog.Add(err) return err diff --git a/pkg/commands/user/list.go b/pkg/commands/user/list.go index fdb7085c3..6cc770851 100644 --- a/pkg/commands/user/list.go +++ b/pkg/commands/user/list.go @@ -58,7 +58,7 @@ func (c *ListCommand) Exec(in io.Reader, out io.Writer) error { input := c.constructInput() - rs, err := c.Globals.Client.ListCustomerUsers(input) + rs, err := c.Globals.APIClient.ListCustomerUsers(input) if err != nil { c.Globals.ErrLog.AddWithContext(err, map[string]interface{}{ "Customer ID": c.customerID.Value, diff --git a/pkg/commands/user/update.go b/pkg/commands/user/update.go index 7e7318486..5d23d15ed 100644 --- a/pkg/commands/user/update.go +++ b/pkg/commands/user/update.go @@ -52,7 +52,7 @@ func (c *UpdateCommand) Exec(in io.Reader, out io.Writer) error { return err } - err = c.Globals.Client.ResetUserPassword(input) + err = c.Globals.APIClient.ResetUserPassword(input) if err != nil { c.Globals.ErrLog.AddWithContext(err, map[string]interface{}{ "User Login": c.login, @@ -69,7 +69,7 @@ func (c *UpdateCommand) Exec(in io.Reader, out io.Writer) error { return err } - r, err := c.Globals.Client.UpdateUser(input) + r, err := c.Globals.APIClient.UpdateUser(input) if err != nil { c.Globals.ErrLog.AddWithContext(err, map[string]interface{}{ "User ID": c.id, diff --git a/pkg/commands/vcl/custom/create.go b/pkg/commands/vcl/custom/create.go index c4a48392e..fa520258e 100644 --- a/pkg/commands/vcl/custom/create.go +++ b/pkg/commands/vcl/custom/create.go @@ -67,7 +67,7 @@ type CreateCommand struct { func (c *CreateCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.autoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -84,7 +84,7 @@ func (c *CreateCommand) Exec(in io.Reader, out io.Writer) error { input := c.constructInput(serviceID, serviceVersion.Number) - v, err := c.Globals.Client.CreateVCL(input) + v, err := c.Globals.APIClient.CreateVCL(input) if err != nil { c.Globals.ErrLog.AddWithContext(err, map[string]interface{}{ "Service ID": serviceID, diff --git a/pkg/commands/vcl/custom/delete.go b/pkg/commands/vcl/custom/delete.go index bddb57497..672766dd2 100644 --- a/pkg/commands/vcl/custom/delete.go +++ b/pkg/commands/vcl/custom/delete.go @@ -63,7 +63,7 @@ type DeleteCommand struct { func (c *DeleteCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.autoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -80,7 +80,7 @@ func (c *DeleteCommand) Exec(in io.Reader, out io.Writer) error { input := c.constructInput(serviceID, serviceVersion.Number) - err = c.Globals.Client.DeleteVCL(input) + err = c.Globals.APIClient.DeleteVCL(input) if err != nil { c.Globals.ErrLog.AddWithContext(err, map[string]interface{}{ "Service ID": serviceID, diff --git a/pkg/commands/vcl/custom/describe.go b/pkg/commands/vcl/custom/describe.go index 4899d10fe..624997a3d 100644 --- a/pkg/commands/vcl/custom/describe.go +++ b/pkg/commands/vcl/custom/describe.go @@ -70,7 +70,7 @@ func (c *DescribeCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AllowActiveLocked: true, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -87,7 +87,7 @@ func (c *DescribeCommand) Exec(in io.Reader, out io.Writer) error { input := c.constructInput(serviceID, serviceVersion.Number) - v, err := c.Globals.Client.GetVCL(input) + v, err := c.Globals.APIClient.GetVCL(input) if err != nil { c.Globals.ErrLog.AddWithContext(err, map[string]interface{}{ "Service ID": serviceID, diff --git a/pkg/commands/vcl/custom/list.go b/pkg/commands/vcl/custom/list.go index 47e13ec3c..8884063dd 100644 --- a/pkg/commands/vcl/custom/list.go +++ b/pkg/commands/vcl/custom/list.go @@ -69,7 +69,7 @@ func (c *ListCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AllowActiveLocked: true, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -86,7 +86,7 @@ func (c *ListCommand) Exec(in io.Reader, out io.Writer) error { input := c.constructInput(serviceID, serviceVersion.Number) - vs, err := c.Globals.Client.ListVCLs(input) + vs, err := c.Globals.APIClient.ListVCLs(input) if err != nil { c.Globals.ErrLog.AddWithContext(err, map[string]interface{}{ "Service ID": serviceID, diff --git a/pkg/commands/vcl/custom/update.go b/pkg/commands/vcl/custom/update.go index d6a309197..86c908354 100644 --- a/pkg/commands/vcl/custom/update.go +++ b/pkg/commands/vcl/custom/update.go @@ -68,7 +68,7 @@ type UpdateCommand struct { func (c *UpdateCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.autoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -92,7 +92,7 @@ func (c *UpdateCommand) Exec(in io.Reader, out io.Writer) error { return err } - v, err := c.Globals.Client.UpdateVCL(input) + v, err := c.Globals.APIClient.UpdateVCL(input) if err != nil { c.Globals.ErrLog.AddWithContext(err, map[string]interface{}{ "Service ID": serviceID, diff --git a/pkg/commands/vcl/snippet/create.go b/pkg/commands/vcl/snippet/create.go index 6f31bc254..2d3aeb0f3 100644 --- a/pkg/commands/vcl/snippet/create.go +++ b/pkg/commands/vcl/snippet/create.go @@ -74,7 +74,7 @@ type CreateCommand struct { func (c *CreateCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.autoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -91,7 +91,7 @@ func (c *CreateCommand) Exec(in io.Reader, out io.Writer) error { input := c.constructInput(serviceID, serviceVersion.Number) - v, err := c.Globals.Client.CreateSnippet(input) + v, err := c.Globals.APIClient.CreateSnippet(input) if err != nil { c.Globals.ErrLog.AddWithContext(err, map[string]interface{}{ "Service ID": serviceID, diff --git a/pkg/commands/vcl/snippet/delete.go b/pkg/commands/vcl/snippet/delete.go index f86165afe..e91b14d9d 100644 --- a/pkg/commands/vcl/snippet/delete.go +++ b/pkg/commands/vcl/snippet/delete.go @@ -63,7 +63,7 @@ type DeleteCommand struct { func (c *DeleteCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.autoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -80,7 +80,7 @@ func (c *DeleteCommand) Exec(in io.Reader, out io.Writer) error { input := c.constructInput(serviceID, serviceVersion.Number) - err = c.Globals.Client.DeleteSnippet(input) + err = c.Globals.APIClient.DeleteSnippet(input) if err != nil { c.Globals.ErrLog.AddWithContext(err, map[string]interface{}{ "Service ID": serviceID, diff --git a/pkg/commands/vcl/snippet/describe.go b/pkg/commands/vcl/snippet/describe.go index f82ff848f..abaa556e2 100644 --- a/pkg/commands/vcl/snippet/describe.go +++ b/pkg/commands/vcl/snippet/describe.go @@ -74,7 +74,7 @@ func (c *DescribeCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AllowActiveLocked: true, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -98,7 +98,7 @@ func (c *DescribeCommand) Exec(in io.Reader, out io.Writer) error { }) return err } - v, err := c.Globals.Client.GetDynamicSnippet(input) + v, err := c.Globals.APIClient.GetDynamicSnippet(input) if err != nil { c.Globals.ErrLog.AddWithContext(err, map[string]interface{}{ "Service ID": serviceID, @@ -121,7 +121,7 @@ func (c *DescribeCommand) Exec(in io.Reader, out io.Writer) error { }) return err } - v, err := c.Globals.Client.GetSnippet(input) + v, err := c.Globals.APIClient.GetSnippet(input) if err != nil { c.Globals.ErrLog.AddWithContext(err, map[string]interface{}{ "Service ID": serviceID, diff --git a/pkg/commands/vcl/snippet/list.go b/pkg/commands/vcl/snippet/list.go index 9e8979a44..e9369be42 100644 --- a/pkg/commands/vcl/snippet/list.go +++ b/pkg/commands/vcl/snippet/list.go @@ -69,7 +69,7 @@ func (c *ListCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AllowActiveLocked: true, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -86,7 +86,7 @@ func (c *ListCommand) Exec(in io.Reader, out io.Writer) error { input := c.constructInput(serviceID, serviceVersion.Number) - vs, err := c.Globals.Client.ListSnippets(input) + vs, err := c.Globals.APIClient.ListSnippets(input) if err != nil { c.Globals.ErrLog.AddWithContext(err, map[string]interface{}{ "Service ID": serviceID, diff --git a/pkg/commands/vcl/snippet/update.go b/pkg/commands/vcl/snippet/update.go index a314fe2d8..978f8b8fe 100644 --- a/pkg/commands/vcl/snippet/update.go +++ b/pkg/commands/vcl/snippet/update.go @@ -78,7 +78,7 @@ type UpdateCommand struct { func (c *UpdateCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{ AutoCloneFlag: c.autoClone, - Client: c.Globals.Client, + APIClient: c.Globals.APIClient, Manifest: c.manifest, Out: out, ServiceNameFlag: c.serviceName, @@ -102,7 +102,7 @@ func (c *UpdateCommand) Exec(in io.Reader, out io.Writer) error { }) return err } - v, err := c.Globals.Client.UpdateDynamicSnippet(input) + v, err := c.Globals.APIClient.UpdateDynamicSnippet(input) if err != nil { c.Globals.ErrLog.AddWithContext(err, map[string]interface{}{ "Service ID": serviceID, @@ -122,7 +122,7 @@ func (c *UpdateCommand) Exec(in io.Reader, out io.Writer) error { }) return err } - v, err := c.Globals.Client.UpdateSnippet(input) + v, err := c.Globals.APIClient.UpdateSnippet(input) if err != nil { c.Globals.ErrLog.AddWithContext(err, map[string]interface{}{ "Service ID": serviceID, diff --git a/pkg/commands/whoami/root.go b/pkg/commands/whoami/root.go index 1072c4036..6d0c781a2 100644 --- a/pkg/commands/whoami/root.go +++ b/pkg/commands/whoami/root.go @@ -8,7 +8,6 @@ import ( "sort" "strings" - "github.com/fastly/cli/pkg/api" "github.com/fastly/cli/pkg/cmd" "github.com/fastly/cli/pkg/config" "github.com/fastly/cli/pkg/errors" @@ -19,14 +18,12 @@ import ( // It should be installed under the primary root command. type RootCommand struct { cmd.Base - client api.HTTPClient } // NewRootCommand returns a new command registered in the parent. -func NewRootCommand(parent cmd.Registerer, client api.HTTPClient, globals *config.Data) *RootCommand { +func NewRootCommand(parent cmd.Registerer, globals *config.Data) *RootCommand { var c RootCommand c.Globals = globals - c.client = client c.CmdClause = parent.Command("whoami", "Get information about the currently authenticated account") return &c } @@ -51,7 +48,7 @@ func (c *RootCommand) Exec(in io.Reader, out io.Writer) error { req.Header.Set("Fastly-Key", token) req.Header.Set("Accept", "application/json") req.Header.Set("User-Agent", useragent.Name) - resp, err := c.client.Do(req) + resp, err := c.Globals.HTTPClient.Do(req) if err != nil { c.Globals.ErrLog.Add(err) return fmt.Errorf("error executing API request: %w", err) diff --git a/pkg/config/data.go b/pkg/config/data.go index 13f6eccef..2ce305335 100644 --- a/pkg/config/data.go +++ b/pkg/config/data.go @@ -1,11 +1,11 @@ package config import ( - "context" "errors" "fmt" "io" "net/http" + "net/url" "os" "path/filepath" "strings" @@ -58,10 +58,6 @@ const ( // UpdateSuccessful represents the message shown to a user when their // application configuration has been updated successfully. UpdateSuccessful = "Successfully updated platform compatibility and versioning information." - - // ConfigRequestTimeout is how long we'll wait for the CLI API endpoint to - // return a response before timing out the request. - ConfigRequestTimeout = 5 * time.Second ) // ErrLegacyConfig indicates that the local configuration file is using the @@ -106,8 +102,9 @@ type Data struct { Flag Flag ErrLog fsterr.LogInterface - Client api.Interface - RTSClient api.RealtimeStatsInterface + APIClient api.Interface + HTTPClient api.HTTPClient + RTSClient api.RealtimeStatsInterface } // Token yields the Fastly API token. @@ -285,11 +282,8 @@ func (f *File) Static() []byte { // Load gets the configuration file from the CLI API endpoint and encodes it // from memory into config.File. -func (f *File) Load(configEndpoint string, c api.HTTPClient, d time.Duration, path string) error { - ctx, cancel := context.WithTimeout(context.Background(), d) - defer cancel() - - req, err := http.NewRequestWithContext(ctx, http.MethodGet, configEndpoint, nil) +func (f *File) Load(endpoint, path string, c api.HTTPClient) error { + req, err := http.NewRequest(http.MethodGet, endpoint, nil) if err != nil { return err } @@ -297,7 +291,7 @@ func (f *File) Load(configEndpoint string, c api.HTTPClient, d time.Duration, pa req.Header.Set("User-Agent", useragent.Name) resp, err := c.Do(req) if err != nil { - if errors.Is(err, context.DeadlineExceeded) { + if urlErr, ok := err.(*url.Error); ok && urlErr.Timeout() { return fsterr.RemediationError{ Inner: err, Remediation: fsterr.NetworkRemediation, diff --git a/pkg/config/data_test.go b/pkg/config/data_test.go index fd8211b81..adc719378 100644 --- a/pkg/config/data_test.go +++ b/pkg/config/data_test.go @@ -2,16 +2,16 @@ package config_test import ( "bytes" + "context" _ "embed" "strings" - "context" "errors" "net/http" + "net/url" "os" "path/filepath" "testing" - "time" "github.com/fastly/cli/pkg/config" fsterr "github.com/fastly/cli/pkg/errors" @@ -22,7 +22,9 @@ import ( type mockHTTPClient struct{} func (c mockHTTPClient) Do(req *http.Request) (*http.Response, error) { - return &http.Response{}, context.DeadlineExceeded + return &http.Response{}, &url.Error{ + Err: context.DeadlineExceeded, + } } // TestConfigLoad validates that when a context.DeadlineExceeded error is @@ -31,10 +33,9 @@ func (c mockHTTPClient) Do(req *http.Request) (*http.Response, error) { func TestConfigLoad(t *testing.T) { var ( c mockHTTPClient - d time.Duration f *config.File ) - if err := f.Load("foo", c, d, "/path/to/config.toml"); err != nil { + if err := f.Load("foo", "/path/to/config.toml", c); err != nil { if !errors.As(err, &fsterr.RemediationError{}) { t.Errorf("expected RemediationError got: %T", err) } diff --git a/pkg/errors/remediation_error.go b/pkg/errors/remediation_error.go index 7d5c1eefa..087312019 100644 --- a/pkg/errors/remediation_error.go +++ b/pkg/errors/remediation_error.go @@ -137,3 +137,7 @@ var ComputeBuildRemediation = strings.Join([]string{ "Add a [scripts.build] setting for your custom build process.", "See more at https://developer.fastly.com/reference/fastly-toml/", }, " ") + +// ComputeTrialRemediation suggests contacting customer manager to enable the +// free trial feature flag. +var ComputeTrialRemediation = "For more help with this error see fastly.help/cli/ecp-feature" From 098fd8dfacfa668ec55af028911feff039114016 Mon Sep 17 00:00:00 2001 From: Mark McDonnell Date: Mon, 7 Feb 2022 16:13:22 +0000 Subject: [PATCH 2/5] add additional error logging --- pkg/commands/compute/deploy.go | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/pkg/commands/compute/deploy.go b/pkg/commands/compute/deploy.go index d40e15c14..d331b5745 100644 --- a/pkg/commands/compute/deploy.go +++ b/pkg/commands/compute/deploy.go @@ -574,7 +574,7 @@ func manageNoServiceIDFlow( // There is no service and so we'll do a one time creation of the service // // NOTE: we're shadowing the `serviceVersion` and `serviceID` variables. - serviceID, serviceVersion, err = createService(pkgName, apiClient, activateTrial, progress) + serviceID, serviceVersion, err = createService(pkgName, apiClient, activateTrial, progress, errLog) if err != nil { progress.Fail() errLog.AddWithContext(err, map[string]interface{}{ @@ -601,7 +601,7 @@ func manageNoServiceIDFlow( // // NOTE: If the creation of the service fails because the user has not // activated a free trial, then we'll trigger the trial for their account. -func createService(name string, apiClient api.Interface, activateTrial activator, progress text.Progress) (serviceID string, serviceVersion *fastly.Version, err error) { +func createService(name string, apiClient api.Interface, activateTrial activator, progress text.Progress, errLog fsterr.LogInterface) (serviceID string, serviceVersion *fastly.Version, err error) { progress.Step("Creating service...") service, err := apiClient.CreateService(&fastly.CreateServiceInput{ @@ -626,8 +626,17 @@ func createService(name string, apiClient api.Interface, activateTrial activator } } - return createService(name, apiClient, activateTrial, progress) + errLog.AddWithContext(err, map[string]interface{}{ + "Name": name, + "User": user.Name, + "Customer ID": user.CustomerID, + }) + return createService(name, apiClient, activateTrial, progress, errLog) } + + errLog.AddWithContext(err, map[string]interface{}{ + "Name": name, + }) return serviceID, serviceVersion, fmt.Errorf("error creating service: %w", err) } @@ -676,9 +685,18 @@ func manageExistingServiceFlow( // VCL service, for which we cannot upload a wasm package format to. serviceDetails, err := apiClient.GetServiceDetails(&fastly.GetServiceInput{ID: serviceID}) if err != nil { + errLog.AddWithContext(err, map[string]interface{}{ + "Service ID": serviceID, + "Service Version": serviceVersion, + }) return serviceVersion, err } if serviceDetails.Type != "wasm" { + errLog.AddWithContext(err, map[string]interface{}{ + "Service ID": serviceID, + "Service Version": serviceVersion, + "Service Type": serviceDetails.Type, + }) return serviceVersion, fsterr.RemediationError{ Inner: fmt.Errorf("invalid service type: %s", serviceDetails.Type), Remediation: "Ensure the provided Service ID is associated with a 'Wasm' Fastly Service and not a 'VCL' Fastly service. " + fsterr.ComputeTrialRemediation, From 88aeb91aff2c4df1dcc3b67c6226e6600fec3d41 Mon Sep 17 00:00:00 2001 From: Mark McDonnell Date: Tue, 8 Feb 2022 16:41:42 +0000 Subject: [PATCH 3/5] return custom error that contains status code --- pkg/api/undocumented/undocumented.go | 33 ++++++++++++++++++++++------ pkg/commands/compute/deploy.go | 11 ++++++---- 2 files changed, 33 insertions(+), 11 deletions(-) diff --git a/pkg/api/undocumented/undocumented.go b/pkg/api/undocumented/undocumented.go index c3e5f144a..d43e3d435 100644 --- a/pkg/api/undocumented/undocumented.go +++ b/pkg/api/undocumented/undocumented.go @@ -19,14 +19,33 @@ const EdgeComputeTrial = "/customer/%s/edge-compute-trial" // RequestTimeout is the timeout for the API network request. const RequestTimeout = 5 * time.Second +// APIError models a custom error for undocumented API calls. +type APIError struct { + Err error + StatusCode int +} + +// Error implements the error interface. +func (e APIError) Error() string { + return e.Err.Error() +} + +// NewError returns an APIError +func NewError(err error, statusCode int) APIError { + return APIError{ + Err: err, + StatusCode: statusCode, + } +} + // Get calls the given API endpoint and returns its response data. -func Get(host, path, token string, c api.HTTPClient) (data []byte, statusCode int, err error) { +func Get(host, path, token string, c api.HTTPClient) (data []byte, err error) { host = strings.TrimSuffix(host, "/") endpoint := fmt.Sprintf("%s%s", host, path) req, err := http.NewRequest(http.MethodPost, endpoint, nil) if err != nil { - return data, statusCode, err + return data, NewError(err, 0) } req.Header.Set("Fastly-Key", token) @@ -35,23 +54,23 @@ func Get(host, path, token string, c api.HTTPClient) (data []byte, statusCode in res, err := c.Do(req) if err != nil { if urlErr, ok := err.(*url.Error); ok && urlErr.Timeout() { - return data, statusCode, fsterr.RemediationError{ + return data, fsterr.RemediationError{ Inner: err, Remediation: fsterr.NetworkRemediation, } } - return data, statusCode, err + return data, NewError(err, 0) } defer res.Body.Close() if res.StatusCode != http.StatusOK { - return data, res.StatusCode, fmt.Errorf("error from API: '%s'", res.Status) + return data, NewError(fmt.Errorf("non-2xx response"), res.StatusCode) } data, err = io.ReadAll(res.Body) if err != nil { - return data, res.StatusCode, err + return data, NewError(err, res.StatusCode) } - return data, res.StatusCode, nil + return data, nil } diff --git a/pkg/commands/compute/deploy.go b/pkg/commands/compute/deploy.go index d331b5745..f680f58c6 100644 --- a/pkg/commands/compute/deploy.go +++ b/pkg/commands/compute/deploy.go @@ -527,14 +527,17 @@ type activator func(customerID string) error func preconfigureActivateTrial(endpoint, token string, httpClient api.HTTPClient) activator { return func(customerID string) error { path := fmt.Sprintf(undocumented.EdgeComputeTrial, customerID) - _, statusCode, err := undocumented.Get(endpoint, path, token, httpClient) + _, err := undocumented.Get(endpoint, path, token, httpClient) if err != nil { - // 409 Conflict == The Compute@Edge trial has already been created. - if statusCode != http.StatusConflict { + apiErr, ok := err.(undocumented.APIError) + if !ok { return err } + // 409 Conflict == The Compute@Edge trial has already been created. + if apiErr.StatusCode != http.StatusConflict { + return fmt.Errorf("%w: %d %s", err, apiErr.StatusCode, http.StatusText(apiErr.StatusCode)) + } } - return nil } } From 729f503062ef18f6e227be69e11fe6c01496b7b7 Mon Sep 17 00:00:00 2001 From: Mark McDonnell Date: Tue, 8 Feb 2022 16:42:45 +0000 Subject: [PATCH 4/5] implement mock HTTP client abstraction with tests --- pkg/commands/compute/deploy_test.go | 121 +++++++++++++++++++++++++++- pkg/mock/client.go | 20 +++++ 2 files changed, 140 insertions(+), 1 deletion(-) diff --git a/pkg/commands/compute/deploy_test.go b/pkg/commands/compute/deploy_test.go index 34e6c8419..a426c8a3b 100644 --- a/pkg/commands/compute/deploy_test.go +++ b/pkg/commands/compute/deploy_test.go @@ -2,8 +2,11 @@ package compute_test import ( "bytes" + "context" "fmt" "io" + "net/http" + "net/url" "os" "path/filepath" "strings" @@ -80,6 +83,8 @@ func TestDeploy(t *testing.T) { api mock.API args []string dontWantOutput []string + httpClientRes *http.Response + httpClientErr error manifest string name string noManifest bool @@ -227,6 +232,98 @@ func TestDeploy(t *testing.T) { "Creating service...", }, }, + // The following test mocks the service creation to fail with a specific + // error value that will result in the code trying to activate a free trial + // for the customer's account. + // + // Specifically this test will fail the initial API call to get the + // customer's details and so we expect it to return that error (as we can't + // activate a free trial without knowing the customer ID). + { + name: "service create error due to no trial activated and error getting user", + args: args("compute deploy --token 123"), + api: mock.API{ + CreateServiceFn: createServiceErrorNoTrial, + GetCurrentUserFn: getCurrentUserError, + }, + stdin: []string{ + "Y", // when prompted to create a new service + }, + wantError: fmt.Sprintf("unable to identify user associated with the given token: %s", testutil.Err.Error()), + wantOutput: []string{ + "Creating service...", + }, + }, + // The following test mocks the HTTP client to return a 400 Bad Request, + // which is then coerced into a generic 'no free trial' error. + { + name: "service create error due to no trial activated and error activating trial", + args: args("compute deploy --token 123"), + api: mock.API{ + CreateServiceFn: createServiceErrorNoTrial, + GetCurrentUserFn: getCurrentUser, + }, + httpClientRes: &http.Response{ + Body: io.NopCloser(strings.NewReader(testutil.Err.Error())), + Status: http.StatusText(http.StatusBadRequest), + StatusCode: http.StatusBadRequest, + }, + httpClientErr: nil, + stdin: []string{ + "Y", // when prompted to create a new service + }, + wantError: "error creating service: you do not have the Compute@Edge free trial enabled on your Fastly account", + wantRemediationError: errors.ComputeTrialRemediation, + wantOutput: []string{ + "Creating service...", + }, + }, + // The following test mocks the HTTP client to return a timeout error, + // which is then coerced into a generic 'no free trial' error. + { + name: "service create error due to no trial activated and activating trial timeout", + args: args("compute deploy --token 123"), + api: mock.API{ + CreateServiceFn: createServiceErrorNoTrial, + GetCurrentUserFn: getCurrentUser, + }, + httpClientRes: nil, + httpClientErr: &url.Error{Err: context.DeadlineExceeded}, + stdin: []string{ + "Y", // when prompted to create a new service + }, + wantError: "error creating service: you do not have the Compute@Edge free trial enabled on your Fastly account", + wantRemediationError: errors.ComputeTrialRemediation, + wantOutput: []string{ + "Creating service...", + }, + }, + // The following test mocks the HTTP client to return successfully when + // trying to activate the free trial. + { + name: "service create success", + args: args("compute deploy --token 123"), + api: mock.API{ + ActivateVersionFn: activateVersionOk, + CreateBackendFn: createBackendOK, + CreateServiceFn: createServiceOK, + GetPackageFn: getPackageOk, + ListDomainsFn: listDomainsOk, + UpdatePackageFn: updatePackageOk, + }, + httpClientRes: &http.Response{ + Body: io.NopCloser(strings.NewReader(testutil.Err.Error())), + Status: http.StatusText(http.StatusOK), + StatusCode: http.StatusOK, + }, + httpClientErr: nil, + stdin: []string{ + "Y", // when prompted to create a new service + }, + wantOutput: []string{ + "Creating service...", + }, + }, // The following test doesn't provide a Service ID by either a flag nor the // manifest, so this will result in the deploy script attempting to create // a new service. We mock the service creation to be successful while we @@ -302,6 +399,8 @@ func TestDeploy(t *testing.T) { "Activating version...", }, }, + // The following test validates that if a package contains code that has + // not changed since the last deploy, then the deployment is skipped. { name: "identical package", args: args("compute deploy --service-id 123 --token 123"), @@ -317,7 +416,7 @@ func TestDeploy(t *testing.T) { }, }, { - name: "success", + name: "success with existing service", args: args("compute deploy --service-id 123 --token 123"), api: mock.API{ ActivateVersionFn: activateVersionOk, @@ -1194,6 +1293,10 @@ func TestDeploy(t *testing.T) { opts := testutil.NewRunOpts(testcase.args, &stdout) opts.APIClient = mock.APIClient(testcase.api) + if testcase.httpClientRes != nil || testcase.httpClientErr != nil { + opts.HTTPClient = mock.HTMLClient(testcase.httpClientRes, testcase.httpClientErr) + } + if testcase.reduceSizeLimit { compute.PackageSizeLimit = 1000000 // 1mb (our test package should above this) } else { @@ -1277,6 +1380,22 @@ func createServiceError(*fastly.CreateServiceInput) (*fastly.Service, error) { return nil, testutil.Err } +// NOTE: We don't return testutil.Err but a very specific error message so that +// the Deploy logic will drop into a nested logic block. +func createServiceErrorNoTrial(*fastly.CreateServiceInput) (*fastly.Service, error) { + return nil, fmt.Errorf("Valid values for 'type' are: 'vcl'") +} + +func getCurrentUser() (*fastly.User, error) { + return &fastly.User{ + CustomerID: "abc", + }, nil +} + +func getCurrentUserError() (*fastly.User, error) { + return nil, testutil.Err +} + func deleteServiceOK(i *fastly.DeleteServiceInput) error { return nil } diff --git a/pkg/mock/client.go b/pkg/mock/client.go index 79cb0302b..e6ad57a56 100644 --- a/pkg/mock/client.go +++ b/pkg/mock/client.go @@ -1,6 +1,8 @@ package mock import ( + "net/http" + "github.com/fastly/cli/pkg/api" ) @@ -11,3 +13,21 @@ func APIClient(a API) func(string, string) (api.Interface, error) { return a, nil } } + +type mockHTTPClient struct { + res *http.Response + err error +} + +func (c mockHTTPClient) Do(req *http.Request) (*http.Response, error) { + return c.res, c.err +} + +// HTMLClient returns a mock HTTP Client that returns a stubbed response or +// error. +func HTMLClient(res *http.Response, err error) api.HTTPClient { + return mockHTTPClient{ + res: res, + err: err, + } +} From 31bd6cad1facb2525edb9067246e06fabdd8bf92 Mon Sep 17 00:00:00 2001 From: Mark McDonnell Date: Tue, 8 Feb 2022 17:41:31 +0000 Subject: [PATCH 5/5] although message is not validated, at least use a message that resembles a success --- pkg/commands/compute/deploy_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/commands/compute/deploy_test.go b/pkg/commands/compute/deploy_test.go index a426c8a3b..814b9c0bc 100644 --- a/pkg/commands/compute/deploy_test.go +++ b/pkg/commands/compute/deploy_test.go @@ -312,7 +312,7 @@ func TestDeploy(t *testing.T) { UpdatePackageFn: updatePackageOk, }, httpClientRes: &http.Response{ - Body: io.NopCloser(strings.NewReader(testutil.Err.Error())), + Body: io.NopCloser(strings.NewReader("success")), Status: http.StatusText(http.StatusOK), StatusCode: http.StatusOK, },