Skip to content

Commit

Permalink
Add Limited Access Keys
Browse files Browse the repository at this point in the history
  • Loading branch information
phillc committed Oct 21, 2020
1 parent 590e28a commit b14973a
Show file tree
Hide file tree
Showing 20 changed files with 580 additions and 489 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ env:
- GO111MODULE=on

go:
- "1.13"
- "1.15"

before_script:
- bash ./scripts/verify-gomod-tidy.sh
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ require (
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45
)

go 1.13
go 1.15
2 changes: 1 addition & 1 deletion k8s/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ require (

replace github.com/linode/linodego => ../

go 1.13
go 1.15
21 changes: 16 additions & 5 deletions object_storage_keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,26 @@ import (

// ObjectStorageKey represents a linode object storage key object
type ObjectStorageKey struct {
ID int `json:"id"`
Label string `json:"label"`
AccessKey string `json:"access_key"`
SecretKey string `json:"secret_key"`
ID int `json:"id"`
Label string `json:"label"`
AccessKey string `json:"access_key"`
SecretKey string `json:"secret_key"`
Limited bool `json:"limited"`
BucketAccess *[]ObjectStorageKeyBucketAccess `json:"bucket_access"`
}

// ObjectStorageKeyBucketAccess represents a linode limited object storage key's bucket access
type ObjectStorageKeyBucketAccess struct {
Cluster string `json:"cluster"`
BucketName string `json:"bucket_name"`
Permissions string `json:"permissions"`
}

// ObjectStorageKeyCreateOptions fields are those accepted by CreateObjectStorageKey
type ObjectStorageKeyCreateOptions struct {
Label string `json:"label"`
Label string `json:"label"`
Limited bool `json:"limited,omitempty"`
BucketAccess *[]ObjectStorageKeyBucketAccess `json:"bucket_access"`
}

// ObjectStorageKeyUpdateOptions fields are those accepted by UpdateObjectStorageKey
Expand Down
16 changes: 8 additions & 8 deletions test/go.mod
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
module test

go 1.13
go 1.15

require (
github.com/dnaeon/go-vcr v1.0.1
github.com/google/go-cmp v0.5.2
github.com/linode/linodego v0.20.1
github.com/linode/linodego/k8s v0.0.0-00010101000000-000000000000
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d
gopkg.in/yaml.v2 v2.3.0 // indirect
k8s.io/client-go v0.18.3
github.com/dnaeon/go-vcr v1.0.1
github.com/google/go-cmp v0.5.2
github.com/linode/linodego v0.20.1
github.com/linode/linodego/k8s v0.0.0-00010101000000-000000000000
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d
gopkg.in/yaml.v2 v2.3.0 // indirect
k8s.io/client-go v0.18.3
)

replace github.com/linode/linodego => ../
Expand Down
47 changes: 11 additions & 36 deletions test/integration/fixtures/TestCreateObjectStorageBucket.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,19 @@
version: 1
interactions:
- request:
body: '{"cluster":"us-east-1","label":"linodego-test-bucket-1570022485501837000"}'
body: '{"cluster":"us-east-1","label":"linodego-test-bucket-1603309943521033000"}'
form: {}
headers:
Accept:
- application/json
Authorization:
- Bearer awesometokenawesometokenawesometoken
Content-Type:
- application/json
User-Agent:
- linodego 0.10.0 https://github.com/linode/linodego
- linodego https://github.com/linode/linodego
url: https://api.linode.com/v4beta/object-storage/buckets
method: POST
response:
body: '{"created": "2018-01-02T03:04:05", "hostname": "linodego-test-bucket-1570022485501837000.us-east-1.linodeobjects.com",
"label": "linodego-test-bucket-1570022485501837000", "cluster": "us-east-1"}'
body: '{"hostname": "linodego-test-bucket-1603309943521033000.us-east-1.linodeobjects.com", "label": "linodego-test-bucket-1603309943521033000", "created": "2020-10-21T19:52:30", "cluster": "us-east-1", "size": 0}'
headers:
Access-Control-Allow-Credentials:
- "true"
Expand All @@ -31,18 +28,12 @@ interactions:
- X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Status
Cache-Control:
- private, max-age=60, s-maxage=60
Connection:
- keep-alive
Content-Length:
- "201"
- "206"
Content-Security-Policy:
- default-src 'none'
Content-Type:
- application/json
Date:
- Fri, 27 Sep 2019 15:22:34 GMT
Retry-After:
- "117"
Server:
- nginx
Strict-Transport-Security:
Expand All @@ -59,13 +50,9 @@ interactions:
X-Oauth-Scopes:
- '*'
X-Ratelimit-Limit:
- "400"
X-Ratelimit-Remaining:
- "399"
X-Ratelimit-Reset:
- "1569597872"
- "800"
X-Spec-Version:
- 4.5.0
- 4.78.3
X-Xss-Protection:
- 1; mode=block
status: 200 OK
Expand All @@ -77,13 +64,11 @@ interactions:
headers:
Accept:
- application/json
Authorization:
- Bearer awesometokenawesometokenawesometoken
Content-Type:
- application/json
User-Agent:
- linodego 0.10.0 https://github.com/linode/linodego
url: https://api.linode.com/v4beta/object-storage/buckets/us-east-1/linodego-test-bucket-1570022485501837000
- linodego https://github.com/linode/linodego
url: https://api.linode.com/v4beta/object-storage/buckets/us-east-1/linodego-test-bucket-1603309943521033000
method: DELETE
response:
body: '{}'
Expand All @@ -100,26 +85,20 @@ interactions:
- 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:
- Fri, 27 Sep 2019 15:22:34 GMT
Retry-After:
- "119"
Server:
- nginx
Strict-Transport-Security:
- max-age=31536000
Vary:
- Authorization, X-Filter
X-Accepted-Oauth-Scopes:
- object_storage:read_only
- object_storage:read_write
X-Content-Type-Options:
- nosniff
X-Frame-Options:
Expand All @@ -128,13 +107,9 @@ interactions:
X-Oauth-Scopes:
- '*'
X-Ratelimit-Limit:
- "400"
X-Ratelimit-Remaining:
- "399"
X-Ratelimit-Reset:
- "1569597874"
- "800"
X-Spec-Version:
- 4.5.0
- 4.78.3
X-Xss-Protection:
- 1; mode=block
status: 200 OK
Expand Down
74 changes: 17 additions & 57 deletions test/integration/fixtures/TestGetObjectStorageBucket_found.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,19 @@
version: 1
interactions:
- request:
body: '{"cluster":"us-east-1","label":"linodego-test-bucket-1570022485501837000"}'
body: '{"cluster":"us-east-1","label":"linodego-test-bucket-1603309943521033000"}'
form: {}
headers:
Accept:
- application/json
Authorization:
- Bearer awesometokenawesometokenawesometoken
Content-Type:
- application/json
User-Agent:
- linodego 0.10.0 https://github.com/linode/linodego
- linodego https://github.com/linode/linodego
url: https://api.linode.com/v4beta/object-storage/buckets
method: POST
response:
body: '{"cluster": "us-east-1",
"created": "2018-01-02T03:04:05", "label": "linodego-test-bucket-1570022485501837000",
"hostname": "linodego-test-bucket-1570022485501837000.us-east-1.linodeobjects.com"}'
body: '{"hostname": "linodego-test-bucket-1603309943521033000.us-east-1.linodeobjects.com", "label": "linodego-test-bucket-1603309943521033000", "created": "2020-10-21T19:52:35", "cluster": "us-east-1", "size": 0}'
headers:
Access-Control-Allow-Credentials:
- "true"
Expand All @@ -32,18 +28,12 @@ interactions:
- X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Status
Cache-Control:
- private, max-age=60, s-maxage=60
Connection:
- keep-alive
Content-Length:
- "201"
- "206"
Content-Security-Policy:
- default-src 'none'
Content-Type:
- application/json
Date:
- Fri, 27 Sep 2019 15:22:38 GMT
Retry-After:
- "118"
Server:
- nginx
Strict-Transport-Security:
Expand All @@ -60,13 +50,9 @@ interactions:
X-Oauth-Scopes:
- '*'
X-Ratelimit-Limit:
- "400"
X-Ratelimit-Remaining:
- "399"
X-Ratelimit-Reset:
- "1569597877"
- "800"
X-Spec-Version:
- 4.5.0
- 4.78.3
X-Xss-Protection:
- 1; mode=block
status: 200 OK
Expand All @@ -78,18 +64,14 @@ interactions:
headers:
Accept:
- application/json
Authorization:
- Bearer awesometokenawesometokenawesometoken
Content-Type:
- application/json
User-Agent:
- linodego 0.10.0 https://github.com/linode/linodego
url: https://api.linode.com/v4beta/object-storage/buckets/us-east-1/linodego-test-bucket-1570022485501837000
- linodego https://github.com/linode/linodego
url: https://api.linode.com/v4beta/object-storage/buckets/us-east-1/linodego-test-bucket-1603309943521033000
method: GET
response:
body: '{"hostname": "linodego-test-bucket-1570022485501837000.us-east-1.linodeobjects.com",
"label": "linodego-test-bucket-1570022485501837000", "cluster":
"us-east-1", "created": "2018-01-02T03:04:05"}'
body: '{"hostname": "linodego-test-bucket-1603309943521033000.us-east-1.linodeobjects.com", "label": "linodego-test-bucket-1603309943521033000", "created": "2020-10-21T19:52:35", "cluster": "us-east-1", "size": 0}'
headers:
Access-Control-Allow-Credentials:
- "true"
Expand All @@ -104,18 +86,12 @@ interactions:
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:
- "201"
- "206"
Content-Security-Policy:
- default-src 'none'
Content-Type:
- application/json
Date:
- Fri, 27 Sep 2019 15:22:38 GMT
Retry-After:
- "113"
Server:
- nginx
Strict-Transport-Security:
Expand All @@ -133,13 +109,9 @@ interactions:
X-Oauth-Scopes:
- '*'
X-Ratelimit-Limit:
- "400"
X-Ratelimit-Remaining:
- "398"
X-Ratelimit-Reset:
- "1569597872"
- "800"
X-Spec-Version:
- 4.5.0
- 4.78.3
X-Xss-Protection:
- 1; mode=block
status: 200 OK
Expand All @@ -151,13 +123,11 @@ interactions:
headers:
Accept:
- application/json
Authorization:
- Bearer awesometokenawesometokenawesometoken
Content-Type:
- application/json
User-Agent:
- linodego 0.10.0 https://github.com/linode/linodego
url: https://api.linode.com/v4beta/object-storage/buckets/us-east-1/linodego-test-bucket-1570022485501837000
- linodego https://github.com/linode/linodego
url: https://api.linode.com/v4beta/object-storage/buckets/us-east-1/linodego-test-bucket-1603309943521033000
method: DELETE
response:
body: '{}'
Expand All @@ -174,26 +144,20 @@ interactions:
- 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:
- Fri, 27 Sep 2019 15:22:39 GMT
Retry-After:
- "119"
Server:
- nginx
Strict-Transport-Security:
- max-age=31536000
Vary:
- Authorization, X-Filter
X-Accepted-Oauth-Scopes:
- object_storage:read_only
- object_storage:read_write
X-Content-Type-Options:
- nosniff
X-Frame-Options:
Expand All @@ -202,13 +166,9 @@ interactions:
X-Oauth-Scopes:
- '*'
X-Ratelimit-Limit:
- "400"
X-Ratelimit-Remaining:
- "399"
X-Ratelimit-Reset:
- "1569597879"
- "800"
X-Spec-Version:
- 4.5.0
- 4.78.3
X-Xss-Protection:
- 1; mode=block
status: 200 OK
Expand Down
Loading

0 comments on commit b14973a

Please sign in to comment.