-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Review feedback... removing unnecessary source files.
- Loading branch information
Showing
68 changed files
with
969 additions
and
1,285 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// Package productcore contains a group of generic structures and | ||
// functions which are used to implement common behaviors in product | ||
// enablement/configuration commands | ||
package productcore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// Package productcore_test contains a group of generic structures and | ||
// functions which are used to implement common behaviors in product | ||
// enablement/configuration tests | ||
package productcore_test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
package botmanagement | ||
|
||
import ( | ||
"io" | ||
|
||
"github.com/fastly/cli/pkg/argparser" | ||
"github.com/fastly/cli/pkg/global" | ||
"github.com/fastly/go-fastly/v9/fastly" | ||
product "github.com/fastly/go-fastly/v9/fastly/products/botmanagement" | ||
|
||
"github.com/fastly/cli/internal/productcore" | ||
"github.com/fastly/cli/pkg/api" | ||
) | ||
|
||
// EnablementHooks is a structure of dependency-injection points used | ||
// by unit tests to provide mock behaviors | ||
var EnablementHooks = productcore.EnablementHookFuncs[*product.EnableOutput]{ | ||
DisableFunc: func(client api.Interface, serviceID string) error { | ||
return product.Disable(client.(*fastly.Client), serviceID) | ||
}, | ||
EnableFunc: func(client api.Interface, serviceID string) (*product.EnableOutput, error) { | ||
return product.Enable(client.(*fastly.Client), serviceID) | ||
}, | ||
GetFunc: func(client api.Interface, serviceID string) (*product.EnableOutput, error) { | ||
return product.Get(client.(*fastly.Client), serviceID) | ||
}, | ||
} | ||
|
||
// RootCommand is the parent command for all subcommands in this package. | ||
// It should be installed under the primary root command. | ||
type RootCommand struct { | ||
argparser.Base | ||
// no flags | ||
} | ||
|
||
// CommandName is the string to be used to invoke this command | ||
const CommandName = "bot_management" | ||
|
||
// NewRootCommand returns a new command registered in the parent. | ||
func NewRootCommand(parent argparser.Registerer, g *global.Data) *RootCommand { | ||
var c RootCommand | ||
c.Globals = g | ||
c.CmdClause = parent.Command(CommandName, "Enable and disable the Bot Management product") | ||
return &c | ||
} | ||
|
||
// Exec implements the command interface. | ||
func (c *RootCommand) Exec(_ io.Reader, _ io.Writer) error { | ||
panic("unreachable") | ||
} | ||
|
||
// EnableCommand calls the Fastly API to disable the product. | ||
type EnableCommand struct { | ||
productcore.Enable[*product.EnableOutput] | ||
} | ||
|
||
// NewEnableCommand returns a usable command registered under the parent. | ||
func NewEnableCommand(parent argparser.Registerer, g *global.Data) *EnableCommand { | ||
c := EnableCommand{} | ||
c.Init(parent, g, product.ProductID, product.ProductName, &EnablementHooks) | ||
return &c | ||
} | ||
|
||
// Exec invokes the application logic for the command. | ||
func (cmd *EnableCommand) Exec(_ io.Reader, out io.Writer) error { | ||
return cmd.Enable.Exec(out) | ||
} | ||
|
||
// DisableCommand calls the Fastly API to disable the product. | ||
type DisableCommand struct { | ||
productcore.Disable[*product.EnableOutput] | ||
} | ||
|
||
// NewDisableCommand returns a usable command registered under the parent. | ||
func NewDisableCommand(parent argparser.Registerer, g *global.Data) *DisableCommand { | ||
c := DisableCommand{} | ||
c.Init(parent, g, product.ProductID, product.ProductName, &EnablementHooks) | ||
return &c | ||
} | ||
|
||
// Exec invokes the application logic for the command. | ||
func (cmd *DisableCommand) Exec(_ io.Reader, out io.Writer) error { | ||
return cmd.Disable.Exec(out) | ||
} | ||
|
||
// StatusCommand calls the Fastly API to get the enablement status of the product. | ||
type StatusCommand struct { | ||
productcore.Status[*product.EnableOutput] | ||
} | ||
|
||
// NewStatusCommand returns a usable command registered under the parent. | ||
func NewStatusCommand(parent argparser.Registerer, g *global.Data) *StatusCommand { | ||
c := StatusCommand{} | ||
c.Init(parent, g, product.ProductID, product.ProductName, &EnablementHooks) | ||
return &c | ||
} | ||
|
||
// Exec invokes the application logic for the command. | ||
func (cmd *StatusCommand) Exec(_ io.Reader, out io.Writer) error { | ||
return cmd.Status.Exec(out) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.