Skip to content

Commit dfd45f1

Browse files
committed
Rename command name from origin-add to create
1 parent 1420431 commit dfd45f1

6 files changed

Lines changed: 104 additions & 107 deletions

File tree

plugin/commands/cdn/cdn.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ func SetupCobraCommands(sl *metadata.SoftlayerCommand) *cobra.Command {
1717
cobraCmd.AddCommand(NewListCommand(sl).Command)
1818
cobraCmd.AddCommand(NewDetailCommand(sl).Command)
1919
cobraCmd.AddCommand(NewEditCommand(sl).Command)
20-
cobraCmd.AddCommand(NewOriginAddCommand(sl).Command)
20+
cobraCmd.AddCommand(NewCreateCommand(sl).Command)
2121
return cobraCmd
2222
}
2323

plugin/commands/cdn/cdn_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ var availableCommands = []string{
2121
"detail",
2222
"edit",
2323
"list",
24-
"origin-add",
24+
"create",
2525
}
2626

2727
// This test suite exists to make sure commands don't get accidently removed from the actionBindings
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
"github.ibm.com/SoftLayer/softlayer-cli/plugin/utils"
1313
)
1414

15-
type OriginAddCommand struct {
15+
type CreateCommand struct {
1616
*metadata.SoftlayerCommand
1717
CdnManager managers.CdnManager
1818
Command *cobra.Command
@@ -28,17 +28,17 @@ type OriginAddCommand struct {
2828
Ssl string
2929
}
3030

31-
func NewOriginAddCommand(sl *metadata.SoftlayerCommand) *OriginAddCommand {
32-
thisCmd := &OriginAddCommand{
31+
func NewCreateCommand(sl *metadata.SoftlayerCommand) *CreateCommand {
32+
thisCmd := &CreateCommand{
3333
SoftlayerCommand: sl,
3434
CdnManager: managers.NewCdnManager(sl.Session),
3535
}
3636
cobraCmd := &cobra.Command{
37-
Use: "origin-add",
38-
Short: T("Create an origin path for an existing CDN mapping."),
39-
Long: T(`${COMMAND_NAME} sl cdn origin-add
37+
Use: "create",
38+
Short: T("Create a new CDN domain mapping"),
39+
Long: T(`${COMMAND_NAME} sl cdn create
4040
Example:
41-
${COMMAND_NAME} sl cdn origin-add --hostname www.example.com --origin 123.45.67.8 --http 80`),
41+
${COMMAND_NAME} sl cdn create --hostname www.example.com --origin 123.45.67.8 --http 80`),
4242
Args: metadata.NoArgs,
4343
RunE: func(cmd *cobra.Command, args []string) error {
4444
return thisCmd.Run(args)
@@ -63,7 +63,7 @@ ${COMMAND_NAME} sl cdn origin-add --hostname www.example.com --origin 123.45.67.
6363
return thisCmd
6464
}
6565

66-
func (cmd *OriginAddCommand) Run(args []string) error {
66+
func (cmd *CreateCommand) Run(args []string) error {
6767
if cmd.Http == 0 && cmd.Https == 0 {
6868
return errors.NewMissingInputError("http or https")
6969
}
@@ -76,7 +76,7 @@ func (cmd *OriginAddCommand) Run(args []string) error {
7676

7777
outputFormat := cmd.GetOutputFlag()
7878

79-
newCdn, err := cmd.CdnManager.OriginAdd(cmd.HostName, cmd.OriginHost, cmd.OriginType, cmd.Http, cmd.Https, cmd.BucketName, cmd.CName, cmd.Header, cmd.Path, cmd.Ssl)
79+
newCdn, err := cmd.CdnManager.CreateCdn(cmd.HostName, cmd.OriginHost, cmd.OriginType, cmd.Http, cmd.Https, cmd.BucketName, cmd.CName, cmd.Header, cmd.Path, cmd.Ssl)
8080
if err != nil {
8181
return errors.NewAPIError(T("Failed to create a CDN."), err.Error(), 2)
8282
}
Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,26 +11,23 @@ import (
1111
"github.ibm.com/SoftLayer/softlayer-cli/plugin/testhelpers"
1212
)
1313

14-
var _ = Describe("Cdn origin add", func() {
14+
var _ = Describe("Cdn create", func() {
1515
var (
1616
fakeUI *terminal.FakeUI
17-
cliCommand *cdn.OriginAddCommand
17+
cliCommand *cdn.CreateCommand
1818
fakeSession *session.Session
1919
slCommand *metadata.SoftlayerCommand
20-
// fakeCdnManager *testhelpers.FakeCdnManager
2120
)
2221
BeforeEach(func() {
2322
fakeUI = terminal.NewFakeUI()
2423
fakeSession = testhelpers.NewFakeSoftlayerSession([]string{})
2524
slCommand = metadata.NewSoftlayerCommand(fakeUI, fakeSession)
26-
cliCommand = cdn.NewOriginAddCommand(slCommand)
25+
cliCommand = cdn.NewCreateCommand(slCommand)
2726
cliCommand.Command.PersistentFlags().Var(cliCommand.OutputFlag, "output", "--output=JSON for json output.")
28-
// fakeCdnManager = new(testhelpers.FakeCdnManager)
29-
// cliCommand.CdnManager = fakeCdnManager
3027
})
3128

32-
Describe("Cdn origin add", func() {
33-
Context("Cdn origin add, Invalid Usage", func() {
29+
Describe("Cdn create", func() {
30+
Context("Cdn create, Invalid Usage", func() {
3431
It("Set command with an invalid output option", func() {
3532
err := testhelpers.RunCobraCommand(cliCommand.Command, "--output=xml")
3633
Expect(err).To(HaveOccurred())
@@ -63,8 +60,8 @@ var _ = Describe("Cdn origin add", func() {
6360
})
6461
})
6562

66-
Context("Cdn origin add, correct use", func() {
67-
It("return cdn origin add", func() {
63+
Context("Cdn create, correct use", func() {
64+
It("return cdn created", func() {
6865
err := testhelpers.RunCobraCommand(cliCommand.Command, "--hostname", "www.example.com", "--origin", "123.45.67.8", "--http", "80")
6966
Expect(err).NotTo(HaveOccurred())
7067
Expect(fakeUI.Outputs()).To(ContainSubstring("CDN Unique ID"))
@@ -82,7 +79,7 @@ var _ = Describe("Cdn origin add", func() {
8279
Expect(fakeUI.Outputs()).To(ContainSubstring("Certificate Type"))
8380
Expect(fakeUI.Outputs()).To(ContainSubstring("WILDCARD_CERT"))
8481
})
85-
It("return cdn cdn in format json", func() {
82+
It("return cdn in format json", func() {
8683
err := testhelpers.RunCobraCommand(cliCommand.Command, "--hostname", "www.example.com", "--origin", "123.45.67.8", "--http", "80", "--output", "json")
8784
Expect(err).NotTo(HaveOccurred())
8885
Expect(fakeUI.Outputs()).To(ContainSubstring(`"Name": "CDN Unique ID",`))

plugin/managers/cdn.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ type CdnManager interface {
1616
GetDetailCDN(uniqueId int, mask string) (datatypes.Container_Network_CdnMarketplace_Configuration_Mapping, error)
1717
GetUsageMetrics(uniqueId int, history int, mask string) (datatypes.Container_Network_CdnMarketplace_Metrics, error)
1818
EditCDN(uniqueId int, header string, httpPort int, httpsPort int, origin string, respectHeaders string, cache string, cacheDescription string, performanceConfiguration string) (datatypes.Container_Network_CdnMarketplace_Configuration_Mapping, error)
19-
OriginAdd(hostname string, originHost string, originType string, http int, https int, bucketName string, cname string, header string, path string, ssl string) ([]datatypes.Container_Network_CdnMarketplace_Configuration_Mapping, error)
19+
CreateCdn(hostname string, originHost string, originType string, http int, https int, bucketName string, cname string, header string, path string, ssl string) ([]datatypes.Container_Network_CdnMarketplace_Configuration_Mapping, error)
2020
}
2121

2222
type cdnManager struct {
@@ -143,7 +143,7 @@ func (a cdnManager) EditCDN(uniqueId int, header string, httpPort int, httpsPort
143143
/*
144144
https://sldn.softlayer.com/reference/services/SoftLayer_Network_CdnMarketplace_Configuration_Mapping/createDomainMapping/
145145
*/
146-
func (a cdnManager) OriginAdd(hostname string, originHost string, originType string, http int, https int, bucketName string, cname string, header string, path string, ssl string) ([]datatypes.Container_Network_CdnMarketplace_Configuration_Mapping, error) {
146+
func (a cdnManager) CreateCdn(hostname string, originHost string, originType string, http int, https int, bucketName string, cname string, header string, path string, ssl string) ([]datatypes.Container_Network_CdnMarketplace_Configuration_Mapping, error) {
147147
types := map[string]string{
148148
"server": "HOST_SERVER",
149149
"storage": "OBJECT_STORAGE",

plugin/testhelpers/fake_cdn_manager.go

Lines changed: 83 additions & 83 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)