worker: Make BasePath configurable
This commit is contained in:
parent
6ce20a9ef6
commit
ce7ac9a756
11 changed files with 106 additions and 25 deletions
|
|
@ -87,7 +87,7 @@ func NewComposer(config *ComposerConfigFile, stateDir, cacheDir string) (*Compos
|
|||
}
|
||||
}
|
||||
|
||||
c.workers = worker.NewServer(c.logger, jobs, artifactsDir)
|
||||
c.workers = worker.NewServer(c.logger, jobs, artifactsDir, config.Worker.BasePath)
|
||||
|
||||
return &c, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ type AWSConfig struct {
|
|||
type WorkerAPIConfig struct {
|
||||
AllowedDomains []string `toml:"allowed_domains"`
|
||||
CA string `toml:"ca"`
|
||||
BasePath string `toml:"base_path"`
|
||||
PGHost string `toml:"pg_host" env:"PGHOST"`
|
||||
PGPort string `toml:"pg_port" env:"PGPORT"`
|
||||
PGDatabase string `toml:"pg_database" env:"PGDATABASE"`
|
||||
|
|
@ -85,6 +86,7 @@ func GetDefaultConfig() *ComposerConfigFile {
|
|||
},
|
||||
},
|
||||
Worker: WorkerAPIConfig{
|
||||
BasePath: "/api/worker/v1",
|
||||
EnableTLS: true,
|
||||
EnableMTLS: true,
|
||||
EnableJWT: false,
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ func TestDefaultConfig(t *testing.T) {
|
|||
}, defaultConfig.Koji)
|
||||
|
||||
require.Equal(t, WorkerAPIConfig{
|
||||
BasePath: "/api/worker/v1",
|
||||
EnableTLS: true,
|
||||
EnableMTLS: true,
|
||||
EnableJWT: false,
|
||||
|
|
|
|||
|
|
@ -97,6 +97,7 @@ func main() {
|
|||
OAuthURL string `toml:"oauth_url"`
|
||||
OfflineTokenPath string `toml:"offline_token"`
|
||||
} `toml:"authentication"`
|
||||
BasePath string `toml:"base_path"`
|
||||
}
|
||||
var unix bool
|
||||
flag.BoolVar(&unix, "unix", false, "Interpret 'address' as a path to a unix domain socket instead of a network address")
|
||||
|
|
@ -126,6 +127,10 @@ func main() {
|
|||
logrus.Fatalf("Could not load config file '%s': %v", configFile, err)
|
||||
}
|
||||
|
||||
if config.BasePath == "" {
|
||||
config.BasePath = "/api/worker/v1"
|
||||
}
|
||||
|
||||
cacheDirectory, ok := os.LookupEnv("CACHE_DIRECTORY")
|
||||
if !ok {
|
||||
logrus.Fatal("CACHE_DIRECTORY is not set. Is the service file missing CacheDirectory=?")
|
||||
|
|
@ -148,7 +153,7 @@ func main() {
|
|||
|
||||
var client *worker.Client
|
||||
if unix {
|
||||
client = worker.NewClientUnix(address)
|
||||
client = worker.NewClientUnix(address, config.BasePath)
|
||||
} else {
|
||||
var token *string
|
||||
var oAuthURL *string
|
||||
|
|
@ -189,7 +194,7 @@ func main() {
|
|||
}
|
||||
}
|
||||
|
||||
client, err = worker.NewClient(address, conf, token, oAuthURL)
|
||||
client, err = worker.NewClient(address, conf, token, oAuthURL, config.BasePath)
|
||||
if err != nil {
|
||||
logrus.Fatalf("Error creating worker client: %v", err)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue