diff --git a/nomad/api_querier.go b/nomad/api_querier.go index 909820f..ac2fbab 100644 --- a/nomad/api_querier.go +++ b/nomad/api_querier.go @@ -42,8 +42,9 @@ type apiQuerier interface { // nomadApiClient implements the nomadApiQuerier interface and provides access to a real Nomad API. type nomadApiClient struct { - client *nomadApi.Client - namespace string + client *nomadApi.Client + namespace string + queryOptions *nomadApi.QueryOptions } func (nc *nomadApiClient) init(nomadURL *url.URL, nomadNamespace string) (err error) { @@ -53,11 +54,14 @@ func (nc *nomadApiClient) init(nomadURL *url.URL, nomadNamespace string) (err er Namespace: nomadNamespace, }) nc.namespace = nomadNamespace + nc.queryOptions = &nomadApi.QueryOptions{ + Namespace: nc.namespace, + } return err } func (nc *nomadApiClient) DeleteRunner(runnerId string) (err error) { - allocation, _, err := nc.client.Allocations().Info(runnerId, nil) + allocation, _, err := nc.client.Allocations().Info(runnerId, nc.queryOptions) if err != nil { return } @@ -76,7 +80,7 @@ func (nc *nomadApiClient) ExecuteCommand(allocationID string, } func (nc *nomadApiClient) loadRunners(jobId string) (allocationListStub []*nomadApi.AllocationListStub, err error) { - allocationListStub, _, err = nc.client.Jobs().Allocations(jobId, true, nil) + allocationListStub, _, err = nc.client.Jobs().Allocations(jobId, true, nc.queryOptions) return } @@ -102,6 +106,6 @@ func (nc *nomadApiClient) EvaluationStream(evalID string, ctx context.Context) ( nomadApi.TopicEvaluation: {evalID}, }, 0, - nil) + nc.queryOptions) return } diff --git a/nomad/job.go b/nomad/job.go index 01a63b7..857f066 100644 --- a/nomad/job.go +++ b/nomad/job.go @@ -12,13 +12,13 @@ const ( // LoadJobList loads the list of jobs from the Nomad api. func (nc *nomadApiClient) LoadJobList() (list []*nomadApi.JobListStub, err error) { - list, _, err = nc.client.Jobs().List(nil) + list, _, err = nc.client.Jobs().List(nc.queryOptions) return } // JobScale returns the scale of the passed job. func (nc *nomadApiClient) JobScale(jobId string) (jobScale uint, err error) { - status, _, err := nc.client.Jobs().ScaleStatus(jobId, nil) + status, _, err := nc.client.Jobs().ScaleStatus(jobId, nc.queryOptions) if err != nil { return }