Store default Nomad job in apiClient to cache it

This commit is contained in:
sirkrypt0
2021-05-07 10:50:09 +02:00
committed by Konrad Hanff
parent 9a5d982dfc
commit dfd34144f8
2 changed files with 11 additions and 5 deletions

View File

@@ -19,6 +19,8 @@ type ExecutorApi interface {
// ApiClient implements the ExecutorApi interface and can be used to perform different operations on the real Executor API and its return values.
type ApiClient struct {
apiQuerier
client *nomadApi.Client
defaultJob nomadApi.Job
}
// NewExecutorApi creates a new api client.
@@ -35,7 +37,11 @@ func (apiClient *ApiClient) init(nomadURL *url.URL) (err error) {
Address: nomadURL.String(),
TLSConfig: &nomadApi.TLSConfig{},
})
return err
if err != nil {
return err
}
apiClient.defaultJob = *parseJob(defaultJobHCL)
return nil
}
// LoadRunners loads the allocations of the specified job.