Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix token API not returning IDs anymore #86

Merged
merged 2 commits into from
Aug 7, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions scaleway/resource_token.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,21 @@ func resourceScalewayToken() *schema.Resource {
Computed: true,
Description: "The userid of the associated user.",
},
"access_key": {
Type: schema.TypeString,
Computed: true,
Description: "The access_key.",
},
"secret_key": {
Type: schema.TypeString,
Computed: true,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we probably want to set Sensitive: true here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done :)

Description: "The secret_key.",
},
"creation_ip": {
Type: schema.TypeString,
Computed: true,
Description: "The ip used to create the key.",
},
"description": {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -99,6 +114,9 @@ func resourceScalewayTokenRead(d *schema.ResourceData, m interface{}) error {
d.Set("expiration_date", token.Expires)
d.Set("expires", token.Expires != "")
d.Set("user_id", token.UserID)
d.Set("creation_ip", token.CreationIP)
d.Set("access_key", token.AccessKey)
d.Set("secret_key", token.SecretKey)
user, err := scaleway.GetUser()
if err != nil {
return err
Expand Down
5 changes: 4 additions & 1 deletion scaleway/resource_token_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ func TestAccScalewayToken_Basic(t *testing.T) {
"scaleway_token.base", "description", "just a test"),
resource.TestCheckResourceAttr(
"scaleway_token.base", "expires", "false"),
resource.TestCheckResourceAttrSet("scaleway_token.base", "access_key"),
resource.TestCheckResourceAttrSet("scaleway_token.base", "secret_key"),
resource.TestCheckResourceAttrSet("scaleway_token.base", "creation_ip"),
),
},
resource.TestStep{
Expand Down Expand Up @@ -129,7 +132,7 @@ func testAccCheckScalewayTokenExists(n string) resource.TestCheckFunc {
}

if token.ID != rs.Primary.ID {
return fmt.Errorf("Record not found")
return fmt.Errorf("Expected %q, got %q", rs.Primary.ID, token.ID)
}

return nil
Expand Down
6 changes: 6 additions & 0 deletions vendor/github.com/nicolai86/scaleway-sdk/tokens.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions vendor/vendor.json
Original file line number Diff line number Diff line change
Expand Up @@ -578,10 +578,10 @@
"revisionTime": "2016-10-03T17:45:16Z"
},
{
"checksumSHA1": "w5i5Tximdwrgf2TDbyVr0KmNO9Q=",
"checksumSHA1": "Aw1tHFrJM6tp6d0taTozZPd3RPw=",
"path": "github.com/nicolai86/scaleway-sdk",
"revision": "798f60e20bb2466bc3d8f36f1cf4f98410e49b6a",
"revisionTime": "2018-06-28T01:02:48Z"
"revision": "56991d7abc819253a234bfdf847add638b75749c",
"revisionTime": "2018-08-06T04:29:30Z"
},
{
"checksumSHA1": "u5s2PZ7fzCOqQX7bVPf9IJ+qNLQ=",
Expand Down
3 changes: 3 additions & 0 deletions website/docs/r/token.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ The following arguments are supported:
The following attributes are exported:

* `id` - Token ID - can be used to access scaleway API
* `access_key` - Token Access Key
* `secret_key` - Token Secret Key
* `creation_ip` - IP used to create the token
* `expiration_date` - Expiration date of token, if expiration is requested

## Import
Expand Down