From d6bbb6b28ea76e2546abe25095d2aeccee1958c7 Mon Sep 17 00:00:00 2001 From: Grant Stephens Date: Fri, 18 Nov 2022 15:02:06 +0000 Subject: [PATCH] Sort it all --- pkg/commands/acl/create.go | 3 +- pkg/commands/acl/delete.go | 16 +++-- pkg/commands/acl/describe.go | 7 +- pkg/commands/acl/list.go | 4 +- pkg/commands/acl/update.go | 9 ++- pkg/commands/aclentry/create.go | 15 ++-- pkg/commands/aclentry/delete.go | 13 ++-- pkg/commands/aclentry/describe.go | 13 ++-- pkg/commands/aclentry/list.go | 20 +++--- pkg/commands/aclentry/update.go | 13 ++-- pkg/commands/authtoken/create.go | 13 ++-- pkg/commands/authtoken/delete.go | 10 ++- pkg/commands/authtoken/describe.go | 10 ++- pkg/commands/authtoken/list.go | 10 ++- pkg/commands/backend/create.go | 68 ++++++++++-------- pkg/commands/backend/delete.go | 36 ++++++---- pkg/commands/backend/describe.go | 27 +++++--- pkg/commands/backend/list.go | 25 ++++--- pkg/commands/backend/update.go | 69 ++++++++++--------- pkg/commands/compute/update.go | 9 ++- pkg/commands/dictionary/create.go | 35 ++++++---- pkg/commands/dictionary/delete.go | 35 ++++++---- pkg/commands/dictionary/describe.go | 27 +++++--- pkg/commands/dictionary/list.go | 25 ++++--- pkg/commands/dictionary/update.go | 37 ++++++---- pkg/commands/dictionaryitem/create.go | 19 +++-- pkg/commands/dictionaryitem/delete.go | 17 +++-- pkg/commands/dictionaryitem/describe.go | 18 +++-- pkg/commands/dictionaryitem/list.go | 13 +++- pkg/commands/dictionaryitem/update.go | 13 +++- pkg/commands/domain/create.go | 37 ++++++---- pkg/commands/domain/delete.go | 33 +++++---- pkg/commands/domain/describe.go | 27 +++++--- pkg/commands/domain/list.go | 25 ++++--- pkg/commands/domain/update.go | 39 ++++++----- pkg/commands/domain/validate.go | 4 +- pkg/commands/healthcheck/create.go | 51 ++++++++------ pkg/commands/healthcheck/delete.go | 35 ++++++---- pkg/commands/healthcheck/describe.go | 27 +++++--- pkg/commands/healthcheck/list.go | 25 ++++--- pkg/commands/healthcheck/update.go | 53 +++++++------- pkg/commands/logging/azureblob/create.go | 39 ++++++----- pkg/commands/logging/azureblob/delete.go | 13 +++- pkg/commands/logging/azureblob/describe.go | 27 +++++--- pkg/commands/logging/azureblob/list.go | 25 ++++--- pkg/commands/logging/azureblob/update.go | 45 +++++++----- pkg/commands/logging/bigquery/create.go | 29 +++++--- pkg/commands/logging/bigquery/delete.go | 15 ++-- pkg/commands/logging/bigquery/describe.go | 27 +++++--- pkg/commands/logging/bigquery/list.go | 25 ++++--- pkg/commands/logging/bigquery/update.go | 33 +++++---- pkg/commands/logging/cloudfiles/create.go | 41 ++++++----- pkg/commands/logging/cloudfiles/delete.go | 15 ++-- pkg/commands/logging/cloudfiles/describe.go | 27 +++++--- pkg/commands/logging/cloudfiles/list.go | 25 ++++--- pkg/commands/logging/cloudfiles/update.go | 45 +++++++----- pkg/commands/logging/datadog/create.go | 23 ++++--- pkg/commands/logging/datadog/delete.go | 15 ++-- pkg/commands/logging/datadog/describe.go | 27 +++++--- pkg/commands/logging/datadog/list.go | 25 ++++--- pkg/commands/logging/datadog/update.go | 29 +++++--- pkg/commands/logging/digitalocean/create.go | 39 ++++++----- pkg/commands/logging/digitalocean/delete.go | 15 ++-- pkg/commands/logging/digitalocean/describe.go | 27 +++++--- pkg/commands/logging/digitalocean/list.go | 25 ++++--- pkg/commands/logging/digitalocean/update.go | 45 +++++++----- pkg/commands/logging/elasticsearch/create.go | 29 +++++--- pkg/commands/logging/elasticsearch/delete.go | 15 ++-- .../logging/elasticsearch/describe.go | 27 +++++--- pkg/commands/logging/elasticsearch/list.go | 25 ++++--- pkg/commands/logging/elasticsearch/update.go | 35 ++++++---- pkg/commands/logging/ftp/create.go | 37 ++++++---- pkg/commands/logging/ftp/delete.go | 15 ++-- pkg/commands/logging/ftp/describe.go | 9 ++- pkg/commands/logging/ftp/list.go | 25 ++++--- pkg/commands/logging/ftp/update.go | 43 +++++++----- pkg/commands/logging/gcs/create.go | 35 ++++++---- pkg/commands/logging/gcs/delete.go | 15 ++-- pkg/commands/logging/gcs/describe.go | 27 +++++--- pkg/commands/logging/gcs/list.go | 25 ++++--- pkg/commands/logging/gcs/update.go | 41 ++++++----- pkg/commands/logging/googlepubsub/create.go | 27 +++++--- pkg/commands/logging/googlepubsub/delete.go | 15 ++-- pkg/commands/logging/googlepubsub/describe.go | 27 +++++--- pkg/commands/logging/googlepubsub/list.go | 25 ++++--- pkg/commands/logging/googlepubsub/update.go | 31 +++++---- pkg/commands/logging/heroku/create.go | 25 ++++--- pkg/commands/logging/heroku/delete.go | 15 ++-- pkg/commands/logging/heroku/describe.go | 27 +++++--- pkg/commands/logging/heroku/list.go | 25 ++++--- pkg/commands/logging/heroku/update.go | 27 +++++--- pkg/commands/logging/honeycomb/create.go | 23 ++++--- pkg/commands/logging/honeycomb/delete.go | 15 ++-- pkg/commands/logging/honeycomb/describe.go | 27 +++++--- pkg/commands/logging/honeycomb/list.go | 25 ++++--- pkg/commands/logging/honeycomb/update.go | 29 +++++--- pkg/commands/logging/https/create.go | 39 ++++++----- pkg/commands/logging/https/delete.go | 15 ++-- pkg/commands/logging/https/describe.go | 27 +++++--- pkg/commands/logging/https/list.go | 25 ++++--- pkg/commands/logging/https/update.go | 43 +++++++----- pkg/commands/logging/kafka/create.go | 37 ++++++---- pkg/commands/logging/kafka/delete.go | 15 ++-- pkg/commands/logging/kafka/describe.go | 27 +++++--- pkg/commands/logging/kafka/list.go | 25 ++++--- pkg/commands/logging/kafka/update.go | 43 +++++++----- pkg/commands/logging/kinesis/create.go | 21 +++--- pkg/commands/logging/kinesis/delete.go | 15 ++-- pkg/commands/logging/kinesis/describe.go | 27 +++++--- pkg/commands/logging/kinesis/list.go | 25 ++++--- pkg/commands/logging/kinesis/update.go | 33 +++++---- pkg/commands/logging/logentries/create.go | 47 +++++++------ pkg/commands/logging/logentries/delete.go | 15 ++-- pkg/commands/logging/logentries/describe.go | 27 +++++--- pkg/commands/logging/logentries/list.go | 25 ++++--- pkg/commands/logging/logentries/update.go | 31 +++++---- pkg/commands/logging/loggly/create.go | 23 ++++--- pkg/commands/logging/loggly/delete.go | 15 ++-- pkg/commands/logging/loggly/describe.go | 27 +++++--- pkg/commands/logging/loggly/list.go | 25 ++++--- pkg/commands/logging/loggly/update.go | 27 +++++--- pkg/commands/logging/logshuttle/create.go | 25 ++++--- pkg/commands/logging/logshuttle/delete.go | 15 ++-- pkg/commands/logging/logshuttle/describe.go | 27 +++++--- pkg/commands/logging/logshuttle/list.go | 25 ++++--- pkg/commands/logging/logshuttle/update.go | 27 +++++--- pkg/commands/logging/newrelic/create.go | 15 ++-- pkg/commands/logging/newrelic/delete.go | 13 ++-- pkg/commands/logging/newrelic/describe.go | 13 ++-- pkg/commands/logging/newrelic/list.go | 13 ++-- pkg/commands/logging/newrelic/update.go | 13 ++-- pkg/commands/logging/openstack/create.go | 41 ++++++----- pkg/commands/logging/openstack/delete.go | 15 ++-- pkg/commands/logging/openstack/describe.go | 27 +++++--- pkg/commands/logging/openstack/list.go | 25 ++++--- pkg/commands/logging/openstack/update.go | 45 ++++++------ pkg/commands/logging/papertrail/create.go | 25 ++++--- pkg/commands/logging/papertrail/delete.go | 15 ++-- pkg/commands/logging/papertrail/describe.go | 27 +++++--- pkg/commands/logging/papertrail/list.go | 25 ++++--- pkg/commands/logging/papertrail/update.go | 29 +++++--- pkg/commands/logging/s3/create.go | 45 +++++++----- pkg/commands/logging/s3/delete.go | 15 ++-- pkg/commands/logging/s3/describe.go | 27 +++++--- pkg/commands/logging/s3/list.go | 25 ++++--- pkg/commands/logging/s3/update.go | 53 +++++++------- pkg/commands/logging/scalyr/create.go | 25 ++++--- pkg/commands/logging/scalyr/delete.go | 15 ++-- pkg/commands/logging/scalyr/describe.go | 27 +++++--- pkg/commands/logging/scalyr/list.go | 25 ++++--- pkg/commands/logging/scalyr/update.go | 29 +++++--- pkg/commands/logging/sftp/create.go | 43 +++++++----- pkg/commands/logging/sftp/delete.go | 15 ++-- pkg/commands/logging/sftp/describe.go | 27 +++++--- pkg/commands/logging/sftp/list.go | 25 ++++--- pkg/commands/logging/sftp/update.go | 45 +++++++----- pkg/commands/logging/splunk/create.go | 27 +++++--- pkg/commands/logging/splunk/delete.go | 15 ++-- pkg/commands/logging/splunk/describe.go | 27 +++++--- pkg/commands/logging/splunk/list.go | 25 ++++--- pkg/commands/logging/splunk/update.go | 31 +++++---- pkg/commands/logging/sumologic/create.go | 25 ++++--- pkg/commands/logging/sumologic/delete.go | 15 ++-- pkg/commands/logging/sumologic/describe.go | 27 +++++--- pkg/commands/logging/sumologic/list.go | 25 ++++--- pkg/commands/logging/sumologic/update.go | 27 +++++--- pkg/commands/logging/syslog/create.go | 32 +++++---- pkg/commands/logging/syslog/delete.go | 15 ++-- pkg/commands/logging/syslog/describe.go | 27 +++++--- pkg/commands/logging/syslog/list.go | 25 ++++--- pkg/commands/logging/syslog/update.go | 35 ++++++---- pkg/commands/objectstore/create.go | 9 ++- pkg/commands/objectstore/delete.go | 9 ++- pkg/commands/objectstore/list.go | 9 ++- pkg/commands/purge/root.go | 2 +- pkg/commands/service/create.go | 11 ++- pkg/commands/service/delete.go | 13 ++-- pkg/commands/service/describe.go | 11 ++- pkg/commands/service/list.go | 9 ++- pkg/commands/service/search.go | 11 ++- pkg/commands/service/update.go | 15 ++-- pkg/commands/serviceauth/create.go | 15 ++-- pkg/commands/serviceauth/delete.go | 11 ++- pkg/commands/serviceauth/describe.go | 13 +++- pkg/commands/serviceauth/list.go | 2 + pkg/commands/serviceauth/update.go | 11 ++- pkg/commands/serviceversion/list.go | 9 ++- pkg/commands/serviceversion/update.go | 9 ++- pkg/commands/tls/config/describe.go | 4 +- pkg/commands/tls/config/list.go | 2 +- pkg/commands/tls/config/update.go | 2 +- pkg/commands/tls/custom/activation/create.go | 2 +- pkg/commands/tls/custom/activation/delete.go | 2 +- .../tls/custom/activation/describe.go | 4 +- pkg/commands/tls/custom/activation/list.go | 2 +- pkg/commands/tls/custom/activation/update.go | 2 +- pkg/commands/tls/custom/certificate/create.go | 4 +- pkg/commands/tls/custom/certificate/delete.go | 2 +- .../tls/custom/certificate/describe.go | 4 +- pkg/commands/tls/custom/certificate/list.go | 2 +- pkg/commands/tls/custom/certificate/update.go | 4 +- pkg/commands/tls/custom/domain/list.go | 2 +- pkg/commands/tls/custom/privatekey/create.go | 2 +- pkg/commands/tls/custom/privatekey/delete.go | 2 +- .../tls/custom/privatekey/describe.go | 4 +- pkg/commands/tls/custom/privatekey/list.go | 2 +- pkg/commands/tls/platform/create.go | 4 +- pkg/commands/tls/platform/delete.go | 2 +- pkg/commands/tls/platform/describe.go | 4 +- pkg/commands/tls/platform/list.go | 2 +- pkg/commands/tls/platform/update.go | 4 +- pkg/commands/tls/subscription/create.go | 4 +- pkg/commands/tls/subscription/delete.go | 4 +- pkg/commands/tls/subscription/describe.go | 4 +- pkg/commands/tls/subscription/list.go | 2 +- pkg/commands/tls/subscription/update.go | 4 +- pkg/commands/user/create.go | 4 +- pkg/commands/vcl/custom/create.go | 15 ++-- pkg/commands/vcl/custom/delete.go | 13 ++-- pkg/commands/vcl/custom/describe.go | 13 ++-- pkg/commands/vcl/custom/list.go | 13 ++-- pkg/commands/vcl/custom/update.go | 13 ++-- pkg/commands/vcl/snippet/create.go | 19 ++--- pkg/commands/vcl/snippet/delete.go | 13 ++-- pkg/commands/vcl/snippet/describe.go | 13 ++-- pkg/commands/vcl/snippet/list.go | 13 ++-- pkg/commands/vcl/snippet/update.go | 13 ++-- 227 files changed, 2997 insertions(+), 1806 deletions(-) diff --git a/pkg/commands/acl/create.go b/pkg/commands/acl/create.go index 786674849..34717cba1 100644 --- a/pkg/commands/acl/create.go +++ b/pkg/commands/acl/create.go @@ -35,6 +35,7 @@ func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest Action: c.autoClone.Set, Dst: &c.autoClone.Value, }) + c.CmdClause.Flag("name", "Name for the ACL. Must start with an alphanumeric character and contain only alphanumeric characters, underscores, and whitespace").Action(c.name.Set).StringVar(&c.name.Value) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagServiceIDName, Description: cmd.FlagServiceIDDesc, @@ -48,8 +49,6 @@ func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest Dst: &c.serviceName.Value, }) - c.CmdClause.Flag("name", "Name for the ACL. Must start with an alphanumeric character and contain only alphanumeric characters, underscores, and whitespace").Action(c.name.Set).StringVar(&c.name.Value) - return &c } diff --git a/pkg/commands/acl/delete.go b/pkg/commands/acl/delete.go index abdf411f6..f220fa3a2 100644 --- a/pkg/commands/acl/delete.go +++ b/pkg/commands/acl/delete.go @@ -13,12 +13,16 @@ import ( // NewDeleteCommand returns a usable command registered under the parent. func NewDeleteCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *DeleteCommand { - var c DeleteCommand - c.Globals = globals - c.manifest = data + c := DeleteCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("delete", "Delete an ACL from the specified service version").Alias("remove") - // Required flags + // required + c.CmdClause.Flag("name", "The name of the ACL to delete").Required().StringVar(&c.name) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagVersionName, Description: cmd.FlagVersionDesc, @@ -26,9 +30,7 @@ func NewDeleteCommand(parent cmd.Registerer, globals *config.Data, data manifest Required: true, }) - c.CmdClause.Flag("name", "The name of the ACL to delete").Required().StringVar(&c.name) - - // Optional flags + // optional c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ Action: c.autoClone.Set, Dst: &c.autoClone.Value, diff --git a/pkg/commands/acl/describe.go b/pkg/commands/acl/describe.go index ffe87e10d..056d457f6 100644 --- a/pkg/commands/acl/describe.go +++ b/pkg/commands/acl/describe.go @@ -22,7 +22,8 @@ func NewDescribeCommand(parent cmd.Registerer, globals *config.Data, data manife } c.CmdClause = parent.Command("describe", "Retrieve a single ACL by name for the version and service").Alias("get") - // Required flags + // required + c.CmdClause.Flag("name", "The name of the ACL").Required().StringVar(&c.name) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagVersionName, Description: cmd.FlagVersionDesc, @@ -30,9 +31,7 @@ func NewDescribeCommand(parent cmd.Registerer, globals *config.Data, data manife Required: true, }) - c.CmdClause.Flag("name", "The name of the ACL").Required().StringVar(&c.name) - - // Optional Flags + // optional c.RegisterFlagBool(cmd.BoolFlagOpts{ Name: cmd.FlagJSONName, Description: cmd.FlagJSONDesc, diff --git a/pkg/commands/acl/list.go b/pkg/commands/acl/list.go index d9791756f..31a9f8c74 100644 --- a/pkg/commands/acl/list.go +++ b/pkg/commands/acl/list.go @@ -23,7 +23,7 @@ func NewListCommand(parent cmd.Registerer, globals *config.Data, data manifest.D } c.CmdClause = parent.Command("list", "List ACLs") - // Required flags + // required c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagVersionName, Description: cmd.FlagVersionDesc, @@ -31,7 +31,7 @@ func NewListCommand(parent cmd.Registerer, globals *config.Data, data manifest.D Required: true, }) - // Optional Flags + // optional c.RegisterFlagBool(cmd.BoolFlagOpts{ Name: cmd.FlagJSONName, Description: cmd.FlagJSONDesc, diff --git a/pkg/commands/acl/update.go b/pkg/commands/acl/update.go index 86119213e..49042843b 100644 --- a/pkg/commands/acl/update.go +++ b/pkg/commands/acl/update.go @@ -21,7 +21,9 @@ func NewUpdateCommand(parent cmd.Registerer, globals *config.Data, data manifest } c.CmdClause = parent.Command("update", "Update an ACL for a particular service and version") - // Required flags + // required + c.CmdClause.Flag("name", "The name of the ACL to update").Required().StringVar(&c.name) + c.CmdClause.Flag("new-name", "The new name of the ACL").Required().StringVar(&c.newName) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagVersionName, Description: cmd.FlagVersionDesc, @@ -29,10 +31,7 @@ func NewUpdateCommand(parent cmd.Registerer, globals *config.Data, data manifest Required: true, }) - c.CmdClause.Flag("name", "The name of the ACL to update").Required().StringVar(&c.name) - c.CmdClause.Flag("new-name", "The new name of the ACL").Required().StringVar(&c.newName) - - // Optional flags + // optional c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ Action: c.autoClone.Set, Dst: &c.autoClone.Value, diff --git a/pkg/commands/aclentry/create.go b/pkg/commands/aclentry/create.go index 83a4102be..71c7f4b89 100644 --- a/pkg/commands/aclentry/create.go +++ b/pkg/commands/aclentry/create.go @@ -12,17 +12,20 @@ import ( // NewCreateCommand returns a usable command registered under the parent. func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *CreateCommand { - var c CreateCommand + c := CreateCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("create", "Add an ACL entry to an ACL").Alias("add") - c.Globals = globals - c.manifest = data - // Required flags + // required c.CmdClause.Flag("acl-id", "Alphanumeric string identifying a ACL").Required().StringVar(&c.aclID) - // Optional flags - c.CmdClause.Flag("ip", "An IP address").Action(c.ip.Set).StringVar(&c.ip.Value) + // optional c.CmdClause.Flag("comment", "A freeform descriptive note").Action(c.comment.Set).StringVar(&c.comment.Value) + c.CmdClause.Flag("ip", "An IP address").Action(c.ip.Set).StringVar(&c.ip.Value) c.CmdClause.Flag("negated", "Whether to negate the match").Action(c.negated.Set).BoolVar(&c.negated.Value) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagServiceIDName, diff --git a/pkg/commands/aclentry/delete.go b/pkg/commands/aclentry/delete.go index d2993ad48..6a8e89625 100644 --- a/pkg/commands/aclentry/delete.go +++ b/pkg/commands/aclentry/delete.go @@ -12,16 +12,19 @@ import ( // NewDeleteCommand returns a usable command registered under the parent. func NewDeleteCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *DeleteCommand { - var c DeleteCommand + c := DeleteCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("delete", "Delete an ACL entry from a specified ACL").Alias("remove") - c.Globals = globals - c.manifest = data - // Required flags + // required c.CmdClause.Flag("acl-id", "Alphanumeric string identifying a ACL").Required().StringVar(&c.aclID) c.CmdClause.Flag("id", "Alphanumeric string identifying an ACL Entry").Required().StringVar(&c.id) - // Optional flags + // optional c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagServiceIDName, Description: cmd.FlagServiceIDDesc, diff --git a/pkg/commands/aclentry/describe.go b/pkg/commands/aclentry/describe.go index 681b9ff30..b6a1dead3 100644 --- a/pkg/commands/aclentry/describe.go +++ b/pkg/commands/aclentry/describe.go @@ -14,16 +14,19 @@ import ( // NewDescribeCommand returns a usable command registered under the parent. func NewDescribeCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *DescribeCommand { - var c DescribeCommand + c := DescribeCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("describe", "Retrieve a single ACL entry").Alias("get") - c.Globals = globals - c.manifest = data - // Required flags + // required c.CmdClause.Flag("acl-id", "Alphanumeric string identifying a ACL").Required().StringVar(&c.aclID) c.CmdClause.Flag("id", "Alphanumeric string identifying an ACL Entry").Required().StringVar(&c.id) - // Optional Flags + // optional c.RegisterFlagBool(cmd.BoolFlagOpts{ Name: cmd.FlagJSONName, Description: cmd.FlagJSONDesc, diff --git a/pkg/commands/aclentry/list.go b/pkg/commands/aclentry/list.go index 886636e25..b5659218b 100644 --- a/pkg/commands/aclentry/list.go +++ b/pkg/commands/aclentry/list.go @@ -15,24 +15,24 @@ import ( // NewListCommand returns a usable command registered under the parent. func NewListCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *ListCommand { - var c ListCommand + c := ListCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("list", "List ACLs") - c.Globals = globals - c.manifest = data - // Required flags + // required c.CmdClause.Flag("acl-id", "Alphanumeric string identifying a ACL").Required().StringVar(&c.aclID) - // Optional Flags - c.CmdClause.Flag("direction", "Direction in which to sort results").Default(cmd.PaginationDirection[0]).HintOptions(cmd.PaginationDirection...).EnumVar(&c.direction, cmd.PaginationDirection...) + // optional c.RegisterFlagBool(cmd.BoolFlagOpts{ Name: cmd.FlagJSONName, Description: cmd.FlagJSONDesc, Dst: &c.json, Short: 'j', }) - c.CmdClause.Flag("page", "Page number of data set to fetch").IntVar(&c.page) - c.CmdClause.Flag("per-page", "Number of records per page").IntVar(&c.perPage) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagServiceIDName, Description: cmd.FlagServiceIDDesc, @@ -45,6 +45,10 @@ func NewListCommand(parent cmd.Registerer, globals *config.Data, data manifest.D Description: cmd.FlagServiceDesc, Dst: &c.serviceName.Value, }) + + c.CmdClause.Flag("direction", "Direction in which to sort results").Default(cmd.PaginationDirection[0]).HintOptions(cmd.PaginationDirection...).EnumVar(&c.direction, cmd.PaginationDirection...) + c.CmdClause.Flag("page", "Page number of data set to fetch").IntVar(&c.page) + c.CmdClause.Flag("per-page", "Number of records per page").IntVar(&c.perPage) c.CmdClause.Flag("sort", "Field on which to sort").Default("created").StringVar(&c.sort) return &c diff --git a/pkg/commands/aclentry/update.go b/pkg/commands/aclentry/update.go index 22d129744..5358dfc63 100644 --- a/pkg/commands/aclentry/update.go +++ b/pkg/commands/aclentry/update.go @@ -15,15 +15,18 @@ import ( // NewUpdateCommand returns a usable command registered under the parent. func NewUpdateCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *UpdateCommand { - var c UpdateCommand + c := UpdateCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("update", "Update an ACL entry for a specified ACL") - c.Globals = globals - c.manifest = data - // Required flags + // required c.CmdClause.Flag("acl-id", "Alphanumeric string identifying a ACL").Required().StringVar(&c.aclID) - // Optional flags + // optional c.CmdClause.Flag("comment", "A freeform descriptive note").Action(c.comment.Set).StringVar(&c.comment.Value) c.CmdClause.Flag("file", "Batch update json passed as file path or content, e.g. $(< batch.json)").Action(c.file.Set).StringVar(&c.file.Value) c.CmdClause.Flag("id", "Alphanumeric string identifying an ACL Entry").Action(c.id.Set).StringVar(&c.id.Value) diff --git a/pkg/commands/authtoken/create.go b/pkg/commands/authtoken/create.go index 8975d06af..6aff16091 100644 --- a/pkg/commands/authtoken/create.go +++ b/pkg/commands/authtoken/create.go @@ -20,12 +20,15 @@ var Scopes = []string{"global", "purge_select", "purge_all", "global:read"} // NewCreateCommand returns a usable command registered under the parent. func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *CreateCommand { - var c CreateCommand + c := CreateCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("create", "Create an API token").Alias("add") - c.Globals = globals - c.manifest = data - // Required flags + // required // // NOTE: The go-fastly client internally calls `/sudo` before `/tokens` and // the sudo endpoint requires a password to be provided alongside an API @@ -33,7 +36,7 @@ func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest // being passed as authentication to the API endpoint. c.CmdClause.Flag("password", "User password corresponding with --token or $FASTLY_API_TOKEN").Required().StringVar(&c.password) - // Optional flags + // optional // // NOTE: The API describes 'scope' as being space-delimited but we've opted // for comma-separated as it means users don't have to worry about how best diff --git a/pkg/commands/authtoken/delete.go b/pkg/commands/authtoken/delete.go index c55ffedcb..ae60e266c 100644 --- a/pkg/commands/authtoken/delete.go +++ b/pkg/commands/authtoken/delete.go @@ -17,10 +17,14 @@ import ( // NewDeleteCommand returns a usable command registered under the parent. func NewDeleteCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *DeleteCommand { - var c DeleteCommand + c := DeleteCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("delete", "Revoke an API token").Alias("remove") - c.Globals = globals - c.manifest = data + c.CmdClause.Flag("current", "Revoke the token used to authenticate the request").BoolVar(&c.current) c.CmdClause.Flag("file", "Revoke tokens in bulk from a newline delimited list of tokens").StringVar(&c.file) c.CmdClause.Flag("id", "Alphanumeric string identifying a token").StringVar(&c.id) diff --git a/pkg/commands/authtoken/describe.go b/pkg/commands/authtoken/describe.go index 279fa0a1b..ef30e757a 100644 --- a/pkg/commands/authtoken/describe.go +++ b/pkg/commands/authtoken/describe.go @@ -15,10 +15,14 @@ import ( // NewDescribeCommand returns a usable command registered under the parent. func NewDescribeCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *DescribeCommand { - var c DescribeCommand + c := DescribeCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("describe", "Get the current API token").Alias("get") - c.Globals = globals - c.manifest = data + c.RegisterFlagBool(cmd.BoolFlagOpts{ Name: cmd.FlagJSONName, Description: cmd.FlagJSONDesc, diff --git a/pkg/commands/authtoken/list.go b/pkg/commands/authtoken/list.go index e3e2c090e..1114fd78b 100644 --- a/pkg/commands/authtoken/list.go +++ b/pkg/commands/authtoken/list.go @@ -16,10 +16,14 @@ import ( // NewListCommand returns a usable command registered under the parent. func NewListCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *ListCommand { - var c ListCommand + c := ListCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("list", "List API tokens") - c.Globals = globals - c.manifest = data + c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagCustomerIDName, Description: cmd.FlagCustomerIDDesc, diff --git a/pkg/commands/backend/create.go b/pkg/commands/backend/create.go index 9737dcb8f..bae62bd5c 100644 --- a/pkg/commands/backend/create.go +++ b/pkg/commands/backend/create.go @@ -51,56 +51,64 @@ type CreateCommand struct { // NewCreateCommand returns a usable command registered under the parent. func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *CreateCommand { - var c CreateCommand - c.Globals = globals - c.manifest = data + c := CreateCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("create", "Create a backend on a Fastly service version").Alias("add") - c.RegisterFlag(cmd.StringFlagOpts{ - Name: cmd.FlagServiceIDName, - Description: cmd.FlagServiceIDDesc, - Dst: &c.manifest.Flag.ServiceID, - Short: 's', - }) - c.RegisterFlag(cmd.StringFlagOpts{ - Action: c.serviceName.Set, - Name: cmd.FlagServiceName, - Description: cmd.FlagServiceDesc, - Dst: &c.serviceName.Value, - }) + + // required c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagVersionName, Description: cmd.FlagVersionDesc, Dst: &c.serviceVersion.Value, Required: true, }) + + // optional + + c.CmdClause.Flag("address", "A hostname, IPv4, or IPv6 address for the backend").Action(c.address.Set).StringVar(&c.address.Value) c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ Action: c.autoClone.Set, Dst: &c.autoClone.Value, }) - c.CmdClause.Flag("name", "Backend name").Short('n').Action(c.name.Set).StringVar(&c.name.Value) + c.CmdClause.Flag("auto-loadbalance", "Whether or not this backend should be automatically load balanced").Action(c.autoLoadBalance.Set).BoolVar(&c.autoLoadBalance.Value) + c.CmdClause.Flag("between-bytes-timeout", "How long to wait between bytes in milliseconds").Action(c.betweenBytesTimeout.Set).IntVar(&c.betweenBytesTimeout.Value) c.CmdClause.Flag("comment", "A descriptive note").Action(c.comment.Set).StringVar(&c.comment.Value) - c.CmdClause.Flag("address", "A hostname, IPv4, or IPv6 address for the backend").Action(c.address.Set).StringVar(&c.address.Value) - c.CmdClause.Flag("port", "Port number of the address").Action(c.port.Set).IntVar(&c.port.Value) - c.CmdClause.Flag("override-host", "The hostname to override the Host header").Action(c.overrideHost.Set).StringVar(&c.overrideHost.Value) c.CmdClause.Flag("connect-timeout", "How long to wait for a timeout in milliseconds").Action(c.connectTimeout.Set).IntVar(&c.connectTimeout.Value) - c.CmdClause.Flag("max-conn", "Maximum number of connections").Action(c.maxConn.Set).IntVar(&c.maxConn.Value) c.CmdClause.Flag("first-byte-timeout", "How long to wait for the first bytes in milliseconds").Action(c.firstByteTimeout.Set).IntVar(&c.firstByteTimeout.Value) - c.CmdClause.Flag("between-bytes-timeout", "How long to wait between bytes in milliseconds").Action(c.betweenBytesTimeout.Set).IntVar(&c.betweenBytesTimeout.Value) - c.CmdClause.Flag("auto-loadbalance", "Whether or not this backend should be automatically load balanced").Action(c.autoLoadBalance.Set).BoolVar(&c.autoLoadBalance.Value) - c.CmdClause.Flag("weight", "Weight used to load balance this backend against others").Action(c.weight.Set).IntVar(&c.weight.Value) - c.CmdClause.Flag("request-condition", "Condition, which if met, will select this backend during a request").Action(c.requestCondition.Set).StringVar(&c.requestCondition.Value) c.CmdClause.Flag("healthcheck", "The name of the healthcheck to use with this backend").Action(c.healthCheck.Set).StringVar(&c.healthCheck.Value) + c.CmdClause.Flag("max-conn", "Maximum number of connections").Action(c.maxConn.Set).IntVar(&c.maxConn.Value) + c.CmdClause.Flag("max-tls-version", "Maximum allowed TLS version on SSL connections to this backend").Action(c.maxTLSVersion.Set).StringVar(&c.maxTLSVersion.Value) + c.CmdClause.Flag("min-tls-version", "Minimum allowed TLS version on SSL connections to this backend").Action(c.minTLSVersion.Set).StringVar(&c.minTLSVersion.Value) + c.CmdClause.Flag("name", "Backend name").Short('n').Action(c.name.Set).StringVar(&c.name.Value) + c.CmdClause.Flag("override-host", "The hostname to override the Host header").Action(c.overrideHost.Set).StringVar(&c.overrideHost.Value) + c.CmdClause.Flag("port", "Port number of the address").Action(c.port.Set).IntVar(&c.port.Value) + c.CmdClause.Flag("request-condition", "Condition, which if met, will select this backend during a request").Action(c.requestCondition.Set).StringVar(&c.requestCondition.Value) + c.RegisterFlag(cmd.StringFlagOpts{ + Name: cmd.FlagServiceIDName, + Description: cmd.FlagServiceIDDesc, + Dst: &c.manifest.Flag.ServiceID, + Short: 's', + }) + c.RegisterFlag(cmd.StringFlagOpts{ + Action: c.serviceName.Set, + Name: cmd.FlagServiceName, + Description: cmd.FlagServiceDesc, + Dst: &c.serviceName.Value, + }) c.CmdClause.Flag("shield", "The shield POP designated to reduce inbound load on this origin by serving the cached data to the rest of the network").Action(c.shield.Set).StringVar(&c.shield.Value) - c.CmdClause.Flag("use-ssl", "Whether or not to use SSL to reach the backend").Action(c.useSSL.Set).BoolVar(&c.useSSL.Value) - c.CmdClause.Flag("ssl-check-cert", "Be strict on checking SSL certs").Action(c.sslCheckCert.Set).BoolVar(&c.sslCheckCert.Value) c.CmdClause.Flag("ssl-ca-cert", "CA certificate attached to origin").Action(c.sslCACert.Set).StringVar(&c.sslCACert.Value) + c.CmdClause.Flag("ssl-cert-hostname", "Overrides ssl_hostname, but only for cert verification. Does not affect SNI at all.").Action(c.sslCertHostname.Set).StringVar(&c.sslCertHostname.Value) + c.CmdClause.Flag("ssl-check-cert", "Be strict on checking SSL certs").Action(c.sslCheckCert.Set).BoolVar(&c.sslCheckCert.Value) + c.CmdClause.Flag("ssl-ciphers", "List of OpenSSL ciphers (https://www.openssl.org/docs/man1.0.2/man1/ciphers)").Action(c.sslCiphers.Set).StringVar(&c.sslCiphers.Value) c.CmdClause.Flag("ssl-client-cert", "Client certificate attached to origin").Action(c.sslClientCert.Set).StringVar(&c.sslClientCert.Value) c.CmdClause.Flag("ssl-client-key", "Client key attached to origin").Action(c.sslClientKey.Set).StringVar(&c.sslClientKey.Value) - c.CmdClause.Flag("ssl-cert-hostname", "Overrides ssl_hostname, but only for cert verification. Does not affect SNI at all.").Action(c.sslCertHostname.Set).StringVar(&c.sslCertHostname.Value) c.CmdClause.Flag("ssl-sni-hostname", "Overrides ssl_hostname, but only for SNI in the handshake. Does not affect cert validation at all.").Action(c.sslSNIHostname.Set).StringVar(&c.sslSNIHostname.Value) - c.CmdClause.Flag("min-tls-version", "Minimum allowed TLS version on SSL connections to this backend").Action(c.minTLSVersion.Set).StringVar(&c.minTLSVersion.Value) - c.CmdClause.Flag("max-tls-version", "Maximum allowed TLS version on SSL connections to this backend").Action(c.maxTLSVersion.Set).StringVar(&c.maxTLSVersion.Value) - c.CmdClause.Flag("ssl-ciphers", "List of OpenSSL ciphers (https://www.openssl.org/docs/man1.0.2/man1/ciphers)").Action(c.sslCiphers.Set).StringVar(&c.sslCiphers.Value) + c.CmdClause.Flag("use-ssl", "Whether or not to use SSL to reach the backend").Action(c.useSSL.Set).BoolVar(&c.useSSL.Value) + c.CmdClause.Flag("weight", "Weight used to load balance this backend against others").Action(c.weight.Set).IntVar(&c.weight.Value) return &c } diff --git a/pkg/commands/backend/delete.go b/pkg/commands/backend/delete.go index 1d815de01..9cc964bc3 100644 --- a/pkg/commands/backend/delete.go +++ b/pkg/commands/backend/delete.go @@ -23,10 +23,28 @@ type DeleteCommand struct { // NewDeleteCommand returns a usable command registered under the parent. func NewDeleteCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *DeleteCommand { - var c DeleteCommand - c.Globals = globals - c.manifest = data + c := DeleteCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("delete", "Delete a backend on a Fastly service version").Alias("remove") + + // required + c.CmdClause.Flag("name", "Backend name").Short('n').Required().StringVar(&c.Input.Name) + c.RegisterFlag(cmd.StringFlagOpts{ + Name: cmd.FlagVersionName, + Description: cmd.FlagVersionDesc, + Dst: &c.serviceVersion.Value, + Required: true, + }) + + // optional + c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ + Action: c.autoClone.Set, + Dst: &c.autoClone.Value, + }) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagServiceIDName, Description: cmd.FlagServiceIDDesc, @@ -39,17 +57,7 @@ func NewDeleteCommand(parent cmd.Registerer, globals *config.Data, data manifest Description: cmd.FlagServiceDesc, Dst: &c.serviceName.Value, }) - c.RegisterFlag(cmd.StringFlagOpts{ - Name: cmd.FlagVersionName, - Description: cmd.FlagVersionDesc, - Dst: &c.serviceVersion.Value, - Required: true, - }) - c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ - Action: c.autoClone.Set, - Dst: &c.autoClone.Value, - }) - c.CmdClause.Flag("name", "Backend name").Short('n').Required().StringVar(&c.Input.Name) + return &c } diff --git a/pkg/commands/backend/describe.go b/pkg/commands/backend/describe.go index 674da23a0..46e6829df 100644 --- a/pkg/commands/backend/describe.go +++ b/pkg/commands/backend/describe.go @@ -24,10 +24,24 @@ type DescribeCommand struct { // NewDescribeCommand returns a usable command registered under the parent. func NewDescribeCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *DescribeCommand { - var c DescribeCommand - c.Globals = globals - c.manifest = data + c := DescribeCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("describe", "Show detailed information about a backend on a Fastly service version").Alias("get") + + // required + c.CmdClause.Flag("name", "Name of backend").Short('n').Required().StringVar(&c.Input.Name) + c.RegisterFlag(cmd.StringFlagOpts{ + Name: cmd.FlagVersionName, + Description: cmd.FlagVersionDesc, + Dst: &c.serviceVersion.Value, + Required: true, + }) + + // optional c.RegisterFlagBool(cmd.BoolFlagOpts{ Name: cmd.FlagJSONName, Description: cmd.FlagJSONDesc, @@ -46,13 +60,6 @@ func NewDescribeCommand(parent cmd.Registerer, globals *config.Data, data manife Description: cmd.FlagServiceDesc, Dst: &c.serviceName.Value, }) - c.RegisterFlag(cmd.StringFlagOpts{ - Name: cmd.FlagVersionName, - Description: cmd.FlagVersionDesc, - Dst: &c.serviceVersion.Value, - Required: true, - }) - c.CmdClause.Flag("name", "Name of backend").Short('n').Required().StringVar(&c.Input.Name) return &c } diff --git a/pkg/commands/backend/list.go b/pkg/commands/backend/list.go index cbfd58fa6..d00c874cf 100644 --- a/pkg/commands/backend/list.go +++ b/pkg/commands/backend/list.go @@ -25,10 +25,23 @@ type ListCommand struct { // NewListCommand returns a usable command registered under the parent. func NewListCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *ListCommand { - var c ListCommand - c.Globals = globals - c.manifest = data + c := ListCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("list", "List backends on a Fastly service version") + + // required + c.RegisterFlag(cmd.StringFlagOpts{ + Name: cmd.FlagVersionName, + Description: cmd.FlagVersionDesc, + Dst: &c.serviceVersion.Value, + Required: true, + }) + + // optional c.RegisterFlagBool(cmd.BoolFlagOpts{ Name: cmd.FlagJSONName, Description: cmd.FlagJSONDesc, @@ -47,12 +60,6 @@ func NewListCommand(parent cmd.Registerer, globals *config.Data, data manifest.D Description: cmd.FlagServiceDesc, Dst: &c.serviceName.Value, }) - c.RegisterFlag(cmd.StringFlagOpts{ - Name: cmd.FlagVersionName, - Description: cmd.FlagVersionDesc, - Dst: &c.serviceVersion.Value, - Required: true, - }) return &c } diff --git a/pkg/commands/backend/update.go b/pkg/commands/backend/update.go index 003c428d4..896b09b2a 100644 --- a/pkg/commands/backend/update.go +++ b/pkg/commands/backend/update.go @@ -49,57 +49,64 @@ type UpdateCommand struct { // NewUpdateCommand returns a usable command registered under the parent. func NewUpdateCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *UpdateCommand { - var c UpdateCommand - c.Globals = globals - c.manifest = data + c := UpdateCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("update", "Update a backend on a Fastly service version") - c.RegisterFlag(cmd.StringFlagOpts{ - Name: cmd.FlagServiceIDName, - Description: cmd.FlagServiceIDDesc, - Dst: &c.manifest.Flag.ServiceID, - Short: 's', - }) - c.RegisterFlag(cmd.StringFlagOpts{ - Action: c.serviceName.Set, - Name: cmd.FlagServiceName, - Description: cmd.FlagServiceDesc, - Dst: &c.serviceName.Value, - }) + + // required c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagVersionName, Description: cmd.FlagVersionDesc, Dst: &c.serviceVersion.Value, Required: true, }) + c.CmdClause.Flag("name", "backend name").Short('n').Required().StringVar(&c.name) + + // optional + c.CmdClause.Flag("address", "A hostname, IPv4, or IPv6 address for the backend").Action(c.Address.Set).StringVar(&c.Address.Value) c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ Action: c.autoClone.Set, Dst: &c.autoClone.Value, }) - c.CmdClause.Flag("name", "backend name").Short('n').Required().StringVar(&c.name) - c.CmdClause.Flag("new-name", "New backend name").Action(c.NewName.Set).StringVar(&c.NewName.Value) + c.CmdClause.Flag("auto-loadbalance", "Whether or not this backend should be automatically load balanced").Action(c.AutoLoadbalance.Set).BoolVar(&c.AutoLoadbalance.Value) + c.CmdClause.Flag("between-bytes-timeout", "How long to wait between bytes in milliseconds").Action(c.BetweenBytesTimeout.Set).IntVar(&c.BetweenBytesTimeout.Value) c.CmdClause.Flag("comment", "A descriptive note").Action(c.Comment.Set).StringVar(&c.Comment.Value) - c.CmdClause.Flag("address", "A hostname, IPv4, or IPv6 address for the backend").Action(c.Address.Set).StringVar(&c.Address.Value) - c.CmdClause.Flag("port", "Port number of the address").Action(c.Port.Set).IntVar(&c.Port.Value) - c.CmdClause.Flag("override-host", "The hostname to override the Host header").Action(c.OverrideHost.Set).StringVar(&c.OverrideHost.Value) c.CmdClause.Flag("connect-timeout", "How long to wait for a timeout in milliseconds").Action(c.ConnectTimeout.Set).IntVar(&c.ConnectTimeout.Value) - c.CmdClause.Flag("max-conn", "Maximum number of connections").Action(c.MaxConn.Set).IntVar(&c.MaxConn.Value) c.CmdClause.Flag("first-byte-timeout", "How long to wait for the first bytes in milliseconds").Action(c.FirstByteTimeout.Set).IntVar(&c.FirstByteTimeout.Value) - c.CmdClause.Flag("between-bytes-timeout", "How long to wait between bytes in milliseconds").Action(c.BetweenBytesTimeout.Set).IntVar(&c.BetweenBytesTimeout.Value) - c.CmdClause.Flag("auto-loadbalance", "Whether or not this backend should be automatically load balanced").Action(c.AutoLoadbalance.Set).BoolVar(&c.AutoLoadbalance.Value) - c.CmdClause.Flag("weight", "Weight used to load balance this backend against others").Action(c.Weight.Set).IntVar(&c.Weight.Value) - c.CmdClause.Flag("request-condition", "condition, which if met, will select this backend during a request").Action(c.RequestCondition.Set).StringVar(&c.RequestCondition.Value) c.CmdClause.Flag("healthcheck", "The name of the healthcheck to use with this backend").Action(c.HealthCheck.Set).StringVar(&c.HealthCheck.Value) + c.CmdClause.Flag("max-conn", "Maximum number of connections").Action(c.MaxConn.Set).IntVar(&c.MaxConn.Value) + c.CmdClause.Flag("max-tls-version", "Maximum allowed TLS version on SSL connections to this backend").Action(c.MaxTLSVersion.Set).StringVar(&c.MaxTLSVersion.Value) + c.CmdClause.Flag("min-tls-version", "Minimum allowed TLS version on SSL connections to this backend").Action(c.MinTLSVersion.Set).StringVar(&c.MinTLSVersion.Value) + c.CmdClause.Flag("new-name", "New backend name").Action(c.NewName.Set).StringVar(&c.NewName.Value) + c.CmdClause.Flag("override-host", "The hostname to override the Host header").Action(c.OverrideHost.Set).StringVar(&c.OverrideHost.Value) + c.CmdClause.Flag("port", "Port number of the address").Action(c.Port.Set).IntVar(&c.Port.Value) + c.CmdClause.Flag("request-condition", "condition, which if met, will select this backend during a request").Action(c.RequestCondition.Set).StringVar(&c.RequestCondition.Value) + c.RegisterFlag(cmd.StringFlagOpts{ + Name: cmd.FlagServiceIDName, + Description: cmd.FlagServiceIDDesc, + Dst: &c.manifest.Flag.ServiceID, + Short: 's', + }) + c.RegisterFlag(cmd.StringFlagOpts{ + Action: c.serviceName.Set, + Name: cmd.FlagServiceName, + Description: cmd.FlagServiceDesc, + Dst: &c.serviceName.Value, + }) c.CmdClause.Flag("shield", "The shield POP designated to reduce inbound load on this origin by serving the cached data to the rest of the network").Action(c.Shield.Set).StringVar(&c.Shield.Value) - c.CmdClause.Flag("use-ssl", "Whether or not to use SSL to reach the backend").Action(c.UseSSL.Set).BoolVar(&c.UseSSL.Value) - c.CmdClause.Flag("ssl-check-cert", "Be strict on checking SSL certs").Action(c.SSLCheckCert.Set).BoolVar(&c.SSLCheckCert.Value) c.CmdClause.Flag("ssl-ca-cert", "CA certificate attached to origin").Action(c.SSLCACert.Set).StringVar(&c.SSLCACert.Value) + c.CmdClause.Flag("ssl-cert-hostname", "Overrides ssl_hostname, but only for cert verification. Does not affect SNI at all.").Action(c.SSLCertHostname.Set).StringVar(&c.SSLCertHostname.Value) + c.CmdClause.Flag("ssl-check-cert", "Be strict on checking SSL certs").Action(c.SSLCheckCert.Set).BoolVar(&c.SSLCheckCert.Value) + c.CmdClause.Flag("ssl-ciphers", "List of OpenSSL ciphers (https://www.openssl.org/docs/man1.0.2/man1/ciphers)").Action(c.SSLCiphers.Set).StringVar(&c.SSLCiphers.Value) c.CmdClause.Flag("ssl-client-cert", "Client certificate attached to origin").Action(c.SSLClientCert.Set).StringVar(&c.SSLClientCert.Value) c.CmdClause.Flag("ssl-client-key", "Client key attached to origin").Action(c.SSLClientKey.Set).StringVar(&c.SSLClientKey.Value) - c.CmdClause.Flag("ssl-cert-hostname", "Overrides ssl_hostname, but only for cert verification. Does not affect SNI at all.").Action(c.SSLCertHostname.Set).StringVar(&c.SSLCertHostname.Value) c.CmdClause.Flag("ssl-sni-hostname", "Overrides ssl_hostname, but only for SNI in the handshake. Does not affect cert validation at all.").Action(c.SSLSNIHostname.Set).StringVar(&c.SSLSNIHostname.Value) - c.CmdClause.Flag("min-tls-version", "Minimum allowed TLS version on SSL connections to this backend").Action(c.MinTLSVersion.Set).StringVar(&c.MinTLSVersion.Value) - c.CmdClause.Flag("max-tls-version", "Maximum allowed TLS version on SSL connections to this backend").Action(c.MaxTLSVersion.Set).StringVar(&c.MaxTLSVersion.Value) - c.CmdClause.Flag("ssl-ciphers", "List of OpenSSL ciphers (https://www.openssl.org/docs/man1.0.2/man1/ciphers)").Action(c.SSLCiphers.Set).StringVar(&c.SSLCiphers.Value) + c.CmdClause.Flag("use-ssl", "Whether or not to use SSL to reach the backend").Action(c.UseSSL.Set).BoolVar(&c.UseSSL.Value) + c.CmdClause.Flag("weight", "Weight used to load balance this backend against others").Action(c.Weight.Set).IntVar(&c.Weight.Value) return &c } diff --git a/pkg/commands/compute/update.go b/pkg/commands/compute/update.go index 72de447f5..d46df0caf 100644 --- a/pkg/commands/compute/update.go +++ b/pkg/commands/compute/update.go @@ -26,9 +26,12 @@ type UpdateCommand struct { // NewUpdateCommand returns a usable command registered under the parent. func NewUpdateCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *UpdateCommand { - var c UpdateCommand - c.Globals = globals - c.manifest = data + c := UpdateCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("update", "Update a package on a Fastly Compute@Edge service version") c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagServiceIDName, diff --git a/pkg/commands/dictionary/create.go b/pkg/commands/dictionary/create.go index 51449e4d9..b8057d068 100644 --- a/pkg/commands/dictionary/create.go +++ b/pkg/commands/dictionary/create.go @@ -28,10 +28,28 @@ type CreateCommand struct { // NewCreateCommand returns a usable command registered under the parent. func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *CreateCommand { - var c CreateCommand - c.Globals = globals - c.manifest = data + c := CreateCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("create", "Create a Fastly edge dictionary on a Fastly service version") + + // required + c.RegisterFlag(cmd.StringFlagOpts{ + Name: cmd.FlagVersionName, + Description: cmd.FlagVersionDesc, + Dst: &c.serviceVersion.Value, + Required: true, + }) + + // optional + c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ + Action: c.autoClone.Set, + Dst: &c.autoClone.Value, + }) + c.CmdClause.Flag("name", "Name of Dictionary").Short('n').Action(c.name.Set).StringVar(&c.name.Value) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagServiceIDName, Description: cmd.FlagServiceIDDesc, @@ -44,17 +62,6 @@ func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest Description: cmd.FlagServiceDesc, Dst: &c.serviceName.Value, }) - c.RegisterFlag(cmd.StringFlagOpts{ - Name: cmd.FlagVersionName, - Description: cmd.FlagVersionDesc, - Dst: &c.serviceVersion.Value, - Required: true, - }) - c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ - Action: c.autoClone.Set, - Dst: &c.autoClone.Value, - }) - c.CmdClause.Flag("name", "Name of Dictionary").Short('n').Action(c.name.Set).StringVar(&c.name.Value) c.CmdClause.Flag("write-only", "Whether to mark this dictionary as write-only").Action(c.writeOnly.Set).BoolVar(&c.writeOnly.Value) return &c } diff --git a/pkg/commands/dictionary/delete.go b/pkg/commands/dictionary/delete.go index 0d425a354..211f1818b 100644 --- a/pkg/commands/dictionary/delete.go +++ b/pkg/commands/dictionary/delete.go @@ -23,10 +23,28 @@ type DeleteCommand struct { // NewDeleteCommand returns a usable command registered under the parent. func NewDeleteCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *DeleteCommand { - var c DeleteCommand - c.Globals = globals - c.manifest = data + c := DeleteCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("delete", "Delete a Fastly edge dictionary from a Fastly service version") + + // required + c.CmdClause.Flag("name", "Name of Dictionary").Short('n').Required().StringVar(&c.Input.Name) + c.RegisterFlag(cmd.StringFlagOpts{ + Name: cmd.FlagVersionName, + Description: cmd.FlagVersionDesc, + Dst: &c.serviceVersion.Value, + Required: true, + }) + + // optional + c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ + Action: c.autoClone.Set, + Dst: &c.autoClone.Value, + }) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagServiceIDName, Description: cmd.FlagServiceIDDesc, @@ -39,17 +57,6 @@ func NewDeleteCommand(parent cmd.Registerer, globals *config.Data, data manifest Description: cmd.FlagServiceDesc, Dst: &c.serviceName.Value, }) - c.RegisterFlag(cmd.StringFlagOpts{ - Name: cmd.FlagVersionName, - Description: cmd.FlagVersionDesc, - Dst: &c.serviceVersion.Value, - Required: true, - }) - c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ - Action: c.autoClone.Set, - Dst: &c.autoClone.Value, - }) - c.CmdClause.Flag("name", "Name of Dictionary").Short('n').Required().StringVar(&c.Input.Name) return &c } diff --git a/pkg/commands/dictionary/describe.go b/pkg/commands/dictionary/describe.go index 8523f323a..179bb8fad 100644 --- a/pkg/commands/dictionary/describe.go +++ b/pkg/commands/dictionary/describe.go @@ -25,10 +25,24 @@ type DescribeCommand struct { // NewDescribeCommand returns a usable command registered under the parent. func NewDescribeCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *DescribeCommand { - var c DescribeCommand - c.Globals = globals - c.manifest = data + c := DescribeCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("describe", "Show detailed information about a Fastly edge dictionary").Alias("get") + + // required + c.CmdClause.Flag("name", "Name of Dictionary").Short('n').Required().StringVar(&c.Input.Name) + c.RegisterFlag(cmd.StringFlagOpts{ + Name: cmd.FlagVersionName, + Description: cmd.FlagVersionDesc, + Dst: &c.serviceVersion.Value, + Required: true, + }) + + // optional c.RegisterFlagBool(cmd.BoolFlagOpts{ Name: cmd.FlagJSONName, Description: cmd.FlagJSONDesc, @@ -47,13 +61,6 @@ func NewDescribeCommand(parent cmd.Registerer, globals *config.Data, data manife Description: cmd.FlagServiceDesc, Dst: &c.serviceName.Value, }) - c.RegisterFlag(cmd.StringFlagOpts{ - Name: cmd.FlagVersionName, - Description: cmd.FlagVersionDesc, - Dst: &c.serviceVersion.Value, - Required: true, - }) - c.CmdClause.Flag("name", "Name of Dictionary").Short('n').Required().StringVar(&c.Input.Name) return &c } diff --git a/pkg/commands/dictionary/list.go b/pkg/commands/dictionary/list.go index 40e1c8ad4..1dd406459 100644 --- a/pkg/commands/dictionary/list.go +++ b/pkg/commands/dictionary/list.go @@ -25,10 +25,23 @@ type ListCommand struct { // NewListCommand returns a usable command registered under the parent func NewListCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *ListCommand { - var c ListCommand - c.Globals = globals - c.manifest = data + c := ListCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("list", "List all dictionaries on a Fastly service version") + + // required + c.RegisterFlag(cmd.StringFlagOpts{ + Name: cmd.FlagVersionName, + Description: cmd.FlagVersionDesc, + Dst: &c.serviceVersion.Value, + Required: true, + }) + + // optional c.RegisterFlagBool(cmd.BoolFlagOpts{ Name: cmd.FlagJSONName, Description: cmd.FlagJSONDesc, @@ -47,12 +60,6 @@ func NewListCommand(parent cmd.Registerer, globals *config.Data, data manifest.D Description: cmd.FlagServiceDesc, Dst: &c.serviceName.Value, }) - c.RegisterFlag(cmd.StringFlagOpts{ - Name: cmd.FlagVersionName, - Description: cmd.FlagVersionDesc, - Dst: &c.serviceVersion.Value, - Required: true, - }) return &c } diff --git a/pkg/commands/dictionary/update.go b/pkg/commands/dictionary/update.go index 0352d25a1..1f7ab2554 100644 --- a/pkg/commands/dictionary/update.go +++ b/pkg/commands/dictionary/update.go @@ -29,10 +29,29 @@ type UpdateCommand struct { // NewUpdateCommand returns a usable command registered under the parent. func NewUpdateCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *UpdateCommand { - var c UpdateCommand - c.Globals = globals - c.manifest = data + c := UpdateCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("update", "Update name of dictionary on a Fastly service version").Alias("get") + + // required + c.CmdClause.Flag("name", "Old name of Dictionary").Short('n').Required().StringVar(&c.input.Name) + c.RegisterFlag(cmd.StringFlagOpts{ + Name: cmd.FlagVersionName, + Description: cmd.FlagVersionDesc, + Dst: &c.serviceVersion.Value, + Required: true, + }) + + // optional + c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ + Action: c.autoClone.Set, + Dst: &c.autoClone.Value, + }) + c.CmdClause.Flag("new-name", "New name of Dictionary").Action(c.newname.Set).StringVar(&c.newname.Value) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagServiceIDName, Description: cmd.FlagServiceIDDesc, @@ -45,18 +64,6 @@ func NewUpdateCommand(parent cmd.Registerer, globals *config.Data, data manifest Description: cmd.FlagServiceDesc, Dst: &c.serviceName.Value, }) - c.RegisterFlag(cmd.StringFlagOpts{ - Name: cmd.FlagVersionName, - Description: cmd.FlagVersionDesc, - Dst: &c.serviceVersion.Value, - Required: true, - }) - c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ - Action: c.autoClone.Set, - Dst: &c.autoClone.Value, - }) - c.CmdClause.Flag("name", "Old name of Dictionary").Short('n').Required().StringVar(&c.input.Name) - c.CmdClause.Flag("new-name", "New name of Dictionary").Action(c.newname.Set).StringVar(&c.newname.Value) c.CmdClause.Flag("write-only", "Whether to mark this dictionary as write-only. Can be true or false (defaults to false)").Action(c.writeOnly.Set).StringVar(&c.writeOnly.Value) return &c } diff --git a/pkg/commands/dictionaryitem/create.go b/pkg/commands/dictionaryitem/create.go index 4435cca05..ae817ee0e 100644 --- a/pkg/commands/dictionaryitem/create.go +++ b/pkg/commands/dictionaryitem/create.go @@ -20,10 +20,20 @@ type CreateCommand struct { // NewCreateCommand returns a usable command registered under the parent. func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *CreateCommand { - var c CreateCommand - c.Globals = globals - c.manifest = data + c := CreateCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("create", "Create a new item on a Fastly edge dictionary") + + // required + c.CmdClause.Flag("dictionary-id", "Dictionary ID").Required().StringVar(&c.Input.DictionaryID) + c.CmdClause.Flag("key", "Dictionary item key").Required().StringVar(&c.Input.ItemKey) + c.CmdClause.Flag("value", "Dictionary item value").Required().StringVar(&c.Input.ItemValue) + + // optional c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagServiceIDName, Description: cmd.FlagServiceIDDesc, @@ -36,9 +46,6 @@ func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest Description: cmd.FlagServiceDesc, Dst: &c.serviceName.Value, }) - c.CmdClause.Flag("dictionary-id", "Dictionary ID").Required().StringVar(&c.Input.DictionaryID) - c.CmdClause.Flag("key", "Dictionary item key").Required().StringVar(&c.Input.ItemKey) - c.CmdClause.Flag("value", "Dictionary item value").Required().StringVar(&c.Input.ItemValue) return &c } diff --git a/pkg/commands/dictionaryitem/delete.go b/pkg/commands/dictionaryitem/delete.go index ffe1f300e..987fc4402 100644 --- a/pkg/commands/dictionaryitem/delete.go +++ b/pkg/commands/dictionaryitem/delete.go @@ -20,10 +20,19 @@ type DeleteCommand struct { // NewDeleteCommand returns a usable command registered under the parent. func NewDeleteCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *DeleteCommand { - var c DeleteCommand - c.Globals = globals - c.manifest = data + c := DeleteCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("delete", "Delete an item from a Fastly edge dictionary") + + // required + c.CmdClause.Flag("dictionary-id", "Dictionary ID").Required().StringVar(&c.Input.DictionaryID) + c.CmdClause.Flag("key", "Dictionary item key").Required().StringVar(&c.Input.ItemKey) + + // optional c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagServiceIDName, Description: cmd.FlagServiceIDDesc, @@ -36,8 +45,6 @@ func NewDeleteCommand(parent cmd.Registerer, globals *config.Data, data manifest Description: cmd.FlagServiceDesc, Dst: &c.serviceName.Value, }) - c.CmdClause.Flag("dictionary-id", "Dictionary ID").Required().StringVar(&c.Input.DictionaryID) - c.CmdClause.Flag("key", "Dictionary item key").Required().StringVar(&c.Input.ItemKey) return &c } diff --git a/pkg/commands/dictionaryitem/describe.go b/pkg/commands/dictionaryitem/describe.go index 680a25507..af9933cfc 100644 --- a/pkg/commands/dictionaryitem/describe.go +++ b/pkg/commands/dictionaryitem/describe.go @@ -24,10 +24,19 @@ type DescribeCommand struct { // NewDescribeCommand returns a usable command registered under the parent. func NewDescribeCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *DescribeCommand { - var c DescribeCommand - c.Globals = globals - c.manifest = data + c := DescribeCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("describe", "Show detailed information about a Fastly edge dictionary item").Alias("get") + + // required + c.CmdClause.Flag("dictionary-id", "Dictionary ID").Required().StringVar(&c.Input.DictionaryID) + c.CmdClause.Flag("key", "Dictionary item key").Required().StringVar(&c.Input.ItemKey) + + // optional c.RegisterFlagBool(cmd.BoolFlagOpts{ Name: cmd.FlagJSONName, Description: cmd.FlagJSONDesc, @@ -46,8 +55,7 @@ func NewDescribeCommand(parent cmd.Registerer, globals *config.Data, data manife Description: cmd.FlagServiceDesc, Dst: &c.serviceName.Value, }) - c.CmdClause.Flag("dictionary-id", "Dictionary ID").Required().StringVar(&c.Input.DictionaryID) - c.CmdClause.Flag("key", "Dictionary item key").Required().StringVar(&c.Input.ItemKey) + return &c } diff --git a/pkg/commands/dictionaryitem/list.go b/pkg/commands/dictionaryitem/list.go index de0297fec..c2bf0c752 100644 --- a/pkg/commands/dictionaryitem/list.go +++ b/pkg/commands/dictionaryitem/list.go @@ -24,11 +24,18 @@ type ListCommand struct { // NewListCommand returns a usable command registered under the parent. func NewListCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *ListCommand { - var c ListCommand - c.Globals = globals - c.manifest = data + c := ListCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("list", "List items in a Fastly edge dictionary") + + // required c.CmdClause.Flag("dictionary-id", "Dictionary ID").Required().StringVar(&c.input.DictionaryID) + + // optional c.CmdClause.Flag("direction", "Direction in which to sort results").Default(cmd.PaginationDirection[0]).HintOptions(cmd.PaginationDirection...).EnumVar(&c.input.Direction, cmd.PaginationDirection...) c.RegisterFlagBool(cmd.BoolFlagOpts{ Name: cmd.FlagJSONName, diff --git a/pkg/commands/dictionaryitem/update.go b/pkg/commands/dictionaryitem/update.go index af209c3b4..335b5e516 100644 --- a/pkg/commands/dictionaryitem/update.go +++ b/pkg/commands/dictionaryitem/update.go @@ -26,11 +26,18 @@ type UpdateCommand struct { // NewUpdateCommand returns a usable command registered under the parent. func NewUpdateCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *UpdateCommand { - var c UpdateCommand - c.Globals = globals - c.manifest = data + c := UpdateCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("update", "Update or insert an item on a Fastly edge dictionary") + + // required c.CmdClause.Flag("dictionary-id", "Dictionary ID").Required().StringVar(&c.Input.DictionaryID) + + // optional c.CmdClause.Flag("file", "Batch update json file").Action(c.file.Set).StringVar(&c.file.Value) c.CmdClause.Flag("key", "Dictionary item key").StringVar(&c.Input.ItemKey) c.RegisterFlag(cmd.StringFlagOpts{ diff --git a/pkg/commands/domain/create.go b/pkg/commands/domain/create.go index d08916fda..734ebac61 100644 --- a/pkg/commands/domain/create.go +++ b/pkg/commands/domain/create.go @@ -28,10 +28,29 @@ type CreateCommand struct { // NewCreateCommand returns a usable command registered under the parent. func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *CreateCommand { - var c CreateCommand - c.Globals = globals - c.manifest = data + c := CreateCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("create", "Create a domain on a Fastly service version").Alias("add") + + // required + c.RegisterFlag(cmd.StringFlagOpts{ + Name: cmd.FlagVersionName, + Description: cmd.FlagVersionDesc, + Dst: &c.serviceVersion.Value, + Required: true, + }) + + // optional + c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ + Action: c.autoClone.Set, + Dst: &c.autoClone.Value, + }) + c.CmdClause.Flag("comment", "A descriptive note").Action(c.comment.Set).StringVar(&c.comment.Value) + c.CmdClause.Flag("name", "Domain name").Short('n').Action(c.name.Set).StringVar(&c.name.Value) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagServiceIDName, Description: cmd.FlagServiceIDDesc, @@ -44,18 +63,6 @@ func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest Description: cmd.FlagServiceDesc, Dst: &c.serviceName.Value, }) - c.RegisterFlag(cmd.StringFlagOpts{ - Name: cmd.FlagVersionName, - Description: cmd.FlagVersionDesc, - Dst: &c.serviceVersion.Value, - Required: true, - }) - c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ - Action: c.autoClone.Set, - Dst: &c.autoClone.Value, - }) - c.CmdClause.Flag("name", "Domain name").Short('n').Action(c.name.Set).StringVar(&c.name.Value) - c.CmdClause.Flag("comment", "A descriptive note").Action(c.comment.Set).StringVar(&c.comment.Value) return &c } diff --git a/pkg/commands/domain/delete.go b/pkg/commands/domain/delete.go index 9bff96159..9890694cf 100644 --- a/pkg/commands/domain/delete.go +++ b/pkg/commands/domain/delete.go @@ -23,11 +23,28 @@ type DeleteCommand struct { // NewDeleteCommand returns a usable command registered under the parent. func NewDeleteCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *DeleteCommand { - var c DeleteCommand - c.Globals = globals - c.manifest = data + c := DeleteCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("delete", "Delete a domain on a Fastly service version").Alias("remove") + + // required c.CmdClause.Flag("name", "Domain name").Short('n').Required().StringVar(&c.Input.Name) + c.RegisterFlag(cmd.StringFlagOpts{ + Name: cmd.FlagVersionName, + Description: cmd.FlagVersionDesc, + Dst: &c.serviceVersion.Value, + Required: true, + }) + + // optional + c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ + Action: c.autoClone.Set, + Dst: &c.autoClone.Value, + }) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagServiceIDName, Description: cmd.FlagServiceIDDesc, @@ -40,16 +57,6 @@ func NewDeleteCommand(parent cmd.Registerer, globals *config.Data, data manifest Description: cmd.FlagServiceDesc, Dst: &c.serviceName.Value, }) - c.RegisterFlag(cmd.StringFlagOpts{ - Name: cmd.FlagVersionName, - Description: cmd.FlagVersionDesc, - Dst: &c.serviceVersion.Value, - Required: true, - }) - c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ - Action: c.autoClone.Set, - Dst: &c.autoClone.Value, - }) return &c } diff --git a/pkg/commands/domain/describe.go b/pkg/commands/domain/describe.go index f2c5fd00b..320c11c4f 100644 --- a/pkg/commands/domain/describe.go +++ b/pkg/commands/domain/describe.go @@ -24,10 +24,24 @@ type DescribeCommand struct { // NewDescribeCommand returns a usable command registered under the parent. func NewDescribeCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *DescribeCommand { - var c DescribeCommand - c.Globals = globals - c.manifest = data + c := DescribeCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("describe", "Show detailed information about a domain on a Fastly service version").Alias("get") + + // required + c.CmdClause.Flag("name", "Name of domain").Short('n').Required().StringVar(&c.Input.Name) + c.RegisterFlag(cmd.StringFlagOpts{ + Name: cmd.FlagVersionName, + Description: cmd.FlagVersionDesc, + Dst: &c.serviceVersion.Value, + Required: true, + }) + + // optional c.RegisterFlagBool(cmd.BoolFlagOpts{ Name: cmd.FlagJSONName, Description: cmd.FlagJSONDesc, @@ -46,13 +60,6 @@ func NewDescribeCommand(parent cmd.Registerer, globals *config.Data, data manife Description: cmd.FlagServiceDesc, Dst: &c.serviceName.Value, }) - c.RegisterFlag(cmd.StringFlagOpts{ - Name: cmd.FlagVersionName, - Description: cmd.FlagVersionDesc, - Dst: &c.serviceVersion.Value, - Required: true, - }) - c.CmdClause.Flag("name", "Name of domain").Short('n').Required().StringVar(&c.Input.Name) return &c } diff --git a/pkg/commands/domain/list.go b/pkg/commands/domain/list.go index c45bdacb2..e2d4b9a24 100644 --- a/pkg/commands/domain/list.go +++ b/pkg/commands/domain/list.go @@ -25,10 +25,23 @@ type ListCommand struct { // NewListCommand returns a usable command registered under the parent. func NewListCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *ListCommand { - var c ListCommand - c.Globals = globals - c.manifest = data + c := ListCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("list", "List domains on a Fastly service version") + + // required + c.RegisterFlag(cmd.StringFlagOpts{ + Name: cmd.FlagVersionName, + Description: cmd.FlagVersionDesc, + Dst: &c.serviceVersion.Value, + Required: true, + }) + + // optional c.RegisterFlagBool(cmd.BoolFlagOpts{ Name: cmd.FlagJSONName, Description: cmd.FlagJSONDesc, @@ -47,12 +60,6 @@ func NewListCommand(parent cmd.Registerer, globals *config.Data, data manifest.D Description: cmd.FlagServiceDesc, Dst: &c.serviceName.Value, }) - c.RegisterFlag(cmd.StringFlagOpts{ - Name: cmd.FlagVersionName, - Description: cmd.FlagVersionDesc, - Dst: &c.serviceVersion.Value, - Required: true, - }) return &c } diff --git a/pkg/commands/domain/update.go b/pkg/commands/domain/update.go index c1e9b9ee1..ebc6797a2 100644 --- a/pkg/commands/domain/update.go +++ b/pkg/commands/domain/update.go @@ -27,10 +27,30 @@ type UpdateCommand struct { // NewUpdateCommand returns a usable command registered under the parent. func NewUpdateCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *UpdateCommand { - var c UpdateCommand - c.Globals = globals - c.manifest = data + c := UpdateCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("update", "Update a domain on a Fastly service version") + + // required + c.CmdClause.Flag("name", "Domain name").Short('n').Required().StringVar(&c.input.Name) + c.RegisterFlag(cmd.StringFlagOpts{ + Name: cmd.FlagVersionName, + Description: cmd.FlagVersionDesc, + Dst: &c.serviceVersion.Value, + Required: true, + }) + + // optional + c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ + Action: c.autoClone.Set, + Dst: &c.autoClone.Value, + }) + c.CmdClause.Flag("comment", "A descriptive note").Action(c.Comment.Set).StringVar(&c.Comment.Value) + c.CmdClause.Flag("new-name", "New domain name").Action(c.NewName.Set).StringVar(&c.NewName.Value) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagServiceIDName, Description: cmd.FlagServiceIDDesc, @@ -43,19 +63,6 @@ func NewUpdateCommand(parent cmd.Registerer, globals *config.Data, data manifest Description: cmd.FlagServiceDesc, Dst: &c.serviceName.Value, }) - c.RegisterFlag(cmd.StringFlagOpts{ - Name: cmd.FlagVersionName, - Description: cmd.FlagVersionDesc, - Dst: &c.serviceVersion.Value, - Required: true, - }) - c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ - Action: c.autoClone.Set, - Dst: &c.autoClone.Value, - }) - c.CmdClause.Flag("name", "Domain name").Short('n').Required().StringVar(&c.input.Name) - c.CmdClause.Flag("new-name", "New domain name").Action(c.NewName.Set).StringVar(&c.NewName.Value) - c.CmdClause.Flag("comment", "A descriptive note").Action(c.Comment.Set).StringVar(&c.Comment.Value) return &c } diff --git a/pkg/commands/domain/validate.go b/pkg/commands/domain/validate.go index 227638616..6810ee95c 100644 --- a/pkg/commands/domain/validate.go +++ b/pkg/commands/domain/validate.go @@ -18,7 +18,7 @@ func NewValidateCommand(parent cmd.Registerer, globals *config.Data, data manife c.Globals = globals c.manifest = data - // Required flags + // required c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagVersionName, Description: cmd.FlagVersionDesc, @@ -26,7 +26,7 @@ func NewValidateCommand(parent cmd.Registerer, globals *config.Data, data manife Required: true, }) - // Optional flags + // optional c.CmdClause.Flag("all", "Checks the status of all domains' DNS records for a Service Version").Short('a').BoolVar(&c.all) c.CmdClause.Flag("name", "The name of the domain associated with this service").Short('n').Action(c.name.Set).StringVar(&c.name.Value) c.RegisterFlag(cmd.StringFlagOpts{ diff --git a/pkg/commands/healthcheck/create.go b/pkg/commands/healthcheck/create.go index 8f3c75888..98398ef99 100644 --- a/pkg/commands/healthcheck/create.go +++ b/pkg/commands/healthcheck/create.go @@ -38,44 +38,51 @@ type CreateCommand struct { // NewCreateCommand returns a usable command registered under the parent. func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *CreateCommand { - var c CreateCommand - c.Globals = globals - c.manifest = data + c := CreateCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("create", "Create a healthcheck on a Fastly service version").Alias("add") - c.RegisterFlag(cmd.StringFlagOpts{ - Name: cmd.FlagServiceIDName, - Description: cmd.FlagServiceIDDesc, - Dst: &c.manifest.Flag.ServiceID, - Short: 's', - }) - c.RegisterFlag(cmd.StringFlagOpts{ - Action: c.serviceName.Set, - Name: cmd.FlagServiceName, - Description: cmd.FlagServiceDesc, - Dst: &c.serviceName.Value, - }) + + // required c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagVersionName, Description: cmd.FlagVersionDesc, Dst: &c.serviceVersion.Value, Required: true, }) + + // optional c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ Action: c.autoClone.Set, Dst: &c.autoClone.Value, }) - c.CmdClause.Flag("name", "Healthcheck name").Short('n').Action(c.name.Set).StringVar(&c.name.Value) + c.CmdClause.Flag("check-interval", "How often to run the healthcheck in milliseconds").Action(c.checkInterval.Set).IntVar(&c.checkInterval.Value) c.CmdClause.Flag("comment", "A descriptive note").Action(c.comment.Set).StringVar(&c.comment.Value) - c.CmdClause.Flag("method", "Which HTTP method to use").Action(c.method.Set).StringVar(&c.method.Value) + c.CmdClause.Flag("expected-response", "The status code expected from the host").Action(c.expectedResponse.Set).IntVar(&c.expectedResponse.Value) c.CmdClause.Flag("host", "Which host to check").Action(c.host.Set).StringVar(&c.host.Value) - c.CmdClause.Flag("path", "The path to check").Action(c.path.Set).StringVar(&c.path.Value) c.CmdClause.Flag("http-version", "Whether to use version 1.0 or 1.1 HTTP").Action(c.httpVersion.Set).StringVar(&c.httpVersion.Value) + c.CmdClause.Flag("initial", "When loading a config, the initial number of probes to be seen as OK").Action(c.initial.Set).IntVar(&c.initial.Value) + c.CmdClause.Flag("method", "Which HTTP method to use").Action(c.method.Set).StringVar(&c.method.Value) + c.CmdClause.Flag("name", "Healthcheck name").Short('n').Action(c.name.Set).StringVar(&c.name.Value) + c.CmdClause.Flag("path", "The path to check").Action(c.path.Set).StringVar(&c.path.Value) + c.RegisterFlag(cmd.StringFlagOpts{ + Name: cmd.FlagServiceIDName, + Description: cmd.FlagServiceIDDesc, + Dst: &c.manifest.Flag.ServiceID, + Short: 's', + }) + c.RegisterFlag(cmd.StringFlagOpts{ + Action: c.serviceName.Set, + Name: cmd.FlagServiceName, + Description: cmd.FlagServiceDesc, + Dst: &c.serviceName.Value, + }) + c.CmdClause.Flag("threshold", "How many healthchecks must succeed to be considered healthy").Action(c.threshold.Set).IntVar(&c.threshold.Value) c.CmdClause.Flag("timeout", "Timeout in milliseconds").Action(c.timeout.Set).IntVar(&c.timeout.Value) - c.CmdClause.Flag("check-interval", "How often to run the healthcheck in milliseconds").Action(c.checkInterval.Set).IntVar(&c.checkInterval.Value) - c.CmdClause.Flag("expected-response", "The status code expected from the host").Action(c.expectedResponse.Set).IntVar(&c.expectedResponse.Value) c.CmdClause.Flag("window", "The number of most recent healthcheck queries to keep for this healthcheck").Action(c.window.Set).IntVar(&c.window.Value) - c.CmdClause.Flag("threshold", "How many healthchecks must succeed to be considered healthy").Action(c.threshold.Set).IntVar(&c.threshold.Value) - c.CmdClause.Flag("initial", "When loading a config, the initial number of probes to be seen as OK").Action(c.initial.Set).IntVar(&c.initial.Value) return &c } diff --git a/pkg/commands/healthcheck/delete.go b/pkg/commands/healthcheck/delete.go index 03c66a45f..54d6f7fcd 100644 --- a/pkg/commands/healthcheck/delete.go +++ b/pkg/commands/healthcheck/delete.go @@ -23,10 +23,28 @@ type DeleteCommand struct { // NewDeleteCommand returns a usable command registered under the parent. func NewDeleteCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *DeleteCommand { - var c DeleteCommand - c.Globals = globals - c.manifest = data + c := DeleteCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("delete", "Delete a healthcheck on a Fastly service version").Alias("remove") + + // required + c.CmdClause.Flag("name", "Healthcheck name").Short('n').Required().StringVar(&c.Input.Name) + c.RegisterFlag(cmd.StringFlagOpts{ + Name: cmd.FlagVersionName, + Description: cmd.FlagVersionDesc, + Dst: &c.serviceVersion.Value, + Required: true, + }) + + // optional + c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ + Action: c.autoClone.Set, + Dst: &c.autoClone.Value, + }) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagServiceIDName, Description: cmd.FlagServiceIDDesc, @@ -39,17 +57,6 @@ func NewDeleteCommand(parent cmd.Registerer, globals *config.Data, data manifest Description: cmd.FlagServiceDesc, Dst: &c.serviceName.Value, }) - c.RegisterFlag(cmd.StringFlagOpts{ - Name: cmd.FlagVersionName, - Description: cmd.FlagVersionDesc, - Dst: &c.serviceVersion.Value, - Required: true, - }) - c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ - Action: c.autoClone.Set, - Dst: &c.autoClone.Value, - }) - c.CmdClause.Flag("name", "Healthcheck name").Short('n').Required().StringVar(&c.Input.Name) return &c } diff --git a/pkg/commands/healthcheck/describe.go b/pkg/commands/healthcheck/describe.go index b264f0adc..d049c5be2 100644 --- a/pkg/commands/healthcheck/describe.go +++ b/pkg/commands/healthcheck/describe.go @@ -25,10 +25,24 @@ type DescribeCommand struct { // NewDescribeCommand returns a usable command registered under the parent. func NewDescribeCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *DescribeCommand { - var c DescribeCommand - c.Globals = globals - c.manifest = data + c := DescribeCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("describe", "Show detailed information about a healthcheck on a Fastly service version").Alias("get") + + // required + c.CmdClause.Flag("name", "Name of healthcheck").Short('n').Required().StringVar(&c.Input.Name) + c.RegisterFlag(cmd.StringFlagOpts{ + Name: cmd.FlagVersionName, + Description: cmd.FlagVersionDesc, + Dst: &c.serviceVersion.Value, + Required: true, + }) + + // optional c.RegisterFlagBool(cmd.BoolFlagOpts{ Name: cmd.FlagJSONName, Description: cmd.FlagJSONDesc, @@ -47,13 +61,6 @@ func NewDescribeCommand(parent cmd.Registerer, globals *config.Data, data manife Description: cmd.FlagServiceDesc, Dst: &c.serviceName.Value, }) - c.RegisterFlag(cmd.StringFlagOpts{ - Name: cmd.FlagVersionName, - Description: cmd.FlagVersionDesc, - Dst: &c.serviceVersion.Value, - Required: true, - }) - c.CmdClause.Flag("name", "Name of healthcheck").Short('n').Required().StringVar(&c.Input.Name) return &c } diff --git a/pkg/commands/healthcheck/list.go b/pkg/commands/healthcheck/list.go index 7419c79e0..1f0f06f51 100644 --- a/pkg/commands/healthcheck/list.go +++ b/pkg/commands/healthcheck/list.go @@ -25,10 +25,23 @@ type ListCommand struct { // NewListCommand returns a usable command registered under the parent. func NewListCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *ListCommand { - var c ListCommand - c.Globals = globals - c.manifest = data + c := ListCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("list", "List healthchecks on a Fastly service version") + + // required + c.RegisterFlag(cmd.StringFlagOpts{ + Name: cmd.FlagVersionName, + Description: cmd.FlagVersionDesc, + Dst: &c.serviceVersion.Value, + Required: true, + }) + + // optional c.RegisterFlagBool(cmd.BoolFlagOpts{ Name: cmd.FlagJSONName, Description: cmd.FlagJSONDesc, @@ -47,12 +60,6 @@ func NewListCommand(parent cmd.Registerer, globals *config.Data, data manifest.D Description: cmd.FlagServiceDesc, Dst: &c.serviceName.Value, }) - c.RegisterFlag(cmd.StringFlagOpts{ - Name: cmd.FlagVersionName, - Description: cmd.FlagVersionDesc, - Dst: &c.serviceVersion.Value, - Required: true, - }) return &c } diff --git a/pkg/commands/healthcheck/update.go b/pkg/commands/healthcheck/update.go index 67273462d..aa25b74b4 100644 --- a/pkg/commands/healthcheck/update.go +++ b/pkg/commands/healthcheck/update.go @@ -36,45 +36,52 @@ type UpdateCommand struct { // NewUpdateCommand returns a usable command registered under the parent. func NewUpdateCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *UpdateCommand { - var c UpdateCommand - c.Globals = globals - c.manifest = data + c := UpdateCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("update", "Update a healthcheck on a Fastly service version") - c.RegisterFlag(cmd.StringFlagOpts{ - Name: cmd.FlagServiceIDName, - Description: cmd.FlagServiceIDDesc, - Dst: &c.manifest.Flag.ServiceID, - Short: 's', - }) - c.RegisterFlag(cmd.StringFlagOpts{ - Action: c.serviceName.Set, - Name: cmd.FlagServiceName, - Description: cmd.FlagServiceDesc, - Dst: &c.serviceName.Value, - }) + + // required + c.CmdClause.Flag("name", "Healthcheck name").Short('n').Required().StringVar(&c.input.Name) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagVersionName, Description: cmd.FlagVersionDesc, Dst: &c.serviceVersion.Value, Required: true, }) + + // optional c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ Action: c.autoClone.Set, Dst: &c.autoClone.Value, }) - c.CmdClause.Flag("name", "Healthcheck name").Short('n').Required().StringVar(&c.input.Name) - c.CmdClause.Flag("new-name", "Healthcheck name").Action(c.NewName.Set).StringVar(&c.NewName.Value) + c.CmdClause.Flag("check-interval", "How often to run the healthcheck in milliseconds").Action(c.CheckInterval.Set).IntVar(&c.CheckInterval.Value) c.CmdClause.Flag("comment", "A descriptive note").Action(c.Comment.Set).StringVar(&c.Comment.Value) - c.CmdClause.Flag("method", "Which HTTP method to use").Action(c.Method.Set).StringVar(&c.Method.Value) + c.CmdClause.Flag("expected-response", "The status code expected from the host").Action(c.ExpectedResponse.Set).IntVar(&c.ExpectedResponse.Value) c.CmdClause.Flag("host", "Which host to check").Action(c.Host.Set).StringVar(&c.Host.Value) - c.CmdClause.Flag("path", "The path to check").Action(c.Path.Set).StringVar(&c.Path.Value) c.CmdClause.Flag("http-version", "Whether to use version 1.0 or 1.1 HTTP").Action(c.HTTPVersion.Set).StringVar(&c.HTTPVersion.Value) + c.CmdClause.Flag("initial", "When loading a config, the initial number of probes to be seen as OK").Action(c.Initial.Set).IntVar(&c.Initial.Value) + c.CmdClause.Flag("method", "Which HTTP method to use").Action(c.Method.Set).StringVar(&c.Method.Value) + c.CmdClause.Flag("new-name", "Healthcheck name").Action(c.NewName.Set).StringVar(&c.NewName.Value) + c.CmdClause.Flag("path", "The path to check").Action(c.Path.Set).StringVar(&c.Path.Value) + c.RegisterFlag(cmd.StringFlagOpts{ + Name: cmd.FlagServiceIDName, + Description: cmd.FlagServiceIDDesc, + Dst: &c.manifest.Flag.ServiceID, + Short: 's', + }) + c.RegisterFlag(cmd.StringFlagOpts{ + Action: c.serviceName.Set, + Name: cmd.FlagServiceName, + Description: cmd.FlagServiceDesc, + Dst: &c.serviceName.Value, + }) + c.CmdClause.Flag("threshold", "How many healthchecks must succeed to be considered healthy").Action(c.Threshold.Set).IntVar(&c.Threshold.Value) c.CmdClause.Flag("timeout", "Timeout in milliseconds").Action(c.Timeout.Set).IntVar(&c.Timeout.Value) - c.CmdClause.Flag("check-interval", "How often to run the healthcheck in milliseconds").Action(c.CheckInterval.Set).IntVar(&c.CheckInterval.Value) - c.CmdClause.Flag("expected-response", "The status code expected from the host").Action(c.ExpectedResponse.Set).IntVar(&c.ExpectedResponse.Value) c.CmdClause.Flag("window", "The number of most recent healthcheck queries to keep for this healthcheck").Action(c.Window.Set).IntVar(&c.Window.Value) - c.CmdClause.Flag("threshold", "How many healthchecks must succeed to be considered healthy").Action(c.Threshold.Set).IntVar(&c.Threshold.Value) - c.CmdClause.Flag("initial", "When loading a config, the initial number of probes to be seen as OK").Action(c.Initial.Set).IntVar(&c.Initial.Value) return &c } diff --git a/pkg/commands/logging/azureblob/create.go b/pkg/commands/logging/azureblob/create.go index d14d3ceb5..ace6b554a 100644 --- a/pkg/commands/logging/azureblob/create.go +++ b/pkg/commands/logging/azureblob/create.go @@ -44,23 +44,41 @@ type CreateCommand struct { // NewCreateCommand returns a usable command registered under the parent. func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *CreateCommand { - var c CreateCommand - c.Globals = globals - c.Manifest = data + c := CreateCommand{ + Base: cmd.Base{ + Globals: globals, + }, + Manifest: data, + } c.CmdClause = parent.Command("create", "Create an Azure Blob Storage logging endpoint on a Fastly service version").Alias("add") + + // required c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagVersionName, Description: cmd.FlagVersionDesc, Dst: &c.ServiceVersion.Value, Required: true, }) + + // optional + c.CmdClause.Flag("account-name", "The unique Azure Blob Storage namespace in which your data objects are stored").Action(c.AccountName.Set).StringVar(&c.AccountName.Value) c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ Action: c.AutoClone.Set, Dst: &c.AutoClone.Value, }) - c.CmdClause.Flag("name", "The name of the Azure Blob Storage logging object. Used as a primary key for API access").Short('n').Action(c.EndpointName.Set).StringVar(&c.EndpointName.Value) + common.CompressionCodec(c.CmdClause, &c.CompressionCodec) c.CmdClause.Flag("container", "The name of the Azure Blob Storage container in which to store logs").Action(c.Container.Set).StringVar(&c.Container.Value) - c.CmdClause.Flag("account-name", "The unique Azure Blob Storage namespace in which your data objects are stored").Action(c.AccountName.Set).StringVar(&c.AccountName.Value) + c.CmdClause.Flag("file-max-bytes", "The maximum size of a log file in bytes").Action(c.FileMaxBytes.Set).IntVar(&c.FileMaxBytes.Value) + common.Format(c.CmdClause, &c.Format) + common.FormatVersion(c.CmdClause, &c.FormatVersion) + common.GzipLevel(c.CmdClause, &c.GzipLevel) + common.MessageType(c.CmdClause, &c.MessageType) + c.CmdClause.Flag("name", "The name of the Azure Blob Storage logging object. Used as a primary key for API access").Short('n').Action(c.EndpointName.Set).StringVar(&c.EndpointName.Value) + common.Path(c.CmdClause, &c.Path) + common.Period(c.CmdClause, &c.Period) + common.Placement(c.CmdClause, &c.Placement) + common.PublicKey(c.CmdClause, &c.PublicKey) + common.ResponseCondition(c.CmdClause, &c.ResponseCondition) c.CmdClause.Flag("sas-token", "The Azure shared access signature providing write access to the blob service objects. Be sure to update your token before it expires or the logging functionality will not work").Action(c.SASToken.Set).StringVar(&c.SASToken.Value) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagServiceIDName, @@ -74,18 +92,7 @@ func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest Description: cmd.FlagServiceDesc, Dst: &c.ServiceName.Value, }) - common.Path(c.CmdClause, &c.Path) - common.Period(c.CmdClause, &c.Period) - common.GzipLevel(c.CmdClause, &c.GzipLevel) - common.Format(c.CmdClause, &c.Format) - common.MessageType(c.CmdClause, &c.MessageType) - common.FormatVersion(c.CmdClause, &c.FormatVersion) - common.ResponseCondition(c.CmdClause, &c.ResponseCondition) common.TimestampFormat(c.CmdClause, &c.TimestampFormat) - common.Placement(c.CmdClause, &c.Placement) - common.PublicKey(c.CmdClause, &c.PublicKey) - c.CmdClause.Flag("file-max-bytes", "The maximum size of a log file in bytes").Action(c.FileMaxBytes.Set).IntVar(&c.FileMaxBytes.Value) - common.CompressionCodec(c.CmdClause, &c.CompressionCodec) return &c } diff --git a/pkg/commands/logging/azureblob/delete.go b/pkg/commands/logging/azureblob/delete.go index cdf19173c..0b2938b45 100644 --- a/pkg/commands/logging/azureblob/delete.go +++ b/pkg/commands/logging/azureblob/delete.go @@ -23,16 +23,23 @@ type DeleteCommand struct { // NewDeleteCommand returns a usable command registered under the parent. func NewDeleteCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *DeleteCommand { - var c DeleteCommand - c.Globals = globals - c.manifest = data + c := DeleteCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("delete", "Delete an Azure Blob Storage logging endpoint on a Fastly service version").Alias("remove") + + // required c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagVersionName, Description: cmd.FlagVersionDesc, Dst: &c.serviceVersion.Value, Required: true, }) + + // optional c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ Action: c.autoClone.Set, Dst: &c.autoClone.Value, diff --git a/pkg/commands/logging/azureblob/describe.go b/pkg/commands/logging/azureblob/describe.go index ccb59855d..eab80fab5 100644 --- a/pkg/commands/logging/azureblob/describe.go +++ b/pkg/commands/logging/azureblob/describe.go @@ -25,10 +25,24 @@ type DescribeCommand struct { // NewDescribeCommand returns a usable command registered under the parent. func NewDescribeCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *DescribeCommand { - var c DescribeCommand - c.Globals = globals - c.manifest = data + c := DescribeCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("describe", "Show detailed information about an Azure Blob Storage logging endpoint on a Fastly service version").Alias("get") + + // required + c.CmdClause.Flag("name", "The name of the Azure Blob Storage logging object").Short('n').Required().StringVar(&c.Input.Name) + c.RegisterFlag(cmd.StringFlagOpts{ + Name: cmd.FlagVersionName, + Description: cmd.FlagVersionDesc, + Dst: &c.serviceVersion.Value, + Required: true, + }) + + // optional c.RegisterFlagBool(cmd.BoolFlagOpts{ Name: cmd.FlagJSONName, Description: cmd.FlagJSONDesc, @@ -47,13 +61,6 @@ func NewDescribeCommand(parent cmd.Registerer, globals *config.Data, data manife Description: cmd.FlagServiceDesc, Dst: &c.serviceName.Value, }) - c.RegisterFlag(cmd.StringFlagOpts{ - Name: cmd.FlagVersionName, - Description: cmd.FlagVersionDesc, - Dst: &c.serviceVersion.Value, - Required: true, - }) - c.CmdClause.Flag("name", "The name of the Azure Blob Storage logging object").Short('n').Required().StringVar(&c.Input.Name) return &c } diff --git a/pkg/commands/logging/azureblob/list.go b/pkg/commands/logging/azureblob/list.go index 385fef366..b2fcc7f10 100644 --- a/pkg/commands/logging/azureblob/list.go +++ b/pkg/commands/logging/azureblob/list.go @@ -25,10 +25,23 @@ type ListCommand struct { // NewListCommand returns a usable command registered under the parent. func NewListCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *ListCommand { - var c ListCommand - c.Globals = globals - c.manifest = data + c := ListCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("list", "List Azure Blob Storage logging endpoints on a Fastly service version") + + // required + c.RegisterFlag(cmd.StringFlagOpts{ + Name: cmd.FlagVersionName, + Description: cmd.FlagVersionDesc, + Dst: &c.serviceVersion.Value, + Required: true, + }) + + // optional c.RegisterFlagBool(cmd.BoolFlagOpts{ Name: cmd.FlagJSONName, Description: cmd.FlagJSONDesc, @@ -47,12 +60,6 @@ func NewListCommand(parent cmd.Registerer, globals *config.Data, data manifest.D Description: cmd.FlagServiceDesc, Dst: &c.serviceName.Value, }) - c.RegisterFlag(cmd.StringFlagOpts{ - Name: cmd.FlagVersionName, - Description: cmd.FlagVersionDesc, - Dst: &c.serviceVersion.Value, - Required: true, - }) return &c } diff --git a/pkg/commands/logging/azureblob/update.go b/pkg/commands/logging/azureblob/update.go index 193c01f89..eb8a03b0a 100644 --- a/pkg/commands/logging/azureblob/update.go +++ b/pkg/commands/logging/azureblob/update.go @@ -44,21 +44,45 @@ type UpdateCommand struct { // NewUpdateCommand returns a usable command registered under the parent. func NewUpdateCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *UpdateCommand { - var c UpdateCommand - c.Globals = globals - c.Manifest = data + c := UpdateCommand{ + Base: cmd.Base{ + Globals: globals, + }, + Manifest: data, + } c.CmdClause = parent.Command("update", "Update an Azure Blob Storage logging endpoint on a Fastly service version") + + // required c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagVersionName, Description: cmd.FlagVersionDesc, Dst: &c.ServiceVersion.Value, Required: true, }) + + // optional c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ Action: c.AutoClone.Set, Dst: &c.AutoClone.Value, }) c.CmdClause.Flag("name", "The name of the Azure Blob Storage logging object").Short('n').Required().StringVar(&c.EndpointName) + + // optional + c.CmdClause.Flag("account-name", "The unique Azure Blob Storage namespace in which your data objects are stored").Action(c.AccountName.Set).StringVar(&c.AccountName.Value) + common.CompressionCodec(c.CmdClause, &c.CompressionCodec) + c.CmdClause.Flag("container", "The name of the Azure Blob Storage container in which to store logs").Action(c.Container.Set).StringVar(&c.Container.Value) + c.CmdClause.Flag("file-max-bytes", "The maximum size of a log file in bytes").Action(c.FileMaxBytes.Set).IntVar(&c.FileMaxBytes.Value) + common.Format(c.CmdClause, &c.Format) + common.FormatVersion(c.CmdClause, &c.FormatVersion) + common.GzipLevel(c.CmdClause, &c.GzipLevel) + common.MessageType(c.CmdClause, &c.MessageType) + c.CmdClause.Flag("new-name", "New name of the Azure Blob Storage logging object").Action(c.NewName.Set).StringVar(&c.NewName.Value) + common.Path(c.CmdClause, &c.Path) + common.Period(c.CmdClause, &c.Period) + common.Placement(c.CmdClause, &c.Placement) + common.PublicKey(c.CmdClause, &c.PublicKey) + common.ResponseCondition(c.CmdClause, &c.ResponseCondition) + c.CmdClause.Flag("sas-token", "The Azure shared access signature providing write access to the blob service objects. Be sure to update your token before it expires or the logging functionality will not work").Action(c.SASToken.Set).StringVar(&c.SASToken.Value) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagServiceIDName, Description: cmd.FlagServiceIDDesc, @@ -71,22 +95,7 @@ func NewUpdateCommand(parent cmd.Registerer, globals *config.Data, data manifest Description: cmd.FlagServiceDesc, Dst: &c.ServiceName.Value, }) - c.CmdClause.Flag("new-name", "New name of the Azure Blob Storage logging object").Action(c.NewName.Set).StringVar(&c.NewName.Value) - c.CmdClause.Flag("container", "The name of the Azure Blob Storage container in which to store logs").Action(c.Container.Set).StringVar(&c.Container.Value) - c.CmdClause.Flag("account-name", "The unique Azure Blob Storage namespace in which your data objects are stored").Action(c.AccountName.Set).StringVar(&c.AccountName.Value) - c.CmdClause.Flag("sas-token", "The Azure shared access signature providing write access to the blob service objects. Be sure to update your token before it expires or the logging functionality will not work").Action(c.SASToken.Set).StringVar(&c.SASToken.Value) - common.Path(c.CmdClause, &c.Path) - common.Period(c.CmdClause, &c.Period) - common.GzipLevel(c.CmdClause, &c.GzipLevel) - common.Format(c.CmdClause, &c.Format) - common.MessageType(c.CmdClause, &c.MessageType) - common.FormatVersion(c.CmdClause, &c.FormatVersion) - common.ResponseCondition(c.CmdClause, &c.ResponseCondition) common.TimestampFormat(c.CmdClause, &c.TimestampFormat) - common.Placement(c.CmdClause, &c.Placement) - common.PublicKey(c.CmdClause, &c.PublicKey) - c.CmdClause.Flag("file-max-bytes", "The maximum size of a log file in bytes").Action(c.FileMaxBytes.Set).IntVar(&c.FileMaxBytes.Value) - common.CompressionCodec(c.CmdClause, &c.CompressionCodec) return &c } diff --git a/pkg/commands/logging/bigquery/create.go b/pkg/commands/logging/bigquery/create.go index e93bf4641..f42694fe2 100644 --- a/pkg/commands/logging/bigquery/create.go +++ b/pkg/commands/logging/bigquery/create.go @@ -38,25 +38,34 @@ type CreateCommand struct { // NewCreateCommand returns a usable command registered under the parent. func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *CreateCommand { - var c CreateCommand - c.Globals = globals - c.Manifest = data + c := CreateCommand{ + Base: cmd.Base{ + Globals: globals, + }, + Manifest: data, + } c.CmdClause = parent.Command("create", "Create a BigQuery logging endpoint on a Fastly service version").Alias("add") - c.CmdClause.Flag("name", "The name of the BigQuery logging object. Used as a primary key for API access").Short('n').Action(c.EndpointName.Set).StringVar(&c.EndpointName.Value) + + // required c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagVersionName, Description: cmd.FlagVersionDesc, Dst: &c.ServiceVersion.Value, Required: true, }) + + // optional c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ Action: c.AutoClone.Set, Dst: &c.AutoClone.Value, }) - c.CmdClause.Flag("project-id", "Your Google Cloud Platform project ID").Action(c.ProjectID.Set).StringVar(&c.ProjectID.Value) c.CmdClause.Flag("dataset", "Your BigQuery dataset").Action(c.Dataset.Set).StringVar(&c.Dataset.Value) - c.CmdClause.Flag("table", "Your BigQuery table").Action(c.Table.Set).StringVar(&c.Table.Value) - c.CmdClause.Flag("user", "Your Google Cloud Platform service account email address. The client_email field in your service account authentication JSON.").Action(c.User.Set).StringVar(&c.User.Value) + common.Format(c.CmdClause, &c.Format) + common.FormatVersion(c.CmdClause, &c.FormatVersion) + c.CmdClause.Flag("name", "The name of the BigQuery logging object. Used as a primary key for API access").Short('n').Action(c.EndpointName.Set).StringVar(&c.EndpointName.Value) + common.Placement(c.CmdClause, &c.Placement) + c.CmdClause.Flag("project-id", "Your Google Cloud Platform project ID").Action(c.ProjectID.Set).StringVar(&c.ProjectID.Value) + common.ResponseCondition(c.CmdClause, &c.ResponseCondition) c.CmdClause.Flag("secret-key", "Your Google Cloud Platform account secret key. The private_key field in your service account authentication JSON.").Action(c.SecretKey.Set).StringVar(&c.SecretKey.Value) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagServiceIDName, @@ -70,11 +79,9 @@ func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest Description: cmd.FlagServiceDesc, Dst: &c.ServiceName.Value, }) + c.CmdClause.Flag("table", "Your BigQuery table").Action(c.Table.Set).StringVar(&c.Table.Value) c.CmdClause.Flag("template-suffix", "BigQuery table name suffix template").Action(c.Template.Set).StringVar(&c.Template.Value) - common.Format(c.CmdClause, &c.Format) - common.FormatVersion(c.CmdClause, &c.FormatVersion) - common.Placement(c.CmdClause, &c.Placement) - common.ResponseCondition(c.CmdClause, &c.ResponseCondition) + c.CmdClause.Flag("user", "Your Google Cloud Platform service account email address. The client_email field in your service account authentication JSON.").Action(c.User.Set).StringVar(&c.User.Value) return &c } diff --git a/pkg/commands/logging/bigquery/delete.go b/pkg/commands/logging/bigquery/delete.go index 6312b259f..f80dff103 100644 --- a/pkg/commands/logging/bigquery/delete.go +++ b/pkg/commands/logging/bigquery/delete.go @@ -23,21 +23,28 @@ type DeleteCommand struct { // NewDeleteCommand returns a usable command registered under the parent. func NewDeleteCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *DeleteCommand { - var c DeleteCommand - c.Globals = globals - c.manifest = data + c := DeleteCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("delete", "Delete a BigQuery logging endpoint on a Fastly service version").Alias("remove") + + // required + c.CmdClause.Flag("name", "The name of the BigQuery logging object").Short('n').Required().StringVar(&c.Input.Name) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagVersionName, Description: cmd.FlagVersionDesc, Dst: &c.serviceVersion.Value, Required: true, }) + + // optional c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ Action: c.autoClone.Set, Dst: &c.autoClone.Value, }) - c.CmdClause.Flag("name", "The name of the BigQuery logging object").Short('n').Required().StringVar(&c.Input.Name) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagServiceIDName, Description: cmd.FlagServiceIDDesc, diff --git a/pkg/commands/logging/bigquery/describe.go b/pkg/commands/logging/bigquery/describe.go index c62ec65ec..1174f33d1 100644 --- a/pkg/commands/logging/bigquery/describe.go +++ b/pkg/commands/logging/bigquery/describe.go @@ -25,10 +25,24 @@ type DescribeCommand struct { // NewDescribeCommand returns a usable command registered under the parent. func NewDescribeCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *DescribeCommand { - var c DescribeCommand - c.Globals = globals - c.manifest = data + c := DescribeCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("describe", "Show detailed information about a BigQuery logging endpoint on a Fastly service version").Alias("get") + + // required + c.CmdClause.Flag("name", "The name of the BigQuery logging object").Short('n').Required().StringVar(&c.Input.Name) + c.RegisterFlag(cmd.StringFlagOpts{ + Name: cmd.FlagVersionName, + Description: cmd.FlagVersionDesc, + Dst: &c.serviceVersion.Value, + Required: true, + }) + + // optional c.RegisterFlagBool(cmd.BoolFlagOpts{ Name: cmd.FlagJSONName, Description: cmd.FlagJSONDesc, @@ -47,13 +61,6 @@ func NewDescribeCommand(parent cmd.Registerer, globals *config.Data, data manife Description: cmd.FlagServiceDesc, Dst: &c.serviceName.Value, }) - c.RegisterFlag(cmd.StringFlagOpts{ - Name: cmd.FlagVersionName, - Description: cmd.FlagVersionDesc, - Dst: &c.serviceVersion.Value, - Required: true, - }) - c.CmdClause.Flag("name", "The name of the BigQuery logging object").Short('n').Required().StringVar(&c.Input.Name) return &c } diff --git a/pkg/commands/logging/bigquery/list.go b/pkg/commands/logging/bigquery/list.go index ae7a56ab4..ace63242c 100644 --- a/pkg/commands/logging/bigquery/list.go +++ b/pkg/commands/logging/bigquery/list.go @@ -25,10 +25,23 @@ type ListCommand struct { // NewListCommand returns a usable command registered under the parent. func NewListCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *ListCommand { - var c ListCommand - c.Globals = globals - c.manifest = data + c := ListCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("list", "List BigQuery endpoints on a Fastly service version") + + // required + c.RegisterFlag(cmd.StringFlagOpts{ + Name: cmd.FlagVersionName, + Description: cmd.FlagVersionDesc, + Dst: &c.serviceVersion.Value, + Required: true, + }) + + // optional c.RegisterFlagBool(cmd.BoolFlagOpts{ Name: cmd.FlagJSONName, Description: cmd.FlagJSONDesc, @@ -47,12 +60,6 @@ func NewListCommand(parent cmd.Registerer, globals *config.Data, data manifest.D Description: cmd.FlagServiceDesc, Dst: &c.serviceName.Value, }) - c.RegisterFlag(cmd.StringFlagOpts{ - Name: cmd.FlagVersionName, - Description: cmd.FlagVersionDesc, - Dst: &c.serviceVersion.Value, - Required: true, - }) return &c } diff --git a/pkg/commands/logging/bigquery/update.go b/pkg/commands/logging/bigquery/update.go index 4304614ab..41fa46985 100644 --- a/pkg/commands/logging/bigquery/update.go +++ b/pkg/commands/logging/bigquery/update.go @@ -39,21 +39,36 @@ type UpdateCommand struct { // NewUpdateCommand returns a usable command registered under the parent. func NewUpdateCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *UpdateCommand { - var c UpdateCommand - c.Globals = globals - c.Manifest = data + c := UpdateCommand{ + Base: cmd.Base{ + Globals: globals, + }, + Manifest: data, + } c.CmdClause = parent.Command("update", "Update a BigQuery logging endpoint on a Fastly service version") + + // required + c.CmdClause.Flag("name", "The name of the BigQuery logging object").Short('n').Required().StringVar(&c.EndpointName) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagVersionName, Description: cmd.FlagVersionDesc, Dst: &c.ServiceVersion.Value, Required: true, }) + + // optional c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ Action: c.AutoClone.Set, Dst: &c.AutoClone.Value, }) - c.CmdClause.Flag("name", "The name of the BigQuery logging object").Short('n').Required().StringVar(&c.EndpointName) + c.CmdClause.Flag("dataset", "Your BigQuery dataset").Action(c.Dataset.Set).StringVar(&c.Dataset.Value) + common.Format(c.CmdClause, &c.Format) + common.FormatVersion(c.CmdClause, &c.FormatVersion) + c.CmdClause.Flag("new-name", "New name of the BigQuery logging object").Action(c.NewName.Set).StringVar(&c.NewName.Value) + common.Placement(c.CmdClause, &c.Placement) + c.CmdClause.Flag("project-id", "Your Google Cloud Platform project ID").Action(c.ProjectID.Set).StringVar(&c.ProjectID.Value) + common.ResponseCondition(c.CmdClause, &c.ResponseCondition) + c.CmdClause.Flag("secret-key", "Your Google Cloud Platform account secret key. The private_key field in your service account authentication JSON.").Action(c.SecretKey.Set).StringVar(&c.SecretKey.Value) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagServiceIDName, Description: cmd.FlagServiceIDDesc, @@ -66,17 +81,9 @@ func NewUpdateCommand(parent cmd.Registerer, globals *config.Data, data manifest Description: cmd.FlagServiceDesc, Dst: &c.ServiceName.Value, }) - c.CmdClause.Flag("new-name", "New name of the BigQuery logging object").Action(c.NewName.Set).StringVar(&c.NewName.Value) - c.CmdClause.Flag("project-id", "Your Google Cloud Platform project ID").Action(c.ProjectID.Set).StringVar(&c.ProjectID.Value) - c.CmdClause.Flag("dataset", "Your BigQuery dataset").Action(c.Dataset.Set).StringVar(&c.Dataset.Value) c.CmdClause.Flag("table", "Your BigQuery table").Action(c.Table.Set).StringVar(&c.Table.Value) - c.CmdClause.Flag("user", "Your Google Cloud Platform service account email address. The client_email field in your service account authentication JSON.").Action(c.User.Set).StringVar(&c.User.Value) - c.CmdClause.Flag("secret-key", "Your Google Cloud Platform account secret key. The private_key field in your service account authentication JSON.").Action(c.SecretKey.Set).StringVar(&c.SecretKey.Value) c.CmdClause.Flag("template-suffix", "BigQuery table name suffix template").Action(c.Template.Set).StringVar(&c.Template.Value) - common.Format(c.CmdClause, &c.Format) - common.FormatVersion(c.CmdClause, &c.FormatVersion) - common.Placement(c.CmdClause, &c.Placement) - common.ResponseCondition(c.CmdClause, &c.ResponseCondition) + c.CmdClause.Flag("user", "Your Google Cloud Platform service account email address. The client_email field in your service account authentication JSON.").Action(c.User.Set).StringVar(&c.User.Value) return &c } diff --git a/pkg/commands/logging/cloudfiles/create.go b/pkg/commands/logging/cloudfiles/create.go index 3838561c9..a2de6b6d6 100644 --- a/pkg/commands/logging/cloudfiles/create.go +++ b/pkg/commands/logging/cloudfiles/create.go @@ -45,24 +45,41 @@ type CreateCommand struct { // NewCreateCommand returns a usable command registered under the parent. func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *CreateCommand { - var c CreateCommand - c.Globals = globals - c.Manifest = data + c := CreateCommand{ + Base: cmd.Base{ + Globals: globals, + }, + Manifest: data, + } c.CmdClause = parent.Command("create", "Create a Cloudfiles logging endpoint on a Fastly service version").Alias("add") - c.CmdClause.Flag("name", "The name of the Cloudfiles logging object. Used as a primary key for API access").Short('n').Action(c.EndpointName.Set).StringVar(&c.EndpointName.Value) + + // required c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagVersionName, Description: cmd.FlagVersionDesc, Dst: &c.ServiceVersion.Value, Required: true, }) + + // optional + c.CmdClause.Flag("access-key", "Your Cloudfile account access key").Action(c.AccessKey.Set).StringVar(&c.AccessKey.Value) c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ Action: c.AutoClone.Set, Dst: &c.AutoClone.Value, }) - c.CmdClause.Flag("user", "The username for your Cloudfile account").Action(c.User.Set).StringVar(&c.User.Value) - c.CmdClause.Flag("access-key", "Your Cloudfile account access key").Action(c.AccessKey.Set).StringVar(&c.AccessKey.Value) c.CmdClause.Flag("bucket", "The name of your Cloudfiles container").Action(c.BucketName.Set).StringVar(&c.BucketName.Value) + common.CompressionCodec(c.CmdClause, &c.CompressionCodec) + common.Format(c.CmdClause, &c.Format) + common.FormatVersion(c.CmdClause, &c.FormatVersion) + common.GzipLevel(c.CmdClause, &c.GzipLevel) + common.MessageType(c.CmdClause, &c.MessageType) + c.CmdClause.Flag("name", "The name of the Cloudfiles logging object. Used as a primary key for API access").Short('n').Action(c.EndpointName.Set).StringVar(&c.EndpointName.Value) + common.Path(c.CmdClause, &c.Path) + common.Period(c.CmdClause, &c.Period) + common.Placement(c.CmdClause, &c.Placement) + common.PublicKey(c.CmdClause, &c.PublicKey) + c.CmdClause.Flag("region", "The region to stream logs to. One of: DFW-Dallas, ORD-Chicago, IAD-Northern Virginia, LON-London, SYD-Sydney, HKG-Hong Kong").Action(c.Region.Set).StringVar(&c.Region.Value) + common.ResponseCondition(c.CmdClause, &c.ResponseCondition) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagServiceIDName, Description: cmd.FlagServiceIDDesc, @@ -75,18 +92,8 @@ func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest Description: cmd.FlagServiceDesc, Dst: &c.ServiceName.Value, }) - c.CmdClause.Flag("region", "The region to stream logs to. One of: DFW-Dallas, ORD-Chicago, IAD-Northern Virginia, LON-London, SYD-Sydney, HKG-Hong Kong").Action(c.Region.Set).StringVar(&c.Region.Value) - common.Path(c.CmdClause, &c.Path) - common.Placement(c.CmdClause, &c.Placement) - common.Period(c.CmdClause, &c.Period) - common.GzipLevel(c.CmdClause, &c.GzipLevel) - common.Format(c.CmdClause, &c.Format) - common.FormatVersion(c.CmdClause, &c.FormatVersion) - common.ResponseCondition(c.CmdClause, &c.ResponseCondition) - common.MessageType(c.CmdClause, &c.MessageType) common.TimestampFormat(c.CmdClause, &c.TimestampFormat) - common.PublicKey(c.CmdClause, &c.PublicKey) - common.CompressionCodec(c.CmdClause, &c.CompressionCodec) + c.CmdClause.Flag("user", "The username for your Cloudfile account").Action(c.User.Set).StringVar(&c.User.Value) return &c } diff --git a/pkg/commands/logging/cloudfiles/delete.go b/pkg/commands/logging/cloudfiles/delete.go index 833b73093..99fbaa950 100644 --- a/pkg/commands/logging/cloudfiles/delete.go +++ b/pkg/commands/logging/cloudfiles/delete.go @@ -23,21 +23,28 @@ type DeleteCommand struct { // NewDeleteCommand returns a usable command registered under the parent. func NewDeleteCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *DeleteCommand { - var c DeleteCommand - c.Globals = globals - c.manifest = data + c := DeleteCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("delete", "Delete a Cloudfiles logging endpoint on a Fastly service version").Alias("remove") + + // required + c.CmdClause.Flag("name", "The name of the Cloudfiles logging object").Short('n').Required().StringVar(&c.Input.Name) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagVersionName, Description: cmd.FlagVersionDesc, Dst: &c.serviceVersion.Value, Required: true, }) + + // optional c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ Action: c.autoClone.Set, Dst: &c.autoClone.Value, }) - c.CmdClause.Flag("name", "The name of the Cloudfiles logging object").Short('n').Required().StringVar(&c.Input.Name) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagServiceIDName, Description: cmd.FlagServiceIDDesc, diff --git a/pkg/commands/logging/cloudfiles/describe.go b/pkg/commands/logging/cloudfiles/describe.go index 2b7419a83..4397fd783 100644 --- a/pkg/commands/logging/cloudfiles/describe.go +++ b/pkg/commands/logging/cloudfiles/describe.go @@ -25,10 +25,24 @@ type DescribeCommand struct { // NewDescribeCommand returns a usable command registered under the parent. func NewDescribeCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *DescribeCommand { - var c DescribeCommand - c.Globals = globals - c.manifest = data + c := DescribeCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("describe", "Show detailed information about a Cloudfiles logging endpoint on a Fastly service version").Alias("get") + + // required + c.CmdClause.Flag("name", "The name of the Cloudfiles logging object").Short('n').Required().StringVar(&c.Input.Name) + c.RegisterFlag(cmd.StringFlagOpts{ + Name: cmd.FlagVersionName, + Description: cmd.FlagVersionDesc, + Dst: &c.serviceVersion.Value, + Required: true, + }) + + // optional c.RegisterFlagBool(cmd.BoolFlagOpts{ Name: cmd.FlagJSONName, Description: cmd.FlagJSONDesc, @@ -47,13 +61,6 @@ func NewDescribeCommand(parent cmd.Registerer, globals *config.Data, data manife Description: cmd.FlagServiceDesc, Dst: &c.serviceName.Value, }) - c.RegisterFlag(cmd.StringFlagOpts{ - Name: cmd.FlagVersionName, - Description: cmd.FlagVersionDesc, - Dst: &c.serviceVersion.Value, - Required: true, - }) - c.CmdClause.Flag("name", "The name of the Cloudfiles logging object").Short('n').Required().StringVar(&c.Input.Name) return &c } diff --git a/pkg/commands/logging/cloudfiles/list.go b/pkg/commands/logging/cloudfiles/list.go index 28d47c9cf..8fde9b5e4 100644 --- a/pkg/commands/logging/cloudfiles/list.go +++ b/pkg/commands/logging/cloudfiles/list.go @@ -25,10 +25,23 @@ type ListCommand struct { // NewListCommand returns a usable command registered under the parent. func NewListCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *ListCommand { - var c ListCommand - c.Globals = globals - c.manifest = data + c := ListCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("list", "List Cloudfiles endpoints on a Fastly service version") + + // required + c.RegisterFlag(cmd.StringFlagOpts{ + Name: cmd.FlagVersionName, + Description: cmd.FlagVersionDesc, + Dst: &c.serviceVersion.Value, + Required: true, + }) + + // optional c.RegisterFlagBool(cmd.BoolFlagOpts{ Name: cmd.FlagJSONName, Description: cmd.FlagJSONDesc, @@ -47,12 +60,6 @@ func NewListCommand(parent cmd.Registerer, globals *config.Data, data manifest.D Description: cmd.FlagServiceDesc, Dst: &c.serviceName.Value, }) - c.RegisterFlag(cmd.StringFlagOpts{ - Name: cmd.FlagVersionName, - Description: cmd.FlagVersionDesc, - Dst: &c.serviceVersion.Value, - Required: true, - }) return &c } diff --git a/pkg/commands/logging/cloudfiles/update.go b/pkg/commands/logging/cloudfiles/update.go index 6d18f5b49..1137c2d6f 100644 --- a/pkg/commands/logging/cloudfiles/update.go +++ b/pkg/commands/logging/cloudfiles/update.go @@ -44,21 +44,43 @@ type UpdateCommand struct { // NewUpdateCommand returns a usable command registered under the parent. func NewUpdateCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *UpdateCommand { - var c UpdateCommand - c.Globals = globals - c.Manifest = data + c := UpdateCommand{ + Base: cmd.Base{ + Globals: globals, + }, + Manifest: data, + } c.CmdClause = parent.Command("update", "Update a Cloudfiles logging endpoint on a Fastly service version") + + // required + c.CmdClause.Flag("name", "The name of the Cloudfiles logging object").Short('n').Required().StringVar(&c.EndpointName) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagVersionName, Description: cmd.FlagVersionDesc, Dst: &c.ServiceVersion.Value, Required: true, }) + + // optional c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ Action: c.AutoClone.Set, Dst: &c.AutoClone.Value, }) - c.CmdClause.Flag("name", "The name of the Cloudfiles logging object").Short('n').Required().StringVar(&c.EndpointName) + c.CmdClause.Flag("access-key", "Your Cloudfile account access key").Action(c.AccessKey.Set).StringVar(&c.AccessKey.Value) + c.CmdClause.Flag("bucket", "The name of your Cloudfiles container").Action(c.BucketName.Set).StringVar(&c.BucketName.Value) + common.CompressionCodec(c.CmdClause, &c.CompressionCodec) + common.Format(c.CmdClause, &c.Format) + common.FormatVersion(c.CmdClause, &c.FormatVersion) + common.GzipLevel(c.CmdClause, &c.GzipLevel) + common.MessageType(c.CmdClause, &c.MessageType) + c.CmdClause.Flag("new-name", "New name of the Cloudfiles logging object").Action(c.NewName.Set).StringVar(&c.NewName.Value) + common.Path(c.CmdClause, &c.Path) + common.Period(c.CmdClause, &c.Period) + common.Placement(c.CmdClause, &c.Placement) + common.PublicKey(c.CmdClause, &c.PublicKey) + c.CmdClause.Flag("region", "The region to stream logs to. One of: DFW-Dallas, ORD-Chicago, IAD-Northern Virginia, LON-London, SYD-Sydney, HKG-Hong Kong").Action(c.Region.Set).StringVar(&c.Region.Value) + c.CmdClause.Flag("user", "The username for your Cloudfile account").Action(c.User.Set).StringVar(&c.User.Value) + common.ResponseCondition(c.CmdClause, &c.ResponseCondition) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagServiceIDName, Description: cmd.FlagServiceIDDesc, @@ -71,22 +93,7 @@ func NewUpdateCommand(parent cmd.Registerer, globals *config.Data, data manifest Description: cmd.FlagServiceDesc, Dst: &c.ServiceName.Value, }) - c.CmdClause.Flag("new-name", "New name of the Cloudfiles logging object").Action(c.NewName.Set).StringVar(&c.NewName.Value) - c.CmdClause.Flag("user", "The username for your Cloudfile account").Action(c.User.Set).StringVar(&c.User.Value) - c.CmdClause.Flag("access-key", "Your Cloudfile account access key").Action(c.AccessKey.Set).StringVar(&c.AccessKey.Value) - c.CmdClause.Flag("bucket", "The name of your Cloudfiles container").Action(c.BucketName.Set).StringVar(&c.BucketName.Value) - common.Path(c.CmdClause, &c.Path) - c.CmdClause.Flag("region", "The region to stream logs to. One of: DFW-Dallas, ORD-Chicago, IAD-Northern Virginia, LON-London, SYD-Sydney, HKG-Hong Kong").Action(c.Region.Set).StringVar(&c.Region.Value) - common.Placement(c.CmdClause, &c.Placement) - common.Period(c.CmdClause, &c.Period) - common.GzipLevel(c.CmdClause, &c.GzipLevel) - common.Format(c.CmdClause, &c.Format) - common.FormatVersion(c.CmdClause, &c.FormatVersion) - common.ResponseCondition(c.CmdClause, &c.ResponseCondition) - common.MessageType(c.CmdClause, &c.MessageType) common.TimestampFormat(c.CmdClause, &c.TimestampFormat) - common.PublicKey(c.CmdClause, &c.PublicKey) - common.CompressionCodec(c.CmdClause, &c.CompressionCodec) return &c } diff --git a/pkg/commands/logging/datadog/create.go b/pkg/commands/logging/datadog/create.go index 1628a08a8..bf73bb756 100644 --- a/pkg/commands/logging/datadog/create.go +++ b/pkg/commands/logging/datadog/create.go @@ -34,10 +34,15 @@ type CreateCommand struct { // NewCreateCommand returns a usable command registered under the parent. func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *CreateCommand { - var c CreateCommand - c.Globals = globals - c.Manifest = data + c := CreateCommand{ + Base: cmd.Base{ + Globals: globals, + }, + Manifest: data, + } c.CmdClause = parent.Command("create", "Create a Datadog logging endpoint on a Fastly service version").Alias("add") + + // required c.CmdClause.Flag("name", "The name of the Datadog logging object. Used as a primary key for API access").Short('n').Action(c.EndpointName.Set).StringVar(&c.EndpointName.Value) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagVersionName, @@ -45,11 +50,18 @@ func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest Dst: &c.ServiceVersion.Value, Required: true, }) + + // optional c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ Action: c.AutoClone.Set, Dst: &c.AutoClone.Value, }) c.CmdClause.Flag("auth-token", "The API key from your Datadog account").Action(c.Token.Set).StringVar(&c.Token.Value) + common.Format(c.CmdClause, &c.Format) + common.FormatVersion(c.CmdClause, &c.FormatVersion) + common.Placement(c.CmdClause, &c.Placement) + c.CmdClause.Flag("region", "The region that log data will be sent to. One of US, US3, US5, or EU. Defaults to US if undefined").Action(c.Region.Set).StringVar(&c.Region.Value) + common.ResponseCondition(c.CmdClause, &c.ResponseCondition) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagServiceIDName, Description: cmd.FlagServiceIDDesc, @@ -62,11 +74,6 @@ func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest Description: cmd.FlagServiceDesc, Dst: &c.ServiceName.Value, }) - c.CmdClause.Flag("region", "The region that log data will be sent to. One of US, US3, US5, or EU. Defaults to US if undefined").Action(c.Region.Set).StringVar(&c.Region.Value) - common.Format(c.CmdClause, &c.Format) - common.FormatVersion(c.CmdClause, &c.FormatVersion) - common.ResponseCondition(c.CmdClause, &c.ResponseCondition) - common.Placement(c.CmdClause, &c.Placement) return &c } diff --git a/pkg/commands/logging/datadog/delete.go b/pkg/commands/logging/datadog/delete.go index 7f638aa49..e47bc8b3b 100644 --- a/pkg/commands/logging/datadog/delete.go +++ b/pkg/commands/logging/datadog/delete.go @@ -23,21 +23,28 @@ type DeleteCommand struct { // NewDeleteCommand returns a usable command registered under the parent. func NewDeleteCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *DeleteCommand { - var c DeleteCommand - c.Globals = globals - c.manifest = data + c := DeleteCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("delete", "Delete a Datadog logging endpoint on a Fastly service version").Alias("remove") + + // required + c.CmdClause.Flag("name", "The name of the Datadog logging object").Short('n').Required().StringVar(&c.Input.Name) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagVersionName, Description: cmd.FlagVersionDesc, Dst: &c.serviceVersion.Value, Required: true, }) + + // optional c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ Action: c.autoClone.Set, Dst: &c.autoClone.Value, }) - c.CmdClause.Flag("name", "The name of the Datadog logging object").Short('n').Required().StringVar(&c.Input.Name) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagServiceIDName, Description: cmd.FlagServiceIDDesc, diff --git a/pkg/commands/logging/datadog/describe.go b/pkg/commands/logging/datadog/describe.go index 9cae2d303..370bdae91 100644 --- a/pkg/commands/logging/datadog/describe.go +++ b/pkg/commands/logging/datadog/describe.go @@ -25,10 +25,24 @@ type DescribeCommand struct { // NewDescribeCommand returns a usable command registered under the parent. func NewDescribeCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *DescribeCommand { - var c DescribeCommand - c.Globals = globals - c.manifest = data + c := DescribeCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("describe", "Show detailed information about a Datadog logging endpoint on a Fastly service version").Alias("get") + + // required + c.CmdClause.Flag("name", "The name of the Datadog logging object").Short('n').Required().StringVar(&c.Input.Name) + c.RegisterFlag(cmd.StringFlagOpts{ + Name: cmd.FlagVersionName, + Description: cmd.FlagVersionDesc, + Dst: &c.serviceVersion.Value, + Required: true, + }) + + // optional c.RegisterFlagBool(cmd.BoolFlagOpts{ Name: cmd.FlagJSONName, Description: cmd.FlagJSONDesc, @@ -47,13 +61,6 @@ func NewDescribeCommand(parent cmd.Registerer, globals *config.Data, data manife Description: cmd.FlagServiceDesc, Dst: &c.serviceName.Value, }) - c.RegisterFlag(cmd.StringFlagOpts{ - Name: cmd.FlagVersionName, - Description: cmd.FlagVersionDesc, - Dst: &c.serviceVersion.Value, - Required: true, - }) - c.CmdClause.Flag("name", "The name of the Datadog logging object").Short('n').Required().StringVar(&c.Input.Name) return &c } diff --git a/pkg/commands/logging/datadog/list.go b/pkg/commands/logging/datadog/list.go index e2ad1d575..8aa4f129c 100644 --- a/pkg/commands/logging/datadog/list.go +++ b/pkg/commands/logging/datadog/list.go @@ -25,10 +25,23 @@ type ListCommand struct { // NewListCommand returns a usable command registered under the parent. func NewListCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *ListCommand { - var c ListCommand - c.Globals = globals - c.manifest = data + c := ListCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("list", "List Datadog endpoints on a Fastly service version") + + // required + c.RegisterFlag(cmd.StringFlagOpts{ + Name: cmd.FlagVersionName, + Description: cmd.FlagVersionDesc, + Dst: &c.serviceVersion.Value, + Required: true, + }) + + // optional c.RegisterFlagBool(cmd.BoolFlagOpts{ Name: cmd.FlagJSONName, Description: cmd.FlagJSONDesc, @@ -47,12 +60,6 @@ func NewListCommand(parent cmd.Registerer, globals *config.Data, data manifest.D Description: cmd.FlagServiceDesc, Dst: &c.serviceName.Value, }) - c.RegisterFlag(cmd.StringFlagOpts{ - Name: cmd.FlagVersionName, - Description: cmd.FlagVersionDesc, - Dst: &c.serviceVersion.Value, - Required: true, - }) return &c } diff --git a/pkg/commands/logging/datadog/update.go b/pkg/commands/logging/datadog/update.go index ea919b0f1..9e627dcac 100644 --- a/pkg/commands/logging/datadog/update.go +++ b/pkg/commands/logging/datadog/update.go @@ -35,21 +35,35 @@ type UpdateCommand struct { // NewUpdateCommand returns a usable command registered under the parent. func NewUpdateCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *UpdateCommand { - var c UpdateCommand - c.Globals = globals - c.Manifest = data + c := UpdateCommand{ + Base: cmd.Base{ + Globals: globals, + }, + Manifest: data, + } c.CmdClause = parent.Command("update", "Update a Datadog logging endpoint on a Fastly service version") + + // required + c.CmdClause.Flag("name", "The name of the Datadog logging object").Short('n').Required().StringVar(&c.EndpointName) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagVersionName, Description: cmd.FlagVersionDesc, Dst: &c.ServiceVersion.Value, Required: true, }) + + // optional c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ Action: c.AutoClone.Set, Dst: &c.AutoClone.Value, }) - c.CmdClause.Flag("name", "The name of the Datadog logging object").Short('n').Required().StringVar(&c.EndpointName) + c.CmdClause.Flag("auth-token", "The API key from your Datadog account").Action(c.Token.Set).StringVar(&c.Token.Value) + common.Format(c.CmdClause, &c.Format) + common.FormatVersion(c.CmdClause, &c.FormatVersion) + c.CmdClause.Flag("new-name", "New name of the Datadog logging object").Action(c.NewName.Set).StringVar(&c.NewName.Value) + common.Placement(c.CmdClause, &c.Placement) + c.CmdClause.Flag("region", "The region that log data will be sent to. One of US, US3, US5, or EU. Defaults to US if undefined").Action(c.Region.Set).StringVar(&c.Region.Value) + common.ResponseCondition(c.CmdClause, &c.ResponseCondition) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagServiceIDName, Description: cmd.FlagServiceIDDesc, @@ -62,13 +76,6 @@ func NewUpdateCommand(parent cmd.Registerer, globals *config.Data, data manifest Description: cmd.FlagServiceDesc, Dst: &c.ServiceName.Value, }) - c.CmdClause.Flag("new-name", "New name of the Datadog logging object").Action(c.NewName.Set).StringVar(&c.NewName.Value) - c.CmdClause.Flag("auth-token", "The API key from your Datadog account").Action(c.Token.Set).StringVar(&c.Token.Value) - c.CmdClause.Flag("region", "The region that log data will be sent to. One of US, US3, US5, or EU. Defaults to US if undefined").Action(c.Region.Set).StringVar(&c.Region.Value) - common.Format(c.CmdClause, &c.Format) - common.FormatVersion(c.CmdClause, &c.FormatVersion) - common.ResponseCondition(c.CmdClause, &c.ResponseCondition) - common.Placement(c.CmdClause, &c.Placement) return &c } diff --git a/pkg/commands/logging/digitalocean/create.go b/pkg/commands/logging/digitalocean/create.go index a73e7b14c..c9b236872 100644 --- a/pkg/commands/logging/digitalocean/create.go +++ b/pkg/commands/logging/digitalocean/create.go @@ -44,23 +44,41 @@ type CreateCommand struct { // NewCreateCommand returns a usable command registered under the parent. func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *CreateCommand { - var c CreateCommand - c.Globals = globals - c.Manifest = data + c := CreateCommand{ + Base: cmd.Base{ + Globals: globals, + }, + Manifest: data, + } c.CmdClause = parent.Command("create", "Create a DigitalOcean Spaces logging endpoint on a Fastly service version").Alias("add") - c.CmdClause.Flag("name", "The name of the DigitalOcean Spaces logging object. Used as a primary key for API access").Short('n').Action(c.EndpointName.Set).StringVar(&c.EndpointName.Value) + + // required c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagVersionName, Description: cmd.FlagVersionDesc, Dst: &c.ServiceVersion.Value, Required: true, }) + + // optional c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ Action: c.AutoClone.Set, Dst: &c.AutoClone.Value, }) - c.CmdClause.Flag("bucket", "The name of the DigitalOcean Space").Action(c.BucketName.Set).StringVar(&c.BucketName.Value) c.CmdClause.Flag("access-key", "Your DigitalOcean Spaces account access key").Action(c.AccessKey.Set).StringVar(&c.AccessKey.Value) + c.CmdClause.Flag("bucket", "The name of the DigitalOcean Space").Action(c.BucketName.Set).StringVar(&c.BucketName.Value) + common.CompressionCodec(c.CmdClause, &c.CompressionCodec) + c.CmdClause.Flag("domain", "The domain of the DigitalOcean Spaces endpoint (default 'nyc3.digitaloceanspaces.com')").Action(c.Domain.Set).StringVar(&c.Domain.Value) + common.Format(c.CmdClause, &c.Format) + common.FormatVersion(c.CmdClause, &c.FormatVersion) + common.GzipLevel(c.CmdClause, &c.GzipLevel) + c.CmdClause.Flag("name", "The name of the DigitalOcean Spaces logging object. Used as a primary key for API access").Short('n').Action(c.EndpointName.Set).StringVar(&c.EndpointName.Value) + common.MessageType(c.CmdClause, &c.MessageType) + common.Path(c.CmdClause, &c.Path) + common.Period(c.CmdClause, &c.Period) + common.Placement(c.CmdClause, &c.Placement) + common.PublicKey(c.CmdClause, &c.PublicKey) + common.ResponseCondition(c.CmdClause, &c.ResponseCondition) c.CmdClause.Flag("secret-key", "Your DigitalOcean Spaces account secret key").Action(c.SecretKey.Set).StringVar(&c.SecretKey.Value) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagServiceIDName, @@ -74,18 +92,7 @@ func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest Description: cmd.FlagServiceDesc, Dst: &c.ServiceName.Value, }) - c.CmdClause.Flag("domain", "The domain of the DigitalOcean Spaces endpoint (default 'nyc3.digitaloceanspaces.com')").Action(c.Domain.Set).StringVar(&c.Domain.Value) - common.Path(c.CmdClause, &c.Path) - common.Period(c.CmdClause, &c.Period) - common.GzipLevel(c.CmdClause, &c.GzipLevel) - common.Format(c.CmdClause, &c.Format) - common.MessageType(c.CmdClause, &c.MessageType) - common.FormatVersion(c.CmdClause, &c.FormatVersion) - common.ResponseCondition(c.CmdClause, &c.ResponseCondition) common.TimestampFormat(c.CmdClause, &c.TimestampFormat) - common.Placement(c.CmdClause, &c.Placement) - common.PublicKey(c.CmdClause, &c.PublicKey) - common.CompressionCodec(c.CmdClause, &c.CompressionCodec) return &c } diff --git a/pkg/commands/logging/digitalocean/delete.go b/pkg/commands/logging/digitalocean/delete.go index 90d6a5140..190c0ada9 100644 --- a/pkg/commands/logging/digitalocean/delete.go +++ b/pkg/commands/logging/digitalocean/delete.go @@ -23,21 +23,28 @@ type DeleteCommand struct { // NewDeleteCommand returns a usable command registered under the parent. func NewDeleteCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *DeleteCommand { - var c DeleteCommand - c.Globals = globals - c.manifest = data + c := DeleteCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("delete", "Delete a DigitalOcean Spaces logging endpoint on a Fastly service version").Alias("remove") + + // required + c.CmdClause.Flag("name", "The name of the DigitalOcean Spaces logging object").Short('n').Required().StringVar(&c.Input.Name) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagVersionName, Description: cmd.FlagVersionDesc, Dst: &c.serviceVersion.Value, Required: true, }) + + // optional c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ Action: c.autoClone.Set, Dst: &c.autoClone.Value, }) - c.CmdClause.Flag("name", "The name of the DigitalOcean Spaces logging object").Short('n').Required().StringVar(&c.Input.Name) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagServiceIDName, Description: cmd.FlagServiceIDDesc, diff --git a/pkg/commands/logging/digitalocean/describe.go b/pkg/commands/logging/digitalocean/describe.go index 082190e6e..9902f0d0d 100644 --- a/pkg/commands/logging/digitalocean/describe.go +++ b/pkg/commands/logging/digitalocean/describe.go @@ -25,10 +25,24 @@ type DescribeCommand struct { // NewDescribeCommand returns a usable command registered under the parent. func NewDescribeCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *DescribeCommand { - var c DescribeCommand - c.Globals = globals - c.manifest = data + c := DescribeCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("describe", "Show detailed information about a DigitalOcean Spaces logging endpoint on a Fastly service version").Alias("get") + + // required + c.CmdClause.Flag("name", "The name of the DigitalOcean Spaces logging object").Short('n').Required().StringVar(&c.Input.Name) + c.RegisterFlag(cmd.StringFlagOpts{ + Name: cmd.FlagVersionName, + Description: cmd.FlagVersionDesc, + Dst: &c.serviceVersion.Value, + Required: true, + }) + + // optional c.RegisterFlagBool(cmd.BoolFlagOpts{ Name: cmd.FlagJSONName, Description: cmd.FlagJSONDesc, @@ -47,13 +61,6 @@ func NewDescribeCommand(parent cmd.Registerer, globals *config.Data, data manife Description: cmd.FlagServiceDesc, Dst: &c.serviceName.Value, }) - c.RegisterFlag(cmd.StringFlagOpts{ - Name: cmd.FlagVersionName, - Description: cmd.FlagVersionDesc, - Dst: &c.serviceVersion.Value, - Required: true, - }) - c.CmdClause.Flag("name", "The name of the DigitalOcean Spaces logging object").Short('n').Required().StringVar(&c.Input.Name) return &c } diff --git a/pkg/commands/logging/digitalocean/list.go b/pkg/commands/logging/digitalocean/list.go index 7cadf1602..143d7f706 100644 --- a/pkg/commands/logging/digitalocean/list.go +++ b/pkg/commands/logging/digitalocean/list.go @@ -25,10 +25,23 @@ type ListCommand struct { // NewListCommand returns a usable command registered under the parent. func NewListCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *ListCommand { - var c ListCommand - c.Globals = globals - c.manifest = data + c := ListCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("list", "List DigitalOcean Spaces logging endpoints on a Fastly service version") + + // required + c.RegisterFlag(cmd.StringFlagOpts{ + Name: cmd.FlagVersionName, + Description: cmd.FlagVersionDesc, + Dst: &c.serviceVersion.Value, + Required: true, + }) + + // optional c.RegisterFlagBool(cmd.BoolFlagOpts{ Name: cmd.FlagJSONName, Description: cmd.FlagJSONDesc, @@ -47,12 +60,6 @@ func NewListCommand(parent cmd.Registerer, globals *config.Data, data manifest.D Description: cmd.FlagServiceDesc, Dst: &c.serviceName.Value, }) - c.RegisterFlag(cmd.StringFlagOpts{ - Name: cmd.FlagVersionName, - Description: cmd.FlagVersionDesc, - Dst: &c.serviceVersion.Value, - Required: true, - }) return &c } diff --git a/pkg/commands/logging/digitalocean/update.go b/pkg/commands/logging/digitalocean/update.go index 5530e83db..817934743 100644 --- a/pkg/commands/logging/digitalocean/update.go +++ b/pkg/commands/logging/digitalocean/update.go @@ -44,21 +44,43 @@ type UpdateCommand struct { // NewUpdateCommand returns a usable command registered under the parent. func NewUpdateCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *UpdateCommand { - var c UpdateCommand - c.Globals = globals - c.Manifest = data + c := UpdateCommand{ + Base: cmd.Base{ + Globals: globals, + }, + Manifest: data, + } c.CmdClause = parent.Command("update", "Update a DigitalOcean Spaces logging endpoint on a Fastly service version") + + // required + c.CmdClause.Flag("name", "The name of the DigitalOcean Spaces logging object").Short('n').Required().StringVar(&c.EndpointName) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagVersionName, Description: cmd.FlagVersionDesc, Dst: &c.ServiceVersion.Value, Required: true, }) + + // optional + c.CmdClause.Flag("access-key", "Your DigitalOcean Spaces account access key").Action(c.AccessKey.Set).StringVar(&c.AccessKey.Value) c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ Action: c.AutoClone.Set, Dst: &c.AutoClone.Value, }) - c.CmdClause.Flag("name", "The name of the DigitalOcean Spaces logging object").Short('n').Required().StringVar(&c.EndpointName) + c.CmdClause.Flag("bucket", "The name of the DigitalOcean Space").Action(c.BucketName.Set).StringVar(&c.BucketName.Value) + common.CompressionCodec(c.CmdClause, &c.CompressionCodec) + c.CmdClause.Flag("domain", "The domain of the DigitalOcean Spaces endpoint (default 'nyc3.digitaloceanspaces.com')").Action(c.Domain.Set).StringVar(&c.Domain.Value) + common.Format(c.CmdClause, &c.Format) + common.FormatVersion(c.CmdClause, &c.FormatVersion) + common.GzipLevel(c.CmdClause, &c.GzipLevel) + common.MessageType(c.CmdClause, &c.MessageType) + c.CmdClause.Flag("new-name", "New name of the DigitalOcean Spaces logging object").Action(c.NewName.Set).StringVar(&c.NewName.Value) + common.Path(c.CmdClause, &c.Path) + common.Period(c.CmdClause, &c.Period) + common.Placement(c.CmdClause, &c.Placement) + common.PublicKey(c.CmdClause, &c.PublicKey) + common.ResponseCondition(c.CmdClause, &c.ResponseCondition) + c.CmdClause.Flag("secret-key", "Your DigitalOcean Spaces account secret key").Action(c.SecretKey.Set).StringVar(&c.SecretKey.Value) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagServiceIDName, Description: cmd.FlagServiceIDDesc, @@ -71,22 +93,7 @@ func NewUpdateCommand(parent cmd.Registerer, globals *config.Data, data manifest Description: cmd.FlagServiceDesc, Dst: &c.ServiceName.Value, }) - c.CmdClause.Flag("new-name", "New name of the DigitalOcean Spaces logging object").Action(c.NewName.Set).StringVar(&c.NewName.Value) - c.CmdClause.Flag("bucket", "The name of the DigitalOcean Space").Action(c.BucketName.Set).StringVar(&c.BucketName.Value) - c.CmdClause.Flag("domain", "The domain of the DigitalOcean Spaces endpoint (default 'nyc3.digitaloceanspaces.com')").Action(c.Domain.Set).StringVar(&c.Domain.Value) - c.CmdClause.Flag("access-key", "Your DigitalOcean Spaces account access key").Action(c.AccessKey.Set).StringVar(&c.AccessKey.Value) - c.CmdClause.Flag("secret-key", "Your DigitalOcean Spaces account secret key").Action(c.SecretKey.Set).StringVar(&c.SecretKey.Value) - common.Path(c.CmdClause, &c.Path) - common.Period(c.CmdClause, &c.Period) - common.GzipLevel(c.CmdClause, &c.GzipLevel) - common.Format(c.CmdClause, &c.Format) - common.FormatVersion(c.CmdClause, &c.FormatVersion) - common.ResponseCondition(c.CmdClause, &c.ResponseCondition) - common.MessageType(c.CmdClause, &c.MessageType) common.TimestampFormat(c.CmdClause, &c.TimestampFormat) - common.Placement(c.CmdClause, &c.Placement) - common.PublicKey(c.CmdClause, &c.PublicKey) - common.CompressionCodec(c.CmdClause, &c.CompressionCodec) return &c } diff --git a/pkg/commands/logging/elasticsearch/create.go b/pkg/commands/logging/elasticsearch/create.go index 77caa016e..63fbe641a 100644 --- a/pkg/commands/logging/elasticsearch/create.go +++ b/pkg/commands/logging/elasticsearch/create.go @@ -43,10 +43,15 @@ type CreateCommand struct { // NewCreateCommand returns a usable command registered under the parent. func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *CreateCommand { - var c CreateCommand - c.Globals = globals - c.Manifest = data + c := CreateCommand{ + Base: cmd.Base{ + Globals: globals, + }, + Manifest: data, + } c.CmdClause = parent.Command("create", "Create an Elasticsearch logging endpoint on a Fastly service version").Alias("add") + + // required c.CmdClause.Flag("name", "The name of the Elasticsearch logging object. Used as a primary key for API access").Short('n').Action(c.EndpointName.Set).StringVar(&c.EndpointName.Value) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagVersionName, @@ -54,12 +59,20 @@ func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest Dst: &c.ServiceVersion.Value, Required: true, }) + + // optional c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ Action: c.AutoClone.Set, Dst: &c.AutoClone.Value, }) + common.Format(c.CmdClause, &c.Format) + common.FormatVersion(c.CmdClause, &c.FormatVersion) c.CmdClause.Flag("index", `The name of the Elasticsearch index to send documents (logs) to. The index must follow the Elasticsearch index format rules (https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-create-index.html). We support strftime (http://man7.org/linux/man-pages/man3/strftime.3.html) interpolated variables inside braces prefixed with a pound symbol. For example, #{%F} will interpolate as YYYY-MM-DD with today's date`).Action(c.Index.Set).StringVar(&c.Index.Value) - c.CmdClause.Flag("url", "The URL to stream logs to. Must use HTTPS.").Action(c.URL.Set).StringVar(&c.URL.Value) + common.Placement(c.CmdClause, &c.Placement) + c.CmdClause.Flag("pipeline", "The ID of the Elasticsearch ingest pipeline to apply pre-process transformations to before indexing. For example my_pipeline_id. Learn more about creating a pipeline in the Elasticsearch docs (https://www.elastic.co/guide/en/elasticsearch/reference/current/ingest.html)").Action(c.Password.Set).StringVar(&c.Pipeline.Value) + c.CmdClause.Flag("request-max-bytes", "Maximum size of log batch, if non-zero. Defaults to 100MB").Action(c.RequestMaxBytes.Set).IntVar(&c.RequestMaxBytes.Value) + c.CmdClause.Flag("request-max-entries", "Maximum number of logs to append to a batch, if non-zero. Defaults to 10k").Action(c.RequestMaxEntries.Set).IntVar(&c.RequestMaxEntries.Value) + common.ResponseCondition(c.CmdClause, &c.ResponseCondition) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagServiceIDName, Description: cmd.FlagServiceIDDesc, @@ -72,17 +85,11 @@ func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest Description: cmd.FlagServiceDesc, Dst: &c.ServiceName.Value, }) - c.CmdClause.Flag("pipeline", "The ID of the Elasticsearch ingest pipeline to apply pre-process transformations to before indexing. For example my_pipeline_id. Learn more about creating a pipeline in the Elasticsearch docs (https://www.elastic.co/guide/en/elasticsearch/reference/current/ingest.html)").Action(c.Password.Set).StringVar(&c.Pipeline.Value) common.TLSCACert(c.CmdClause, &c.TLSCACert) common.TLSClientCert(c.CmdClause, &c.TLSClientCert) common.TLSClientKey(c.CmdClause, &c.TLSClientKey) common.TLSHostname(c.CmdClause, &c.TLSHostname) - common.Format(c.CmdClause, &c.Format) - common.FormatVersion(c.CmdClause, &c.FormatVersion) - common.Placement(c.CmdClause, &c.Placement) - common.ResponseCondition(c.CmdClause, &c.ResponseCondition) - c.CmdClause.Flag("request-max-entries", "Maximum number of logs to append to a batch, if non-zero. Defaults to 10k").Action(c.RequestMaxEntries.Set).IntVar(&c.RequestMaxEntries.Value) - c.CmdClause.Flag("request-max-bytes", "Maximum size of log batch, if non-zero. Defaults to 100MB").Action(c.RequestMaxBytes.Set).IntVar(&c.RequestMaxBytes.Value) + c.CmdClause.Flag("url", "The URL to stream logs to. Must use HTTPS.").Action(c.URL.Set).StringVar(&c.URL.Value) return &c } diff --git a/pkg/commands/logging/elasticsearch/delete.go b/pkg/commands/logging/elasticsearch/delete.go index f9eb2e5e2..b29301e46 100644 --- a/pkg/commands/logging/elasticsearch/delete.go +++ b/pkg/commands/logging/elasticsearch/delete.go @@ -23,21 +23,28 @@ type DeleteCommand struct { // NewDeleteCommand returns a usable command registered under the parent. func NewDeleteCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *DeleteCommand { - var c DeleteCommand - c.Globals = globals - c.manifest = data + c := DeleteCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("delete", "Delete an Elasticsearch logging endpoint on a Fastly service version").Alias("remove") + + // required + c.CmdClause.Flag("name", "The name of the Elasticsearch logging object").Short('n').Required().StringVar(&c.Input.Name) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagVersionName, Description: cmd.FlagVersionDesc, Dst: &c.serviceVersion.Value, Required: true, }) + + // optional c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ Action: c.autoClone.Set, Dst: &c.autoClone.Value, }) - c.CmdClause.Flag("name", "The name of the Elasticsearch logging object").Short('n').Required().StringVar(&c.Input.Name) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagServiceIDName, Description: cmd.FlagServiceIDDesc, diff --git a/pkg/commands/logging/elasticsearch/describe.go b/pkg/commands/logging/elasticsearch/describe.go index 2fc2903c3..c4f2da910 100644 --- a/pkg/commands/logging/elasticsearch/describe.go +++ b/pkg/commands/logging/elasticsearch/describe.go @@ -25,10 +25,24 @@ type DescribeCommand struct { // NewDescribeCommand returns a usable command registered under the parent. func NewDescribeCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *DescribeCommand { - var c DescribeCommand - c.Globals = globals - c.manifest = data + c := DescribeCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("describe", "Show detailed information about an Elasticsearch logging endpoint on a Fastly service version").Alias("get") + + // required + c.CmdClause.Flag("name", "The name of the Elasticsearch logging object").Short('n').Required().StringVar(&c.Input.Name) + c.RegisterFlag(cmd.StringFlagOpts{ + Name: cmd.FlagVersionName, + Description: cmd.FlagVersionDesc, + Dst: &c.serviceVersion.Value, + Required: true, + }) + + // optional c.RegisterFlagBool(cmd.BoolFlagOpts{ Name: cmd.FlagJSONName, Description: cmd.FlagJSONDesc, @@ -47,13 +61,6 @@ func NewDescribeCommand(parent cmd.Registerer, globals *config.Data, data manife Description: cmd.FlagServiceDesc, Dst: &c.serviceName.Value, }) - c.RegisterFlag(cmd.StringFlagOpts{ - Name: cmd.FlagVersionName, - Description: cmd.FlagVersionDesc, - Dst: &c.serviceVersion.Value, - Required: true, - }) - c.CmdClause.Flag("name", "The name of the Elasticsearch logging object").Short('n').Required().StringVar(&c.Input.Name) return &c } diff --git a/pkg/commands/logging/elasticsearch/list.go b/pkg/commands/logging/elasticsearch/list.go index 1f3bba5ea..1f2b176c8 100644 --- a/pkg/commands/logging/elasticsearch/list.go +++ b/pkg/commands/logging/elasticsearch/list.go @@ -25,10 +25,23 @@ type ListCommand struct { // NewListCommand returns a usable command registered under the parent. func NewListCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *ListCommand { - var c ListCommand - c.Globals = globals - c.manifest = data + c := ListCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("list", "List Elasticsearch endpoints on a Fastly service version") + + // required + c.RegisterFlag(cmd.StringFlagOpts{ + Name: cmd.FlagVersionName, + Description: cmd.FlagVersionDesc, + Dst: &c.serviceVersion.Value, + Required: true, + }) + + // optional c.RegisterFlagBool(cmd.BoolFlagOpts{ Name: cmd.FlagJSONName, Description: cmd.FlagJSONDesc, @@ -47,12 +60,6 @@ func NewListCommand(parent cmd.Registerer, globals *config.Data, data manifest.D Description: cmd.FlagServiceDesc, Dst: &c.serviceName.Value, }) - c.RegisterFlag(cmd.StringFlagOpts{ - Name: cmd.FlagVersionName, - Description: cmd.FlagVersionDesc, - Dst: &c.serviceVersion.Value, - Required: true, - }) return &c } diff --git a/pkg/commands/logging/elasticsearch/update.go b/pkg/commands/logging/elasticsearch/update.go index cd2e3bf5d..2e79cbe89 100644 --- a/pkg/commands/logging/elasticsearch/update.go +++ b/pkg/commands/logging/elasticsearch/update.go @@ -44,21 +44,37 @@ type UpdateCommand struct { // NewUpdateCommand returns a usable command registered under the parent. func NewUpdateCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *UpdateCommand { - var c UpdateCommand - c.Globals = globals - c.Manifest = data + c := UpdateCommand{ + Base: cmd.Base{ + Globals: globals, + }, + Manifest: data, + } c.CmdClause = parent.Command("update", "Update an Elasticsearch logging endpoint on a Fastly service version") + + // required + c.CmdClause.Flag("name", "The name of the Elasticsearch logging object").Short('n').Required().StringVar(&c.EndpointName) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagVersionName, Description: cmd.FlagVersionDesc, Dst: &c.ServiceVersion.Value, Required: true, }) + + // optional c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ Action: c.AutoClone.Set, Dst: &c.AutoClone.Value, }) - c.CmdClause.Flag("name", "The name of the Elasticsearch logging object").Short('n').Required().StringVar(&c.EndpointName) + common.Format(c.CmdClause, &c.Format) + common.FormatVersion(c.CmdClause, &c.FormatVersion) + c.CmdClause.Flag("index", `The name of the Elasticsearch index to send documents (logs) to. The index must follow the Elasticsearch index format rules (https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-create-index.html). We support strftime (http://man7.org/linux/man-pages/man3/strftime.3.html) interpolated variables inside braces prefixed with a pound symbol. For example, #{%F} will interpolate as YYYY-MM-DD with today's date`).Action(c.Index.Set).StringVar(&c.Index.Value) + c.CmdClause.Flag("new-name", "New name of the Elasticsearch logging object").Action(c.NewName.Set).StringVar(&c.NewName.Value) + c.CmdClause.Flag("pipeline", "The ID of the Elasticsearch ingest pipeline to apply pre-process transformations to before indexing. For example my_pipeline_id. Learn more about creating a pipeline in the Elasticsearch docs (https://www.elastic.co/guide/en/elasticsearch/reference/current/ingest.html)").Action(c.Password.Set).StringVar(&c.Pipeline.Value) + common.Placement(c.CmdClause, &c.Placement) + c.CmdClause.Flag("request-max-bytes", "Maximum size of log batch, if non-zero. Defaults to 100MB").Action(c.RequestMaxBytes.Set).IntVar(&c.RequestMaxBytes.Value) + c.CmdClause.Flag("request-max-entries", "Maximum number of logs to append to a batch, if non-zero. Defaults to 10k").Action(c.RequestMaxEntries.Set).IntVar(&c.RequestMaxEntries.Value) + common.ResponseCondition(c.CmdClause, &c.ResponseCondition) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagServiceIDName, Description: cmd.FlagServiceIDDesc, @@ -71,20 +87,11 @@ func NewUpdateCommand(parent cmd.Registerer, globals *config.Data, data manifest Description: cmd.FlagServiceDesc, Dst: &c.ServiceName.Value, }) - c.CmdClause.Flag("new-name", "New name of the Elasticsearch logging object").Action(c.NewName.Set).StringVar(&c.NewName.Value) - c.CmdClause.Flag("index", `The name of the Elasticsearch index to send documents (logs) to. The index must follow the Elasticsearch index format rules (https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-create-index.html). We support strftime (http://man7.org/linux/man-pages/man3/strftime.3.html) interpolated variables inside braces prefixed with a pound symbol. For example, #{%F} will interpolate as YYYY-MM-DD with today's date`).Action(c.Index.Set).StringVar(&c.Index.Value) - c.CmdClause.Flag("url", "The URL to stream logs to. Must use HTTPS.").Action(c.URL.Set).StringVar(&c.URL.Value) - c.CmdClause.Flag("pipeline", "The ID of the Elasticsearch ingest pipeline to apply pre-process transformations to before indexing. For example my_pipeline_id. Learn more about creating a pipeline in the Elasticsearch docs (https://www.elastic.co/guide/en/elasticsearch/reference/current/ingest.html)").Action(c.Password.Set).StringVar(&c.Pipeline.Value) common.TLSCACert(c.CmdClause, &c.TLSCACert) common.TLSClientCert(c.CmdClause, &c.TLSClientCert) common.TLSClientKey(c.CmdClause, &c.TLSClientKey) common.TLSHostname(c.CmdClause, &c.TLSHostname) - common.Format(c.CmdClause, &c.Format) - common.FormatVersion(c.CmdClause, &c.FormatVersion) - common.Placement(c.CmdClause, &c.Placement) - common.ResponseCondition(c.CmdClause, &c.ResponseCondition) - c.CmdClause.Flag("request-max-entries", "Maximum number of logs to append to a batch, if non-zero. Defaults to 10k").Action(c.RequestMaxEntries.Set).IntVar(&c.RequestMaxEntries.Value) - c.CmdClause.Flag("request-max-bytes", "Maximum size of log batch, if non-zero. Defaults to 100MB").Action(c.RequestMaxBytes.Set).IntVar(&c.RequestMaxBytes.Value) + c.CmdClause.Flag("url", "The URL to stream logs to. Must use HTTPS.").Action(c.URL.Set).StringVar(&c.URL.Value) return &c } diff --git a/pkg/commands/logging/ftp/create.go b/pkg/commands/logging/ftp/create.go index 875b40f94..15ef7e147 100644 --- a/pkg/commands/logging/ftp/create.go +++ b/pkg/commands/logging/ftp/create.go @@ -42,24 +42,40 @@ type CreateCommand struct { // NewCreateCommand returns a usable command registered under the parent. func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *CreateCommand { - var c CreateCommand - c.Globals = globals - c.Manifest = data + c := CreateCommand{ + Base: cmd.Base{ + Globals: globals, + }, + Manifest: data, + } c.CmdClause = parent.Command("create", "Create an FTP logging endpoint on a Fastly service version").Alias("add") - c.CmdClause.Flag("name", "The name of the FTP logging object. Used as a primary key for API access").Short('n').Action(c.EndpointName.Set).StringVar(&c.EndpointName.Value) + + // required c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagVersionName, Description: cmd.FlagVersionDesc, Dst: &c.ServiceVersion.Value, Required: true, }) + + // optional c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ Action: c.AutoClone.Set, Dst: &c.AutoClone.Value, }) c.CmdClause.Flag("address", "An hostname or IPv4 address").Action(c.Address.Set).StringVar(&c.Address.Value) - c.CmdClause.Flag("user", "The username for the server (can be anonymous)").Action(c.Username.Set).StringVar(&c.Username.Value) + common.CompressionCodec(c.CmdClause, &c.CompressionCodec) + c.CmdClause.Flag("name", "The name of the FTP logging object. Used as a primary key for API access").Short('n').Action(c.EndpointName.Set).StringVar(&c.EndpointName.Value) + common.Format(c.CmdClause, &c.Format) + common.FormatVersion(c.CmdClause, &c.FormatVersion) + common.GzipLevel(c.CmdClause, &c.GzipLevel) c.CmdClause.Flag("password", "The password for the server (for anonymous use an email address)").Action(c.Password.Set).StringVar(&c.Password.Value) + c.CmdClause.Flag("path", "The path to upload log files to. If the path ends in / then it is treated as a directory").Action(c.Path.Set).StringVar(&c.Path.Value) + common.Period(c.CmdClause, &c.Period) + common.Placement(c.CmdClause, &c.Placement) + c.CmdClause.Flag("port", "The port number").Action(c.Port.Set).IntVar(&c.Port.Value) + common.ResponseCondition(c.CmdClause, &c.ResponseCondition) + common.TimestampFormat(c.CmdClause, &c.TimestampFormat) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagServiceIDName, Description: cmd.FlagServiceIDDesc, @@ -72,16 +88,7 @@ func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest Description: cmd.FlagServiceDesc, Dst: &c.ServiceName.Value, }) - c.CmdClause.Flag("port", "The port number").Action(c.Port.Set).IntVar(&c.Port.Value) - c.CmdClause.Flag("path", "The path to upload log files to. If the path ends in / then it is treated as a directory").Action(c.Path.Set).StringVar(&c.Path.Value) - common.Period(c.CmdClause, &c.Period) - common.GzipLevel(c.CmdClause, &c.GzipLevel) - common.Format(c.CmdClause, &c.Format) - common.FormatVersion(c.CmdClause, &c.FormatVersion) - common.ResponseCondition(c.CmdClause, &c.ResponseCondition) - common.TimestampFormat(c.CmdClause, &c.TimestampFormat) - common.Placement(c.CmdClause, &c.Placement) - common.CompressionCodec(c.CmdClause, &c.CompressionCodec) + c.CmdClause.Flag("user", "The username for the server (can be anonymous)").Action(c.Username.Set).StringVar(&c.Username.Value) return &c } diff --git a/pkg/commands/logging/ftp/delete.go b/pkg/commands/logging/ftp/delete.go index 60142f7d8..419ab0bb3 100644 --- a/pkg/commands/logging/ftp/delete.go +++ b/pkg/commands/logging/ftp/delete.go @@ -23,21 +23,28 @@ type DeleteCommand struct { // NewDeleteCommand returns a usable command registered under the parent. func NewDeleteCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *DeleteCommand { - var c DeleteCommand - c.Globals = globals - c.manifest = data + c := DeleteCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("delete", "Delete an FTP logging endpoint on a Fastly service version").Alias("remove") + + // required + c.CmdClause.Flag("name", "The name of the FTP logging object").Short('n').Required().StringVar(&c.Input.Name) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagVersionName, Description: cmd.FlagVersionDesc, Dst: &c.serviceVersion.Value, Required: true, }) + + // optional c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ Action: c.autoClone.Set, Dst: &c.autoClone.Value, }) - c.CmdClause.Flag("name", "The name of the FTP logging object").Short('n').Required().StringVar(&c.Input.Name) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagServiceIDName, Description: cmd.FlagServiceIDDesc, diff --git a/pkg/commands/logging/ftp/describe.go b/pkg/commands/logging/ftp/describe.go index daddcdefa..5a4269e34 100644 --- a/pkg/commands/logging/ftp/describe.go +++ b/pkg/commands/logging/ftp/describe.go @@ -25,9 +25,12 @@ type DescribeCommand struct { // NewDescribeCommand returns a usable command registered under the parent. func NewDescribeCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *DescribeCommand { - var c DescribeCommand - c.Globals = globals - c.manifest = data + c := DescribeCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("describe", "Show detailed information about an FTP logging endpoint on a Fastly service version").Alias("get") c.RegisterFlagBool(cmd.BoolFlagOpts{ Name: cmd.FlagJSONName, diff --git a/pkg/commands/logging/ftp/list.go b/pkg/commands/logging/ftp/list.go index ed9cd3330..9803ea0bb 100644 --- a/pkg/commands/logging/ftp/list.go +++ b/pkg/commands/logging/ftp/list.go @@ -25,10 +25,23 @@ type ListCommand struct { // NewListCommand returns a usable command registered under the parent. func NewListCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *ListCommand { - var c ListCommand - c.Globals = globals - c.manifest = data + c := ListCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("list", "List FTP endpoints on a Fastly service version") + + // required + c.RegisterFlag(cmd.StringFlagOpts{ + Name: cmd.FlagVersionName, + Description: cmd.FlagVersionDesc, + Dst: &c.serviceVersion.Value, + Required: true, + }) + + // optional c.RegisterFlagBool(cmd.BoolFlagOpts{ Name: cmd.FlagJSONName, Description: cmd.FlagJSONDesc, @@ -47,12 +60,6 @@ func NewListCommand(parent cmd.Registerer, globals *config.Data, data manifest.D Description: cmd.FlagServiceDesc, Dst: &c.serviceName.Value, }) - c.RegisterFlag(cmd.StringFlagOpts{ - Name: cmd.FlagVersionName, - Description: cmd.FlagVersionDesc, - Dst: &c.serviceVersion.Value, - Required: true, - }) return &c } diff --git a/pkg/commands/logging/ftp/update.go b/pkg/commands/logging/ftp/update.go index 7813a898b..6d8520367 100644 --- a/pkg/commands/logging/ftp/update.go +++ b/pkg/commands/logging/ftp/update.go @@ -43,21 +43,41 @@ type UpdateCommand struct { // NewUpdateCommand returns a usable command registered under the parent. func NewUpdateCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *UpdateCommand { - var c UpdateCommand - c.Globals = globals - c.Manifest = data + c := UpdateCommand{ + Base: cmd.Base{ + Globals: globals, + }, + Manifest: data, + } c.CmdClause = parent.Command("update", "Update an FTP logging endpoint on a Fastly service version") + + // required + c.CmdClause.Flag("name", "The name of the FTP logging object").Short('n').Required().StringVar(&c.EndpointName) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagVersionName, Description: cmd.FlagVersionDesc, Dst: &c.ServiceVersion.Value, Required: true, }) + + // optional + c.CmdClause.Flag("address", "An hostname or IPv4 address").Action(c.Address.Set).StringVar(&c.Address.Value) c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ Action: c.AutoClone.Set, Dst: &c.AutoClone.Value, }) - c.CmdClause.Flag("name", "The name of the FTP logging object").Short('n').Required().StringVar(&c.EndpointName) + common.CompressionCodec(c.CmdClause, &c.CompressionCodec) + common.Format(c.CmdClause, &c.Format) + common.FormatVersion(c.CmdClause, &c.FormatVersion) + common.GzipLevel(c.CmdClause, &c.GzipLevel) + c.CmdClause.Flag("new-name", "New name of the FTP logging object").Action(c.NewName.Set).StringVar(&c.NewName.Value) + c.CmdClause.Flag("password", "The password for the server (for anonymous use an email address)").Action(c.Password.Set).StringVar(&c.Password.Value) + c.CmdClause.Flag("path", "The path to upload log files to. If the path ends in / then it is treated as a directory").Action(c.Path.Set).StringVar(&c.Path.Value) + common.Period(c.CmdClause, &c.Period) + common.Placement(c.CmdClause, &c.Placement) + c.CmdClause.Flag("port", "The port number").Action(c.Port.Set).IntVar(&c.Port.Value) + common.PublicKey(c.CmdClause, &c.PublicKey) + common.ResponseCondition(c.CmdClause, &c.ResponseCondition) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagServiceIDName, Description: cmd.FlagServiceIDDesc, @@ -70,21 +90,8 @@ func NewUpdateCommand(parent cmd.Registerer, globals *config.Data, data manifest Description: cmd.FlagServiceDesc, Dst: &c.ServiceName.Value, }) - c.CmdClause.Flag("new-name", "New name of the FTP logging object").Action(c.NewName.Set).StringVar(&c.NewName.Value) - c.CmdClause.Flag("address", "An hostname or IPv4 address").Action(c.Address.Set).StringVar(&c.Address.Value) - c.CmdClause.Flag("port", "The port number").Action(c.Port.Set).IntVar(&c.Port.Value) - c.CmdClause.Flag("username", "The username for the server (can be anonymous)").Action(c.Username.Set).StringVar(&c.Username.Value) - c.CmdClause.Flag("password", "The password for the server (for anonymous use an email address)").Action(c.Password.Set).StringVar(&c.Password.Value) - common.PublicKey(c.CmdClause, &c.PublicKey) - c.CmdClause.Flag("path", "The path to upload log files to. If the path ends in / then it is treated as a directory").Action(c.Path.Set).StringVar(&c.Path.Value) - common.Period(c.CmdClause, &c.Period) - common.GzipLevel(c.CmdClause, &c.GzipLevel) - common.Format(c.CmdClause, &c.Format) - common.FormatVersion(c.CmdClause, &c.FormatVersion) - common.ResponseCondition(c.CmdClause, &c.ResponseCondition) common.TimestampFormat(c.CmdClause, &c.TimestampFormat) - common.Placement(c.CmdClause, &c.Placement) - common.CompressionCodec(c.CmdClause, &c.CompressionCodec) + c.CmdClause.Flag("username", "The username for the server (can be anonymous)").Action(c.Username.Set).StringVar(&c.Username.Value) return &c } diff --git a/pkg/commands/logging/gcs/create.go b/pkg/commands/logging/gcs/create.go index 9b78e927e..8fa55fcc5 100644 --- a/pkg/commands/logging/gcs/create.go +++ b/pkg/commands/logging/gcs/create.go @@ -43,10 +43,15 @@ type CreateCommand struct { // NewCreateCommand returns a usable command registered under the parent. func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *CreateCommand { - var c CreateCommand - c.Globals = globals - c.Manifest = data + c := CreateCommand{ + Base: cmd.Base{ + Globals: globals, + }, + Manifest: data, + } c.CmdClause = parent.Command("create", "Create a GCS logging endpoint on a Fastly service version").Alias("add") + + // required c.CmdClause.Flag("name", "The name of the GCS logging object. Used as a primary key for API access").Short('n').Action(c.EndpointName.Set).StringVar(&c.EndpointName.Value) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagVersionName, @@ -54,12 +59,23 @@ func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest Dst: &c.ServiceVersion.Value, Required: true, }) + + // optional + c.CmdClause.Flag("account-name", "The google account name used to obtain temporary credentials (default none)").Action(c.AccountName.Set).StringVar(&c.AccountName.Value) c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ Action: c.AutoClone.Set, Dst: &c.AutoClone.Value, }) - c.CmdClause.Flag("user", "Your GCS service account email address. The client_email field in your service account authentication JSON").Action(c.User.Set).StringVar(&c.User.Value) c.CmdClause.Flag("bucket", "The bucket of the GCS bucket").Action(c.Bucket.Set).StringVar(&c.Bucket.Value) + common.CompressionCodec(c.CmdClause, &c.CompressionCodec) + common.Format(c.CmdClause, &c.Format) + common.FormatVersion(c.CmdClause, &c.FormatVersion) + common.GzipLevel(c.CmdClause, &c.GzipLevel) + common.MessageType(c.CmdClause, &c.MessageType) + common.Path(c.CmdClause, &c.Path) + common.Period(c.CmdClause, &c.Period) + common.Placement(c.CmdClause, &c.Placement) + common.ResponseCondition(c.CmdClause, &c.ResponseCondition) c.CmdClause.Flag("secret-key", "Your GCS account secret key. The private_key field in your service account authentication JSON").Action(c.SecretKey.Set).StringVar(&c.SecretKey.Value) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagServiceIDName, @@ -73,17 +89,8 @@ func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest Description: cmd.FlagServiceDesc, Dst: &c.ServiceName.Value, }) - common.Period(c.CmdClause, &c.Period) - common.GzipLevel(c.CmdClause, &c.GzipLevel) - common.Path(c.CmdClause, &c.Path) - common.Format(c.CmdClause, &c.Format) - common.FormatVersion(c.CmdClause, &c.FormatVersion) - common.MessageType(c.CmdClause, &c.MessageType) - common.ResponseCondition(c.CmdClause, &c.ResponseCondition) common.TimestampFormat(c.CmdClause, &c.TimestampFormat) - common.Placement(c.CmdClause, &c.Placement) - common.CompressionCodec(c.CmdClause, &c.CompressionCodec) - c.CmdClause.Flag("account-name", "The google account name used to obtain temporary credentials (default none)").Action(c.AccountName.Set).StringVar(&c.AccountName.Value) + c.CmdClause.Flag("user", "Your GCS service account email address. The client_email field in your service account authentication JSON").Action(c.User.Set).StringVar(&c.User.Value) return &c } diff --git a/pkg/commands/logging/gcs/delete.go b/pkg/commands/logging/gcs/delete.go index 138e23de6..ddf648468 100644 --- a/pkg/commands/logging/gcs/delete.go +++ b/pkg/commands/logging/gcs/delete.go @@ -23,21 +23,28 @@ type DeleteCommand struct { // NewDeleteCommand returns a usable command registered under the parent. func NewDeleteCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *DeleteCommand { - var c DeleteCommand - c.Globals = globals - c.manifest = data + c := DeleteCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("delete", "Delete a GCS logging endpoint on a Fastly service version").Alias("remove") + + // required + c.CmdClause.Flag("name", "The name of the GCS logging object").Short('n').Required().StringVar(&c.Input.Name) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagVersionName, Description: cmd.FlagVersionDesc, Dst: &c.serviceVersion.Value, Required: true, }) + + // optional c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ Action: c.autoClone.Set, Dst: &c.autoClone.Value, }) - c.CmdClause.Flag("name", "The name of the GCS logging object").Short('n').Required().StringVar(&c.Input.Name) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagServiceIDName, Description: cmd.FlagServiceIDDesc, diff --git a/pkg/commands/logging/gcs/describe.go b/pkg/commands/logging/gcs/describe.go index 39d7a5198..edd791626 100644 --- a/pkg/commands/logging/gcs/describe.go +++ b/pkg/commands/logging/gcs/describe.go @@ -25,10 +25,24 @@ type DescribeCommand struct { // NewDescribeCommand returns a usable command registered under the parent. func NewDescribeCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *DescribeCommand { - var c DescribeCommand - c.Globals = globals - c.manifest = data + c := DescribeCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("describe", "Show detailed information about a GCS logging endpoint on a Fastly service version").Alias("get") + + // required + c.CmdClause.Flag("name", "The name of the GCS logging object").Short('n').Required().StringVar(&c.Input.Name) + c.RegisterFlag(cmd.StringFlagOpts{ + Name: cmd.FlagVersionName, + Description: cmd.FlagVersionDesc, + Dst: &c.serviceVersion.Value, + Required: true, + }) + + // optional c.RegisterFlagBool(cmd.BoolFlagOpts{ Name: cmd.FlagJSONName, Description: cmd.FlagJSONDesc, @@ -47,13 +61,6 @@ func NewDescribeCommand(parent cmd.Registerer, globals *config.Data, data manife Description: cmd.FlagServiceDesc, Dst: &c.serviceName.Value, }) - c.RegisterFlag(cmd.StringFlagOpts{ - Name: cmd.FlagVersionName, - Description: cmd.FlagVersionDesc, - Dst: &c.serviceVersion.Value, - Required: true, - }) - c.CmdClause.Flag("name", "The name of the GCS logging object").Short('n').Required().StringVar(&c.Input.Name) return &c } diff --git a/pkg/commands/logging/gcs/list.go b/pkg/commands/logging/gcs/list.go index 6485f3351..a57ab42ab 100644 --- a/pkg/commands/logging/gcs/list.go +++ b/pkg/commands/logging/gcs/list.go @@ -25,10 +25,23 @@ type ListCommand struct { // NewListCommand returns a usable command registered under the parent. func NewListCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *ListCommand { - var c ListCommand - c.Globals = globals - c.manifest = data + c := ListCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("list", "List GCS endpoints on a Fastly service version") + + // required + c.RegisterFlag(cmd.StringFlagOpts{ + Name: cmd.FlagVersionName, + Description: cmd.FlagVersionDesc, + Dst: &c.serviceVersion.Value, + Required: true, + }) + + // optional c.RegisterFlagBool(cmd.BoolFlagOpts{ Name: cmd.FlagJSONName, Description: cmd.FlagJSONDesc, @@ -47,12 +60,6 @@ func NewListCommand(parent cmd.Registerer, globals *config.Data, data manifest.D Description: cmd.FlagServiceDesc, Dst: &c.serviceName.Value, }) - c.RegisterFlag(cmd.StringFlagOpts{ - Name: cmd.FlagVersionName, - Description: cmd.FlagVersionDesc, - Dst: &c.serviceVersion.Value, - Required: true, - }) return &c } diff --git a/pkg/commands/logging/gcs/update.go b/pkg/commands/logging/gcs/update.go index d2f286e9e..f350e07e2 100644 --- a/pkg/commands/logging/gcs/update.go +++ b/pkg/commands/logging/gcs/update.go @@ -43,21 +43,41 @@ type UpdateCommand struct { // NewUpdateCommand returns a usable command registered under the parent. func NewUpdateCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *UpdateCommand { - var c UpdateCommand - c.Globals = globals - c.Manifest = data + c := UpdateCommand{ + Base: cmd.Base{ + Globals: globals, + }, + Manifest: data, + } c.CmdClause = parent.Command("update", "Update a GCS logging endpoint on a Fastly service version") + + // required + c.CmdClause.Flag("name", "The name of the GCS logging object").Short('n').Required().StringVar(&c.EndpointName) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagVersionName, Description: cmd.FlagVersionDesc, Dst: &c.ServiceVersion.Value, Required: true, }) + + // optional c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ Action: c.AutoClone.Set, Dst: &c.AutoClone.Value, }) - c.CmdClause.Flag("name", "The name of the GCS logging object").Short('n').Required().StringVar(&c.EndpointName) + c.CmdClause.Flag("account-name", "The google account name used to obtain temporary credentials").Action(c.AccountName.Set).StringVar(&c.AccountName.Value) + c.CmdClause.Flag("bucket", "The bucket of the GCS bucket").Action(c.Bucket.Set).StringVar(&c.Bucket.Value) + common.CompressionCodec(c.CmdClause, &c.CompressionCodec) + common.Format(c.CmdClause, &c.Format) + common.FormatVersion(c.CmdClause, &c.FormatVersion) + common.GzipLevel(c.CmdClause, &c.GzipLevel) + common.MessageType(c.CmdClause, &c.MessageType) + c.CmdClause.Flag("new-name", "New name of the GCS logging object").Action(c.NewName.Set).StringVar(&c.NewName.Value) + c.CmdClause.Flag("path", "The path to upload logs to (default '/')").Action(c.Path.Set).StringVar(&c.Path.Value) + common.Period(c.CmdClause, &c.Period) + common.Placement(c.CmdClause, &c.Placement) + common.ResponseCondition(c.CmdClause, &c.ResponseCondition) + c.CmdClause.Flag("secret-key", "Your GCS account secret key. The private_key field in your service account authentication JSON").Action(c.SecretKey.Set).StringVar(&c.SecretKey.Value) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagServiceIDName, Description: cmd.FlagServiceIDDesc, @@ -70,21 +90,8 @@ func NewUpdateCommand(parent cmd.Registerer, globals *config.Data, data manifest Description: cmd.FlagServiceDesc, Dst: &c.ServiceName.Value, }) - c.CmdClause.Flag("new-name", "New name of the GCS logging object").Action(c.NewName.Set).StringVar(&c.NewName.Value) - c.CmdClause.Flag("bucket", "The bucket of the GCS bucket").Action(c.Bucket.Set).StringVar(&c.Bucket.Value) c.CmdClause.Flag("user", "Your GCS service account email address. The client_email field in your service account authentication JSON").Action(c.User.Set).StringVar(&c.User.Value) - c.CmdClause.Flag("account-name", "The google account name used to obtain temporary credentials").Action(c.AccountName.Set).StringVar(&c.AccountName.Value) - c.CmdClause.Flag("secret-key", "Your GCS account secret key. The private_key field in your service account authentication JSON").Action(c.SecretKey.Set).StringVar(&c.SecretKey.Value) - c.CmdClause.Flag("path", "The path to upload logs to (default '/')").Action(c.Path.Set).StringVar(&c.Path.Value) - common.Period(c.CmdClause, &c.Period) - common.FormatVersion(c.CmdClause, &c.FormatVersion) - common.GzipLevel(c.CmdClause, &c.GzipLevel) - common.Format(c.CmdClause, &c.Format) - common.ResponseCondition(c.CmdClause, &c.ResponseCondition) common.TimestampFormat(c.CmdClause, &c.TimestampFormat) - common.MessageType(c.CmdClause, &c.MessageType) - common.Placement(c.CmdClause, &c.Placement) - common.CompressionCodec(c.CmdClause, &c.CompressionCodec) return &c } diff --git a/pkg/commands/logging/googlepubsub/create.go b/pkg/commands/logging/googlepubsub/create.go index 2719744a2..373c60bf9 100644 --- a/pkg/commands/logging/googlepubsub/create.go +++ b/pkg/commands/logging/googlepubsub/create.go @@ -36,10 +36,15 @@ type CreateCommand struct { // NewCreateCommand returns a usable command registered under the parent. func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *CreateCommand { - var c CreateCommand - c.Globals = globals - c.Manifest = data + c := CreateCommand{ + Base: cmd.Base{ + Globals: globals, + }, + Manifest: data, + } c.CmdClause = parent.Command("create", "Create a Google Cloud Pub/Sub logging endpoint on a Fastly service version").Alias("add") + + // required c.CmdClause.Flag("name", "The name of the Google Cloud Pub/Sub logging object. Used as a primary key for API access").Short('n').Action(c.EndpointName.Set).StringVar(&c.EndpointName.Value) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagVersionName, @@ -47,14 +52,18 @@ func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest Dst: &c.ServiceVersion.Value, Required: true, }) + + // optional c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ Action: c.AutoClone.Set, Dst: &c.AutoClone.Value, }) - c.CmdClause.Flag("user", "Your Google Cloud Platform service account email address. The client_email field in your service account authentication JSON").Action(c.User.Set).StringVar(&c.User.Value) - c.CmdClause.Flag("secret-key", "Your Google Cloud Platform account secret key. The private_key field in your service account authentication JSON").Action(c.SecretKey.Set).StringVar(&c.SecretKey.Value) - c.CmdClause.Flag("topic", "The Google Cloud Pub/Sub topic to which logs will be published").Action(c.Topic.Set).StringVar(&c.Topic.Value) + common.Format(c.CmdClause, &c.Format) + common.FormatVersion(c.CmdClause, &c.FormatVersion) + common.Placement(c.CmdClause, &c.Placement) c.CmdClause.Flag("project-id", "The ID of your Google Cloud Platform project").Action(c.ProjectID.Set).StringVar(&c.ProjectID.Value) + common.ResponseCondition(c.CmdClause, &c.ResponseCondition) + c.CmdClause.Flag("secret-key", "Your Google Cloud Platform account secret key. The private_key field in your service account authentication JSON").Action(c.SecretKey.Set).StringVar(&c.SecretKey.Value) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagServiceIDName, Description: cmd.FlagServiceIDDesc, @@ -67,10 +76,8 @@ func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest Description: cmd.FlagServiceDesc, Dst: &c.ServiceName.Value, }) - common.Format(c.CmdClause, &c.Format) - common.FormatVersion(c.CmdClause, &c.FormatVersion) - common.Placement(c.CmdClause, &c.Placement) - common.ResponseCondition(c.CmdClause, &c.ResponseCondition) + c.CmdClause.Flag("topic", "The Google Cloud Pub/Sub topic to which logs will be published").Action(c.Topic.Set).StringVar(&c.Topic.Value) + c.CmdClause.Flag("user", "Your Google Cloud Platform service account email address. The client_email field in your service account authentication JSON").Action(c.User.Set).StringVar(&c.User.Value) return &c } diff --git a/pkg/commands/logging/googlepubsub/delete.go b/pkg/commands/logging/googlepubsub/delete.go index e166d4c73..c08efe4fd 100644 --- a/pkg/commands/logging/googlepubsub/delete.go +++ b/pkg/commands/logging/googlepubsub/delete.go @@ -23,21 +23,28 @@ type DeleteCommand struct { // NewDeleteCommand returns a usable command registered under the parent. func NewDeleteCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *DeleteCommand { - var c DeleteCommand - c.Globals = globals - c.manifest = data + c := DeleteCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("delete", "Delete a Google Cloud Pub/Sub logging endpoint on a Fastly service version").Alias("remove") + + // required + c.CmdClause.Flag("name", "The name of the Google Cloud Pub/Sub logging object").Short('n').Required().StringVar(&c.Input.Name) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagVersionName, Description: cmd.FlagVersionDesc, Dst: &c.serviceVersion.Value, Required: true, }) + + // optional c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ Action: c.autoClone.Set, Dst: &c.autoClone.Value, }) - c.CmdClause.Flag("name", "The name of the Google Cloud Pub/Sub logging object").Short('n').Required().StringVar(&c.Input.Name) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagServiceIDName, Description: cmd.FlagServiceIDDesc, diff --git a/pkg/commands/logging/googlepubsub/describe.go b/pkg/commands/logging/googlepubsub/describe.go index 8ffb5370e..212abdcf9 100644 --- a/pkg/commands/logging/googlepubsub/describe.go +++ b/pkg/commands/logging/googlepubsub/describe.go @@ -25,10 +25,24 @@ type DescribeCommand struct { // NewDescribeCommand returns a usable command registered under the parent. func NewDescribeCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *DescribeCommand { - var c DescribeCommand - c.Globals = globals - c.manifest = data + c := DescribeCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("describe", "Show detailed information about a Google Cloud Pub/Sub logging endpoint on a Fastly service version").Alias("get") + + // required + c.CmdClause.Flag("name", "The name of the Google Cloud Pub/Sub logging object").Short('n').Required().StringVar(&c.Input.Name) + c.RegisterFlag(cmd.StringFlagOpts{ + Name: cmd.FlagVersionName, + Description: cmd.FlagVersionDesc, + Dst: &c.serviceVersion.Value, + Required: true, + }) + + // optional c.RegisterFlagBool(cmd.BoolFlagOpts{ Name: cmd.FlagJSONName, Description: cmd.FlagJSONDesc, @@ -47,13 +61,6 @@ func NewDescribeCommand(parent cmd.Registerer, globals *config.Data, data manife Description: cmd.FlagServiceDesc, Dst: &c.serviceName.Value, }) - c.RegisterFlag(cmd.StringFlagOpts{ - Name: cmd.FlagVersionName, - Description: cmd.FlagVersionDesc, - Dst: &c.serviceVersion.Value, - Required: true, - }) - c.CmdClause.Flag("name", "The name of the Google Cloud Pub/Sub logging object").Short('n').Required().StringVar(&c.Input.Name) return &c } diff --git a/pkg/commands/logging/googlepubsub/list.go b/pkg/commands/logging/googlepubsub/list.go index e1abbc219..a82be50a0 100644 --- a/pkg/commands/logging/googlepubsub/list.go +++ b/pkg/commands/logging/googlepubsub/list.go @@ -25,10 +25,23 @@ type ListCommand struct { // NewListCommand returns a usable command registered under the parent. func NewListCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *ListCommand { - var c ListCommand - c.Globals = globals - c.manifest = data + c := ListCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("list", "List Google Cloud Pub/Sub endpoints on a Fastly service version") + + // required + c.RegisterFlag(cmd.StringFlagOpts{ + Name: cmd.FlagVersionName, + Description: cmd.FlagVersionDesc, + Dst: &c.serviceVersion.Value, + Required: true, + }) + + // optional c.RegisterFlagBool(cmd.BoolFlagOpts{ Name: cmd.FlagJSONName, Description: cmd.FlagJSONDesc, @@ -47,12 +60,6 @@ func NewListCommand(parent cmd.Registerer, globals *config.Data, data manifest.D Description: cmd.FlagServiceDesc, Dst: &c.serviceName.Value, }) - c.RegisterFlag(cmd.StringFlagOpts{ - Name: cmd.FlagVersionName, - Description: cmd.FlagVersionDesc, - Dst: &c.serviceVersion.Value, - Required: true, - }) return &c } diff --git a/pkg/commands/logging/googlepubsub/update.go b/pkg/commands/logging/googlepubsub/update.go index 5b82ba003..12c6cc415 100644 --- a/pkg/commands/logging/googlepubsub/update.go +++ b/pkg/commands/logging/googlepubsub/update.go @@ -37,21 +37,35 @@ type UpdateCommand struct { // NewUpdateCommand returns a usable command registered under the parent. func NewUpdateCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *UpdateCommand { - var c UpdateCommand - c.Globals = globals - c.Manifest = data + c := UpdateCommand{ + Base: cmd.Base{ + Globals: globals, + }, + Manifest: data, + } c.CmdClause = parent.Command("update", "Update a Google Cloud Pub/Sub logging endpoint on a Fastly service version") + + // required + c.CmdClause.Flag("name", "The name of the Google Cloud Pub/Sub logging object").Short('n').Required().StringVar(&c.EndpointName) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagVersionName, Description: cmd.FlagVersionDesc, Dst: &c.ServiceVersion.Value, Required: true, }) + + // optional c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ Action: c.AutoClone.Set, Dst: &c.AutoClone.Value, }) - c.CmdClause.Flag("name", "The name of the Google Cloud Pub/Sub logging object").Short('n').Required().StringVar(&c.EndpointName) + common.Format(c.CmdClause, &c.Format) + common.FormatVersion(c.CmdClause, &c.FormatVersion) + c.CmdClause.Flag("new-name", "New name of the Google Cloud Pub/Sub logging object").Action(c.NewName.Set).StringVar(&c.NewName.Value) + common.Placement(c.CmdClause, &c.Placement) + c.CmdClause.Flag("project-id", "The ID of your Google Cloud Platform project").Action(c.ProjectID.Set).StringVar(&c.ProjectID.Value) + c.CmdClause.Flag("secret-key", "Your Google Cloud Platform account secret key. The private_key field in your service account authentication JSON").Action(c.SecretKey.Set).StringVar(&c.SecretKey.Value) + common.ResponseCondition(c.CmdClause, &c.ResponseCondition) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagServiceIDName, Description: cmd.FlagServiceIDDesc, @@ -64,15 +78,8 @@ func NewUpdateCommand(parent cmd.Registerer, globals *config.Data, data manifest Description: cmd.FlagServiceDesc, Dst: &c.ServiceName.Value, }) - c.CmdClause.Flag("new-name", "New name of the Google Cloud Pub/Sub logging object").Action(c.NewName.Set).StringVar(&c.NewName.Value) - c.CmdClause.Flag("user", "Your Google Cloud Platform service account email address. The client_email field in your service account authentication JSON").Action(c.User.Set).StringVar(&c.User.Value) - c.CmdClause.Flag("secret-key", "Your Google Cloud Platform account secret key. The private_key field in your service account authentication JSON").Action(c.SecretKey.Set).StringVar(&c.SecretKey.Value) c.CmdClause.Flag("topic", "The Google Cloud Pub/Sub topic to which logs will be published").Action(c.Topic.Set).StringVar(&c.Topic.Value) - c.CmdClause.Flag("project-id", "The ID of your Google Cloud Platform project").Action(c.ProjectID.Set).StringVar(&c.ProjectID.Value) - common.Format(c.CmdClause, &c.Format) - common.FormatVersion(c.CmdClause, &c.FormatVersion) - common.Placement(c.CmdClause, &c.Placement) - common.ResponseCondition(c.CmdClause, &c.ResponseCondition) + c.CmdClause.Flag("user", "Your Google Cloud Platform service account email address. The client_email field in your service account authentication JSON").Action(c.User.Set).StringVar(&c.User.Value) return &c } diff --git a/pkg/commands/logging/heroku/create.go b/pkg/commands/logging/heroku/create.go index 471d22cc7..568787dd0 100644 --- a/pkg/commands/logging/heroku/create.go +++ b/pkg/commands/logging/heroku/create.go @@ -34,10 +34,15 @@ type CreateCommand struct { // NewCreateCommand returns a usable command registered under the parent. func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *CreateCommand { - var c CreateCommand - c.Globals = globals - c.Manifest = data + c := CreateCommand{ + Base: cmd.Base{ + Globals: globals, + }, + Manifest: data, + } c.CmdClause = parent.Command("create", "Create a Heroku logging endpoint on a Fastly service version").Alias("add") + + // required c.CmdClause.Flag("name", "The name of the Heroku logging object. Used as a primary key for API access").Short('n').Action(c.EndpointName.Set).StringVar(&c.EndpointName.Value) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagVersionName, @@ -45,12 +50,17 @@ func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest Dst: &c.ServiceVersion.Value, Required: true, }) + + // optional + c.CmdClause.Flag("auth-token", "The token to use for authentication (https://devcenter.heroku.com/articles/add-on-partner-log-integration)").Action(c.Token.Set).StringVar(&c.Token.Value) c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ Action: c.AutoClone.Set, Dst: &c.AutoClone.Value, }) - c.CmdClause.Flag("url", "The url to stream logs to").Action(c.URL.Set).StringVar(&c.URL.Value) - c.CmdClause.Flag("auth-token", "The token to use for authentication (https://devcenter.heroku.com/articles/add-on-partner-log-integration)").Action(c.Token.Set).StringVar(&c.Token.Value) + common.Format(c.CmdClause, &c.Format) + common.FormatVersion(c.CmdClause, &c.FormatVersion) + common.Placement(c.CmdClause, &c.Placement) + common.ResponseCondition(c.CmdClause, &c.ResponseCondition) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagServiceIDName, Description: cmd.FlagServiceIDDesc, @@ -63,10 +73,7 @@ func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest Description: cmd.FlagServiceDesc, Dst: &c.ServiceName.Value, }) - common.Format(c.CmdClause, &c.Format) - common.FormatVersion(c.CmdClause, &c.FormatVersion) - common.ResponseCondition(c.CmdClause, &c.ResponseCondition) - common.Placement(c.CmdClause, &c.Placement) + c.CmdClause.Flag("url", "The url to stream logs to").Action(c.URL.Set).StringVar(&c.URL.Value) return &c } diff --git a/pkg/commands/logging/heroku/delete.go b/pkg/commands/logging/heroku/delete.go index 24a778190..c48b1b185 100644 --- a/pkg/commands/logging/heroku/delete.go +++ b/pkg/commands/logging/heroku/delete.go @@ -23,21 +23,28 @@ type DeleteCommand struct { // NewDeleteCommand returns a usable command registered under the parent. func NewDeleteCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *DeleteCommand { - var c DeleteCommand - c.Globals = globals - c.manifest = data + c := DeleteCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("delete", "Delete a Heroku logging endpoint on a Fastly service version").Alias("remove") + + // required + c.CmdClause.Flag("name", "The name of the Heroku logging object").Short('n').Required().StringVar(&c.Input.Name) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagVersionName, Description: cmd.FlagVersionDesc, Dst: &c.serviceVersion.Value, Required: true, }) + + // optional c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ Action: c.autoClone.Set, Dst: &c.autoClone.Value, }) - c.CmdClause.Flag("name", "The name of the Heroku logging object").Short('n').Required().StringVar(&c.Input.Name) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagServiceIDName, Description: cmd.FlagServiceIDDesc, diff --git a/pkg/commands/logging/heroku/describe.go b/pkg/commands/logging/heroku/describe.go index fb7abbd09..8a3a18269 100644 --- a/pkg/commands/logging/heroku/describe.go +++ b/pkg/commands/logging/heroku/describe.go @@ -25,10 +25,24 @@ type DescribeCommand struct { // NewDescribeCommand returns a usable command registered under the parent. func NewDescribeCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *DescribeCommand { - var c DescribeCommand - c.Globals = globals - c.manifest = data + c := DescribeCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("describe", "Show detailed information about a Heroku logging endpoint on a Fastly service version").Alias("get") + + // required + c.CmdClause.Flag("name", "The name of the Heroku logging object").Short('n').Required().StringVar(&c.Input.Name) + c.RegisterFlag(cmd.StringFlagOpts{ + Name: cmd.FlagVersionName, + Description: cmd.FlagVersionDesc, + Dst: &c.serviceVersion.Value, + Required: true, + }) + + // optional c.RegisterFlagBool(cmd.BoolFlagOpts{ Name: cmd.FlagJSONName, Description: cmd.FlagJSONDesc, @@ -47,13 +61,6 @@ func NewDescribeCommand(parent cmd.Registerer, globals *config.Data, data manife Description: cmd.FlagServiceDesc, Dst: &c.serviceName.Value, }) - c.RegisterFlag(cmd.StringFlagOpts{ - Name: cmd.FlagVersionName, - Description: cmd.FlagVersionDesc, - Dst: &c.serviceVersion.Value, - Required: true, - }) - c.CmdClause.Flag("name", "The name of the Heroku logging object").Short('n').Required().StringVar(&c.Input.Name) return &c } diff --git a/pkg/commands/logging/heroku/list.go b/pkg/commands/logging/heroku/list.go index f77195390..2d7e59ac2 100644 --- a/pkg/commands/logging/heroku/list.go +++ b/pkg/commands/logging/heroku/list.go @@ -25,10 +25,23 @@ type ListCommand struct { // NewListCommand returns a usable command registered under the parent. func NewListCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *ListCommand { - var c ListCommand - c.Globals = globals - c.manifest = data + c := ListCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("list", "List Heroku endpoints on a Fastly service version") + + // required + c.RegisterFlag(cmd.StringFlagOpts{ + Name: cmd.FlagVersionName, + Description: cmd.FlagVersionDesc, + Dst: &c.serviceVersion.Value, + Required: true, + }) + + // optional c.RegisterFlagBool(cmd.BoolFlagOpts{ Name: cmd.FlagJSONName, Description: cmd.FlagJSONDesc, @@ -47,12 +60,6 @@ func NewListCommand(parent cmd.Registerer, globals *config.Data, data manifest.D Description: cmd.FlagServiceDesc, Dst: &c.serviceName.Value, }) - c.RegisterFlag(cmd.StringFlagOpts{ - Name: cmd.FlagVersionName, - Description: cmd.FlagVersionDesc, - Dst: &c.serviceVersion.Value, - Required: true, - }) return &c } diff --git a/pkg/commands/logging/heroku/update.go b/pkg/commands/logging/heroku/update.go index 4a0a7a6b9..dd0ca8d3b 100644 --- a/pkg/commands/logging/heroku/update.go +++ b/pkg/commands/logging/heroku/update.go @@ -35,21 +35,34 @@ type UpdateCommand struct { // NewUpdateCommand returns a usable command registered under the parent. func NewUpdateCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *UpdateCommand { - var c UpdateCommand - c.Globals = globals - c.Manifest = data + c := UpdateCommand{ + Base: cmd.Base{ + Globals: globals, + }, + Manifest: data, + } c.CmdClause = parent.Command("update", "Update a Heroku logging endpoint on a Fastly service version") + + // required + c.CmdClause.Flag("name", "The name of the Heroku logging object").Short('n').Required().StringVar(&c.EndpointName) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagVersionName, Description: cmd.FlagVersionDesc, Dst: &c.ServiceVersion.Value, Required: true, }) + + // optional + c.CmdClause.Flag("auth-token", "The token to use for authentication (https://devcenter.heroku.com/articles/add-on-partner-log-integration)").Action(c.Token.Set).StringVar(&c.Token.Value) c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ Action: c.AutoClone.Set, Dst: &c.AutoClone.Value, }) - c.CmdClause.Flag("name", "The name of the Heroku logging object").Short('n').Required().StringVar(&c.EndpointName) + common.Format(c.CmdClause, &c.Format) + common.FormatVersion(c.CmdClause, &c.FormatVersion) + c.CmdClause.Flag("new-name", "New name of the Heroku logging object").Action(c.NewName.Set).StringVar(&c.NewName.Value) + common.Placement(c.CmdClause, &c.Placement) + common.ResponseCondition(c.CmdClause, &c.ResponseCondition) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagServiceIDName, Description: cmd.FlagServiceIDDesc, @@ -62,13 +75,7 @@ func NewUpdateCommand(parent cmd.Registerer, globals *config.Data, data manifest Description: cmd.FlagServiceDesc, Dst: &c.ServiceName.Value, }) - c.CmdClause.Flag("new-name", "New name of the Heroku logging object").Action(c.NewName.Set).StringVar(&c.NewName.Value) - common.Format(c.CmdClause, &c.Format) - common.FormatVersion(c.CmdClause, &c.FormatVersion) c.CmdClause.Flag("url", "The url to stream logs to").Action(c.URL.Set).StringVar(&c.URL.Value) - c.CmdClause.Flag("auth-token", "The token to use for authentication (https://devcenter.heroku.com/articles/add-on-partner-log-integration)").Action(c.Token.Set).StringVar(&c.Token.Value) - common.ResponseCondition(c.CmdClause, &c.ResponseCondition) - common.Placement(c.CmdClause, &c.Placement) return &c } diff --git a/pkg/commands/logging/honeycomb/create.go b/pkg/commands/logging/honeycomb/create.go index 740b23139..ab72f8971 100644 --- a/pkg/commands/logging/honeycomb/create.go +++ b/pkg/commands/logging/honeycomb/create.go @@ -34,10 +34,15 @@ type CreateCommand struct { // NewCreateCommand returns a usable command registered under the parent. func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *CreateCommand { - var c CreateCommand - c.Globals = globals - c.Manifest = data + c := CreateCommand{ + Base: cmd.Base{ + Globals: globals, + }, + Manifest: data, + } c.CmdClause = parent.Command("create", "Create a Honeycomb logging endpoint on a Fastly service version").Alias("add") + + // required c.CmdClause.Flag("name", "The name of the Honeycomb logging object. Used as a primary key for API access").Short('n').Action(c.EndpointName.Set).StringVar(&c.EndpointName.Value) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagVersionName, @@ -45,12 +50,18 @@ func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest Dst: &c.ServiceVersion.Value, Required: true, }) + + // optional + c.CmdClause.Flag("auth-token", "The Write Key from the Account page of your Honeycomb account").Action(c.Token.Set).StringVar(&c.Token.Value) c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ Action: c.AutoClone.Set, Dst: &c.AutoClone.Value, }) c.CmdClause.Flag("dataset", "The Honeycomb Dataset you want to log to").Action(c.Dataset.Set).StringVar(&c.Dataset.Value) - c.CmdClause.Flag("auth-token", "The Write Key from the Account page of your Honeycomb account").Action(c.Token.Set).StringVar(&c.Token.Value) + common.Format(c.CmdClause, &c.Format) + common.FormatVersion(c.CmdClause, &c.FormatVersion) + common.ResponseCondition(c.CmdClause, &c.ResponseCondition) + common.Placement(c.CmdClause, &c.Placement) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagServiceIDName, Description: cmd.FlagServiceIDDesc, @@ -63,10 +74,6 @@ func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest Description: cmd.FlagServiceDesc, Dst: &c.ServiceName.Value, }) - common.Format(c.CmdClause, &c.Format) - common.FormatVersion(c.CmdClause, &c.FormatVersion) - common.ResponseCondition(c.CmdClause, &c.ResponseCondition) - common.Placement(c.CmdClause, &c.Placement) return &c } diff --git a/pkg/commands/logging/honeycomb/delete.go b/pkg/commands/logging/honeycomb/delete.go index 5e8348797..16074855a 100644 --- a/pkg/commands/logging/honeycomb/delete.go +++ b/pkg/commands/logging/honeycomb/delete.go @@ -23,21 +23,28 @@ type DeleteCommand struct { // NewDeleteCommand returns a usable command registered under the parent. func NewDeleteCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *DeleteCommand { - var c DeleteCommand - c.Globals = globals - c.manifest = data + c := DeleteCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("delete", "Delete a Honeycomb logging endpoint on a Fastly service version").Alias("remove") + + // required + c.CmdClause.Flag("name", "The name of the Honeycomb logging object").Short('n').Required().StringVar(&c.Input.Name) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagVersionName, Description: cmd.FlagVersionDesc, Dst: &c.serviceVersion.Value, Required: true, }) + + // optional c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ Action: c.autoClone.Set, Dst: &c.autoClone.Value, }) - c.CmdClause.Flag("name", "The name of the Honeycomb logging object").Short('n').Required().StringVar(&c.Input.Name) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagServiceIDName, Description: cmd.FlagServiceIDDesc, diff --git a/pkg/commands/logging/honeycomb/describe.go b/pkg/commands/logging/honeycomb/describe.go index 6421064b3..0b570dca7 100644 --- a/pkg/commands/logging/honeycomb/describe.go +++ b/pkg/commands/logging/honeycomb/describe.go @@ -25,10 +25,24 @@ type DescribeCommand struct { // NewDescribeCommand returns a usable command registered under the parent. func NewDescribeCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *DescribeCommand { - var c DescribeCommand - c.Globals = globals - c.manifest = data + c := DescribeCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("describe", "Show detailed information about a Honeycomb logging endpoint on a Fastly service version").Alias("get") + + // required + c.CmdClause.Flag("name", "The name of the Honeycomb logging object").Short('n').Required().StringVar(&c.Input.Name) + c.RegisterFlag(cmd.StringFlagOpts{ + Name: cmd.FlagVersionName, + Description: cmd.FlagVersionDesc, + Dst: &c.serviceVersion.Value, + Required: true, + }) + + // optional c.RegisterFlagBool(cmd.BoolFlagOpts{ Name: cmd.FlagJSONName, Description: cmd.FlagJSONDesc, @@ -47,13 +61,6 @@ func NewDescribeCommand(parent cmd.Registerer, globals *config.Data, data manife Description: cmd.FlagServiceDesc, Dst: &c.serviceName.Value, }) - c.RegisterFlag(cmd.StringFlagOpts{ - Name: cmd.FlagVersionName, - Description: cmd.FlagVersionDesc, - Dst: &c.serviceVersion.Value, - Required: true, - }) - c.CmdClause.Flag("name", "The name of the Honeycomb logging object").Short('n').Required().StringVar(&c.Input.Name) return &c } diff --git a/pkg/commands/logging/honeycomb/list.go b/pkg/commands/logging/honeycomb/list.go index 0b8df6ee6..9c1a85053 100644 --- a/pkg/commands/logging/honeycomb/list.go +++ b/pkg/commands/logging/honeycomb/list.go @@ -25,10 +25,23 @@ type ListCommand struct { // NewListCommand returns a usable command registered under the parent. func NewListCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *ListCommand { - var c ListCommand - c.Globals = globals - c.manifest = data + c := ListCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("list", "List Honeycomb endpoints on a Fastly service version") + + // required + c.RegisterFlag(cmd.StringFlagOpts{ + Name: cmd.FlagVersionName, + Description: cmd.FlagVersionDesc, + Dst: &c.serviceVersion.Value, + Required: true, + }) + + // optional c.RegisterFlagBool(cmd.BoolFlagOpts{ Name: cmd.FlagJSONName, Description: cmd.FlagJSONDesc, @@ -47,12 +60,6 @@ func NewListCommand(parent cmd.Registerer, globals *config.Data, data manifest.D Description: cmd.FlagServiceDesc, Dst: &c.serviceName.Value, }) - c.RegisterFlag(cmd.StringFlagOpts{ - Name: cmd.FlagVersionName, - Description: cmd.FlagVersionDesc, - Dst: &c.serviceVersion.Value, - Required: true, - }) return &c } diff --git a/pkg/commands/logging/honeycomb/update.go b/pkg/commands/logging/honeycomb/update.go index de2115167..240e06ddf 100644 --- a/pkg/commands/logging/honeycomb/update.go +++ b/pkg/commands/logging/honeycomb/update.go @@ -35,21 +35,35 @@ type UpdateCommand struct { // NewUpdateCommand returns a usable command registered under the parent. func NewUpdateCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *UpdateCommand { - var c UpdateCommand - c.Globals = globals - c.Manifest = data + c := UpdateCommand{ + Base: cmd.Base{ + Globals: globals, + }, + Manifest: data, + } c.CmdClause = parent.Command("update", "Update a Honeycomb logging endpoint on a Fastly service version") + + // required + c.CmdClause.Flag("name", "The name of the Honeycomb logging object").Short('n').Required().StringVar(&c.EndpointName) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagVersionName, Description: cmd.FlagVersionDesc, Dst: &c.ServiceVersion.Value, Required: true, }) + + // optional + c.CmdClause.Flag("auth-token", "The Write Key from the Account page of your Honeycomb account").Action(c.Token.Set).StringVar(&c.Token.Value) c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ Action: c.AutoClone.Set, Dst: &c.AutoClone.Value, }) - c.CmdClause.Flag("name", "The name of the Honeycomb logging object").Short('n').Required().StringVar(&c.EndpointName) + c.CmdClause.Flag("dataset", "The Honeycomb Dataset you want to log to").Action(c.Dataset.Set).StringVar(&c.Dataset.Value) + common.Format(c.CmdClause, &c.Format) + common.FormatVersion(c.CmdClause, &c.FormatVersion) + c.CmdClause.Flag("new-name", "New name of the Honeycomb logging object").Action(c.NewName.Set).StringVar(&c.NewName.Value) + common.Placement(c.CmdClause, &c.Placement) + common.ResponseCondition(c.CmdClause, &c.ResponseCondition) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagServiceIDName, Description: cmd.FlagServiceIDDesc, @@ -62,13 +76,6 @@ func NewUpdateCommand(parent cmd.Registerer, globals *config.Data, data manifest Description: cmd.FlagServiceDesc, Dst: &c.ServiceName.Value, }) - c.CmdClause.Flag("new-name", "New name of the Honeycomb logging object").Action(c.NewName.Set).StringVar(&c.NewName.Value) - common.Format(c.CmdClause, &c.Format) - common.FormatVersion(c.CmdClause, &c.FormatVersion) - c.CmdClause.Flag("dataset", "The Honeycomb Dataset you want to log to").Action(c.Dataset.Set).StringVar(&c.Dataset.Value) - c.CmdClause.Flag("auth-token", "The Write Key from the Account page of your Honeycomb account").Action(c.Token.Set).StringVar(&c.Token.Value) - common.ResponseCondition(c.CmdClause, &c.ResponseCondition) - common.Placement(c.CmdClause, &c.Placement) return &c } diff --git a/pkg/commands/logging/https/create.go b/pkg/commands/logging/https/create.go index 53f1455b1..dd723d479 100644 --- a/pkg/commands/logging/https/create.go +++ b/pkg/commands/logging/https/create.go @@ -45,10 +45,15 @@ type CreateCommand struct { // NewCreateCommand returns a usable command registered under the parent. func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *CreateCommand { - var c CreateCommand - c.Globals = globals - c.Manifest = data + c := CreateCommand{ + Base: cmd.Base{ + Globals: globals, + }, + Manifest: data, + } c.CmdClause = parent.Command("create", "Create an HTTPS logging endpoint on a Fastly service version").Alias("add") + + // required c.CmdClause.Flag("name", "The name of the HTTPS logging object. Used as a primary key for API access").Short('n').Action(c.EndpointName.Set).StringVar(&c.EndpointName.Value) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagVersionName, @@ -56,11 +61,24 @@ func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest Dst: &c.ServiceVersion.Value, Required: true, }) + + // optional c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ Action: c.AutoClone.Set, Dst: &c.AutoClone.Value, }) - c.CmdClause.Flag("url", "URL that log data will be sent to. Must use the https protocol").Action(c.URL.Set).StringVar(&c.URL.Value) + c.CmdClause.Flag("content-type", "Content type of the header sent with the request").Action(c.ContentType.Set).StringVar(&c.ContentType.Value) + common.Format(c.CmdClause, &c.Format) + common.FormatVersion(c.CmdClause, &c.FormatVersion) + c.CmdClause.Flag("header-name", "Name of the custom header sent with the request").Action(c.HeaderName.Set).StringVar(&c.HeaderName.Value) + c.CmdClause.Flag("header-value", "Value of the custom header sent with the request").Action(c.HeaderValue.Set).StringVar(&c.HeaderValue.Value) + c.CmdClause.Flag("json-format", "Enforces valid JSON formatting for log entries. Can be disabled 0, array of json (wraps JSON log batches in an array) 1, or newline delimited json (places each JSON log entry onto a new line in a batch) 2").Action(c.JSONFormat.Set).StringVar(&c.JSONFormat.Value) + common.MessageType(c.CmdClause, &c.MessageType) + c.CmdClause.Flag("method", "HTTP method used for request. Can be POST or PUT. Defaults to POST if not specified").Action(c.Method.Set).StringVar(&c.Method.Value) + common.Placement(c.CmdClause, &c.Placement) + c.CmdClause.Flag("request-max-bytes", "Maximum size of log batch, if non-zero. Defaults to 100MB").Action(c.RequestMaxBytes.Set).IntVar(&c.RequestMaxBytes.Value) + c.CmdClause.Flag("request-max-entries", "Maximum number of logs to append to a batch, if non-zero. Defaults to 10k").Action(c.RequestMaxEntries.Set).IntVar(&c.RequestMaxEntries.Value) + common.ResponseCondition(c.CmdClause, &c.ResponseCondition) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagServiceIDName, Description: cmd.FlagServiceIDDesc, @@ -73,22 +91,11 @@ func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest Description: cmd.FlagServiceDesc, Dst: &c.ServiceName.Value, }) - c.CmdClause.Flag("content-type", "Content type of the header sent with the request").Action(c.ContentType.Set).StringVar(&c.ContentType.Value) - c.CmdClause.Flag("header-name", "Name of the custom header sent with the request").Action(c.HeaderName.Set).StringVar(&c.HeaderName.Value) - c.CmdClause.Flag("header-value", "Value of the custom header sent with the request").Action(c.HeaderValue.Set).StringVar(&c.HeaderValue.Value) - c.CmdClause.Flag("method", "HTTP method used for request. Can be POST or PUT. Defaults to POST if not specified").Action(c.Method.Set).StringVar(&c.Method.Value) - c.CmdClause.Flag("json-format", "Enforces valid JSON formatting for log entries. Can be disabled 0, array of json (wraps JSON log batches in an array) 1, or newline delimited json (places each JSON log entry onto a new line in a batch) 2").Action(c.JSONFormat.Set).StringVar(&c.JSONFormat.Value) common.TLSCACert(c.CmdClause, &c.TLSCACert) common.TLSClientCert(c.CmdClause, &c.TLSClientCert) common.TLSClientKey(c.CmdClause, &c.TLSClientKey) common.TLSHostname(c.CmdClause, &c.TLSHostname) - common.MessageType(c.CmdClause, &c.MessageType) - common.Format(c.CmdClause, &c.Format) - common.FormatVersion(c.CmdClause, &c.FormatVersion) - common.Placement(c.CmdClause, &c.Placement) - common.ResponseCondition(c.CmdClause, &c.ResponseCondition) - c.CmdClause.Flag("request-max-entries", "Maximum number of logs to append to a batch, if non-zero. Defaults to 10k").Action(c.RequestMaxEntries.Set).IntVar(&c.RequestMaxEntries.Value) - c.CmdClause.Flag("request-max-bytes", "Maximum size of log batch, if non-zero. Defaults to 100MB").Action(c.RequestMaxBytes.Set).IntVar(&c.RequestMaxBytes.Value) + c.CmdClause.Flag("url", "URL that log data will be sent to. Must use the https protocol").Action(c.URL.Set).StringVar(&c.URL.Value) return &c } diff --git a/pkg/commands/logging/https/delete.go b/pkg/commands/logging/https/delete.go index 66cce7333..51d45f033 100644 --- a/pkg/commands/logging/https/delete.go +++ b/pkg/commands/logging/https/delete.go @@ -23,21 +23,28 @@ type DeleteCommand struct { // NewDeleteCommand returns a usable command registered under the parent. func NewDeleteCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *DeleteCommand { - var c DeleteCommand - c.Globals = globals - c.manifest = data + c := DeleteCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("delete", "Delete an HTTPS logging endpoint on a Fastly service version").Alias("remove") + + // required + c.CmdClause.Flag("name", "The name of the HTTPS logging object").Short('n').Required().StringVar(&c.Input.Name) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagVersionName, Description: cmd.FlagVersionDesc, Dst: &c.serviceVersion.Value, Required: true, }) + + // optional c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ Action: c.autoClone.Set, Dst: &c.autoClone.Value, }) - c.CmdClause.Flag("name", "The name of the HTTPS logging object").Short('n').Required().StringVar(&c.Input.Name) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagServiceIDName, Description: cmd.FlagServiceIDDesc, diff --git a/pkg/commands/logging/https/describe.go b/pkg/commands/logging/https/describe.go index 5725c2b14..392e7953b 100644 --- a/pkg/commands/logging/https/describe.go +++ b/pkg/commands/logging/https/describe.go @@ -25,10 +25,24 @@ type DescribeCommand struct { // NewDescribeCommand returns a usable command registered under the parent. func NewDescribeCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *DescribeCommand { - var c DescribeCommand - c.Globals = globals - c.manifest = data + c := DescribeCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("describe", "Show detailed information about an HTTPS logging endpoint on a Fastly service version").Alias("get") + + // required + c.CmdClause.Flag("name", "The name of the HTTPS logging object").Short('n').Required().StringVar(&c.Input.Name) + c.RegisterFlag(cmd.StringFlagOpts{ + Name: cmd.FlagVersionName, + Description: cmd.FlagVersionDesc, + Dst: &c.serviceVersion.Value, + Required: true, + }) + + // optional c.RegisterFlagBool(cmd.BoolFlagOpts{ Name: cmd.FlagJSONName, Description: cmd.FlagJSONDesc, @@ -47,13 +61,6 @@ func NewDescribeCommand(parent cmd.Registerer, globals *config.Data, data manife Description: cmd.FlagServiceDesc, Dst: &c.serviceName.Value, }) - c.RegisterFlag(cmd.StringFlagOpts{ - Name: cmd.FlagVersionName, - Description: cmd.FlagVersionDesc, - Dst: &c.serviceVersion.Value, - Required: true, - }) - c.CmdClause.Flag("name", "The name of the HTTPS logging object").Short('n').Required().StringVar(&c.Input.Name) return &c } diff --git a/pkg/commands/logging/https/list.go b/pkg/commands/logging/https/list.go index e5c451487..209e8dfe3 100644 --- a/pkg/commands/logging/https/list.go +++ b/pkg/commands/logging/https/list.go @@ -25,10 +25,23 @@ type ListCommand struct { // NewListCommand returns a usable command registered under the parent. func NewListCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *ListCommand { - var c ListCommand - c.Globals = globals - c.manifest = data + c := ListCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("list", "List HTTPS endpoints on a Fastly service version") + + // required + c.RegisterFlag(cmd.StringFlagOpts{ + Name: cmd.FlagVersionName, + Description: cmd.FlagVersionDesc, + Dst: &c.serviceVersion.Value, + Required: true, + }) + + // optional c.RegisterFlagBool(cmd.BoolFlagOpts{ Name: cmd.FlagJSONName, Description: cmd.FlagJSONDesc, @@ -47,12 +60,6 @@ func NewListCommand(parent cmd.Registerer, globals *config.Data, data manifest.D Description: cmd.FlagServiceDesc, Dst: &c.serviceName.Value, }) - c.RegisterFlag(cmd.StringFlagOpts{ - Name: cmd.FlagVersionName, - Description: cmd.FlagVersionDesc, - Dst: &c.serviceVersion.Value, - Required: true, - }) return &c } diff --git a/pkg/commands/logging/https/update.go b/pkg/commands/logging/https/update.go index 5c89d97d9..6cc16d998 100644 --- a/pkg/commands/logging/https/update.go +++ b/pkg/commands/logging/https/update.go @@ -46,21 +46,41 @@ type UpdateCommand struct { // NewUpdateCommand returns a usable command registered under the parent. func NewUpdateCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *UpdateCommand { - var c UpdateCommand - c.Globals = globals - c.Manifest = data + c := UpdateCommand{ + Base: cmd.Base{ + Globals: globals, + }, + Manifest: data, + } c.CmdClause = parent.Command("update", "Update an HTTPS logging endpoint on a Fastly service version") + + // required + c.CmdClause.Flag("name", "The name of the HTTPS logging object").Short('n').Required().StringVar(&c.EndpointName) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagVersionName, Description: cmd.FlagVersionDesc, Dst: &c.ServiceVersion.Value, Required: true, }) + + // optional c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ Action: c.AutoClone.Set, Dst: &c.AutoClone.Value, }) - c.CmdClause.Flag("name", "The name of the HTTPS logging object").Short('n').Required().StringVar(&c.EndpointName) + c.CmdClause.Flag("content-type", "Content type of the header sent with the request").Action(c.ContentType.Set).StringVar(&c.ContentType.Value) + common.Format(c.CmdClause, &c.Format) + common.FormatVersion(c.CmdClause, &c.FormatVersion) + c.CmdClause.Flag("header-name", "Name of the custom header sent with the request").Action(c.HeaderName.Set).StringVar(&c.HeaderName.Value) + c.CmdClause.Flag("header-value", "Value of the custom header sent with the request").Action(c.HeaderValue.Set).StringVar(&c.HeaderValue.Value) + c.CmdClause.Flag("json-format", "Enforces valid JSON formatting for log entries. Can be disabled 0, array of json (wraps JSON log batches in an array) 1, or newline delimited json (places each JSON log entry onto a new line in a batch) 2").Action(c.JSONFormat.Set).StringVar(&c.JSONFormat.Value) + common.MessageType(c.CmdClause, &c.MessageType) + c.CmdClause.Flag("method", "HTTP method used for request. Can be POST or PUT. Defaults to POST if not specified").Action(c.Method.Set).StringVar(&c.Method.Value) + c.CmdClause.Flag("new-name", "New name of the HTTPS logging object").Action(c.NewName.Set).StringVar(&c.NewName.Value) + common.Placement(c.CmdClause, &c.Placement) + c.CmdClause.Flag("request-max-bytes", "Maximum size of log batch, if non-zero. Defaults to 100MB").Action(c.RequestMaxBytes.Set).IntVar(&c.RequestMaxBytes.Value) + c.CmdClause.Flag("request-max-entries", "Maximum number of logs to append to a batch, if non-zero. Defaults to 10k").Action(c.RequestMaxEntries.Set).IntVar(&c.RequestMaxEntries.Value) + common.ResponseCondition(c.CmdClause, &c.ResponseCondition) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagServiceIDName, Description: cmd.FlagServiceIDDesc, @@ -73,24 +93,11 @@ func NewUpdateCommand(parent cmd.Registerer, globals *config.Data, data manifest Description: cmd.FlagServiceDesc, Dst: &c.ServiceName.Value, }) - c.CmdClause.Flag("new-name", "New name of the HTTPS logging object").Action(c.NewName.Set).StringVar(&c.NewName.Value) - c.CmdClause.Flag("url", "URL that log data will be sent to. Must use the https protocol").Action(c.URL.Set).StringVar(&c.URL.Value) - c.CmdClause.Flag("content-type", "Content type of the header sent with the request").Action(c.ContentType.Set).StringVar(&c.ContentType.Value) - c.CmdClause.Flag("header-name", "Name of the custom header sent with the request").Action(c.HeaderName.Set).StringVar(&c.HeaderName.Value) - c.CmdClause.Flag("header-value", "Value of the custom header sent with the request").Action(c.HeaderValue.Set).StringVar(&c.HeaderValue.Value) - c.CmdClause.Flag("method", "HTTP method used for request. Can be POST or PUT. Defaults to POST if not specified").Action(c.Method.Set).StringVar(&c.Method.Value) - c.CmdClause.Flag("json-format", "Enforces valid JSON formatting for log entries. Can be disabled 0, array of json (wraps JSON log batches in an array) 1, or newline delimited json (places each JSON log entry onto a new line in a batch) 2").Action(c.JSONFormat.Set).StringVar(&c.JSONFormat.Value) common.TLSCACert(c.CmdClause, &c.TLSCACert) common.TLSClientCert(c.CmdClause, &c.TLSClientCert) common.TLSClientKey(c.CmdClause, &c.TLSClientKey) common.TLSHostname(c.CmdClause, &c.TLSHostname) - common.MessageType(c.CmdClause, &c.MessageType) - common.Format(c.CmdClause, &c.Format) - common.FormatVersion(c.CmdClause, &c.FormatVersion) - common.Placement(c.CmdClause, &c.Placement) - common.ResponseCondition(c.CmdClause, &c.ResponseCondition) - c.CmdClause.Flag("request-max-entries", "Maximum number of logs to append to a batch, if non-zero. Defaults to 10k").Action(c.RequestMaxEntries.Set).IntVar(&c.RequestMaxEntries.Value) - c.CmdClause.Flag("request-max-bytes", "Maximum size of log batch, if non-zero. Defaults to 100MB").Action(c.RequestMaxBytes.Set).IntVar(&c.RequestMaxBytes.Value) + c.CmdClause.Flag("url", "URL that log data will be sent to. Must use the https protocol").Action(c.URL.Set).StringVar(&c.URL.Value) return &c } diff --git a/pkg/commands/logging/kafka/create.go b/pkg/commands/logging/kafka/create.go index e3828842b..3e03f13f4 100644 --- a/pkg/commands/logging/kafka/create.go +++ b/pkg/commands/logging/kafka/create.go @@ -48,10 +48,15 @@ type CreateCommand struct { // NewCreateCommand returns a usable command registered under the parent. func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *CreateCommand { - var c CreateCommand - c.Globals = globals - c.Manifest = data + c := CreateCommand{ + Base: cmd.Base{ + Globals: globals, + }, + Manifest: data, + } c.CmdClause = parent.Command("create", "Create a Kafka logging endpoint on a Fastly service version").Alias("add") + + // required c.CmdClause.Flag("name", "The name of the Kafka logging object. Used as a primary key for API access").Short('n').Action(c.EndpointName.Set).StringVar(&c.EndpointName.Value) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagVersionName, @@ -59,12 +64,23 @@ func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest Dst: &c.ServiceVersion.Value, Required: true, }) + + // optional c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ Action: c.AutoClone.Set, Dst: &c.AutoClone.Value, }) - c.CmdClause.Flag("topic", "The Kafka topic to send logs to").Action(c.Topic.Set).StringVar(&c.Topic.Value) + c.CmdClause.Flag("auth-method", "SASL authentication method. Valid values are: plain, scram-sha-256, scram-sha-512").Action(c.AuthMethod.Set).HintOptions("plain", "scram-sha-256", "scram-sha-512").EnumVar(&c.AuthMethod.Value, "plain", "scram-sha-256", "scram-sha-512") c.CmdClause.Flag("brokers", "A comma-separated list of IP addresses or hostnames of Kafka brokers").Action(c.Brokers.Set).StringVar(&c.Brokers.Value) + c.CmdClause.Flag("compression-codec", "The codec used for compression of your logs. One of: gzip, snappy, lz4").Action(c.CompressionCodec.Set).StringVar(&c.CompressionCodec.Value) + common.Format(c.CmdClause, &c.Format) + common.FormatVersion(c.CmdClause, &c.FormatVersion) + c.CmdClause.Flag("max-batch-size", "The maximum size of the log batch in bytes").Action(c.RequestMaxBytes.Set).IntVar(&c.RequestMaxBytes.Value) + c.CmdClause.Flag("parse-log-keyvals", "Parse key-value pairs within the log format").Action(c.ParseLogKeyvals.Set).BoolVar(&c.ParseLogKeyvals.Value) + c.CmdClause.Flag("password", "SASL authentication password. Required if --auth-method is specified").Action(c.Password.Set).StringVar(&c.Password.Value) + common.Placement(c.CmdClause, &c.Placement) + c.CmdClause.Flag("required-acks", "The Number of acknowledgements a leader must receive before a write is considered successful. One of: 1 (default) One server needs to respond. 0 No servers need to respond. -1 Wait for all in-sync replicas to respond").Action(c.RequiredACKs.Set).StringVar(&c.RequiredACKs.Value) + common.ResponseCondition(c.CmdClause, &c.ResponseCondition) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagServiceIDName, Description: cmd.FlagServiceIDDesc, @@ -77,23 +93,14 @@ func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest Description: cmd.FlagServiceDesc, Dst: &c.ServiceName.Value, }) - c.CmdClause.Flag("compression-codec", "The codec used for compression of your logs. One of: gzip, snappy, lz4").Action(c.CompressionCodec.Set).StringVar(&c.CompressionCodec.Value) - c.CmdClause.Flag("required-acks", "The Number of acknowledgements a leader must receive before a write is considered successful. One of: 1 (default) One server needs to respond. 0 No servers need to respond. -1 Wait for all in-sync replicas to respond").Action(c.RequiredACKs.Set).StringVar(&c.RequiredACKs.Value) - c.CmdClause.Flag("use-tls", "Whether to use TLS for secure logging. Can be either true or false").Action(c.UseTLS.Set).BoolVar(&c.UseTLS.Value) common.TLSCACert(c.CmdClause, &c.TLSCACert) common.TLSClientCert(c.CmdClause, &c.TLSClientCert) common.TLSClientKey(c.CmdClause, &c.TLSClientKey) common.TLSHostname(c.CmdClause, &c.TLSHostname) - common.Format(c.CmdClause, &c.Format) - common.FormatVersion(c.CmdClause, &c.FormatVersion) - common.Placement(c.CmdClause, &c.Placement) - common.ResponseCondition(c.CmdClause, &c.ResponseCondition) - c.CmdClause.Flag("parse-log-keyvals", "Parse key-value pairs within the log format").Action(c.ParseLogKeyvals.Set).BoolVar(&c.ParseLogKeyvals.Value) - c.CmdClause.Flag("max-batch-size", "The maximum size of the log batch in bytes").Action(c.RequestMaxBytes.Set).IntVar(&c.RequestMaxBytes.Value) + c.CmdClause.Flag("topic", "The Kafka topic to send logs to").Action(c.Topic.Set).StringVar(&c.Topic.Value) c.CmdClause.Flag("use-sasl", "Enable SASL authentication. Requires --auth-method, --username, and --password to be specified").Action(c.UseSASL.Set).BoolVar(&c.UseSASL.Value) - c.CmdClause.Flag("auth-method", "SASL authentication method. Valid values are: plain, scram-sha-256, scram-sha-512").Action(c.AuthMethod.Set).HintOptions("plain", "scram-sha-256", "scram-sha-512").EnumVar(&c.AuthMethod.Value, "plain", "scram-sha-256", "scram-sha-512") + c.CmdClause.Flag("use-tls", "Whether to use TLS for secure logging. Can be either true or false").Action(c.UseTLS.Set).BoolVar(&c.UseTLS.Value) c.CmdClause.Flag("username", "SASL authentication username. Required if --auth-method is specified").Action(c.User.Set).StringVar(&c.User.Value) - c.CmdClause.Flag("password", "SASL authentication password. Required if --auth-method is specified").Action(c.Password.Set).StringVar(&c.Password.Value) return &c } diff --git a/pkg/commands/logging/kafka/delete.go b/pkg/commands/logging/kafka/delete.go index 8b6b12d58..9e8b85ab0 100644 --- a/pkg/commands/logging/kafka/delete.go +++ b/pkg/commands/logging/kafka/delete.go @@ -23,21 +23,28 @@ type DeleteCommand struct { // NewDeleteCommand returns a usable command registered under the parent. func NewDeleteCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *DeleteCommand { - var c DeleteCommand - c.Globals = globals - c.manifest = data + c := DeleteCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("delete", "Delete a Kafka logging endpoint on a Fastly service version").Alias("remove") + + // required + c.CmdClause.Flag("name", "The name of the Kafka logging object").Short('n').Required().StringVar(&c.Input.Name) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagVersionName, Description: cmd.FlagVersionDesc, Dst: &c.serviceVersion.Value, Required: true, }) + + // optional c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ Action: c.autoClone.Set, Dst: &c.autoClone.Value, }) - c.CmdClause.Flag("name", "The name of the Kafka logging object").Short('n').Required().StringVar(&c.Input.Name) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagServiceIDName, Description: cmd.FlagServiceIDDesc, diff --git a/pkg/commands/logging/kafka/describe.go b/pkg/commands/logging/kafka/describe.go index dfcc253c0..bf068ee3e 100644 --- a/pkg/commands/logging/kafka/describe.go +++ b/pkg/commands/logging/kafka/describe.go @@ -25,10 +25,24 @@ type DescribeCommand struct { // NewDescribeCommand returns a usable command registered under the parent. func NewDescribeCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *DescribeCommand { - var c DescribeCommand - c.Globals = globals - c.manifest = data + c := DescribeCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("describe", "Show detailed information about a Kafka logging endpoint on a Fastly service version").Alias("get") + + // required + c.CmdClause.Flag("name", "The name of the Kafka logging object").Short('n').Required().StringVar(&c.Input.Name) + c.RegisterFlag(cmd.StringFlagOpts{ + Name: cmd.FlagVersionName, + Description: cmd.FlagVersionDesc, + Dst: &c.serviceVersion.Value, + Required: true, + }) + + // optional c.RegisterFlagBool(cmd.BoolFlagOpts{ Name: cmd.FlagJSONName, Description: cmd.FlagJSONDesc, @@ -47,13 +61,6 @@ func NewDescribeCommand(parent cmd.Registerer, globals *config.Data, data manife Description: cmd.FlagServiceDesc, Dst: &c.serviceName.Value, }) - c.RegisterFlag(cmd.StringFlagOpts{ - Name: cmd.FlagVersionName, - Description: cmd.FlagVersionDesc, - Dst: &c.serviceVersion.Value, - Required: true, - }) - c.CmdClause.Flag("name", "The name of the Kafka logging object").Short('n').Required().StringVar(&c.Input.Name) return &c } diff --git a/pkg/commands/logging/kafka/list.go b/pkg/commands/logging/kafka/list.go index 31657953c..c17f52345 100644 --- a/pkg/commands/logging/kafka/list.go +++ b/pkg/commands/logging/kafka/list.go @@ -25,10 +25,23 @@ type ListCommand struct { // NewListCommand returns a usable command registered under the parent. func NewListCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *ListCommand { - var c ListCommand - c.Globals = globals - c.manifest = data + c := ListCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("list", "List Kafka endpoints on a Fastly service version") + + // required + c.RegisterFlag(cmd.StringFlagOpts{ + Name: cmd.FlagVersionName, + Description: cmd.FlagVersionDesc, + Dst: &c.serviceVersion.Value, + Required: true, + }) + + // optional c.RegisterFlagBool(cmd.BoolFlagOpts{ Name: cmd.FlagJSONName, Description: cmd.FlagJSONDesc, @@ -47,12 +60,6 @@ func NewListCommand(parent cmd.Registerer, globals *config.Data, data manifest.D Description: cmd.FlagServiceDesc, Dst: &c.serviceName.Value, }) - c.RegisterFlag(cmd.StringFlagOpts{ - Name: cmd.FlagVersionName, - Description: cmd.FlagVersionDesc, - Dst: &c.serviceVersion.Value, - Required: true, - }) return &c } diff --git a/pkg/commands/logging/kafka/update.go b/pkg/commands/logging/kafka/update.go index 34bf08078..257c40781 100644 --- a/pkg/commands/logging/kafka/update.go +++ b/pkg/commands/logging/kafka/update.go @@ -50,21 +50,40 @@ type UpdateCommand struct { // NewUpdateCommand returns a usable command registered under the parent. func NewUpdateCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *UpdateCommand { - var c UpdateCommand - c.Globals = globals - c.Manifest = data + c := UpdateCommand{ + Base: cmd.Base{ + Globals: globals, + }, + Manifest: data, + } c.CmdClause = parent.Command("update", "Update a Kafka logging endpoint on a Fastly service version") + + // required + c.CmdClause.Flag("name", "The name of the Kafka logging object").Short('n').Required().StringVar(&c.EndpointName) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagVersionName, Description: cmd.FlagVersionDesc, Dst: &c.ServiceVersion.Value, Required: true, }) + + // optional c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ Action: c.AutoClone.Set, Dst: &c.AutoClone.Value, }) - c.CmdClause.Flag("name", "The name of the Kafka logging object").Short('n').Required().StringVar(&c.EndpointName) + c.CmdClause.Flag("auth-method", "SASL authentication method. Valid values are: plain, scram-sha-256, scram-sha-512").Action(c.AuthMethod.Set).HintOptions("plain", "scram-sha-256", "scram-sha-512").EnumVar(&c.AuthMethod.Value, "plain", "scram-sha-256", "scram-sha-512") + c.CmdClause.Flag("brokers", "A comma-separated list of IP addresses or hostnames of Kafka brokers").Action(c.Brokers.Set).StringVar(&c.Brokers.Value) + c.CmdClause.Flag("compression-codec", "The codec used for compression of your logs. One of: gzip, snappy, lz4").Action(c.CompressionCodec.Set).StringVar(&c.CompressionCodec.Value) + common.Format(c.CmdClause, &c.Format) + common.FormatVersion(c.CmdClause, &c.FormatVersion) + c.CmdClause.Flag("max-batch-size", "The maximum size of the log batch in bytes").Action(c.RequestMaxBytes.Set).IntVar(&c.RequestMaxBytes.Value) + c.CmdClause.Flag("new-name", "New name of the Kafka logging object").Action(c.NewName.Set).StringVar(&c.NewName.Value) + c.CmdClause.Flag("parse-log-keyvals", "Parse key-value pairs within the log format").Action(c.ParseLogKeyvals.Set).NegatableBoolVar(&c.ParseLogKeyvals.Value) + c.CmdClause.Flag("password", "SASL authentication password. Required if --auth-method is specified").Action(c.Password.Set).StringVar(&c.Password.Value) + common.Placement(c.CmdClause, &c.Placement) + c.CmdClause.Flag("required-acks", "The Number of acknowledgements a leader must receive before a write is considered successful. One of: 1 (default) One server needs to respond. 0 No servers need to respond. -1 Wait for all in-sync replicas to respond").Action(c.RequiredACKs.Set).StringVar(&c.RequiredACKs.Value) + common.ResponseCondition(c.CmdClause, &c.ResponseCondition) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagServiceIDName, Description: cmd.FlagServiceIDDesc, @@ -77,26 +96,14 @@ func NewUpdateCommand(parent cmd.Registerer, globals *config.Data, data manifest Description: cmd.FlagServiceDesc, Dst: &c.ServiceName.Value, }) - c.CmdClause.Flag("new-name", "New name of the Kafka logging object").Action(c.NewName.Set).StringVar(&c.NewName.Value) - c.CmdClause.Flag("topic", "The Kafka topic to send logs to").Action(c.Topic.Set).StringVar(&c.Topic.Value) - c.CmdClause.Flag("brokers", "A comma-separated list of IP addresses or hostnames of Kafka brokers").Action(c.Brokers.Set).StringVar(&c.Brokers.Value) - c.CmdClause.Flag("compression-codec", "The codec used for compression of your logs. One of: gzip, snappy, lz4").Action(c.CompressionCodec.Set).StringVar(&c.CompressionCodec.Value) - c.CmdClause.Flag("required-acks", "The Number of acknowledgements a leader must receive before a write is considered successful. One of: 1 (default) One server needs to respond. 0 No servers need to respond. -1 Wait for all in-sync replicas to respond").Action(c.RequiredACKs.Set).StringVar(&c.RequiredACKs.Value) - c.CmdClause.Flag("use-tls", "Whether to use TLS for secure logging. Can be either true or false").Action(c.UseTLS.Set).BoolVar(&c.UseTLS.Value) common.TLSCACert(c.CmdClause, &c.TLSCACert) common.TLSClientCert(c.CmdClause, &c.TLSClientCert) common.TLSClientKey(c.CmdClause, &c.TLSClientKey) common.TLSHostname(c.CmdClause, &c.TLSHostname) - common.Format(c.CmdClause, &c.Format) - common.FormatVersion(c.CmdClause, &c.FormatVersion) - common.Placement(c.CmdClause, &c.Placement) - common.ResponseCondition(c.CmdClause, &c.ResponseCondition) - c.CmdClause.Flag("parse-log-keyvals", "Parse key-value pairs within the log format").Action(c.ParseLogKeyvals.Set).NegatableBoolVar(&c.ParseLogKeyvals.Value) - c.CmdClause.Flag("max-batch-size", "The maximum size of the log batch in bytes").Action(c.RequestMaxBytes.Set).IntVar(&c.RequestMaxBytes.Value) + c.CmdClause.Flag("topic", "The Kafka topic to send logs to").Action(c.Topic.Set).StringVar(&c.Topic.Value) c.CmdClause.Flag("use-sasl", "Enable SASL authentication. Requires --auth-method, --username, and --password to be specified").Action(c.UseSASL.Set).BoolVar(&c.UseSASL.Value) - c.CmdClause.Flag("auth-method", "SASL authentication method. Valid values are: plain, scram-sha-256, scram-sha-512").Action(c.AuthMethod.Set).HintOptions("plain", "scram-sha-256", "scram-sha-512").EnumVar(&c.AuthMethod.Value, "plain", "scram-sha-256", "scram-sha-512") + c.CmdClause.Flag("use-tls", "Whether to use TLS for secure logging. Can be either true or false").Action(c.UseTLS.Set).BoolVar(&c.UseTLS.Value) c.CmdClause.Flag("username", "SASL authentication username. Required if --auth-method is specified").Action(c.User.Set).StringVar(&c.User.Value) - c.CmdClause.Flag("password", "SASL authentication password. Required if --auth-method is specified").Action(c.Password.Set).StringVar(&c.Password.Value) return &c } diff --git a/pkg/commands/logging/kinesis/create.go b/pkg/commands/logging/kinesis/create.go index 630001050..61fab795a 100644 --- a/pkg/commands/logging/kinesis/create.go +++ b/pkg/commands/logging/kinesis/create.go @@ -41,9 +41,12 @@ type CreateCommand struct { // NewCreateCommand returns a usable command registered under the parent. func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *CreateCommand { - var c CreateCommand - c.Globals = globals - c.Manifest = data + c := CreateCommand{ + Base: cmd.Base{ + Globals: globals, + }, + Manifest: data, + } c.CmdClause = parent.Command("create", "Create an Amazon Kinesis logging endpoint on a Fastly service version").Alias("add") // required @@ -54,8 +57,6 @@ func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest Dst: &c.ServiceVersion.Value, Required: true, }) - c.CmdClause.Flag("stream-name", "The Amazon Kinesis stream to send logs to").Action(c.StreamName.Set).StringVar(&c.StreamName.Value) - c.CmdClause.Flag("region", "The AWS region where the Kinesis stream exists").Action(c.Region.Set).StringVar(&c.Region.Value) // required, but mutually exclusive c.CmdClause.Flag("access-key", "The access key associated with the target Amazon Kinesis stream").Action(c.AccessKey.Set).StringVar(&c.AccessKey.Value) @@ -67,6 +68,12 @@ func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest Action: c.AutoClone.Set, Dst: &c.AutoClone.Value, }) + common.Format(c.CmdClause, &c.Format) + common.FormatVersion(c.CmdClause, &c.FormatVersion) + c.CmdClause.Flag("region", "The AWS region where the Kinesis stream exists").Action(c.Region.Set).StringVar(&c.Region.Value) + common.ResponseCondition(c.CmdClause, &c.ResponseCondition) + common.Placement(c.CmdClause, &c.Placement) + c.CmdClause.Flag("stream-name", "The Amazon Kinesis stream to send logs to").Action(c.StreamName.Set).StringVar(&c.StreamName.Value) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagServiceIDName, Description: cmd.FlagServiceIDDesc, @@ -79,10 +86,6 @@ func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest Description: cmd.FlagServiceDesc, Dst: &c.ServiceName.Value, }) - common.Format(c.CmdClause, &c.Format) - common.FormatVersion(c.CmdClause, &c.FormatVersion) - common.ResponseCondition(c.CmdClause, &c.ResponseCondition) - common.Placement(c.CmdClause, &c.Placement) return &c } diff --git a/pkg/commands/logging/kinesis/delete.go b/pkg/commands/logging/kinesis/delete.go index bb13f9db6..ea5b27716 100644 --- a/pkg/commands/logging/kinesis/delete.go +++ b/pkg/commands/logging/kinesis/delete.go @@ -23,21 +23,28 @@ type DeleteCommand struct { // NewDeleteCommand returns a usable command registered under the parent. func NewDeleteCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *DeleteCommand { - var c DeleteCommand - c.Globals = globals - c.manifest = data + c := DeleteCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("delete", "Delete a Kinesis logging endpoint on a Fastly service version").Alias("remove") + + // required + c.CmdClause.Flag("name", "The name of the Kinesis logging object").Short('n').Required().StringVar(&c.Input.Name) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagVersionName, Description: cmd.FlagVersionDesc, Dst: &c.serviceVersion.Value, Required: true, }) + + // optional c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ Action: c.autoClone.Set, Dst: &c.autoClone.Value, }) - c.CmdClause.Flag("name", "The name of the Kinesis logging object").Short('n').Required().StringVar(&c.Input.Name) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagServiceIDName, Description: cmd.FlagServiceIDDesc, diff --git a/pkg/commands/logging/kinesis/describe.go b/pkg/commands/logging/kinesis/describe.go index c43f56db2..e7c1f9297 100644 --- a/pkg/commands/logging/kinesis/describe.go +++ b/pkg/commands/logging/kinesis/describe.go @@ -25,10 +25,24 @@ type DescribeCommand struct { // NewDescribeCommand returns a usable command registered under the parent. func NewDescribeCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *DescribeCommand { - var c DescribeCommand - c.Globals = globals - c.manifest = data + c := DescribeCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("describe", "Show detailed information about a Kinesis logging endpoint on a Fastly service version").Alias("get") + + // required + c.CmdClause.Flag("name", "The name of the Kinesis logging object").Short('n').Required().StringVar(&c.Input.Name) + c.RegisterFlag(cmd.StringFlagOpts{ + Name: cmd.FlagVersionName, + Description: cmd.FlagVersionDesc, + Dst: &c.serviceVersion.Value, + Required: true, + }) + + // optional c.RegisterFlagBool(cmd.BoolFlagOpts{ Name: cmd.FlagJSONName, Description: cmd.FlagJSONDesc, @@ -47,13 +61,6 @@ func NewDescribeCommand(parent cmd.Registerer, globals *config.Data, data manife Description: cmd.FlagServiceDesc, Dst: &c.serviceName.Value, }) - c.RegisterFlag(cmd.StringFlagOpts{ - Name: cmd.FlagVersionName, - Description: cmd.FlagVersionDesc, - Dst: &c.serviceVersion.Value, - Required: true, - }) - c.CmdClause.Flag("name", "The name of the Kinesis logging object").Short('n').Required().StringVar(&c.Input.Name) return &c } diff --git a/pkg/commands/logging/kinesis/list.go b/pkg/commands/logging/kinesis/list.go index a114c7d75..4de9469f8 100644 --- a/pkg/commands/logging/kinesis/list.go +++ b/pkg/commands/logging/kinesis/list.go @@ -25,10 +25,23 @@ type ListCommand struct { // NewListCommand returns a usable command registered under the parent. func NewListCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *ListCommand { - var c ListCommand - c.Globals = globals - c.manifest = data + c := ListCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("list", "List Kinesis endpoints on a Fastly service version") + + // required + c.RegisterFlag(cmd.StringFlagOpts{ + Name: cmd.FlagVersionName, + Description: cmd.FlagVersionDesc, + Dst: &c.serviceVersion.Value, + Required: true, + }) + + // optional c.RegisterFlagBool(cmd.BoolFlagOpts{ Name: cmd.FlagJSONName, Description: cmd.FlagJSONDesc, @@ -47,12 +60,6 @@ func NewListCommand(parent cmd.Registerer, globals *config.Data, data manifest.D Description: cmd.FlagServiceDesc, Dst: &c.serviceName.Value, }) - c.RegisterFlag(cmd.StringFlagOpts{ - Name: cmd.FlagVersionName, - Description: cmd.FlagVersionDesc, - Dst: &c.serviceVersion.Value, - Required: true, - }) return &c } diff --git a/pkg/commands/logging/kinesis/update.go b/pkg/commands/logging/kinesis/update.go index 2a7d06a48..29991f543 100644 --- a/pkg/commands/logging/kinesis/update.go +++ b/pkg/commands/logging/kinesis/update.go @@ -38,21 +38,37 @@ type UpdateCommand struct { // NewUpdateCommand returns a usable command registered under the parent. func NewUpdateCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *UpdateCommand { - var c UpdateCommand - c.Globals = globals - c.Manifest = data + c := UpdateCommand{ + Base: cmd.Base{ + Globals: globals, + }, + Manifest: data, + } c.CmdClause = parent.Command("update", "Update a Kinesis logging endpoint on a Fastly service version") + + // required + c.CmdClause.Flag("name", "The name of the Kinesis logging object").Short('n').Required().StringVar(&c.EndpointName) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagVersionName, Description: cmd.FlagVersionDesc, Dst: &c.ServiceVersion.Value, Required: true, }) + + // optional c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ Action: c.AutoClone.Set, Dst: &c.AutoClone.Value, }) - c.CmdClause.Flag("name", "The name of the Kinesis logging object").Short('n').Required().StringVar(&c.EndpointName) + c.CmdClause.Flag("access-key", "Your Kinesis account access key").Action(c.AccessKey.Set).StringVar(&c.AccessKey.Value) + common.Format(c.CmdClause, &c.Format) + common.FormatVersion(c.CmdClause, &c.FormatVersion) + c.CmdClause.Flag("iam-role", "The IAM role ARN for logging").Action(c.IAMRole.Set).StringVar(&c.IAMRole.Value) + c.CmdClause.Flag("new-name", "New name of the Kinesis logging object").Action(c.NewName.Set).StringVar(&c.NewName.Value) + common.Placement(c.CmdClause, &c.Placement) + c.CmdClause.Flag("region", "The AWS region where the Kinesis stream exists").Action(c.Region.Set).StringVar(&c.Region.Value) + common.ResponseCondition(c.CmdClause, &c.ResponseCondition) + c.CmdClause.Flag("secret-key", "Your Kinesis account secret key").Action(c.SecretKey.Set).StringVar(&c.SecretKey.Value) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagServiceIDName, Description: cmd.FlagServiceIDDesc, @@ -65,16 +81,7 @@ func NewUpdateCommand(parent cmd.Registerer, globals *config.Data, data manifest Description: cmd.FlagServiceDesc, Dst: &c.ServiceName.Value, }) - c.CmdClause.Flag("new-name", "New name of the Kinesis logging object").Action(c.NewName.Set).StringVar(&c.NewName.Value) c.CmdClause.Flag("stream-name", "Your Kinesis stream name").Action(c.StreamName.Set).StringVar(&c.StreamName.Value) - c.CmdClause.Flag("access-key", "Your Kinesis account access key").Action(c.AccessKey.Set).StringVar(&c.AccessKey.Value) - c.CmdClause.Flag("secret-key", "Your Kinesis account secret key").Action(c.SecretKey.Set).StringVar(&c.SecretKey.Value) - c.CmdClause.Flag("iam-role", "The IAM role ARN for logging").Action(c.IAMRole.Set).StringVar(&c.IAMRole.Value) - c.CmdClause.Flag("region", "The AWS region where the Kinesis stream exists").Action(c.Region.Set).StringVar(&c.Region.Value) - common.Format(c.CmdClause, &c.Format) - common.FormatVersion(c.CmdClause, &c.FormatVersion) - common.ResponseCondition(c.CmdClause, &c.ResponseCondition) - common.Placement(c.CmdClause, &c.Placement) return &c } diff --git a/pkg/commands/logging/logentries/create.go b/pkg/commands/logging/logentries/create.go index 0036ccf64..56f011279 100644 --- a/pkg/commands/logging/logentries/create.go +++ b/pkg/commands/logging/logentries/create.go @@ -36,11 +36,35 @@ type CreateCommand struct { // NewCreateCommand returns a usable command registered under the parent. func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *CreateCommand { - var c CreateCommand - c.Globals = globals - c.Manifest = data + c := CreateCommand{ + Base: cmd.Base{ + Globals: globals, + }, + Manifest: data, + } c.CmdClause = parent.Command("create", "Create a Logentries logging endpoint on a Fastly service version").Alias("add") + + // required c.CmdClause.Flag("name", "The name of the Logentries logging object. Used as a primary key for API access").Short('n').Action(c.EndpointName.Set).StringVar(&c.EndpointName.Value) + c.RegisterFlag(cmd.StringFlagOpts{ + Name: cmd.FlagVersionName, + Description: cmd.FlagVersionDesc, + Dst: &c.ServiceVersion.Value, + Required: true, + }) + + // optional + c.CmdClause.Flag("auth-token", "Use token based authentication (https://logentries.com/doc/input-token/)").Action(c.Token.Set).StringVar(&c.Token.Value) + c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ + Action: c.AutoClone.Set, + Dst: &c.AutoClone.Value, + }) + common.Format(c.CmdClause, &c.Format) + common.FormatVersion(c.CmdClause, &c.FormatVersion) + common.Placement(c.CmdClause, &c.Placement) + c.CmdClause.Flag("port", "The port number").Action(c.Port.Set).IntVar(&c.Port.Value) + c.CmdClause.Flag("region", "The region to which to stream logs").Action(c.Region.Set).StringVar(&c.Region.Value) + common.ResponseCondition(c.CmdClause, &c.ResponseCondition) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagServiceIDName, Description: cmd.FlagServiceIDDesc, @@ -53,24 +77,7 @@ func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest Description: cmd.FlagServiceDesc, Dst: &c.ServiceName.Value, }) - c.CmdClause.Flag("port", "The port number").Action(c.Port.Set).IntVar(&c.Port.Value) c.CmdClause.Flag("use-tls", "Whether to use TLS for secure logging. Can be either true or false").Action(c.UseTLS.Set).BoolVar(&c.UseTLS.Value) - c.CmdClause.Flag("auth-token", "Use token based authentication (https://logentries.com/doc/input-token/)").Action(c.Token.Set).StringVar(&c.Token.Value) - common.Format(c.CmdClause, &c.Format) - common.FormatVersion(c.CmdClause, &c.FormatVersion) - common.ResponseCondition(c.CmdClause, &c.ResponseCondition) - common.Placement(c.CmdClause, &c.Placement) - c.CmdClause.Flag("region", "The region to which to stream logs").Action(c.Region.Set).StringVar(&c.Region.Value) - c.RegisterFlag(cmd.StringFlagOpts{ - Name: cmd.FlagVersionName, - Description: cmd.FlagVersionDesc, - Dst: &c.ServiceVersion.Value, - Required: true, - }) - c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ - Action: c.AutoClone.Set, - Dst: &c.AutoClone.Value, - }) return &c } diff --git a/pkg/commands/logging/logentries/delete.go b/pkg/commands/logging/logentries/delete.go index a750db36c..0831bce91 100644 --- a/pkg/commands/logging/logentries/delete.go +++ b/pkg/commands/logging/logentries/delete.go @@ -23,21 +23,28 @@ type DeleteCommand struct { // NewDeleteCommand returns a usable command registered under the parent. func NewDeleteCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *DeleteCommand { - var c DeleteCommand - c.Globals = globals - c.manifest = data + c := DeleteCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("delete", "Delete a Logentries logging endpoint on a Fastly service version").Alias("remove") + + // required + c.CmdClause.Flag("name", "The name of the Logentries logging object").Short('n').Required().StringVar(&c.Input.Name) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagVersionName, Description: cmd.FlagVersionDesc, Dst: &c.serviceVersion.Value, Required: true, }) + + // optional c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ Action: c.autoClone.Set, Dst: &c.autoClone.Value, }) - c.CmdClause.Flag("name", "The name of the Logentries logging object").Short('n').Required().StringVar(&c.Input.Name) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagServiceIDName, Description: cmd.FlagServiceIDDesc, diff --git a/pkg/commands/logging/logentries/describe.go b/pkg/commands/logging/logentries/describe.go index b6f7e2b18..91219e11d 100644 --- a/pkg/commands/logging/logentries/describe.go +++ b/pkg/commands/logging/logentries/describe.go @@ -25,10 +25,24 @@ type DescribeCommand struct { // NewDescribeCommand returns a usable command registered under the parent. func NewDescribeCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *DescribeCommand { - var c DescribeCommand - c.Globals = globals - c.manifest = data + c := DescribeCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("describe", "Show detailed information about a Logentries logging endpoint on a Fastly service version").Alias("get") + + // required + c.CmdClause.Flag("name", "The name of the Logentries logging object").Short('n').Required().StringVar(&c.Input.Name) + c.RegisterFlag(cmd.StringFlagOpts{ + Name: cmd.FlagVersionName, + Description: cmd.FlagVersionDesc, + Dst: &c.serviceVersion.Value, + Required: true, + }) + + // optional c.RegisterFlagBool(cmd.BoolFlagOpts{ Name: cmd.FlagJSONName, Description: cmd.FlagJSONDesc, @@ -47,13 +61,6 @@ func NewDescribeCommand(parent cmd.Registerer, globals *config.Data, data manife Description: cmd.FlagServiceDesc, Dst: &c.serviceName.Value, }) - c.RegisterFlag(cmd.StringFlagOpts{ - Name: cmd.FlagVersionName, - Description: cmd.FlagVersionDesc, - Dst: &c.serviceVersion.Value, - Required: true, - }) - c.CmdClause.Flag("name", "The name of the Logentries logging object").Short('n').Required().StringVar(&c.Input.Name) return &c } diff --git a/pkg/commands/logging/logentries/list.go b/pkg/commands/logging/logentries/list.go index a59df6cee..9e72bb52e 100644 --- a/pkg/commands/logging/logentries/list.go +++ b/pkg/commands/logging/logentries/list.go @@ -25,10 +25,23 @@ type ListCommand struct { // NewListCommand returns a usable command registered under the parent. func NewListCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *ListCommand { - var c ListCommand - c.Globals = globals - c.manifest = data + c := ListCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("list", "List Logentries endpoints on a Fastly service version") + + // required + c.RegisterFlag(cmd.StringFlagOpts{ + Name: cmd.FlagVersionName, + Description: cmd.FlagVersionDesc, + Dst: &c.serviceVersion.Value, + Required: true, + }) + + // optional c.RegisterFlagBool(cmd.BoolFlagOpts{ Name: cmd.FlagJSONName, Description: cmd.FlagJSONDesc, @@ -47,12 +60,6 @@ func NewListCommand(parent cmd.Registerer, globals *config.Data, data manifest.D Description: cmd.FlagServiceDesc, Dst: &c.serviceName.Value, }) - c.RegisterFlag(cmd.StringFlagOpts{ - Name: cmd.FlagVersionName, - Description: cmd.FlagVersionDesc, - Dst: &c.serviceVersion.Value, - Required: true, - }) return &c } diff --git a/pkg/commands/logging/logentries/update.go b/pkg/commands/logging/logentries/update.go index 46eb89ae0..1881dc94c 100644 --- a/pkg/commands/logging/logentries/update.go +++ b/pkg/commands/logging/logentries/update.go @@ -37,21 +37,36 @@ type UpdateCommand struct { // NewUpdateCommand returns a usable command registered under the parent. func NewUpdateCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *UpdateCommand { - var c UpdateCommand - c.Globals = globals - c.Manifest = data + c := UpdateCommand{ + Base: cmd.Base{ + Globals: globals, + }, + Manifest: data, + } c.CmdClause = parent.Command("update", "Update a Logentries logging endpoint on a Fastly service version") + + // required + c.CmdClause.Flag("name", "The name of the Logentries logging object").Short('n').Required().StringVar(&c.EndpointName) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagVersionName, Description: cmd.FlagVersionDesc, Dst: &c.ServiceVersion.Value, Required: true, }) + + // optional + c.CmdClause.Flag("auth-token", "Use token based authentication (https://logentries.com/doc/input-token/)").Action(c.Token.Set).StringVar(&c.Token.Value) c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ Action: c.AutoClone.Set, Dst: &c.AutoClone.Value, }) - c.CmdClause.Flag("name", "The name of the Logentries logging object").Short('n').Required().StringVar(&c.EndpointName) + common.Format(c.CmdClause, &c.Format) + common.FormatVersion(c.CmdClause, &c.FormatVersion) + c.CmdClause.Flag("new-name", "New name of the Logentries logging object").Action(c.NewName.Set).StringVar(&c.NewName.Value) + common.Placement(c.CmdClause, &c.Placement) + c.CmdClause.Flag("port", "The port number").Action(c.Port.Set).IntVar(&c.Port.Value) + c.CmdClause.Flag("region", "The region to which to stream logs").Action(c.Region.Set).StringVar(&c.Region.Value) + common.ResponseCondition(c.CmdClause, &c.ResponseCondition) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagServiceIDName, Description: cmd.FlagServiceIDDesc, @@ -64,15 +79,7 @@ func NewUpdateCommand(parent cmd.Registerer, globals *config.Data, data manifest Description: cmd.FlagServiceDesc, Dst: &c.ServiceName.Value, }) - c.CmdClause.Flag("new-name", "New name of the Logentries logging object").Action(c.NewName.Set).StringVar(&c.NewName.Value) - c.CmdClause.Flag("port", "The port number").Action(c.Port.Set).IntVar(&c.Port.Value) c.CmdClause.Flag("use-tls", "Whether to use TLS for secure logging. Can be either true or false").Action(c.UseTLS.Set).BoolVar(&c.UseTLS.Value) - c.CmdClause.Flag("auth-token", "Use token based authentication (https://logentries.com/doc/input-token/)").Action(c.Token.Set).StringVar(&c.Token.Value) - common.Format(c.CmdClause, &c.Format) - common.FormatVersion(c.CmdClause, &c.FormatVersion) - common.ResponseCondition(c.CmdClause, &c.ResponseCondition) - common.Placement(c.CmdClause, &c.Placement) - c.CmdClause.Flag("region", "The region to which to stream logs").Action(c.Region.Set).StringVar(&c.Region.Value) return &c } diff --git a/pkg/commands/logging/loggly/create.go b/pkg/commands/logging/loggly/create.go index adee6127b..3283e1f28 100644 --- a/pkg/commands/logging/loggly/create.go +++ b/pkg/commands/logging/loggly/create.go @@ -33,10 +33,15 @@ type CreateCommand struct { // NewCreateCommand returns a usable command registered under the parent. func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *CreateCommand { - var c CreateCommand - c.Globals = globals - c.Manifest = data + c := CreateCommand{ + Base: cmd.Base{ + Globals: globals, + }, + Manifest: data, + } c.CmdClause = parent.Command("create", "Create a Loggly logging endpoint on a Fastly service version").Alias("add") + + // required c.CmdClause.Flag("name", "The name of the Loggly logging object. Used as a primary key for API access").Short('n').Action(c.EndpointName.Set).StringVar(&c.EndpointName.Value) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagVersionName, @@ -44,11 +49,17 @@ func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest Dst: &c.ServiceVersion.Value, Required: true, }) + + // optional + c.CmdClause.Flag("auth-token", "The token to use for authentication (https://www.loggly.com/docs/customer-token-authentication-token/)").Action(c.Token.Set).StringVar(&c.Token.Value) c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ Action: c.AutoClone.Set, Dst: &c.AutoClone.Value, }) - c.CmdClause.Flag("auth-token", "The token to use for authentication (https://www.loggly.com/docs/customer-token-authentication-token/)").Action(c.Token.Set).StringVar(&c.Token.Value) + common.Format(c.CmdClause, &c.Format) + common.FormatVersion(c.CmdClause, &c.FormatVersion) + common.ResponseCondition(c.CmdClause, &c.ResponseCondition) + common.Placement(c.CmdClause, &c.Placement) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagServiceIDName, Description: cmd.FlagServiceIDDesc, @@ -61,10 +72,6 @@ func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest Description: cmd.FlagServiceDesc, Dst: &c.ServiceName.Value, }) - common.Format(c.CmdClause, &c.Format) - common.FormatVersion(c.CmdClause, &c.FormatVersion) - common.ResponseCondition(c.CmdClause, &c.ResponseCondition) - common.Placement(c.CmdClause, &c.Placement) return &c } diff --git a/pkg/commands/logging/loggly/delete.go b/pkg/commands/logging/loggly/delete.go index 230ac1957..a6a271f35 100644 --- a/pkg/commands/logging/loggly/delete.go +++ b/pkg/commands/logging/loggly/delete.go @@ -23,21 +23,28 @@ type DeleteCommand struct { // NewDeleteCommand returns a usable command registered under the parent. func NewDeleteCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *DeleteCommand { - var c DeleteCommand - c.Globals = globals - c.manifest = data + c := DeleteCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("delete", "Delete a Loggly logging endpoint on a Fastly service version").Alias("remove") + + // required + c.CmdClause.Flag("name", "The name of the Loggly logging object").Short('n').Required().StringVar(&c.Input.Name) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagVersionName, Description: cmd.FlagVersionDesc, Dst: &c.serviceVersion.Value, Required: true, }) + + // optional c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ Action: c.autoClone.Set, Dst: &c.autoClone.Value, }) - c.CmdClause.Flag("name", "The name of the Loggly logging object").Short('n').Required().StringVar(&c.Input.Name) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagServiceIDName, Description: cmd.FlagServiceIDDesc, diff --git a/pkg/commands/logging/loggly/describe.go b/pkg/commands/logging/loggly/describe.go index b7cd22b5b..2a3d9b2ca 100644 --- a/pkg/commands/logging/loggly/describe.go +++ b/pkg/commands/logging/loggly/describe.go @@ -25,10 +25,24 @@ type DescribeCommand struct { // NewDescribeCommand returns a usable command registered under the parent. func NewDescribeCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *DescribeCommand { - var c DescribeCommand - c.Globals = globals - c.manifest = data + c := DescribeCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("describe", "Show detailed information about a Loggly logging endpoint on a Fastly service version").Alias("get") + + // required + c.CmdClause.Flag("name", "The name of the Loggly logging object").Short('n').Required().StringVar(&c.Input.Name) + c.RegisterFlag(cmd.StringFlagOpts{ + Name: cmd.FlagVersionName, + Description: cmd.FlagVersionDesc, + Dst: &c.serviceVersion.Value, + Required: true, + }) + + // optional c.RegisterFlagBool(cmd.BoolFlagOpts{ Name: cmd.FlagJSONName, Description: cmd.FlagJSONDesc, @@ -47,13 +61,6 @@ func NewDescribeCommand(parent cmd.Registerer, globals *config.Data, data manife Description: cmd.FlagServiceDesc, Dst: &c.serviceName.Value, }) - c.RegisterFlag(cmd.StringFlagOpts{ - Name: cmd.FlagVersionName, - Description: cmd.FlagVersionDesc, - Dst: &c.serviceVersion.Value, - Required: true, - }) - c.CmdClause.Flag("name", "The name of the Loggly logging object").Short('n').Required().StringVar(&c.Input.Name) return &c } diff --git a/pkg/commands/logging/loggly/list.go b/pkg/commands/logging/loggly/list.go index 7b0e79c8d..655ec7eb5 100644 --- a/pkg/commands/logging/loggly/list.go +++ b/pkg/commands/logging/loggly/list.go @@ -25,10 +25,23 @@ type ListCommand struct { // NewListCommand returns a usable command registered under the parent. func NewListCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *ListCommand { - var c ListCommand - c.Globals = globals - c.manifest = data + c := ListCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("list", "List Loggly endpoints on a Fastly service version") + + // required + c.RegisterFlag(cmd.StringFlagOpts{ + Name: cmd.FlagVersionName, + Description: cmd.FlagVersionDesc, + Dst: &c.serviceVersion.Value, + Required: true, + }) + + // optional c.RegisterFlagBool(cmd.BoolFlagOpts{ Name: cmd.FlagJSONName, Description: cmd.FlagJSONDesc, @@ -47,12 +60,6 @@ func NewListCommand(parent cmd.Registerer, globals *config.Data, data manifest.D Description: cmd.FlagServiceDesc, Dst: &c.serviceName.Value, }) - c.RegisterFlag(cmd.StringFlagOpts{ - Name: cmd.FlagVersionName, - Description: cmd.FlagVersionDesc, - Dst: &c.serviceVersion.Value, - Required: true, - }) return &c } diff --git a/pkg/commands/logging/loggly/update.go b/pkg/commands/logging/loggly/update.go index 0c2b89a1c..11f145d2a 100644 --- a/pkg/commands/logging/loggly/update.go +++ b/pkg/commands/logging/loggly/update.go @@ -34,21 +34,34 @@ type UpdateCommand struct { // NewUpdateCommand returns a usable command registered under the parent. func NewUpdateCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *UpdateCommand { - var c UpdateCommand - c.Globals = globals - c.Manifest = data + c := UpdateCommand{ + Base: cmd.Base{ + Globals: globals, + }, + Manifest: data, + } c.CmdClause = parent.Command("update", "Update a Loggly logging endpoint on a Fastly service version") + + // required + c.CmdClause.Flag("name", "The name of the Loggly logging object").Short('n').Required().StringVar(&c.EndpointName) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagVersionName, Description: cmd.FlagVersionDesc, Dst: &c.ServiceVersion.Value, Required: true, }) + + // optional c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ Action: c.AutoClone.Set, Dst: &c.AutoClone.Value, }) - c.CmdClause.Flag("name", "The name of the Loggly logging object").Short('n').Required().StringVar(&c.EndpointName) + c.CmdClause.Flag("auth-token", "The token to use for authentication (https://www.loggly.com/docs/customer-token-authentication-token/)").Action(c.Token.Set).StringVar(&c.Token.Value) + common.Format(c.CmdClause, &c.Format) + common.FormatVersion(c.CmdClause, &c.FormatVersion) + c.CmdClause.Flag("new-name", "New name of the Loggly logging object").Action(c.NewName.Set).StringVar(&c.NewName.Value) + common.Placement(c.CmdClause, &c.Placement) + common.ResponseCondition(c.CmdClause, &c.ResponseCondition) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagServiceIDName, Description: cmd.FlagServiceIDDesc, @@ -61,12 +74,6 @@ func NewUpdateCommand(parent cmd.Registerer, globals *config.Data, data manifest Description: cmd.FlagServiceDesc, Dst: &c.ServiceName.Value, }) - c.CmdClause.Flag("new-name", "New name of the Loggly logging object").Action(c.NewName.Set).StringVar(&c.NewName.Value) - c.CmdClause.Flag("auth-token", "The token to use for authentication (https://www.loggly.com/docs/customer-token-authentication-token/)").Action(c.Token.Set).StringVar(&c.Token.Value) - common.Format(c.CmdClause, &c.Format) - common.FormatVersion(c.CmdClause, &c.FormatVersion) - common.ResponseCondition(c.CmdClause, &c.ResponseCondition) - common.Placement(c.CmdClause, &c.Placement) return &c } diff --git a/pkg/commands/logging/logshuttle/create.go b/pkg/commands/logging/logshuttle/create.go index ca4882730..16bcdba54 100644 --- a/pkg/commands/logging/logshuttle/create.go +++ b/pkg/commands/logging/logshuttle/create.go @@ -34,10 +34,15 @@ type CreateCommand struct { // NewCreateCommand returns a usable command registered under the parent. func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *CreateCommand { - var c CreateCommand - c.Globals = globals - c.Manifest = data + c := CreateCommand{ + Base: cmd.Base{ + Globals: globals, + }, + Manifest: data, + } c.CmdClause = parent.Command("create", "Create a Logshuttle logging endpoint on a Fastly service version").Alias("add") + + // required c.CmdClause.Flag("name", "The name of the Logshuttle logging object. Used as a primary key for API access").Short('n').Action(c.EndpointName.Set).StringVar(&c.EndpointName.Value) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagVersionName, @@ -45,12 +50,17 @@ func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest Dst: &c.ServiceVersion.Value, Required: true, }) + + // optional + c.CmdClause.Flag("auth-token", "The data authentication token associated with this endpoint").Action(c.Token.Set).StringVar(&c.Token.Value) c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ Action: c.AutoClone.Set, Dst: &c.AutoClone.Value, }) - c.CmdClause.Flag("url", "Your Log Shuttle endpoint url").Action(c.URL.Set).StringVar(&c.URL.Value) - c.CmdClause.Flag("auth-token", "The data authentication token associated with this endpoint").Action(c.Token.Set).StringVar(&c.Token.Value) + common.Format(c.CmdClause, &c.Format) + common.FormatVersion(c.CmdClause, &c.FormatVersion) + common.ResponseCondition(c.CmdClause, &c.ResponseCondition) + common.Placement(c.CmdClause, &c.Placement) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagServiceIDName, Description: cmd.FlagServiceIDDesc, @@ -63,10 +73,7 @@ func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest Description: cmd.FlagServiceDesc, Dst: &c.ServiceName.Value, }) - common.Format(c.CmdClause, &c.Format) - common.FormatVersion(c.CmdClause, &c.FormatVersion) - common.ResponseCondition(c.CmdClause, &c.ResponseCondition) - common.Placement(c.CmdClause, &c.Placement) + c.CmdClause.Flag("url", "Your Log Shuttle endpoint url").Action(c.URL.Set).StringVar(&c.URL.Value) return &c } diff --git a/pkg/commands/logging/logshuttle/delete.go b/pkg/commands/logging/logshuttle/delete.go index 3c72f2153..57b7a0935 100644 --- a/pkg/commands/logging/logshuttle/delete.go +++ b/pkg/commands/logging/logshuttle/delete.go @@ -23,21 +23,28 @@ type DeleteCommand struct { // NewDeleteCommand returns a usable command registered under the parent. func NewDeleteCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *DeleteCommand { - var c DeleteCommand - c.Globals = globals - c.manifest = data + c := DeleteCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("delete", "Delete a Logshuttle logging endpoint on a Fastly service version").Alias("remove") + + // required + c.CmdClause.Flag("name", "The name of the Logshuttle logging object").Short('n').Required().StringVar(&c.Input.Name) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagVersionName, Description: cmd.FlagVersionDesc, Dst: &c.serviceVersion.Value, Required: true, }) + + // optional c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ Action: c.autoClone.Set, Dst: &c.autoClone.Value, }) - c.CmdClause.Flag("name", "The name of the Logshuttle logging object").Short('n').Required().StringVar(&c.Input.Name) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagServiceIDName, Description: cmd.FlagServiceIDDesc, diff --git a/pkg/commands/logging/logshuttle/describe.go b/pkg/commands/logging/logshuttle/describe.go index cbee1d437..de956acf2 100644 --- a/pkg/commands/logging/logshuttle/describe.go +++ b/pkg/commands/logging/logshuttle/describe.go @@ -25,10 +25,24 @@ type DescribeCommand struct { // NewDescribeCommand returns a usable command registered under the parent. func NewDescribeCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *DescribeCommand { - var c DescribeCommand - c.Globals = globals - c.manifest = data + c := DescribeCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("describe", "Show detailed information about a Logshuttle logging endpoint on a Fastly service version").Alias("get") + + // required + c.CmdClause.Flag("name", "The name of the Logshuttle logging object").Short('n').Required().StringVar(&c.Input.Name) + c.RegisterFlag(cmd.StringFlagOpts{ + Name: cmd.FlagVersionName, + Description: cmd.FlagVersionDesc, + Dst: &c.serviceVersion.Value, + Required: true, + }) + + // optional c.RegisterFlagBool(cmd.BoolFlagOpts{ Name: cmd.FlagJSONName, Description: cmd.FlagJSONDesc, @@ -47,13 +61,6 @@ func NewDescribeCommand(parent cmd.Registerer, globals *config.Data, data manife Description: cmd.FlagServiceDesc, Dst: &c.serviceName.Value, }) - c.RegisterFlag(cmd.StringFlagOpts{ - Name: cmd.FlagVersionName, - Description: cmd.FlagVersionDesc, - Dst: &c.serviceVersion.Value, - Required: true, - }) - c.CmdClause.Flag("name", "The name of the Logshuttle logging object").Short('n').Required().StringVar(&c.Input.Name) return &c } diff --git a/pkg/commands/logging/logshuttle/list.go b/pkg/commands/logging/logshuttle/list.go index c1968ce4f..40e8a13c4 100644 --- a/pkg/commands/logging/logshuttle/list.go +++ b/pkg/commands/logging/logshuttle/list.go @@ -25,10 +25,23 @@ type ListCommand struct { // NewListCommand returns a usable command registered under the parent. func NewListCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *ListCommand { - var c ListCommand - c.Globals = globals - c.manifest = data + c := ListCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("list", "List Logshuttle endpoints on a Fastly service version") + + // required + c.RegisterFlag(cmd.StringFlagOpts{ + Name: cmd.FlagVersionName, + Description: cmd.FlagVersionDesc, + Dst: &c.serviceVersion.Value, + Required: true, + }) + + // optional c.RegisterFlagBool(cmd.BoolFlagOpts{ Name: cmd.FlagJSONName, Description: cmd.FlagJSONDesc, @@ -47,12 +60,6 @@ func NewListCommand(parent cmd.Registerer, globals *config.Data, data manifest.D Description: cmd.FlagServiceDesc, Dst: &c.serviceName.Value, }) - c.RegisterFlag(cmd.StringFlagOpts{ - Name: cmd.FlagVersionName, - Description: cmd.FlagVersionDesc, - Dst: &c.serviceVersion.Value, - Required: true, - }) return &c } diff --git a/pkg/commands/logging/logshuttle/update.go b/pkg/commands/logging/logshuttle/update.go index 9cd6bef68..9a89e67aa 100644 --- a/pkg/commands/logging/logshuttle/update.go +++ b/pkg/commands/logging/logshuttle/update.go @@ -35,21 +35,34 @@ type UpdateCommand struct { // NewUpdateCommand returns a usable command registered under the parent. func NewUpdateCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *UpdateCommand { - var c UpdateCommand - c.Globals = globals - c.Manifest = data + c := UpdateCommand{ + Base: cmd.Base{ + Globals: globals, + }, + Manifest: data, + } c.CmdClause = parent.Command("update", "Update a Logshuttle logging endpoint on a Fastly service version") + + // required + c.CmdClause.Flag("name", "The name of the Logshuttle logging object").Short('n').Required().StringVar(&c.EndpointName) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagVersionName, Description: cmd.FlagVersionDesc, Dst: &c.ServiceVersion.Value, Required: true, }) + + // optional + c.CmdClause.Flag("auth-token", "The data authentication token associated with this endpoint").Action(c.Token.Set).StringVar(&c.Token.Value) c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ Action: c.AutoClone.Set, Dst: &c.AutoClone.Value, }) - c.CmdClause.Flag("name", "The name of the Logshuttle logging object").Short('n').Required().StringVar(&c.EndpointName) + common.Format(c.CmdClause, &c.Format) + common.FormatVersion(c.CmdClause, &c.FormatVersion) + c.CmdClause.Flag("new-name", "New name of the Logshuttle logging object").Action(c.NewName.Set).StringVar(&c.NewName.Value) + common.Placement(c.CmdClause, &c.Placement) + common.ResponseCondition(c.CmdClause, &c.ResponseCondition) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagServiceIDName, Description: cmd.FlagServiceIDDesc, @@ -62,13 +75,7 @@ func NewUpdateCommand(parent cmd.Registerer, globals *config.Data, data manifest Description: cmd.FlagServiceDesc, Dst: &c.ServiceName.Value, }) - c.CmdClause.Flag("new-name", "New name of the Logshuttle logging object").Action(c.NewName.Set).StringVar(&c.NewName.Value) - common.Format(c.CmdClause, &c.Format) - common.FormatVersion(c.CmdClause, &c.FormatVersion) c.CmdClause.Flag("url", "Your Log Shuttle endpoint url").Action(c.URL.Set).StringVar(&c.URL.Value) - c.CmdClause.Flag("auth-token", "The data authentication token associated with this endpoint").Action(c.Token.Set).StringVar(&c.Token.Value) - common.ResponseCondition(c.CmdClause, &c.ResponseCondition) - common.Placement(c.CmdClause, &c.Placement) return &c } diff --git a/pkg/commands/logging/newrelic/create.go b/pkg/commands/logging/newrelic/create.go index 92325ce96..14903be8a 100644 --- a/pkg/commands/logging/newrelic/create.go +++ b/pkg/commands/logging/newrelic/create.go @@ -34,13 +34,15 @@ type CreateCommand struct { // NewCreateCommand returns a usable command registered under the parent. func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *CreateCommand { - var c CreateCommand + c := CreateCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("create", "Create an New Relic logging endpoint attached to the specified service version").Alias("add") - c.Globals = globals - c.manifest = data - // Required flags - c.CmdClause.Flag("key", "The Insert API key from the Account page of your New Relic account").Action(c.key.Set).StringVar(&c.key.Value) + // required c.CmdClause.Flag("name", "The name for the real-time logging configuration").Action(c.name.Set).StringVar(&c.name.Value) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagVersionName, @@ -49,13 +51,14 @@ func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest Required: true, }) - // Optional flags + // optional c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ Action: c.autoClone.Set, Dst: &c.autoClone.Value, }) common.Format(c.CmdClause, &c.format) common.FormatVersion(c.CmdClause, &c.formatVersion) + c.CmdClause.Flag("key", "The Insert API key from the Account page of your New Relic account").Action(c.key.Set).StringVar(&c.key.Value) c.CmdClause.Flag("placement", "Where in the generated VCL the logging call should be placed").Action(c.placement.Set).StringVar(&c.placement.Value) c.CmdClause.Flag("region", "The region to which to stream logs").Action(c.region.Set).StringVar(&c.region.Value) c.CmdClause.Flag("response-condition", "The name of an existing condition in the configured endpoint").Action(c.responseCondition.Set).StringVar(&c.responseCondition.Value) diff --git a/pkg/commands/logging/newrelic/delete.go b/pkg/commands/logging/newrelic/delete.go index b2f3b6408..eef60b764 100644 --- a/pkg/commands/logging/newrelic/delete.go +++ b/pkg/commands/logging/newrelic/delete.go @@ -13,12 +13,15 @@ import ( // NewDeleteCommand returns a usable command registered under the parent. func NewDeleteCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *DeleteCommand { - var c DeleteCommand + c := DeleteCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("delete", "Delete the New Relic Logs logging object for a particular service and version").Alias("remove") - c.Globals = globals - c.manifest = data - // Required flags + // required c.CmdClause.Flag("name", "The name for the real-time logging configuration to delete").Required().StringVar(&c.name) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagVersionName, @@ -27,7 +30,7 @@ func NewDeleteCommand(parent cmd.Registerer, globals *config.Data, data manifest Required: true, }) - // Optional flags + // optional c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ Action: c.autoClone.Set, Dst: &c.autoClone.Value, diff --git a/pkg/commands/logging/newrelic/describe.go b/pkg/commands/logging/newrelic/describe.go index 0fe407999..1b007758c 100644 --- a/pkg/commands/logging/newrelic/describe.go +++ b/pkg/commands/logging/newrelic/describe.go @@ -15,12 +15,15 @@ import ( // NewDescribeCommand returns a usable command registered under the parent. func NewDescribeCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *DescribeCommand { - var c DescribeCommand + c := DescribeCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("describe", "Get the details of a New Relic Logs logging object for a particular service and version").Alias("get") - c.Globals = globals - c.manifest = data - // Required flags + // required c.CmdClause.Flag("name", "The name for the real-time logging configuration").Required().StringVar(&c.name) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagVersionName, @@ -29,7 +32,7 @@ func NewDescribeCommand(parent cmd.Registerer, globals *config.Data, data manife Required: true, }) - // Optional Flags + // optional c.RegisterFlagBool(cmd.BoolFlagOpts{ Name: cmd.FlagJSONName, Description: cmd.FlagJSONDesc, diff --git a/pkg/commands/logging/newrelic/list.go b/pkg/commands/logging/newrelic/list.go index 32f92cdd1..acca1e0fc 100644 --- a/pkg/commands/logging/newrelic/list.go +++ b/pkg/commands/logging/newrelic/list.go @@ -15,12 +15,15 @@ import ( // NewListCommand returns a usable command registered under the parent. func NewListCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *ListCommand { - var c ListCommand + c := ListCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("list", "List all of the New Relic Logs logging objects for a particular service and version") - c.Globals = globals - c.manifest = data - // Required flags + // required c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagVersionName, Description: cmd.FlagVersionDesc, @@ -28,7 +31,7 @@ func NewListCommand(parent cmd.Registerer, globals *config.Data, data manifest.D Required: true, }) - // Optional Flags + // optional c.RegisterFlagBool(cmd.BoolFlagOpts{ Name: cmd.FlagJSONName, Description: cmd.FlagJSONDesc, diff --git a/pkg/commands/logging/newrelic/update.go b/pkg/commands/logging/newrelic/update.go index b0843a1dd..df3896d9f 100644 --- a/pkg/commands/logging/newrelic/update.go +++ b/pkg/commands/logging/newrelic/update.go @@ -34,12 +34,15 @@ type UpdateCommand struct { // NewUpdateCommand returns a usable command registered under the parent. func NewUpdateCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *UpdateCommand { - var c UpdateCommand + c := UpdateCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("update", "Update a New Relic Logs logging object for a particular service and version") - c.Globals = globals - c.manifest = data - // Required flags + // required c.CmdClause.Flag("name", "The name for the real-time logging configuration to update").Required().StringVar(&c.endpointName) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagVersionName, @@ -48,7 +51,7 @@ func NewUpdateCommand(parent cmd.Registerer, globals *config.Data, data manifest Required: true, }) - // Optional flags + // optional c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ Action: c.autoClone.Set, Dst: &c.autoClone.Value, diff --git a/pkg/commands/logging/openstack/create.go b/pkg/commands/logging/openstack/create.go index 4bc108d8c..c6b5d109c 100644 --- a/pkg/commands/logging/openstack/create.go +++ b/pkg/commands/logging/openstack/create.go @@ -44,10 +44,15 @@ type CreateCommand struct { // NewCreateCommand returns a usable command registered under the parent. func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *CreateCommand { - var c CreateCommand - c.Globals = globals - c.Manifest = data + c := CreateCommand{ + Base: cmd.Base{ + Globals: globals, + }, + Manifest: data, + } c.CmdClause = parent.Command("create", "Create an OpenStack logging endpoint on a Fastly service version").Alias("add") + + // required c.CmdClause.Flag("name", "The name of the OpenStack logging object. Used as a primary key for API access").Short('n').Action(c.EndpointName.Set).StringVar(&c.EndpointName.Value) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagVersionName, @@ -55,14 +60,25 @@ func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest Dst: &c.ServiceVersion.Value, Required: true, }) + + // optional + c.CmdClause.Flag("access-key", "Your OpenStack account access key").Action(c.AccessKey.Set).StringVar(&c.AccessKey.Value) c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ Action: c.AutoClone.Set, Dst: &c.AutoClone.Value, }) c.CmdClause.Flag("bucket", "The name of your OpenStack container").Action(c.BucketName.Set).StringVar(&c.BucketName.Value) - c.CmdClause.Flag("access-key", "Your OpenStack account access key").Action(c.AccessKey.Set).StringVar(&c.AccessKey.Value) - c.CmdClause.Flag("user", "The username for your OpenStack account").Action(c.User.Set).StringVar(&c.User.Value) - c.CmdClause.Flag("url", "Your OpenStack auth url").Action(c.URL.Set).StringVar(&c.URL.Value) + common.CompressionCodec(c.CmdClause, &c.CompressionCodec) + common.Format(c.CmdClause, &c.Format) + common.FormatVersion(c.CmdClause, &c.FormatVersion) + common.GzipLevel(c.CmdClause, &c.GzipLevel) + common.MessageType(c.CmdClause, &c.MessageType) + common.Path(c.CmdClause, &c.Path) + common.Period(c.CmdClause, &c.Period) + common.Placement(c.CmdClause, &c.Placement) + common.PublicKey(c.CmdClause, &c.PublicKey) + common.ResponseCondition(c.CmdClause, &c.ResponseCondition) + common.TimestampFormat(c.CmdClause, &c.TimestampFormat) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagServiceIDName, Description: cmd.FlagServiceIDDesc, @@ -75,17 +91,8 @@ func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest Description: cmd.FlagServiceDesc, Dst: &c.ServiceName.Value, }) - common.PublicKey(c.CmdClause, &c.PublicKey) - common.Path(c.CmdClause, &c.Path) - common.Period(c.CmdClause, &c.Period) - common.GzipLevel(c.CmdClause, &c.GzipLevel) - common.Format(c.CmdClause, &c.Format) - common.MessageType(c.CmdClause, &c.MessageType) - common.FormatVersion(c.CmdClause, &c.FormatVersion) - common.ResponseCondition(c.CmdClause, &c.ResponseCondition) - common.TimestampFormat(c.CmdClause, &c.TimestampFormat) - common.Placement(c.CmdClause, &c.Placement) - common.CompressionCodec(c.CmdClause, &c.CompressionCodec) + c.CmdClause.Flag("url", "Your OpenStack auth url").Action(c.URL.Set).StringVar(&c.URL.Value) + c.CmdClause.Flag("user", "The username for your OpenStack account").Action(c.User.Set).StringVar(&c.User.Value) return &c } diff --git a/pkg/commands/logging/openstack/delete.go b/pkg/commands/logging/openstack/delete.go index 70a3e3f28..17252afa0 100644 --- a/pkg/commands/logging/openstack/delete.go +++ b/pkg/commands/logging/openstack/delete.go @@ -23,21 +23,28 @@ type DeleteCommand struct { // NewDeleteCommand returns a usable command registered under the parent. func NewDeleteCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *DeleteCommand { - var c DeleteCommand - c.Globals = globals - c.manifest = data + c := DeleteCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("delete", "Delete an OpenStack logging endpoint on a Fastly service version").Alias("remove") + + // required + c.CmdClause.Flag("name", "The name of the OpenStack logging object").Short('n').Required().StringVar(&c.Input.Name) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagVersionName, Description: cmd.FlagVersionDesc, Dst: &c.serviceVersion.Value, Required: true, }) + + // optional c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ Action: c.autoClone.Set, Dst: &c.autoClone.Value, }) - c.CmdClause.Flag("name", "The name of the OpenStack logging object").Short('n').Required().StringVar(&c.Input.Name) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagServiceIDName, Description: cmd.FlagServiceIDDesc, diff --git a/pkg/commands/logging/openstack/describe.go b/pkg/commands/logging/openstack/describe.go index 671b462bb..0c3413ed5 100644 --- a/pkg/commands/logging/openstack/describe.go +++ b/pkg/commands/logging/openstack/describe.go @@ -25,10 +25,24 @@ type DescribeCommand struct { // NewDescribeCommand returns a usable command registered under the parent. func NewDescribeCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *DescribeCommand { - var c DescribeCommand - c.Globals = globals - c.manifest = data + c := DescribeCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("describe", "Show detailed information about an OpenStack logging endpoint on a Fastly service version").Alias("get") + + // required + c.CmdClause.Flag("name", "The name of the OpenStack logging object").Short('n').Required().StringVar(&c.Input.Name) + c.RegisterFlag(cmd.StringFlagOpts{ + Name: cmd.FlagVersionName, + Description: cmd.FlagVersionDesc, + Dst: &c.serviceVersion.Value, + Required: true, + }) + + // optional c.RegisterFlagBool(cmd.BoolFlagOpts{ Name: cmd.FlagJSONName, Description: cmd.FlagJSONDesc, @@ -47,13 +61,6 @@ func NewDescribeCommand(parent cmd.Registerer, globals *config.Data, data manife Description: cmd.FlagServiceDesc, Dst: &c.serviceName.Value, }) - c.RegisterFlag(cmd.StringFlagOpts{ - Name: cmd.FlagVersionName, - Description: cmd.FlagVersionDesc, - Dst: &c.serviceVersion.Value, - Required: true, - }) - c.CmdClause.Flag("name", "The name of the OpenStack logging object").Short('n').Required().StringVar(&c.Input.Name) return &c } diff --git a/pkg/commands/logging/openstack/list.go b/pkg/commands/logging/openstack/list.go index 0971b8df6..8a5be9c40 100644 --- a/pkg/commands/logging/openstack/list.go +++ b/pkg/commands/logging/openstack/list.go @@ -25,10 +25,23 @@ type ListCommand struct { // NewListCommand returns a usable command registered under the parent. func NewListCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *ListCommand { - var c ListCommand - c.Globals = globals - c.manifest = data + c := ListCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("list", "List OpenStack logging endpoints on a Fastly service version") + + // required + c.RegisterFlag(cmd.StringFlagOpts{ + Name: cmd.FlagVersionName, + Description: cmd.FlagVersionDesc, + Dst: &c.serviceVersion.Value, + Required: true, + }) + + // optional c.RegisterFlagBool(cmd.BoolFlagOpts{ Name: cmd.FlagJSONName, Description: cmd.FlagJSONDesc, @@ -47,12 +60,6 @@ func NewListCommand(parent cmd.Registerer, globals *config.Data, data manifest.D Description: cmd.FlagServiceDesc, Dst: &c.serviceName.Value, }) - c.RegisterFlag(cmd.StringFlagOpts{ - Name: cmd.FlagVersionName, - Description: cmd.FlagVersionDesc, - Dst: &c.serviceVersion.Value, - Required: true, - }) return &c } diff --git a/pkg/commands/logging/openstack/update.go b/pkg/commands/logging/openstack/update.go index 7a014be79..7c4a8b320 100644 --- a/pkg/commands/logging/openstack/update.go +++ b/pkg/commands/logging/openstack/update.go @@ -44,23 +44,41 @@ type UpdateCommand struct { // NewUpdateCommand returns a usable command registered under the parent. func NewUpdateCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *UpdateCommand { - var c UpdateCommand - c.Globals = globals - c.Manifest = data + c := UpdateCommand{ + Base: cmd.Base{ + Globals: globals, + }, + Manifest: data, + } c.CmdClause = parent.Command("update", "Update an OpenStack logging endpoint on a Fastly service version") + // required + c.CmdClause.Flag("name", "The name of the OpenStack logging object").Short('n').Required().StringVar(&c.EndpointName) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagVersionName, Description: cmd.FlagVersionDesc, Dst: &c.ServiceVersion.Value, Required: true, }) + + // optional c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ Action: c.AutoClone.Set, Dst: &c.AutoClone.Value, }) - c.CmdClause.Flag("name", "The name of the OpenStack logging object").Short('n').Required().StringVar(&c.EndpointName) - + c.CmdClause.Flag("access-key", "Your OpenStack account access key").Action(c.AccessKey.Set).StringVar(&c.AccessKey.Value) + c.CmdClause.Flag("bucket", "The name of the Openstack Space").Action(c.BucketName.Set).StringVar(&c.BucketName.Value) + common.CompressionCodec(c.CmdClause, &c.CompressionCodec) + common.Format(c.CmdClause, &c.Format) + common.FormatVersion(c.CmdClause, &c.FormatVersion) + common.GzipLevel(c.CmdClause, &c.GzipLevel) + common.MessageType(c.CmdClause, &c.MessageType) + c.CmdClause.Flag("new-name", "New name of the OpenStack logging object").Action(c.NewName.Set).StringVar(&c.NewName.Value) + common.Path(c.CmdClause, &c.Path) + common.Period(c.CmdClause, &c.Period) + common.Placement(c.CmdClause, &c.Placement) + common.PublicKey(c.CmdClause, &c.PublicKey) + common.ResponseCondition(c.CmdClause, &c.ResponseCondition) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagServiceIDName, Description: cmd.FlagServiceIDDesc, @@ -73,22 +91,9 @@ func NewUpdateCommand(parent cmd.Registerer, globals *config.Data, data manifest Description: cmd.FlagServiceDesc, Dst: &c.ServiceName.Value, }) - c.CmdClause.Flag("new-name", "New name of the OpenStack logging object").Action(c.NewName.Set).StringVar(&c.NewName.Value) - c.CmdClause.Flag("bucket", "The name of the Openstack Space").Action(c.BucketName.Set).StringVar(&c.BucketName.Value) - c.CmdClause.Flag("access-key", "Your OpenStack account access key").Action(c.AccessKey.Set).StringVar(&c.AccessKey.Value) - c.CmdClause.Flag("user", "The username for your OpenStack account.").Action(c.User.Set).StringVar(&c.User.Value) - c.CmdClause.Flag("url", "Your OpenStack auth url.").Action(c.URL.Set).StringVar(&c.URL.Value) - common.Path(c.CmdClause, &c.Path) - common.Period(c.CmdClause, &c.Period) - common.GzipLevel(c.CmdClause, &c.GzipLevel) - common.Format(c.CmdClause, &c.Format) - common.FormatVersion(c.CmdClause, &c.FormatVersion) - common.ResponseCondition(c.CmdClause, &c.ResponseCondition) - common.MessageType(c.CmdClause, &c.MessageType) common.TimestampFormat(c.CmdClause, &c.TimestampFormat) - common.Placement(c.CmdClause, &c.Placement) - common.PublicKey(c.CmdClause, &c.PublicKey) - common.CompressionCodec(c.CmdClause, &c.CompressionCodec) + c.CmdClause.Flag("url", "Your OpenStack auth url.").Action(c.URL.Set).StringVar(&c.URL.Value) + c.CmdClause.Flag("user", "The username for your OpenStack account.").Action(c.User.Set).StringVar(&c.User.Value) return &c } diff --git a/pkg/commands/logging/papertrail/create.go b/pkg/commands/logging/papertrail/create.go index e0a323499..8141672aa 100644 --- a/pkg/commands/logging/papertrail/create.go +++ b/pkg/commands/logging/papertrail/create.go @@ -34,10 +34,15 @@ type CreateCommand struct { // NewCreateCommand returns a usable command registered under the parent. func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *CreateCommand { - var c CreateCommand - c.Globals = globals - c.Manifest = data + c := CreateCommand{ + Base: cmd.Base{ + Globals: globals, + }, + Manifest: data, + } c.CmdClause = parent.Command("create", "Create a Papertrail logging endpoint on a Fastly service version").Alias("add") + + // required c.CmdClause.Flag("name", "The name of the Papertrail logging object. Used as a primary key for API access").Short('n').Action(c.EndpointName.Set).StringVar(&c.EndpointName.Value) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagVersionName, @@ -45,11 +50,18 @@ func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest Dst: &c.ServiceVersion.Value, Required: true, }) + + // optional + c.CmdClause.Flag("address", "A hostname or IPv4 address").Action(c.Address.Set).StringVar(&c.Address.Value) c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ Action: c.AutoClone.Set, Dst: &c.AutoClone.Value, }) - c.CmdClause.Flag("address", "A hostname or IPv4 address").Action(c.Address.Set).StringVar(&c.Address.Value) + common.FormatVersion(c.CmdClause, &c.FormatVersion) + common.Format(c.CmdClause, &c.Format) + common.Placement(c.CmdClause, &c.Placement) + c.CmdClause.Flag("port", "The port number").Action(c.Port.Set).IntVar(&c.Port.Value) + common.ResponseCondition(c.CmdClause, &c.ResponseCondition) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagServiceIDName, Description: cmd.FlagServiceIDDesc, @@ -62,11 +74,6 @@ func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest Description: cmd.FlagServiceDesc, Dst: &c.ServiceName.Value, }) - c.CmdClause.Flag("port", "The port number").Action(c.Port.Set).IntVar(&c.Port.Value) - common.FormatVersion(c.CmdClause, &c.FormatVersion) - common.Format(c.CmdClause, &c.Format) - common.ResponseCondition(c.CmdClause, &c.ResponseCondition) - common.Placement(c.CmdClause, &c.Placement) return &c } diff --git a/pkg/commands/logging/papertrail/delete.go b/pkg/commands/logging/papertrail/delete.go index 7eb491485..501b5baab 100644 --- a/pkg/commands/logging/papertrail/delete.go +++ b/pkg/commands/logging/papertrail/delete.go @@ -23,21 +23,28 @@ type DeleteCommand struct { // NewDeleteCommand returns a usable command registered under the parent. func NewDeleteCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *DeleteCommand { - var c DeleteCommand - c.Globals = globals - c.manifest = data + c := DeleteCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("delete", "Delete a Papertrail logging endpoint on a Fastly service version").Alias("remove") + + // required + c.CmdClause.Flag("name", "The name of the Papertrail logging object").Short('n').Required().StringVar(&c.Input.Name) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagVersionName, Description: cmd.FlagVersionDesc, Dst: &c.serviceVersion.Value, Required: true, }) + + // optional c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ Action: c.autoClone.Set, Dst: &c.autoClone.Value, }) - c.CmdClause.Flag("name", "The name of the Papertrail logging object").Short('n').Required().StringVar(&c.Input.Name) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagServiceIDName, Description: cmd.FlagServiceIDDesc, diff --git a/pkg/commands/logging/papertrail/describe.go b/pkg/commands/logging/papertrail/describe.go index fdcddb587..e4e700a19 100644 --- a/pkg/commands/logging/papertrail/describe.go +++ b/pkg/commands/logging/papertrail/describe.go @@ -25,10 +25,24 @@ type DescribeCommand struct { // NewDescribeCommand returns a usable command registered under the parent. func NewDescribeCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *DescribeCommand { - var c DescribeCommand - c.Globals = globals - c.manifest = data + c := DescribeCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("describe", "Show detailed information about a Papertrail logging endpoint on a Fastly service version").Alias("get") + + // required + c.CmdClause.Flag("name", "The name of the Papertrail logging object").Short('n').Required().StringVar(&c.Input.Name) + c.RegisterFlag(cmd.StringFlagOpts{ + Name: cmd.FlagVersionName, + Description: cmd.FlagVersionDesc, + Dst: &c.serviceVersion.Value, + Required: true, + }) + + // optional c.RegisterFlagBool(cmd.BoolFlagOpts{ Name: cmd.FlagJSONName, Description: cmd.FlagJSONDesc, @@ -47,13 +61,6 @@ func NewDescribeCommand(parent cmd.Registerer, globals *config.Data, data manife Description: cmd.FlagServiceDesc, Dst: &c.serviceName.Value, }) - c.RegisterFlag(cmd.StringFlagOpts{ - Name: cmd.FlagVersionName, - Description: cmd.FlagVersionDesc, - Dst: &c.serviceVersion.Value, - Required: true, - }) - c.CmdClause.Flag("name", "The name of the Papertrail logging object").Short('n').Required().StringVar(&c.Input.Name) return &c } diff --git a/pkg/commands/logging/papertrail/list.go b/pkg/commands/logging/papertrail/list.go index c02aaa93d..af917d29e 100644 --- a/pkg/commands/logging/papertrail/list.go +++ b/pkg/commands/logging/papertrail/list.go @@ -25,10 +25,23 @@ type ListCommand struct { // NewListCommand returns a usable command registered under the parent. func NewListCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *ListCommand { - var c ListCommand - c.Globals = globals - c.manifest = data + c := ListCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("list", "List Papertrail endpoints on a Fastly service version") + + // required + c.RegisterFlag(cmd.StringFlagOpts{ + Name: cmd.FlagVersionName, + Description: cmd.FlagVersionDesc, + Dst: &c.serviceVersion.Value, + Required: true, + }) + + // optional c.RegisterFlagBool(cmd.BoolFlagOpts{ Name: cmd.FlagJSONName, Description: cmd.FlagJSONDesc, @@ -47,12 +60,6 @@ func NewListCommand(parent cmd.Registerer, globals *config.Data, data manifest.D Description: cmd.FlagServiceDesc, Dst: &c.serviceName.Value, }) - c.RegisterFlag(cmd.StringFlagOpts{ - Name: cmd.FlagVersionName, - Description: cmd.FlagVersionDesc, - Dst: &c.serviceVersion.Value, - Required: true, - }) return &c } diff --git a/pkg/commands/logging/papertrail/update.go b/pkg/commands/logging/papertrail/update.go index 61a86abd5..719fd103a 100644 --- a/pkg/commands/logging/papertrail/update.go +++ b/pkg/commands/logging/papertrail/update.go @@ -35,21 +35,35 @@ type UpdateCommand struct { // NewUpdateCommand returns a usable command registered under the parent. func NewUpdateCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *UpdateCommand { - var c UpdateCommand - c.Globals = globals - c.Manifest = data + c := UpdateCommand{ + Base: cmd.Base{ + Globals: globals, + }, + Manifest: data, + } c.CmdClause = parent.Command("update", "Update a Papertrail logging endpoint on a Fastly service version") + + // required + c.CmdClause.Flag("name", "The name of the Papertrail logging object").Short('n').Required().StringVar(&c.EndpointName) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagVersionName, Description: cmd.FlagVersionDesc, Dst: &c.ServiceVersion.Value, Required: true, }) + + // optional c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ Action: c.AutoClone.Set, Dst: &c.AutoClone.Value, }) - c.CmdClause.Flag("name", "The name of the Papertrail logging object").Short('n').Required().StringVar(&c.EndpointName) + c.CmdClause.Flag("address", "A hostname or IPv4 address").Action(c.Address.Set).StringVar(&c.Address.Value) + common.Format(c.CmdClause, &c.Format) + common.FormatVersion(c.CmdClause, &c.FormatVersion) + c.CmdClause.Flag("new-name", "New name of the Papertrail logging object").Action(c.NewName.Set).StringVar(&c.NewName.Value) + common.Placement(c.CmdClause, &c.Placement) + c.CmdClause.Flag("port", "The port number").Action(c.Port.Set).IntVar(&c.Port.Value) + common.ResponseCondition(c.CmdClause, &c.ResponseCondition) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagServiceIDName, Description: cmd.FlagServiceIDDesc, @@ -62,13 +76,6 @@ func NewUpdateCommand(parent cmd.Registerer, globals *config.Data, data manifest Description: cmd.FlagServiceDesc, Dst: &c.ServiceName.Value, }) - c.CmdClause.Flag("new-name", "New name of the Papertrail logging object").Action(c.NewName.Set).StringVar(&c.NewName.Value) - c.CmdClause.Flag("address", "A hostname or IPv4 address").Action(c.Address.Set).StringVar(&c.Address.Value) - c.CmdClause.Flag("port", "The port number").Action(c.Port.Set).IntVar(&c.Port.Value) - common.FormatVersion(c.CmdClause, &c.FormatVersion) - common.Format(c.CmdClause, &c.Format) - common.ResponseCondition(c.CmdClause, &c.ResponseCondition) - common.Placement(c.CmdClause, &c.Placement) return &c } diff --git a/pkg/commands/logging/s3/create.go b/pkg/commands/logging/s3/create.go index 137e911a8..91615b9cc 100644 --- a/pkg/commands/logging/s3/create.go +++ b/pkg/commands/logging/s3/create.go @@ -51,10 +51,15 @@ type CreateCommand struct { // NewCreateCommand returns a usable command registered under the parent. func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *CreateCommand { - var c CreateCommand - c.Globals = globals - c.Manifest = data + c := CreateCommand{ + Base: cmd.Base{ + Globals: globals, + }, + Manifest: data, + } c.CmdClause = parent.Command("create", "Create an Amazon S3 logging endpoint on a Fastly service version").Alias("add") + + // required c.CmdClause.Flag("name", "The name of the S3 logging object. Used as a primary key for API access").Short('n').Action(c.EndpointName.Set).StringVar(&c.EndpointName.Value) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagVersionName, @@ -62,14 +67,30 @@ func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest Dst: &c.ServiceVersion.Value, Required: true, }) + + // optional c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ Action: c.AutoClone.Set, Dst: &c.AutoClone.Value, }) - c.CmdClause.Flag("bucket", "Your S3 bucket name").Action(c.BucketName.Set).StringVar(&c.BucketName.Value) c.CmdClause.Flag("access-key", "Your S3 account access key").Action(c.AccessKey.Set).StringVar(&c.AccessKey.Value) - c.CmdClause.Flag("secret-key", "Your S3 account secret key").Action(c.SecretKey.Set).StringVar(&c.SecretKey.Value) + c.CmdClause.Flag("bucket", "Your S3 bucket name").Action(c.BucketName.Set).StringVar(&c.BucketName.Value) + common.CompressionCodec(c.CmdClause, &c.CompressionCodec) + c.CmdClause.Flag("domain", "The domain of the S3 endpoint").Action(c.Domain.Set).StringVar(&c.Domain.Value) + common.Format(c.CmdClause, &c.Format) + common.FormatVersion(c.CmdClause, &c.FormatVersion) + common.GzipLevel(c.CmdClause, &c.GzipLevel) c.CmdClause.Flag("iam-role", "The IAM role ARN for logging").Action(c.IAMRole.Set).StringVar(&c.IAMRole.Value) + common.MessageType(c.CmdClause, &c.MessageType) + common.Path(c.CmdClause, &c.Path) + common.Period(c.CmdClause, &c.Period) + common.Placement(c.CmdClause, &c.Placement) + common.PublicKey(c.CmdClause, &c.PublicKey) + c.CmdClause.Flag("redundancy", "The S3 storage class. One of: standard, intelligent_tiering, standard_ia, onezone_ia, glacier, glacier_ir, deep_archive, or reduced_redundancy").Action(c.Redundancy.Set).EnumVar(&c.Redundancy.Value, string(fastly.S3RedundancyStandard), string(fastly.S3RedundancyIntelligentTiering), string(fastly.S3RedundancyStandardIA), string(fastly.S3RedundancyOneZoneIA), string(fastly.S3RedundancyGlacierFlexibleRetrieval), string(fastly.S3RedundancyGlacierInstantRetrieval), string(fastly.S3RedundancyGlacierDeepArchive), string(fastly.S3RedundancyReduced)) + common.ResponseCondition(c.CmdClause, &c.ResponseCondition) + c.CmdClause.Flag("secret-key", "Your S3 account secret key").Action(c.SecretKey.Set).StringVar(&c.SecretKey.Value) + c.CmdClause.Flag("server-side-encryption", "Set to enable S3 Server Side Encryption. Can be either AES256 or aws:kms").Action(c.ServerSideEncryption.Set).EnumVar(&c.ServerSideEncryption.Value, string(fastly.S3ServerSideEncryptionAES), string(fastly.S3ServerSideEncryptionKMS)) + c.CmdClause.Flag("server-side-encryption-kms-key-id", "Server-side KMS Key ID. Must be set if server-side-encryption is set to aws:kms").Action(c.ServerSideEncryptionKMSKeyID.Set).StringVar(&c.ServerSideEncryptionKMSKeyID.Value) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagServiceIDName, Description: cmd.FlagServiceIDDesc, @@ -82,21 +103,7 @@ func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest Description: cmd.FlagServiceDesc, Dst: &c.ServiceName.Value, }) - c.CmdClause.Flag("domain", "The domain of the S3 endpoint").Action(c.Domain.Set).StringVar(&c.Domain.Value) - common.Path(c.CmdClause, &c.Path) - common.Period(c.CmdClause, &c.Period) - common.GzipLevel(c.CmdClause, &c.GzipLevel) - common.Format(c.CmdClause, &c.Format) - common.FormatVersion(c.CmdClause, &c.FormatVersion) - common.MessageType(c.CmdClause, &c.MessageType) - common.ResponseCondition(c.CmdClause, &c.ResponseCondition) common.TimestampFormat(c.CmdClause, &c.TimestampFormat) - c.CmdClause.Flag("redundancy", "The S3 storage class. One of: standard, intelligent_tiering, standard_ia, onezone_ia, glacier, glacier_ir, deep_archive, or reduced_redundancy").Action(c.Redundancy.Set).EnumVar(&c.Redundancy.Value, string(fastly.S3RedundancyStandard), string(fastly.S3RedundancyIntelligentTiering), string(fastly.S3RedundancyStandardIA), string(fastly.S3RedundancyOneZoneIA), string(fastly.S3RedundancyGlacierFlexibleRetrieval), string(fastly.S3RedundancyGlacierInstantRetrieval), string(fastly.S3RedundancyGlacierDeepArchive), string(fastly.S3RedundancyReduced)) - common.Placement(c.CmdClause, &c.Placement) - common.PublicKey(c.CmdClause, &c.PublicKey) - c.CmdClause.Flag("server-side-encryption", "Set to enable S3 Server Side Encryption. Can be either AES256 or aws:kms").Action(c.ServerSideEncryption.Set).EnumVar(&c.ServerSideEncryption.Value, string(fastly.S3ServerSideEncryptionAES), string(fastly.S3ServerSideEncryptionKMS)) - c.CmdClause.Flag("server-side-encryption-kms-key-id", "Server-side KMS Key ID. Must be set if server-side-encryption is set to aws:kms").Action(c.ServerSideEncryptionKMSKeyID.Set).StringVar(&c.ServerSideEncryptionKMSKeyID.Value) - common.CompressionCodec(c.CmdClause, &c.CompressionCodec) return &c } diff --git a/pkg/commands/logging/s3/delete.go b/pkg/commands/logging/s3/delete.go index aaa37cbbd..e67977abc 100644 --- a/pkg/commands/logging/s3/delete.go +++ b/pkg/commands/logging/s3/delete.go @@ -23,21 +23,28 @@ type DeleteCommand struct { // NewDeleteCommand returns a usable command registered under the parent. func NewDeleteCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *DeleteCommand { - var c DeleteCommand - c.Globals = globals - c.manifest = data + c := DeleteCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("delete", "Delete a S3 logging endpoint on a Fastly service version").Alias("remove") + + // required + c.CmdClause.Flag("name", "The name of the S3 logging object").Short('n').Required().StringVar(&c.Input.Name) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagVersionName, Description: cmd.FlagVersionDesc, Dst: &c.serviceVersion.Value, Required: true, }) + + // optional c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ Action: c.autoClone.Set, Dst: &c.autoClone.Value, }) - c.CmdClause.Flag("name", "The name of the S3 logging object").Short('n').Required().StringVar(&c.Input.Name) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagServiceIDName, Description: cmd.FlagServiceIDDesc, diff --git a/pkg/commands/logging/s3/describe.go b/pkg/commands/logging/s3/describe.go index 283b6920d..3c15924b9 100644 --- a/pkg/commands/logging/s3/describe.go +++ b/pkg/commands/logging/s3/describe.go @@ -25,10 +25,24 @@ type DescribeCommand struct { // NewDescribeCommand returns a usable command registered under the parent. func NewDescribeCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *DescribeCommand { - var c DescribeCommand - c.Globals = globals - c.manifest = data + c := DescribeCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("describe", "Show detailed information about a S3 logging endpoint on a Fastly service version").Alias("get") + + // required + c.CmdClause.Flag("name", "The name of the S3 logging object").Short('n').Required().StringVar(&c.Input.Name) + c.RegisterFlag(cmd.StringFlagOpts{ + Name: cmd.FlagVersionName, + Description: cmd.FlagVersionDesc, + Dst: &c.serviceVersion.Value, + Required: true, + }) + + // optional c.RegisterFlagBool(cmd.BoolFlagOpts{ Name: cmd.FlagJSONName, Description: cmd.FlagJSONDesc, @@ -47,13 +61,6 @@ func NewDescribeCommand(parent cmd.Registerer, globals *config.Data, data manife Description: cmd.FlagServiceDesc, Dst: &c.serviceName.Value, }) - c.RegisterFlag(cmd.StringFlagOpts{ - Name: cmd.FlagVersionName, - Description: cmd.FlagVersionDesc, - Dst: &c.serviceVersion.Value, - Required: true, - }) - c.CmdClause.Flag("name", "The name of the S3 logging object").Short('n').Required().StringVar(&c.Input.Name) return &c } diff --git a/pkg/commands/logging/s3/list.go b/pkg/commands/logging/s3/list.go index c5c5bbb0e..a7a538979 100644 --- a/pkg/commands/logging/s3/list.go +++ b/pkg/commands/logging/s3/list.go @@ -25,10 +25,23 @@ type ListCommand struct { // NewListCommand returns a usable command registered under the parent. func NewListCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *ListCommand { - var c ListCommand - c.Globals = globals - c.manifest = data + c := ListCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("list", "List S3 endpoints on a Fastly service version") + + // required + c.RegisterFlag(cmd.StringFlagOpts{ + Name: cmd.FlagVersionName, + Description: cmd.FlagVersionDesc, + Dst: &c.serviceVersion.Value, + Required: true, + }) + + // optional c.RegisterFlagBool(cmd.BoolFlagOpts{ Name: cmd.FlagJSONName, Description: cmd.FlagJSONDesc, @@ -47,12 +60,6 @@ func NewListCommand(parent cmd.Registerer, globals *config.Data, data manifest.D Description: cmd.FlagServiceDesc, Dst: &c.serviceName.Value, }) - c.RegisterFlag(cmd.StringFlagOpts{ - Name: cmd.FlagVersionName, - Description: cmd.FlagVersionDesc, - Dst: &c.serviceVersion.Value, - Required: true, - }) return &c } diff --git a/pkg/commands/logging/s3/update.go b/pkg/commands/logging/s3/update.go index 79207e8d1..639dfd8e5 100644 --- a/pkg/commands/logging/s3/update.go +++ b/pkg/commands/logging/s3/update.go @@ -49,21 +49,47 @@ type UpdateCommand struct { // NewUpdateCommand returns a usable command registered under the parent. func NewUpdateCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *UpdateCommand { - var c UpdateCommand - c.Globals = globals - c.Manifest = data + c := UpdateCommand{ + Base: cmd.Base{ + Globals: globals, + }, + Manifest: data, + } c.CmdClause = parent.Command("update", "Update a S3 logging endpoint on a Fastly service version") + + // required + c.CmdClause.Flag("name", "The name of the S3 logging object").Short('n').Required().StringVar(&c.EndpointName) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagVersionName, Description: cmd.FlagVersionDesc, Dst: &c.ServiceVersion.Value, Required: true, }) + + // optional c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ Action: c.AutoClone.Set, Dst: &c.AutoClone.Value, }) - c.CmdClause.Flag("name", "The name of the S3 logging object").Short('n').Required().StringVar(&c.EndpointName) + c.CmdClause.Flag("access-key", "Your S3 account access key").Action(c.AccessKey.Set).StringVar(&c.AccessKey.Value) + c.CmdClause.Flag("bucket", "Your S3 bucket name").Action(c.BucketName.Set).StringVar(&c.BucketName.Value) + common.CompressionCodec(c.CmdClause, &c.CompressionCodec) + c.CmdClause.Flag("domain", "The domain of the S3 endpoint").Action(c.Domain.Set).StringVar(&c.Domain.Value) + common.Format(c.CmdClause, &c.Format) + common.FormatVersion(c.CmdClause, &c.FormatVersion) + common.GzipLevel(c.CmdClause, &c.GzipLevel) + c.CmdClause.Flag("iam-role", "The IAM role ARN for logging").Action(c.IAMRole.Set).StringVar(&c.IAMRole.Value) + common.MessageType(c.CmdClause, &c.MessageType) + c.CmdClause.Flag("new-name", "New name of the S3 logging object").Action(c.NewName.Set).StringVar(&c.NewName.Value) + common.Path(c.CmdClause, &c.Path) + common.Period(c.CmdClause, &c.Period) + common.Placement(c.CmdClause, &c.Placement) + common.PublicKey(c.CmdClause, &c.PublicKey) + c.CmdClause.Flag("redundancy", "The S3 storage class. One of: standard, intelligent_tiering, standard_ia, onezone_ia, glacier, glacier_ir, deep_archive, or reduced_redundancy").Action(c.Redundancy.Set).EnumVar(&c.Redundancy.Value, string(fastly.S3RedundancyStandard), string(fastly.S3RedundancyIntelligentTiering), string(fastly.S3RedundancyStandardIA), string(fastly.S3RedundancyOneZoneIA), string(fastly.S3RedundancyGlacierFlexibleRetrieval), string(fastly.S3RedundancyGlacierInstantRetrieval), string(fastly.S3RedundancyGlacierDeepArchive), string(fastly.S3RedundancyReduced)) + common.ResponseCondition(c.CmdClause, &c.ResponseCondition) + c.CmdClause.Flag("secret-key", "Your S3 account secret key").Action(c.SecretKey.Set).StringVar(&c.SecretKey.Value) + c.CmdClause.Flag("server-side-encryption", "Set to enable S3 Server Side Encryption. Can be either AES256 or aws:kms").Action(c.ServerSideEncryption.Set).EnumVar(&c.ServerSideEncryption.Value, string(fastly.S3ServerSideEncryptionAES), string(fastly.S3ServerSideEncryptionKMS)) + c.CmdClause.Flag("server-side-encryption-kms-key-id", "Server-side KMS Key ID. Must be set if server-side-encryption is set to aws:kms").Action(c.ServerSideEncryptionKMSKeyID.Set).StringVar(&c.ServerSideEncryptionKMSKeyID.Value) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagServiceIDName, Description: cmd.FlagServiceIDDesc, @@ -76,26 +102,7 @@ func NewUpdateCommand(parent cmd.Registerer, globals *config.Data, data manifest Description: cmd.FlagServiceDesc, Dst: &c.ServiceName.Value, }) - c.CmdClause.Flag("new-name", "New name of the S3 logging object").Action(c.NewName.Set).StringVar(&c.NewName.Value) - c.CmdClause.Flag("bucket", "Your S3 bucket name").Action(c.BucketName.Set).StringVar(&c.BucketName.Value) - c.CmdClause.Flag("access-key", "Your S3 account access key").Action(c.AccessKey.Set).StringVar(&c.AccessKey.Value) - c.CmdClause.Flag("secret-key", "Your S3 account secret key").Action(c.SecretKey.Set).StringVar(&c.SecretKey.Value) - c.CmdClause.Flag("iam-role", "The IAM role ARN for logging").Action(c.IAMRole.Set).StringVar(&c.IAMRole.Value) - c.CmdClause.Flag("domain", "The domain of the S3 endpoint").Action(c.Domain.Set).StringVar(&c.Domain.Value) - common.Path(c.CmdClause, &c.Path) - common.Period(c.CmdClause, &c.Period) - common.GzipLevel(c.CmdClause, &c.GzipLevel) - common.Format(c.CmdClause, &c.Format) - common.FormatVersion(c.CmdClause, &c.FormatVersion) - common.MessageType(c.CmdClause, &c.MessageType) - common.ResponseCondition(c.CmdClause, &c.ResponseCondition) common.TimestampFormat(c.CmdClause, &c.TimestampFormat) - c.CmdClause.Flag("redundancy", "The S3 storage class. One of: standard, intelligent_tiering, standard_ia, onezone_ia, glacier, glacier_ir, deep_archive, or reduced_redundancy").Action(c.Redundancy.Set).EnumVar(&c.Redundancy.Value, string(fastly.S3RedundancyStandard), string(fastly.S3RedundancyIntelligentTiering), string(fastly.S3RedundancyStandardIA), string(fastly.S3RedundancyOneZoneIA), string(fastly.S3RedundancyGlacierFlexibleRetrieval), string(fastly.S3RedundancyGlacierInstantRetrieval), string(fastly.S3RedundancyGlacierDeepArchive), string(fastly.S3RedundancyReduced)) - common.Placement(c.CmdClause, &c.Placement) - common.PublicKey(c.CmdClause, &c.PublicKey) - c.CmdClause.Flag("server-side-encryption", "Set to enable S3 Server Side Encryption. Can be either AES256 or aws:kms").Action(c.ServerSideEncryption.Set).EnumVar(&c.ServerSideEncryption.Value, string(fastly.S3ServerSideEncryptionAES), string(fastly.S3ServerSideEncryptionKMS)) - c.CmdClause.Flag("server-side-encryption-kms-key-id", "Server-side KMS Key ID. Must be set if server-side-encryption is set to aws:kms").Action(c.ServerSideEncryptionKMSKeyID.Set).StringVar(&c.ServerSideEncryptionKMSKeyID.Value) - common.CompressionCodec(c.CmdClause, &c.CompressionCodec) return &c } diff --git a/pkg/commands/logging/scalyr/create.go b/pkg/commands/logging/scalyr/create.go index 24087d2e2..a548f8272 100644 --- a/pkg/commands/logging/scalyr/create.go +++ b/pkg/commands/logging/scalyr/create.go @@ -34,10 +34,15 @@ type CreateCommand struct { // NewCreateCommand returns a usable command registered under the parent. func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *CreateCommand { - var c CreateCommand - c.Globals = globals - c.Manifest = data + c := CreateCommand{ + Base: cmd.Base{ + Globals: globals, + }, + Manifest: data, + } c.CmdClause = parent.Command("create", "Create a Scalyr logging endpoint on a Fastly service version").Alias("add") + + // required c.CmdClause.Flag("name", "The name of the Scalyr logging object. Used as a primary key for API access").Short('n').Action(c.EndpointName.Set).StringVar(&c.EndpointName.Value) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagVersionName, @@ -45,11 +50,18 @@ func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest Dst: &c.ServiceVersion.Value, Required: true, }) + + // optional + c.CmdClause.Flag("auth-token", "The token to use for authentication (https://www.scalyr.com/keys)").Action(c.Token.Set).StringVar(&c.Token.Value) c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ Action: c.AutoClone.Set, Dst: &c.AutoClone.Value, }) - c.CmdClause.Flag("auth-token", "The token to use for authentication (https://www.scalyr.com/keys)").Action(c.Token.Set).StringVar(&c.Token.Value) + common.Format(c.CmdClause, &c.Format) + common.FormatVersion(c.CmdClause, &c.FormatVersion) + common.Placement(c.CmdClause, &c.Placement) + c.CmdClause.Flag("region", "The region that log data will be sent to. One of US or EU. Defaults to US if undefined").Action(c.Region.Set).StringVar(&c.Region.Value) + common.ResponseCondition(c.CmdClause, &c.ResponseCondition) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagServiceIDName, Description: cmd.FlagServiceIDDesc, @@ -62,11 +74,6 @@ func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest Description: cmd.FlagServiceDesc, Dst: &c.ServiceName.Value, }) - c.CmdClause.Flag("region", "The region that log data will be sent to. One of US or EU. Defaults to US if undefined").Action(c.Region.Set).StringVar(&c.Region.Value) - common.Format(c.CmdClause, &c.Format) - common.FormatVersion(c.CmdClause, &c.FormatVersion) - common.ResponseCondition(c.CmdClause, &c.ResponseCondition) - common.Placement(c.CmdClause, &c.Placement) return &c } diff --git a/pkg/commands/logging/scalyr/delete.go b/pkg/commands/logging/scalyr/delete.go index a9b8beda6..da80215c7 100644 --- a/pkg/commands/logging/scalyr/delete.go +++ b/pkg/commands/logging/scalyr/delete.go @@ -23,21 +23,28 @@ type DeleteCommand struct { // NewDeleteCommand returns a usable command registered under the parent. func NewDeleteCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *DeleteCommand { - var c DeleteCommand - c.Globals = globals - c.manifest = data + c := DeleteCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("delete", "Delete a Scalyr logging endpoint on a Fastly service version").Alias("remove") + + // required + c.CmdClause.Flag("name", "The name of the Scalyr logging object").Short('n').Required().StringVar(&c.Input.Name) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagVersionName, Description: cmd.FlagVersionDesc, Dst: &c.serviceVersion.Value, Required: true, }) + + // optional c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ Action: c.autoClone.Set, Dst: &c.autoClone.Value, }) - c.CmdClause.Flag("name", "The name of the Scalyr logging object").Short('n').Required().StringVar(&c.Input.Name) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagServiceIDName, Description: cmd.FlagServiceIDDesc, diff --git a/pkg/commands/logging/scalyr/describe.go b/pkg/commands/logging/scalyr/describe.go index 184e50c45..462138514 100644 --- a/pkg/commands/logging/scalyr/describe.go +++ b/pkg/commands/logging/scalyr/describe.go @@ -25,10 +25,24 @@ type DescribeCommand struct { // NewDescribeCommand returns a usable command registered under the parent. func NewDescribeCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *DescribeCommand { - var c DescribeCommand - c.Globals = globals - c.manifest = data + c := DescribeCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("describe", "Show detailed information about a Scalyr logging endpoint on a Fastly service version").Alias("get") + + // required + c.CmdClause.Flag("name", "The name of the Scalyr logging object").Short('n').Required().StringVar(&c.Input.Name) + c.RegisterFlag(cmd.StringFlagOpts{ + Name: cmd.FlagVersionName, + Description: cmd.FlagVersionDesc, + Dst: &c.serviceVersion.Value, + Required: true, + }) + + // optional c.RegisterFlagBool(cmd.BoolFlagOpts{ Name: cmd.FlagJSONName, Description: cmd.FlagJSONDesc, @@ -47,13 +61,6 @@ func NewDescribeCommand(parent cmd.Registerer, globals *config.Data, data manife Description: cmd.FlagServiceDesc, Dst: &c.serviceName.Value, }) - c.RegisterFlag(cmd.StringFlagOpts{ - Name: cmd.FlagVersionName, - Description: cmd.FlagVersionDesc, - Dst: &c.serviceVersion.Value, - Required: true, - }) - c.CmdClause.Flag("name", "The name of the Scalyr logging object").Short('n').Required().StringVar(&c.Input.Name) return &c } diff --git a/pkg/commands/logging/scalyr/list.go b/pkg/commands/logging/scalyr/list.go index 957021736..383bbf4bc 100644 --- a/pkg/commands/logging/scalyr/list.go +++ b/pkg/commands/logging/scalyr/list.go @@ -25,10 +25,23 @@ type ListCommand struct { // NewListCommand returns a usable command registered under the parent. func NewListCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *ListCommand { - var c ListCommand - c.Globals = globals - c.manifest = data + c := ListCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("list", "List Scalyr endpoints on a Fastly service version") + + // required + c.RegisterFlag(cmd.StringFlagOpts{ + Name: cmd.FlagVersionName, + Description: cmd.FlagVersionDesc, + Dst: &c.serviceVersion.Value, + Required: true, + }) + + // optional c.RegisterFlagBool(cmd.BoolFlagOpts{ Name: cmd.FlagJSONName, Description: cmd.FlagJSONDesc, @@ -47,12 +60,6 @@ func NewListCommand(parent cmd.Registerer, globals *config.Data, data manifest.D Description: cmd.FlagServiceDesc, Dst: &c.serviceName.Value, }) - c.RegisterFlag(cmd.StringFlagOpts{ - Name: cmd.FlagVersionName, - Description: cmd.FlagVersionDesc, - Dst: &c.serviceVersion.Value, - Required: true, - }) return &c } diff --git a/pkg/commands/logging/scalyr/update.go b/pkg/commands/logging/scalyr/update.go index 773f167aa..4cad3426e 100644 --- a/pkg/commands/logging/scalyr/update.go +++ b/pkg/commands/logging/scalyr/update.go @@ -35,21 +35,35 @@ type UpdateCommand struct { // NewUpdateCommand returns a usable command registered under the parent. func NewUpdateCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *UpdateCommand { - var c UpdateCommand - c.Globals = globals - c.Manifest = data + c := UpdateCommand{ + Base: cmd.Base{ + Globals: globals, + }, + Manifest: data, + } c.CmdClause = parent.Command("update", "Update a Scalyr logging endpoint on a Fastly service version") + + // required + c.CmdClause.Flag("name", "The name of the Scalyr logging object").Short('n').Required().StringVar(&c.EndpointName) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagVersionName, Description: cmd.FlagVersionDesc, Dst: &c.ServiceVersion.Value, Required: true, }) + + // optional + c.CmdClause.Flag("auth-token", "The token to use for authentication (https://www.scalyr.com/keys)").Action(c.Token.Set).StringVar(&c.Token.Value) c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ Action: c.AutoClone.Set, Dst: &c.AutoClone.Value, }) - c.CmdClause.Flag("name", "The name of the Scalyr logging object").Short('n').Required().StringVar(&c.EndpointName) + common.Format(c.CmdClause, &c.Format) + common.FormatVersion(c.CmdClause, &c.FormatVersion) + c.CmdClause.Flag("new-name", "New name of the Scalyr logging object").Action(c.NewName.Set).StringVar(&c.NewName.Value) + common.Placement(c.CmdClause, &c.Placement) + c.CmdClause.Flag("region", "The region that log data will be sent to. One of US or EU. Defaults to US if undefined").Action(c.Region.Set).StringVar(&c.Region.Value) + common.ResponseCondition(c.CmdClause, &c.ResponseCondition) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagServiceIDName, Description: cmd.FlagServiceIDDesc, @@ -62,13 +76,6 @@ func NewUpdateCommand(parent cmd.Registerer, globals *config.Data, data manifest Description: cmd.FlagServiceDesc, Dst: &c.ServiceName.Value, }) - c.CmdClause.Flag("new-name", "New name of the Scalyr logging object").Action(c.NewName.Set).StringVar(&c.NewName.Value) - common.Format(c.CmdClause, &c.Format) - common.FormatVersion(c.CmdClause, &c.FormatVersion) - c.CmdClause.Flag("auth-token", "The token to use for authentication (https://www.scalyr.com/keys)").Action(c.Token.Set).StringVar(&c.Token.Value) - c.CmdClause.Flag("region", "The region that log data will be sent to. One of US or EU. Defaults to US if undefined").Action(c.Region.Set).StringVar(&c.Region.Value) - common.ResponseCondition(c.CmdClause, &c.ResponseCondition) - common.Placement(c.CmdClause, &c.Placement) return &c } diff --git a/pkg/commands/logging/sftp/create.go b/pkg/commands/logging/sftp/create.go index 0913d2b26..164b01b03 100644 --- a/pkg/commands/logging/sftp/create.go +++ b/pkg/commands/logging/sftp/create.go @@ -46,10 +46,15 @@ type CreateCommand struct { // NewCreateCommand returns a usable command registered under the parent. func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *CreateCommand { - var c CreateCommand - c.Globals = globals - c.Manifest = data + c := CreateCommand{ + Base: cmd.Base{ + Globals: globals, + }, + Manifest: data, + } c.CmdClause = parent.Command("create", "Create an SFTP logging endpoint on a Fastly service version").Alias("add") + + // required c.CmdClause.Flag("name", "The name of the SFTP logging object. Used as a primary key for API access").Short('n').Action(c.EndpointName.Set).StringVar(&c.EndpointName.Value) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagVersionName, @@ -57,13 +62,26 @@ func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest Dst: &c.ServiceVersion.Value, Required: true, }) + + // optional c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ Action: c.AutoClone.Set, Dst: &c.AutoClone.Value, }) c.CmdClause.Flag("address", "The hostname or IPv4 address").Action(c.Address.Set).StringVar(&c.Address.Value) - c.CmdClause.Flag("user", "The username for the server").Action(c.User.Set).StringVar(&c.User.Value) - c.CmdClause.Flag("ssh-known-hosts", "A list of host keys for all hosts we can connect to over SFTP").Action(c.SSHKnownHosts.Set).StringVar(&c.SSHKnownHosts.Value) + common.CompressionCodec(c.CmdClause, &c.CompressionCodec) + common.Format(c.CmdClause, &c.Format) + common.FormatVersion(c.CmdClause, &c.FormatVersion) + common.GzipLevel(c.CmdClause, &c.GzipLevel) + common.MessageType(c.CmdClause, &c.MessageType) + c.CmdClause.Flag("password", "The password for the server. If both password and secret_key are passed, secret_key will be used in preference").Action(c.Password.Set).StringVar(&c.Password.Value) + c.CmdClause.Flag("path", "The path to upload logs to. The directory must exist on the SFTP server before logs can be saved to it").Action(c.Path.Set).StringVar(&c.Path.Value) + common.Period(c.CmdClause, &c.Period) + common.Placement(c.CmdClause, &c.Placement) + c.CmdClause.Flag("port", "The port number").Action(c.Port.Set).IntVar(&c.Port.Value) + common.PublicKey(c.CmdClause, &c.PublicKey) + common.ResponseCondition(c.CmdClause, &c.ResponseCondition) + c.CmdClause.Flag("secret-key", "The SSH private key for the server. If both password and secret_key are passed, secret_key will be used in preference").Action(c.SecretKey.Set).StringVar(&c.SecretKey.Value) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagServiceIDName, Description: cmd.FlagServiceIDDesc, @@ -76,20 +94,9 @@ func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest Description: cmd.FlagServiceDesc, Dst: &c.ServiceName.Value, }) - c.CmdClause.Flag("port", "The port number").Action(c.Port.Set).IntVar(&c.Port.Value) - c.CmdClause.Flag("password", "The password for the server. If both password and secret_key are passed, secret_key will be used in preference").Action(c.Password.Set).StringVar(&c.Password.Value) - common.PublicKey(c.CmdClause, &c.PublicKey) - c.CmdClause.Flag("secret-key", "The SSH private key for the server. If both password and secret_key are passed, secret_key will be used in preference").Action(c.SecretKey.Set).StringVar(&c.SecretKey.Value) - c.CmdClause.Flag("path", "The path to upload logs to. The directory must exist on the SFTP server before logs can be saved to it").Action(c.Path.Set).StringVar(&c.Path.Value) - common.Period(c.CmdClause, &c.Period) - common.Format(c.CmdClause, &c.Format) - common.FormatVersion(c.CmdClause, &c.FormatVersion) - common.GzipLevel(c.CmdClause, &c.GzipLevel) - common.MessageType(c.CmdClause, &c.MessageType) - common.ResponseCondition(c.CmdClause, &c.ResponseCondition) + c.CmdClause.Flag("ssh-known-hosts", "A list of host keys for all hosts we can connect to over SFTP").Action(c.SSHKnownHosts.Set).StringVar(&c.SSHKnownHosts.Value) common.TimestampFormat(c.CmdClause, &c.TimestampFormat) - common.Placement(c.CmdClause, &c.Placement) - common.CompressionCodec(c.CmdClause, &c.CompressionCodec) + c.CmdClause.Flag("user", "The username for the server").Action(c.User.Set).StringVar(&c.User.Value) return &c } diff --git a/pkg/commands/logging/sftp/delete.go b/pkg/commands/logging/sftp/delete.go index 331d7550f..3e7c79a3a 100644 --- a/pkg/commands/logging/sftp/delete.go +++ b/pkg/commands/logging/sftp/delete.go @@ -23,21 +23,28 @@ type DeleteCommand struct { // NewDeleteCommand returns a usable command registered under the parent. func NewDeleteCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *DeleteCommand { - var c DeleteCommand - c.Globals = globals - c.manifest = data + c := DeleteCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("delete", "Delete an SFTP logging endpoint on a Fastly service version").Alias("remove") + + // required + c.CmdClause.Flag("name", "The name of the SFTP logging object").Short('n').Required().StringVar(&c.Input.Name) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagVersionName, Description: cmd.FlagVersionDesc, Dst: &c.serviceVersion.Value, Required: true, }) + + // optional c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ Action: c.autoClone.Set, Dst: &c.autoClone.Value, }) - c.CmdClause.Flag("name", "The name of the SFTP logging object").Short('n').Required().StringVar(&c.Input.Name) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagServiceIDName, Description: cmd.FlagServiceIDDesc, diff --git a/pkg/commands/logging/sftp/describe.go b/pkg/commands/logging/sftp/describe.go index 13de0b92c..aae513288 100644 --- a/pkg/commands/logging/sftp/describe.go +++ b/pkg/commands/logging/sftp/describe.go @@ -25,10 +25,24 @@ type DescribeCommand struct { // NewDescribeCommand returns a usable command registered under the parent. func NewDescribeCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *DescribeCommand { - var c DescribeCommand - c.Globals = globals - c.manifest = data + c := DescribeCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("describe", "Show detailed information about an SFTP logging endpoint on a Fastly service version").Alias("get") + + // required + c.CmdClause.Flag("name", "The name of the SFTP logging object").Short('n').Required().StringVar(&c.Input.Name) + c.RegisterFlag(cmd.StringFlagOpts{ + Name: cmd.FlagVersionName, + Description: cmd.FlagVersionDesc, + Dst: &c.serviceVersion.Value, + Required: true, + }) + + // optional c.RegisterFlagBool(cmd.BoolFlagOpts{ Name: cmd.FlagJSONName, Description: cmd.FlagJSONDesc, @@ -47,13 +61,6 @@ func NewDescribeCommand(parent cmd.Registerer, globals *config.Data, data manife Description: cmd.FlagServiceDesc, Dst: &c.serviceName.Value, }) - c.RegisterFlag(cmd.StringFlagOpts{ - Name: cmd.FlagVersionName, - Description: cmd.FlagVersionDesc, - Dst: &c.serviceVersion.Value, - Required: true, - }) - c.CmdClause.Flag("name", "The name of the SFTP logging object").Short('n').Required().StringVar(&c.Input.Name) return &c } diff --git a/pkg/commands/logging/sftp/list.go b/pkg/commands/logging/sftp/list.go index 96226d66e..22279b1cf 100644 --- a/pkg/commands/logging/sftp/list.go +++ b/pkg/commands/logging/sftp/list.go @@ -25,10 +25,23 @@ type ListCommand struct { // NewListCommand returns a usable command registered under the parent. func NewListCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *ListCommand { - var c ListCommand - c.Globals = globals - c.manifest = data + c := ListCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("list", "List SFTP endpoints on a Fastly service version") + + // required + c.RegisterFlag(cmd.StringFlagOpts{ + Name: cmd.FlagVersionName, + Description: cmd.FlagVersionDesc, + Dst: &c.serviceVersion.Value, + Required: true, + }) + + // optional c.RegisterFlagBool(cmd.BoolFlagOpts{ Name: cmd.FlagJSONName, Description: cmd.FlagJSONDesc, @@ -47,12 +60,6 @@ func NewListCommand(parent cmd.Registerer, globals *config.Data, data manifest.D Description: cmd.FlagServiceDesc, Dst: &c.serviceName.Value, }) - c.RegisterFlag(cmd.StringFlagOpts{ - Name: cmd.FlagVersionName, - Description: cmd.FlagVersionDesc, - Dst: &c.serviceVersion.Value, - Required: true, - }) return &c } diff --git a/pkg/commands/logging/sftp/update.go b/pkg/commands/logging/sftp/update.go index 807e53221..e976154ba 100644 --- a/pkg/commands/logging/sftp/update.go +++ b/pkg/commands/logging/sftp/update.go @@ -46,21 +46,43 @@ type UpdateCommand struct { // NewUpdateCommand returns a usable command registered under the parent. func NewUpdateCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *UpdateCommand { - var c UpdateCommand - c.Globals = globals - c.Manifest = data + c := UpdateCommand{ + Base: cmd.Base{ + Globals: globals, + }, + Manifest: data, + } c.CmdClause = parent.Command("update", "Update an SFTP logging endpoint on a Fastly service version") + + // required + c.CmdClause.Flag("name", "The name of the SFTP logging object").Short('n').Required().StringVar(&c.EndpointName) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagVersionName, Description: cmd.FlagVersionDesc, Dst: &c.ServiceVersion.Value, Required: true, }) + + // optional c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ Action: c.AutoClone.Set, Dst: &c.AutoClone.Value, }) - c.CmdClause.Flag("name", "The name of the SFTP logging object").Short('n').Required().StringVar(&c.EndpointName) + c.CmdClause.Flag("address", "The hostname or IPv4 address").Action(c.Address.Set).StringVar(&c.Address.Value) + common.CompressionCodec(c.CmdClause, &c.CompressionCodec) + c.CmdClause.Flag("new-name", "New name of the SFTP logging object").Action(c.NewName.Set).StringVar(&c.NewName.Value) + common.Format(c.CmdClause, &c.Format) + common.FormatVersion(c.CmdClause, &c.FormatVersion) + common.GzipLevel(c.CmdClause, &c.GzipLevel) + common.MessageType(c.CmdClause, &c.MessageType) + c.CmdClause.Flag("password", "The password for the server. If both password and secret_key are passed, secret_key will be used in preference").Action(c.Password.Set).StringVar(&c.Password.Value) + c.CmdClause.Flag("path", "The path to upload logs to. The directory must exist on the SFTP server before logs can be saved to it").Action(c.Path.Set).StringVar(&c.Path.Value) + common.Period(c.CmdClause, &c.Period) + common.Placement(c.CmdClause, &c.Placement) + c.CmdClause.Flag("port", "The port number").Action(c.Port.Set).IntVar(&c.Port.Value) + common.PublicKey(c.CmdClause, &c.PublicKey) + common.ResponseCondition(c.CmdClause, &c.ResponseCondition) + c.CmdClause.Flag("secret-key", "The SSH private key for the server. If both password and secret_key are passed, secret_key will be used in preference").Action(c.SecretKey.Set).StringVar(&c.SecretKey.Value) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagServiceIDName, Description: cmd.FlagServiceIDDesc, @@ -73,24 +95,9 @@ func NewUpdateCommand(parent cmd.Registerer, globals *config.Data, data manifest Description: cmd.FlagServiceDesc, Dst: &c.ServiceName.Value, }) - c.CmdClause.Flag("new-name", "New name of the SFTP logging object").Action(c.NewName.Set).StringVar(&c.NewName.Value) - c.CmdClause.Flag("address", "The hostname or IPv4 address").Action(c.Address.Set).StringVar(&c.Address.Value) - c.CmdClause.Flag("port", "The port number").Action(c.Port.Set).IntVar(&c.Port.Value) - common.PublicKey(c.CmdClause, &c.PublicKey) - c.CmdClause.Flag("secret-key", "The SSH private key for the server. If both password and secret_key are passed, secret_key will be used in preference").Action(c.SecretKey.Set).StringVar(&c.SecretKey.Value) c.CmdClause.Flag("ssh-known-hosts", "A list of host keys for all hosts we can connect to over SFTP").Action(c.SSHKnownHosts.Set).StringVar(&c.SSHKnownHosts.Value) c.CmdClause.Flag("user", "The username for the server").Action(c.User.Set).StringVar(&c.User.Value) - c.CmdClause.Flag("password", "The password for the server. If both password and secret_key are passed, secret_key will be used in preference").Action(c.Password.Set).StringVar(&c.Password.Value) - c.CmdClause.Flag("path", "The path to upload logs to. The directory must exist on the SFTP server before logs can be saved to it").Action(c.Path.Set).StringVar(&c.Path.Value) - common.Period(c.CmdClause, &c.Period) - common.Format(c.CmdClause, &c.Format) - common.FormatVersion(c.CmdClause, &c.FormatVersion) - common.MessageType(c.CmdClause, &c.MessageType) - common.GzipLevel(c.CmdClause, &c.GzipLevel) - common.ResponseCondition(c.CmdClause, &c.ResponseCondition) common.TimestampFormat(c.CmdClause, &c.TimestampFormat) - common.Placement(c.CmdClause, &c.Placement) - common.CompressionCodec(c.CmdClause, &c.CompressionCodec) return &c } diff --git a/pkg/commands/logging/splunk/create.go b/pkg/commands/logging/splunk/create.go index 6f7a45b6f..e691905a4 100644 --- a/pkg/commands/logging/splunk/create.go +++ b/pkg/commands/logging/splunk/create.go @@ -39,10 +39,15 @@ type CreateCommand struct { // NewCreateCommand returns a usable command registered under the parent. func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *CreateCommand { - var c CreateCommand - c.Globals = globals - c.Manifest = data + c := CreateCommand{ + Base: cmd.Base{ + Globals: globals, + }, + Manifest: data, + } c.CmdClause = parent.Command("create", "Create a Splunk logging endpoint on a Fastly service version").Alias("add") + + // required c.CmdClause.Flag("name", "The name of the Splunk logging object. Used as a primary key for API access").Short('n').Action(c.EndpointName.Set).StringVar(&c.EndpointName.Value) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagVersionName, @@ -50,11 +55,17 @@ func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest Dst: &c.ServiceVersion.Value, Required: true, }) + + // optional + c.CmdClause.Flag("auth-token", "A Splunk token for use in posting logs over HTTP to your collector").Action(c.Token.Set).StringVar(&c.Token.Value) c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ Action: c.AutoClone.Set, Dst: &c.AutoClone.Value, }) - c.CmdClause.Flag("url", "The URL to POST to").Action(c.URL.Set).StringVar(&c.URL.Value) + common.Format(c.CmdClause, &c.Format) + common.FormatVersion(c.CmdClause, &c.FormatVersion) + common.Placement(c.CmdClause, &c.Placement) + common.ResponseCondition(c.CmdClause, &c.ResponseCondition) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagServiceIDName, Description: cmd.FlagServiceIDDesc, @@ -68,14 +79,10 @@ func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest Dst: &c.ServiceName.Value, }) common.TLSCACert(c.CmdClause, &c.TLSCACert) - common.TLSHostname(c.CmdClause, &c.TLSHostname) common.TLSClientCert(c.CmdClause, &c.TLSClientCert) common.TLSClientKey(c.CmdClause, &c.TLSClientKey) - common.Format(c.CmdClause, &c.Format) - common.FormatVersion(c.CmdClause, &c.FormatVersion) - common.ResponseCondition(c.CmdClause, &c.ResponseCondition) - common.Placement(c.CmdClause, &c.Placement) - c.CmdClause.Flag("auth-token", "A Splunk token for use in posting logs over HTTP to your collector").Action(c.Token.Set).StringVar(&c.Token.Value) + common.TLSHostname(c.CmdClause, &c.TLSHostname) + c.CmdClause.Flag("url", "The URL to POST to").Action(c.URL.Set).StringVar(&c.URL.Value) return &c } diff --git a/pkg/commands/logging/splunk/delete.go b/pkg/commands/logging/splunk/delete.go index 25e74c95d..e96cc52cb 100644 --- a/pkg/commands/logging/splunk/delete.go +++ b/pkg/commands/logging/splunk/delete.go @@ -23,21 +23,28 @@ type DeleteCommand struct { // NewDeleteCommand returns a usable command registered under the parent. func NewDeleteCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *DeleteCommand { - var c DeleteCommand - c.Globals = globals - c.manifest = data + c := DeleteCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("delete", "Delete a Splunk logging endpoint on a Fastly service version").Alias("remove") + + // required + c.CmdClause.Flag("name", "The name of the Splunk logging object").Short('n').Required().StringVar(&c.Input.Name) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagVersionName, Description: cmd.FlagVersionDesc, Dst: &c.serviceVersion.Value, Required: true, }) + + // optional c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ Action: c.autoClone.Set, Dst: &c.autoClone.Value, }) - c.CmdClause.Flag("name", "The name of the Splunk logging object").Short('n').Required().StringVar(&c.Input.Name) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagServiceIDName, Description: cmd.FlagServiceIDDesc, diff --git a/pkg/commands/logging/splunk/describe.go b/pkg/commands/logging/splunk/describe.go index e58be364c..8d21e77d5 100644 --- a/pkg/commands/logging/splunk/describe.go +++ b/pkg/commands/logging/splunk/describe.go @@ -25,10 +25,24 @@ type DescribeCommand struct { // NewDescribeCommand returns a usable command registered under the parent. func NewDescribeCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *DescribeCommand { - var c DescribeCommand - c.Globals = globals - c.manifest = data + c := DescribeCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("describe", "Show detailed information about a Splunk logging endpoint on a Fastly service version").Alias("get") + + // required + c.CmdClause.Flag("name", "The name of the Splunk logging object").Short('n').Required().StringVar(&c.Input.Name) + c.RegisterFlag(cmd.StringFlagOpts{ + Name: cmd.FlagVersionName, + Description: cmd.FlagVersionDesc, + Dst: &c.serviceVersion.Value, + Required: true, + }) + + // optional c.RegisterFlagBool(cmd.BoolFlagOpts{ Name: cmd.FlagJSONName, Description: cmd.FlagJSONDesc, @@ -47,13 +61,6 @@ func NewDescribeCommand(parent cmd.Registerer, globals *config.Data, data manife Description: cmd.FlagServiceDesc, Dst: &c.serviceName.Value, }) - c.RegisterFlag(cmd.StringFlagOpts{ - Name: cmd.FlagVersionName, - Description: cmd.FlagVersionDesc, - Dst: &c.serviceVersion.Value, - Required: true, - }) - c.CmdClause.Flag("name", "The name of the Splunk logging object").Short('n').Required().StringVar(&c.Input.Name) return &c } diff --git a/pkg/commands/logging/splunk/list.go b/pkg/commands/logging/splunk/list.go index 5eb452cca..9c6fa833d 100644 --- a/pkg/commands/logging/splunk/list.go +++ b/pkg/commands/logging/splunk/list.go @@ -25,10 +25,23 @@ type ListCommand struct { // NewListCommand returns a usable command registered under the parent. func NewListCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *ListCommand { - var c ListCommand - c.Globals = globals - c.manifest = data + c := ListCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("list", "List Splunk endpoints on a Fastly service version") + + // required + c.RegisterFlag(cmd.StringFlagOpts{ + Name: cmd.FlagVersionName, + Description: cmd.FlagVersionDesc, + Dst: &c.serviceVersion.Value, + Required: true, + }) + + // optional c.RegisterFlagBool(cmd.BoolFlagOpts{ Name: cmd.FlagJSONName, Description: cmd.FlagJSONDesc, @@ -47,12 +60,6 @@ func NewListCommand(parent cmd.Registerer, globals *config.Data, data manifest.D Description: cmd.FlagServiceDesc, Dst: &c.serviceName.Value, }) - c.RegisterFlag(cmd.StringFlagOpts{ - Name: cmd.FlagVersionName, - Description: cmd.FlagVersionDesc, - Dst: &c.serviceVersion.Value, - Required: true, - }) return &c } diff --git a/pkg/commands/logging/splunk/update.go b/pkg/commands/logging/splunk/update.go index 2105c262e..ea819a4ed 100644 --- a/pkg/commands/logging/splunk/update.go +++ b/pkg/commands/logging/splunk/update.go @@ -39,21 +39,34 @@ type UpdateCommand struct { // NewUpdateCommand returns a usable command registered under the parent. func NewUpdateCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *UpdateCommand { - var c UpdateCommand - c.Globals = globals - c.Manifest = data + c := UpdateCommand{ + Base: cmd.Base{ + Globals: globals, + }, + Manifest: data, + } c.CmdClause = parent.Command("update", "Update a Splunk logging endpoint on a Fastly service version") + + // required + c.CmdClause.Flag("name", "The name of the Splunk logging object").Short('n').Required().StringVar(&c.EndpointName) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagVersionName, Description: cmd.FlagVersionDesc, Dst: &c.ServiceVersion.Value, Required: true, }) + + // optional + c.CmdClause.Flag("auth-token", "").Action(c.Token.Set).StringVar(&c.Token.Value) c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ Action: c.AutoClone.Set, Dst: &c.AutoClone.Value, }) - c.CmdClause.Flag("name", "The name of the Splunk logging object").Short('n').Required().StringVar(&c.EndpointName) + c.CmdClause.Flag("new-name", "New name of the Splunk logging object").Action(c.NewName.Set).StringVar(&c.NewName.Value) + common.Format(c.CmdClause, &c.Format) + common.FormatVersion(c.CmdClause, &c.FormatVersion) + c.CmdClause.Flag("placement", " Where in the generated VCL the logging call should be placed, overriding any format_version default. Can be none or waf_debug. This field is not required and has no default value").Action(c.Placement.Set).StringVar(&c.Placement.Value) + common.ResponseCondition(c.CmdClause, &c.ResponseCondition) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagServiceIDName, Description: cmd.FlagServiceIDDesc, @@ -66,17 +79,11 @@ func NewUpdateCommand(parent cmd.Registerer, globals *config.Data, data manifest Description: cmd.FlagServiceDesc, Dst: &c.ServiceName.Value, }) - c.CmdClause.Flag("new-name", "New name of the Splunk logging object").Action(c.NewName.Set).StringVar(&c.NewName.Value) - c.CmdClause.Flag("url", "The URL to POST to.").Action(c.URL.Set).StringVar(&c.URL.Value) common.TLSCACert(c.CmdClause, &c.TLSCACert) - common.TLSHostname(c.CmdClause, &c.TLSHostname) common.TLSClientCert(c.CmdClause, &c.TLSClientCert) common.TLSClientKey(c.CmdClause, &c.TLSClientKey) - common.Format(c.CmdClause, &c.Format) - common.FormatVersion(c.CmdClause, &c.FormatVersion) - common.ResponseCondition(c.CmdClause, &c.ResponseCondition) - c.CmdClause.Flag("placement", " Where in the generated VCL the logging call should be placed, overriding any format_version default. Can be none or waf_debug. This field is not required and has no default value").Action(c.Placement.Set).StringVar(&c.Placement.Value) - c.CmdClause.Flag("auth-token", "").Action(c.Token.Set).StringVar(&c.Token.Value) + common.TLSHostname(c.CmdClause, &c.TLSHostname) + c.CmdClause.Flag("url", "The URL to POST to.").Action(c.URL.Set).StringVar(&c.URL.Value) return &c } diff --git a/pkg/commands/logging/sumologic/create.go b/pkg/commands/logging/sumologic/create.go index feb7852b3..bace7aa47 100644 --- a/pkg/commands/logging/sumologic/create.go +++ b/pkg/commands/logging/sumologic/create.go @@ -34,10 +34,15 @@ type CreateCommand struct { // NewCreateCommand returns a usable command registered under the parent. func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *CreateCommand { - var c CreateCommand - c.Globals = globals - c.Manifest = data + c := CreateCommand{ + Base: cmd.Base{ + Globals: globals, + }, + Manifest: data, + } c.CmdClause = parent.Command("create", "Create a Sumologic logging endpoint on a Fastly service version").Alias("add") + + // required c.CmdClause.Flag("name", "The name of the Sumologic logging object. Used as a primary key for API access").Short('n').Action(c.EndpointName.Set).StringVar(&c.EndpointName.Value) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagVersionName, @@ -45,11 +50,17 @@ func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest Dst: &c.ServiceVersion.Value, Required: true, }) + + // optional c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ Action: c.AutoClone.Set, Dst: &c.AutoClone.Value, }) - c.CmdClause.Flag("url", "The URL to POST to").Action(c.URL.Set).StringVar(&c.URL.Value) + c.CmdClause.Flag("format-version", "The version of the custom logging format used for the configured endpoint. Can be either 2 (the default, version 2 log format) or 1 (the version 1 log format). The logging call gets placed by default in vcl_log if format_version is set to 2 and in vcl_deliver if format_version is set to 1").Action(c.FormatVersion.Set).IntVar(&c.FormatVersion.Value) + common.Format(c.CmdClause, &c.Format) + common.MessageType(c.CmdClause, &c.MessageType) + common.Placement(c.CmdClause, &c.Placement) + common.ResponseCondition(c.CmdClause, &c.ResponseCondition) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagServiceIDName, Description: cmd.FlagServiceIDDesc, @@ -62,11 +73,7 @@ func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest Description: cmd.FlagServiceDesc, Dst: &c.ServiceName.Value, }) - common.Format(c.CmdClause, &c.Format) - c.CmdClause.Flag("format-version", "The version of the custom logging format used for the configured endpoint. Can be either 2 (the default, version 2 log format) or 1 (the version 1 log format). The logging call gets placed by default in vcl_log if format_version is set to 2 and in vcl_deliver if format_version is set to 1").Action(c.FormatVersion.Set).IntVar(&c.FormatVersion.Value) - common.ResponseCondition(c.CmdClause, &c.ResponseCondition) - common.MessageType(c.CmdClause, &c.MessageType) - common.Placement(c.CmdClause, &c.Placement) + c.CmdClause.Flag("url", "The URL to POST to").Action(c.URL.Set).StringVar(&c.URL.Value) return &c } diff --git a/pkg/commands/logging/sumologic/delete.go b/pkg/commands/logging/sumologic/delete.go index f96b7110b..4df099fb5 100644 --- a/pkg/commands/logging/sumologic/delete.go +++ b/pkg/commands/logging/sumologic/delete.go @@ -23,21 +23,28 @@ type DeleteCommand struct { // NewDeleteCommand returns a usable command registered under the parent. func NewDeleteCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *DeleteCommand { - var c DeleteCommand - c.Globals = globals - c.manifest = data + c := DeleteCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("delete", "Delete a Sumologic logging endpoint on a Fastly service version").Alias("remove") + + // required + c.CmdClause.Flag("name", "The name of the Sumologic logging object").Short('n').Required().StringVar(&c.Input.Name) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagVersionName, Description: cmd.FlagVersionDesc, Dst: &c.serviceVersion.Value, Required: true, }) + + // optional c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ Action: c.autoClone.Set, Dst: &c.autoClone.Value, }) - c.CmdClause.Flag("name", "The name of the Sumologic logging object").Short('n').Required().StringVar(&c.Input.Name) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagServiceIDName, Description: cmd.FlagServiceIDDesc, diff --git a/pkg/commands/logging/sumologic/describe.go b/pkg/commands/logging/sumologic/describe.go index 69f7d2839..31344bc82 100644 --- a/pkg/commands/logging/sumologic/describe.go +++ b/pkg/commands/logging/sumologic/describe.go @@ -25,10 +25,24 @@ type DescribeCommand struct { // NewDescribeCommand returns a usable command registered under the parent. func NewDescribeCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *DescribeCommand { - var c DescribeCommand - c.Globals = globals - c.manifest = data + c := DescribeCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("describe", "Show detailed information about a Sumologic logging endpoint on a Fastly service version").Alias("get") + + // required + c.CmdClause.Flag("name", "The name of the Sumologic logging object").Short('n').Required().StringVar(&c.Input.Name) + c.RegisterFlag(cmd.StringFlagOpts{ + Name: cmd.FlagVersionName, + Description: cmd.FlagVersionDesc, + Dst: &c.serviceVersion.Value, + Required: true, + }) + + // optional c.RegisterFlagBool(cmd.BoolFlagOpts{ Name: cmd.FlagJSONName, Description: cmd.FlagJSONDesc, @@ -47,13 +61,6 @@ func NewDescribeCommand(parent cmd.Registerer, globals *config.Data, data manife Description: cmd.FlagServiceDesc, Dst: &c.serviceName.Value, }) - c.RegisterFlag(cmd.StringFlagOpts{ - Name: cmd.FlagVersionName, - Description: cmd.FlagVersionDesc, - Dst: &c.serviceVersion.Value, - Required: true, - }) - c.CmdClause.Flag("name", "The name of the Sumologic logging object").Short('n').Required().StringVar(&c.Input.Name) return &c } diff --git a/pkg/commands/logging/sumologic/list.go b/pkg/commands/logging/sumologic/list.go index 235a4c3ed..488c257d0 100644 --- a/pkg/commands/logging/sumologic/list.go +++ b/pkg/commands/logging/sumologic/list.go @@ -25,10 +25,23 @@ type ListCommand struct { // NewListCommand returns a usable command registered under the parent. func NewListCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *ListCommand { - var c ListCommand - c.Globals = globals - c.manifest = data + c := ListCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("list", "List Sumologic endpoints on a Fastly service version") + + // required + c.RegisterFlag(cmd.StringFlagOpts{ + Name: cmd.FlagVersionName, + Description: cmd.FlagVersionDesc, + Dst: &c.serviceVersion.Value, + Required: true, + }) + + // optional c.RegisterFlagBool(cmd.BoolFlagOpts{ Name: cmd.FlagJSONName, Description: cmd.FlagJSONDesc, @@ -47,12 +60,6 @@ func NewListCommand(parent cmd.Registerer, globals *config.Data, data manifest.D Description: cmd.FlagServiceDesc, Dst: &c.serviceName.Value, }) - c.RegisterFlag(cmd.StringFlagOpts{ - Name: cmd.FlagVersionName, - Description: cmd.FlagVersionDesc, - Dst: &c.serviceVersion.Value, - Required: true, - }) return &c } diff --git a/pkg/commands/logging/sumologic/update.go b/pkg/commands/logging/sumologic/update.go index 1e371fdb7..186b1753a 100644 --- a/pkg/commands/logging/sumologic/update.go +++ b/pkg/commands/logging/sumologic/update.go @@ -35,21 +35,34 @@ type UpdateCommand struct { // NewUpdateCommand returns a usable command registered under the parent. func NewUpdateCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *UpdateCommand { - var c UpdateCommand - c.Globals = globals - c.Manifest = data + c := UpdateCommand{ + Base: cmd.Base{ + Globals: globals, + }, + Manifest: data, + } c.CmdClause = parent.Command("update", "Update a Sumologic logging endpoint on a Fastly service version") + + // required + c.CmdClause.Flag("name", "The name of the Sumologic logging object").Short('n').Required().StringVar(&c.EndpointName) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagVersionName, Description: cmd.FlagVersionDesc, Dst: &c.ServiceVersion.Value, Required: true, }) + + // optional c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ Action: c.AutoClone.Set, Dst: &c.AutoClone.Value, }) - c.CmdClause.Flag("name", "The name of the Sumologic logging object").Short('n').Required().StringVar(&c.EndpointName) + common.Format(c.CmdClause, &c.Format) + c.CmdClause.Flag("format-version", "The version of the custom logging format used for the configured endpoint. Can be either 2 (the default, version 2 log format) or 1 (the version 1 log format). The logging call gets placed by default in vcl_log if format_version is set to 2 and in vcl_deliver if format_version is set to 1").Action(c.FormatVersion.Set).IntVar(&c.FormatVersion.Value) + common.MessageType(c.CmdClause, &c.MessageType) + c.CmdClause.Flag("new-name", "New name of the Sumologic logging object").Action(c.NewName.Set).StringVar(&c.NewName.Value) + common.Placement(c.CmdClause, &c.Placement) + common.ResponseCondition(c.CmdClause, &c.ResponseCondition) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagServiceIDName, Description: cmd.FlagServiceIDDesc, @@ -62,13 +75,7 @@ func NewUpdateCommand(parent cmd.Registerer, globals *config.Data, data manifest Description: cmd.FlagServiceDesc, Dst: &c.ServiceName.Value, }) - c.CmdClause.Flag("new-name", "New name of the Sumologic logging object").Action(c.NewName.Set).StringVar(&c.NewName.Value) c.CmdClause.Flag("url", "The URL to POST to").Action(c.URL.Set).StringVar(&c.URL.Value) - common.Format(c.CmdClause, &c.Format) - c.CmdClause.Flag("format-version", "The version of the custom logging format used for the configured endpoint. Can be either 2 (the default, version 2 log format) or 1 (the version 1 log format). The logging call gets placed by default in vcl_log if format_version is set to 2 and in vcl_deliver if format_version is set to 1").Action(c.FormatVersion.Set).IntVar(&c.FormatVersion.Value) - common.ResponseCondition(c.CmdClause, &c.ResponseCondition) - common.MessageType(c.CmdClause, &c.MessageType) - common.Placement(c.CmdClause, &c.Placement) return &c } diff --git a/pkg/commands/logging/syslog/create.go b/pkg/commands/logging/syslog/create.go index e0649a0c0..b432b5f36 100644 --- a/pkg/commands/logging/syslog/create.go +++ b/pkg/commands/logging/syslog/create.go @@ -41,10 +41,15 @@ type CreateCommand struct { // NewCreateCommand returns a usable command registered under the parent. func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *CreateCommand { - var c CreateCommand - c.Globals = globals - c.Manifest = data + c := CreateCommand{ + Base: cmd.Base{ + Globals: globals, + }, + Manifest: data, + } c.CmdClause = parent.Command("create", "Create a Syslog logging endpoint on a Fastly service version").Alias("add") + + // required c.CmdClause.Flag("name", "The name of the Syslog logging object. Used as a primary key for API access").Short('n').Action(c.EndpointName.Set).StringVar(&c.EndpointName.Value) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagVersionName, @@ -52,36 +57,37 @@ func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest Dst: &c.ServiceVersion.Value, Required: true, }) + + // optional + c.CmdClause.Flag("address", "A hostname or IPv4 address").Action(c.Address.Set).StringVar(&c.Address.Value) + c.CmdClause.Flag("auth-token", "Whether to prepend each message with a specific token").Action(c.Token.Set).StringVar(&c.Token.Value) c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ Action: c.AutoClone.Set, Dst: &c.AutoClone.Value, }) - c.CmdClause.Flag("address", "A hostname or IPv4 address").Action(c.Address.Set).StringVar(&c.Address.Value) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagServiceIDName, Description: cmd.FlagServiceIDDesc, Dst: &c.Manifest.Flag.ServiceID, Short: 's', }) + common.Format(c.CmdClause, &c.Format) + common.FormatVersion(c.CmdClause, &c.FormatVersion) + common.MessageType(c.CmdClause, &c.MessageType) + common.Placement(c.CmdClause, &c.Placement) + c.CmdClause.Flag("port", "The port number").Action(c.Port.Set).IntVar(&c.Port.Value) + common.ResponseCondition(c.CmdClause, &c.ResponseCondition) c.RegisterFlag(cmd.StringFlagOpts{ Action: c.ServiceName.Set, Name: cmd.FlagServiceName, Description: cmd.FlagServiceDesc, Dst: &c.ServiceName.Value, }) - c.CmdClause.Flag("port", "The port number").Action(c.Port.Set).IntVar(&c.Port.Value) - c.CmdClause.Flag("use-tls", "Whether to use TLS for secure logging. Can be either true or false").Action(c.UseTLS.Set).BoolVar(&c.UseTLS.Value) - c.CmdClause.Flag("auth-token", "Whether to prepend each message with a specific token").Action(c.Token.Set).StringVar(&c.Token.Value) - // c.CmdClause.Flag("tls-hostname", "Used during the TLS handshake to validate the certificate").Action(c.TLSHostname.Set).StringVar(&c.TLSHostname.Value) common.TLSCACert(c.CmdClause, &c.TLSCACert) common.TLSClientCert(c.CmdClause, &c.TLSClientCert) common.TLSClientKey(c.CmdClause, &c.TLSClientKey) common.TLSHostname(c.CmdClause, &c.TLSHostname) - common.Format(c.CmdClause, &c.Format) - common.FormatVersion(c.CmdClause, &c.FormatVersion) - common.MessageType(c.CmdClause, &c.MessageType) - common.ResponseCondition(c.CmdClause, &c.ResponseCondition) - common.Placement(c.CmdClause, &c.Placement) + c.CmdClause.Flag("use-tls", "Whether to use TLS for secure logging. Can be either true or false").Action(c.UseTLS.Set).BoolVar(&c.UseTLS.Value) return &c } diff --git a/pkg/commands/logging/syslog/delete.go b/pkg/commands/logging/syslog/delete.go index 4f933214d..d3f718c51 100644 --- a/pkg/commands/logging/syslog/delete.go +++ b/pkg/commands/logging/syslog/delete.go @@ -23,21 +23,28 @@ type DeleteCommand struct { // NewDeleteCommand returns a usable command registered under the parent. func NewDeleteCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *DeleteCommand { - var c DeleteCommand - c.Globals = globals - c.manifest = data + c := DeleteCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("delete", "Delete a Syslog logging endpoint on a Fastly service version").Alias("remove") + + // required + c.CmdClause.Flag("name", "The name of the Syslog logging object").Short('n').Required().StringVar(&c.Input.Name) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagVersionName, Description: cmd.FlagVersionDesc, Dst: &c.serviceVersion.Value, Required: true, }) + + // optional c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ Action: c.autoClone.Set, Dst: &c.autoClone.Value, }) - c.CmdClause.Flag("name", "The name of the Syslog logging object").Short('n').Required().StringVar(&c.Input.Name) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagServiceIDName, Description: cmd.FlagServiceIDDesc, diff --git a/pkg/commands/logging/syslog/describe.go b/pkg/commands/logging/syslog/describe.go index 30d8b93bb..5ca0e86c7 100644 --- a/pkg/commands/logging/syslog/describe.go +++ b/pkg/commands/logging/syslog/describe.go @@ -25,10 +25,24 @@ type DescribeCommand struct { // NewDescribeCommand returns a usable command registered under the parent. func NewDescribeCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *DescribeCommand { - var c DescribeCommand - c.Globals = globals - c.manifest = data + c := DescribeCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("describe", "Show detailed information about a Syslog logging endpoint on a Fastly service version").Alias("get") + + // required + c.CmdClause.Flag("name", "The name of the Syslog logging object").Short('n').Required().StringVar(&c.Input.Name) + c.RegisterFlag(cmd.StringFlagOpts{ + Name: cmd.FlagVersionName, + Description: cmd.FlagVersionDesc, + Dst: &c.serviceVersion.Value, + Required: true, + }) + + // optional c.RegisterFlagBool(cmd.BoolFlagOpts{ Name: cmd.FlagJSONName, Description: cmd.FlagJSONDesc, @@ -47,13 +61,6 @@ func NewDescribeCommand(parent cmd.Registerer, globals *config.Data, data manife Description: cmd.FlagServiceDesc, Dst: &c.serviceName.Value, }) - c.RegisterFlag(cmd.StringFlagOpts{ - Name: cmd.FlagVersionName, - Description: cmd.FlagVersionDesc, - Dst: &c.serviceVersion.Value, - Required: true, - }) - c.CmdClause.Flag("name", "The name of the Syslog logging object").Short('n').Required().StringVar(&c.Input.Name) return &c } diff --git a/pkg/commands/logging/syslog/list.go b/pkg/commands/logging/syslog/list.go index be1095931..069e8f1c1 100644 --- a/pkg/commands/logging/syslog/list.go +++ b/pkg/commands/logging/syslog/list.go @@ -25,10 +25,23 @@ type ListCommand struct { // NewListCommand returns a usable command registered under the parent. func NewListCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *ListCommand { - var c ListCommand - c.Globals = globals - c.manifest = data + c := ListCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("list", "List Syslog endpoints on a Fastly service version") + + // required + c.RegisterFlag(cmd.StringFlagOpts{ + Name: cmd.FlagVersionName, + Description: cmd.FlagVersionDesc, + Dst: &c.serviceVersion.Value, + Required: true, + }) + + // optional c.RegisterFlagBool(cmd.BoolFlagOpts{ Name: cmd.FlagJSONName, Description: cmd.FlagJSONDesc, @@ -47,12 +60,6 @@ func NewListCommand(parent cmd.Registerer, globals *config.Data, data manifest.D Description: cmd.FlagServiceDesc, Dst: &c.serviceName.Value, }) - c.RegisterFlag(cmd.StringFlagOpts{ - Name: cmd.FlagVersionName, - Description: cmd.FlagVersionDesc, - Dst: &c.serviceVersion.Value, - Required: true, - }) return &c } diff --git a/pkg/commands/logging/syslog/update.go b/pkg/commands/logging/syslog/update.go index 493444d6b..0a188c545 100644 --- a/pkg/commands/logging/syslog/update.go +++ b/pkg/commands/logging/syslog/update.go @@ -42,21 +42,36 @@ type UpdateCommand struct { // NewUpdateCommand returns a usable command registered under the parent. func NewUpdateCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *UpdateCommand { - var c UpdateCommand - c.Globals = globals - c.Manifest = data + c := UpdateCommand{ + Base: cmd.Base{ + Globals: globals, + }, + Manifest: data, + } c.CmdClause = parent.Command("update", "Update a Syslog logging endpoint on a Fastly service version") + + // required + c.CmdClause.Flag("name", "The name of the Syslog logging object").Short('n').Required().StringVar(&c.EndpointName) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagVersionName, Description: cmd.FlagVersionDesc, Dst: &c.ServiceVersion.Value, Required: true, }) + + // optional + c.CmdClause.Flag("address", "A hostname or IPv4 address").Action(c.Address.Set).StringVar(&c.Address.Value) + c.CmdClause.Flag("auth-token", "Whether to prepend each message with a specific token").Action(c.Token.Set).StringVar(&c.Token.Value) c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ Action: c.AutoClone.Set, Dst: &c.AutoClone.Value, }) - c.CmdClause.Flag("name", "The name of the Syslog logging object").Short('n').Required().StringVar(&c.EndpointName) + common.Format(c.CmdClause, &c.Format) + common.FormatVersion(c.CmdClause, &c.FormatVersion) + c.CmdClause.Flag("new-name", "New name of the Syslog logging object").Action(c.NewName.Set).StringVar(&c.NewName.Value) + common.MessageType(c.CmdClause, &c.MessageType) + common.Placement(c.CmdClause, &c.Placement) + c.CmdClause.Flag("port", "The port number").Action(c.Port.Set).IntVar(&c.Port.Value) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagServiceIDName, Description: cmd.FlagServiceIDDesc, @@ -69,20 +84,12 @@ func NewUpdateCommand(parent cmd.Registerer, globals *config.Data, data manifest Description: cmd.FlagServiceDesc, Dst: &c.ServiceName.Value, }) - c.CmdClause.Flag("new-name", "New name of the Syslog logging object").Action(c.NewName.Set).StringVar(&c.NewName.Value) - c.CmdClause.Flag("address", "A hostname or IPv4 address").Action(c.Address.Set).StringVar(&c.Address.Value) - c.CmdClause.Flag("port", "The port number").Action(c.Port.Set).IntVar(&c.Port.Value) - c.CmdClause.Flag("use-tls", "Whether to use TLS for secure logging. Can be either true or false").Action(c.UseTLS.Set).BoolVar(&c.UseTLS.Value) + common.ResponseCondition(c.CmdClause, &c.ResponseCondition) common.TLSCACert(c.CmdClause, &c.TLSCACert) common.TLSClientCert(c.CmdClause, &c.TLSClientCert) common.TLSClientKey(c.CmdClause, &c.TLSClientKey) c.CmdClause.Flag("tls-hostname", "Used during the TLS handshake to validate the certificate").Action(c.TLSHostname.Set).StringVar(&c.TLSHostname.Value) - c.CmdClause.Flag("auth-token", "Whether to prepend each message with a specific token").Action(c.Token.Set).StringVar(&c.Token.Value) - common.Format(c.CmdClause, &c.Format) - common.FormatVersion(c.CmdClause, &c.FormatVersion) - common.MessageType(c.CmdClause, &c.MessageType) - common.ResponseCondition(c.CmdClause, &c.ResponseCondition) - common.Placement(c.CmdClause, &c.Placement) + c.CmdClause.Flag("use-tls", "Whether to use TLS for secure logging. Can be either true or false").Action(c.UseTLS.Set).BoolVar(&c.UseTLS.Value) return &c } diff --git a/pkg/commands/objectstore/create.go b/pkg/commands/objectstore/create.go index b9427b2cf..209845f95 100644 --- a/pkg/commands/objectstore/create.go +++ b/pkg/commands/objectstore/create.go @@ -19,9 +19,12 @@ type CreateCommand struct { // NewCreateCommand returns a usable command registered under the parent. func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *CreateCommand { - var c CreateCommand - c.Globals = globals - c.manifest = data + c := CreateCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("create", "Create a Fastly object store") c.CmdClause.Flag("name", "Name of Object Store").Short('n').Required().StringVar(&c.Input.Name) return &c diff --git a/pkg/commands/objectstore/delete.go b/pkg/commands/objectstore/delete.go index 304e571a3..4567ed9cd 100644 --- a/pkg/commands/objectstore/delete.go +++ b/pkg/commands/objectstore/delete.go @@ -19,9 +19,12 @@ type DeleteCommand struct { // NewDeleteCommand returns a usable command registered under the parent. func NewDeleteCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *DeleteCommand { - var c DeleteCommand - c.Globals = globals - c.manifest = data + c := DeleteCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("delete", "Delete a Fastly object store") c.CmdClause.Flag("id", "ID of object store").Required().StringVar(&c.Input.ID) return &c diff --git a/pkg/commands/objectstore/list.go b/pkg/commands/objectstore/list.go index 8f41bd844..03913a796 100644 --- a/pkg/commands/objectstore/list.go +++ b/pkg/commands/objectstore/list.go @@ -19,9 +19,12 @@ type ListCommand struct { // NewListCommand returns a usable command registered under the parent. func NewListCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *ListCommand { - var c ListCommand - c.Globals = globals - c.manifest = data + c := ListCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("list", "List Fastly object stores") return &c } diff --git a/pkg/commands/purge/root.go b/pkg/commands/purge/root.go index c5a599c1b..64668cb16 100644 --- a/pkg/commands/purge/root.go +++ b/pkg/commands/purge/root.go @@ -23,7 +23,7 @@ func NewRootCommand(parent cmd.Registerer, globals *config.Data, data manifest.D c.Globals = globals c.manifest = data - // Optional flags + // optional c.CmdClause.Flag("all", "Purge everything from a service").BoolVar(&c.all) c.CmdClause.Flag("file", "Purge a service of a newline delimited list of Surrogate Keys").StringVar(&c.file) c.CmdClause.Flag("key", "Purge a service of objects tagged with a Surrogate Key").StringVar(&c.key) diff --git a/pkg/commands/service/create.go b/pkg/commands/service/create.go index da8495e52..a759295b2 100644 --- a/pkg/commands/service/create.go +++ b/pkg/commands/service/create.go @@ -21,12 +21,17 @@ type CreateCommand struct { // NewCreateCommand returns a usable command registered under the parent. func NewCreateCommand(parent cmd.Registerer, globals *config.Data) *CreateCommand { - var c CreateCommand - c.Globals = globals + c := CreateCommand{ + Base: cmd.Base{ + Globals: globals, + }, + } c.CmdClause = parent.Command("create", "Create a Fastly service").Alias("add") + + // optional + c.CmdClause.Flag("comment", "Human-readable comment").Action(c.comment.Set).StringVar(&c.comment.Value) c.CmdClause.Flag("name", "Service name").Short('n').Action(c.name.Set).StringVar(&c.name.Value) c.CmdClause.Flag("type", `Service type. Can be one of "wasm" or "vcl", defaults to "vcl".`).Default("vcl").Action(c.stype.Set).EnumVar(&c.stype.Value, "wasm", "vcl") - c.CmdClause.Flag("comment", "Human-readable comment").Action(c.comment.Set).StringVar(&c.comment.Value) return &c } diff --git a/pkg/commands/service/delete.go b/pkg/commands/service/delete.go index 3ccf7e422..4a3f3ce47 100644 --- a/pkg/commands/service/delete.go +++ b/pkg/commands/service/delete.go @@ -23,10 +23,16 @@ type DeleteCommand struct { // NewDeleteCommand returns a usable command registered under the parent. func NewDeleteCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *DeleteCommand { - var c DeleteCommand - c.Globals = globals - c.manifest = data + c := DeleteCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("delete", "Delete a Fastly service").Alias("remove") + + // optional + c.CmdClause.Flag("force", "Force deletion of an active service").Short('f').BoolVar(&c.force) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagServiceIDName, Description: cmd.FlagServiceIDDesc, @@ -39,7 +45,6 @@ func NewDeleteCommand(parent cmd.Registerer, globals *config.Data, data manifest Description: cmd.FlagServiceDesc, Dst: &c.serviceName.Value, }) - c.CmdClause.Flag("force", "Force deletion of an active service").Short('f').BoolVar(&c.force) return &c } diff --git a/pkg/commands/service/describe.go b/pkg/commands/service/describe.go index 4c58739df..734891cfc 100644 --- a/pkg/commands/service/describe.go +++ b/pkg/commands/service/describe.go @@ -26,10 +26,15 @@ type DescribeCommand struct { // NewDescribeCommand returns a usable command registered under the parent. func NewDescribeCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *DescribeCommand { - var c DescribeCommand - c.Globals = globals - c.manifest = data + c := DescribeCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("describe", "Show detailed information about a Fastly service").Alias("get") + + // optional c.RegisterFlagBool(cmd.BoolFlagOpts{ Name: cmd.FlagJSONName, Description: cmd.FlagJSONDesc, diff --git a/pkg/commands/service/list.go b/pkg/commands/service/list.go index aa728fc09..0baa4fc1f 100644 --- a/pkg/commands/service/list.go +++ b/pkg/commands/service/list.go @@ -22,9 +22,14 @@ type ListCommand struct { // NewListCommand returns a usable command registered under the parent. func NewListCommand(parent cmd.Registerer, globals *config.Data) *ListCommand { - var c ListCommand - c.Globals = globals + c := ListCommand{ + Base: cmd.Base{ + Globals: globals, + }, + } c.CmdClause = parent.Command("list", "List Fastly services") + + // optional c.CmdClause.Flag("direction", "Direction in which to sort results").Default(cmd.PaginationDirection[0]).HintOptions(cmd.PaginationDirection...).EnumVar(&c.input.Direction, cmd.PaginationDirection...) c.RegisterFlagBool(cmd.BoolFlagOpts{ Name: cmd.FlagJSONName, diff --git a/pkg/commands/service/search.go b/pkg/commands/service/search.go index b975c15bf..5fdde6024 100644 --- a/pkg/commands/service/search.go +++ b/pkg/commands/service/search.go @@ -19,11 +19,16 @@ type SearchCommand struct { // NewSearchCommand returns a usable command registered under the parent. func NewSearchCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *SearchCommand { - var c SearchCommand - c.Globals = globals - c.manifest = data + c := SearchCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("search", "Search for a Fastly service by name") + // required c.CmdClause.Flag("name", "Service name").Short('n').Required().StringVar(&c.Input.Name) + return &c } diff --git a/pkg/commands/service/update.go b/pkg/commands/service/update.go index 415753340..280c2fb32 100644 --- a/pkg/commands/service/update.go +++ b/pkg/commands/service/update.go @@ -24,10 +24,17 @@ type UpdateCommand struct { // NewUpdateCommand returns a usable command registered under the parent. func NewUpdateCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *UpdateCommand { - var c UpdateCommand - c.Globals = globals - c.manifest = data + c := UpdateCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("update", "Update a Fastly service") + + // optional + c.CmdClause.Flag("comment", "Human-readable comment").Action(c.comment.Set).StringVar(&c.comment.Value) + c.CmdClause.Flag("name", "Service name").Short('n').Action(c.name.Set).StringVar(&c.name.Value) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagServiceIDName, Description: cmd.FlagServiceIDDesc, @@ -40,8 +47,6 @@ func NewUpdateCommand(parent cmd.Registerer, globals *config.Data, data manifest Description: cmd.FlagServiceDesc, Dst: &c.serviceName.Value, }) - c.CmdClause.Flag("name", "Service name").Short('n').Action(c.name.Set).StringVar(&c.name.Value) - c.CmdClause.Flag("comment", "Human-readable comment").Action(c.comment.Set).StringVar(&c.comment.Value) return &c } diff --git a/pkg/commands/serviceauth/create.go b/pkg/commands/serviceauth/create.go index bb2fa756e..b8f97d619 100644 --- a/pkg/commands/serviceauth/create.go +++ b/pkg/commands/serviceauth/create.go @@ -25,15 +25,21 @@ type CreateCommand struct { // NewCreateCommand returns a usable command registered under the parent. func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *CreateCommand { - var c CreateCommand - c.Globals = globals - c.manifest = data + c := CreateCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("create", "Create service authorization").Alias("add") + // required + c.CmdClause.Flag("user-id", "Alphanumeric string identifying the user").Required().Short('u').StringVar(&c.userID) + + // optional // NOTE: We default to 'read_only' for security reasons. // The API otherwise defaults to 'full' permissions! c.CmdClause.Flag("permission", "The permission the user has in relation to the service (default: read_only)").HintOptions(Permissions...).Default("read_only").Short('p').EnumVar(&c.input.Permission, Permissions...) - c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagServiceIDName, Description: cmd.FlagServiceIDDesc, @@ -46,7 +52,6 @@ func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest Description: cmd.FlagServiceDesc, Dst: &c.serviceName.Value, }) - c.CmdClause.Flag("user-id", "Alphanumeric string identifying the user").Required().Short('u').StringVar(&c.userID) return &c } diff --git a/pkg/commands/serviceauth/delete.go b/pkg/commands/serviceauth/delete.go index 4290b6511..de823a886 100644 --- a/pkg/commands/serviceauth/delete.go +++ b/pkg/commands/serviceauth/delete.go @@ -19,10 +19,15 @@ type DeleteCommand struct { // NewDeleteCommand returns a usable command registered under the parent. func NewDeleteCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *DeleteCommand { - var c DeleteCommand - c.Globals = globals - c.manifest = data + c := DeleteCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("delete", "Delete service authorization").Alias("remove") + + // required c.CmdClause.Flag("id", "ID of the service authorization to delete").Required().StringVar(&c.Input.ID) return &c } diff --git a/pkg/commands/serviceauth/describe.go b/pkg/commands/serviceauth/describe.go index f79349c46..d1a0e3202 100644 --- a/pkg/commands/serviceauth/describe.go +++ b/pkg/commands/serviceauth/describe.go @@ -23,11 +23,18 @@ type DescribeCommand struct { // NewDescribeCommand returns a usable command registered under the parent. func NewDescribeCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *DescribeCommand { - var c DescribeCommand - c.Globals = globals - c.manifest = data + c := DescribeCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("describe", "Show service authorization").Alias("get") + + // required c.CmdClause.Flag("id", "ID of the service authorization to retrieve").Required().StringVar(&c.Input.ID) + + // optional c.RegisterFlagBool(cmd.BoolFlagOpts{ Name: cmd.FlagJSONName, Description: cmd.FlagJSONDesc, diff --git a/pkg/commands/serviceauth/list.go b/pkg/commands/serviceauth/list.go index 0d4bdb76d..d1b0b4a32 100644 --- a/pkg/commands/serviceauth/list.go +++ b/pkg/commands/serviceauth/list.go @@ -25,6 +25,8 @@ func NewListCommand(parent cmd.Registerer, globals *config.Data) *ListCommand { var c ListCommand c.Globals = globals c.CmdClause = parent.Command("list", "List service authorizations") + + // optional c.RegisterFlagBool(cmd.BoolFlagOpts{ Name: cmd.FlagJSONName, Description: cmd.FlagJSONDesc, diff --git a/pkg/commands/serviceauth/update.go b/pkg/commands/serviceauth/update.go index 157087cae..646ae06e8 100644 --- a/pkg/commands/serviceauth/update.go +++ b/pkg/commands/serviceauth/update.go @@ -20,10 +20,15 @@ type UpdateCommand struct { // NewUpdateCommand returns a usable command registered under the parent. func NewUpdateCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *UpdateCommand { - var c UpdateCommand - c.Globals = globals - c.manifest = data + c := UpdateCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("update", "Update service authorization") + + // required c.CmdClause.Flag("id", "ID of the service authorization to delete").Required().StringVar(&c.input.ID) c.CmdClause.Flag("permission", "The permission the user has in relation to the service").Required().HintOptions(Permissions...).Short('p').EnumVar(&c.input.Permission, Permissions...) return &c diff --git a/pkg/commands/serviceversion/list.go b/pkg/commands/serviceversion/list.go index 014c7be59..2c6f25af6 100644 --- a/pkg/commands/serviceversion/list.go +++ b/pkg/commands/serviceversion/list.go @@ -25,9 +25,12 @@ type ListCommand struct { // NewListCommand returns a usable command registered under the parent. func NewListCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *ListCommand { - var c ListCommand - c.Globals = globals - c.manifest = data + c := ListCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("list", "List Fastly service versions") c.RegisterFlagBool(cmd.BoolFlagOpts{ Name: cmd.FlagJSONName, diff --git a/pkg/commands/serviceversion/update.go b/pkg/commands/serviceversion/update.go index 8e253b3a1..58ee77d76 100644 --- a/pkg/commands/serviceversion/update.go +++ b/pkg/commands/serviceversion/update.go @@ -26,9 +26,12 @@ type UpdateCommand struct { // NewUpdateCommand returns a usable command registered under the parent. func NewUpdateCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *UpdateCommand { - var c UpdateCommand - c.Globals = globals - c.manifest = data + c := UpdateCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("update", "Update a Fastly service version") c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagServiceIDName, diff --git a/pkg/commands/tls/config/describe.go b/pkg/commands/tls/config/describe.go index 21934ce83..a3e79c8c4 100644 --- a/pkg/commands/tls/config/describe.go +++ b/pkg/commands/tls/config/describe.go @@ -21,10 +21,10 @@ func NewDescribeCommand(parent cmd.Registerer, globals *config.Data, data manife c.Globals = globals c.manifest = data - // Required flags + // required c.CmdClause.Flag("id", "Alphanumeric string identifying a TLS configuration").Required().StringVar(&c.id) - // Optional Flags + // optional c.CmdClause.Flag("include", "Include related objects (comma-separated values)").HintOptions(include).EnumVar(&c.include, include) c.RegisterFlagBool(cmd.BoolFlagOpts{ Name: cmd.FlagJSONName, diff --git a/pkg/commands/tls/config/list.go b/pkg/commands/tls/config/list.go index 7a29141e8..f152c8283 100644 --- a/pkg/commands/tls/config/list.go +++ b/pkg/commands/tls/config/list.go @@ -21,7 +21,7 @@ func NewListCommand(parent cmd.Registerer, globals *config.Data, data manifest.D c.Globals = globals c.manifest = data - // Optional Flags + // optional c.CmdClause.Flag("filter-bulk", "Optionally filter by the bulk attribute").Action(c.filterBulk.Set).BoolVar(&c.filterBulk.Value) c.CmdClause.Flag("include", "Include related objects (comma-separated values)").HintOptions(include).EnumVar(&c.include, include) c.RegisterFlagBool(cmd.BoolFlagOpts{ diff --git a/pkg/commands/tls/config/update.go b/pkg/commands/tls/config/update.go index 61e31f894..3a9582512 100644 --- a/pkg/commands/tls/config/update.go +++ b/pkg/commands/tls/config/update.go @@ -17,7 +17,7 @@ func NewUpdateCommand(parent cmd.Registerer, globals *config.Data, data manifest c.Globals = globals c.manifest = data - // Required flags + // required c.CmdClause.Flag("id", "Alphanumeric string identifying a TLS configuration").Required().StringVar(&c.id) c.CmdClause.Flag("name", "A custom name for your TLS configuration").Required().StringVar(&c.name) return &c diff --git a/pkg/commands/tls/custom/activation/create.go b/pkg/commands/tls/custom/activation/create.go index 049861ccd..f10ee8ef1 100644 --- a/pkg/commands/tls/custom/activation/create.go +++ b/pkg/commands/tls/custom/activation/create.go @@ -17,7 +17,7 @@ func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest c.Globals = globals c.manifest = data - // Required flags + // required c.CmdClause.Flag("cert-id", "Alphanumeric string identifying a TLS certificate").Required().StringVar(&c.certID) c.CmdClause.Flag("id", "Alphanumeric string identifying a TLS activation").Required().StringVar(&c.id) diff --git a/pkg/commands/tls/custom/activation/delete.go b/pkg/commands/tls/custom/activation/delete.go index 39b21fc19..c5be4ea55 100644 --- a/pkg/commands/tls/custom/activation/delete.go +++ b/pkg/commands/tls/custom/activation/delete.go @@ -17,7 +17,7 @@ func NewDeleteCommand(parent cmd.Registerer, globals *config.Data, data manifest c.Globals = globals c.manifest = data - // Required flags + // required c.CmdClause.Flag("id", "Alphanumeric string identifying a TLS activation").Required().StringVar(&c.id) return &c diff --git a/pkg/commands/tls/custom/activation/describe.go b/pkg/commands/tls/custom/activation/describe.go index f95111291..22d44170c 100644 --- a/pkg/commands/tls/custom/activation/describe.go +++ b/pkg/commands/tls/custom/activation/describe.go @@ -21,10 +21,10 @@ func NewDescribeCommand(parent cmd.Registerer, globals *config.Data, data manife c.Globals = globals c.manifest = data - // Required flags + // required c.CmdClause.Flag("id", "Alphanumeric string identifying a TLS activation").Required().StringVar(&c.id) - // Optional Flags + // optional c.CmdClause.Flag("include", "Include related objects (comma-separated values)").HintOptions(include...).EnumVar(&c.include, include...) c.RegisterFlagBool(cmd.BoolFlagOpts{ Name: cmd.FlagJSONName, diff --git a/pkg/commands/tls/custom/activation/list.go b/pkg/commands/tls/custom/activation/list.go index d6a7ec717..74b2e919c 100644 --- a/pkg/commands/tls/custom/activation/list.go +++ b/pkg/commands/tls/custom/activation/list.go @@ -20,7 +20,7 @@ func NewListCommand(parent cmd.Registerer, globals *config.Data, data manifest.D c.Globals = globals c.manifest = data - // Optional Flags + // optional c.CmdClause.Flag("filter-cert", "Limit the returned activations to a specific certificate").StringVar(&c.filterTLSCertID) c.CmdClause.Flag("filter-config", "Limit the returned activations to a specific TLS configuration").StringVar(&c.filterTLSConfigID) c.CmdClause.Flag("filter-domain", "Limit the returned rules to a specific domain name").StringVar(&c.filterTLSDomainID) diff --git a/pkg/commands/tls/custom/activation/update.go b/pkg/commands/tls/custom/activation/update.go index 45b35fef0..2677bafaf 100644 --- a/pkg/commands/tls/custom/activation/update.go +++ b/pkg/commands/tls/custom/activation/update.go @@ -17,7 +17,7 @@ func NewUpdateCommand(parent cmd.Registerer, globals *config.Data, data manifest c.Globals = globals c.manifest = data - // Required flags + // required c.CmdClause.Flag("cert-id", "Alphanumeric string identifying a TLS certificate").Required().StringVar(&c.certID) c.CmdClause.Flag("id", "Alphanumeric string identifying a TLS activation").Required().StringVar(&c.id) return &c diff --git a/pkg/commands/tls/custom/certificate/create.go b/pkg/commands/tls/custom/certificate/create.go index be6b56095..23b4930c1 100644 --- a/pkg/commands/tls/custom/certificate/create.go +++ b/pkg/commands/tls/custom/certificate/create.go @@ -17,10 +17,10 @@ func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest c.Globals = globals c.manifest = data - // Required flags + // required c.CmdClause.Flag("cert-blob", "The PEM-formatted certificate blob").Required().StringVar(&c.certBlob) - // Optional flags + // optional c.CmdClause.Flag("id", "Alphanumeric string identifying a TLS certificate").StringVar(&c.id) c.CmdClause.Flag("name", "A customizable name for your certificate. Defaults to the certificate's Common Name or first Subject Alternative Names (SAN) entry").StringVar(&c.name) diff --git a/pkg/commands/tls/custom/certificate/delete.go b/pkg/commands/tls/custom/certificate/delete.go index c327d300b..c8209342b 100644 --- a/pkg/commands/tls/custom/certificate/delete.go +++ b/pkg/commands/tls/custom/certificate/delete.go @@ -17,7 +17,7 @@ func NewDeleteCommand(parent cmd.Registerer, globals *config.Data, data manifest c.Globals = globals c.manifest = data - // Required flags + // required c.CmdClause.Flag("id", "Alphanumeric string identifying a TLS certificate").Required().StringVar(&c.id) return &c diff --git a/pkg/commands/tls/custom/certificate/describe.go b/pkg/commands/tls/custom/certificate/describe.go index 09daa7dd6..ca03ea442 100644 --- a/pkg/commands/tls/custom/certificate/describe.go +++ b/pkg/commands/tls/custom/certificate/describe.go @@ -19,10 +19,10 @@ func NewDescribeCommand(parent cmd.Registerer, globals *config.Data, data manife c.Globals = globals c.manifest = data - // Required flags + // required c.CmdClause.Flag("id", "Alphanumeric string identifying a TLS certificate").Required().StringVar(&c.id) - // Optional Flags + // optional c.RegisterFlagBool(cmd.BoolFlagOpts{ Name: cmd.FlagJSONName, Description: cmd.FlagJSONDesc, diff --git a/pkg/commands/tls/custom/certificate/list.go b/pkg/commands/tls/custom/certificate/list.go index bbb707f33..2c6dcd178 100644 --- a/pkg/commands/tls/custom/certificate/list.go +++ b/pkg/commands/tls/custom/certificate/list.go @@ -22,7 +22,7 @@ func NewListCommand(parent cmd.Registerer, globals *config.Data, data manifest.D c.Globals = globals c.manifest = data - // Optional Flags + // optional c.CmdClause.Flag("filter-not-after", "Limit the returned certificates to those that expire prior to the specified date in UTC").StringVar(&c.filterNotAfter) c.CmdClause.Flag("filter-domain", "Limit the returned certificates to those that include the specific domain").StringVar(&c.filterTLSDomainID) c.CmdClause.Flag("include", "Include related objects (comma-separated values)").HintOptions("tls_activations").EnumVar(&c.include, "tls_activations") diff --git a/pkg/commands/tls/custom/certificate/update.go b/pkg/commands/tls/custom/certificate/update.go index 9583c6886..9a5c5ecfe 100644 --- a/pkg/commands/tls/custom/certificate/update.go +++ b/pkg/commands/tls/custom/certificate/update.go @@ -17,11 +17,11 @@ func NewUpdateCommand(parent cmd.Registerer, globals *config.Data, data manifest c.Globals = globals c.manifest = data - // Required flags + // required c.CmdClause.Flag("cert-blob", "The PEM-formatted certificate blob").Required().StringVar(&c.certBlob) c.CmdClause.Flag("id", "Alphanumeric string identifying a TLS certificate").Required().StringVar(&c.id) - // Optional flags + // optional c.CmdClause.Flag("name", "A customizable name for your certificate. Defaults to the certificate's Common Name or first Subject Alternative Names (SAN) entry").StringVar(&c.name) return &c } diff --git a/pkg/commands/tls/custom/domain/list.go b/pkg/commands/tls/custom/domain/list.go index 64f2345c2..2f3ef3712 100644 --- a/pkg/commands/tls/custom/domain/list.go +++ b/pkg/commands/tls/custom/domain/list.go @@ -22,7 +22,7 @@ func NewListCommand(parent cmd.Registerer, globals *config.Data, data manifest.D c.Globals = globals c.manifest = data - // Optional Flags + // optional c.CmdClause.Flag("filter-cert", "Limit the returned domains to those listed in the given TLS certificate's SAN list").StringVar(&c.filterTLSCertsID) c.CmdClause.Flag("filter-in-use", "Limit the returned domains to those currently using Fastly to terminate TLS with SNI").Action(c.filterInUse.Set).BoolVar(&c.filterInUse.Value) c.CmdClause.Flag("filter-subscription", "Limit the returned domains to those for a given TLS subscription").StringVar(&c.filterTLSSubsID) diff --git a/pkg/commands/tls/custom/privatekey/create.go b/pkg/commands/tls/custom/privatekey/create.go index 8903519f2..7d005aecf 100644 --- a/pkg/commands/tls/custom/privatekey/create.go +++ b/pkg/commands/tls/custom/privatekey/create.go @@ -17,7 +17,7 @@ func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest c.Globals = globals c.manifest = data - // Required flags + // required c.CmdClause.Flag("key", "The contents of the private key. Must be a PEM-formatted key").Required().StringVar(&c.key) c.CmdClause.Flag("name", "A customizable name for your private key").Required().StringVar(&c.name) diff --git a/pkg/commands/tls/custom/privatekey/delete.go b/pkg/commands/tls/custom/privatekey/delete.go index 2d528bae0..6bef9e674 100644 --- a/pkg/commands/tls/custom/privatekey/delete.go +++ b/pkg/commands/tls/custom/privatekey/delete.go @@ -17,7 +17,7 @@ func NewDeleteCommand(parent cmd.Registerer, globals *config.Data, data manifest c.Globals = globals c.manifest = data - // Required flags + // required c.CmdClause.Flag("id", "Alphanumeric string identifying a private Key").Required().StringVar(&c.id) return &c diff --git a/pkg/commands/tls/custom/privatekey/describe.go b/pkg/commands/tls/custom/privatekey/describe.go index 5b5463e29..4886c20d2 100644 --- a/pkg/commands/tls/custom/privatekey/describe.go +++ b/pkg/commands/tls/custom/privatekey/describe.go @@ -19,10 +19,10 @@ func NewDescribeCommand(parent cmd.Registerer, globals *config.Data, data manife c.Globals = globals c.manifest = data - // Required flags + // required c.CmdClause.Flag("id", "Alphanumeric string identifying a private Key").Required().StringVar(&c.id) - // Optional Flags + // optional c.RegisterFlagBool(cmd.BoolFlagOpts{ Name: cmd.FlagJSONName, Description: cmd.FlagJSONDesc, diff --git a/pkg/commands/tls/custom/privatekey/list.go b/pkg/commands/tls/custom/privatekey/list.go index a11c0b7b7..4ad46fbd3 100644 --- a/pkg/commands/tls/custom/privatekey/list.go +++ b/pkg/commands/tls/custom/privatekey/list.go @@ -20,7 +20,7 @@ func NewListCommand(parent cmd.Registerer, globals *config.Data, data manifest.D c.Globals = globals c.manifest = data - // Optional Flags + // optional c.CmdClause.Flag("filter-in-use", "Limit the returned keys to those without any matching TLS certificates").HintOptions("false").EnumVar(&c.filterInUse, "false") c.RegisterFlagBool(cmd.BoolFlagOpts{ Name: cmd.FlagJSONName, diff --git a/pkg/commands/tls/platform/create.go b/pkg/commands/tls/platform/create.go index 3e002d6aa..eaa6e78f8 100644 --- a/pkg/commands/tls/platform/create.go +++ b/pkg/commands/tls/platform/create.go @@ -17,11 +17,11 @@ func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest c.Globals = globals c.manifest = data - // Required flags + // required c.CmdClause.Flag("cert-blob", "The PEM-formatted certificate blob").Required().StringVar(&c.certBlob) c.CmdClause.Flag("intermediates-blob", "The PEM-formatted chain of intermediate blobs").Required().StringVar(&c.intermediatesBlob) - // Optional flags + // optional c.CmdClause.Flag("allow-untrusted", "Allow certificates that chain to untrusted roots").Action(c.allowUntrusted.Set).BoolVar(&c.allowUntrusted.Value) c.CmdClause.Flag("config", "Alphanumeric string identifying a TLS configuration (set flag once per Configuration ID)").StringsVar(&c.config) diff --git a/pkg/commands/tls/platform/delete.go b/pkg/commands/tls/platform/delete.go index ee090f9d8..f60ef5e90 100644 --- a/pkg/commands/tls/platform/delete.go +++ b/pkg/commands/tls/platform/delete.go @@ -17,7 +17,7 @@ func NewDeleteCommand(parent cmd.Registerer, globals *config.Data, data manifest c.Globals = globals c.manifest = data - // Required flags + // required c.CmdClause.Flag("id", "Alphanumeric string identifying a TLS bulk certificate").Required().StringVar(&c.id) return &c diff --git a/pkg/commands/tls/platform/describe.go b/pkg/commands/tls/platform/describe.go index 6e7d9258f..5c4d6c5ef 100644 --- a/pkg/commands/tls/platform/describe.go +++ b/pkg/commands/tls/platform/describe.go @@ -19,10 +19,10 @@ func NewDescribeCommand(parent cmd.Registerer, globals *config.Data, data manife c.Globals = globals c.manifest = data - // Required flags + // required c.CmdClause.Flag("id", "Alphanumeric string identifying a TLS bulk certificate").Required().StringVar(&c.id) - // Optional Flags + // optional c.RegisterFlagBool(cmd.BoolFlagOpts{ Name: cmd.FlagJSONName, Description: cmd.FlagJSONDesc, diff --git a/pkg/commands/tls/platform/list.go b/pkg/commands/tls/platform/list.go index 979df1473..b7359ba5c 100644 --- a/pkg/commands/tls/platform/list.go +++ b/pkg/commands/tls/platform/list.go @@ -20,7 +20,7 @@ func NewListCommand(parent cmd.Registerer, globals *config.Data, data manifest.D c.Globals = globals c.manifest = data - // Optional Flags + // optional c.CmdClause.Flag("filter-domain", "Optionally filter by the bulk attribute").StringVar(&c.filterTLSDomainID) c.RegisterFlagBool(cmd.BoolFlagOpts{ Name: cmd.FlagJSONName, diff --git a/pkg/commands/tls/platform/update.go b/pkg/commands/tls/platform/update.go index 9cd7b0858..3672f21b3 100644 --- a/pkg/commands/tls/platform/update.go +++ b/pkg/commands/tls/platform/update.go @@ -21,7 +21,7 @@ func NewUpdateCommand( c.Globals = globals c.manifest = data - // Required flags + // required c.CmdClause.Flag( "id", "Alphanumeric string identifying a TLS bulk certificate", @@ -35,7 +35,7 @@ func NewUpdateCommand( "intermediates-blob", "The PEM-formatted chain of intermediate blobs", ).Required().StringVar(&c.intermediatesBlob) - // Optional flags + // optional c.CmdClause.Flag( "allow-untrusted", "Allow certificates that chain to untrusted roots", diff --git a/pkg/commands/tls/subscription/create.go b/pkg/commands/tls/subscription/create.go index 459912e66..04f5b3b1f 100644 --- a/pkg/commands/tls/subscription/create.go +++ b/pkg/commands/tls/subscription/create.go @@ -21,10 +21,10 @@ func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest c.Globals = globals c.manifest = data - // Required flags + // required c.CmdClause.Flag("domain", "Domain(s) to add to the TLS certificates generated for the subscription (set flag once per domain)").Required().StringsVar(&c.domains) - // Optional flags + // optional c.CmdClause.Flag("cert-auth", "The entity that issues and certifies the TLS certificates for your subscription. Valid values are lets-encrypt or globalsign").HintOptions(certAuth...).EnumVar(&c.certAuth, certAuth...) c.CmdClause.Flag("common-name", "The domain name associated with the subscription. Default to the first domain specified by --domain").StringVar(&c.commonName) c.CmdClause.Flag("config", "Alphanumeric string identifying a TLS configuration").StringVar(&c.config) diff --git a/pkg/commands/tls/subscription/delete.go b/pkg/commands/tls/subscription/delete.go index a26a66936..887a1fde3 100644 --- a/pkg/commands/tls/subscription/delete.go +++ b/pkg/commands/tls/subscription/delete.go @@ -17,10 +17,10 @@ func NewDeleteCommand(parent cmd.Registerer, globals *config.Data, data manifest c.Globals = globals c.manifest = data - // Required flags + // required c.CmdClause.Flag("id", "Alphanumeric string identifying a TLS subscription").Required().StringVar(&c.id) - // Optional flags + // optional c.CmdClause.Flag("force", "A flag that allows you to edit and delete a subscription with active domains").Action(c.force.Set).BoolVar(&c.force.Value) return &c diff --git a/pkg/commands/tls/subscription/describe.go b/pkg/commands/tls/subscription/describe.go index 1bab85226..ba9bac0ea 100644 --- a/pkg/commands/tls/subscription/describe.go +++ b/pkg/commands/tls/subscription/describe.go @@ -21,10 +21,10 @@ func NewDescribeCommand(parent cmd.Registerer, globals *config.Data, data manife c.Globals = globals c.manifest = data - // Required flags + // required c.CmdClause.Flag("id", "Alphanumeric string identifying a TLS subscription").Required().StringVar(&c.id) - // Optional Flags + // optional c.CmdClause.Flag("include", "Include related objects (comma-separated values)").HintOptions(include...).EnumVar(&c.include, include...) c.RegisterFlagBool(cmd.BoolFlagOpts{ Name: cmd.FlagJSONName, diff --git a/pkg/commands/tls/subscription/list.go b/pkg/commands/tls/subscription/list.go index 8210aff24..902e4db9e 100644 --- a/pkg/commands/tls/subscription/list.go +++ b/pkg/commands/tls/subscription/list.go @@ -22,7 +22,7 @@ func NewListCommand(parent cmd.Registerer, globals *config.Data, data manifest.D c.Globals = globals c.manifest = data - // Optional Flags + // optional c.CmdClause.Flag("filter-active", "Limit the returned subscriptions to those that have currently active orders").BoolVar(&c.filterHasActiveOrder) c.CmdClause.Flag("filter-domain", "Limit the returned subscriptions to those that include the specific domain").StringVar(&c.filterTLSDomainID) c.CmdClause.Flag("filter-state", "Limit the returned subscriptions by state").HintOptions(states...).EnumVar(&c.filterState, states...) diff --git a/pkg/commands/tls/subscription/update.go b/pkg/commands/tls/subscription/update.go index 06edd4e2d..a5e4f4406 100644 --- a/pkg/commands/tls/subscription/update.go +++ b/pkg/commands/tls/subscription/update.go @@ -17,10 +17,10 @@ func NewUpdateCommand(parent cmd.Registerer, globals *config.Data, data manifest c.Globals = globals c.manifest = data - // Required flags + // required c.CmdClause.Flag("id", "Alphanumeric string identifying a TLS subscription").Required().StringVar(&c.id) - // Optional flags + // optional c.CmdClause.Flag("common-name", "The domain name associated with the subscription").StringVar(&c.commonName) c.CmdClause.Flag("config", "Alphanumeric string identifying a TLS configuration").StringVar(&c.config) c.CmdClause.Flag("domain", "Domain(s) to add to the TLS certificates generated for the subscription (set flag once per domain)").StringsVar(&c.domains) diff --git a/pkg/commands/user/create.go b/pkg/commands/user/create.go index 617cfd91c..80acc39ed 100644 --- a/pkg/commands/user/create.go +++ b/pkg/commands/user/create.go @@ -18,11 +18,11 @@ func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest c.Globals = globals c.manifest = data - // Required flags + // required c.CmdClause.Flag("login", "The login associated with the user (typically, an email address)").Action(c.login.Set).StringVar(&c.login.Value) c.CmdClause.Flag("name", "The real life name of the user").Action(c.name.Set).StringVar(&c.name.Value) - // Optional flags + // optional c.CmdClause.Flag("role", "The permissions role assigned to the user. Can be user, billing, engineer, or superuser").Action(c.role.Set).EnumVar(&c.role.Value, "user", "billing", "engineer", "superuser") return &c diff --git a/pkg/commands/vcl/custom/create.go b/pkg/commands/vcl/custom/create.go index ec13c593b..db263815e 100644 --- a/pkg/commands/vcl/custom/create.go +++ b/pkg/commands/vcl/custom/create.go @@ -13,14 +13,16 @@ import ( // NewCreateCommand returns a usable command registered under the parent. func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *CreateCommand { - var c CreateCommand + c := CreateCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("create", "Upload a VCL for a particular service and version").Alias("add") - c.Globals = globals - c.manifest = data - // Required flags + // required c.CmdClause.Flag("content", "VCL passed as file path or content, e.g. $(< main.vcl)").Action(c.content.Set).StringVar(&c.content.Value) - c.CmdClause.Flag("name", "The name of the VCL").Action(c.name.Set).StringVar(&c.name.Value) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagVersionName, Description: cmd.FlagVersionDesc, @@ -28,12 +30,13 @@ func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest Required: true, }) - // Optional flags + // optional c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ Action: c.autoClone.Set, Dst: &c.autoClone.Value, }) c.CmdClause.Flag("main", "Whether the VCL is the 'main' entrypoint").Action(c.main.Set).BoolVar(&c.main.Value) + c.CmdClause.Flag("name", "The name of the VCL").Action(c.name.Set).StringVar(&c.name.Value) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagServiceIDName, Description: cmd.FlagServiceIDDesc, diff --git a/pkg/commands/vcl/custom/delete.go b/pkg/commands/vcl/custom/delete.go index 16eb58c86..86b34fc82 100644 --- a/pkg/commands/vcl/custom/delete.go +++ b/pkg/commands/vcl/custom/delete.go @@ -13,12 +13,15 @@ import ( // NewDeleteCommand returns a usable command registered under the parent. func NewDeleteCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *DeleteCommand { - var c DeleteCommand + c := DeleteCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("delete", "Delete the uploaded VCL for a particular service and version").Alias("remove") - c.Globals = globals - c.manifest = data - // Required flags + // required c.CmdClause.Flag("name", "The name of the VCL to delete").Required().StringVar(&c.name) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagVersionName, @@ -27,7 +30,7 @@ func NewDeleteCommand(parent cmd.Registerer, globals *config.Data, data manifest Required: true, }) - // Optional flags + // optional c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ Action: c.autoClone.Set, Dst: &c.autoClone.Value, diff --git a/pkg/commands/vcl/custom/describe.go b/pkg/commands/vcl/custom/describe.go index 1a8d34eda..3a97b822d 100644 --- a/pkg/commands/vcl/custom/describe.go +++ b/pkg/commands/vcl/custom/describe.go @@ -14,12 +14,15 @@ import ( // NewDescribeCommand returns a usable command registered under the parent. func NewDescribeCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *DescribeCommand { - var c DescribeCommand + c := DescribeCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("describe", "Get the uploaded VCL for a particular service and version").Alias("get") - c.Globals = globals - c.manifest = data - // Required flags + // required c.CmdClause.Flag("name", "The name of the VCL").Required().StringVar(&c.name) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagVersionName, @@ -28,7 +31,7 @@ func NewDescribeCommand(parent cmd.Registerer, globals *config.Data, data manife Required: true, }) - // Optional Flags + // optional c.RegisterFlagBool(cmd.BoolFlagOpts{ Name: cmd.FlagJSONName, Description: cmd.FlagJSONDesc, diff --git a/pkg/commands/vcl/custom/list.go b/pkg/commands/vcl/custom/list.go index 1ec1c9c82..d51ed7d42 100644 --- a/pkg/commands/vcl/custom/list.go +++ b/pkg/commands/vcl/custom/list.go @@ -15,12 +15,15 @@ import ( // NewListCommand returns a usable command registered under the parent. func NewListCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *ListCommand { - var c ListCommand + c := ListCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("list", "List the uploaded VCLs for a particular service and version") - c.Globals = globals - c.manifest = data - // Required flags + // required c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagVersionName, Description: cmd.FlagVersionDesc, @@ -28,7 +31,7 @@ func NewListCommand(parent cmd.Registerer, globals *config.Data, data manifest.D Required: true, }) - // Optional Flags + // optional c.RegisterFlagBool(cmd.BoolFlagOpts{ Name: cmd.FlagJSONName, Description: cmd.FlagJSONDesc, diff --git a/pkg/commands/vcl/custom/update.go b/pkg/commands/vcl/custom/update.go index 04a034943..cf359ccbd 100644 --- a/pkg/commands/vcl/custom/update.go +++ b/pkg/commands/vcl/custom/update.go @@ -14,12 +14,15 @@ import ( // NewUpdateCommand returns a usable command registered under the parent. func NewUpdateCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *UpdateCommand { - var c UpdateCommand + c := UpdateCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("update", "Update the uploaded VCL for a particular service and version") - c.Globals = globals - c.manifest = data - // Required flags + // required c.CmdClause.Flag("name", "The name of the VCL to update").Required().StringVar(&c.name) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagVersionName, @@ -28,7 +31,7 @@ func NewUpdateCommand(parent cmd.Registerer, globals *config.Data, data manifest Required: true, }) - // Optional flags + // optional c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ Action: c.autoClone.Set, Dst: &c.autoClone.Value, diff --git a/pkg/commands/vcl/snippet/create.go b/pkg/commands/vcl/snippet/create.go index 8de469d3c..329dd5e9d 100644 --- a/pkg/commands/vcl/snippet/create.go +++ b/pkg/commands/vcl/snippet/create.go @@ -16,28 +16,30 @@ var Locations = []string{"init", "recv", "hash", "hit", "miss", "pass", "fetch", // NewCreateCommand returns a usable command registered under the parent. func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *CreateCommand { - var c CreateCommand + c := CreateCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("create", "Create a snippet for a particular service and version").Alias("add") - c.Globals = globals - c.manifest = data - // Required flags - c.CmdClause.Flag("content", "VCL snippet passed as file path or content, e.g. $(< snippet.vcl)").Action(c.content.Set).StringVar(&c.content.Value) - c.CmdClause.Flag("name", "The name of the VCL snippet").Action(c.name.Set).StringVar(&c.name.Value) + // required c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagVersionName, Description: cmd.FlagVersionDesc, Dst: &c.serviceVersion.Value, Required: true, }) - c.CmdClause.Flag("type", "The location in generated VCL where the snippet should be placed").Action(c.location.Set).HintOptions(Locations...).EnumVar(&c.location.Value, Locations...) - // Optional flags + // optional c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ Action: c.autoClone.Set, Dst: &c.autoClone.Value, }) + c.CmdClause.Flag("content", "VCL snippet passed as file path or content, e.g. $(< snippet.vcl)").Action(c.content.Set).StringVar(&c.content.Value) c.CmdClause.Flag("dynamic", "Whether the VCL snippet is dynamic or versioned").Action(c.dynamic.Set).BoolVar(&c.dynamic.Value) + c.CmdClause.Flag("name", "The name of the VCL snippet").Action(c.name.Set).StringVar(&c.name.Value) c.CmdClause.Flag("priority", "Priority determines execution order. Lower numbers execute first").Short('p').Action(c.priority.Set).IntVar(&c.priority.Value) c.RegisterFlag(cmd.StringFlagOpts{ @@ -52,6 +54,7 @@ func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest Description: cmd.FlagServiceDesc, Dst: &c.serviceName.Value, }) + c.CmdClause.Flag("type", "The location in generated VCL where the snippet should be placed").Action(c.location.Set).HintOptions(Locations...).EnumVar(&c.location.Value, Locations...) return &c } diff --git a/pkg/commands/vcl/snippet/delete.go b/pkg/commands/vcl/snippet/delete.go index 04bce3334..45b376d30 100644 --- a/pkg/commands/vcl/snippet/delete.go +++ b/pkg/commands/vcl/snippet/delete.go @@ -13,12 +13,15 @@ import ( // NewDeleteCommand returns a usable command registered under the parent. func NewDeleteCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *DeleteCommand { - var c DeleteCommand + c := DeleteCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("delete", "Delete a specific snippet for a particular service and version").Alias("remove") - c.Globals = globals - c.manifest = data - // Required flags + // required c.CmdClause.Flag("name", "The name of the VCL snippet to delete").Required().StringVar(&c.name) c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagVersionName, @@ -27,7 +30,7 @@ func NewDeleteCommand(parent cmd.Registerer, globals *config.Data, data manifest Required: true, }) - // Optional flags + // optional c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ Action: c.autoClone.Set, Dst: &c.autoClone.Value, diff --git a/pkg/commands/vcl/snippet/describe.go b/pkg/commands/vcl/snippet/describe.go index e02ce31d0..29c3137d5 100644 --- a/pkg/commands/vcl/snippet/describe.go +++ b/pkg/commands/vcl/snippet/describe.go @@ -14,12 +14,15 @@ import ( // NewDescribeCommand returns a usable command registered under the parent. func NewDescribeCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *DescribeCommand { - var c DescribeCommand + c := DescribeCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("describe", "Get the uploaded VCL snippet for a particular service and version").Alias("get") - c.Globals = globals - c.manifest = data - // Required flags + // required c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagVersionName, Description: cmd.FlagVersionDesc, @@ -27,7 +30,7 @@ func NewDescribeCommand(parent cmd.Registerer, globals *config.Data, data manife Required: true, }) - // Optional Flags + // optional c.CmdClause.Flag("dynamic", "Whether the VCL snippet is dynamic or versioned").Action(c.dynamic.Set).BoolVar(&c.dynamic.Value) c.RegisterFlagBool(cmd.BoolFlagOpts{ Name: cmd.FlagJSONName, diff --git a/pkg/commands/vcl/snippet/list.go b/pkg/commands/vcl/snippet/list.go index 6374aa6e3..ee19dfc76 100644 --- a/pkg/commands/vcl/snippet/list.go +++ b/pkg/commands/vcl/snippet/list.go @@ -15,12 +15,15 @@ import ( // NewListCommand returns a usable command registered under the parent. func NewListCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *ListCommand { - var c ListCommand + c := ListCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("list", "List the uploaded VCL snippets for a particular service and version") - c.Globals = globals - c.manifest = data - // Required flags + // required c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagVersionName, Description: cmd.FlagVersionDesc, @@ -28,7 +31,7 @@ func NewListCommand(parent cmd.Registerer, globals *config.Data, data manifest.D Required: true, }) - // Optional Flags + // optional c.RegisterFlagBool(cmd.BoolFlagOpts{ Name: cmd.FlagJSONName, Description: cmd.FlagJSONDesc, diff --git a/pkg/commands/vcl/snippet/update.go b/pkg/commands/vcl/snippet/update.go index 608cfaeb7..81c21bf60 100644 --- a/pkg/commands/vcl/snippet/update.go +++ b/pkg/commands/vcl/snippet/update.go @@ -14,12 +14,15 @@ import ( // NewUpdateCommand returns a usable command registered under the parent. func NewUpdateCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *UpdateCommand { - var c UpdateCommand + c := UpdateCommand{ + Base: cmd.Base{ + Globals: globals, + }, + manifest: data, + } c.CmdClause = parent.Command("update", "Update a VCL snippet for a particular service and version") - c.Globals = globals - c.manifest = data - // Required flags + // required c.RegisterFlag(cmd.StringFlagOpts{ Name: cmd.FlagVersionName, Description: cmd.FlagVersionDesc, @@ -27,7 +30,7 @@ func NewUpdateCommand(parent cmd.Registerer, globals *config.Data, data manifest Required: true, }) - // Optional flags + // optional c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{ Action: c.autoClone.Set, Dst: &c.autoClone.Value,