Skip to content

Commit 38a865d

Browse files
committed
Migrate to Go modules and Go 1.13
Signed-off-by: Alex Ellis (OpenFaaS Ltd) <[email protected]>
1 parent 14776ab commit 38a865d

File tree

18 files changed

+117
-181
lines changed

18 files changed

+117
-181
lines changed

.vscode/launch.json

Lines changed: 0 additions & 21 deletions
This file was deleted.

.vscode/settings.json

Lines changed: 0 additions & 3 deletions
This file was deleted.

.vscode/tasks.json

Lines changed: 0 additions & 32 deletions
This file was deleted.

Dockerfile

Lines changed: 43 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,55 @@
1-
FROM golang:1.11
1+
FROM teamserverless/license-check:0.3.9 as license-check
22

3-
RUN mkdir -p /go/src/github.com/openfaas-incubator/cron-connector/
3+
FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.13 as build
44

5-
WORKDIR /go/src/github.com/openfaas-incubator/cron-connector
5+
ARG TARGETPLATFORM
6+
ARG BUILDPLATFORM
7+
ARG TARGETOS
8+
ARG TARGETARCH
69

10+
ENV CGO_ENABLED=0
11+
ENV GO111MODULE=on
12+
ENV GOFLAGS=-mod=vendor
13+
14+
COPY --from=license-check /license-check /usr/bin/
15+
16+
WORKDIR /go/src/github.com/openfaas/cron-connector
717
COPY . .
818

9-
ARG OPTS
19+
RUN license-check -path /go/src/github.com/openfaas/cron-connector/ --verbose=false "Alex Ellis" "OpenFaaS Author(s)"
20+
RUN gofmt -l -d $(find . -type f -name '*.go' -not -path "./vendor/*")
21+
RUN CGO_ENABLED=${CGO_ENABLED} GOOS=${TARGETOS} GOARCH=${TARGETARCH} go test -v ./...
22+
23+
RUN VERSION=$(git describe --all --exact-match `git rev-parse HEAD` | grep tags | sed 's/tags\///') \
24+
&& GIT_COMMIT=$(git rev-list -1 HEAD) \
25+
&& GOOS=${TARGETOS} GOARCH=${TARGETARCH} CGO_ENABLED=${CGO_ENABLED} go build \
26+
--ldflags "-s -w \
27+
-X github.com/openfaas/cron-connector/version.GitCommit=${GIT_COMMIT}\
28+
-X github.com/openfaas/cron-connector/version.Version=${VERSION}" \
29+
-a -installsuffix cgo -o cron-connector .
30+
31+
FROM --platform=${TARGETPLATFORM:-linux/amd64} alpine:3.12 as ship
32+
LABEL org.label-schema.license="MIT" \
33+
org.label-schema.vcs-url="https://github.com/openfaas/cron-connector" \
34+
org.label-schema.vcs-type="Git" \
35+
org.label-schema.name="openfaas/cron-connector" \
36+
org.label-schema.vendor="openfaas" \
37+
org.label-schema.docker.schema-version="1.0"
38+
39+
RUN apk --no-cache add \
40+
ca-certificates
1041

11-
RUN gofmt -l -d $(find . -type f -name '*.go' -not -path "./vendor/*") && \
12-
go test -v ./ && \
13-
VERSION=$(git describe --all --exact-match `git rev-parse HEAD` | grep tags | sed 's/tags\///') && \
14-
GIT_COMMIT=$(git rev-list -1 HEAD) && \
15-
env ${OPTS} CGO_ENABLED=0 GOOS=linux go build -ldflags "-s -w \
16-
-X github.com/openfaas-incubator/cron-connector/pkg/version.Release=${VERSION} \
17-
-X github.com/openfaas-incubator/cron-connector/pkg/version.SHA=${GIT_COMMIT}" \
18-
-a -installsuffix cgo -o cron-connector . && \
19-
addgroup --system app && \
20-
adduser --system --ingroup app app && \
21-
mkdir /scratch-tmp
42+
RUN addgroup -S app \
43+
&& adduser -S -g app app
2244

23-
# we can't add user in next stage because it's from scratch
24-
# ca-certificates and tmp folder are also missing in scratch
25-
# so we add all of it here and copy files in next stage
45+
WORKDIR /home/app
2646

27-
FROM scratch
47+
ENV http_proxy ""
48+
ENV https_proxy ""
2849

29-
COPY --from=0 /etc/passwd /etc/group /etc/
30-
COPY --from=0 /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
31-
COPY --from=0 --chown=app:app /scratch-tmp /tmp/
32-
COPY --from=0 /go/src/github.com/openfaas-incubator/cron-connector/cron-connector .
50+
COPY --from=build /go/src/github.com/openfaas/cron-connector/cron-connector .
51+
RUN chown -R app:app ./
3352

3453
USER app
3554

36-
ENTRYPOINT ["./cron-connector"]
55+
CMD ["./cron-connector"]

Gopkg.lock

Lines changed: 0 additions & 54 deletions
This file was deleted.

Gopkg.toml

Lines changed: 0 additions & 34 deletions
This file was deleted.

LICENSE

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
Copyright 2019 Rishabh Gupta
2-
Copyright 2019 OpenFaaS Author(s)
1+
Copyright 2020 OpenFaaS Author(s)
32

43
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
54

Makefile

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,3 @@ manifest:
2626

2727
test:
2828
go test ./...
29-
30-
verify-codegen:
31-
./hack/verify-codegen.sh

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
This is a cron event connector for OpenFaaS. This was built to provide a timer interface to trigger OpenFaaS functions. Also checkout [OpenFaaS docs on cron](https://docs.openfaas.com/reference/cron/) for other methods on how you can run functions triggered by cron.
44

5-
This project was forked from [zeerorg/cron-connector](https://github.com/openfaas-incubator/cron-connector) to enable prompt updates and patches for end-users.
5+
This project was forked from [zeerorg/cron-connector](https://github.com/openfaas/cron-connector) to enable prompt updates and patches for end-users.
66

77
## How to Use
88

go.mod

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
module github.com/openfaas/cron-connector
2+
3+
go 1.13
4+
5+
require (
6+
github.com/ewilde/faas-federation v0.0.0-20200206161705-23d8f6d639f1 // indirect
7+
github.com/openfaas-incubator/connector-sdk v0.0.0-20190125151851-d722c9f72ad0
8+
github.com/openfaas/faas v0.0.0-20190104165101-a65df4795bc6
9+
github.com/openfaas/faas-provider v0.0.0-20181216160432-220324e98f5d // indirect
10+
github.com/pkg/errors v0.8.1
11+
gopkg.in/robfig/cron.v2 v2.0.0-20150107220207-be2e0b0deed5
12+
)

0 commit comments

Comments
 (0)