-
Notifications
You must be signed in to change notification settings - Fork 83
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
Add support for OBJ gen2 #649
base: main
Are you sure you want to change the base?
Conversation
b35ffe2
to
e7e09ae
Compare
e7e09ae
to
cf499ea
Compare
b90f3cf
to
c75f5c9
Compare
return doGETRequest[ObjectStorageObjectACLConfigV2](ctx, c, e) | ||
} | ||
|
||
func (c *Client) UpdateObjectStorageObjectACLConfigV2(ctx context.Context, objectID, label string, opts ObjectStorageObjectACLConfigUpdateOptions) (*ObjectStorageObjectACLConfigV2, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if it's worth introducing a ObjectStorageObjectACLConfigUpdateOptionsV2
struct for consistency and future-proofing, although it might be a bit redundant 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the API schema will stay the same for this set of options? Gen2 doesn't currently support the object-level ACL.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, excellent work!
Manually tested on my local machine using the following:
package main
import (
"context"
_ "embed"
"log"
"os"
"github.com/davecgh/go-spew/spew"
"github.com/linode/linodego"
)
var (
//go:embed key.pem
privateKey string
//go:embed cert.pem
certificate string
)
func main() {
ctx := context.Background()
client := linodego.NewClient(nil)
client.SetToken(os.Getenv("LINODE_TOKEN"))
client.SetAPIVersion("v4beta")
endpoints, err := client.ListObjectStorageEndpoints(ctx, nil)
if err != nil {
log.Fatal(err)
}
spew.Dump(endpoints)
bucket, err := client.CreateObjectStorageBucket(ctx, linodego.ObjectStorageBucketCreateOptions{
Region: endpoints[0].Region,
Label: "lgarber-dev-foobar",
S3Endpoint: *endpoints[0].S3Endpoint,
EndpointType: endpoints[0].EndpointType,
ACL: linodego.ACLAuthenticatedRead,
})
if err != nil {
log.Fatal(err)
}
spew.Dump(bucket)
acl, err := client.GetObjectStorageBucketAccessV2(ctx, bucket.Region, bucket.Label)
if err != nil {
log.Fatal(err)
}
spew.Dump(acl)
if err := client.UpdateObjectStorageBucketAccess(ctx, bucket.Region, bucket.Label, linodego.ObjectStorageBucketUpdateAccessOptions{
ACL: linodego.ACLPublicRead,
CorsEnabled: linodego.Pointer(false),
}); err != nil {
log.Fatal(err)
}
acl, err = client.GetObjectStorageBucketAccessV2(ctx, bucket.Region, bucket.Label)
if err != nil {
log.Fatal(err)
}
spew.Dump(acl)
cert, err := client.UploadObjectStorageBucketCertV2(ctx, bucket.Region, bucket.Label, linodego.ObjectStorageBucketCertUploadOptions{
Certificate: certificate,
PrivateKey: privateKey,
})
if err != nil {
log.Fatal(err)
}
spew.Dump(cert)
cert, err = client.GetObjectStorageBucketCertV2(ctx, bucket.Region, bucket.Label)
if err != nil {
log.Fatal(err)
}
spew.Dump(cert)
key, err := client.CreateObjectStorageKey(ctx, linodego.ObjectStorageKeyCreateOptions{
Label: "lgarber-dev-key",
BucketAccess: &[]linodego.ObjectStorageKeyBucketAccess{
{
Region: endpoints[0].Region,
BucketName: bucket.Label,
Permissions: "read_write",
},
},
Regions: []string{endpoints[0].Region},
})
if err != nil {
log.Fatal(err)
}
spew.Dump(key)
}
📝 Description
This is to add support for the API changes came with the object storage service gen2.
✔️ How to Test
make fixtures ARGS="-run TestObjectStorage"