Skip to content

Commit 06c052b

Browse files
committed
Fix compile errors
1 parent eb7c9d6 commit 06c052b

4 files changed

+13
-21
lines changed

ovh/data_source_ovh_me_ssh_key.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
package ovh
22

33
import (
4-
"fmt"
5-
"log"
6-
74
"github.com/hashicorp/terraform/helper/schema"
85
)
96

ovh/data_source_ovh_me_ssh_keys.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func dataSourceMeSshKeysRead(d *schema.ResourceData, meta interface{}) error {
2828
err := config.OVHClient.Get("/me/sshKey", &names)
2929

3030
if err != nil {
31-
return fmt.Errorf("Error calling %s:\n\t %q", endpoint, err)
31+
return fmt.Errorf("Error calling /me/sshKey:\n\t %q", err)
3232
}
3333

3434
d.Set("names", names)

ovh/resource_ovh_me_ssh_key.go

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,14 @@ package ovh
33
import (
44
"fmt"
55
"log"
6-
"regexp"
7-
"strconv"
8-
"time"
96

10-
"github.com/hashicorp/terraform/helper/resource"
117
"github.com/hashicorp/terraform/helper/schema"
12-
13-
"github.com/ovh/go-ovh/ovh"
148
)
159

1610
func resourceMeSshKey() *schema.Resource {
1711
return &schema.Resource{
1812
Create: resourceMeSshKeyCreate,
19-
Read: readeMeSshKey,
13+
Read: readMeSshKey,
2014
Update: resourceMeSshKeyUpdate,
2115
Delete: resourceMeSshKeyDelete,
2216

@@ -59,12 +53,12 @@ func readMeSshKey(d *schema.ResourceData, meta interface{}) error {
5953
sshKey,
6054
)
6155
if err != nil {
62-
return nil, fmt.Errorf("Unable to find SSH key named %s:\n\t %q", keyName, err)
56+
return fmt.Errorf("Unable to find SSH key named %s:\n\t %q", keyName, err)
6357
}
6458

65-
d.Set("key_name", s.KeyName)
66-
d.Set("key", s.Key)
67-
d.Set("default", s.Default)
59+
d.Set("key_name", sshKey.KeyName)
60+
d.Set("key", sshKey.Key)
61+
d.Set("default", sshKey.Default)
6862

6963
return nil
7064
}
@@ -86,26 +80,27 @@ func resourceMeSshKeyCreate(d *schema.ResourceData, meta interface{}) error {
8680
return fmt.Errorf("Error creating SSH Key with params %s:\n\t %q", params, err)
8781
}
8882

89-
return resourceMeSshKeyRead(d, meta)
83+
return readMeSshKey(d, meta)
9084
}
9185

9286
func resourceMeSshKeyUpdate(d *schema.ResourceData, meta interface{}) error {
9387
config := meta.(*Config)
9488

9589
keyName := d.Get("key_name").(string)
9690
params := &MeSshKeyUpdateOpts{
97-
Default: d.Get("default").(string),
91+
Default: d.Get("default").(bool),
9892
}
9993
err := config.OVHClient.Put(
10094
fmt.Sprintf("/me/sshKey/%s", keyName),
10195
nil,
96+
params,
10297
)
10398
if err != nil {
104-
return nil, fmt.Errorf("Unable to update SSH key named %s:\n\t %q", keyName, err)
99+
return fmt.Errorf("Unable to update SSH key named %s:\n\t %q", keyName, err)
105100
}
106101

107102
log.Printf("[DEBUG] Updated SSH Key %s", keyName)
108-
return resourceMeSshKeyRead(d, meta)
103+
return readMeSshKey(d, meta)
109104
}
110105

111106
func resourceMeSshKeyDelete(d *schema.ResourceData, meta interface{}) error {
@@ -117,7 +112,7 @@ func resourceMeSshKeyDelete(d *schema.ResourceData, meta interface{}) error {
117112
nil,
118113
)
119114
if err != nil {
120-
return nil, fmt.Errorf("Unable to delete SSH key named %s:\n\t %q", keyName, err)
115+
return fmt.Errorf("Unable to delete SSH key named %s:\n\t %q", keyName, err)
121116
}
122117

123118
log.Printf("[DEBUG] Deleted SSH Key %s", keyName)

ovh/types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ type MeSshKeyResponse struct {
166166
}
167167

168168
func (s *MeSshKeyResponse) String() string {
169-
return fmt.Sprintf("SSH Key: %s, key:%s, default:%s",
169+
return fmt.Sprintf("SSH Key: %s, key:%s, default:%t",
170170
s.Key, s.KeyName, s.Default)
171171
}
172172

0 commit comments

Comments
 (0)