Skip to content

Commit

Permalink
Upgrades
Browse files Browse the repository at this point in the history
* Upgrade to latest version of connector-sdk
* Add build, push and travis files (Copied from kafka-connector)
  • Loading branch information
chriskolenko authored and alexellis committed Jul 8, 2019
1 parent ea5afc9 commit 5fa718d
Show file tree
Hide file tree
Showing 53 changed files with 6,200 additions and 197 deletions.
1 change: 1 addition & 0 deletions .DEREK.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
redirect: https://raw.githubusercontent.com/openfaas/faas/master/.DEREK.yml
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
nats-connector
.ash_history
connector
nats-connector
32 changes: 32 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
sudo: required

language: go

go:
- "1.10.x"

services:
- docker

addons:
apt:
packages:
- docker-ce

script:
- make build

after_success:
- if [ -z $DOCKER_NS ] ; then
export DOCKER_NS=openfaas;
fi

- if [ ! -z "$TRAVIS_TAG" ] ; then
docker tag $DOCKER_NS/nats-connector:latest-dev $DOCKER_NS/nats-connector:$TRAVIS_TAG;
echo $DOCKER_PASSWORD | docker login -u=$DOCKER_USERNAME --password-stdin;
docker push $DOCKER_NS/nats-connector:$TRAVIS_TAG;

docker tag $DOCKER_NS/nats-connector:latest-dev quay.io/$DOCKER_NS/nats-connector:$TRAVIS_TAG;
echo $QUAY_PASSWORD | docker login -u=$QUAY_USERNAME --password-stdin quay.io;
docker push quay.io/$DOCKER_NS/nats-connector:$TRAVIS_TAG;
fi
15 changes: 10 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
FROM golang:1.9.2
FROM golang:1.10 as build

RUN mkdir -p /go/src/github.com/openfaas-incubator/nats-connector
WORKDIR /go/src/github.com/openfaas-incubator/nats-connector

COPY vendor vendor
COPY config config
COPY nats nats
COPY main.go .

# Run a gofmt and exclude all vendored code.
Expand All @@ -13,6 +12,12 @@ RUN test -z "$(gofmt -l $(find . -type f -name '*.go' -not -path "./vendor/*"))"
RUN go test -v ./...

# Stripping via -ldflags "-s -w"
RUN CGO_ENABLED=0 GOOS=linux go build -a -ldflags "-s -w" -installsuffix cgo -o ./connector
RUN CGO_ENABLED=0 GOOS=linux go build -a -ldflags "-s -w" -installsuffix cgo -o /usr/bin/producer

FROM alpine:3.9 as ship
RUN apk add --no-cache ca-certificates

COPY --from=build /usr/bin/producer /usr/bin/producer
WORKDIR /root/

CMD ["./connector"]
CMD ["/usr/bin/producer"]
16 changes: 16 additions & 0 deletions Dockerfile.armhf
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM golang:1.10
RUN mkdir -p /go/src/github.com/openfaas-incubator/nats-connector
WORKDIR /go/src/github.com/openfaas-incubator/nats-connector

COPY vendor vendor
COPY main.go .

# Run a gofmt and exclude all vendored code.
RUN test -z "$(gofmt -l $(find . -type f -name '*.go' -not -path "./vendor/*"))"

RUN go test -v ./...

# Stripping via -ldflags "-s -w"
RUN GOARM=7 CGO_ENABLED=0 GOOS=linux go build -a -ldflags "-s -w" -installsuffix cgo -o ./connector

CMD ["./connector"]
15 changes: 15 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
TAG?=latest-dev
NAMESPACE?=openfaas
.PHONY: build

build:
./build.sh $(TAG)

ci-armhf-build:
./build.sh $(TAG)

ci-armhf-push:
./build.sh $(TAG)

push:
./push.sh $(TAG)
25 changes: 25 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/sh
set -e

export dockerfile="Dockerfile"
export arch=$(uname -m)
export TAG="latest"

if [ "$arch" = "armv7l" ]; then
dockerfile="Dockerfile.armhf"
TAG="latest-armhf-dev"
fi

if [ "$1" ]; then
TAG=$1
if [ "$arch" = "armv7l" ]; then
TAG="$1-armhf"
fi
fi

if [ -z "$NAMESPACE" ]; then
NAMESPACE="openfaas"
fi

docker build -t $NAMESPACE/nats-connector:$TAG . -f $dockerfile --no-cache
#(cd yaml && docker service rm nats_connector ; docker stack deploy nats -c connector-swarm.yml)
9 changes: 7 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
module github.com/openfaas-incubator/nats-connector

require (
github.com/nats-io/go-nats v1.6.0
github.com/golang/protobuf v1.3.1 // indirect
github.com/nats-io/gnatsd v1.4.1 // indirect
github.com/nats-io/go-nats v1.7.2
github.com/nats-io/nkeys v0.0.2 // indirect
github.com/nats-io/nuid v1.0.0 // indirect
github.com/openfaas-incubator/connector-sdk v0.0.0-20181118154933-2db120a2ec4b
github.com/openfaas-incubator/connector-sdk v0.0.0-20190611163053-d4baf95d4c62
github.com/openfaas/faas v0.0.0-20181122165013-495cf9e7aff0 // indirect
github.com/openfaas/faas-provider v0.0.0-20181104131730-8b3147b013c6 // indirect
github.com/pkg/errors v0.8.1 // indirect
golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb // indirect
)
20 changes: 16 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
github.com/nats-io/go-nats v1.6.0 h1:FznPwMfrVwGnSCh7JTXyJDRW0TIkD4Tr+M1LPJt9T70=
github.com/nats-io/go-nats v1.6.0/go.mod h1:+t7RHT5ApZebkrQdnn6AhQJmhJJiKAvJUio1PiiCtj0=
github.com/golang/protobuf v1.3.1 h1:YF8+flBXS5eO826T4nzqPrxfhQThhXl0YzfuUPu4SBg=
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/nats-io/gnatsd v1.4.1 h1:RconcfDeWpKCD6QIIwiVFcvForlXpWeJP7i5/lDLy44=
github.com/nats-io/gnatsd v1.4.1/go.mod h1:nqco77VO78hLCJpIcVfygDP2rPGfsEHkGTUk94uh5DQ=
github.com/nats-io/go-nats v1.7.2 h1:cJujlwCYR8iMz5ofZSD/p2WLW8FabhkQ2lIEVbSvNSA=
github.com/nats-io/go-nats v1.7.2/go.mod h1:+t7RHT5ApZebkrQdnn6AhQJmhJJiKAvJUio1PiiCtj0=
github.com/nats-io/nkeys v0.0.2 h1:+qM7QpgXnvDDixitZtQUBDY9w/s9mu1ghS+JIbsrx6M=
github.com/nats-io/nkeys v0.0.2/go.mod h1:dab7URMsZm6Z/jp9Z5UGa87Uutgc2mVpXLC4B7TDb/4=
github.com/nats-io/nuid v1.0.0 h1:44QGdhbiANq8ZCbUkdn6W5bqtg+mHuDE4wOUuxxndFs=
github.com/nats-io/nuid v1.0.0/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c=
github.com/openfaas-incubator/connector-sdk v0.0.0-20181118154933-2db120a2ec4b h1:XRljIkAJNgYWzx5py2w/fRHPVuRS0/5kSXSlPTT/Evw=
github.com/openfaas-incubator/connector-sdk v0.0.0-20181118154933-2db120a2ec4b/go.mod h1:jHCtd1HCZwhuwdPy4OB8CQU7ZqzxBdWNhIhH/khCJqQ=
github.com/openfaas-incubator/connector-sdk v0.0.0-20190611163053-d4baf95d4c62 h1:NoF7kLOXQIeKRTbqa6ZOG8u+e5Ptng7aSA+R33BFKl0=
github.com/openfaas-incubator/connector-sdk v0.0.0-20190611163053-d4baf95d4c62/go.mod h1:jHCtd1HCZwhuwdPy4OB8CQU7ZqzxBdWNhIhH/khCJqQ=
github.com/openfaas/faas v0.0.0-20181122165013-495cf9e7aff0 h1:4+fM0yvoGK5uhdI3kKLzJ8bZTmcyss2FAU6hfpEXh84=
github.com/openfaas/faas v0.0.0-20181122165013-495cf9e7aff0/go.mod h1:E0m2rLup0Vvxg53BKxGgaYAGcZa3Xl+vvL7vSi5yQ14=
github.com/openfaas/faas-provider v0.0.0-20181104131730-8b3147b013c6 h1:PGmPk5iR8IY2Gl4SlMd2+o4sUmeEFBGFy0SmJoxSIlU=
github.com/openfaas/faas-provider v0.0.0-20181104131730-8b3147b013c6/go.mod h1:W4OIp33RUOpR7wW+omJB/7GhIydRmYXvKf/VqUKI4yM=
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9 h1:mKdxBk7AujPs8kU4m80U72y/zjbZ3UcXC7dClwKbUI0=
golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb h1:fgwFCsaw9buMuxNd6+DQfAuSFqbNiQZpcgJQAgJsK6k=
golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
8 changes: 8 additions & 0 deletions push.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh
set -e

if [ -z "$NAMESPACE" ]; then
NAMESPACE="openfaas"
fi

docker push $NAMESPACE/nats-connector:$TAG
8 changes: 4 additions & 4 deletions vendor/github.com/nats-io/go-nats/.travis.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 44 additions & 1 deletion vendor/github.com/nats-io/go-nats/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

69 changes: 63 additions & 6 deletions vendor/github.com/nats-io/go-nats/context.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 5fa718d

Please sign in to comment.