Skip to content

Commit

Permalink
InstanceRebuildOptions no longer requires all fields to be specified
Browse files Browse the repository at this point in the history
  • Loading branch information
phillc committed Apr 2, 2020
1 parent 6e3f589 commit f7c090e
Show file tree
Hide file tree
Showing 3 changed files with 405 additions and 7 deletions.
14 changes: 7 additions & 7 deletions instances.go
Original file line number Diff line number Diff line change
Expand Up @@ -398,13 +398,13 @@ func (c *Client) RebootInstance(ctx context.Context, id int, configID int) error

// InstanceRebuildOptions is a struct representing the options to send to the rebuild linode endpoint
type InstanceRebuildOptions struct {
Image string `json:"image"`
RootPass string `json:"root_pass"`
AuthorizedKeys []string `json:"authorized_keys"`
AuthorizedUsers []string `json:"authorized_users"`
StackscriptID int `json:"stackscript_id"`
StackscriptData map[string]string `json:"stackscript_data"`
Booted bool `json:"booted"`
Image string `json:"image,omitempty"`
RootPass string `json:"root_pass,omitempty"`
AuthorizedKeys []string `json:"authorized_keys,omitempty"`
AuthorizedUsers []string `json:"authorized_users,omitempty"`
StackScriptID int `json:"stackscript_id,omitempty"`
StackScriptData map[string]string `json:"stackscript_data,omitempty"`
Booted *bool `json:"booted,omitempty"`
}

// RebuildInstance Deletes all Disks and Configs on this Linode,
Expand Down
373 changes: 373 additions & 0 deletions test/integration/fixtures/TestRebuildInstance.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,373 @@
---
version: 1
interactions:
- request:
body: '{"region":"us-west","type":"g6-nanode-1","label":"linodego-test-instance-wo-disk","booted":false}'
form: {}
headers:
Accept:
- application/json
Content-Type:
- application/json
User-Agent:
- linodego 0.12.0 https://github.com/linode/linodego
url: https://api.linode.com/v4beta/linode/instances
method: POST
response:
body: '{"id": 19977966, "label": "linodego-test-instance-wo-disk", "group": "",
"status": "provisioning", "created": "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05",
"type": "g6-nanode-1", "ipv4": ["10.20.30.40"], "ipv6": "1234::5678/64",
"image": null, "region": "us-west", "specs": {"disk": 25600, "memory": 1024,
"vcpus": 1, "gpus": 0, "transfer": 1000}, "alerts": {"cpu": 90, "network_in":
10, "network_out": 10, "transfer_quota": 80, "io": 10000}, "backups": {"enabled":
false, "schedule": {"day": null, "window": null}, "last_successful": null},
"hypervisor": "kvm", "watchdog_enabled": true, "tags": []}'
headers:
Access-Control-Allow-Credentials:
- "true"
Access-Control-Allow-Headers:
- Authorization, Origin, X-Requested-With, Content-Type, Accept, X-Filter
Access-Control-Allow-Methods:
- HEAD, GET, OPTIONS, POST, PUT, DELETE
Access-Control-Allow-Origin:
- '*'
Access-Control-Expose-Headers:
- X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Status
Cache-Control:
- private, max-age=60, s-maxage=60
Connection:
- keep-alive
Content-Length:
- "632"
Content-Security-Policy:
- default-src 'none'
Content-Type:
- application/json
Date:
- Thu, 02 Apr 2020 13:34:23 GMT
Retry-After:
- "80"
Server:
- nginx
Strict-Transport-Security:
- max-age=31536000
Vary:
- Authorization, X-Filter
X-Accepted-Oauth-Scopes:
- linodes:read_write
X-Content-Type-Options:
- nosniff
X-Frame-Options:
- DENY
- DENY
X-Oauth-Scopes:
- '*'
X-Ratelimit-Limit:
- "1600"
X-Ratelimit-Remaining:
- "1584"
X-Ratelimit-Reset:
- "1585834544"
X-Spec-Version:
- 4.60.0
X-Xss-Protection:
- 1; mode=block
status: 200 OK
code: 200
duration: ""
- request:
body: '{"label":"linodego-test-config","devices":{}}'
form: {}
headers:
Accept:
- application/json
Content-Type:
- application/json
User-Agent:
- linodego 0.12.0 https://github.com/linode/linodego
url: https://api.linode.com/v4beta/linode/instances/19977966/configs
method: POST
response:
body: '{"id": 21359003, "label": "linodego-test-config", "helpers": {"updatedb_disabled":
true, "distro": true, "modules_dep": true, "network": true, "devtmpfs_automount":
true}, "kernel": "linode/latest-64bit", "comments": "", "memory_limit": 0, "created":
"2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05", "root_device": "/dev/sda",
"devices": {"sda": null, "sdb": null, "sdc": null, "sdd": null, "sde": null,
"sdf": null, "sdg": null, "sdh": null}, "initrd": null, "run_level": "default",
"virt_mode": "paravirt"}'
headers:
Access-Control-Allow-Credentials:
- "true"
Access-Control-Allow-Headers:
- Authorization, Origin, X-Requested-With, Content-Type, Accept, X-Filter
Access-Control-Allow-Methods:
- HEAD, GET, OPTIONS, POST, PUT, DELETE
Access-Control-Allow-Origin:
- '*'
Access-Control-Expose-Headers:
- X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Status
Cache-Control:
- private, max-age=60, s-maxage=60
Connection:
- keep-alive
Content-Length:
- "516"
Content-Security-Policy:
- default-src 'none'
Content-Type:
- application/json
Date:
- Thu, 02 Apr 2020 13:34:24 GMT
Retry-After:
- "80"
Server:
- nginx
Strict-Transport-Security:
- max-age=31536000
Vary:
- Authorization, X-Filter
X-Accepted-Oauth-Scopes:
- linodes:read_write
X-Content-Type-Options:
- nosniff
X-Frame-Options:
- DENY
- DENY
X-Oauth-Scopes:
- '*'
X-Ratelimit-Limit:
- "1600"
X-Ratelimit-Remaining:
- "1583"
X-Ratelimit-Reset:
- "1585834545"
X-Spec-Version:
- 4.60.0
X-Xss-Protection:
- 1; mode=block
status: 200 OK
code: 200
duration: ""
- request:
body: ""
form: {}
headers:
Accept:
- application/json
Content-Type:
- application/json
User-Agent:
- linodego 0.12.0 https://github.com/linode/linodego
X-Filter:
- '{"+order":"desc","+order_by":"created","entity.id":19977966,"entity.type":"linode","seen":false}'
url: https://api.linode.com/v4beta/account/events?page=1
method: GET
response:
body: '{"data": [{"id": 79314392, "created": "2018-01-02T03:04:05", "seen": false,
"read": false, "percent_complete": null, "time_remaining": null, "rate": null,
"duration": null, "action": "linode_config_create", "username": "pccampbell",
"entity": {"label": "linodego-test-instance-wo-disk", "id": 19977966, "type":
"linode", "url": "/v4/linode/instances/19977966"}, "status": "notification",
"secondary_entity": {"id": 21359003, "type": "linode_config", "label": "linodego-test-config",
"url": "/v4/linode/instances/19977966/configs/21359003"}}, {"id": 79314390,
"created": "2018-01-02T03:04:05", "seen": false, "read": false, "percent_complete":
100, "time_remaining": 0, "rate": null, "duration": 5.0, "action": "linode_create",
"username": "pccampbell", "entity": {"label": "linodego-test-instance-wo-disk",
"id": 19977966, "type": "linode", "url": "/v4/linode/instances/19977966"}, "status":
"finished", "secondary_entity": null}], "page": 1, "pages": 1, "results": 2}'
headers:
Access-Control-Allow-Credentials:
- "true"
Access-Control-Allow-Headers:
- Authorization, Origin, X-Requested-With, Content-Type, Accept, X-Filter
Access-Control-Allow-Methods:
- HEAD, GET, OPTIONS, POST, PUT, DELETE
Access-Control-Allow-Origin:
- '*'
Access-Control-Expose-Headers:
- X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Status
Cache-Control:
- private, max-age=0, s-maxage=0, no-cache, no-store
- private, max-age=60, s-maxage=60
Connection:
- keep-alive
Content-Length:
- "968"
Content-Security-Policy:
- default-src 'none'
Content-Type:
- application/json
Date:
- Thu, 02 Apr 2020 13:34:39 GMT
Retry-After:
- "64"
Server:
- nginx
Strict-Transport-Security:
- max-age=31536000
Vary:
- Authorization, X-Filter
- Authorization, X-Filter
X-Accepted-Oauth-Scopes:
- events:read_only
X-Content-Type-Options:
- nosniff
X-Frame-Options:
- DENY
- DENY
X-Oauth-Scopes:
- '*'
X-Ratelimit-Limit:
- "1600"
X-Ratelimit-Remaining:
- "1582"
X-Ratelimit-Reset:
- "1585834544"
X-Spec-Version:
- 4.60.0
X-Xss-Protection:
- 1; mode=block
status: 200 OK
code: 200
duration: ""
- request:
body: '{"image":"linode/alpine3.11","root_pass":"R34lBAdP455"}'
form: {}
headers:
Accept:
- application/json
Content-Type:
- application/json
User-Agent:
- linodego 0.12.0 https://github.com/linode/linodego
url: https://api.linode.com/v4beta/linode/instances/19977966/rebuild
method: POST
response:
body: '{"id": 19977966, "label": "linodego-test-instance-wo-disk", "group": "",
"status": "rebuilding", "created": "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05",
"type": "g6-nanode-1", "ipv4": ["10.20.30.40"], "ipv6": "1234::5678/64",
"image": "linode/alpine3.11", "region": "us-west", "specs": {"disk": 25600,
"memory": 1024, "vcpus": 1, "gpus": 0, "transfer": 1000}, "alerts": {"cpu":
90, "network_in": 10, "network_out": 10, "transfer_quota": 80, "io": 10000},
"backups": {"enabled": false, "schedule": {"day": null, "window": null}, "last_successful":
null}, "hypervisor": "kvm", "watchdog_enabled": true, "tags": []}'
headers:
Access-Control-Allow-Credentials:
- "true"
Access-Control-Allow-Headers:
- Authorization, Origin, X-Requested-With, Content-Type, Accept, X-Filter
Access-Control-Allow-Methods:
- HEAD, GET, OPTIONS, POST, PUT, DELETE
Access-Control-Allow-Origin:
- '*'
Access-Control-Expose-Headers:
- X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Status
Cache-Control:
- private, max-age=60, s-maxage=60
Connection:
- keep-alive
Content-Length:
- "645"
Content-Security-Policy:
- default-src 'none'
Content-Type:
- application/json
Date:
- Thu, 02 Apr 2020 13:34:40 GMT
Retry-After:
- "64"
Server:
- nginx
Strict-Transport-Security:
- max-age=31536000
Vary:
- Authorization, X-Filter
X-Accepted-Oauth-Scopes:
- linodes:read_write
X-Content-Type-Options:
- nosniff
X-Frame-Options:
- DENY
- DENY
X-Oauth-Scopes:
- '*'
X-Ratelimit-Limit:
- "1600"
X-Ratelimit-Remaining:
- "1581"
X-Ratelimit-Reset:
- "1585834545"
X-Spec-Version:
- 4.60.0
X-Xss-Protection:
- 1; mode=block
status: 200 OK
code: 200
duration: ""
- request:
body: ""
form: {}
headers:
Accept:
- application/json
Content-Type:
- application/json
User-Agent:
- linodego 0.12.0 https://github.com/linode/linodego
url: https://api.linode.com/v4beta/linode/instances/19977966
method: DELETE
response:
body: '{}'
headers:
Access-Control-Allow-Credentials:
- "true"
Access-Control-Allow-Headers:
- Authorization, Origin, X-Requested-With, Content-Type, Accept, X-Filter
Access-Control-Allow-Methods:
- HEAD, GET, OPTIONS, POST, PUT, DELETE
Access-Control-Allow-Origin:
- '*'
Access-Control-Expose-Headers:
- X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Status
Cache-Control:
- private, max-age=60, s-maxage=60
Connection:
- keep-alive
Content-Length:
- "2"
Content-Security-Policy:
- default-src 'none'
Content-Type:
- application/json
Date:
- Thu, 02 Apr 2020 13:34:40 GMT
Retry-After:
- "63"
Server:
- nginx
Strict-Transport-Security:
- max-age=31536000
Vary:
- Authorization, X-Filter
X-Accepted-Oauth-Scopes:
- linodes:read_write
X-Content-Type-Options:
- nosniff
X-Frame-Options:
- DENY
- DENY
X-Oauth-Scopes:
- '*'
X-Ratelimit-Limit:
- "1600"
X-Ratelimit-Remaining:
- "1580"
X-Ratelimit-Reset:
- "1585834544"
X-Spec-Version:
- 4.60.0
X-Xss-Protection:
- 1; mode=block
status: 200 OK
code: 200
duration: ""
Loading

0 comments on commit f7c090e

Please sign in to comment.