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

migrate to mackerel.Client #566

Merged
merged 22 commits into from Jun 12, 2019

Conversation

Projects
None yet
3 participants
@lufia
Copy link
Contributor

commented May 22, 2019

I migrated mackerel-agent/mackerel to use mackerel.Client.

@lufia lufia force-pushed the lufia:migrate-client branch from dc51faf to 1adbd4d May 22, 2019

lufia added some commits May 22, 2019

use mackerel.Client.CreateHost
If the response's StatusCode is not in between 200 and 299,
Client.CreateHost handles a response as an error by Client.Request.

@lufia lufia force-pushed the lufia:migrate-client branch from 1adbd4d to 57d69be May 23, 2019

resp, err := api.postJSON("/api/v0/monitoring/checks/report", payload)
defer closeResp(resp)
return err
return api.c.PostCheckReports(payload)
}

return data.ID, nil
func (api *API) CreateHost(hostParam *mkr.CreateHostParam) (string, error) {
return api.c.CreateHost(hostParam)
}
resp, err := api.putJSON("/api/v0/hosts/"+hostID+"/metadata/"+namespace, metadata)
defer closeResp(resp)

return resp, err

@lufia lufia force-pushed the lufia:migrate-client branch from 106ce3f to 1959011 May 24, 2019

@lufia lufia marked this pull request as ready for review May 24, 2019

Show resolved Hide resolved command/command.go Outdated
Show resolved Hide resolved mackerel/api.go Outdated
Show resolved Hide resolved mackerel/api.go Outdated
@@ -613,8 +612,7 @@ func (app *App) UpdateHostSpecs() {
return
}

err = app.API.UpdateHost(app.Host.ID, mkr.UpdateHostParam(hostParam))

_, err = app.API.UpdateHost(app.Host.ID, (*mkr.UpdateHostParam)(hostParam))

This comment has been minimized.

Copy link
@itchyny

itchyny May 24, 2019

Contributor

This cast is required?

This comment has been minimized.

Copy link
@lufia

lufia May 28, 2019

Author Contributor

Yes, this is required. hostParam is typed as *mkr.CreateHostParam.

}

func (aperr *Error) Error() string {
return fmt.Sprintf("API error. status: %d, msg: %s", aperr.StatusCode, aperr.Message)

This comment has been minimized.

Copy link
@itchyny

itchyny May 24, 2019

Contributor

This is different from ApiError of mackerel-client-go so log message can change but maybe ok...

if api.Verbose {
dump, err := httputil.DumpRequest(req, true)
if err == nil {
logger.Tracef("%s", dump)

This comment has been minimized.

Copy link
@itchyny

itchyny May 24, 2019

Contributor

Logger prefix <api> for log in verbose mode will be lost but maybe ok.

This comment has been minimized.

Copy link
@lufia

lufia Jun 12, 2019

Author Contributor

I've fixed at edde7d6

lufia added some commits May 28, 2019

@lufia

This comment has been minimized.

Copy link
Contributor Author

commented Jun 4, 2019

I fixed lines that is commented.

resp, err := api.postJSON("/api/v0/monitoring/checks/report", payload)
defer closeResp(resp)
return err
return api.Client.PostCheckReports(payload)

This comment has been minimized.

Copy link
@astj

astj Jun 6, 2019

Contributor

[nit]
payload might be named something like reports ?

@@ -34,6 +34,8 @@ github.com/mackerelio/golib v0.0.0-20190411032134-c87047ca454e h1:MwWzFCq2tENDy2
github.com/mackerelio/golib v0.0.0-20190411032134-c87047ca454e/go.mod h1:kbqYA8VcFqcMt07v+GPSZQwqtwc7Wr0V0vzxUNMrk7E=
github.com/mackerelio/mackerel-client-go v0.3.0 h1:4SFqVdKIWz5IiL/LY/SosoZJ73zDpgaX2rw0/JW6mLo=

This comment has been minimized.

Copy link
@astj

astj Jun 6, 2019

Contributor

Can you clean those old dependencies by something like go mod tidy?

This comment has been minimized.

Copy link
@lufia

lufia Jun 12, 2019

Author Contributor

I'm not sure. Perhaps I could remove go.sum and then regenerate it.

@astj

astj approved these changes Jun 6, 2019

@lufia lufia merged commit a8bf455 into mackerelio:master Jun 12, 2019

3 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
coverage/coveralls Coverage increased (+0.2%) to 67.454%
Details

@lufia lufia deleted the lufia:migrate-client branch Jun 12, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.