forked from nitrictech/nitric
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Implement stubs for the s3 plugin.
- Loading branch information
Showing
1 changed file
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |