Skip to content

Commit be52910

Browse files
allmightyspiffGitHub Enterprise
authored andcommitted
Merge pull request #768 from Ramkishor-Chaladi/issue_726
/softlayer-cli account hook-create --help, [required] text message was missing
2 parents 4a6db4c + c51619e commit be52910

6 files changed

Lines changed: 4 additions & 163 deletions

File tree

plugin/commands/account/hook_create.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ func NewHookCreateCommand(sl *metadata.SoftlayerCommand) *HookCreateCommand {
3535
},
3636
}
3737

38-
cobraCmd.Flags().StringVarP(&thisCmd.Name, "name", "N", "", T("The name of the hook."))
39-
cobraCmd.Flags().StringVarP(&thisCmd.Uri, "uri", "U", "", T("The endpoint that the script will be downloaded."))
38+
cobraCmd.Flags().StringVarP(&thisCmd.Name, "name", "N", "", T("The name of the hook."+" "+T("[required]")))
39+
cobraCmd.Flags().StringVarP(&thisCmd.Uri, "uri", "U", "", T("The endpoint that the script will be downloaded."+" "+T("[required]")))
4040

4141
//#nosec G104 -- This is a false positive
4242
cobraCmd.MarkFlagRequired("name")

plugin/commands/block/replica_order.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func NewReplicaOrderCommand(sl *metadata.SoftlayerStorageCommand) *ReplicaOrderC
3434
Use: "replica-order " + T("IDENTIFIER"),
3535
Short: T("Order a block storage replica volume"),
3636
Long: T(`${COMMAND_NAME} sl {{.storageType}} replica-order VOLUME_ID [OPTIONS]
37-
37+
3838
EXAMPLE:
3939
${COMMAND_NAME} sl {{.storageType}} replica-order 12345678 -s DAILY -d dal09 --tier 4 --os-type LINUX
4040
This command orders a replica for volume with ID 12345678, which performs DAILY replication, is located at dal09, tier level is 4, OS type is Linux.`, sl.StorageI18n),

plugin/commands/block/replica_partners.go

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package block
22

33
import (
4-
"sort"
54
"strconv"
65

76
"github.com/spf13/cobra"
@@ -17,7 +16,6 @@ type ReplicaPartnersCommand struct {
1716
*metadata.SoftlayerStorageCommand
1817
Command *cobra.Command
1918
StorageManager managers.StorageManager
20-
Sortby string
2119
}
2220

2321
func NewReplicaPartnersCommand(sl *metadata.SoftlayerStorageCommand) *ReplicaPartnersCommand {
@@ -39,7 +37,6 @@ EXAMPLE:
3937
},
4038
}
4139

42-
cobraCmd.Flags().StringVar(&thisCmd.Sortby, "sortby", "username", T("Column to sort by. Options are: id, username, accountId, capacityGb, hardwareId, guestId, hostId"))
4340
thisCmd.Command = cobraCmd
4441
return thisCmd
4542
}
@@ -50,8 +47,6 @@ func (cmd *ReplicaPartnersCommand) Run(args []string) error {
5047
if err != nil {
5148
return slErr.NewInvalidSoftlayerIdInputError("Volume ID")
5249
}
53-
sortby := cmd.Sortby
54-
5550
outputFormat := cmd.GetOutputFlag()
5651

5752
partners, err := cmd.StorageManager.GetReplicationPartners(volumeID)
@@ -60,24 +55,6 @@ func (cmd *ReplicaPartnersCommand) Run(args []string) error {
6055
return slErr.NewAPIError(T("Failed to get replication partners for volume {{.VolumeID}}.\n", subs), err.Error(), 2)
6156
}
6257

63-
if sortby == "id" {
64-
sort.Sort(utils.VolumeById(partners))
65-
} else if sortby == "username" {
66-
sort.Sort(utils.VolumeByUsername(partners))
67-
} else if sortby == "accountId" {
68-
sort.Sort(utils.VolumeByAccountId(partners))
69-
} else if sortby == "capacityGb" {
70-
sort.Sort(utils.VolumeByCapacity(partners))
71-
} else if sortby == "hardwareId" {
72-
sort.Sort(utils.VolumeByHardwareById(partners))
73-
} else if sortby == "guestId" {
74-
sort.Sort(utils.VolumeByGuestId(partners))
75-
} else if sortby == "hostId" {
76-
sort.Sort(utils.VolumeByHostId(partners))
77-
} else {
78-
return slErr.NewInvalidUsageError(T("--sortby '{{.Column}}' is not supported.", map[string]interface{}{"Column": sortby}))
79-
}
80-
8158
if outputFormat == "JSON" {
8259
return utils.PrintPrettyJSON(cmd.UI, partners)
8360
}

plugin/commands/block/replica_partners_test.go

Lines changed: 0 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -84,81 +84,5 @@ var _ = Describe("Replica partners", func() {
8484
Expect(fakeUI.Outputs()).To(ContainSubstring("There are no replication partners for volume 1234."))
8585
})
8686
})
87-
Context("Replica partners with correct volume id and --sortby id", func() {
88-
BeforeEach(func() {
89-
FakeStorageManager.GetReplicationPartnersReturns(nil, nil)
90-
})
91-
It("return table", func() {
92-
err := testhelpers.RunCobraCommand(cliCommand.Command, "442707460", "--sortby=id")
93-
Expect(err).NotTo(HaveOccurred())
94-
Expect(fakeUI.Outputs()).To(ContainSubstring("442707460"))
95-
})
96-
})
97-
98-
Context("Replica partners with correct volume id and --sortby accountId", func() {
99-
BeforeEach(func() {
100-
FakeStorageManager.GetReplicationPartnersReturns(nil, nil)
101-
})
102-
It("return table", func() {
103-
err := testhelpers.RunCobraCommand(cliCommand.Command, "307608", "--sortby=accountId")
104-
Expect(err).NotTo(HaveOccurred())
105-
Expect(fakeUI.Outputs()).To(ContainSubstring("307608"))
106-
})
107-
})
108-
109-
Context("Replica partners with correct volume id and --sortby capacityGb", func() {
110-
BeforeEach(func() {
111-
FakeStorageManager.GetReplicationPartnersReturns(nil, nil)
112-
})
113-
It("return table", func() {
114-
err := testhelpers.RunCobraCommand(cliCommand.Command, "25", "--sortby=capacityGb")
115-
Expect(err).NotTo(HaveOccurred())
116-
Expect(fakeUI.Outputs()).To(ContainSubstring("25"))
117-
})
118-
})
119-
120-
Context("Replica partners with correct volume id and --sortby hardwareId", func() {
121-
BeforeEach(func() {
122-
FakeStorageManager.GetReplicationPartnersReturns(nil, nil)
123-
})
124-
It("return table", func() {
125-
err := testhelpers.RunCobraCommand(cliCommand.Command, "1234", "--sortby=hardwareId")
126-
Expect(err).NotTo(HaveOccurred())
127-
Expect(fakeUI.Outputs()).To(ContainSubstring("1234"))
128-
})
129-
})
130-
131-
Context("Replica partners with correct volume id and --sortby guestId", func() {
132-
BeforeEach(func() {
133-
FakeStorageManager.GetReplicationPartnersReturns(nil, nil)
134-
})
135-
It("return table", func() {
136-
err := testhelpers.RunCobraCommand(cliCommand.Command, "1234", "--sortby=guestId")
137-
Expect(err).NotTo(HaveOccurred())
138-
Expect(fakeUI.Outputs()).To(ContainSubstring("1234"))
139-
})
140-
})
141-
142-
Context("Replica partners with correct volume id and --sortby hostId", func() {
143-
BeforeEach(func() {
144-
FakeStorageManager.GetReplicationPartnersReturns(nil, nil)
145-
})
146-
It("return table", func() {
147-
err := testhelpers.RunCobraCommand(cliCommand.Command, "1234", "--sortby=hostId")
148-
Expect(err).NotTo(HaveOccurred())
149-
Expect(fakeUI.Outputs()).To(ContainSubstring("1234"))
150-
})
151-
})
152-
153-
Context("Replica partners with correct volume id and --sortby abcd", func() {
154-
BeforeEach(func() {
155-
FakeStorageManager.GetReplicationPartnersReturns(nil, nil)
156-
})
157-
It("return error", func() {
158-
err := testhelpers.RunCobraCommand(cliCommand.Command, "1234", "--sortby=abcd")
159-
Expect(err).To(HaveOccurred())
160-
Expect(err.Error()).To(ContainSubstring("Incorrect Usage: --sortby 'abcd' is not supported."))
161-
})
162-
})
16387
})
16488
})

plugin/commands/block/snapshot_cancel.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func NewSnapshotCancelCommand(sl *metadata.SoftlayerStorageCommand) *SnapshotCan
2929
Use: "snapshot-cancel " + T("IDENTIFIER"),
3030
Short: T("Cancel existing snapshot space for a given volume"),
3131
Long: T(`${COMMAND_NAME} sl {{.storageType}} snapshot-cancel SNAPSHOT_ID [OPTIONS]
32-
32+
3333
EXAMPLE:
3434
${COMMAND_NAME} sl {{.storageType}} snapshot-cancel 12345678 --immediate -f
3535
This command cancels snapshot with ID 12345678 immediately without asking for confirmation.`, sl.StorageI18n),

plugin/utils/blocksort.go

Lines changed: 0 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -36,66 +36,6 @@ func (a VolumeByUsername) Less(i, j int) bool {
3636
return false
3737
}
3838

39-
type VolumeByAccountId []datatypes.Network_Storage
40-
41-
func (a VolumeByAccountId) Len() int {
42-
return len(a)
43-
}
44-
func (a VolumeByAccountId) Swap(i, j int) {
45-
a[i], a[j] = a[j], a[i]
46-
}
47-
func (a VolumeByAccountId) Less(i, j int) bool {
48-
if a[i].AccountId != nil && a[j].AccountId != nil {
49-
return *a[i].AccountId < *a[j].AccountId
50-
}
51-
return false
52-
}
53-
54-
type VolumeByHardwareById []datatypes.Network_Storage
55-
56-
func (a VolumeByHardwareById) Len() int {
57-
return len(a)
58-
}
59-
func (a VolumeByHardwareById) Swap(i, j int) {
60-
a[i], a[j] = a[j], a[i]
61-
}
62-
func (a VolumeByHardwareById) Less(i, j int) bool {
63-
if a[i].HardwareId != nil && a[j].HardwareId != nil {
64-
return *a[i].HardwareId < *a[j].HardwareId
65-
}
66-
return false
67-
}
68-
69-
type VolumeByGuestId []datatypes.Network_Storage
70-
71-
func (a VolumeByGuestId) Len() int {
72-
return len(a)
73-
}
74-
func (a VolumeByGuestId) Swap(i, j int) {
75-
a[i], a[j] = a[j], a[i]
76-
}
77-
func (a VolumeByGuestId) Less(i, j int) bool {
78-
if a[i].GuestId != nil && a[j].GuestId != nil {
79-
return *a[i].GuestId < *a[j].GuestId
80-
}
81-
return false
82-
}
83-
84-
type VolumeByHostId []datatypes.Network_Storage
85-
86-
func (a VolumeByHostId) Len() int {
87-
return len(a)
88-
}
89-
func (a VolumeByHostId) Swap(i, j int) {
90-
a[i], a[j] = a[j], a[i]
91-
}
92-
func (a VolumeByHostId) Less(i, j int) bool {
93-
if a[i].HostId != nil && a[j].HostId != nil {
94-
return *a[i].HostId < *a[j].HostId
95-
}
96-
return false
97-
}
98-
9939
type VolumeByDatacenter []datatypes.Network_Storage
10040

10141
func (a VolumeByDatacenter) Len() int {

0 commit comments

Comments
 (0)