summaryrefslogtreecommitdiffstats
path: root/examples/rgw/golang
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-21 11:54:28 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-21 11:54:28 +0000
commite6918187568dbd01842d8d1d2c808ce16a894239 (patch)
tree64f88b554b444a49f656b6c656111a145cbbaa28 /examples/rgw/golang
parentInitial commit. (diff)
downloadceph-b26c4052f3542036551aa9dec9caa4226e456195.tar.xz
ceph-b26c4052f3542036551aa9dec9caa4226e456195.zip
Adding upstream version 18.2.2.upstream/18.2.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--examples/rgw/golang/object-upload/README.md16
-rw-r--r--examples/rgw/golang/object-upload/fortuna.txt1
-rw-r--r--examples/rgw/golang/object-upload/go.mod5
-rw-r--r--examples/rgw/golang/object-upload/go.sum24
-rw-r--r--examples/rgw/golang/object-upload/object-upload.go84
-rw-r--r--examples/rgw/golang/put-bucket-notification-creation/README.md24
-rw-r--r--examples/rgw/golang/put-bucket-notification-creation/go.mod5
-rw-r--r--examples/rgw/golang/put-bucket-notification-creation/go.sum24
-rw-r--r--examples/rgw/golang/put-bucket-notification-creation/put-bucket-notification-creation.go96
-rw-r--r--examples/rgw/golang/topic-creation/README.md11
-rw-r--r--examples/rgw/golang/topic-creation/go.mod5
-rw-r--r--examples/rgw/golang/topic-creation/go.sum24
-rw-r--r--examples/rgw/golang/topic-creation/topic-creation.go81
13 files changed, 400 insertions, 0 deletions
diff --git a/examples/rgw/golang/object-upload/README.md b/examples/rgw/golang/object-upload/README.md
new file mode 100644
index 000000000..1bf1c24ae
--- /dev/null
+++ b/examples/rgw/golang/object-upload/README.md
@@ -0,0 +1,16 @@
+# Introduction
+This directory contains Golang code examples on how to upload an object to an S3 bucket running on a Ceph RGW cluster.
+
+# Prerequisite
+Linux machine running an RGW Ceph cluster. Preferrably started with the ``OSD=1 MON=1 MDS=0 MGR=0 RGW=1 ../src/vstart.sh --debug --new `` command.
+Go installed on the Linux machine.
+
+## Workflow Procedure
+1. Install AWS CLI version one on your Linux machine as explained [here](https://docs.aws.amazon.com/cli/v1/userguide/install-linux.html)
+2. Create a bucket on the Ceph cluster with the command
+```
+aws --endpoint-url http://localhost:8000 s3 mb s3://sample-bucket
+```
+3. Navigate through your file system to where the Golang example code exist on your terminal.
+4. Run ``` go mod tidy ``` to install the required Go packages on the system.
+5. Run the Golang program as ``` go run object-upload.go -b sample-bucket -f fortuna.txt ``` on the terminal window to test out object upload to Ceph RGW cluster.
diff --git a/examples/rgw/golang/object-upload/fortuna.txt b/examples/rgw/golang/object-upload/fortuna.txt
new file mode 100644
index 000000000..146240570
--- /dev/null
+++ b/examples/rgw/golang/object-upload/fortuna.txt
@@ -0,0 +1 @@
+This file is being used to test Go upload capabilities to Ceph RGW cluster.
diff --git a/examples/rgw/golang/object-upload/go.mod b/examples/rgw/golang/object-upload/go.mod
new file mode 100644
index 000000000..9cb158af1
--- /dev/null
+++ b/examples/rgw/golang/object-upload/go.mod
@@ -0,0 +1,5 @@
+module ceph/object-upload
+
+go 1.13
+
+require github.com/aws/aws-sdk-go v1.43.41
diff --git a/examples/rgw/golang/object-upload/go.sum b/examples/rgw/golang/object-upload/go.sum
new file mode 100644
index 000000000..8ab2f12b3
--- /dev/null
+++ b/examples/rgw/golang/object-upload/go.sum
@@ -0,0 +1,24 @@
+github.com/aws/aws-sdk-go v1.43.41 h1:HaazVplP8/t6SOfybQlNUmjAxLWDKdLdX8BSEHFlJdY=
+github.com/aws/aws-sdk-go v1.43.41/go.mod h1:y4AeaBuwd2Lk+GepC1E9v0qOiTws0MIWAX4oIKwKHZo=
+github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
+github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg=
+github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo=
+github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8=
+github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U=
+github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
+github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
+github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
+github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
+golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd h1:O7DYs+zxREGLKzKoMQrtrEacpb0ZVXA5rIwylE2Xchk=
+golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
+golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
+golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
+golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
+golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
+gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
+gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
+gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
+gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
diff --git a/examples/rgw/golang/object-upload/object-upload.go b/examples/rgw/golang/object-upload/object-upload.go
new file mode 100644
index 000000000..82f09caa2
--- /dev/null
+++ b/examples/rgw/golang/object-upload/object-upload.go
@@ -0,0 +1,84 @@
+package main
+
+import (
+ "flag"
+ "fmt"
+ "os"
+
+ "github.com/aws/aws-sdk-go/aws"
+ "github.com/aws/aws-sdk-go/aws/credentials"
+ "github.com/aws/aws-sdk-go/aws/endpoints"
+ "github.com/aws/aws-sdk-go/aws/session"
+ "github.com/aws/aws-sdk-go/service/s3/s3manager"
+)
+
+func main() {
+ bucket := flag.String("b", "", "The name of the bucket")
+ filename := flag.String("f", "", "Complete file path to object to be uploaded")
+ flag.Parse()
+
+ if *bucket == "" {
+ fmt.Println("You must supply the name of the bucket")
+ fmt.Println("-b BUCKET")
+ return
+ }
+
+ if *filename == "" {
+ fmt.Println("You must supply the object to be uploaded")
+ fmt.Println("-f FILE/FILEPATH")
+ return
+ }
+
+ file, err := os.Open(*filename)
+ if err != nil {
+ exitErrorf("Unable to open file %q, %v", filename, err)
+ }
+
+ defer file.Close()
+
+ //Ceph RGW Cluster credentials
+ access_key := "0555b35654ad1656d804"
+ secret_key := "h7GhxuBLTrlhVUyxSPUKUV8r/2EI4ngqJxD7iBdBYLhwluN30JaT3Q=="
+ token_id := ""
+ url := "http://127.0.0.1:8000"
+
+ defaultResolver := endpoints.DefaultResolver()
+ s3CustResolverFn := func(service, region string, optFns ...func(*endpoints.Options)) (endpoints.ResolvedEndpoint, error) {
+ if service == "s3" {
+ return endpoints.ResolvedEndpoint{
+ URL: url,
+ }, nil
+ }
+
+ return defaultResolver.EndpointFor(service, region, optFns...)
+ }
+
+ sess := session.Must(session.NewSessionWithOptions(session.Options{
+ Config: aws.Config{
+ Region: aws.String("default"),
+ Credentials: credentials.NewStaticCredentials(access_key, secret_key, token_id),
+ S3ForcePathStyle: aws.Bool(true),
+ EndpointResolver: endpoints.ResolverFunc(s3CustResolverFn),
+ },
+ }))
+
+ uploader := s3manager.NewUploader(sess)
+
+ // Upload the file's body to S3 bucket as an object with the key being the
+ // same as the filename.
+ _, err = uploader.Upload(&s3manager.UploadInput{
+ Bucket: bucket,
+ Key: filename,
+ Body: file,
+ })
+ if err != nil {
+ exitErrorf("Unable to upload %q to %q, %v", *filename, *bucket, err)
+ }
+
+ fmt.Printf("Successfully uploaded %q to %q\n", *filename, *bucket)
+}
+
+func exitErrorf(msg string, args ...interface{}) {
+ fmt.Fprintf(os.Stderr, msg+"\n", args...)
+ os.Exit(1)
+}
diff --git a/examples/rgw/golang/put-bucket-notification-creation/README.md b/examples/rgw/golang/put-bucket-notification-creation/README.md
new file mode 100644
index 000000000..47555c0c0
--- /dev/null
+++ b/examples/rgw/golang/put-bucket-notification-creation/README.md
@@ -0,0 +1,24 @@
+# Introduction
+This directory contains Golang code examples on how to create a put bucket notification to a topic and S3 bucket running on a Ceph RGW cluster.
+
+# Prerequisite
+Linux machine running an RGW Ceph cluster. Preferrably started with the ``OSD=1 MON=1 MDS=0 MGR=0 RGW=1 ../src/vstart.sh --debug --new `` command.
+Go installed on the Linux machine.
+
+## Workflow Procedure
+1. Install AWS CLI version one on your Linux machine as explained [here](https://docs.aws.amazon.com/cli/v1/userguide/install-linux.html)
+2. Create a topic on the Ceph cluster with the command
+```
+aws --region default --endpoint-url http://localhost:8000 sns create-topic --name=sample-topic --attributes='{"push-endpoint": "http://localhost:10900"}'
+```
+3. Create a bucket to which the topic will be attached to with the command
+```
+aws --endpoint-url http://localhost:8000 s3 mb s3://sample-bucket
+```
+4. Navigate through your file system to where the Golang example code exists on your terminal.
+5. Run ``` go mod tidy ``` to install the required Go packages on the system.
+6. Run the Golang program as ``` go run put-bucket-notification-creation.go -b sample-bucket -t arn:aws:sns:default::sample-topic ``` on the terminal window to create the put bucket notification with the suffix filter rule.
+7. Upload any jpg file you have to the bucket with the command
+```
+aws --endpoint-url http://localhost:8000 s3 cp your-jpg-file.jpg s3://sample-bucket
+```
diff --git a/examples/rgw/golang/put-bucket-notification-creation/go.mod b/examples/rgw/golang/put-bucket-notification-creation/go.mod
new file mode 100644
index 000000000..4740ead2f
--- /dev/null
+++ b/examples/rgw/golang/put-bucket-notification-creation/go.mod
@@ -0,0 +1,5 @@
+module put-bucket-notification-creation
+
+go 1.13
+
+require github.com/aws/aws-sdk-go v1.44.62
diff --git a/examples/rgw/golang/put-bucket-notification-creation/go.sum b/examples/rgw/golang/put-bucket-notification-creation/go.sum
new file mode 100644
index 000000000..7cee1fa2b
--- /dev/null
+++ b/examples/rgw/golang/put-bucket-notification-creation/go.sum
@@ -0,0 +1,24 @@
+github.com/aws/aws-sdk-go v1.44.62 h1:N8qOPnBhl2ZCIFiqyB640Xt5CeX9D8CEVhG/Vj7jGJU=
+github.com/aws/aws-sdk-go v1.44.62/go.mod h1:y4AeaBuwd2Lk+GepC1E9v0qOiTws0MIWAX4oIKwKHZo=
+github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
+github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg=
+github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo=
+github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8=
+github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U=
+github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
+github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
+github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
+github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
+golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd h1:O7DYs+zxREGLKzKoMQrtrEacpb0ZVXA5rIwylE2Xchk=
+golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
+golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
+golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
+golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
+golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
+gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
+gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
+gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
+gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
diff --git a/examples/rgw/golang/put-bucket-notification-creation/put-bucket-notification-creation.go b/examples/rgw/golang/put-bucket-notification-creation/put-bucket-notification-creation.go
new file mode 100644
index 000000000..5e8b7f4bc
--- /dev/null
+++ b/examples/rgw/golang/put-bucket-notification-creation/put-bucket-notification-creation.go
@@ -0,0 +1,96 @@
+package main
+
+import (
+ "flag"
+ "fmt"
+ "os"
+
+ "github.com/aws/aws-sdk-go/aws"
+ "github.com/aws/aws-sdk-go/aws/credentials"
+ "github.com/aws/aws-sdk-go/aws/endpoints"
+ "github.com/aws/aws-sdk-go/aws/session"
+ "github.com/aws/aws-sdk-go/service/s3"
+)
+
+func main() {
+ bucket := flag.String("b", "", "Name of the bucket to add notification to")
+ topic := flag.String("t", "", "The topic onto which the notification is attached to")
+ flag.Parse()
+
+ if *bucket == "" {
+ fmt.Println("You must supply the name of the bucket")
+ fmt.Println("-b BUCKET")
+ return
+ }
+
+ if *topic == "" {
+ fmt.Println("You must supply the name of the topic ARN")
+ fmt.Println("-t TOPIC ARN")
+ return
+ }
+
+ //Ceph RGW Credentials
+ access_key := "0555b35654ad1656d804"
+ secret_key := "h7GhxuBLTrlhVUyxSPUKUV8r/2EI4ngqJxD7iBdBYLhwluN30JaT3Q=="
+ token_id := ""
+ url := "http://127.0.0.1:8000"
+
+ defaultResolver := endpoints.DefaultResolver()
+ CustResolverFn := func(service, region string, optFns ...func(*endpoints.Options)) (endpoints.ResolvedEndpoint, error) {
+ if service == "s3" {
+ return endpoints.ResolvedEndpoint{
+ URL: url,
+ }, nil
+ }
+
+ return defaultResolver.EndpointFor(service, region, optFns...)
+ }
+
+ sess := session.Must(session.NewSessionWithOptions(session.Options{
+ Config: aws.Config{
+ Region: aws.String("default"),
+ Credentials: credentials.NewStaticCredentials(access_key, secret_key, token_id),
+ S3ForcePathStyle: aws.Bool(true),
+ EndpointResolver: endpoints.ResolverFunc(CustResolverFn),
+ },
+ }))
+
+ svc := s3.New(sess)
+
+ suffixRule := []*s3.FilterRule{
+ {
+ Name: aws.String("suffix"),
+ Value: aws.String("jpg"),
+ },
+ }
+
+ input := &s3.PutBucketNotificationConfigurationInput{
+ Bucket: bucket,
+ NotificationConfiguration: &s3.NotificationConfiguration{
+ TopicConfigurations: []*s3.TopicConfiguration{
+ {
+ Events: []*string{aws.String("s3:ObjectCreated:*")},
+ Filter: &s3.NotificationConfigurationFilter{
+ Key: &s3.KeyFilter{
+ FilterRules: suffixRule,
+ },
+ },
+ Id: aws.String("notif1"), //Raises MalformedXML if absent
+ TopicArn: topic,
+ },
+ },
+ },
+ }
+
+ _, err := svc.PutBucketNotificationConfiguration(input)
+
+ if err != nil {
+ exitErrorf("Unable to create Put Bucket Notification because of %s", err)
+ }
+ fmt.Println("Put bucket notification added to ", *topic)
+}
+
+func exitErrorf(msg string, args ...interface{}) {
+ fmt.Fprintf(os.Stderr, msg+"\n", args...)
+ os.Exit(1)
+}
diff --git a/examples/rgw/golang/topic-creation/README.md b/examples/rgw/golang/topic-creation/README.md
new file mode 100644
index 000000000..3033a86c5
--- /dev/null
+++ b/examples/rgw/golang/topic-creation/README.md
@@ -0,0 +1,11 @@
+# Introduction
+This directory contains Golang code example on how to create an SNS Topic on a Ceph RGW cluster.
+
+# Prerequisite
+Linux machine running an RGW Ceph cluster. Preferrably started with the ``OSD=1 MON=1 MDS=0 MGR=0 RGW=1 ../src/vstart.sh --debug --new `` command.
+Go installed on the Linux machine.
+
+## Workflow Procedure
+1. Navigate through your file system to where the Golang example code exists on your terminal.
+2. Run ``` go mod tidy ``` to install the required Golang packages on the system.
+3. Run the Golang program as ``` go run topic-creation.go -t sample-topic-1 -a '{"push-endpoint": "http://127.0.0.1:10900"}' ``` on the terminal window to create SNS topic with custom attributes.
diff --git a/examples/rgw/golang/topic-creation/go.mod b/examples/rgw/golang/topic-creation/go.mod
new file mode 100644
index 000000000..4b4f7fabd
--- /dev/null
+++ b/examples/rgw/golang/topic-creation/go.mod
@@ -0,0 +1,5 @@
+module examples/topic-creation
+
+go 1.13
+
+require github.com/aws/aws-sdk-go v1.44.61
diff --git a/examples/rgw/golang/topic-creation/go.sum b/examples/rgw/golang/topic-creation/go.sum
new file mode 100644
index 000000000..4c3ec3873
--- /dev/null
+++ b/examples/rgw/golang/topic-creation/go.sum
@@ -0,0 +1,24 @@
+github.com/aws/aws-sdk-go v1.44.61 h1:NcpLSS3Z0MiVQIYugx4I40vSIEEAXT0baO684ExNRco=
+github.com/aws/aws-sdk-go v1.44.61/go.mod h1:y4AeaBuwd2Lk+GepC1E9v0qOiTws0MIWAX4oIKwKHZo=
+github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
+github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg=
+github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo=
+github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8=
+github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U=
+github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
+github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
+github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
+github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
+golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd h1:O7DYs+zxREGLKzKoMQrtrEacpb0ZVXA5rIwylE2Xchk=
+golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
+golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
+golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
+golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
+golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
+gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
+gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
+gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
+gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
diff --git a/examples/rgw/golang/topic-creation/topic-creation.go b/examples/rgw/golang/topic-creation/topic-creation.go
new file mode 100644
index 000000000..128358f40
--- /dev/null
+++ b/examples/rgw/golang/topic-creation/topic-creation.go
@@ -0,0 +1,81 @@
+package main
+
+import (
+ "encoding/json"
+ "flag"
+ "fmt"
+ "os"
+
+ "github.com/aws/aws-sdk-go/aws"
+ "github.com/aws/aws-sdk-go/aws/credentials"
+ "github.com/aws/aws-sdk-go/aws/endpoints"
+ "github.com/aws/aws-sdk-go/aws/session"
+ "github.com/aws/aws-sdk-go/service/sns"
+)
+
+func main() {
+ topic := flag.String("t", "", "The name of the topic")
+ attributes := flag.String("a", "", "Topic attributes needed")
+ flag.Parse()
+
+ attributesmap := map[string]*string{}
+ err := json.Unmarshal([]byte(*attributes), &attributesmap) // convert JSON string to Go map
+ if err != nil {
+ exitErrorf("Check your JSON String for any errors: %s : %s", err, *attributes)
+ }
+
+ if *topic == "" {
+ fmt.Println("You must supply the name of the topic")
+ fmt.Println("-t TOPIC")
+ return
+ }
+
+ if *attributes == "" {
+ fmt.Println("You must supply topic attributes")
+ fmt.Println("-a ATTRIBUTES")
+ return
+ }
+ //Ceph RGW Cluster credentials
+ access_key := "0555b35654ad1656d804"
+ secret_key := "h7GhxuBLTrlhVUyxSPUKUV8r/2EI4ngqJxD7iBdBYLhwluN30JaT3Q=="
+ token_id := ""
+ url := "http://127.0.0.1:8000"
+
+ defaultResolver := endpoints.DefaultResolver()
+ snsCustResolverFn := func(service, region string, optFns ...func(*endpoints.Options)) (endpoints.ResolvedEndpoint, error) {
+ if service == "sns" {
+ return endpoints.ResolvedEndpoint{
+ URL: url,
+ }, nil
+ }
+
+ return defaultResolver.EndpointFor(service, region, optFns...)
+ }
+
+ sess := session.Must(session.NewSessionWithOptions(session.Options{
+ Config: aws.Config{
+ Region: aws.String("default"),
+ Credentials: credentials.NewStaticCredentials(access_key, secret_key, token_id),
+ S3ForcePathStyle: aws.Bool(true),
+ EndpointResolver: endpoints.ResolverFunc(snsCustResolverFn),
+ },
+ }))
+
+ client := sns.New(sess)
+
+ results, err := client.CreateTopic(&sns.CreateTopicInput{
+ Attributes: attributesmap,
+ Name: topic,
+ })
+
+ if err != nil {
+ exitErrorf("Unable to create topic %s, %s", *topic, err)
+ }
+
+ fmt.Printf("Succesfully created %s \n", *results.TopicArn)
+}
+
+func exitErrorf(msg string, args ...interface{}) {
+ fmt.Fprintf(os.Stderr, msg+"\n", args...)
+ os.Exit(1)
+}