diff --git a/Makefile b/Makefile index 0df06616..ad12046d 100644 --- a/Makefile +++ b/Makefile @@ -17,7 +17,7 @@ _GIT_DESCRIPTION_OR_TAG := $(subst v${VERSION}-,,$(shell git describe --dirty -- # ${GITHASH}. GITHASH := $(subst v${VERSION},$(shell git rev-parse --short HEAD),${_GIT_DESCRIPTION_OR_TAG}) -LDFLAGS := -X ${PKG}/internal/appinfo.ApplicationVersion=${VERSION} \ +LDFLAGS := ${LDFLAGS} -X ${PKG}/internal/appinfo.ApplicationVersion=${VERSION} \ -X ${PKG}/internal/appinfo.ApplicationGitHash=${GITHASH} \ -X ${PKG}/internal/appinfo.ReleaseCycle=${RELEASE_CYCLE} BUILD_FLAGS = -ldflags="${LDFLAGS}" diff --git a/internal/appinfo/xdg_paths.go b/internal/appinfo/xdg_paths.go index 114e505b..ea6095d3 100644 --- a/internal/appinfo/xdg_paths.go +++ b/internal/appinfo/xdg_paths.go @@ -10,10 +10,18 @@ import ( "github.com/adrg/xdg" ) +// customHome can be set at link time to specify the home directory for the worker. +// This can be overruled at runtime by setting the FLAMENCO_HOME enviroment variable. +// Only used in InFlamencoHome() function. +var customHome = "" + // InFlamencoHome returns the filename in the 'flamenco home' dir, and ensures // that the directory exists. func InFlamencoHome(filename string) (string, error) { - flamencoHome := os.Getenv("FLAMENCO_HOME") + flamencoHome := customHome + if envHome, ok := os.LookupEnv("FLAMENCO_HOME"); ok { + flamencoHome = envHome + } if flamencoHome == "" { return xdg.DataFile(path.Join(xdgApplicationName, filename)) } diff --git a/internal/manager/config/config.go b/internal/manager/config/config.go index ba917785..09aef57a 100644 --- a/internal/manager/config/config.go +++ b/internal/manager/config/config.go @@ -25,9 +25,12 @@ import ( shaman_config "git.blender.org/flamenco/pkg/shaman/config" ) -const ( - configFilename = "flamenco-manager.yaml" +// configFilename is used to specify where flamenco will write its config file. +// If the path is not absolute, it will use the flamenco binary location as the +// relative root path. This is not intended to be changed during runtime. +var configFilename = "flamenco-manager.yaml" +const ( latestConfigVersion = 3 // // relative to the Flamenco Server Base URL: diff --git a/internal/worker/config.go b/internal/worker/config.go index 81bc164b..fa16ab3a 100644 --- a/internal/worker/config.go +++ b/internal/worker/config.go @@ -22,7 +22,11 @@ var ( errURLWithoutHostName = errors.New("manager URL should contain a host name") ) -const ( +var ( + // config- and credentialsFilename are used to specify where flamenco will + // write its config/credentials file. If the path is not absolute, it will + // use the flamenco binary location as the relative root path. These are not + // intended to be changed during runtime. credentialsFilename = "flamenco-worker-credentials.yaml" configFilename = "flamenco-worker.yaml" )