worker: NewServer: move config parameters to a new Config struct

We will have more parameters soon so let's make this prettier sooner rather
than later.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
This commit is contained in:
Ondřej Budai 2022-03-03 14:37:21 +01:00 committed by Ondřej Budai
parent 9feb7b59d6
commit c1dc58eba4
5 changed files with 49 additions and 32 deletions

View file

@ -30,7 +30,12 @@ func newTestServer(t *testing.T, tempdir string, jobRequestTimeout time.Duration
if err != nil {
t.Fatalf("error creating fsjobqueue: %v", err)
}
return worker.NewServer(nil, q, "", jobRequestTimeout, basePath)
config := worker.Config{
RequestJobTimeout: jobRequestTimeout,
BasePath: basePath,
}
return worker.NewServer(nil, q, config)
}
// Ensure that the status request returns OK.
@ -326,7 +331,11 @@ func TestOAuth(t *testing.T) {
q, err := fsjobqueue.New(tempdir)
require.NoError(t, err)
workerServer := worker.NewServer(nil, q, tempdir, time.Duration(0), "/api/image-builder-worker/v1")
config := worker.Config{
ArtifactsDir: tempdir,
BasePath: "/api/image-builder-worker/v1",
}
workerServer := worker.NewServer(nil, q, config)
handler := workerServer.Handler()
workSrv := httptest.NewServer(handler)