Skip to content

Commit

Permalink
Add Makefile and re-format code
Browse files Browse the repository at this point in the history
  • Loading branch information
p4tin committed Jan 20, 2018
1 parent 0b96b58 commit c25b95e
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 11 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@ goaws
goaws_linux_amd64

*.log

setenv.sh


8 changes: 4 additions & 4 deletions app/gosqs/message_attributes.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package gosqs

import (
"fmt"
"crypto/md5"
"encoding/base64"
"encoding/binary"
"encoding/hex"
"fmt"
"hash"
"net/http"
"sort"
Expand All @@ -15,19 +15,19 @@ import (

type MessageAttributeValue struct {
dataType string
value string
value string
valueKey string
}

func extractMessageAttributes(req *http.Request) map[string]MessageAttributeValue {
attributes := make(map[string]MessageAttributeValue)

for i := 1; true; i++ {
for i := 1; true; i++ {
name := req.FormValue(fmt.Sprintf("MessageAttribute.%d.Name", i))
if name == "" {
break
}

dataType := req.FormValue(fmt.Sprintf("MessageAttribute.%d.Value.DataType", i))
if dataType == "" {
log.Warnf("DataType of MessageAttribute %s is missing, MD5 checksum will most probably be wrong!\n", name)
Expand Down
12 changes: 6 additions & 6 deletions app/servertest/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,21 +43,21 @@ func TestNewIntegration(t *testing.T) {
attributes := make(map[string]*sqs.MessageAttributeValue)
attributes["some string"] = &sqs.MessageAttributeValue{
StringValue: aws.String("string value with a special character \u2318"),
DataType: aws.String("String"),
DataType: aws.String("String"),
}
attributes["some number"] = &sqs.MessageAttributeValue{
StringValue: aws.String("123"),
DataType: aws.String("Number"),
DataType: aws.String("Number"),
}
attributes["some binary"] = &sqs.MessageAttributeValue{
BinaryValue: []byte{1,2,3},
DataType: aws.String("Binary"),
BinaryValue: []byte{1, 2, 3},
DataType: aws.String("Binary"),
}

response, err := svc.SendMessage(&sqs.SendMessageInput{
MessageBody: aws.String("hello world"),
MessageBody: aws.String("hello world"),
MessageAttributes: attributes,
QueueUrl: queueURL,
QueueUrl: queueURL,
})

assert.Equal(t, "5eb63bbbe01eeed093cb22bb8f5acdc3", *response.MD5OfMessageBody)
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: '2'
services:
goaws:
container_name: goaws
image: pafortin/goaws:1.0.0
image: pafortin/goaws
ports:
- 4100:4100
volumes:
Expand Down
28 changes: 28 additions & 0 deletions makefile.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
.DEFAULT_GOAL := run
VERSION=1.0.2
GITHUB_API_KEY = ${GITHUBB_API_KEY}
APIJSON='{"tag_name": "$(VERSION)","target_commitish": "master","name": "$(VERSION)","body": "Release of version $(VERSION)","draft": true,"prerelease": true}'

dep:
dep ensure

fmt:
go fmt ./app/...

test:
go test ./app/...

run: dep fmt test
go run app/cmd/goaws.go

git-release:
curl --data $(APIJSON) https://api.github.com/repos/p4tin/goaws/releases?access_token=$(GITHUB_API_KEY)

linux:
GOOS=linux GOARCH=arm GOARM=5 go build -o goaws_linux_amd64 app/cmd/goaws.go

docker-release: linux
docker build -t pafortin/goaws .
docker tag pafortin/goaws pafortin/goaws:$(VERSION)


0 comments on commit c25b95e

Please sign in to comment.