Make runtime paths configurable at link time #104200

Manually merged
Sybren A. Stüvel merged 1 commits from ZedDB/flamenco:config into main 2023-04-04 15:41:41 +02:00
4 changed files with 20 additions and 5 deletions

View File

@ -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}"

View File

@ -10,10 +10,18 @@ import (
"github.com/adrg/xdg"
)
// customHome can be set at link time to specify the home directory for the worker.
ZedDB marked this conversation as resolved Outdated

Replace This variable can be set with the actual name of the variable, customHome can be set

Also remove the "manually", as this can be done in an automated fashion as well.

Replace `This variable can be set` with the actual name of the variable, `customHome can be set` Also remove the "manually", as this can be done in an automated fashion as well.
// This can be overruled at runtime by setting the FLAMENCO_HOME enviroment variable.
ZedDB marked this conversation as resolved Outdated

Add that this is used in InFlamencoHome() and is still overruled if the FLAMENCO_HOME environment variable is set.

Add that this is used in `InFlamencoHome()` and is still overruled if the `FLAMENCO_HOME` environment variable is set.
// 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))
}

View File

@ -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.
ZedDB marked this conversation as resolved Outdated

Document why this is a variable, and that it's not intended to be changed while Flamenco Manager is running.

Document why this is a variable, and that it's not intended to be changed while Flamenco Manager is running.
// 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:

View File

@ -22,7 +22,11 @@ var (
errURLWithoutHostName = errors.New("manager URL should contain a host name")
)
const (
var (
ZedDB marked this conversation as resolved Outdated

Same comment as above.

Same comment as above.
// 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"
)