func resourceSoftLayerSSHKeyCreate(d *schema.ResourceData, meta interface{}) error { client := meta.(*Client).sshKeyService // Build up our creation options opts := datatypes.SoftLayer_Security_Ssh_Key{ Label: d.Get("name").(string), Key: d.Get("public_key").(string), } if notes, ok := d.GetOk("notes"); ok { opts.Notes = notes.(string) } res, err := client.CreateObject(opts) if err != nil { return fmt.Errorf("Error creating SSH Key: %s", err) } d.SetId(strconv.Itoa(res.Id)) log.Printf("[INFO] SSH Key: %d", res.Id) return resourceSoftLayerSSHKeyRead(d, meta) }
. "github.com/onsi/ginkgo" . "github.com/onsi/gomega" slclientfakes "github.com/maximilien/softlayer-go/client/fakes" datatypes "github.com/maximilien/softlayer-go/data_types" softlayer "github.com/maximilien/softlayer-go/softlayer" testhelpers "github.com/maximilien/softlayer-go/test_helpers" ) var _ = Describe("SoftLayer_Ssh_Key_Service", func() { var ( username, apiKey string err error fakeClient *slclientfakes.FakeSoftLayerClient sshKeyService softlayer.SoftLayer_Security_Ssh_Key_Service sshKey datatypes.SoftLayer_Security_Ssh_Key sshKeyTemplate datatypes.SoftLayer_Security_Ssh_Key ) BeforeEach(func() { username = os.Getenv("SL_USERNAME") Expect(username).ToNot(Equal("")) apiKey = os.Getenv("SL_API_KEY") Expect(apiKey).ToNot(Equal("")) fakeClient = slclientfakes.NewFakeSoftLayerClient(username, apiKey) Expect(fakeClient).ToNot(BeNil())