Skip to content

Commit

Permalink
Sort it all
Browse files Browse the repository at this point in the history
  • Loading branch information
grantstephens committed Nov 18, 2022
1 parent 45c5bb5 commit d6bbb6b
Show file tree
Hide file tree
Showing 227 changed files with 2,997 additions and 1,806 deletions.
3 changes: 1 addition & 2 deletions pkg/commands/acl/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
}

Expand Down
16 changes: 9 additions & 7 deletions pkg/commands/acl/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,24 @@ 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,
Dst: &c.serviceVersion.Value,
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,
Expand Down
7 changes: 3 additions & 4 deletions pkg/commands/acl/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,16 @@ 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,
Dst: &c.serviceVersion.Value,
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,
Expand Down
4 changes: 2 additions & 2 deletions pkg/commands/acl/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ 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,
Dst: &c.serviceVersion.Value,
Required: true,
})

// Optional Flags
// optional
c.RegisterFlagBool(cmd.BoolFlagOpts{
Name: cmd.FlagJSONName,
Description: cmd.FlagJSONDesc,
Expand Down
9 changes: 4 additions & 5 deletions pkg/commands/acl/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,17 @@ 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,
Dst: &c.serviceVersion.Value,
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,
Expand Down
15 changes: 9 additions & 6 deletions pkg/commands/aclentry/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
13 changes: 8 additions & 5 deletions pkg/commands/aclentry/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
13 changes: 8 additions & 5 deletions pkg/commands/aclentry/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
20 changes: 12 additions & 8 deletions pkg/commands/aclentry/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down
13 changes: 8 additions & 5 deletions pkg/commands/aclentry/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
13 changes: 8 additions & 5 deletions pkg/commands/authtoken/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,23 @@ 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
// token. The password must be for the user account that created the token
// 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
Expand Down
10 changes: 7 additions & 3 deletions pkg/commands/authtoken/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 7 additions & 3 deletions pkg/commands/authtoken/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
10 changes: 7 additions & 3 deletions pkg/commands/authtoken/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading

0 comments on commit d6bbb6b

Please sign in to comment.