diff --git a/README.md b/README.md index 9a2166f0..f36a20e9 100644 --- a/README.md +++ b/README.md @@ -17,9 +17,16 @@ git clone https://github.com/cloudbase/garm cd garm go install ./... ``` - You should now have both ```garm``` and ```garm-cli``` in your ```$GOPATH/bin``` folder. +If you have docker/podman installed, you can also build statically linked binaries by running: + +```bash +make +``` + +The ```garm``` and ```garm-cli``` binaries will be built and copied to the ```bin/``` folder in your current working directory. + ## Install the service Add a new system user: @@ -31,12 +38,20 @@ useradd --shell /usr/bin/false \ --no-create-home garm ``` -Copy the binary from your ```$GOPATH``` to somewhere in the system ```$PATH```: +The ```lxd``` group is only needed if you have a local LXD install and want to connect to the unix socket to use it. If you're connecting to a remote LXD server over TCP, you can skip adding the ```garm``` user to the ```lxd``` group. + +Copy the binary to somewhere in the system ```$PATH```: ```bash sudo cp $(go env GOPATH)/bin/garm /usr/local/bin/garm ``` +Or if you built garm using ```make```: + +```bash +sudo cp ./bin/garm /usr/local/bin/garm +``` + Create the config folder: ```bash diff --git a/config/config.go b/config/config.go index 0e561d3b..1ac80e23 100644 --- a/config/config.go +++ b/config/config.go @@ -165,6 +165,12 @@ func (d *Default) Validate() error { return fmt.Errorf("missing callback_url") } + if d.ConfigDir != "" { + if _, err := os.Stat(d.ConfigDir); err != nil { + return errors.Wrap(err, "accessing config dir") + } + } + return nil } diff --git a/config/config_test.go b/config/config_test.go new file mode 100644 index 00000000..d912156b --- /dev/null +++ b/config/config_test.go @@ -0,0 +1 @@ +package config diff --git a/config/external_test.go b/config/external_test.go index 29ff8ad3..5332e2e1 100644 --- a/config/external_test.go +++ b/config/external_test.go @@ -1,6 +1,7 @@ package config import ( + "fmt" "io/ioutil" "os" "path/filepath" @@ -72,6 +73,14 @@ func TestExternal(t *testing.T) { }, errString: "path to provider dir must be absolute", }, + { + name: "Provider executable not found", + cfg: External{ + ConfigFile: "", + ProviderDir: "/tmp", + }, + errString: "checking provider executable: stat /tmp/garm-external-provider: no such file or directory", + }, } for _, tc := range tests { @@ -86,3 +95,16 @@ func TestExternal(t *testing.T) { }) } } + +func TestProviderExecutableIsExecutable(t *testing.T) { + cfg := getDefaultExternalConfig(t) + + execPath, err := cfg.ExecutablePath() + assert.Nil(t, err) + err = os.Chmod(execPath, 0o644) + assert.Nil(t, err) + + err = cfg.Validate() + assert.NotNil(t, err) + assert.EqualError(t, err, fmt.Sprintf("external provider binary %s is not executable", execPath)) +}