Skip to content

Commit

Permalink
Merge pull request #827 from SoftLayer/issues826
Browse files Browse the repository at this point in the history
Fixed sshKey option in 'hardware create'
  • Loading branch information
allmightyspiff authored and GitHub Enterprise committed Jan 5, 2024
2 parents 52f599c + aeed88c commit 5d2254d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
3 changes: 2 additions & 1 deletion plugin/commands/hardware/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func (cmd *CreateCommand) Run(args []string) error {
params["noPublic"] = true
}
params["postInstallURL"] = cmd.PostInstall
params["ssheKeys"] = cmd.Key
params["sshKeys"] = cmd.Key
params["extras"] = cmd.Extra
}

Expand Down Expand Up @@ -180,6 +180,7 @@ func (cmd *CreateCommand) Run(args []string) error {
return nil
}
}

orderReceipt, err := cmd.HardwareManager.PlaceOrder(orderTemplate)
if err != nil {
return errors.NewAPIError(T("Failed to place this order.\n"), err.Error(), 2)
Expand Down
13 changes: 8 additions & 5 deletions plugin/commands/hardware/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import (
"errors"
"os"

. "github.com/IBM-Cloud/ibm-cloud-cli-sdk/testhelpers/matchers"

"github.com/IBM-Cloud/ibm-cloud-cli-sdk/testhelpers/terminal"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
Expand Down Expand Up @@ -167,13 +165,13 @@ var _ = Describe("hardware create", func() {
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")
Expect(err).NotTo(HaveOccurred())
Expect(fakeUI.Outputs()).To(ContainSubstring("Order 123456 was placed."))
Expect(fakeUI.Outputs()).To(ContainSubstrings([]string{"Run 'ibmcloud sl hardware list --order 123456' to find this hardware server after it is ready."}))
Expect(fakeUI.Outputs()).To(ContainSubstring("Run 'ibmcloud sl hardware list --order 123456' to find this hardware server after it is ready."))
})
It("return order receipt", func() {
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")
Expect(err).NotTo(HaveOccurred())
Expect(fakeUI.Outputs()).To(ContainSubstring("Order 123456 was placed."))
Expect(fakeUI.Outputs()).To(ContainSubstrings([]string{"Run 'ibmcloud sl hardware list --order 123456' to find this hardware server after it is ready."}))
Expect(fakeUI.Outputs()).To(ContainSubstring("Run 'ibmcloud sl hardware list --order 123456' to find this hardware server after it is ready."))
})
It("return order receipt", func() {
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")
Expand All @@ -193,11 +191,16 @@ var _ = Describe("hardware create", func() {
Expect(fakeUI.Outputs()).To(ContainSubstring("Order 123456 was placed."))
Expect(fakeUI.Outputs()).To(ContainSubstring("Run 'ibmcloud sl hardware list --order 123456' to find this hardware server after it is ready."))
})
It("return order receipt", func() {
It("Success with SSH keys", func() {
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")
Expect(err).NotTo(HaveOccurred())
Expect(fakeUI.Outputs()).To(ContainSubstring("Order 123456 was placed."))
Expect(fakeUI.Outputs()).To(ContainSubstring("Run 'ibmcloud sl hardware list --order 123456' to find this hardware server after it is ready."))
_, callData := fakeHardwareManager.GenerateCreateTemplateArgsForCall(0)
sshKeys := callData["sshKeys"]
// Expect(len(callData.SshKeys[0].SshKeyIds)).To(Equal(1))
Expect(sshKeys).To(Equal([]int{123, 234}))

})
It("return order receipt", func() {
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")
Expand Down

0 comments on commit 5d2254d

Please sign in to comment.