diff --git a/Gopkg.lock b/Gopkg.lock index f5227a0..b08fd09 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -39,20 +39,20 @@ revision = "9e921883ac929bbe515b39793ece99ce3a9d7706" [[projects]] - digest = "1:74860eb071d52337d67e9ffd6893b29affebd026505aa917ec23131576a91a77" + digest = "1:d7086e6a64a9e4fa54aaf56ce42ead0be1300b0285604c4d306438880db946ad" name = "github.com/alexellis/go-execute" packages = ["pkg/v1"] pruneopts = "UT" - revision = "961405ea754427780f2151adff607fa740d377f7" - version = "0.3.0" + revision = "8697e4e28c5e3ce441ff8b2b6073035606af2fe9" + version = "0.4.0" [[projects]] - digest = "1:6e4df70ce37cf5e682ea90ee865fc65725208b0d42d48e3470e546a3121b9dd9" + digest = "1:345f6fa182d72edfa3abc493881c3fa338a464d93b1e2169cda9c822fde31655" name = "github.com/alexellis/k3sup" packages = ["pkg/env"] pruneopts = "UT" - revision = "aec00235bcc36b6b2cc0799a0b89d9e7bccdd8c6" - version = "0.7.9" + revision = "629c0bc6b50f71ab93a1fbc8971a5bd05dc581eb" + version = "0.9.3" [[projects]] branch = "master" @@ -408,7 +408,7 @@ version = "0.18.10" [[projects]] - digest = "1:7a20be0bdfb2c05a4a7b955cb71645fe2983aa3c0bbae10d6bba3e2dd26ddd0d" + digest = "1:4d972c6728f8cbaded7d2ee6349fbe5f9278cabcd51d1ecad97b2e79c72bea9d" name = "github.com/openfaas/faas-provider" packages = [ ".", @@ -419,8 +419,8 @@ "types", ] pruneopts = "UT" - revision = "8f7c35975e1b2bf8286c2f90ee51633eec427491" - version = "0.14.0" + revision = "db19209aa27f42a9cf6a23448fc2b8c9cc4fbb5d" + version = "v0.15.1" [[projects]] digest = "1:cf31692c14422fa27c83a05292eb5cbe0fb2775972e8f1f8446a71549bd8980b" diff --git a/Gopkg.toml b/Gopkg.toml index 76501bf..6c882bf 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -16,11 +16,11 @@ [[constraint]] name = "github.com/alexellis/k3sup" - version = "0.7.1" + version = "0.9.3" [[constraint]] name = "github.com/alexellis/go-execute" - version = "0.3.0" + version = "0.4.0" [[constraint]] name = "github.com/gorilla/mux" @@ -40,7 +40,7 @@ [[constraint]] name = "github.com/openfaas/faas-provider" - version = "0.14.0" + version = "v0.15.1" [[constraint]] name = "github.com/docker/cli" diff --git a/Makefile b/Makefile index e8451e3..7f147f9 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,8 @@ Version := $(shell git describe --tags --dirty) GitCommit := $(shell git rev-parse HEAD) LDFLAGS := "-s -w -X main.Version=$(Version) -X main.GitCommit=$(GitCommit)" -CONTAINERD_VER := 1.3.2 -CNI_VERSION := v0.8.5 +CONTAINERD_VER := 1.3.4 +CNI_VERSION := v0.8.6 ARCH := amd64 .PHONY: all @@ -36,7 +36,7 @@ prepare-test: sudo systemctl status -l faasd-provider --no-pager sudo systemctl status -l faasd --no-pager curl -sSLf https://cli.openfaas.com | sudo sh - sleep 120 && sudo journalctl -u faasd --no-pager + echo "Sleeping for 2m" && sleep 120 && sudo journalctl -u faasd --no-pager .PHONY: test-e2e test-e2e: diff --git a/cmd/provider.go b/cmd/provider.go index d2fabd0..cf565b5 100644 --- a/cmd/provider.go +++ b/cmd/provider.go @@ -47,6 +47,7 @@ func makeProviderCmd() *cobra.Command { } log.Printf("faasd-provider starting..\tService Timeout: %s\n", config.WriteTimeout.String()) + printVersion() wd, err := os.Getwd() if err != nil { diff --git a/cmd/root.go b/cmd/root.go index cb398b4..89c3941 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -69,11 +69,11 @@ var versionCmd = &cobra.Command{ func parseBaseCommand(_ *cobra.Command, _ []string) { printLogo() - fmt.Printf( - `faasd -Commit: %s -Version: %s -`, GitCommit, GetVersion()) + printVersion() +} + +func printVersion() { + fmt.Printf("faasd version: %s\tcommit: %s\n", GetVersion(), GitCommit) } func printLogo() { diff --git a/cmd/up.go b/cmd/up.go index dc7a88b..ca39347 100644 --- a/cmd/up.go +++ b/cmd/up.go @@ -46,6 +46,8 @@ var upCmd = &cobra.Command{ func runUp(cmd *cobra.Command, _ []string) error { + printVersion() + cfg, err := parseUpFlags(cmd) if err != nil { return err diff --git a/pkg/proxy.go b/pkg/proxy.go index d951b83..f78a4ce 100644 --- a/pkg/proxy.go +++ b/pkg/proxy.go @@ -11,6 +11,8 @@ import ( "time" ) +// NewProxy creates a HTTP proxy to expose the gateway container +// from OpenFaaS to the host func NewProxy(port int, timeout time.Duration) *Proxy { return &Proxy{ @@ -19,11 +21,13 @@ func NewProxy(port int, timeout time.Duration) *Proxy { } } +// Proxy for exposing a private container type Proxy struct { Timeout time.Duration Port int } +// Start listening and forwarding HTTP to the host func (p *Proxy) Start(gatewayChan chan string, done chan bool) error { tcp := p.Port diff --git a/pkg/supervisor.go b/pkg/supervisor.go index b4d2c17..ee749af 100644 --- a/pkg/supervisor.go +++ b/pkg/supervisor.go @@ -294,6 +294,7 @@ func LoadComposeFile(wd string, file string) (*compose.Config, error) { if err != nil { return nil, err } + config, err := loader.ParseYAML(b) if err != nil { return nil, err @@ -306,6 +307,7 @@ func LoadComposeFile(wd string, file string) (*compose.Config, error) { var files []compose.ConfigFile files = append(files, compose.ConfigFile{Filename: file, Config: config}) + return loader.Load(compose.ConfigDetails{ WorkingDir: wd, ConfigFiles: files, @@ -323,14 +325,19 @@ func sortedEnvKeys(env map[string]*string) (keys []string) { return keys } +// ArchGetter provides client CPU architecture and +// client OS type ArchGetter func() (string, string) +// GetArchSuffix provides client CPU architecture and +// client OS from ArchGetter func GetArchSuffix(getClientArch ArchGetter) (suffix string, err error) { clientArch, clientOS := getClientArch() if clientOS != "Linux" { - return "", fmt.Errorf("You can only use faasd on Linux") + return "", fmt.Errorf("you can only use faasd with Linux") } + switch clientArch { case "x86_64": // no suffix needed diff --git a/pkg/supervisor_test.go b/pkg/supervisor_test.go index 0a66061..937f5ed 100644 --- a/pkg/supervisor_test.go +++ b/pkg/supervisor_test.go @@ -186,7 +186,7 @@ func Test_GetArchSuffix(t *testing.T) { { name: "error if os is not linux", foundOS: "mac", - err: "You can only use faasd on Linux", + err: "you can only use faasd with Linux", }, { name: "x86 has no suffix", diff --git a/vendor/github.com/alexellis/go-execute/pkg/v1/exec.go b/vendor/github.com/alexellis/go-execute/pkg/v1/exec.go index 0f4242a..cca18dc 100644 --- a/vendor/github.com/alexellis/go-execute/pkg/v1/exec.go +++ b/vendor/github.com/alexellis/go-execute/pkg/v1/exec.go @@ -71,10 +71,20 @@ func (et ExecTask) Execute() (ExecResult, error) { cmd.Dir = et.Cwd if len(et.Env) > 0 { - cmd.Env = os.Environ() + overrides := map[string]bool{} for _, env := range et.Env { + key := strings.Split(env, "=")[0] + overrides[key] = true cmd.Env = append(cmd.Env, env) } + + for _, env := range os.Environ() { + key := strings.Split(env, "=")[0] + + if _, ok := overrides[key]; !ok { + cmd.Env = append(cmd.Env, env) + } + } } stdoutBuff := bytes.Buffer{} diff --git a/vendor/github.com/alexellis/k3sup/pkg/env/env.go b/vendor/github.com/alexellis/k3sup/pkg/env/env.go index c4d7d80..814f313 100644 --- a/vendor/github.com/alexellis/k3sup/pkg/env/env.go +++ b/vendor/github.com/alexellis/k3sup/pkg/env/env.go @@ -11,7 +11,12 @@ import ( // GetClientArch returns a pair of arch and os func GetClientArch() (string, string) { - task := execute.ExecTask{Command: "uname", Args: []string{"-m"}, StreamStdio: true} + task := execute.ExecTask{ + Command: "uname", + Args: []string{"-m"}, + StreamStdio: false, + } + res, err := task.Execute() if err != nil { log.Println(err) @@ -19,7 +24,12 @@ func GetClientArch() (string, string) { arch := strings.TrimSpace(res.Stdout) - taskOS := execute.ExecTask{Command: "uname", Args: []string{"-s"}, StreamStdio: true} + taskOS := execute.ExecTask{ + Command: "uname", + Args: []string{"-s"}, + StreamStdio: false, + } + resOS, errOS := taskOS.Execute() if errOS != nil { log.Println(errOS) diff --git a/vendor/github.com/openfaas/faas-provider/.travis.yml b/vendor/github.com/openfaas/faas-provider/.travis.yml index d063d86..2c4c11a 100644 --- a/vendor/github.com/openfaas/faas-provider/.travis.yml +++ b/vendor/github.com/openfaas/faas-provider/.travis.yml @@ -1,4 +1,9 @@ language: go + +go: + - 1.13.x + go_import_path: github.com/openfaas/faas-provider script: - make test + diff --git a/vendor/github.com/openfaas/faas-provider/Dockerfile b/vendor/github.com/openfaas/faas-provider/Dockerfile deleted file mode 100644 index 495f9fa..0000000 --- a/vendor/github.com/openfaas/faas-provider/Dockerfile +++ /dev/null @@ -1,27 +0,0 @@ -FROM golang:1.11-alpine3.10 - -ENV CGO_ENABLED=0 - -RUN mkdir -p /go/src/github.com/openfaas/faas-provider/ - -WORKDIR /go/src/github.com/openfaas/faas-provider - -COPY vendor vendor -COPY types types -COPY auth auth -COPY serve.go . - -RUN go test ./auth/ -v \ - && CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o faas-provider . - -FROM alpine:3.8 -RUN apk --no-cache add ca-certificates -WORKDIR /root/ - -EXPOSE 8080 -ENV http_proxy "" -ENV https_proxy "" - -COPY --from=0 /go/src/github.com/openfaas/faas-provider/faas-provider . - -CMD ["./faas-provider] diff --git a/vendor/github.com/openfaas/faas-provider/Gopkg.lock b/vendor/github.com/openfaas/faas-provider/Gopkg.lock deleted file mode 100644 index ce1ac00..0000000 --- a/vendor/github.com/openfaas/faas-provider/Gopkg.lock +++ /dev/null @@ -1,39 +0,0 @@ -# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'. - - -[[projects]] - digest = "1:160eabf7a69910fd74f29c692718bc2437c1c1c7d4c9dea9712357752a70e5df" - name = "github.com/gorilla/context" - packages = ["."] - pruneopts = "UT" - revision = "1ea25387ff6f684839d82767c1733ff4d4d15d0a" - version = "v1.1" - -[[projects]] - digest = "1:e73f5b0152105f18bc131fba127d9949305c8693f8a762588a82a48f61756f5f" - name = "github.com/gorilla/mux" - packages = ["."] - pruneopts = "UT" - revision = "e3702bed27f0d39777b0b37b664b6280e8ef8fbf" - version = "v1.6.2" - -[[projects]] - digest = "1:9a1bb99a85e2ccddbc593aa0af084cdf6ea18ed081469eb90e7f6d0d303af6cd" - name = "go.uber.org/goleak" - packages = [ - ".", - "internal/stack", - ] - pruneopts = "UT" - revision = "1ac8aeca0a53163331564467638f6ffb639636bf" - version = "v0.10.0" - -[solve-meta] - analyzer-name = "dep" - analyzer-version = 1 - input-imports = [ - "github.com/gorilla/mux", - "go.uber.org/goleak", - ] - solver-name = "gps-cdcl" - solver-version = 1 diff --git a/vendor/github.com/openfaas/faas-provider/Gopkg.toml b/vendor/github.com/openfaas/faas-provider/Gopkg.toml deleted file mode 100644 index 3810eac..0000000 --- a/vendor/github.com/openfaas/faas-provider/Gopkg.toml +++ /dev/null @@ -1,7 +0,0 @@ -[prune] - go-tests = true - unused-packages = true - -[[constraint]] - name = "github.com/gorilla/mux" - version = "1.6.2" diff --git a/vendor/github.com/openfaas/faas-provider/README.md b/vendor/github.com/openfaas/faas-provider/README.md index 7d1f31a..e41d926 100644 --- a/vendor/github.com/openfaas/faas-provider/README.md +++ b/vendor/github.com/openfaas/faas-provider/README.md @@ -20,7 +20,7 @@ The following is used in OpenFaaS and recommended for those seeking to build the All the required HTTP routes are configured automatically including a HTTP server on port 8080. Your task is to implement the supplied HTTP handler functions. -For an example see the [server.go](https://github.com/openfaas/faas-netes/blob/master/server.go) file in the [faas-netes](https://github.com/openfaas/faas-netes) Kubernetes backend. +For an example see the [main.go](https://github.com/openfaas/faas-netes/blob/master/main.go) file in the [faas-netes](https://github.com/openfaas/faas-netes) Kubernetes backend. I.e.: diff --git a/vendor/github.com/openfaas/faas-provider/go.mod b/vendor/github.com/openfaas/faas-provider/go.mod new file mode 100644 index 0000000..1a4e586 --- /dev/null +++ b/vendor/github.com/openfaas/faas-provider/go.mod @@ -0,0 +1,10 @@ +module github.com/openfaas/faas-provider + +go 1.13 + +require ( + github.com/gorilla/context v0.0.0-20160226214623-1ea25387ff6f // indirect + github.com/gorilla/mux v1.6.2 + github.com/stretchr/testify v1.5.1 // indirect + go.uber.org/goleak v0.10.0 +) diff --git a/vendor/github.com/openfaas/faas-provider/go.sum b/vendor/github.com/openfaas/faas-provider/go.sum new file mode 100644 index 0000000..938eda4 --- /dev/null +++ b/vendor/github.com/openfaas/faas-provider/go.sum @@ -0,0 +1,17 @@ +github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/gorilla/context v0.0.0-20160226214623-1ea25387ff6f h1:9oNbS1z4rVpbnkHBdPZU4jo9bSmrLpII768arSyMFgk= +github.com/gorilla/context v0.0.0-20160226214623-1ea25387ff6f/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= +github.com/gorilla/mux v1.6.2 h1:Pgr17XVTNXAk3q/r4CpKzC5xBM/qW1uVLV+IhRZpIIk= +github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4= +github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= +go.uber.org/goleak v0.10.0 h1:G3eWbSNIskeRqtsN/1uI5B+eP73y3JUuBsv9AZjehb4= +go.uber.org/goleak v0.10.0/go.mod h1:VCZuO8V8mFPlL0F5J5GK1rtHV3DrFcQ1R8ryq7FK0aI= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/vendor/github.com/openfaas/faas-provider/logs/logs.go b/vendor/github.com/openfaas/faas-provider/logs/logs.go index 4069c40..8dc076a 100644 --- a/vendor/github.com/openfaas/faas-provider/logs/logs.go +++ b/vendor/github.com/openfaas/faas-provider/logs/logs.go @@ -33,7 +33,7 @@ type Request struct { // allows you to safely compare if two requests have the same value. func (r Request) String() string { return fmt.Sprintf( - "name:%s namespace: %s instance:%s since:%v tail:%d follow:%v", + "name: %s namespace: %s instance: %s since: %v tail: %d follow: %v", r.Name, r.Namespace, r.Instance, r.Since, r.Tail, r.Follow, ) } @@ -55,8 +55,12 @@ type Message struct { // String implements the Stringer interface and allows for nice and simple string formatting of a log Message. func (m Message) String() string { + ns := "" + if len(m.Namespace) > 0 { + ns = fmt.Sprintf("%s ", m.Namespace) + } return fmt.Sprintf( - "%s %s (%s %s) %s", - m.Timestamp.String(), m.Name, m.Namespace, m.Instance, m.Text, + "%s %s (%s%s) %s", + m.Timestamp.String(), m.Name, ns, m.Instance, m.Text, ) }