Skip to content

Commit 5d2254d

Browse files
allmightyspiffGitHub Enterprise
authored andcommitted
Merge pull request #827 from SoftLayer/issues826
Fixed sshKey option in 'hardware create'
2 parents 52f599c + aeed88c commit 5d2254d

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

plugin/commands/hardware/create.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ func (cmd *CreateCommand) Run(args []string) error {
123123
params["noPublic"] = true
124124
}
125125
params["postInstallURL"] = cmd.PostInstall
126-
params["ssheKeys"] = cmd.Key
126+
params["sshKeys"] = cmd.Key
127127
params["extras"] = cmd.Extra
128128
}
129129

@@ -180,6 +180,7 @@ func (cmd *CreateCommand) Run(args []string) error {
180180
return nil
181181
}
182182
}
183+
183184
orderReceipt, err := cmd.HardwareManager.PlaceOrder(orderTemplate)
184185
if err != nil {
185186
return errors.NewAPIError(T("Failed to place this order.\n"), err.Error(), 2)

plugin/commands/hardware/create_test.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ import (
44
"errors"
55
"os"
66

7-
. "github.com/IBM-Cloud/ibm-cloud-cli-sdk/testhelpers/matchers"
8-
97
"github.com/IBM-Cloud/ibm-cloud-cli-sdk/testhelpers/terminal"
108
. "github.com/onsi/ginkgo"
119
. "github.com/onsi/gomega"
@@ -167,13 +165,13 @@ var _ = Describe("hardware create", func() {
167165
err := testhelpers.RunCobraCommand(cliCommand.Command, "-s", "S1270_32GB_2X960GBSSD_NORAID", "-H", "ibmcloud-cli", "-D", "ibm.com", "-o", "UBUNTU_16_64", "-d", "dal10", "-p", "1000", "-b", "hourly")
168166
Expect(err).NotTo(HaveOccurred())
169167
Expect(fakeUI.Outputs()).To(ContainSubstring("Order 123456 was placed."))
170-
Expect(fakeUI.Outputs()).To(ContainSubstrings([]string{"Run 'ibmcloud sl hardware list --order 123456' to find this hardware server after it is ready."}))
168+
Expect(fakeUI.Outputs()).To(ContainSubstring("Run 'ibmcloud sl hardware list --order 123456' to find this hardware server after it is ready."))
171169
})
172170
It("return order receipt", func() {
173171
err := testhelpers.RunCobraCommand(cliCommand.Command, "-s", "S1270_32GB_2X960GBSSD_NORAID", "-H", "ibmcloud-cli", "-D", "ibm.com", "-o", "UBUNTU_16_64", "-d", "dal10", "-p", "1000", "-b", "hourly", "-f")
174172
Expect(err).NotTo(HaveOccurred())
175173
Expect(fakeUI.Outputs()).To(ContainSubstring("Order 123456 was placed."))
176-
Expect(fakeUI.Outputs()).To(ContainSubstrings([]string{"Run 'ibmcloud sl hardware list --order 123456' to find this hardware server after it is ready."}))
174+
Expect(fakeUI.Outputs()).To(ContainSubstring("Run 'ibmcloud sl hardware list --order 123456' to find this hardware server after it is ready."))
177175
})
178176
It("return order receipt", func() {
179177
err := testhelpers.RunCobraCommand(cliCommand.Command, "-s", "S1270_32GB_2X960GBSSD_NORAID", "-H", "ibmcloud-cli", "-D", "ibm.com", "-o", "UBUNTU_16_64", "-d", "dal10", "-p", "1000", "-b", "monthly", "-f")
@@ -193,11 +191,16 @@ var _ = Describe("hardware create", func() {
193191
Expect(fakeUI.Outputs()).To(ContainSubstring("Order 123456 was placed."))
194192
Expect(fakeUI.Outputs()).To(ContainSubstring("Run 'ibmcloud sl hardware list --order 123456' to find this hardware server after it is ready."))
195193
})
196-
It("return order receipt", func() {
194+
It("Success with SSH keys", func() {
197195
err := testhelpers.RunCobraCommand(cliCommand.Command, "-s", "S1270_32GB_2X960GBSSD_NORAID", "-H", "ibmcloud-cli", "-D", "ibm.com", "-o", "UBUNTU_16_64", "-d", "dal10", "-p", "1000", "-b", "monthly", "-i", "https://postinstall.sh", "-n", "-k", "123", "-k", "234", "-f")
198196
Expect(err).NotTo(HaveOccurred())
199197
Expect(fakeUI.Outputs()).To(ContainSubstring("Order 123456 was placed."))
200198
Expect(fakeUI.Outputs()).To(ContainSubstring("Run 'ibmcloud sl hardware list --order 123456' to find this hardware server after it is ready."))
199+
_, callData := fakeHardwareManager.GenerateCreateTemplateArgsForCall(0)
200+
sshKeys := callData["sshKeys"]
201+
// Expect(len(callData.SshKeys[0].SshKeyIds)).To(Equal(1))
202+
Expect(sshKeys).To(Equal([]int{123, 234}))
203+
201204
})
202205
It("return order receipt", func() {
203206
err := testhelpers.RunCobraCommand(cliCommand.Command, "-s", "S1270_32GB_2X960GBSSD_NORAID", "-H", "ibmcloud-cli", "-D", "ibm.com", "-o", "UBUNTU_16_64", "-d", "dal10", "-p", "1000", "-b", "monthly", "-i", "https://postinstall.sh", "-n", "-k", "123", "-k", "234", "-e", "1_IPV6_ADDRESS", "-e", "64_BLOCK_STATIC_PUBLIC_IPV6_ADDRESSES", "-f")

0 commit comments

Comments
 (0)