Unverified Commit a7acf2c0 authored by Tomasz Maczukin's avatar Tomasz Maczukin
Browse files

Use NewGitLabClient() instead of explicit GitLabClient{}

parent cdb231f2
......@@ -70,7 +70,7 @@ func (c *ArtifactsDownloaderCommand) Execute(context *cli.Context) {
func init() {
common.RegisterCommand2("artifacts-downloader", "download and extract build artifacts (internal)", &ArtifactsDownloaderCommand{
network: &network.GitLabClient{},
network: network.NewGitLabClient(),
retryHelper: retryHelper{
Retry: 2,
RetryTime: time.Second,
......
......@@ -78,7 +78,7 @@ func (c *ArtifactsUploaderCommand) Execute(*cli.Context) {
func init() {
common.RegisterCommand2("artifacts-uploader", "create and upload build artifacts (internal)", &ArtifactsUploaderCommand{
network: &network.GitLabClient{},
network: network.NewGitLabClient(),
retryHelper: retryHelper{
Retry: 2,
RetryTime: time.Second,
......
......@@ -491,7 +491,7 @@ func (mr *RunCommand) Execute(context *cli.Context) {
func init() {
common.RegisterCommand2("run", "run multi runner service", &RunCommand{
ServiceName: defaultServiceName,
network: &network.GitLabClient{},
network: network.NewGitLabClient(),
prometheusLogHook: prometheus_helper.NewLogHook(),
})
}
......@@ -283,6 +283,6 @@ func init() {
VirtualBox: &common.VirtualBoxConfig{},
},
},
network: &network.GitLabClient{},
network: network.NewGitLabClient(),
})
}
......@@ -160,6 +160,6 @@ func (r *RunSingleCommand) Execute(c *cli.Context) {
func init() {
common.RegisterCommand2("run-single", "start single runner", &RunSingleCommand{
network: &network.GitLabClient{},
network: network.NewGitLabClient(),
})
}
......@@ -63,6 +63,6 @@ func (c *UnregisterCommand) Execute(context *cli.Context) {
func init() {
common.RegisterCommand2("unregister", "unregister specific runner", &UnregisterCommand{
network: &network.GitLabClient{},
network: network.NewGitLabClient(),
})
}
......@@ -53,6 +53,6 @@ func (c *VerifyCommand) Execute(context *cli.Context) {
func init() {
common.RegisterCommand2("verify", "verify all registered runners", &VerifyCommand{
network: &network.GitLabClient{},
network: network.NewGitLabClient(),
})
}
......@@ -442,3 +442,11 @@ func (n *GitLabClient) ProcessBuild(config common.RunnerConfig, buildCredentials
trace.start()
return trace
}
func NewGitLabClient() *GitLabClient {
return &GitLabClient{}
}
func NewLegacyGitLabClient() *GitLabClient {
return &GitLabClient{}
}
\ No newline at end of file
......@@ -25,7 +25,7 @@ var brokenConfig = RunnerConfig{
}
func TestClients(t *testing.T) {
c := GitLabClient{}
c := NewLegacyGitLabClient()
c1, _ := c.getClient(RunnerCredentials{
URL: "http://test/",
})
......@@ -126,7 +126,7 @@ func TestGetBuild(t *testing.T) {
},
}
c := GitLabClient{}
c := NewLegacyGitLabClient()
res, ok := c.GetBuild(validToken)
if assert.NotNil(t, res) {
......@@ -222,7 +222,7 @@ func TestRegisterRunner(t *testing.T) {
Token: "other",
}
c := GitLabClient{}
c := NewLegacyGitLabClient()
res := c.RegisterRunner(validToken, "test", "tags", true)
if assert.NotNil(t, res) {
......@@ -289,7 +289,7 @@ func TestDeleteRunner(t *testing.T) {
Token: "other",
}
c := GitLabClient{}
c := NewLegacyGitLabClient()
state := c.DeleteRunner(validToken)
assert.True(t, state)
......@@ -351,7 +351,7 @@ func TestVerifyRunner(t *testing.T) {
Token: "other",
}
c := GitLabClient{}
c := NewLegacyGitLabClient()
state := c.VerifyRunner(validToken)
assert.True(t, state)
......@@ -409,7 +409,7 @@ func TestUpdateBuild(t *testing.T) {
}
trace := "trace"
c := GitLabClient{}
c := NewLegacyGitLabClient()
state := c.UpdateBuild(config, 10, "running", &trace)
assert.Equal(t, UpdateSucceeded, state, "Update should continue when running")
......@@ -479,7 +479,7 @@ func TestArtifactsUpload(t *testing.T) {
defer tempFile.Close()
defer os.Remove(tempFile.Name())
c := GitLabClient{}
c := NewLegacyGitLabClient()
fmt.Fprint(tempFile, "content")
state := c.UploadArtifacts(config, tempFile.Name())
......@@ -499,7 +499,7 @@ func TestArtifactsUpload(t *testing.T) {
var patchToken = "token"
var patchTraceString = "trace trace trace"
func getPatchServer(t *testing.T, handler func(w http.ResponseWriter, r *http.Request, body string, offset, limit int)) (*httptest.Server, GitLabClient, RunnerConfig) {
func getPatchServer(t *testing.T, handler func(w http.ResponseWriter, r *http.Request, body string, offset, limit int)) (*httptest.Server, *GitLabClient, RunnerConfig) {
patchHandler := func(w http.ResponseWriter, r *http.Request) {
if r.Method != "PATCH" {
w.WriteHeader(406)
......@@ -531,7 +531,7 @@ func getPatchServer(t *testing.T, handler func(w http.ResponseWriter, r *http.Re
},
}
return server, GitLabClient{}, config
return server, NewLegacyGitLabClient(), config
}
func getTracePatch(traceString string, offset int) *tracePatch {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment