From dc22b9c3db5efd6f3ce97bef670d511e483052ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Miguel=20Cust=C3=B3dio?= Date: Thu, 17 Oct 2019 08:29:35 +0100 Subject: [PATCH] Add opt-in support for using Go modules. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Bruno Miguel Custódio --- template/golang-http-armhf/Dockerfile | 15 +++++++---- template/golang-http-armhf/Gopkg.lock | 15 ----------- template/golang-http-armhf/go.mod | 7 +++++ template/golang-http-armhf/go.sum | 2 ++ .../go-function-sdk/LICENSE | 21 +++++++++++++++ .../go-function-sdk/README.md | 2 ++ template/golang-http-armhf/vendor/modules.txt | 2 ++ template/golang-http/Dockerfile | 14 +++++++--- template/golang-http/Gopkg.lock | 15 ----------- template/golang-http/Gopkg.toml | 26 ------------------- template/golang-http/go.mod | 7 +++++ template/golang-http/go.sum | 2 ++ .../go-function-sdk/LICENSE | 21 +++++++++++++++ .../go-function-sdk/README.md | 2 ++ template/golang-http/vendor/modules.txt | 2 ++ template/golang-middleware-armhf/Dockerfile | 16 +++++++----- template/golang-middleware-armhf/go.mod | 5 ++++ template/golang-middleware/Dockerfile | 14 ++++++---- template/golang-middleware/go.mod | 5 ++++ 19 files changed, 116 insertions(+), 77 deletions(-) delete mode 100644 template/golang-http-armhf/Gopkg.lock create mode 100644 template/golang-http-armhf/go.mod create mode 100644 template/golang-http-armhf/go.sum create mode 100644 template/golang-http-armhf/vendor/github.com/openfaas-incubator/go-function-sdk/LICENSE create mode 100644 template/golang-http-armhf/vendor/github.com/openfaas-incubator/go-function-sdk/README.md create mode 100644 template/golang-http-armhf/vendor/modules.txt delete mode 100644 template/golang-http/Gopkg.lock delete mode 100644 template/golang-http/Gopkg.toml create mode 100644 template/golang-http/go.mod create mode 100644 template/golang-http/go.sum create mode 100644 template/golang-http/vendor/github.com/openfaas-incubator/go-function-sdk/LICENSE create mode 100644 template/golang-http/vendor/github.com/openfaas-incubator/go-function-sdk/README.md create mode 100644 template/golang-http/vendor/modules.txt create mode 100644 template/golang-middleware-armhf/go.mod create mode 100644 template/golang-middleware/go.mod diff --git a/template/golang-http-armhf/Dockerfile b/template/golang-http-armhf/Dockerfile index 5309dbb..31fc66e 100644 --- a/template/golang-http-armhf/Dockerfile +++ b/template/golang-http-armhf/Dockerfile @@ -1,12 +1,15 @@ FROM openfaas/of-watchdog:0.7.2 as watchdog -FROM golang:1.11-alpine3.10 as build -ENV CGO_ENABLED=0 +FROM golang:1.13.1-alpine3.10 as build + +RUN apk --no-cache add git COPY --from=watchdog /fwatchdog /usr/bin/fwatchdog RUN chmod +x /usr/bin/fwatchdog +ENV CGO_ENABLED=0 + RUN mkdir -p /go/src/handler WORKDIR /go/src/handler COPY . . @@ -14,9 +17,11 @@ COPY . . # Run a gofmt and exclude all vendored code. RUN test -z "$(gofmt -l $(find . -type f -name '*.go' -not -path "./vendor/*" -not -path "./function/vendor/*"))" || { echo "Run \"gofmt -s -w\" on your Golang code"; exit 1; } -RUN CGO_ENABLED=0 GOOS=linux \ - go build --ldflags "-s -w" -a -installsuffix cgo -o handler . && \ - go test $(go list ./... | grep -v /vendor/) -cover +ARG GO111MODULE="off" +ARG GOPROXY="" + +RUN go build --ldflags "-s -w" -a -installsuffix cgo -o handler . +RUN go test handler/function/... -cover FROM alpine:3.10 # Add non root user and certs diff --git a/template/golang-http-armhf/Gopkg.lock b/template/golang-http-armhf/Gopkg.lock deleted file mode 100644 index 6cb65da..0000000 --- a/template/golang-http-armhf/Gopkg.lock +++ /dev/null @@ -1,15 +0,0 @@ -# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'. - - -[[projects]] - name = "github.com/openfaas-incubator/go-function-sdk" - packages = ["."] - revision = "cac4b8744921c3935ace0551f3d1240eaac69c7a" - version = "1.0.0" - -[solve-meta] - analyzer-name = "dep" - analyzer-version = 1 - inputs-digest = "e1451470edcf08c0746ab26143a4518315a3698e96c6dbc8671b7cfd3ec5b714" - solver-name = "gps-cdcl" - solver-version = 1 diff --git a/template/golang-http-armhf/go.mod b/template/golang-http-armhf/go.mod new file mode 100644 index 0000000..d5be9bf --- /dev/null +++ b/template/golang-http-armhf/go.mod @@ -0,0 +1,7 @@ +module handler + +go 1.12 + +replace handler/function => ./function + +require github.com/openfaas-incubator/go-function-sdk v0.0.0-20181217173454-cac4b8744921 diff --git a/template/golang-http-armhf/go.sum b/template/golang-http-armhf/go.sum new file mode 100644 index 0000000..94e3413 --- /dev/null +++ b/template/golang-http-armhf/go.sum @@ -0,0 +1,2 @@ +github.com/openfaas-incubator/go-function-sdk v0.0.0-20181217173454-cac4b8744921 h1:IGP0tlTdv6r/zy3Kw61EhiXao61krCUs5KRHWSzCdxM= +github.com/openfaas-incubator/go-function-sdk v0.0.0-20181217173454-cac4b8744921/go.mod h1:F37Kp+hwdHP+o3UKjkGzikQg4weKiMvcegT9vCQjvjE= diff --git a/template/golang-http-armhf/vendor/github.com/openfaas-incubator/go-function-sdk/LICENSE b/template/golang-http-armhf/vendor/github.com/openfaas-incubator/go-function-sdk/LICENSE new file mode 100644 index 0000000..8d01a43 --- /dev/null +++ b/template/golang-http-armhf/vendor/github.com/openfaas-incubator/go-function-sdk/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2018 Alex Ellis + +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: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/template/golang-http-armhf/vendor/github.com/openfaas-incubator/go-function-sdk/README.md b/template/golang-http-armhf/vendor/github.com/openfaas-incubator/go-function-sdk/README.md new file mode 100644 index 0000000..9f571c1 --- /dev/null +++ b/template/golang-http-armhf/vendor/github.com/openfaas-incubator/go-function-sdk/README.md @@ -0,0 +1,2 @@ +# go-function-sdk +An SDK for building functions in Go diff --git a/template/golang-http-armhf/vendor/modules.txt b/template/golang-http-armhf/vendor/modules.txt new file mode 100644 index 0000000..3e695a2 --- /dev/null +++ b/template/golang-http-armhf/vendor/modules.txt @@ -0,0 +1,2 @@ +# github.com/openfaas-incubator/go-function-sdk v0.0.0-20181217173454-cac4b8744921 +github.com/openfaas-incubator/go-function-sdk diff --git a/template/golang-http/Dockerfile b/template/golang-http/Dockerfile index a1e0e17..8ffc5ae 100644 --- a/template/golang-http/Dockerfile +++ b/template/golang-http/Dockerfile @@ -1,12 +1,16 @@ FROM openfaas/of-watchdog:0.7.2 as watchdog -FROM golang:1.10.4-alpine3.8 as build +FROM golang:1.13.1-alpine3.10 as build + +RUN apk --no-cache add git ENV CGO_ENABLED=0 COPY --from=watchdog /fwatchdog /usr/bin/fwatchdog RUN chmod +x /usr/bin/fwatchdog +ENV CGO_ENABLED=0 + RUN mkdir -p /go/src/handler WORKDIR /go/src/handler COPY . . @@ -14,9 +18,11 @@ COPY . . # Run a gofmt and exclude all vendored code. RUN test -z "$(gofmt -l $(find . -type f -name '*.go' -not -path "./vendor/*" -not -path "./function/vendor/*"))" || { echo "Run \"gofmt -s -w\" on your Golang code"; exit 1; } -RUN CGO_ENABLED=0 GOOS=linux \ - go build --ldflags "-s -w" -a -installsuffix cgo -o handler . && \ - go test $(go list ./... | grep -v /vendor/) -cover +ARG GO111MODULE="off" +ARG GOPROXY="" + +RUN go build --ldflags "-s -w" -a -installsuffix cgo -o handler . +RUN go test handler/function/... -cover FROM alpine:3.10 # Add non root user and certs diff --git a/template/golang-http/Gopkg.lock b/template/golang-http/Gopkg.lock deleted file mode 100644 index 6cb65da..0000000 --- a/template/golang-http/Gopkg.lock +++ /dev/null @@ -1,15 +0,0 @@ -# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'. - - -[[projects]] - name = "github.com/openfaas-incubator/go-function-sdk" - packages = ["."] - revision = "cac4b8744921c3935ace0551f3d1240eaac69c7a" - version = "1.0.0" - -[solve-meta] - analyzer-name = "dep" - analyzer-version = 1 - inputs-digest = "e1451470edcf08c0746ab26143a4518315a3698e96c6dbc8671b7cfd3ec5b714" - solver-name = "gps-cdcl" - solver-version = 1 diff --git a/template/golang-http/Gopkg.toml b/template/golang-http/Gopkg.toml deleted file mode 100644 index eb6edae..0000000 --- a/template/golang-http/Gopkg.toml +++ /dev/null @@ -1,26 +0,0 @@ - -# Gopkg.toml example -# -# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md -# for detailed Gopkg.toml documentation. -# -# required = ["github.com/user/thing/cmd/thing"] -# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"] -# -# [[constraint]] -# name = "github.com/user/project" -# version = "1.0.0" -# -# [[constraint]] -# name = "github.com/user/project2" -# branch = "dev" -# source = "github.com/myfork/project2" -# -# [[override]] -# name = "github.com/x/y" -# version = "2.4.0" - - -[[constraint]] - branch = "master" - name = "github.com/openfaas-incubator/go-function-sdk" diff --git a/template/golang-http/go.mod b/template/golang-http/go.mod new file mode 100644 index 0000000..d5be9bf --- /dev/null +++ b/template/golang-http/go.mod @@ -0,0 +1,7 @@ +module handler + +go 1.12 + +replace handler/function => ./function + +require github.com/openfaas-incubator/go-function-sdk v0.0.0-20181217173454-cac4b8744921 diff --git a/template/golang-http/go.sum b/template/golang-http/go.sum new file mode 100644 index 0000000..94e3413 --- /dev/null +++ b/template/golang-http/go.sum @@ -0,0 +1,2 @@ +github.com/openfaas-incubator/go-function-sdk v0.0.0-20181217173454-cac4b8744921 h1:IGP0tlTdv6r/zy3Kw61EhiXao61krCUs5KRHWSzCdxM= +github.com/openfaas-incubator/go-function-sdk v0.0.0-20181217173454-cac4b8744921/go.mod h1:F37Kp+hwdHP+o3UKjkGzikQg4weKiMvcegT9vCQjvjE= diff --git a/template/golang-http/vendor/github.com/openfaas-incubator/go-function-sdk/LICENSE b/template/golang-http/vendor/github.com/openfaas-incubator/go-function-sdk/LICENSE new file mode 100644 index 0000000..8d01a43 --- /dev/null +++ b/template/golang-http/vendor/github.com/openfaas-incubator/go-function-sdk/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2018 Alex Ellis + +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: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/template/golang-http/vendor/github.com/openfaas-incubator/go-function-sdk/README.md b/template/golang-http/vendor/github.com/openfaas-incubator/go-function-sdk/README.md new file mode 100644 index 0000000..9f571c1 --- /dev/null +++ b/template/golang-http/vendor/github.com/openfaas-incubator/go-function-sdk/README.md @@ -0,0 +1,2 @@ +# go-function-sdk +An SDK for building functions in Go diff --git a/template/golang-http/vendor/modules.txt b/template/golang-http/vendor/modules.txt new file mode 100644 index 0000000..3e695a2 --- /dev/null +++ b/template/golang-http/vendor/modules.txt @@ -0,0 +1,2 @@ +# github.com/openfaas-incubator/go-function-sdk v0.0.0-20181217173454-cac4b8744921 +github.com/openfaas-incubator/go-function-sdk diff --git a/template/golang-middleware-armhf/Dockerfile b/template/golang-middleware-armhf/Dockerfile index eb25dc0..1d3143d 100644 --- a/template/golang-middleware-armhf/Dockerfile +++ b/template/golang-middleware-armhf/Dockerfile @@ -1,13 +1,13 @@ FROM openfaas/of-watchdog:0.7.2 as watchdog +FROM golang:1.13.1-alpine3.10 as build - -FROM golang:1.11-alpine3.10 as build - -ENV CGO_ENABLED=0 +RUN apk --no-cache add git COPY --from=watchdog /fwatchdog /usr/bin/fwatchdog RUN chmod +x /usr/bin/fwatchdog +ENV CGO_ENABLED=0 + RUN mkdir -p /go/src/handler WORKDIR /go/src/handler COPY . . @@ -15,9 +15,11 @@ COPY . . # Run a gofmt and exclude all vendored code. RUN test -z "$(gofmt -l $(find . -type f -name '*.go' -not -path "./vendor/*" -not -path "./function/vendor/*"))" || { echo "Run \"gofmt -s -w\" on your Golang code"; exit 1; } -RUN CGO_ENABLED=0 GOOS=linux \ - go build --ldflags "-s -w" -a -installsuffix cgo -o handler . && \ - go test $(go list ./... | grep -v /vendor/) -cover +ARG GO111MODULE="off" +ARG GOPROXY="" + +RUN go build --ldflags "-s -w" -a -installsuffix cgo -o handler . +RUN go test handler/function/... -cover FROM alpine:3.10 # Add non root user and certs diff --git a/template/golang-middleware-armhf/go.mod b/template/golang-middleware-armhf/go.mod new file mode 100644 index 0000000..c56895b --- /dev/null +++ b/template/golang-middleware-armhf/go.mod @@ -0,0 +1,5 @@ +module handler + +go 1.12 + +replace handler/function => ./function diff --git a/template/golang-middleware/Dockerfile b/template/golang-middleware/Dockerfile index 5309dbb..2e61107 100644 --- a/template/golang-middleware/Dockerfile +++ b/template/golang-middleware/Dockerfile @@ -1,12 +1,14 @@ FROM openfaas/of-watchdog:0.7.2 as watchdog -FROM golang:1.11-alpine3.10 as build +FROM golang:1.13.1-alpine3.10 as build -ENV CGO_ENABLED=0 +RUN apk --no-cache add git COPY --from=watchdog /fwatchdog /usr/bin/fwatchdog RUN chmod +x /usr/bin/fwatchdog +ENV CGO_ENABLED=0 + RUN mkdir -p /go/src/handler WORKDIR /go/src/handler COPY . . @@ -14,9 +16,11 @@ COPY . . # Run a gofmt and exclude all vendored code. RUN test -z "$(gofmt -l $(find . -type f -name '*.go' -not -path "./vendor/*" -not -path "./function/vendor/*"))" || { echo "Run \"gofmt -s -w\" on your Golang code"; exit 1; } -RUN CGO_ENABLED=0 GOOS=linux \ - go build --ldflags "-s -w" -a -installsuffix cgo -o handler . && \ - go test $(go list ./... | grep -v /vendor/) -cover +ARG GO111MODULE="off" +ARG GOPROXY="" + +RUN go build --ldflags "-s -w" -a -installsuffix cgo -o handler . +RUN go test handler/function/... -cover FROM alpine:3.10 # Add non root user and certs diff --git a/template/golang-middleware/go.mod b/template/golang-middleware/go.mod new file mode 100644 index 0000000..c56895b --- /dev/null +++ b/template/golang-middleware/go.mod @@ -0,0 +1,5 @@ +module handler + +go 1.12 + +replace handler/function => ./function