Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

worker: rename server -> serverURL #4325

Merged
merged 1 commit into from
Aug 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions internal/worker/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
)

type Client struct {
server *url.URL
serverURL *url.URL
requester *http.Client
offlineToken string
oAuthURL string
Expand Down Expand Up @@ -75,14 +75,14 @@ type tokenResponse struct {
}

func NewClient(conf ClientConfig) (*Client, error) {
server, err := url.Parse(conf.BaseURL)
serverURL, err := url.Parse(conf.BaseURL)
if err != nil {
return nil, err
}

api.BasePath = conf.BasePath

server, err = server.Parse(api.BasePath + "/")
serverURL, err = serverURL.Parse(api.BasePath + "/")
if err != nil {
panic(err)
}
Expand Down Expand Up @@ -115,7 +115,7 @@ func NewClient(conf ClientConfig) (*Client, error) {
requester.Transport = transport

client := &Client{
server: server,
serverURL: serverURL,
requester: requester,
offlineToken: conf.OfflineToken,
oAuthURL: conf.OAuthURL,
Expand All @@ -131,14 +131,14 @@ func NewClient(conf ClientConfig) (*Client, error) {
}

func NewClientUnix(conf ClientConfig) *Client {
server, err := url.Parse("http://localhost/")
serverURL, err := url.Parse("http://localhost/")
if err != nil {
panic(err)
}

api.BasePath = conf.BasePath

server, err = server.Parse(api.BasePath + "/")
serverURL, err = serverURL.Parse(api.BasePath + "/")
if err != nil {
panic(err)
}
Expand All @@ -151,7 +151,7 @@ func NewClientUnix(conf ClientConfig) *Client {
},
}
client := &Client{
server: server,
serverURL: serverURL,
requester: requester,
}
err = client.registerWorker()
Expand All @@ -166,7 +166,7 @@ func (c *Client) registerWorker() error {
c.workerIDMu.Lock()
defer c.workerIDMu.Unlock()

url, err := c.server.Parse("workers")
url, err := c.serverURL.Parse("workers")
if err != nil {
return err
}
Expand Down Expand Up @@ -222,7 +222,7 @@ func (c *Client) workerHeartbeat() {
}
}

url, err := c.server.Parse(fmt.Sprintf("workers/%s/status", workerID()))
url, err := c.serverURL.Parse(fmt.Sprintf("workers/%s/status", workerID()))
if err != nil {
logrus.Errorf("Error parsing worker status: %v", err)
continue
Expand Down Expand Up @@ -336,7 +336,7 @@ func (c *Client) NewRequest(method, url string, headers map[string]string, body
}

func (c *Client) RequestJob(types []string, arch string) (Job, error) {
url, err := c.server.Parse("jobs")
url, err := c.serverURL.Parse("jobs")
if err != nil {
// This only happens when "jobs" cannot be parsed.
panic(err)
Expand Down Expand Up @@ -382,12 +382,12 @@ func (c *Client) RequestJob(types []string, arch string) (Job, error) {
return nil, fmt.Errorf("error parsing response: %v", err)
}

location, err := c.server.Parse(jr.Location)
location, err := c.serverURL.Parse(jr.Location)
if err != nil {
return nil, fmt.Errorf("error parsing location url in response: %v", err)
}

artifactLocation, err := c.server.Parse(jr.ArtifactLocation)
artifactLocation, err := c.serverURL.Parse(jr.ArtifactLocation)
if err != nil {
return nil, fmt.Errorf("error parsing artifact location url in response: %v", err)
}
Expand Down
Loading