diff --git a/gateway/Dockerfile b/gateway/Dockerfile index a6241dd4..97c48ff6 100644 --- a/gateway/Dockerfile +++ b/gateway/Dockerfile @@ -13,9 +13,12 @@ COPY queue queue COPY plugin plugin COPY server.go . -RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o gateway . +# Run a gofmt and exclude all vendored code. +RUN test -z "$(gofmt -l $(find . -type f -name '*.go' -not -path "./vendor/*"))" \ + && go test $(go list ./... | grep -v integration | grep -v /vendor/ | grep -v /template/) -cover \ + && CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o gateway . -FROM alpine:latest +FROM alpine:3.6 WORKDIR /root/ EXPOSE 8080 diff --git a/gateway/handlers/deletehandler.go b/gateway/handlers/deletehandler.go index 1141c2fc..fd30e2c6 100644 --- a/gateway/handlers/deletehandler.go +++ b/gateway/handlers/deletehandler.go @@ -12,11 +12,11 @@ import ( "io/ioutil" - "github.com/openfaas/faas/gateway/metrics" - "github.com/openfaas/faas/gateway/requests" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/filters" "github.com/docker/docker/client" + "github.com/openfaas/faas/gateway/metrics" + "github.com/openfaas/faas/gateway/requests" ) func MakeDeleteFunctionHandler(metricsOptions metrics.MetricOptions, c *client.Client) http.HandlerFunc { diff --git a/gateway/handlers/queueproxy.go b/gateway/handlers/queueproxy.go index c52fe3c2..59fd906a 100644 --- a/gateway/handlers/queueproxy.go +++ b/gateway/handlers/queueproxy.go @@ -10,9 +10,9 @@ import ( "net/url" "github.com/Sirupsen/logrus" + "github.com/gorilla/mux" "github.com/openfaas/faas/gateway/metrics" "github.com/openfaas/faas/gateway/queue" - "github.com/gorilla/mux" ) // MakeQueuedProxy accepts work onto a queue diff --git a/gateway/handlers/reader.go b/gateway/handlers/reader.go index d94b7aff..49ea60e9 100644 --- a/gateway/handlers/reader.go +++ b/gateway/handlers/reader.go @@ -11,11 +11,11 @@ import ( "strings" - "github.com/openfaas/faas/gateway/metrics" - "github.com/openfaas/faas/gateway/requests" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/filters" "github.com/docker/docker/client" + "github.com/openfaas/faas/gateway/metrics" + "github.com/openfaas/faas/gateway/requests" ) // MakeFunctionReader gives a summary of Function structs with Docker service stats overlaid with Prometheus counters. diff --git a/gateway/tests/registryauth_test.go b/gateway/tests/registryauth_test.go index c4468d0c..9123e211 100644 --- a/gateway/tests/registryauth_test.go +++ b/gateway/tests/registryauth_test.go @@ -9,8 +9,8 @@ import ( "strings" "testing" - "github.com/openfaas/faas/gateway/handlers" "github.com/docker/docker/api/types" + "github.com/openfaas/faas/gateway/handlers" ) func TestBuildEncodedAuthConfig(t *testing.T) { diff --git a/gateway/types/readconfig.go b/gateway/types/readconfig.go index 0a595cd2..1b5a69fd 100644 --- a/gateway/types/readconfig.go +++ b/gateway/types/readconfig.go @@ -104,25 +104,25 @@ func (ReadConfig) Read(hasEnv HasEnv) GatewayConfig { type GatewayConfig struct { // HTTP timeout for reading a request from clients. - ReadTimeout time.Duration + ReadTimeout time.Duration // HTTP timeout for writing a response from functions. - WriteTimeout time.Duration + WriteTimeout time.Duration // URL for alternate functions provider. FunctionsProviderURL *url.URL // Address of the NATS service. Required for async mode. - NATSAddress *string + NATSAddress *string // Port of the NATS Service. Required for async mode. - NATSPort *int + NATSPort *int // Host to connect to Prometheus. - PrometheusHost string + PrometheusHost string // Port to connect to Prometheus. - PrometheusPort int + PrometheusPort int } // UseNATS Use NATSor not