Skip to content

Commit

Permalink
fix: rename filedropper to forwarder
Browse files Browse the repository at this point in the history
For documentation purposes this is much clearer as to what it does.
  • Loading branch information
jta committed Oct 3, 2023
1 parent 46559df commit 55f07ac
Show file tree
Hide file tree
Showing 14 changed files with 32 additions and 32 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,5 @@ build-App:
GOARCH=arm64 GOOS=linux go build -tags lambda.norpc -o ./bootstrap cmd/$(APP)/main.go
cp ./bootstrap $(ARTIFACTS_DIR)/.

build-FiledropperFunction:
APP=filedropper $(MAKE) build-App
build-Forwarder:
APP=forwarder $(MAKE) build-App
2 changes: 1 addition & 1 deletion apps/collection/template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ Resources:
Type: AWS::Serverless::Application
Properties:
Location:
ApplicationId: arn:aws:serverlessrepo:us-east-1:739672403694:applications/observe-filedropper
ApplicationId: arn:aws:serverlessrepo:us-east-1:739672403694:applications/observe-forwarder
SemanticVersion: 0.0.4
NotificationARNs:
- !Ref Topic
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Description: >
Metadata:
AWS::ServerlessRepo::Application:
Name: observe-filedropper
Name: observe-forwarder
Description: A hello world
Author: Observe Inc
SpdxLicenseId: Apache-2.0
Expand Down Expand Up @@ -49,7 +49,7 @@ Parameters:
DestinationUri:
Type: String
Description: >-
The S3 URI for your Filedrop, e.g. `s3://bucket-alias/ds101:secret/`
The S3 URI for your Filedrop, e.g. `s3://bucket-alias/ds101/`
SourceTopicArns:
Type: CommaDelimitedList
Description: A list of SNS topics.
Expand Down Expand Up @@ -195,7 +195,7 @@ Resources:
- - /aws/lambda/
- !Ref 'Name'
RetentionInDays: 365
FiledropperFunction:
Forwarder:
Type: AWS::Serverless::Function
Metadata:
BuildMethod: makefile
Expand Down Expand Up @@ -223,7 +223,7 @@ Resources:
Outputs:
Function:
Description: "Lambda Function ARN"
Value: !GetAtt FiledropperFunction.Arn
Value: !GetAtt Forwarder.Arn
Queue:
Description: "SQS Queue ARN"
Value: !GetAtt Queue.Arn
Expand Down
6 changes: 3 additions & 3 deletions cmd/filedropper/main.go → cmd/forwarder/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/go-logr/stdr"
"github.com/sethvargo/go-envconfig"

"github.com/observeinc/aws-sam-testing/handlers/filedropper"
"github.com/observeinc/aws-sam-testing/handlers/forwarder"
)

var env struct {
Expand All @@ -22,7 +22,7 @@ var env struct {
}

var logger logr.Logger
var handler *filedropper.Handler
var handler *forwarder.Handler

func init() {
if err := realInit(); err != nil {
Expand All @@ -49,7 +49,7 @@ func realInit() error {

s3client := s3.NewFromConfig(awsCfg)

handler, err = filedropper.New(&filedropper.Config{
handler, err = forwarder.New(&forwarder.Config{
DestinationURI: env.DestinationURI,
S3Client: s3client,
Logger: &logger,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package filedropper
package forwarder

import (
"errors"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
package filedropper_test
package forwarder_test

import (
"fmt"
"testing"

"github.com/observeinc/aws-sam-testing/handlers/filedropper"
"github.com/observeinc/aws-sam-testing/handlers/forwarder"

"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
)

func TestConfig(t *testing.T) {
testcases := []struct {
filedropper.Config
forwarder.Config
ExpectError error
}{
{
ExpectError: filedropper.ErrMissingS3Client,
ExpectError: forwarder.ErrMissingS3Client,
},
{
ExpectError: filedropper.ErrInvalidDestination,
ExpectError: forwarder.ErrInvalidDestination,
},
{
Config: filedropper.Config{
Config: forwarder.Config{
DestinationURI: "s3://test",
S3Client: &MockS3Client{},
},
},
{
Config: filedropper.Config{
Config: forwarder.Config{
DestinationURI: "https://example.com",
S3Client: &MockS3Client{},
},
ExpectError: filedropper.ErrInvalidDestination,
ExpectError: forwarder.ErrInvalidDestination,
},
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package filedropper
package forwarder

import (
"bytes"
Expand Down Expand Up @@ -55,7 +55,7 @@ func GetRecordInput(lctx *lambdacontext.LambdaContext, destination *url.URL, r i
return nil
}

key := strings.TrimLeft(fmt.Sprintf("%s/filedropper/%s/%s", strings.Trim(destination.Path, "/"), lctx.InvokedFunctionArn, lctx.AwsRequestID), "/")
key := strings.TrimLeft(fmt.Sprintf("%s/forwarder/%s/%s", strings.Trim(destination.Path, "/"), lctx.InvokedFunctionArn, lctx.AwsRequestID), "/")

return &s3.PutObjectInput{
Bucket: &destination.Host,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package filedropper_test
package forwarder_test

import (
"context"
Expand All @@ -17,7 +17,7 @@ import (
"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"

"github.com/observeinc/aws-sam-testing/handlers/filedropper"
"github.com/observeinc/aws-sam-testing/handlers/forwarder"
)

type MockS3Client struct {
Expand Down Expand Up @@ -99,7 +99,7 @@ func TestCopy(t *testing.T) {
t.Fatal(err)
}

got := filedropper.GetCopyObjectInput(s, d)
got := forwarder.GetCopyObjectInput(s, d)
if diff := cmp.Diff(got, tc.Expected, cmp.AllowUnexported(s3.CopyObjectInput{})); diff != "" {
t.Error("unexpected result", diff)
}
Expand All @@ -114,14 +114,14 @@ func TestHandler(t *testing.T) {

testcases := []struct {
RequestFile string
Config filedropper.Config
Config forwarder.Config
ExpectErr error
ExpectResponse events.SQSEventResponse
}{
{
// Failing a copy should fail the individual item in the queue affected
RequestFile: "testdata/event.json",
Config: filedropper.Config{
Config: forwarder.Config{
DestinationURI: "s3://my-bucket",
S3Client: &MockS3Client{
CopyObjectFunc: func(ctx context.Context, params *s3.CopyObjectInput, optFns ...func(*s3.Options)) (*s3.CopyObjectOutput, error) {
Expand All @@ -138,7 +138,7 @@ func TestHandler(t *testing.T) {
{
// Failing to put a record to the destination URI is a terminal condition. Error out.
RequestFile: "testdata/event.json",
Config: filedropper.Config{
Config: forwarder.Config{
DestinationURI: "s3://my-bucket",
S3Client: &MockS3Client{
PutObjectFunc: func(ctx context.Context, params *s3.PutObjectInput, optFns ...func(*s3.Options)) (*s3.PutObjectOutput, error) {
Expand Down Expand Up @@ -169,7 +169,7 @@ func TestHandler(t *testing.T) {
tc.Config.Logger = &logger
}

h, err := filedropper.New(&tc.Config)
h, err := forwarder.New(&tc.Config)
if err != nil {
t.Fatal(err)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package filedropper
package forwarder

import (
"encoding/json"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package filedropper_test
package forwarder_test

import (
"encoding/json"
"fmt"
"testing"

"github.com/observeinc/aws-sam-testing/handlers/filedropper"
"github.com/observeinc/aws-sam-testing/handlers/forwarder"

"github.com/google/go-cmp/cmp"
)
Expand Down Expand Up @@ -67,7 +67,7 @@ func TestObjectCreated(t *testing.T) {
tc := tc
t.Run(fmt.Sprintf("%d", i), func(t *testing.T) {
t.Parallel()
var message filedropper.SQSMessage
var message forwarder.SQSMessage
if err := json.Unmarshal([]byte(tc.Message), &message); err != nil {
t.Fatal(err)
}
Expand Down
File renamed without changes.

0 comments on commit 55f07ac

Please sign in to comment.