Skip to content

Commit

Permalink
chore: Implement stubs for the s3 plugin.
Browse files Browse the repository at this point in the history
  • Loading branch information
tjholm committed Dec 21, 2020
1 parent 4e634cc commit ba079cb
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions plugins/aws/storage/s3.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,46 @@
package main

import (
"fmt"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/s3"
"github.com/nitric-dev/membrane/plugins/sdk"
"github.com/nitric-dev/membrane/utils"
)

type S3Plugin struct {
sdk.UnimplementedStoragePlugin
client *s3.S3
}

func (s *S3Plugin) Put(bucket string, key string, object []byte) error {
return fmt.Errorf("UNIMPLEMENTED")
}

// Retrieve an item from a bucket
func (s *S3Plugin) Get(bucket string, key string) ([]byte, error) {
return nil, fmt.Errorf("UNIMPLEMENTED")
}

// Create new DynamoDB documents server
// XXX: No External Args for function atm (currently the plugin loader does not pass any argument information)
func New() (sdk.StoragePlugin, error) {
awsRegion := utils.GetEnv("AWS_REGION", "us-east-1")

sess, sessionError := session.NewSession(&aws.Config{
// FIXME: Use ENV configuration
Region: aws.String(awsRegion),
})

if sessionError != nil {
return nil, fmt.Errorf("Error creating new AWS session %v", sessionError)
}

s3Client := s3.New(sess)

return &S3Server{
client: s3Client,
}, nil
}

0 comments on commit ba079cb

Please sign in to comment.