Skip to content

Commit

Permalink
Use k3sup to determine client arch
Browse files Browse the repository at this point in the history
* Set image suffix for OpenFaaS

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
  • Loading branch information
alexellis committed Dec 24, 2019
1 parent d19d899 commit 456e563
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 3 deletions.
9 changes: 9 additions & 0 deletions Gopkg.lock

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

3 changes: 3 additions & 0 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
name = "github.com/spf13/cobra"
version = "0.0.5"

[[constraint]]
name = "github.com/alexellis/k3sup"
version = "0.7.1"

[[constraint]]
name = "github.com/alexellis/go-execute"
Expand Down
25 changes: 22 additions & 3 deletions cmd/up.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"time"

"github.com/alexellis/faasd/pkg"
"github.com/alexellis/k3sup/pkg/env"
"github.com/spf13/cobra"
)

Expand All @@ -22,7 +23,25 @@ var upCmd = &cobra.Command{

func runUp(_ *cobra.Command, _ []string) error {

services := makeServiceDefinitions()
clientArch, clientOS := env.GetClientArch()

if clientOS != "Linux" {
return fmt.Errorf("You can only use faasd on Linux")
}
clientSuffix := ""
switch clientArch {
case "x86_64":
clientSuffix = ""
break
case "armhf":
case "arm64":
clientSuffix = clientArch
break
case "aarch64":
clientSuffix = "arm64"
}

services := makeServiceDefinitions(clientSuffix)

start := time.Now()
supervisor, err := pkg.NewSupervisor("/run/containerd/containerd.sock")
Expand Down Expand Up @@ -69,7 +88,7 @@ func runUp(_ *cobra.Command, _ []string) error {
return nil
}

func makeServiceDefinitions() []pkg.Service {
func makeServiceDefinitions(archSuffix string) []pkg.Service {
wd, _ := os.Getwd()

return []pkg.Service{
Expand Down Expand Up @@ -104,7 +123,7 @@ func makeServiceDefinitions() []pkg.Service {
"faas_nats_address=nats",
"faas_nats_port=4222",
},
Image: "docker.io/openfaas/gateway:0.18.7",
Image: "docker.io/openfaas/gateway:0.18.7" + archSuffix,
Mounts: []pkg.Mount{},
Caps: []string{"CAP_NET_RAW"},
},
Expand Down
21 changes: 21 additions & 0 deletions vendor/github.com/alexellis/k3sup/LICENSE

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

29 changes: 29 additions & 0 deletions vendor/github.com/alexellis/k3sup/pkg/env/env.go

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

0 comments on commit 456e563

Please sign in to comment.