From c57ced3e54ee10cfb36f53b09333f9860a677cce Mon Sep 17 00:00:00 2001 From: "Kevin P. Fleming" Date: Fri, 9 Aug 2024 16:52:35 -0400 Subject: [PATCH] fix(service-version): Allow 'locked' services to be activated. This PR changes the ServiceDetailsOpts structure (used by the ServiceDetails function) to permit commands to specify individual serviceversion states as part of the filtering mechanism. Nearly all commands allow both 'active' and 'locked' serviceversions, and previously 'service-version activate' blocked both, but it should allow 'locked' while still blocking 'active'. Additionally, the error message emitted when the specified serviceversion is not allowed by the filter now indicates whether it was the 'active' or 'locked' status which caused the error. Finally, many more tests were added to ensure that the proper error messages are emitted for 'active' and 'locked' serviceversions in many of the commands which specify filters. --- .tmpl/create.go | 2 + .tmpl/delete.go | 2 + .tmpl/describe.go | 1 - .tmpl/list.go | 1 - .tmpl/test.go | 38 +++++++++++++--- .tmpl/update.go | 2 + pkg/argparser/cmd.go | 43 +++++++++++++++++-- pkg/commands/acl/acl_test.go | 38 +++++++++++++--- pkg/commands/acl/create.go | 3 ++ pkg/commands/acl/delete.go | 3 ++ pkg/commands/acl/describe.go | 1 - pkg/commands/acl/list.go | 1 - pkg/commands/acl/update.go | 3 ++ pkg/commands/backend/backend_test.go | 30 +++++++++++-- pkg/commands/backend/create.go | 3 ++ pkg/commands/backend/delete.go | 3 ++ pkg/commands/backend/describe.go | 1 - pkg/commands/backend/list.go | 1 - pkg/commands/backend/update.go | 3 ++ pkg/commands/compute/deploy_test.go | 11 +++++ pkg/commands/dictionary/create.go | 3 ++ pkg/commands/dictionary/delete.go | 3 ++ pkg/commands/dictionary/describe.go | 1 - pkg/commands/dictionary/list.go | 1 - pkg/commands/dictionary/update.go | 3 ++ pkg/commands/domain/create.go | 3 ++ pkg/commands/domain/delete.go | 3 ++ pkg/commands/domain/describe.go | 1 - pkg/commands/domain/list.go | 1 - pkg/commands/domain/update.go | 3 ++ pkg/commands/domain/validate.go | 1 - pkg/commands/healthcheck/create.go | 3 ++ pkg/commands/healthcheck/delete.go | 3 ++ pkg/commands/healthcheck/describe.go | 1 - pkg/commands/healthcheck/list.go | 1 - pkg/commands/healthcheck/update.go | 3 ++ pkg/commands/logging/azureblob/create.go | 3 ++ pkg/commands/logging/azureblob/delete.go | 3 ++ pkg/commands/logging/azureblob/describe.go | 1 - pkg/commands/logging/azureblob/list.go | 1 - pkg/commands/logging/azureblob/update.go | 3 ++ pkg/commands/logging/bigquery/create.go | 3 ++ pkg/commands/logging/bigquery/delete.go | 3 ++ pkg/commands/logging/bigquery/describe.go | 1 - pkg/commands/logging/bigquery/list.go | 1 - pkg/commands/logging/bigquery/update.go | 3 ++ pkg/commands/logging/cloudfiles/create.go | 3 ++ pkg/commands/logging/cloudfiles/delete.go | 3 ++ pkg/commands/logging/cloudfiles/describe.go | 1 - pkg/commands/logging/cloudfiles/list.go | 1 - pkg/commands/logging/cloudfiles/update.go | 3 ++ pkg/commands/logging/datadog/create.go | 3 ++ pkg/commands/logging/datadog/delete.go | 3 ++ pkg/commands/logging/datadog/describe.go | 1 - pkg/commands/logging/datadog/list.go | 1 - pkg/commands/logging/datadog/update.go | 3 ++ pkg/commands/logging/digitalocean/create.go | 3 ++ pkg/commands/logging/digitalocean/delete.go | 3 ++ pkg/commands/logging/digitalocean/describe.go | 1 - pkg/commands/logging/digitalocean/list.go | 1 - pkg/commands/logging/digitalocean/update.go | 3 ++ pkg/commands/logging/elasticsearch/create.go | 3 ++ pkg/commands/logging/elasticsearch/delete.go | 3 ++ .../logging/elasticsearch/describe.go | 1 - pkg/commands/logging/elasticsearch/list.go | 1 - pkg/commands/logging/elasticsearch/update.go | 3 ++ pkg/commands/logging/ftp/create.go | 3 ++ pkg/commands/logging/ftp/delete.go | 3 ++ pkg/commands/logging/ftp/describe.go | 1 - pkg/commands/logging/ftp/list.go | 1 - pkg/commands/logging/ftp/update.go | 3 ++ pkg/commands/logging/gcs/create.go | 3 ++ pkg/commands/logging/gcs/delete.go | 3 ++ pkg/commands/logging/gcs/describe.go | 1 - pkg/commands/logging/gcs/list.go | 1 - pkg/commands/logging/gcs/update.go | 3 ++ pkg/commands/logging/googlepubsub/create.go | 3 ++ pkg/commands/logging/googlepubsub/delete.go | 3 ++ pkg/commands/logging/googlepubsub/describe.go | 1 - pkg/commands/logging/googlepubsub/list.go | 1 - pkg/commands/logging/googlepubsub/update.go | 3 ++ pkg/commands/logging/heroku/create.go | 3 ++ pkg/commands/logging/heroku/delete.go | 3 ++ pkg/commands/logging/heroku/describe.go | 1 - pkg/commands/logging/heroku/list.go | 1 - pkg/commands/logging/heroku/update.go | 3 ++ pkg/commands/logging/honeycomb/create.go | 3 ++ pkg/commands/logging/honeycomb/delete.go | 3 ++ pkg/commands/logging/honeycomb/describe.go | 1 - pkg/commands/logging/honeycomb/list.go | 1 - pkg/commands/logging/honeycomb/update.go | 3 ++ pkg/commands/logging/https/create.go | 3 ++ pkg/commands/logging/https/delete.go | 3 ++ pkg/commands/logging/https/describe.go | 1 - pkg/commands/logging/https/list.go | 1 - pkg/commands/logging/https/update.go | 3 ++ pkg/commands/logging/kafka/create.go | 3 ++ pkg/commands/logging/kafka/delete.go | 3 ++ pkg/commands/logging/kafka/describe.go | 1 - pkg/commands/logging/kafka/list.go | 1 - pkg/commands/logging/kafka/update.go | 3 ++ pkg/commands/logging/kinesis/create.go | 3 ++ pkg/commands/logging/kinesis/delete.go | 3 ++ pkg/commands/logging/kinesis/describe.go | 1 - pkg/commands/logging/kinesis/list.go | 1 - pkg/commands/logging/kinesis/update.go | 3 ++ pkg/commands/logging/loggly/create.go | 3 ++ pkg/commands/logging/loggly/delete.go | 3 ++ pkg/commands/logging/loggly/describe.go | 1 - pkg/commands/logging/loggly/list.go | 1 - pkg/commands/logging/loggly/update.go | 3 ++ pkg/commands/logging/logshuttle/create.go | 3 ++ pkg/commands/logging/logshuttle/delete.go | 3 ++ pkg/commands/logging/logshuttle/describe.go | 1 - pkg/commands/logging/logshuttle/list.go | 1 - pkg/commands/logging/logshuttle/update.go | 3 ++ pkg/commands/logging/newrelic/create.go | 3 ++ pkg/commands/logging/newrelic/delete.go | 3 ++ pkg/commands/logging/newrelic/describe.go | 1 - pkg/commands/logging/newrelic/list.go | 1 - .../logging/newrelic/newrelic_test.go | 36 +++++++++++++--- pkg/commands/logging/newrelic/update.go | 3 ++ pkg/commands/logging/newrelicotlp/create.go | 3 ++ pkg/commands/logging/newrelicotlp/delete.go | 3 ++ pkg/commands/logging/newrelicotlp/describe.go | 1 - pkg/commands/logging/newrelicotlp/list.go | 1 - .../logging/newrelicotlp/newrelicotlp_test.go | 36 +++++++++++++--- pkg/commands/logging/newrelicotlp/update.go | 3 ++ pkg/commands/logging/openstack/create.go | 3 ++ pkg/commands/logging/openstack/delete.go | 3 ++ pkg/commands/logging/openstack/describe.go | 1 - pkg/commands/logging/openstack/list.go | 1 - pkg/commands/logging/openstack/update.go | 3 ++ pkg/commands/logging/papertrail/create.go | 3 ++ pkg/commands/logging/papertrail/delete.go | 3 ++ pkg/commands/logging/papertrail/describe.go | 1 - pkg/commands/logging/papertrail/list.go | 1 - pkg/commands/logging/papertrail/update.go | 3 ++ pkg/commands/logging/s3/create.go | 3 ++ pkg/commands/logging/s3/delete.go | 3 ++ pkg/commands/logging/s3/describe.go | 1 - pkg/commands/logging/s3/list.go | 1 - pkg/commands/logging/s3/update.go | 3 ++ pkg/commands/logging/scalyr/create.go | 3 ++ pkg/commands/logging/scalyr/delete.go | 3 ++ pkg/commands/logging/scalyr/describe.go | 1 - pkg/commands/logging/scalyr/list.go | 1 - pkg/commands/logging/scalyr/update.go | 3 ++ pkg/commands/logging/sftp/create.go | 3 ++ pkg/commands/logging/sftp/delete.go | 3 ++ pkg/commands/logging/sftp/describe.go | 1 - pkg/commands/logging/sftp/list.go | 1 - pkg/commands/logging/sftp/update.go | 3 ++ pkg/commands/logging/splunk/create.go | 3 ++ pkg/commands/logging/splunk/delete.go | 3 ++ pkg/commands/logging/splunk/describe.go | 1 - pkg/commands/logging/splunk/list.go | 1 - pkg/commands/logging/splunk/update.go | 3 ++ pkg/commands/logging/sumologic/create.go | 3 ++ pkg/commands/logging/sumologic/delete.go | 3 ++ pkg/commands/logging/sumologic/describe.go | 1 - pkg/commands/logging/sumologic/list.go | 1 - pkg/commands/logging/sumologic/update.go | 3 ++ pkg/commands/logging/syslog/create.go | 3 ++ pkg/commands/logging/syslog/delete.go | 3 ++ pkg/commands/logging/syslog/describe.go | 1 - pkg/commands/logging/syslog/list.go | 1 - pkg/commands/logging/syslog/update.go | 3 ++ pkg/commands/ratelimit/create.go | 3 ++ pkg/commands/ratelimit/list.go | 1 - pkg/commands/resourcelink/create.go | 3 ++ pkg/commands/resourcelink/delete.go | 3 ++ pkg/commands/resourcelink/update.go | 3 ++ pkg/commands/serviceversion/activate.go | 2 + pkg/commands/serviceversion/clone.go | 1 - pkg/commands/serviceversion/deactivate.go | 3 +- pkg/commands/serviceversion/lock.go | 3 +- .../serviceversion/serviceversion_test.go | 20 ++++++++- pkg/commands/vcl/condition/create.go | 3 ++ pkg/commands/vcl/condition/delete.go | 3 ++ pkg/commands/vcl/condition/describe.go | 1 - pkg/commands/vcl/condition/list.go | 1 - pkg/commands/vcl/condition/update.go | 3 ++ pkg/commands/vcl/custom/create.go | 3 ++ pkg/commands/vcl/custom/custom_test.go | 36 +++++++++++++--- pkg/commands/vcl/custom/delete.go | 3 ++ pkg/commands/vcl/custom/describe.go | 1 - pkg/commands/vcl/custom/list.go | 1 - pkg/commands/vcl/custom/update.go | 3 ++ pkg/commands/vcl/snippet/create.go | 3 ++ pkg/commands/vcl/snippet/delete.go | 3 ++ pkg/commands/vcl/snippet/describe.go | 1 - pkg/commands/vcl/snippet/list.go | 1 - pkg/commands/vcl/snippet/snippet_test.go | 36 +++++++++++++--- pkg/commands/vcl/snippet/update.go | 14 +++++- 195 files changed, 616 insertions(+), 124 deletions(-) diff --git a/.tmpl/create.go b/.tmpl/create.go index 67c1b86f4..ea2e314da 100644 --- a/.tmpl/create.go +++ b/.tmpl/create.go @@ -62,6 +62,8 @@ type CreateCommand struct { // Exec invokes the application logic for the command. func (c *CreateCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.autoClone, Client: c.Globals.Client, Manifest: c.manifest, diff --git a/.tmpl/delete.go b/.tmpl/delete.go index dd9d9a665..b51fe7a2b 100644 --- a/.tmpl/delete.go +++ b/.tmpl/delete.go @@ -62,6 +62,8 @@ type DeleteCommand struct { // Exec invokes the application logic for the command. func (c *DeleteCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.autoClone, Client: c.Globals.Client, Manifest: c.manifest, diff --git a/.tmpl/describe.go b/.tmpl/describe.go index e800b9ac8..f99a1ec05 100644 --- a/.tmpl/describe.go +++ b/.tmpl/describe.go @@ -57,7 +57,6 @@ type DescribeCommand struct { // Exec invokes the application logic for the command. func (c *DescribeCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ - AllowActiveLocked: true, Client: c.Globals.Client, Manifest: c.manifest, Out: out, diff --git a/.tmpl/list.go b/.tmpl/list.go index ed26c304c..fbc2178eb 100644 --- a/.tmpl/list.go +++ b/.tmpl/list.go @@ -58,7 +58,6 @@ type ListCommand struct { // Exec invokes the application logic for the command. func (c *ListCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ - AllowActiveLocked: true, Client: c.Globals.Client, Manifest: c.manifest, Out: out, diff --git a/.tmpl/test.go b/.tmpl/test.go index 59f986d86..b1c57f06f 100644 --- a/.tmpl/test.go +++ b/.tmpl/test.go @@ -25,12 +25,20 @@ func TestCreate(t *testing.T) { WantError: "error reading service: no service ID found", }, { - Name: "validate missing --autoclone flag", + Name: "validate missing --autoclone flag with 'active' service", API: mock.API{ ListVersionsFn: testutil.ListVersions, }, Args: "--service-id 123 --version 1", - WantError: "service version 1 is not editable", + WantError: "service version 1 is active", + }, + { + Name: "validate missing --autoclone flag with 'locked' service", + API: mock.API{ + ListVersionsFn: testutil.ListVersions, + }, + Args: "--service-id 123 --version 2", + WantError: "service version 2 is locked", }, { Name: "validate Create${CLI_API} API error", @@ -88,12 +96,20 @@ func TestDelete(t *testing.T) { WantError: "error reading service: no service ID found", }, { - Name: "validate missing --autoclone flag", + Name: "validate missing --autoclone flag with 'active' service", API: mock.API{ ListVersionsFn: testutil.ListVersions, }, Args: "--service-id 123 --version 1", - WantError: "service version 1 is not editable", + WantError: "service version 1 is active", + }, + { + Name: "validate missing --autoclone flag with 'locked' service", + API: mock.API{ + ListVersionsFn: testutil.ListVersions, + }, + Args: "--service-id 123 --version 2", + WantError: "service version 2 is locked", }, { Name: "validate Delete${CLI_API} API error", @@ -233,12 +249,20 @@ func TestUpdate(t *testing.T) { WantError: "error reading service: no service ID found", }, { - Name: "validate missing --autoclone flag", + Name: "validate missing --autoclone flag with 'active' service", API: mock.API{ ListVersionsFn: testutil.ListVersions, }, - Args: "--service-id 123 --version 1", - WantError: "service version 1 is not editable", + Args: "--name foobar --service-id 123 --version 1", + WantError: "service version 1 is active", + }, + { + Name: "validate missing --autoclone flag with 'locked' service", + API: mock.API{ + ListVersionsFn: testutil.ListVersions, + }, + Args: "--name foobar --service-id 123 --version 2", + WantError: "service version 2 is locked", }, { Name: "validate Update${CLI_API} API error", diff --git a/.tmpl/update.go b/.tmpl/update.go index cd41e20f9..9ef517ba1 100644 --- a/.tmpl/update.go +++ b/.tmpl/update.go @@ -66,6 +66,8 @@ type UpdateCommand struct { // Exec invokes the application logic for the command. func (c *UpdateCommand) Exec(in io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.autoClone, Client: c.Globals.Client, Manifest: c.manifest, diff --git a/pkg/argparser/cmd.go b/pkg/argparser/cmd.go index 6484250ca..50e9ce62f 100644 --- a/pkg/argparser/cmd.go +++ b/pkg/argparser/cmd.go @@ -13,6 +13,7 @@ import ( "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/manifest" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // Command is an interface that abstracts over all of the concrete command @@ -108,7 +109,14 @@ type OptionalFloat64 struct { // ServiceDetailsOpts provides data and behaviours required by the // ServiceDetails function. type ServiceDetailsOpts struct { - AllowActiveLocked bool + // Active controls whether active serviceversions will be included in the result; + // if this is Empty, then the 'active' state of the version is ignored; + // otherwise, the 'active' state must match the value + Active optional.Optional[bool] + // Locked controls whether locked serviceversions will be included in the result; + // if this is Empty, then the 'locked' state of the version is ignored; + // otherwise, the 'locked' state must match the value + Locked optional.Optional[bool] AutoCloneFlag OptionalAutoClone APIClient api.Interface Manifest manifest.Data @@ -140,14 +148,41 @@ func ServiceDetails(opts ServiceDetailsOpts) (serviceID string, serviceVersion * if err != nil { return serviceID, currentVersion, err } - } else if !opts.AllowActiveLocked && (fastly.ToValue(v.Active) || fastly.ToValue(v.Locked)) { + return serviceID, v, nil + } + + failure := false + var failureState string + + if active, present := opts.Active.Get(); present { + if active && !fastly.ToValue(v.Active) { + failure = true + failureState = "not active" + } + if !active && fastly.ToValue(v.Active) { + failure = true + failureState = "active" + } + } + + if locked, present := opts.Locked.Get(); present { + if locked && !fastly.ToValue(v.Locked) { + failure = true + failureState = "not locked" + } + if !locked && fastly.ToValue(v.Locked) { + failure = true + failureState = "locked" + } + } + + if failure { err = fsterr.RemediationError{ - Inner: fmt.Errorf("service version %d is not editable", fastly.ToValue(v.Number)), + Inner: fmt.Errorf("service version %d is %s", fastly.ToValue(v.Number), failureState), Remediation: fsterr.AutoCloneRemediation, } return serviceID, v, err } - return serviceID, v, nil } diff --git a/pkg/commands/acl/acl_test.go b/pkg/commands/acl/acl_test.go index cfc65d896..66eed5640 100644 --- a/pkg/commands/acl/acl_test.go +++ b/pkg/commands/acl/acl_test.go @@ -28,12 +28,20 @@ func TestACLCreate(t *testing.T) { WantError: "error reading service: no service ID found", }, { - Name: "validate missing --autoclone flag", + Name: "validate missing --autoclone flag with 'active' service", API: mock.API{ ListVersionsFn: testutil.ListVersions, }, Arg: "--name foo --service-id 123 --version 1", - WantError: "service version 1 is not editable", + WantError: "service version 1 is active", + }, + { + Name: "validate missing --autoclone flag with 'locked' service", + API: mock.API{ + ListVersionsFn: testutil.ListVersions, + }, + Arg: "--name foo --service-id 123 --version 2", + WantError: "service version 2 is locked", }, { Name: "validate CreateACL API error", @@ -102,12 +110,20 @@ func TestACLDelete(t *testing.T) { WantError: "error reading service: no service ID found", }, { - Name: "validate missing --autoclone flag", + Name: "validate missing --autoclone flag with 'active' service", API: mock.API{ ListVersionsFn: testutil.ListVersions, }, Arg: "--name foobar --service-id 123 --version 1", - WantError: "service version 1 is not editable", + WantError: "service version 1 is active", + }, + { + Name: "validate missing --autoclone flag with 'locked' service", + API: mock.API{ + ListVersionsFn: testutil.ListVersions, + }, + Arg: "--name foo --service-id 123 --version 2", + WantError: "service version 2 is locked", }, { Name: "validate DeleteACL API error", @@ -276,12 +292,20 @@ func TestACLUpdate(t *testing.T) { WantError: "error reading service: no service ID found", }, { - Name: "validate missing --autoclone flag", + Name: "validate missing --autoclone flag with 'active' service", + API: mock.API{ + ListVersionsFn: testutil.ListVersions, + }, + Arg: "--name foo --new-name beepboop --service-id 123 --version 1", + WantError: "service version 1 is active", + }, + { + Name: "validate missing --autoclone flag with 'locked' service", API: mock.API{ ListVersionsFn: testutil.ListVersions, }, - Arg: "--name foobar --new-name beepboop --service-id 123 --version 1", - WantError: "service version 1 is not editable", + Arg: "--name foo --new-name beepboop --service-id 123 --version 2", + WantError: "service version 2 is locked", }, { Name: "validate UpdateACL API error", diff --git a/pkg/commands/acl/create.go b/pkg/commands/acl/create.go index f8fbde362..8e3505592 100644 --- a/pkg/commands/acl/create.go +++ b/pkg/commands/acl/create.go @@ -9,6 +9,7 @@ import ( "github.com/fastly/cli/pkg/errors" "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // NewCreateCommand returns a usable command registered under the parent. @@ -64,6 +65,8 @@ type CreateCommand struct { // Exec invokes the application logic for the command. func (c *CreateCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.autoClone, APIClient: c.Globals.APIClient, ErrLog: c.Globals.ErrLog, diff --git a/pkg/commands/acl/delete.go b/pkg/commands/acl/delete.go index c3456bb6b..7a475e44d 100644 --- a/pkg/commands/acl/delete.go +++ b/pkg/commands/acl/delete.go @@ -9,6 +9,7 @@ import ( "github.com/fastly/cli/pkg/errors" "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // NewDeleteCommand returns a usable command registered under the parent. @@ -63,6 +64,8 @@ type DeleteCommand struct { // Exec invokes the application logic for the command. func (c *DeleteCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.autoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/acl/describe.go b/pkg/commands/acl/describe.go index 10272cb9c..a06ea414f 100644 --- a/pkg/commands/acl/describe.go +++ b/pkg/commands/acl/describe.go @@ -64,7 +64,6 @@ func (c *DescribeCommand) Exec(_ io.Reader, out io.Writer) error { } serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ - AllowActiveLocked: true, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, Out: out, diff --git a/pkg/commands/acl/list.go b/pkg/commands/acl/list.go index 0301478ce..3353f8c56 100644 --- a/pkg/commands/acl/list.go +++ b/pkg/commands/acl/list.go @@ -63,7 +63,6 @@ func (c *ListCommand) Exec(_ io.Reader, out io.Writer) error { } serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ - AllowActiveLocked: true, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, Out: out, diff --git a/pkg/commands/acl/update.go b/pkg/commands/acl/update.go index cba750784..4e9fe7aa6 100644 --- a/pkg/commands/acl/update.go +++ b/pkg/commands/acl/update.go @@ -9,6 +9,7 @@ import ( "github.com/fastly/cli/pkg/errors" "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // NewUpdateCommand returns a usable command registered under the parent. @@ -65,6 +66,8 @@ type UpdateCommand struct { // Exec invokes the application logic for the command. func (c *UpdateCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.autoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/backend/backend_test.go b/pkg/commands/backend/backend_test.go index 0d95745ee..dc8924738 100644 --- a/pkg/commands/backend/backend_test.go +++ b/pkg/commands/backend/backend_test.go @@ -30,9 +30,31 @@ func TestBackendCreate(t *testing.T) { API: mock.API{ ListVersionsFn: testutil.ListVersions, }, - WantError: "service version 1 is not editable", + WantError: "service version 1 is active", }, - // The following test is the same as the above but it appends --autoclone + // The following test specifies a service version that's 'locked', and + // subsequently we expect it to not be cloned as we don't provide the + // --autoclone flag and trying to add a backend to an activated service + // should cause an error. + { + Arg: "--service-id 123 --version 2 --address example.com --name www.test.com", + API: mock.API{ + ListVersionsFn: testutil.ListVersions, + }, + WantError: "service version 2 is locked", + }, + // The following test is the same as the 'active' test above but it appends --autoclone + // so we can be sure the backend creation error still occurs. + { + Arg: "--service-id 123 --version 1 --address example.com --name www.test.com --autoclone", + API: mock.API{ + ListVersionsFn: testutil.ListVersions, + CloneVersionFn: testutil.CloneVersionResult(4), + CreateBackendFn: createBackendError, + }, + WantError: errTest.Error(), + }, + // The following test is the same as the 'locked' test above but it appends --autoclone // so we can be sure the backend creation error still occurs. { Arg: "--service-id 123 --version 1 --address example.com --name www.test.com --autoclone", @@ -122,8 +144,8 @@ func TestBackendCreate(t *testing.T) { }, WantOutput: "Created backend www.test.com (service 123 version 4)", }, - // The following test specifies a service version that's 'inactive', and - // subsequently we expect it to be the same editable version. + // The following test specifies a service version that's 'inactive' and not 'locked', + // and subsequently we expect it to be the same editable version. { Arg: "--service-id 123 --version 3 --address 127.0.0.1 --name www.test.com", API: mock.API{ diff --git a/pkg/commands/backend/create.go b/pkg/commands/backend/create.go index 7de3e92ee..49cc2d082 100644 --- a/pkg/commands/backend/create.go +++ b/pkg/commands/backend/create.go @@ -11,6 +11,7 @@ import ( fsterr "github.com/fastly/cli/pkg/errors" "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // CreateCommand calls the Fastly API to create backends. @@ -127,6 +128,8 @@ func NewCreateCommand(parent argparser.Registerer, g *global.Data) *CreateComman // Exec invokes the application logic for the command. func (c *CreateCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.autoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/backend/delete.go b/pkg/commands/backend/delete.go index 1e20e244f..08231161a 100644 --- a/pkg/commands/backend/delete.go +++ b/pkg/commands/backend/delete.go @@ -9,6 +9,7 @@ import ( "github.com/fastly/cli/pkg/errors" "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // DeleteCommand calls the Fastly API to delete backends. @@ -62,6 +63,8 @@ func NewDeleteCommand(parent argparser.Registerer, g *global.Data) *DeleteComman // Exec invokes the application logic for the command. func (c *DeleteCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.autoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/backend/describe.go b/pkg/commands/backend/describe.go index 0e3f336d8..61de8686c 100644 --- a/pkg/commands/backend/describe.go +++ b/pkg/commands/backend/describe.go @@ -63,7 +63,6 @@ func (c *DescribeCommand) Exec(_ io.Reader, out io.Writer) error { } serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ - AllowActiveLocked: true, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, Out: out, diff --git a/pkg/commands/backend/list.go b/pkg/commands/backend/list.go index b0d19874a..f6f73cccd 100644 --- a/pkg/commands/backend/list.go +++ b/pkg/commands/backend/list.go @@ -63,7 +63,6 @@ func (c *ListCommand) Exec(_ io.Reader, out io.Writer) error { } serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ - AllowActiveLocked: true, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, Out: out, diff --git a/pkg/commands/backend/update.go b/pkg/commands/backend/update.go index 4adf32651..d62865c28 100644 --- a/pkg/commands/backend/update.go +++ b/pkg/commands/backend/update.go @@ -10,6 +10,7 @@ import ( fsterr "github.com/fastly/cli/pkg/errors" "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // UpdateCommand calls the Fastly API to update backends. @@ -124,6 +125,8 @@ func NewUpdateCommand(parent argparser.Registerer, g *global.Data) *UpdateComman // Exec invokes the application logic for the command. func (c *UpdateCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.autoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/compute/deploy_test.go b/pkg/commands/compute/deploy_test.go index e1bb21fa2..1b07b9674 100644 --- a/pkg/commands/compute/deploy_test.go +++ b/pkg/commands/compute/deploy_test.go @@ -198,6 +198,17 @@ func TestDeploy(t *testing.T) { }, wantError: fmt.Sprintf("error cloning service version: %s", testutil.Err.Error()), }, + { + name: "service version is locked, clone version error", + args: args("compute deploy --service-id 123 --token 123 --version 2"), + api: mock.API{ + CloneVersionFn: testutil.CloneVersionError, + GetPackageFn: getPackageOk, + GetServiceDetailsFn: getServiceDetailsWasm, + ListVersionsFn: testutil.ListVersions, + }, + wantError: fmt.Sprintf("error cloning service version: %s", testutil.Err.Error()), + }, { name: "list domains error", args: args("compute deploy --service-id 123 --token 123"), diff --git a/pkg/commands/dictionary/create.go b/pkg/commands/dictionary/create.go index 3f321e9b1..e8ac5eb84 100644 --- a/pkg/commands/dictionary/create.go +++ b/pkg/commands/dictionary/create.go @@ -9,6 +9,7 @@ import ( "github.com/fastly/cli/pkg/errors" "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // CreateCommand calls the Fastly API to create a service. @@ -67,6 +68,8 @@ func NewCreateCommand(parent argparser.Registerer, g *global.Data) *CreateComman // Exec invokes the application logic for the command. func (c *CreateCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.autoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/dictionary/delete.go b/pkg/commands/dictionary/delete.go index c1846bb90..ba9fa080d 100644 --- a/pkg/commands/dictionary/delete.go +++ b/pkg/commands/dictionary/delete.go @@ -9,6 +9,7 @@ import ( "github.com/fastly/cli/pkg/errors" "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // DeleteCommand calls the Fastly API to delete a service. @@ -61,6 +62,8 @@ func NewDeleteCommand(parent argparser.Registerer, g *global.Data) *DeleteComman // Exec invokes the application logic for the command. func (c *DeleteCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.autoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/dictionary/describe.go b/pkg/commands/dictionary/describe.go index ff16fed8d..4f4a56740 100644 --- a/pkg/commands/dictionary/describe.go +++ b/pkg/commands/dictionary/describe.go @@ -63,7 +63,6 @@ func (c *DescribeCommand) Exec(_ io.Reader, out io.Writer) error { } serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ - AllowActiveLocked: true, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, Out: out, diff --git a/pkg/commands/dictionary/list.go b/pkg/commands/dictionary/list.go index 21aa5ff84..636269fa4 100644 --- a/pkg/commands/dictionary/list.go +++ b/pkg/commands/dictionary/list.go @@ -62,7 +62,6 @@ func (c *ListCommand) Exec(_ io.Reader, out io.Writer) error { return fsterr.ErrInvalidVerboseJSONCombo } serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ - AllowActiveLocked: true, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, Out: out, diff --git a/pkg/commands/dictionary/update.go b/pkg/commands/dictionary/update.go index 71ff2db53..7264b9c09 100644 --- a/pkg/commands/dictionary/update.go +++ b/pkg/commands/dictionary/update.go @@ -11,6 +11,7 @@ import ( fsterr "github.com/fastly/cli/pkg/errors" "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // UpdateCommand calls the Fastly API to update a dictionary. @@ -70,6 +71,8 @@ func NewUpdateCommand(parent argparser.Registerer, g *global.Data) *UpdateComman // Exec invokes the application logic for the command. func (c *UpdateCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.autoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/domain/create.go b/pkg/commands/domain/create.go index 34dabb09c..220c8e5db 100644 --- a/pkg/commands/domain/create.go +++ b/pkg/commands/domain/create.go @@ -9,6 +9,7 @@ import ( "github.com/fastly/cli/pkg/errors" "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // CreateCommand calls the Fastly API to create domains. @@ -67,6 +68,8 @@ func NewCreateCommand(parent argparser.Registerer, g *global.Data) *CreateComman // Exec invokes the application logic for the command. func (c *CreateCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.autoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/domain/delete.go b/pkg/commands/domain/delete.go index 7a652b284..09bfca4e4 100644 --- a/pkg/commands/domain/delete.go +++ b/pkg/commands/domain/delete.go @@ -9,6 +9,7 @@ import ( "github.com/fastly/cli/pkg/errors" "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // DeleteCommand calls the Fastly API to delete domains. @@ -61,6 +62,8 @@ func NewDeleteCommand(parent argparser.Registerer, g *global.Data) *DeleteComman // Exec invokes the application logic for the command. func (c *DeleteCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.autoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/domain/describe.go b/pkg/commands/domain/describe.go index c7bee1df9..1bbbc492a 100644 --- a/pkg/commands/domain/describe.go +++ b/pkg/commands/domain/describe.go @@ -63,7 +63,6 @@ func (c *DescribeCommand) Exec(_ io.Reader, out io.Writer) error { } serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ - AllowActiveLocked: true, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, Out: out, diff --git a/pkg/commands/domain/list.go b/pkg/commands/domain/list.go index 49b5aeb4d..e8da0dd48 100644 --- a/pkg/commands/domain/list.go +++ b/pkg/commands/domain/list.go @@ -63,7 +63,6 @@ func (c *ListCommand) Exec(_ io.Reader, out io.Writer) error { } serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ - AllowActiveLocked: true, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, Out: out, diff --git a/pkg/commands/domain/update.go b/pkg/commands/domain/update.go index dd91068bb..a017e3e30 100644 --- a/pkg/commands/domain/update.go +++ b/pkg/commands/domain/update.go @@ -10,6 +10,7 @@ import ( "github.com/fastly/cli/pkg/errors" "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // UpdateCommand calls the Fastly API to update domains. @@ -67,6 +68,8 @@ func NewUpdateCommand(parent argparser.Registerer, g *global.Data) *UpdateComman // Exec invokes the application logic for the command. func (c *UpdateCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.autoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/domain/validate.go b/pkg/commands/domain/validate.go index 95ee13838..54b62c211 100644 --- a/pkg/commands/domain/validate.go +++ b/pkg/commands/domain/validate.go @@ -57,7 +57,6 @@ type ValidateCommand struct { // Exec invokes the application logic for the command. func (c *ValidateCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ - AllowActiveLocked: true, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, Out: out, diff --git a/pkg/commands/healthcheck/create.go b/pkg/commands/healthcheck/create.go index 51f494bbc..d690006fa 100644 --- a/pkg/commands/healthcheck/create.go +++ b/pkg/commands/healthcheck/create.go @@ -9,6 +9,7 @@ import ( "github.com/fastly/cli/pkg/errors" "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // CreateCommand calls the Fastly API to create healthchecks. @@ -87,6 +88,8 @@ func NewCreateCommand(parent argparser.Registerer, g *global.Data) *CreateComman // Exec invokes the application logic for the command. func (c *CreateCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.autoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/healthcheck/delete.go b/pkg/commands/healthcheck/delete.go index f1ba044ed..1cedf6047 100644 --- a/pkg/commands/healthcheck/delete.go +++ b/pkg/commands/healthcheck/delete.go @@ -9,6 +9,7 @@ import ( "github.com/fastly/cli/pkg/errors" "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // DeleteCommand calls the Fastly API to delete healthchecks. @@ -61,6 +62,8 @@ func NewDeleteCommand(parent argparser.Registerer, g *global.Data) *DeleteComman // Exec invokes the application logic for the command. func (c *DeleteCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.autoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/healthcheck/describe.go b/pkg/commands/healthcheck/describe.go index ca90a2ad3..bf34c82aa 100644 --- a/pkg/commands/healthcheck/describe.go +++ b/pkg/commands/healthcheck/describe.go @@ -64,7 +64,6 @@ func (c *DescribeCommand) Exec(_ io.Reader, out io.Writer) error { } serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ - AllowActiveLocked: true, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, Out: out, diff --git a/pkg/commands/healthcheck/list.go b/pkg/commands/healthcheck/list.go index f26f37f8e..77acbf0e9 100644 --- a/pkg/commands/healthcheck/list.go +++ b/pkg/commands/healthcheck/list.go @@ -63,7 +63,6 @@ func (c *ListCommand) Exec(_ io.Reader, out io.Writer) error { } serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ - AllowActiveLocked: true, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, Out: out, diff --git a/pkg/commands/healthcheck/update.go b/pkg/commands/healthcheck/update.go index bbc89a872..211632b31 100644 --- a/pkg/commands/healthcheck/update.go +++ b/pkg/commands/healthcheck/update.go @@ -9,6 +9,7 @@ import ( "github.com/fastly/cli/pkg/errors" "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // UpdateCommand calls the Fastly API to update healthchecks. @@ -86,6 +87,8 @@ func NewUpdateCommand(parent argparser.Registerer, g *global.Data) *UpdateComman // Exec invokes the application logic for the command. func (c *UpdateCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.autoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/logging/azureblob/create.go b/pkg/commands/logging/azureblob/create.go index ecd144812..1a4b1e787 100644 --- a/pkg/commands/logging/azureblob/create.go +++ b/pkg/commands/logging/azureblob/create.go @@ -12,6 +12,7 @@ import ( "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/manifest" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // CreateCommand calls the Fastly API to create an Azure Blob Storage logging endpoint. @@ -165,6 +166,8 @@ func (c *CreateCommand) ConstructInput(serviceID string, serviceVersion int) (*f // Exec invokes the application logic for the command. func (c *CreateCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.AutoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/logging/azureblob/delete.go b/pkg/commands/logging/azureblob/delete.go index a3031ae8f..bc37ff1b4 100644 --- a/pkg/commands/logging/azureblob/delete.go +++ b/pkg/commands/logging/azureblob/delete.go @@ -9,6 +9,7 @@ import ( "github.com/fastly/cli/pkg/errors" "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // DeleteCommand calls the Fastly API to delete an Azure Blob Storage logging endpoint. @@ -61,6 +62,8 @@ func NewDeleteCommand(parent argparser.Registerer, g *global.Data) *DeleteComman // Exec invokes the application logic for the command. func (c *DeleteCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.autoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/logging/azureblob/describe.go b/pkg/commands/logging/azureblob/describe.go index 3c94fd36b..f90c2a075 100644 --- a/pkg/commands/logging/azureblob/describe.go +++ b/pkg/commands/logging/azureblob/describe.go @@ -63,7 +63,6 @@ func (c *DescribeCommand) Exec(_ io.Reader, out io.Writer) error { } serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ - AllowActiveLocked: true, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, Out: out, diff --git a/pkg/commands/logging/azureblob/list.go b/pkg/commands/logging/azureblob/list.go index 4baa6e4be..eea494279 100644 --- a/pkg/commands/logging/azureblob/list.go +++ b/pkg/commands/logging/azureblob/list.go @@ -63,7 +63,6 @@ func (c *ListCommand) Exec(_ io.Reader, out io.Writer) error { } serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ - AllowActiveLocked: true, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, Out: out, diff --git a/pkg/commands/logging/azureblob/update.go b/pkg/commands/logging/azureblob/update.go index 89c7abc1d..07f023b15 100644 --- a/pkg/commands/logging/azureblob/update.go +++ b/pkg/commands/logging/azureblob/update.go @@ -11,6 +11,7 @@ import ( "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/manifest" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // UpdateCommand calls the Fastly API to update an Azure Blob Storage logging endpoint. @@ -163,6 +164,8 @@ func (c *UpdateCommand) ConstructInput(serviceID string, serviceVersion int) (*f // Exec invokes the application logic for the command. func (c *UpdateCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.AutoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/logging/bigquery/create.go b/pkg/commands/logging/bigquery/create.go index e1c254b29..56bcbc886 100644 --- a/pkg/commands/logging/bigquery/create.go +++ b/pkg/commands/logging/bigquery/create.go @@ -11,6 +11,7 @@ import ( "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/manifest" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // CreateCommand calls the Fastly API to create a BigQuery logging endpoint. @@ -137,6 +138,8 @@ func (c *CreateCommand) ConstructInput(serviceID string, serviceVersion int) (*f // Exec invokes the application logic for the command. func (c *CreateCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.AutoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/logging/bigquery/delete.go b/pkg/commands/logging/bigquery/delete.go index 1b969680d..93967497d 100644 --- a/pkg/commands/logging/bigquery/delete.go +++ b/pkg/commands/logging/bigquery/delete.go @@ -9,6 +9,7 @@ import ( "github.com/fastly/cli/pkg/errors" "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // DeleteCommand calls the Fastly API to delete a BigQuery logging endpoint. @@ -61,6 +62,8 @@ func NewDeleteCommand(parent argparser.Registerer, g *global.Data) *DeleteComman // Exec invokes the application logic for the command. func (c *DeleteCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.autoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/logging/bigquery/describe.go b/pkg/commands/logging/bigquery/describe.go index 2ef1e7c57..2500f8308 100644 --- a/pkg/commands/logging/bigquery/describe.go +++ b/pkg/commands/logging/bigquery/describe.go @@ -63,7 +63,6 @@ func (c *DescribeCommand) Exec(_ io.Reader, out io.Writer) error { } serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ - AllowActiveLocked: true, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, Out: out, diff --git a/pkg/commands/logging/bigquery/list.go b/pkg/commands/logging/bigquery/list.go index a52711457..bf5765828 100644 --- a/pkg/commands/logging/bigquery/list.go +++ b/pkg/commands/logging/bigquery/list.go @@ -63,7 +63,6 @@ func (c *ListCommand) Exec(_ io.Reader, out io.Writer) error { } serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ - AllowActiveLocked: true, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, Out: out, diff --git a/pkg/commands/logging/bigquery/update.go b/pkg/commands/logging/bigquery/update.go index 6b2a749ed..c1cb13207 100644 --- a/pkg/commands/logging/bigquery/update.go +++ b/pkg/commands/logging/bigquery/update.go @@ -11,6 +11,7 @@ import ( "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/manifest" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // UpdateCommand calls the Fastly API to update a BigQuery logging endpoint. @@ -140,6 +141,8 @@ func (c *UpdateCommand) ConstructInput(serviceID string, serviceVersion int) (*f // Exec invokes the application logic for the command. func (c *UpdateCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.AutoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/logging/cloudfiles/create.go b/pkg/commands/logging/cloudfiles/create.go index 8fdc0314c..c16e7027c 100644 --- a/pkg/commands/logging/cloudfiles/create.go +++ b/pkg/commands/logging/cloudfiles/create.go @@ -12,6 +12,7 @@ import ( "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/manifest" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // CreateCommand calls the Fastly API to create a Cloudfiles logging endpoint. @@ -165,6 +166,8 @@ func (c *CreateCommand) ConstructInput(serviceID string, serviceVersion int) (*f // Exec invokes the application logic for the command. func (c *CreateCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.AutoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/logging/cloudfiles/delete.go b/pkg/commands/logging/cloudfiles/delete.go index d9ae12958..df5356828 100644 --- a/pkg/commands/logging/cloudfiles/delete.go +++ b/pkg/commands/logging/cloudfiles/delete.go @@ -9,6 +9,7 @@ import ( "github.com/fastly/cli/pkg/errors" "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // DeleteCommand calls the Fastly API to delete a Cloudfiles logging endpoint. @@ -61,6 +62,8 @@ func NewDeleteCommand(parent argparser.Registerer, g *global.Data) *DeleteComman // Exec invokes the application logic for the command. func (c *DeleteCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.autoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/logging/cloudfiles/describe.go b/pkg/commands/logging/cloudfiles/describe.go index 55a0f7ee0..71a2bcc90 100644 --- a/pkg/commands/logging/cloudfiles/describe.go +++ b/pkg/commands/logging/cloudfiles/describe.go @@ -63,7 +63,6 @@ func (c *DescribeCommand) Exec(_ io.Reader, out io.Writer) error { } serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ - AllowActiveLocked: true, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, Out: out, diff --git a/pkg/commands/logging/cloudfiles/list.go b/pkg/commands/logging/cloudfiles/list.go index 6d42d589c..13c33156d 100644 --- a/pkg/commands/logging/cloudfiles/list.go +++ b/pkg/commands/logging/cloudfiles/list.go @@ -63,7 +63,6 @@ func (c *ListCommand) Exec(_ io.Reader, out io.Writer) error { } serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ - AllowActiveLocked: true, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, Out: out, diff --git a/pkg/commands/logging/cloudfiles/update.go b/pkg/commands/logging/cloudfiles/update.go index f1adc8f1c..bbb4be610 100644 --- a/pkg/commands/logging/cloudfiles/update.go +++ b/pkg/commands/logging/cloudfiles/update.go @@ -11,6 +11,7 @@ import ( "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/manifest" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // UpdateCommand calls the Fastly API to update a Cloudfiles logging endpoint. @@ -176,6 +177,8 @@ func (c *UpdateCommand) ConstructInput(serviceID string, serviceVersion int) (*f // Exec invokes the application logic for the command. func (c *UpdateCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.AutoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/logging/datadog/create.go b/pkg/commands/logging/datadog/create.go index 1c1240713..5a4b2550b 100644 --- a/pkg/commands/logging/datadog/create.go +++ b/pkg/commands/logging/datadog/create.go @@ -11,6 +11,7 @@ import ( "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/manifest" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // CreateCommand calls the Fastly API to create a Datadog logging endpoint. @@ -116,6 +117,8 @@ func (c *CreateCommand) ConstructInput(serviceID string, serviceVersion int) (*f // Exec invokes the application logic for the command. func (c *CreateCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.AutoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/logging/datadog/delete.go b/pkg/commands/logging/datadog/delete.go index 2dc61c178..c41d7e6ff 100644 --- a/pkg/commands/logging/datadog/delete.go +++ b/pkg/commands/logging/datadog/delete.go @@ -9,6 +9,7 @@ import ( "github.com/fastly/cli/pkg/errors" "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // DeleteCommand calls the Fastly API to delete a Datadog logging endpoint. @@ -61,6 +62,8 @@ func NewDeleteCommand(parent argparser.Registerer, g *global.Data) *DeleteComman // Exec invokes the application logic for the command. func (c *DeleteCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.autoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/logging/datadog/describe.go b/pkg/commands/logging/datadog/describe.go index a6264c338..a6337cd6b 100644 --- a/pkg/commands/logging/datadog/describe.go +++ b/pkg/commands/logging/datadog/describe.go @@ -63,7 +63,6 @@ func (c *DescribeCommand) Exec(_ io.Reader, out io.Writer) error { } serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ - AllowActiveLocked: true, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, Out: out, diff --git a/pkg/commands/logging/datadog/list.go b/pkg/commands/logging/datadog/list.go index f73447f58..e003ca088 100644 --- a/pkg/commands/logging/datadog/list.go +++ b/pkg/commands/logging/datadog/list.go @@ -63,7 +63,6 @@ func (c *ListCommand) Exec(_ io.Reader, out io.Writer) error { } serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ - AllowActiveLocked: true, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, Out: out, diff --git a/pkg/commands/logging/datadog/update.go b/pkg/commands/logging/datadog/update.go index c97966bf8..d81488774 100644 --- a/pkg/commands/logging/datadog/update.go +++ b/pkg/commands/logging/datadog/update.go @@ -11,6 +11,7 @@ import ( "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/manifest" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // UpdateCommand calls the Fastly API to update a Datadog logging endpoint. @@ -121,6 +122,8 @@ func (c *UpdateCommand) ConstructInput(serviceID string, serviceVersion int) (*f // Exec invokes the application logic for the command. func (c *UpdateCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.AutoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/logging/digitalocean/create.go b/pkg/commands/logging/digitalocean/create.go index 297776353..4ed07fcca 100644 --- a/pkg/commands/logging/digitalocean/create.go +++ b/pkg/commands/logging/digitalocean/create.go @@ -12,6 +12,7 @@ import ( "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/manifest" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // CreateCommand calls the Fastly API to create a DigitalOcean Spaces logging endpoint. @@ -175,6 +176,8 @@ func (c *CreateCommand) ConstructInput(serviceID string, serviceVersion int) (*f // Exec invokes the application logic for the command. func (c *CreateCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.AutoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/logging/digitalocean/delete.go b/pkg/commands/logging/digitalocean/delete.go index e5acb7cbd..d019a47ac 100644 --- a/pkg/commands/logging/digitalocean/delete.go +++ b/pkg/commands/logging/digitalocean/delete.go @@ -9,6 +9,7 @@ import ( "github.com/fastly/cli/pkg/errors" "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // DeleteCommand calls the Fastly API to delete a DigitalOcean Spaces logging endpoint. @@ -61,6 +62,8 @@ func NewDeleteCommand(parent argparser.Registerer, g *global.Data) *DeleteComman // Exec invokes the application logic for the command. func (c *DeleteCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.autoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/logging/digitalocean/describe.go b/pkg/commands/logging/digitalocean/describe.go index fa42d7d5c..c4cf5d97f 100644 --- a/pkg/commands/logging/digitalocean/describe.go +++ b/pkg/commands/logging/digitalocean/describe.go @@ -63,7 +63,6 @@ func (c *DescribeCommand) Exec(_ io.Reader, out io.Writer) error { } serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ - AllowActiveLocked: true, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, Out: out, diff --git a/pkg/commands/logging/digitalocean/list.go b/pkg/commands/logging/digitalocean/list.go index c27da6fe8..eb8fa8a42 100644 --- a/pkg/commands/logging/digitalocean/list.go +++ b/pkg/commands/logging/digitalocean/list.go @@ -63,7 +63,6 @@ func (c *ListCommand) Exec(_ io.Reader, out io.Writer) error { } serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ - AllowActiveLocked: true, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, Out: out, diff --git a/pkg/commands/logging/digitalocean/update.go b/pkg/commands/logging/digitalocean/update.go index 9b2161d1d..bff0352f8 100644 --- a/pkg/commands/logging/digitalocean/update.go +++ b/pkg/commands/logging/digitalocean/update.go @@ -11,6 +11,7 @@ import ( "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/manifest" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // UpdateCommand calls the Fastly API to update a DigitalOcean Spaces logging endpoint. @@ -176,6 +177,8 @@ func (c *UpdateCommand) ConstructInput(serviceID string, serviceVersion int) (*f // Exec invokes the application logic for the command. func (c *UpdateCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.AutoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/logging/elasticsearch/create.go b/pkg/commands/logging/elasticsearch/create.go index 3621d4613..fea35814f 100644 --- a/pkg/commands/logging/elasticsearch/create.go +++ b/pkg/commands/logging/elasticsearch/create.go @@ -11,6 +11,7 @@ import ( "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/manifest" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // CreateCommand calls the Fastly API to create an Elasticsearch logging endpoint. @@ -167,6 +168,8 @@ func (c *CreateCommand) ConstructInput(serviceID string, serviceVersion int) (*f // Exec invokes the application logic for the command. func (c *CreateCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.AutoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/logging/elasticsearch/delete.go b/pkg/commands/logging/elasticsearch/delete.go index a36d3ee6e..253fce33f 100644 --- a/pkg/commands/logging/elasticsearch/delete.go +++ b/pkg/commands/logging/elasticsearch/delete.go @@ -9,6 +9,7 @@ import ( "github.com/fastly/cli/pkg/errors" "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // DeleteCommand calls the Fastly API to delete an Elasticsearch logging endpoint. @@ -61,6 +62,8 @@ func NewDeleteCommand(parent argparser.Registerer, g *global.Data) *DeleteComman // Exec invokes the application logic for the command. func (c *DeleteCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.autoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/logging/elasticsearch/describe.go b/pkg/commands/logging/elasticsearch/describe.go index d4690cdcc..b0d2b6f30 100644 --- a/pkg/commands/logging/elasticsearch/describe.go +++ b/pkg/commands/logging/elasticsearch/describe.go @@ -63,7 +63,6 @@ func (c *DescribeCommand) Exec(_ io.Reader, out io.Writer) error { } serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ - AllowActiveLocked: true, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, Out: out, diff --git a/pkg/commands/logging/elasticsearch/list.go b/pkg/commands/logging/elasticsearch/list.go index 5ab5a475b..ddb62908d 100644 --- a/pkg/commands/logging/elasticsearch/list.go +++ b/pkg/commands/logging/elasticsearch/list.go @@ -63,7 +63,6 @@ func (c *ListCommand) Exec(_ io.Reader, out io.Writer) error { } serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ - AllowActiveLocked: true, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, Out: out, diff --git a/pkg/commands/logging/elasticsearch/update.go b/pkg/commands/logging/elasticsearch/update.go index 3b7332160..24f57344e 100644 --- a/pkg/commands/logging/elasticsearch/update.go +++ b/pkg/commands/logging/elasticsearch/update.go @@ -11,6 +11,7 @@ import ( "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/manifest" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // UpdateCommand calls the Fastly API to update an Elasticsearch logging endpoint. @@ -173,6 +174,8 @@ func (c *UpdateCommand) ConstructInput(serviceID string, serviceVersion int) (*f // Exec invokes the application logic for the command. func (c *UpdateCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.AutoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/logging/ftp/create.go b/pkg/commands/logging/ftp/create.go index 94da7aec0..80e3a0317 100644 --- a/pkg/commands/logging/ftp/create.go +++ b/pkg/commands/logging/ftp/create.go @@ -12,6 +12,7 @@ import ( "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/manifest" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // CreateCommand calls the Fastly API to create an FTP logging endpoint. @@ -163,6 +164,8 @@ func (c *CreateCommand) ConstructInput(serviceID string, serviceVersion int) (*f // Exec invokes the application logic for the command. func (c *CreateCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.AutoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/logging/ftp/delete.go b/pkg/commands/logging/ftp/delete.go index 0eafdaaee..0f872b33e 100644 --- a/pkg/commands/logging/ftp/delete.go +++ b/pkg/commands/logging/ftp/delete.go @@ -9,6 +9,7 @@ import ( "github.com/fastly/cli/pkg/errors" "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // DeleteCommand calls the Fastly API to delete an FTP logging endpoint. @@ -61,6 +62,8 @@ func NewDeleteCommand(parent argparser.Registerer, g *global.Data) *DeleteComman // Exec invokes the application logic for the command. func (c *DeleteCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.autoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/logging/ftp/describe.go b/pkg/commands/logging/ftp/describe.go index 18fcac5e9..7c8817263 100644 --- a/pkg/commands/logging/ftp/describe.go +++ b/pkg/commands/logging/ftp/describe.go @@ -59,7 +59,6 @@ func (c *DescribeCommand) Exec(_ io.Reader, out io.Writer) error { } serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ - AllowActiveLocked: true, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, Out: out, diff --git a/pkg/commands/logging/ftp/list.go b/pkg/commands/logging/ftp/list.go index 657e44815..1f7b5b0eb 100644 --- a/pkg/commands/logging/ftp/list.go +++ b/pkg/commands/logging/ftp/list.go @@ -63,7 +63,6 @@ func (c *ListCommand) Exec(_ io.Reader, out io.Writer) error { } serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ - AllowActiveLocked: true, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, Out: out, diff --git a/pkg/commands/logging/ftp/update.go b/pkg/commands/logging/ftp/update.go index 97585a9c0..ec1a07c51 100644 --- a/pkg/commands/logging/ftp/update.go +++ b/pkg/commands/logging/ftp/update.go @@ -11,6 +11,7 @@ import ( "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/manifest" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // UpdateCommand calls the Fastly API to update an FTP logging endpoint. @@ -170,6 +171,8 @@ func (c *UpdateCommand) ConstructInput(serviceID string, serviceVersion int) (*f // Exec invokes the application logic for the command. func (c *UpdateCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.AutoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/logging/gcs/create.go b/pkg/commands/logging/gcs/create.go index f3ea6721c..a19d91489 100644 --- a/pkg/commands/logging/gcs/create.go +++ b/pkg/commands/logging/gcs/create.go @@ -12,6 +12,7 @@ import ( "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/manifest" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // CreateCommand calls the Fastly API to create a GCS logging endpoint. @@ -164,6 +165,8 @@ func (c *CreateCommand) ConstructInput(serviceID string, serviceVersion int) (*f // Exec invokes the application logic for the command. func (c *CreateCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.AutoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/logging/gcs/delete.go b/pkg/commands/logging/gcs/delete.go index 6cdedb810..83e67069e 100644 --- a/pkg/commands/logging/gcs/delete.go +++ b/pkg/commands/logging/gcs/delete.go @@ -9,6 +9,7 @@ import ( "github.com/fastly/cli/pkg/errors" "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // DeleteCommand calls the Fastly API to delete a GCS logging endpoint. @@ -61,6 +62,8 @@ func NewDeleteCommand(parent argparser.Registerer, g *global.Data) *DeleteComman // Exec invokes the application logic for the command. func (c *DeleteCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.autoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/logging/gcs/describe.go b/pkg/commands/logging/gcs/describe.go index c33a1c700..bf35842e2 100644 --- a/pkg/commands/logging/gcs/describe.go +++ b/pkg/commands/logging/gcs/describe.go @@ -63,7 +63,6 @@ func (c *DescribeCommand) Exec(_ io.Reader, out io.Writer) error { } serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ - AllowActiveLocked: true, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, Out: out, diff --git a/pkg/commands/logging/gcs/list.go b/pkg/commands/logging/gcs/list.go index 571d7fd32..94067023c 100644 --- a/pkg/commands/logging/gcs/list.go +++ b/pkg/commands/logging/gcs/list.go @@ -63,7 +63,6 @@ func (c *ListCommand) Exec(_ io.Reader, out io.Writer) error { } serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ - AllowActiveLocked: true, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, Out: out, diff --git a/pkg/commands/logging/gcs/update.go b/pkg/commands/logging/gcs/update.go index 77d3541aa..a5c4fc968 100644 --- a/pkg/commands/logging/gcs/update.go +++ b/pkg/commands/logging/gcs/update.go @@ -11,6 +11,7 @@ import ( "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/manifest" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // UpdateCommand calls the Fastly API to update a GCS logging endpoint. @@ -160,6 +161,8 @@ func (c *UpdateCommand) ConstructInput(serviceID string, serviceVersion int) (*f // Exec invokes the application logic for the command. func (c *UpdateCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.AutoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/logging/googlepubsub/create.go b/pkg/commands/logging/googlepubsub/create.go index f65a53235..5c279c374 100644 --- a/pkg/commands/logging/googlepubsub/create.go +++ b/pkg/commands/logging/googlepubsub/create.go @@ -11,6 +11,7 @@ import ( "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/manifest" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // CreateCommand calls the Fastly API to create a Google Cloud Pub/Sub logging endpoint. @@ -127,6 +128,8 @@ func (c *CreateCommand) ConstructInput(serviceID string, serviceVersion int) (*f // Exec invokes the application logic for the command. func (c *CreateCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.AutoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/logging/googlepubsub/delete.go b/pkg/commands/logging/googlepubsub/delete.go index 1df2ea017..2c0ad0def 100644 --- a/pkg/commands/logging/googlepubsub/delete.go +++ b/pkg/commands/logging/googlepubsub/delete.go @@ -9,6 +9,7 @@ import ( "github.com/fastly/cli/pkg/errors" "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // DeleteCommand calls the Fastly API to delete a Google Cloud Pub/Sub logging endpoint. @@ -61,6 +62,8 @@ func NewDeleteCommand(parent argparser.Registerer, g *global.Data) *DeleteComman // Exec invokes the application logic for the command. func (c *DeleteCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.autoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/logging/googlepubsub/describe.go b/pkg/commands/logging/googlepubsub/describe.go index 8f6094c02..791b0dca8 100644 --- a/pkg/commands/logging/googlepubsub/describe.go +++ b/pkg/commands/logging/googlepubsub/describe.go @@ -63,7 +63,6 @@ func (c *DescribeCommand) Exec(_ io.Reader, out io.Writer) error { } serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ - AllowActiveLocked: true, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, Out: out, diff --git a/pkg/commands/logging/googlepubsub/list.go b/pkg/commands/logging/googlepubsub/list.go index 2e764d855..82abe6ef9 100644 --- a/pkg/commands/logging/googlepubsub/list.go +++ b/pkg/commands/logging/googlepubsub/list.go @@ -63,7 +63,6 @@ func (c *ListCommand) Exec(_ io.Reader, out io.Writer) error { } serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ - AllowActiveLocked: true, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, Out: out, diff --git a/pkg/commands/logging/googlepubsub/update.go b/pkg/commands/logging/googlepubsub/update.go index 939723bd2..4d139e3e5 100644 --- a/pkg/commands/logging/googlepubsub/update.go +++ b/pkg/commands/logging/googlepubsub/update.go @@ -11,6 +11,7 @@ import ( "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/manifest" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // UpdateCommand calls the Fastly API to update a Google Cloud Pub/Sub logging endpoint. @@ -130,6 +131,8 @@ func (c *UpdateCommand) ConstructInput(serviceID string, serviceVersion int) (*f // Exec invokes the application logic for the command. func (c *UpdateCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.AutoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/logging/heroku/create.go b/pkg/commands/logging/heroku/create.go index 904058e6a..be33837f2 100644 --- a/pkg/commands/logging/heroku/create.go +++ b/pkg/commands/logging/heroku/create.go @@ -11,6 +11,7 @@ import ( "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/manifest" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // CreateCommand calls the Fastly API to create a Heroku logging endpoint. @@ -115,6 +116,8 @@ func (c *CreateCommand) ConstructInput(serviceID string, serviceVersion int) (*f // Exec invokes the application logic for the command. func (c *CreateCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.AutoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/logging/heroku/delete.go b/pkg/commands/logging/heroku/delete.go index 6988e5ab7..a997fe97f 100644 --- a/pkg/commands/logging/heroku/delete.go +++ b/pkg/commands/logging/heroku/delete.go @@ -9,6 +9,7 @@ import ( "github.com/fastly/cli/pkg/errors" "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // DeleteCommand calls the Fastly API to delete a Heroku logging endpoint. @@ -61,6 +62,8 @@ func NewDeleteCommand(parent argparser.Registerer, g *global.Data) *DeleteComman // Exec invokes the application logic for the command. func (c *DeleteCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.autoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/logging/heroku/describe.go b/pkg/commands/logging/heroku/describe.go index 4566416bc..d4737c421 100644 --- a/pkg/commands/logging/heroku/describe.go +++ b/pkg/commands/logging/heroku/describe.go @@ -63,7 +63,6 @@ func (c *DescribeCommand) Exec(_ io.Reader, out io.Writer) error { } serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ - AllowActiveLocked: true, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, Out: out, diff --git a/pkg/commands/logging/heroku/list.go b/pkg/commands/logging/heroku/list.go index 367f9f1e0..1cab3749d 100644 --- a/pkg/commands/logging/heroku/list.go +++ b/pkg/commands/logging/heroku/list.go @@ -63,7 +63,6 @@ func (c *ListCommand) Exec(_ io.Reader, out io.Writer) error { } serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ - AllowActiveLocked: true, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, Out: out, diff --git a/pkg/commands/logging/heroku/update.go b/pkg/commands/logging/heroku/update.go index f5ef721b3..d6fce6b83 100644 --- a/pkg/commands/logging/heroku/update.go +++ b/pkg/commands/logging/heroku/update.go @@ -11,6 +11,7 @@ import ( "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/manifest" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // UpdateCommand calls the Fastly API to update a Heroku logging endpoint. @@ -121,6 +122,8 @@ func (c *UpdateCommand) ConstructInput(serviceID string, serviceVersion int) (*f // Exec invokes the application logic for the command. func (c *UpdateCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.AutoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/logging/honeycomb/create.go b/pkg/commands/logging/honeycomb/create.go index 0d96a30f8..e51c02c2f 100644 --- a/pkg/commands/logging/honeycomb/create.go +++ b/pkg/commands/logging/honeycomb/create.go @@ -11,6 +11,7 @@ import ( "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/manifest" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // CreateCommand calls the Fastly API to create a Honeycomb logging endpoint. @@ -115,6 +116,8 @@ func (c *CreateCommand) ConstructInput(serviceID string, serviceVersion int) (*f // Exec invokes the application logic for the command. func (c *CreateCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.AutoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/logging/honeycomb/delete.go b/pkg/commands/logging/honeycomb/delete.go index e747363d9..239a22b5e 100644 --- a/pkg/commands/logging/honeycomb/delete.go +++ b/pkg/commands/logging/honeycomb/delete.go @@ -9,6 +9,7 @@ import ( "github.com/fastly/cli/pkg/errors" "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // DeleteCommand calls the Fastly API to delete a Honeycomb logging endpoint. @@ -61,6 +62,8 @@ func NewDeleteCommand(parent argparser.Registerer, g *global.Data) *DeleteComman // Exec invokes the application logic for the command. func (c *DeleteCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.autoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/logging/honeycomb/describe.go b/pkg/commands/logging/honeycomb/describe.go index e4dba3ab5..9ea8579df 100644 --- a/pkg/commands/logging/honeycomb/describe.go +++ b/pkg/commands/logging/honeycomb/describe.go @@ -63,7 +63,6 @@ func (c *DescribeCommand) Exec(_ io.Reader, out io.Writer) error { } serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ - AllowActiveLocked: true, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, Out: out, diff --git a/pkg/commands/logging/honeycomb/list.go b/pkg/commands/logging/honeycomb/list.go index af590e3b7..f62345e91 100644 --- a/pkg/commands/logging/honeycomb/list.go +++ b/pkg/commands/logging/honeycomb/list.go @@ -63,7 +63,6 @@ func (c *ListCommand) Exec(_ io.Reader, out io.Writer) error { } serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ - AllowActiveLocked: true, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, Out: out, diff --git a/pkg/commands/logging/honeycomb/update.go b/pkg/commands/logging/honeycomb/update.go index 1d2fc9f03..464984de0 100644 --- a/pkg/commands/logging/honeycomb/update.go +++ b/pkg/commands/logging/honeycomb/update.go @@ -11,6 +11,7 @@ import ( "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/manifest" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // UpdateCommand calls the Fastly API to update a Honeycomb logging endpoint. @@ -121,6 +122,8 @@ func (c *UpdateCommand) ConstructInput(serviceID string, serviceVersion int) (*f // Exec invokes the application logic for the command. func (c *UpdateCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.AutoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/logging/https/create.go b/pkg/commands/logging/https/create.go index 2aab8a461..db34e3217 100644 --- a/pkg/commands/logging/https/create.go +++ b/pkg/commands/logging/https/create.go @@ -11,6 +11,7 @@ import ( "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/manifest" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // CreateCommand calls the Fastly API to create an HTTPS logging endpoint. @@ -182,6 +183,8 @@ func (c *CreateCommand) ConstructInput(serviceID string, serviceVersion int) (*f // Exec invokes the application logic for the command. func (c *CreateCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.AutoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/logging/https/delete.go b/pkg/commands/logging/https/delete.go index a7fc11aac..69a28be74 100644 --- a/pkg/commands/logging/https/delete.go +++ b/pkg/commands/logging/https/delete.go @@ -9,6 +9,7 @@ import ( "github.com/fastly/cli/pkg/errors" "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // DeleteCommand calls the Fastly API to delete an HTTPS logging endpoint. @@ -61,6 +62,8 @@ func NewDeleteCommand(parent argparser.Registerer, g *global.Data) *DeleteComman // Exec invokes the application logic for the command. func (c *DeleteCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.autoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/logging/https/describe.go b/pkg/commands/logging/https/describe.go index 81253849f..1ba8048d6 100644 --- a/pkg/commands/logging/https/describe.go +++ b/pkg/commands/logging/https/describe.go @@ -63,7 +63,6 @@ func (c *DescribeCommand) Exec(_ io.Reader, out io.Writer) error { } serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ - AllowActiveLocked: true, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, Out: out, diff --git a/pkg/commands/logging/https/list.go b/pkg/commands/logging/https/list.go index 94f8f2234..5650bd8e5 100644 --- a/pkg/commands/logging/https/list.go +++ b/pkg/commands/logging/https/list.go @@ -63,7 +63,6 @@ func (c *ListCommand) Exec(_ io.Reader, out io.Writer) error { } serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ - AllowActiveLocked: true, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, Out: out, diff --git a/pkg/commands/logging/https/update.go b/pkg/commands/logging/https/update.go index 28214dfad..2cca30b90 100644 --- a/pkg/commands/logging/https/update.go +++ b/pkg/commands/logging/https/update.go @@ -11,6 +11,7 @@ import ( "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/manifest" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // UpdateCommand calls the Fastly API to update an HTTPS logging endpoint. @@ -187,6 +188,8 @@ func (c *UpdateCommand) ConstructInput(serviceID string, serviceVersion int) (*f // Exec invokes the application logic for the command. func (c *UpdateCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.AutoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/logging/kafka/create.go b/pkg/commands/logging/kafka/create.go index 3be1af72c..3b484dcbd 100644 --- a/pkg/commands/logging/kafka/create.go +++ b/pkg/commands/logging/kafka/create.go @@ -12,6 +12,7 @@ import ( "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/manifest" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // CreateCommand calls the Fastly API to create a Kafka logging endpoint. @@ -198,6 +199,8 @@ func (c *CreateCommand) ConstructInput(serviceID string, serviceVersion int) (*f // Exec invokes the application logic for the command. func (c *CreateCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.AutoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/logging/kafka/delete.go b/pkg/commands/logging/kafka/delete.go index f73146d55..db135ec1f 100644 --- a/pkg/commands/logging/kafka/delete.go +++ b/pkg/commands/logging/kafka/delete.go @@ -9,6 +9,7 @@ import ( "github.com/fastly/cli/pkg/errors" "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // DeleteCommand calls the Fastly API to delete a Kafka logging endpoint. @@ -61,6 +62,8 @@ func NewDeleteCommand(parent argparser.Registerer, g *global.Data) *DeleteComman // Exec invokes the application logic for the command. func (c *DeleteCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.autoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/logging/kafka/describe.go b/pkg/commands/logging/kafka/describe.go index b7faadce7..8594f81e4 100644 --- a/pkg/commands/logging/kafka/describe.go +++ b/pkg/commands/logging/kafka/describe.go @@ -63,7 +63,6 @@ func (c *DescribeCommand) Exec(_ io.Reader, out io.Writer) error { } serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ - AllowActiveLocked: true, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, Out: out, diff --git a/pkg/commands/logging/kafka/list.go b/pkg/commands/logging/kafka/list.go index 1e7cc8d0a..0b911be3a 100644 --- a/pkg/commands/logging/kafka/list.go +++ b/pkg/commands/logging/kafka/list.go @@ -63,7 +63,6 @@ func (c *ListCommand) Exec(_ io.Reader, out io.Writer) error { } serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ - AllowActiveLocked: true, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, Out: out, diff --git a/pkg/commands/logging/kafka/update.go b/pkg/commands/logging/kafka/update.go index 994877ad3..cb2b2b2ed 100644 --- a/pkg/commands/logging/kafka/update.go +++ b/pkg/commands/logging/kafka/update.go @@ -12,6 +12,7 @@ import ( "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/manifest" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // UpdateCommand calls the Fastly API to update a Kafka logging endpoint. @@ -211,6 +212,8 @@ func (c *UpdateCommand) ConstructInput(serviceID string, serviceVersion int) (*f // Exec invokes the application logic for the command. func (c *UpdateCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.AutoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/logging/kinesis/create.go b/pkg/commands/logging/kinesis/create.go index 66a60e6d8..c9e40e397 100644 --- a/pkg/commands/logging/kinesis/create.go +++ b/pkg/commands/logging/kinesis/create.go @@ -12,6 +12,7 @@ import ( "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/manifest" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // CreateCommand calls the Fastly API to create an Amazon Kinesis logging endpoint. @@ -158,6 +159,8 @@ func (c *CreateCommand) ConstructInput(serviceID string, serviceVersion int) (*f // Exec invokes the application logic for the command. func (c *CreateCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.AutoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/logging/kinesis/delete.go b/pkg/commands/logging/kinesis/delete.go index 3e8e834c5..7ba75a111 100644 --- a/pkg/commands/logging/kinesis/delete.go +++ b/pkg/commands/logging/kinesis/delete.go @@ -9,6 +9,7 @@ import ( "github.com/fastly/cli/pkg/errors" "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // DeleteCommand calls the Fastly API to delete an Amazon Kinesis logging endpoint. @@ -62,6 +63,8 @@ func NewDeleteCommand(parent argparser.Registerer, g *global.Data) *DeleteComman // Exec invokes the application logic for the command. func (c *DeleteCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.autoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/logging/kinesis/describe.go b/pkg/commands/logging/kinesis/describe.go index d5d3debe4..6efea8d31 100644 --- a/pkg/commands/logging/kinesis/describe.go +++ b/pkg/commands/logging/kinesis/describe.go @@ -63,7 +63,6 @@ func (c *DescribeCommand) Exec(_ io.Reader, out io.Writer) error { } serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ - AllowActiveLocked: true, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, Out: out, diff --git a/pkg/commands/logging/kinesis/list.go b/pkg/commands/logging/kinesis/list.go index c923260af..ec04e5cbd 100644 --- a/pkg/commands/logging/kinesis/list.go +++ b/pkg/commands/logging/kinesis/list.go @@ -63,7 +63,6 @@ func (c *ListCommand) Exec(_ io.Reader, out io.Writer) error { } serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ - AllowActiveLocked: true, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, Out: out, diff --git a/pkg/commands/logging/kinesis/update.go b/pkg/commands/logging/kinesis/update.go index 32395cb4c..06ffe8924 100644 --- a/pkg/commands/logging/kinesis/update.go +++ b/pkg/commands/logging/kinesis/update.go @@ -11,6 +11,7 @@ import ( "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/manifest" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // UpdateCommand calls the Fastly API to update an Amazon Kinesis logging endpoint. @@ -139,6 +140,8 @@ func (c *UpdateCommand) ConstructInput(serviceID string, serviceVersion int) (*f // Exec invokes the application logic for the command. func (c *UpdateCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.AutoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/logging/loggly/create.go b/pkg/commands/logging/loggly/create.go index 798f2d847..166122337 100644 --- a/pkg/commands/logging/loggly/create.go +++ b/pkg/commands/logging/loggly/create.go @@ -11,6 +11,7 @@ import ( "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/manifest" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // CreateCommand calls the Fastly API to create a Loggly logging endpoint. @@ -110,6 +111,8 @@ func (c *CreateCommand) ConstructInput(serviceID string, serviceVersion int) (*f // Exec invokes the application logic for the command. func (c *CreateCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.AutoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/logging/loggly/delete.go b/pkg/commands/logging/loggly/delete.go index be1ec6a1d..a7763d1c6 100644 --- a/pkg/commands/logging/loggly/delete.go +++ b/pkg/commands/logging/loggly/delete.go @@ -9,6 +9,7 @@ import ( "github.com/fastly/cli/pkg/errors" "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // DeleteCommand calls the Fastly API to delete a Loggly logging endpoint. @@ -61,6 +62,8 @@ func NewDeleteCommand(parent argparser.Registerer, g *global.Data) *DeleteComman // Exec invokes the application logic for the command. func (c *DeleteCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.autoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/logging/loggly/describe.go b/pkg/commands/logging/loggly/describe.go index af44f3d71..43591b86f 100644 --- a/pkg/commands/logging/loggly/describe.go +++ b/pkg/commands/logging/loggly/describe.go @@ -63,7 +63,6 @@ func (c *DescribeCommand) Exec(_ io.Reader, out io.Writer) error { } serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ - AllowActiveLocked: true, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, Out: out, diff --git a/pkg/commands/logging/loggly/list.go b/pkg/commands/logging/loggly/list.go index 749fca048..fed95c650 100644 --- a/pkg/commands/logging/loggly/list.go +++ b/pkg/commands/logging/loggly/list.go @@ -63,7 +63,6 @@ func (c *ListCommand) Exec(_ io.Reader, out io.Writer) error { } serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ - AllowActiveLocked: true, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, Out: out, diff --git a/pkg/commands/logging/loggly/update.go b/pkg/commands/logging/loggly/update.go index 9fb4d8b20..b5c9038bd 100644 --- a/pkg/commands/logging/loggly/update.go +++ b/pkg/commands/logging/loggly/update.go @@ -11,6 +11,7 @@ import ( "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/manifest" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // UpdateCommand calls the Fastly API to update a Loggly logging endpoint. @@ -115,6 +116,8 @@ func (c *UpdateCommand) ConstructInput(serviceID string, serviceVersion int) (*f // Exec invokes the application logic for the command. func (c *UpdateCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.AutoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/logging/logshuttle/create.go b/pkg/commands/logging/logshuttle/create.go index e8b85423a..ef309c180 100644 --- a/pkg/commands/logging/logshuttle/create.go +++ b/pkg/commands/logging/logshuttle/create.go @@ -11,6 +11,7 @@ import ( "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/manifest" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // CreateCommand calls the Fastly API to create a Logshuttle logging endpoint. @@ -115,6 +116,8 @@ func (c *CreateCommand) ConstructInput(serviceID string, serviceVersion int) (*f // Exec invokes the application logic for the command. func (c *CreateCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.AutoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/logging/logshuttle/delete.go b/pkg/commands/logging/logshuttle/delete.go index c11f29d9d..2f10edbf4 100644 --- a/pkg/commands/logging/logshuttle/delete.go +++ b/pkg/commands/logging/logshuttle/delete.go @@ -9,6 +9,7 @@ import ( "github.com/fastly/cli/pkg/errors" "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // DeleteCommand calls the Fastly API to delete a Logshuttle logging endpoint. @@ -61,6 +62,8 @@ func NewDeleteCommand(parent argparser.Registerer, g *global.Data) *DeleteComman // Exec invokes the application logic for the command. func (c *DeleteCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.autoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/logging/logshuttle/describe.go b/pkg/commands/logging/logshuttle/describe.go index ecf5224c8..3914a48f6 100644 --- a/pkg/commands/logging/logshuttle/describe.go +++ b/pkg/commands/logging/logshuttle/describe.go @@ -63,7 +63,6 @@ func (c *DescribeCommand) Exec(_ io.Reader, out io.Writer) error { } serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ - AllowActiveLocked: true, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, Out: out, diff --git a/pkg/commands/logging/logshuttle/list.go b/pkg/commands/logging/logshuttle/list.go index 26d49fad1..41b05cc45 100644 --- a/pkg/commands/logging/logshuttle/list.go +++ b/pkg/commands/logging/logshuttle/list.go @@ -63,7 +63,6 @@ func (c *ListCommand) Exec(_ io.Reader, out io.Writer) error { } serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ - AllowActiveLocked: true, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, Out: out, diff --git a/pkg/commands/logging/logshuttle/update.go b/pkg/commands/logging/logshuttle/update.go index 9235f35fd..3751eaf32 100644 --- a/pkg/commands/logging/logshuttle/update.go +++ b/pkg/commands/logging/logshuttle/update.go @@ -11,6 +11,7 @@ import ( "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/manifest" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // UpdateCommand calls the Fastly API to update a Logshuttle logging endpoint. @@ -122,6 +123,8 @@ func (c *UpdateCommand) ConstructInput(serviceID string, serviceVersion int) (*f // Exec invokes the application logic for the command. func (c *UpdateCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.AutoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/logging/newrelic/create.go b/pkg/commands/logging/newrelic/create.go index d5220865f..783a25e91 100644 --- a/pkg/commands/logging/newrelic/create.go +++ b/pkg/commands/logging/newrelic/create.go @@ -10,6 +10,7 @@ import ( "github.com/fastly/cli/pkg/errors" "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // CreateCommand calls the Fastly API to create an appropriate resource. @@ -79,6 +80,8 @@ func NewCreateCommand(parent argparser.Registerer, g *global.Data) *CreateComman // Exec invokes the application logic for the command. func (c *CreateCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.autoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/logging/newrelic/delete.go b/pkg/commands/logging/newrelic/delete.go index fd924036d..20ff47592 100644 --- a/pkg/commands/logging/newrelic/delete.go +++ b/pkg/commands/logging/newrelic/delete.go @@ -9,6 +9,7 @@ import ( "github.com/fastly/cli/pkg/errors" "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // NewDeleteCommand returns a usable command registered under the parent. @@ -63,6 +64,8 @@ type DeleteCommand struct { // Exec invokes the application logic for the command. func (c *DeleteCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.autoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/logging/newrelic/describe.go b/pkg/commands/logging/newrelic/describe.go index 13bbe939f..0fb5895b6 100644 --- a/pkg/commands/logging/newrelic/describe.go +++ b/pkg/commands/logging/newrelic/describe.go @@ -64,7 +64,6 @@ func (c *DescribeCommand) Exec(_ io.Reader, out io.Writer) error { } serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ - AllowActiveLocked: true, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, Out: out, diff --git a/pkg/commands/logging/newrelic/list.go b/pkg/commands/logging/newrelic/list.go index 9e3add715..2d919b9a5 100644 --- a/pkg/commands/logging/newrelic/list.go +++ b/pkg/commands/logging/newrelic/list.go @@ -63,7 +63,6 @@ func (c *ListCommand) Exec(_ io.Reader, out io.Writer) error { } serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ - AllowActiveLocked: true, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, Out: out, diff --git a/pkg/commands/logging/newrelic/newrelic_test.go b/pkg/commands/logging/newrelic/newrelic_test.go index 3324ac083..5a8e17194 100644 --- a/pkg/commands/logging/newrelic/newrelic_test.go +++ b/pkg/commands/logging/newrelic/newrelic_test.go @@ -19,12 +19,20 @@ func TestNewRelicCreate(t *testing.T) { WantError: "error reading service: no service ID found", }, { - Name: "validate missing --autoclone flag", + Name: "validate missing --autoclone flag with 'active' service", API: mock.API{ ListVersionsFn: testutil.ListVersions, }, Arg: "--key abc --name foo --service-id 123 --version 1", - WantError: "service version 1 is not editable", + WantError: "service version 1 is active", + }, + { + Name: "validate missing --autoclone flag with 'locked' service", + API: mock.API{ + ListVersionsFn: testutil.ListVersions, + }, + Arg: "--key abc --name foo --service-id 123 --version 2", + WantError: "service version 2 is locked", }, { Name: "validate CreateNewRelic API error", @@ -91,12 +99,20 @@ func TestNewRelicDelete(t *testing.T) { WantError: "error reading service: no service ID found", }, { - Name: "validate missing --autoclone flag", + Name: "validate missing --autoclone flag with 'active' service", API: mock.API{ ListVersionsFn: testutil.ListVersions, }, Arg: "--name foobar --service-id 123 --version 1", - WantError: "service version 1 is not editable", + WantError: "service version 1 is active", + }, + { + Name: "validate missing --autoclone flag with 'locked' service", + API: mock.API{ + ListVersionsFn: testutil.ListVersions, + }, + Arg: "--name foobar --service-id 123 --version 2", + WantError: "service version 2 is locked", }, { Name: "validate DeleteNewRelic API error", @@ -260,12 +276,20 @@ func TestNewRelicUpdate(t *testing.T) { WantError: "error reading service: no service ID found", }, { - Name: "validate missing --autoclone flag", + Name: "validate missing --autoclone flag with 'active' service", API: mock.API{ ListVersionsFn: testutil.ListVersions, }, Arg: "--name foobar --service-id 123 --version 1", - WantError: "service version 1 is not editable", + WantError: "service version 1 is active", + }, + { + Name: "validate missing --autoclone flag with 'locked' service", + API: mock.API{ + ListVersionsFn: testutil.ListVersions, + }, + Arg: "--name foobar --service-id 123 --version 2", + WantError: "service version 2 is locked", }, { Name: "validate UpdateNewRelic API error", diff --git a/pkg/commands/logging/newrelic/update.go b/pkg/commands/logging/newrelic/update.go index 4648aa527..2d8cd6d13 100644 --- a/pkg/commands/logging/newrelic/update.go +++ b/pkg/commands/logging/newrelic/update.go @@ -11,6 +11,7 @@ import ( "github.com/fastly/cli/pkg/errors" "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // UpdateCommand calls the Fastly API to update an appropriate resource. @@ -80,6 +81,8 @@ func NewUpdateCommand(parent argparser.Registerer, g *global.Data) *UpdateComman // Exec invokes the application logic for the command. func (c *UpdateCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.autoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/logging/newrelicotlp/create.go b/pkg/commands/logging/newrelicotlp/create.go index 160666292..0b67d94e4 100644 --- a/pkg/commands/logging/newrelicotlp/create.go +++ b/pkg/commands/logging/newrelicotlp/create.go @@ -10,6 +10,7 @@ import ( "github.com/fastly/cli/pkg/errors" "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // CreateCommand calls the Fastly API to create an appropriate resource. @@ -81,6 +82,8 @@ func NewCreateCommand(parent argparser.Registerer, g *global.Data) *CreateComman // Exec invokes the application logic for the command. func (c *CreateCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.autoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/logging/newrelicotlp/delete.go b/pkg/commands/logging/newrelicotlp/delete.go index ca8ee9395..bce9823cf 100644 --- a/pkg/commands/logging/newrelicotlp/delete.go +++ b/pkg/commands/logging/newrelicotlp/delete.go @@ -9,6 +9,7 @@ import ( "github.com/fastly/cli/pkg/errors" "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // NewDeleteCommand returns a usable command registered under the parent. @@ -63,6 +64,8 @@ type DeleteCommand struct { // Exec invokes the application logic for the command. func (c *DeleteCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.autoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/logging/newrelicotlp/describe.go b/pkg/commands/logging/newrelicotlp/describe.go index 1c72669d2..21a20d0b2 100644 --- a/pkg/commands/logging/newrelicotlp/describe.go +++ b/pkg/commands/logging/newrelicotlp/describe.go @@ -64,7 +64,6 @@ func (c *DescribeCommand) Exec(_ io.Reader, out io.Writer) error { } serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ - AllowActiveLocked: true, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, Out: out, diff --git a/pkg/commands/logging/newrelicotlp/list.go b/pkg/commands/logging/newrelicotlp/list.go index a24f0a119..86064aef1 100644 --- a/pkg/commands/logging/newrelicotlp/list.go +++ b/pkg/commands/logging/newrelicotlp/list.go @@ -63,7 +63,6 @@ func (c *ListCommand) Exec(_ io.Reader, out io.Writer) error { } serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ - AllowActiveLocked: true, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, Out: out, diff --git a/pkg/commands/logging/newrelicotlp/newrelicotlp_test.go b/pkg/commands/logging/newrelicotlp/newrelicotlp_test.go index a2e517b8d..94cecac1b 100644 --- a/pkg/commands/logging/newrelicotlp/newrelicotlp_test.go +++ b/pkg/commands/logging/newrelicotlp/newrelicotlp_test.go @@ -19,12 +19,20 @@ func TestNewRelicOTLPCreate(t *testing.T) { WantError: "error reading service: no service ID found", }, { - Name: "validate missing --autoclone flag", + Name: "validate missing --autoclone flag with 'active' service", API: mock.API{ ListVersionsFn: testutil.ListVersions, }, Arg: "--key abc --name foo --service-id 123 --version 1", - WantError: "service version 1 is not editable", + WantError: "service version 1 is active", + }, + { + Name: "validate missing --autoclone flag with 'locked' service", + API: mock.API{ + ListVersionsFn: testutil.ListVersions, + }, + Arg: "--key abc --name foo --service-id 123 --version 2", + WantError: "service version 2 is locked", }, { Name: "validate CreateNewRelicOTLP API error", @@ -91,12 +99,20 @@ func TestNewRelicOTLPDelete(t *testing.T) { WantError: "error reading service: no service ID found", }, { - Name: "validate missing --autoclone flag", + Name: "validate missing --autoclone flag with 'active' service", API: mock.API{ ListVersionsFn: testutil.ListVersions, }, Arg: "--name foobar --service-id 123 --version 1", - WantError: "service version 1 is not editable", + WantError: "service version 1 is active", + }, + { + Name: "validate missing --autoclone flag with 'locked' service", + API: mock.API{ + ListVersionsFn: testutil.ListVersions, + }, + Arg: "--name foobar --service-id 123 --version 2", + WantError: "service version 2 is locked", }, { Name: "validate DeleteNewRelic API error", @@ -260,12 +276,20 @@ func TestNewRelicUpdate(t *testing.T) { WantError: "error reading service: no service ID found", }, { - Name: "validate missing --autoclone flag", + Name: "validate missing --autoclone flag with 'active' service", API: mock.API{ ListVersionsFn: testutil.ListVersions, }, Arg: "--name foobar --service-id 123 --version 1", - WantError: "service version 1 is not editable", + WantError: "service version 1 is active", + }, + { + Name: "validate missing --autoclone flag with 'locked' service", + API: mock.API{ + ListVersionsFn: testutil.ListVersions, + }, + Arg: "--name foobar --service-id 123 --version 2", + WantError: "service version 2 is locked", }, { Name: "validate UpdateNewRelic API error", diff --git a/pkg/commands/logging/newrelicotlp/update.go b/pkg/commands/logging/newrelicotlp/update.go index 5a03799db..69fcdc4b3 100644 --- a/pkg/commands/logging/newrelicotlp/update.go +++ b/pkg/commands/logging/newrelicotlp/update.go @@ -11,6 +11,7 @@ import ( "github.com/fastly/cli/pkg/errors" "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // UpdateCommand calls the Fastly API to update an appropriate resource. @@ -82,6 +83,8 @@ func NewUpdateCommand(parent argparser.Registerer, g *global.Data) *UpdateComman // Exec invokes the application logic for the command. func (c *UpdateCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.autoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/logging/openstack/create.go b/pkg/commands/logging/openstack/create.go index 88c951bb0..e64a43c5d 100644 --- a/pkg/commands/logging/openstack/create.go +++ b/pkg/commands/logging/openstack/create.go @@ -12,6 +12,7 @@ import ( "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/manifest" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // CreateCommand calls the Fastly API to create an OpenStack logging endpoint. @@ -174,6 +175,8 @@ func (c *CreateCommand) ConstructInput(serviceID string, serviceVersion int) (*f // Exec invokes the application logic for the command. func (c *CreateCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.AutoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/logging/openstack/delete.go b/pkg/commands/logging/openstack/delete.go index 333141a4b..a1db26a70 100644 --- a/pkg/commands/logging/openstack/delete.go +++ b/pkg/commands/logging/openstack/delete.go @@ -9,6 +9,7 @@ import ( "github.com/fastly/cli/pkg/errors" "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // DeleteCommand calls the Fastly API to delete an OpenStack logging endpoint. @@ -61,6 +62,8 @@ func NewDeleteCommand(parent argparser.Registerer, g *global.Data) *DeleteComman // Exec invokes the application logic for the command. func (c *DeleteCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.autoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/logging/openstack/describe.go b/pkg/commands/logging/openstack/describe.go index a5ca374fd..6d2d752be 100644 --- a/pkg/commands/logging/openstack/describe.go +++ b/pkg/commands/logging/openstack/describe.go @@ -63,7 +63,6 @@ func (c *DescribeCommand) Exec(_ io.Reader, out io.Writer) error { } serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ - AllowActiveLocked: true, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, Out: out, diff --git a/pkg/commands/logging/openstack/list.go b/pkg/commands/logging/openstack/list.go index da1a74ca9..0a9d77cdb 100644 --- a/pkg/commands/logging/openstack/list.go +++ b/pkg/commands/logging/openstack/list.go @@ -63,7 +63,6 @@ func (c *ListCommand) Exec(_ io.Reader, out io.Writer) error { } serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ - AllowActiveLocked: true, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, Out: out, diff --git a/pkg/commands/logging/openstack/update.go b/pkg/commands/logging/openstack/update.go index 05ecf0f35..b957f42f9 100644 --- a/pkg/commands/logging/openstack/update.go +++ b/pkg/commands/logging/openstack/update.go @@ -11,6 +11,7 @@ import ( "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/manifest" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // UpdateCommand calls the Fastly API to update an OpenStack logging endpoint. @@ -177,6 +178,8 @@ func (c *UpdateCommand) ConstructInput(serviceID string, serviceVersion int) (*f // Exec invokes the application logic for the command. func (c *UpdateCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.AutoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/logging/papertrail/create.go b/pkg/commands/logging/papertrail/create.go index 85533a765..65889b052 100644 --- a/pkg/commands/logging/papertrail/create.go +++ b/pkg/commands/logging/papertrail/create.go @@ -11,6 +11,7 @@ import ( "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/manifest" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // CreateCommand calls the Fastly API to create a Papertrail logging endpoint. @@ -116,6 +117,8 @@ func (c *CreateCommand) ConstructInput(serviceID string, serviceVersion int) (*f // Exec invokes the application logic for the command. func (c *CreateCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.AutoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/logging/papertrail/delete.go b/pkg/commands/logging/papertrail/delete.go index a4214725b..465758de8 100644 --- a/pkg/commands/logging/papertrail/delete.go +++ b/pkg/commands/logging/papertrail/delete.go @@ -9,6 +9,7 @@ import ( "github.com/fastly/cli/pkg/errors" "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // DeleteCommand calls the Fastly API to delete a Papertrail logging endpoint. @@ -61,6 +62,8 @@ func NewDeleteCommand(parent argparser.Registerer, g *global.Data) *DeleteComman // Exec invokes the application logic for the command. func (c *DeleteCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.autoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/logging/papertrail/describe.go b/pkg/commands/logging/papertrail/describe.go index fd745823f..9198a3ac9 100644 --- a/pkg/commands/logging/papertrail/describe.go +++ b/pkg/commands/logging/papertrail/describe.go @@ -63,7 +63,6 @@ func (c *DescribeCommand) Exec(_ io.Reader, out io.Writer) error { } serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ - AllowActiveLocked: true, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, Out: out, diff --git a/pkg/commands/logging/papertrail/list.go b/pkg/commands/logging/papertrail/list.go index 557b1f0b1..3482b59ff 100644 --- a/pkg/commands/logging/papertrail/list.go +++ b/pkg/commands/logging/papertrail/list.go @@ -63,7 +63,6 @@ func (c *ListCommand) Exec(_ io.Reader, out io.Writer) error { } serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ - AllowActiveLocked: true, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, Out: out, diff --git a/pkg/commands/logging/papertrail/update.go b/pkg/commands/logging/papertrail/update.go index f058f42c6..3095382dc 100644 --- a/pkg/commands/logging/papertrail/update.go +++ b/pkg/commands/logging/papertrail/update.go @@ -11,6 +11,7 @@ import ( "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/manifest" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // UpdateCommand calls the Fastly API to update a Papertrail logging endpoint. @@ -126,6 +127,8 @@ func (c *UpdateCommand) ConstructInput(serviceID string, serviceVersion int) (*f // Exec invokes the application logic for the command. func (c *UpdateCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.AutoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/logging/s3/create.go b/pkg/commands/logging/s3/create.go index e19887409..b5a394134 100644 --- a/pkg/commands/logging/s3/create.go +++ b/pkg/commands/logging/s3/create.go @@ -12,6 +12,7 @@ import ( "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/manifest" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // CreateCommand calls the Fastly API to create an Amazon S3 logging endpoint. @@ -263,6 +264,8 @@ func ValidateRedundancy(val string) (redundancy fastly.S3Redundancy, err error) // Exec invokes the application logic for the command. func (c *CreateCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.AutoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/logging/s3/delete.go b/pkg/commands/logging/s3/delete.go index c2343ce8c..4e1758cc9 100644 --- a/pkg/commands/logging/s3/delete.go +++ b/pkg/commands/logging/s3/delete.go @@ -9,6 +9,7 @@ import ( "github.com/fastly/cli/pkg/errors" "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // DeleteCommand calls the Fastly API to delete an Amazon S3 logging endpoint. @@ -61,6 +62,8 @@ func NewDeleteCommand(parent argparser.Registerer, g *global.Data) *DeleteComman // Exec invokes the application logic for the command. func (c *DeleteCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.autoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/logging/s3/describe.go b/pkg/commands/logging/s3/describe.go index 753e7c155..3d19eb048 100644 --- a/pkg/commands/logging/s3/describe.go +++ b/pkg/commands/logging/s3/describe.go @@ -63,7 +63,6 @@ func (c *DescribeCommand) Exec(_ io.Reader, out io.Writer) error { } serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ - AllowActiveLocked: true, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, Out: out, diff --git a/pkg/commands/logging/s3/list.go b/pkg/commands/logging/s3/list.go index 7fa486abe..f18e5d8d5 100644 --- a/pkg/commands/logging/s3/list.go +++ b/pkg/commands/logging/s3/list.go @@ -63,7 +63,6 @@ func (c *ListCommand) Exec(_ io.Reader, out io.Writer) error { } serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ - AllowActiveLocked: true, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, Out: out, diff --git a/pkg/commands/logging/s3/update.go b/pkg/commands/logging/s3/update.go index 28c11d671..5b0f9e41d 100644 --- a/pkg/commands/logging/s3/update.go +++ b/pkg/commands/logging/s3/update.go @@ -11,6 +11,7 @@ import ( "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/manifest" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // UpdateCommand calls the Fastly API to update an Amazon S3 logging endpoint. @@ -214,6 +215,8 @@ func (c *UpdateCommand) ConstructInput(serviceID string, serviceVersion int) (*f // Exec invokes the application logic for the command. func (c *UpdateCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.AutoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/logging/scalyr/create.go b/pkg/commands/logging/scalyr/create.go index d85bd6beb..31610a17e 100644 --- a/pkg/commands/logging/scalyr/create.go +++ b/pkg/commands/logging/scalyr/create.go @@ -11,6 +11,7 @@ import ( "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/manifest" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // CreateCommand calls the Fastly API to create a Scalyr logging endpoint. @@ -116,6 +117,8 @@ func (c *CreateCommand) ConstructInput(serviceID string, serviceVersion int) (*f // Exec invokes the application logic for the command. func (c *CreateCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.AutoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/logging/scalyr/delete.go b/pkg/commands/logging/scalyr/delete.go index 35789ff0c..91a5cf903 100644 --- a/pkg/commands/logging/scalyr/delete.go +++ b/pkg/commands/logging/scalyr/delete.go @@ -9,6 +9,7 @@ import ( "github.com/fastly/cli/pkg/errors" "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // DeleteCommand calls the Fastly API to delete a Scalyr logging endpoint. @@ -61,6 +62,8 @@ func NewDeleteCommand(parent argparser.Registerer, g *global.Data) *DeleteComman // Exec invokes the application logic for the command. func (c *DeleteCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.autoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/logging/scalyr/describe.go b/pkg/commands/logging/scalyr/describe.go index c8281bf74..c246a09c3 100644 --- a/pkg/commands/logging/scalyr/describe.go +++ b/pkg/commands/logging/scalyr/describe.go @@ -63,7 +63,6 @@ func (c *DescribeCommand) Exec(_ io.Reader, out io.Writer) error { } serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ - AllowActiveLocked: true, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, Out: out, diff --git a/pkg/commands/logging/scalyr/list.go b/pkg/commands/logging/scalyr/list.go index 9d2473f46..24c5e6d45 100644 --- a/pkg/commands/logging/scalyr/list.go +++ b/pkg/commands/logging/scalyr/list.go @@ -63,7 +63,6 @@ func (c *ListCommand) Exec(_ io.Reader, out io.Writer) error { } serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ - AllowActiveLocked: true, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, Out: out, diff --git a/pkg/commands/logging/scalyr/update.go b/pkg/commands/logging/scalyr/update.go index 86484bd62..edc2516f5 100644 --- a/pkg/commands/logging/scalyr/update.go +++ b/pkg/commands/logging/scalyr/update.go @@ -11,6 +11,7 @@ import ( "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/manifest" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // UpdateCommand calls the Fastly API to update Scalyr logging endpoints. @@ -118,6 +119,8 @@ func (c *UpdateCommand) ConstructInput(serviceID string, serviceVersion int) (*f // Exec invokes the application logic for the command. func (c *UpdateCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.AutoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/logging/sftp/create.go b/pkg/commands/logging/sftp/create.go index 19584a5d7..c1bacb2d1 100644 --- a/pkg/commands/logging/sftp/create.go +++ b/pkg/commands/logging/sftp/create.go @@ -12,6 +12,7 @@ import ( "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/manifest" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // CreateCommand calls the Fastly API to create an SFTP logging endpoint. @@ -187,6 +188,8 @@ func (c *CreateCommand) ConstructInput(serviceID string, serviceVersion int) (*f // Exec invokes the application logic for the command. func (c *CreateCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.AutoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/logging/sftp/delete.go b/pkg/commands/logging/sftp/delete.go index 7bb12e0fa..02d5f57c5 100644 --- a/pkg/commands/logging/sftp/delete.go +++ b/pkg/commands/logging/sftp/delete.go @@ -9,6 +9,7 @@ import ( "github.com/fastly/cli/pkg/errors" "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // DeleteCommand calls the Fastly API to delete an SFTP logging endpoint. @@ -61,6 +62,8 @@ func NewDeleteCommand(parent argparser.Registerer, g *global.Data) *DeleteComman // Exec invokes the application logic for the command. func (c *DeleteCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.autoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/logging/sftp/describe.go b/pkg/commands/logging/sftp/describe.go index 8f9fc86fd..d52d5ce6a 100644 --- a/pkg/commands/logging/sftp/describe.go +++ b/pkg/commands/logging/sftp/describe.go @@ -63,7 +63,6 @@ func (c *DescribeCommand) Exec(_ io.Reader, out io.Writer) error { } serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ - AllowActiveLocked: true, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, Out: out, diff --git a/pkg/commands/logging/sftp/list.go b/pkg/commands/logging/sftp/list.go index 6634539fc..733bba5bb 100644 --- a/pkg/commands/logging/sftp/list.go +++ b/pkg/commands/logging/sftp/list.go @@ -63,7 +63,6 @@ func (c *ListCommand) Exec(_ io.Reader, out io.Writer) error { } serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ - AllowActiveLocked: true, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, Out: out, diff --git a/pkg/commands/logging/sftp/update.go b/pkg/commands/logging/sftp/update.go index 337e1363b..85c1162a8 100644 --- a/pkg/commands/logging/sftp/update.go +++ b/pkg/commands/logging/sftp/update.go @@ -11,6 +11,7 @@ import ( "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/manifest" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // UpdateCommand calls the Fastly API to update an SFTP logging endpoint. @@ -187,6 +188,8 @@ func (c *UpdateCommand) ConstructInput(serviceID string, serviceVersion int) (*f // Exec invokes the application logic for the command. func (c *UpdateCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.AutoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/logging/splunk/create.go b/pkg/commands/logging/splunk/create.go index 2fd68d79e..812641285 100644 --- a/pkg/commands/logging/splunk/create.go +++ b/pkg/commands/logging/splunk/create.go @@ -11,6 +11,7 @@ import ( "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/manifest" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // CreateCommand calls the Fastly API to create a Splunk logging endpoint. @@ -141,6 +142,8 @@ func (c *CreateCommand) ConstructInput(serviceID string, serviceVersion int) (*f // Exec invokes the application logic for the command. func (c *CreateCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.AutoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/logging/splunk/delete.go b/pkg/commands/logging/splunk/delete.go index 0cd486d34..935780c4f 100644 --- a/pkg/commands/logging/splunk/delete.go +++ b/pkg/commands/logging/splunk/delete.go @@ -9,6 +9,7 @@ import ( "github.com/fastly/cli/pkg/errors" "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // DeleteCommand calls the Fastly API to delete a Splunk logging endpoint. @@ -61,6 +62,8 @@ func NewDeleteCommand(parent argparser.Registerer, g *global.Data) *DeleteComman // Exec invokes the application logic for the command. func (c *DeleteCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.autoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/logging/splunk/describe.go b/pkg/commands/logging/splunk/describe.go index f6fbeb5e1..de6a20b94 100644 --- a/pkg/commands/logging/splunk/describe.go +++ b/pkg/commands/logging/splunk/describe.go @@ -63,7 +63,6 @@ func (c *DescribeCommand) Exec(_ io.Reader, out io.Writer) error { } serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ - AllowActiveLocked: true, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, Out: out, diff --git a/pkg/commands/logging/splunk/list.go b/pkg/commands/logging/splunk/list.go index 7dc51ac82..7d9485a04 100644 --- a/pkg/commands/logging/splunk/list.go +++ b/pkg/commands/logging/splunk/list.go @@ -63,7 +63,6 @@ func (c *ListCommand) Exec(_ io.Reader, out io.Writer) error { } serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ - AllowActiveLocked: true, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, Out: out, diff --git a/pkg/commands/logging/splunk/update.go b/pkg/commands/logging/splunk/update.go index e529b157b..d12cf3578 100644 --- a/pkg/commands/logging/splunk/update.go +++ b/pkg/commands/logging/splunk/update.go @@ -11,6 +11,7 @@ import ( "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/manifest" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // UpdateCommand calls the Fastly API to update a Splunk logging endpoint. @@ -146,6 +147,8 @@ func (c *UpdateCommand) ConstructInput(serviceID string, serviceVersion int) (*f // Exec invokes the application logic for the command. func (c *UpdateCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.AutoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/logging/sumologic/create.go b/pkg/commands/logging/sumologic/create.go index 5abced065..c04dccaf9 100644 --- a/pkg/commands/logging/sumologic/create.go +++ b/pkg/commands/logging/sumologic/create.go @@ -11,6 +11,7 @@ import ( "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/manifest" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // CreateCommand calls the Fastly API to create a Sumologic logging endpoint. @@ -116,6 +117,8 @@ func (c *CreateCommand) ConstructInput(serviceID string, serviceVersion int) (*f // Exec invokes the application logic for the command. func (c *CreateCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.AutoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/logging/sumologic/delete.go b/pkg/commands/logging/sumologic/delete.go index 9062a2556..9243723c2 100644 --- a/pkg/commands/logging/sumologic/delete.go +++ b/pkg/commands/logging/sumologic/delete.go @@ -9,6 +9,7 @@ import ( "github.com/fastly/cli/pkg/errors" "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // DeleteCommand calls the Fastly API to delete a Sumologic logging endpoint. @@ -61,6 +62,8 @@ func NewDeleteCommand(parent argparser.Registerer, g *global.Data) *DeleteComman // Exec invokes the application logic for the command. func (c *DeleteCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.autoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/logging/sumologic/describe.go b/pkg/commands/logging/sumologic/describe.go index 2afffe50c..28fc10d93 100644 --- a/pkg/commands/logging/sumologic/describe.go +++ b/pkg/commands/logging/sumologic/describe.go @@ -63,7 +63,6 @@ func (c *DescribeCommand) Exec(_ io.Reader, out io.Writer) error { } serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ - AllowActiveLocked: true, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, Out: out, diff --git a/pkg/commands/logging/sumologic/list.go b/pkg/commands/logging/sumologic/list.go index 834d19da9..c63a9c7b7 100644 --- a/pkg/commands/logging/sumologic/list.go +++ b/pkg/commands/logging/sumologic/list.go @@ -63,7 +63,6 @@ func (c *ListCommand) Exec(_ io.Reader, out io.Writer) error { } serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ - AllowActiveLocked: true, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, Out: out, diff --git a/pkg/commands/logging/sumologic/update.go b/pkg/commands/logging/sumologic/update.go index 78b7277f5..1a2dae88c 100644 --- a/pkg/commands/logging/sumologic/update.go +++ b/pkg/commands/logging/sumologic/update.go @@ -11,6 +11,7 @@ import ( "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/manifest" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // UpdateCommand calls the Fastly API to update a Sumologic logging endpoint. @@ -122,6 +123,8 @@ func (c *UpdateCommand) ConstructInput(serviceID string, serviceVersion int) (*f // Exec invokes the application logic for the command. func (c *UpdateCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.AutoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/logging/syslog/create.go b/pkg/commands/logging/syslog/create.go index 34d368172..71a0c8a6e 100644 --- a/pkg/commands/logging/syslog/create.go +++ b/pkg/commands/logging/syslog/create.go @@ -11,6 +11,7 @@ import ( "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/manifest" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // CreateCommand calls the Fastly API to create a Syslog logging endpoint. @@ -157,6 +158,8 @@ func (c *CreateCommand) ConstructInput(serviceID string, serviceVersion int) (*f // Exec invokes the application logic for the command. func (c *CreateCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.AutoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/logging/syslog/delete.go b/pkg/commands/logging/syslog/delete.go index 164a4332a..72999b1c9 100644 --- a/pkg/commands/logging/syslog/delete.go +++ b/pkg/commands/logging/syslog/delete.go @@ -9,6 +9,7 @@ import ( "github.com/fastly/cli/pkg/errors" "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // DeleteCommand calls the Fastly API to delete a Syslog logging endpoint. @@ -61,6 +62,8 @@ func NewDeleteCommand(parent argparser.Registerer, g *global.Data) *DeleteComman // Exec invokes the application logic for the command. func (c *DeleteCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.autoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/logging/syslog/describe.go b/pkg/commands/logging/syslog/describe.go index 314b48c1b..a32123124 100644 --- a/pkg/commands/logging/syslog/describe.go +++ b/pkg/commands/logging/syslog/describe.go @@ -63,7 +63,6 @@ func (c *DescribeCommand) Exec(_ io.Reader, out io.Writer) error { } serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ - AllowActiveLocked: true, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, Out: out, diff --git a/pkg/commands/logging/syslog/list.go b/pkg/commands/logging/syslog/list.go index 04ca88dae..b53dd2fda 100644 --- a/pkg/commands/logging/syslog/list.go +++ b/pkg/commands/logging/syslog/list.go @@ -63,7 +63,6 @@ func (c *ListCommand) Exec(_ io.Reader, out io.Writer) error { } serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ - AllowActiveLocked: true, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, Out: out, diff --git a/pkg/commands/logging/syslog/update.go b/pkg/commands/logging/syslog/update.go index 404814a0f..394ce12d1 100644 --- a/pkg/commands/logging/syslog/update.go +++ b/pkg/commands/logging/syslog/update.go @@ -11,6 +11,7 @@ import ( "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/manifest" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // UpdateCommand calls the Fastly API to update a Syslog logging endpoint. @@ -164,6 +165,8 @@ func (c *UpdateCommand) ConstructInput(serviceID string, serviceVersion int) (*f // Exec invokes the application logic for the command. func (c *UpdateCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.AutoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/ratelimit/create.go b/pkg/commands/ratelimit/create.go index 7691acc03..e163766ac 100644 --- a/pkg/commands/ratelimit/create.go +++ b/pkg/commands/ratelimit/create.go @@ -12,6 +12,7 @@ import ( fsterr "github.com/fastly/cli/pkg/errors" "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // rateLimitActionFlagOpts is a string representation of rateLimitActions @@ -133,6 +134,8 @@ func (c *CreateCommand) Exec(_ io.Reader, out io.Writer) error { } serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.autoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/ratelimit/list.go b/pkg/commands/ratelimit/list.go index 6a49b66f9..9ae294a9a 100644 --- a/pkg/commands/ratelimit/list.go +++ b/pkg/commands/ratelimit/list.go @@ -59,7 +59,6 @@ func (c *ListCommand) Exec(_ io.Reader, out io.Writer) error { } serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ - AllowActiveLocked: true, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, Out: out, diff --git a/pkg/commands/resourcelink/create.go b/pkg/commands/resourcelink/create.go index 23de4e354..57abc004f 100644 --- a/pkg/commands/resourcelink/create.go +++ b/pkg/commands/resourcelink/create.go @@ -9,6 +9,7 @@ import ( fsterr "github.com/fastly/cli/pkg/errors" "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // CreateCommand calls the Fastly API to create a resource link. @@ -88,6 +89,8 @@ func (c *CreateCommand) Exec(_ io.Reader, out io.Writer) error { } serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.autoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/resourcelink/delete.go b/pkg/commands/resourcelink/delete.go index 7db639e5a..777003a2e 100644 --- a/pkg/commands/resourcelink/delete.go +++ b/pkg/commands/resourcelink/delete.go @@ -9,6 +9,7 @@ import ( fsterr "github.com/fastly/cli/pkg/errors" "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // DeleteCommand calls the Fastly API to delete service resource links. @@ -76,6 +77,8 @@ func (c *DeleteCommand) Exec(_ io.Reader, out io.Writer) error { } serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.autoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/resourcelink/update.go b/pkg/commands/resourcelink/update.go index fc1c2232c..d109e5de9 100644 --- a/pkg/commands/resourcelink/update.go +++ b/pkg/commands/resourcelink/update.go @@ -9,6 +9,7 @@ import ( fsterr "github.com/fastly/cli/pkg/errors" "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // UpdateCommand calls the Fastly API to update a dictionary. @@ -87,6 +88,8 @@ func (c *UpdateCommand) Exec(_ io.Reader, out io.Writer) error { } serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.autoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/serviceversion/activate.go b/pkg/commands/serviceversion/activate.go index 813ce2d76..53901ab9f 100644 --- a/pkg/commands/serviceversion/activate.go +++ b/pkg/commands/serviceversion/activate.go @@ -9,6 +9,7 @@ import ( "github.com/fastly/cli/pkg/errors" "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // ActivateCommand calls the Fastly API to activate a service version. @@ -53,6 +54,7 @@ func NewActivateCommand(parent argparser.Registerer, g *global.Data) *ActivateCo // Exec invokes the application logic for the command. func (c *ActivateCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), AutoCloneFlag: c.autoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/serviceversion/clone.go b/pkg/commands/serviceversion/clone.go index c5fd0b239..804d2177a 100644 --- a/pkg/commands/serviceversion/clone.go +++ b/pkg/commands/serviceversion/clone.go @@ -48,7 +48,6 @@ func NewCloneCommand(parent argparser.Registerer, g *global.Data) *CloneCommand // Exec invokes the application logic for the command. func (c *CloneCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ - AllowActiveLocked: true, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, Out: out, diff --git a/pkg/commands/serviceversion/deactivate.go b/pkg/commands/serviceversion/deactivate.go index 8551d1e88..b5a4ba42c 100644 --- a/pkg/commands/serviceversion/deactivate.go +++ b/pkg/commands/serviceversion/deactivate.go @@ -9,6 +9,7 @@ import ( "github.com/fastly/cli/pkg/errors" "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // DeactivateCommand calls the Fastly API to deactivate a service version. @@ -48,7 +49,7 @@ func NewDeactivateCommand(parent argparser.Registerer, g *global.Data) *Deactiva // Exec invokes the application logic for the command. func (c *DeactivateCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ - AllowActiveLocked: true, + Active: optional.Of(true), APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, Out: out, diff --git a/pkg/commands/serviceversion/lock.go b/pkg/commands/serviceversion/lock.go index 1a197d8fc..d863e41b4 100644 --- a/pkg/commands/serviceversion/lock.go +++ b/pkg/commands/serviceversion/lock.go @@ -9,6 +9,7 @@ import ( "github.com/fastly/cli/pkg/errors" "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // LockCommand calls the Fastly API to lock a service version. @@ -48,7 +49,7 @@ func NewLockCommand(parent argparser.Registerer, g *global.Data) *LockCommand { // Exec invokes the application logic for the command. func (c *LockCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ - AllowActiveLocked: true, + Locked: optional.Of(false), APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, Out: out, diff --git a/pkg/commands/serviceversion/serviceversion_test.go b/pkg/commands/serviceversion/serviceversion_test.go index be92db91c..1e50bd1b0 100644 --- a/pkg/commands/serviceversion/serviceversion_test.go +++ b/pkg/commands/serviceversion/serviceversion_test.go @@ -122,6 +122,13 @@ func TestVersionActivate(t *testing.T) { Arg: "--service-id 123", WantError: "error parsing arguments: required flag --version not provided", }, + { + Arg: "--service-id 123 --version 1", + API: mock.API{ + ListVersionsFn: testutil.ListVersions, + }, + WantError: "service version 1 is active", + }, { Arg: "--service-id 123 --version 1 --autoclone", API: mock.API{ @@ -140,6 +147,15 @@ func TestVersionActivate(t *testing.T) { }, WantOutput: "Activated service 123 version 4", }, + { + Arg: "--service-id 123 --version 2 --autoclone", + API: mock.API{ + ListVersionsFn: testutil.ListVersions, + CloneVersionFn: testutil.CloneVersionResult(4), + ActivateVersionFn: activateVersionOK, + }, + WantOutput: "Activated service 123 version 4", + }, { Arg: "--service-id 123 --version 3 --autoclone", API: mock.API{ @@ -173,10 +189,10 @@ func TestVersionDeactivate(t *testing.T) { ListVersionsFn: testutil.ListVersions, DeactivateVersionFn: deactivateVersionOK, }, - WantOutput: "Deactivated service 123 version 3", + WantError: "service version 3 is not active", }, { - Arg: "--service-id 123 --version 3", + Arg: "--service-id 123 --version 1", API: mock.API{ ListVersionsFn: testutil.ListVersions, DeactivateVersionFn: deactivateVersionError, diff --git a/pkg/commands/vcl/condition/create.go b/pkg/commands/vcl/condition/create.go index d4db3f7c7..05da5076e 100644 --- a/pkg/commands/vcl/condition/create.go +++ b/pkg/commands/vcl/condition/create.go @@ -9,6 +9,7 @@ import ( "github.com/fastly/cli/pkg/errors" "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // ConditionTypes are the allowed input values for the --type flag. @@ -76,6 +77,8 @@ func NewCreateCommand(parent argparser.Registerer, g *global.Data) *CreateComman // Exec invokes the application logic for the command. func (c *CreateCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.autoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/vcl/condition/delete.go b/pkg/commands/vcl/condition/delete.go index b0fd071a0..8ce2f7411 100644 --- a/pkg/commands/vcl/condition/delete.go +++ b/pkg/commands/vcl/condition/delete.go @@ -9,6 +9,7 @@ import ( "github.com/fastly/cli/pkg/errors" "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // DeleteCommand calls the Fastly API to delete an appropriate resource. @@ -62,6 +63,8 @@ func NewDeleteCommand(parent argparser.Registerer, g *global.Data) *DeleteComman // Exec invokes the application logic for the command. func (c *DeleteCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.autoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/vcl/condition/describe.go b/pkg/commands/vcl/condition/describe.go index ffdfd22f9..4dcf0115d 100644 --- a/pkg/commands/vcl/condition/describe.go +++ b/pkg/commands/vcl/condition/describe.go @@ -61,7 +61,6 @@ func (c *DescribeCommand) Exec(_ io.Reader, out io.Writer) error { } serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ - AllowActiveLocked: true, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, Out: out, diff --git a/pkg/commands/vcl/condition/list.go b/pkg/commands/vcl/condition/list.go index 152907837..1a7fc94c7 100644 --- a/pkg/commands/vcl/condition/list.go +++ b/pkg/commands/vcl/condition/list.go @@ -59,7 +59,6 @@ func (c *ListCommand) Exec(_ io.Reader, out io.Writer) error { } serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ - AllowActiveLocked: true, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, Out: out, diff --git a/pkg/commands/vcl/condition/update.go b/pkg/commands/vcl/condition/update.go index 8429b0c68..07d434ffd 100644 --- a/pkg/commands/vcl/condition/update.go +++ b/pkg/commands/vcl/condition/update.go @@ -10,6 +10,7 @@ import ( "github.com/fastly/cli/pkg/errors" "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // UpdateCommand calls the Fastly API to update an appropriate resource. @@ -72,6 +73,8 @@ func NewUpdateCommand(parent argparser.Registerer, g *global.Data) *UpdateComman // Exec invokes the application logic for the command. func (c *UpdateCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.autoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/vcl/custom/create.go b/pkg/commands/vcl/custom/create.go index b613357fe..7fd2219b6 100644 --- a/pkg/commands/vcl/custom/create.go +++ b/pkg/commands/vcl/custom/create.go @@ -9,6 +9,7 @@ import ( "github.com/fastly/cli/pkg/errors" "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // NewCreateCommand returns a usable command registered under the parent. @@ -67,6 +68,8 @@ type CreateCommand struct { // Exec invokes the application logic for the command. func (c *CreateCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.autoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/vcl/custom/custom_test.go b/pkg/commands/vcl/custom/custom_test.go index f67d7707b..d7d0b247c 100644 --- a/pkg/commands/vcl/custom/custom_test.go +++ b/pkg/commands/vcl/custom/custom_test.go @@ -15,12 +15,20 @@ func TestVCLCustomCreate(t *testing.T) { var content string scenarios := []testutil.TestScenario{ { - Name: "validate missing --autoclone flag", + Name: "validate missing --autoclone flag with 'active' service", API: mock.API{ ListVersionsFn: testutil.ListVersions, }, Arg: "--content ./testdata/example.vcl --name foo --service-id 123 --version 1", - WantError: "service version 1 is not editable", + WantError: "service version 1 is active", + }, + { + Name: "validate missing --autoclone flag with 'locked' service", + API: mock.API{ + ListVersionsFn: testutil.ListVersions, + }, + Arg: "--content ./testdata/example.vcl --name foo --service-id 123 --version 2", + WantError: "service version 2 is locked", }, { Name: "validate CreateVCL API error", @@ -178,12 +186,20 @@ func TestVCLCustomDelete(t *testing.T) { WantError: "error reading service: no service ID found", }, { - Name: "validate missing --autoclone flag", + Name: "validate missing --autoclone flag with 'active' service", API: mock.API{ ListVersionsFn: testutil.ListVersions, }, Arg: "--name foobar --service-id 123 --version 1", - WantError: "service version 1 is not editable", + WantError: "service version 1 is active", + }, + { + Name: "validate missing --autoclone flag with 'locked' service", + API: mock.API{ + ListVersionsFn: testutil.ListVersions, + }, + Arg: "--name foobar --service-id 123 --version 2", + WantError: "service version 2 is locked", }, { Name: "validate DeleteVCL API error", @@ -348,12 +364,20 @@ func TestVCLCustomUpdate(t *testing.T) { WantError: "error reading service: no service ID found", }, { - Name: "validate missing --autoclone flag", + Name: "validate missing --autoclone flag with 'active' service", API: mock.API{ ListVersionsFn: testutil.ListVersions, }, Arg: "--name foobar --service-id 123 --version 1", - WantError: "service version 1 is not editable", + WantError: "service version 1 is active", + }, + { + Name: "validate missing --autoclone flag with 'locked' service", + API: mock.API{ + ListVersionsFn: testutil.ListVersions, + }, + Arg: "--name foobar --service-id 123 --version 2", + WantError: "service version 2 is locked", }, { Name: "validate UpdateVCL API error", diff --git a/pkg/commands/vcl/custom/delete.go b/pkg/commands/vcl/custom/delete.go index e2272b61c..805fb8059 100644 --- a/pkg/commands/vcl/custom/delete.go +++ b/pkg/commands/vcl/custom/delete.go @@ -9,6 +9,7 @@ import ( "github.com/fastly/cli/pkg/errors" "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // NewDeleteCommand returns a usable command registered under the parent. @@ -63,6 +64,8 @@ type DeleteCommand struct { // Exec invokes the application logic for the command. func (c *DeleteCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.autoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/vcl/custom/describe.go b/pkg/commands/vcl/custom/describe.go index 7cc2e9385..a404e7213 100644 --- a/pkg/commands/vcl/custom/describe.go +++ b/pkg/commands/vcl/custom/describe.go @@ -64,7 +64,6 @@ func (c *DescribeCommand) Exec(_ io.Reader, out io.Writer) error { } serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ - AllowActiveLocked: true, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, Out: out, diff --git a/pkg/commands/vcl/custom/list.go b/pkg/commands/vcl/custom/list.go index 36cade8d4..da105c7e8 100644 --- a/pkg/commands/vcl/custom/list.go +++ b/pkg/commands/vcl/custom/list.go @@ -63,7 +63,6 @@ func (c *ListCommand) Exec(_ io.Reader, out io.Writer) error { } serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ - AllowActiveLocked: true, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, Out: out, diff --git a/pkg/commands/vcl/custom/update.go b/pkg/commands/vcl/custom/update.go index a210694d2..dd39d59dc 100644 --- a/pkg/commands/vcl/custom/update.go +++ b/pkg/commands/vcl/custom/update.go @@ -10,6 +10,7 @@ import ( fsterr "github.com/fastly/cli/pkg/errors" "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // NewUpdateCommand returns a usable command registered under the parent. @@ -68,6 +69,8 @@ type UpdateCommand struct { // Exec invokes the application logic for the command. func (c *UpdateCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.autoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/vcl/snippet/create.go b/pkg/commands/vcl/snippet/create.go index 4345d8074..26c408a4d 100644 --- a/pkg/commands/vcl/snippet/create.go +++ b/pkg/commands/vcl/snippet/create.go @@ -9,6 +9,7 @@ import ( "github.com/fastly/cli/pkg/errors" "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // Locations is a list of VCL subroutines. @@ -75,6 +76,8 @@ type CreateCommand struct { // Exec invokes the application logic for the command. func (c *CreateCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.autoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/vcl/snippet/delete.go b/pkg/commands/vcl/snippet/delete.go index d77a7877d..2122a7c83 100644 --- a/pkg/commands/vcl/snippet/delete.go +++ b/pkg/commands/vcl/snippet/delete.go @@ -9,6 +9,7 @@ import ( "github.com/fastly/cli/pkg/errors" "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // NewDeleteCommand returns a usable command registered under the parent. @@ -63,6 +64,8 @@ type DeleteCommand struct { // Exec invokes the application logic for the command. func (c *DeleteCommand) Exec(_ io.Reader, out io.Writer) error { serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ + Active: optional.Of(false), + Locked: optional.Of(false), AutoCloneFlag: c.autoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, diff --git a/pkg/commands/vcl/snippet/describe.go b/pkg/commands/vcl/snippet/describe.go index 3ef0f3c3f..77879cb99 100644 --- a/pkg/commands/vcl/snippet/describe.go +++ b/pkg/commands/vcl/snippet/describe.go @@ -68,7 +68,6 @@ func (c *DescribeCommand) Exec(_ io.Reader, out io.Writer) error { } serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ - AllowActiveLocked: true, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, Out: out, diff --git a/pkg/commands/vcl/snippet/list.go b/pkg/commands/vcl/snippet/list.go index c2cccf3d6..9562509c4 100644 --- a/pkg/commands/vcl/snippet/list.go +++ b/pkg/commands/vcl/snippet/list.go @@ -63,7 +63,6 @@ func (c *ListCommand) Exec(_ io.Reader, out io.Writer) error { } serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ - AllowActiveLocked: true, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest, Out: out, diff --git a/pkg/commands/vcl/snippet/snippet_test.go b/pkg/commands/vcl/snippet/snippet_test.go index f05a67957..ff872e506 100644 --- a/pkg/commands/vcl/snippet/snippet_test.go +++ b/pkg/commands/vcl/snippet/snippet_test.go @@ -20,12 +20,20 @@ func TestVCLSnippetCreate(t *testing.T) { WantError: "error reading service: no service ID found", }, { - Name: "validate missing --autoclone flag", + Name: "validate missing --autoclone flag with 'active' service", API: mock.API{ ListVersionsFn: testutil.ListVersions, }, Arg: "--content ./testdata/snippet.vcl --name foo --type recv --service-id 123 --version 1", - WantError: "service version 1 is not editable", + WantError: "service version 1 is active", + }, + { + Name: "validate missing --autoclone flag with 'locked' service", + API: mock.API{ + ListVersionsFn: testutil.ListVersions, + }, + Arg: "--content ./testdata/snippet.vcl --name foo --type recv --service-id 123 --version 2", + WantError: "service version 2 is locked", }, { Name: "validate CreateSnippet API error", @@ -213,12 +221,20 @@ func TestVCLSnippetDelete(t *testing.T) { WantError: "error reading service: no service ID found", }, { - Name: "validate missing --autoclone flag", + Name: "validate missing --autoclone flag with 'active' service", API: mock.API{ ListVersionsFn: testutil.ListVersions, }, Arg: "--name foobar --service-id 123 --version 1", - WantError: "service version 1 is not editable", + WantError: "service version 1 is active", + }, + { + Name: "validate missing --autoclone flag with 'locked' service", + API: mock.API{ + ListVersionsFn: testutil.ListVersions, + }, + Arg: "--name foobar --service-id 123 --version 2", + WantError: "service version 2 is locked", }, { Name: "validate DeleteSnippet API error", @@ -396,12 +412,20 @@ func TestVCLSnippetUpdate(t *testing.T) { WantError: "error reading service: no service ID found", }, { - Name: "validate missing --autoclone flag", + Name: "validate missing --autoclone flag with 'active' service", API: mock.API{ ListVersionsFn: testutil.ListVersions, }, Arg: "--service-id 123 --version 1", - WantError: "service version 1 is not editable", + WantError: "service version 1 is active", + }, + { + Name: "validate missing --autoclone flag with 'locked' service", + API: mock.API{ + ListVersionsFn: testutil.ListVersions, + }, + Arg: "--service-id 123 --version 2", + WantError: "service version 2 is locked", }, { Name: "validate versioned snippet missing --name", diff --git a/pkg/commands/vcl/snippet/update.go b/pkg/commands/vcl/snippet/update.go index 34a286c85..0491b4143 100644 --- a/pkg/commands/vcl/snippet/update.go +++ b/pkg/commands/vcl/snippet/update.go @@ -10,6 +10,7 @@ import ( fsterr "github.com/fastly/cli/pkg/errors" "github.com/fastly/cli/pkg/global" "github.com/fastly/cli/pkg/text" + optional "github.com/leighmcculloch/go-optional" ) // NewUpdateCommand returns a usable command registered under the parent. @@ -77,8 +78,19 @@ type UpdateCommand struct { // Exec invokes the application logic for the command. func (c *UpdateCommand) Exec(_ io.Reader, out io.Writer) error { + // in the normal case, we do not want to allow 'active' or 'locked' services to be updated, + // so we require those states to be 'false' + var allowActive = optional.Of(false) + var allowLocked = optional.Of(false) + if c.dynamic.WasSet && c.dynamic.Value { + // in this case, we will accept all states ('active' and 'inactive', 'locked' and 'unlocked'), + // so we mark the Optional[bool] fields as 'empty' and they will not be applied as filters + allowActive = optional.Empty[bool]() + allowLocked = optional.Empty[bool]() + } serviceID, serviceVersion, err := argparser.ServiceDetails(argparser.ServiceDetailsOpts{ - AllowActiveLocked: c.dynamic.WasSet && c.dynamic.Value, + Active: allowActive, + Locked: allowLocked, AutoCloneFlag: c.autoClone, APIClient: c.Globals.APIClient, Manifest: *c.Globals.Manifest,