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

Fix list plugins backward compatibility mechanism #5913

Merged
merged 1 commit into from
Dec 12, 2018
Merged

Fix list plugins backward compatibility mechanism #5913

merged 1 commit into from
Dec 12, 2018

Conversation

bonifaido
Copy link
Contributor

@bonifaido bonifaido commented Dec 6, 2018

In this PR I'm trying to fix the backward compatibility mechanism of the ListPlugins API call, the error checking was too early, and the HTTP 405 detection never happened (which happens to work really nice actually).

@@ -46,22 +46,14 @@ func (c *Sys) ListPlugins(i *ListPluginsInput) (*ListPluginsResponse, error) {
ctx, cancelFunc := context.WithCancel(context.Background())
defer cancelFunc()
resp, err := c.c.RawRequestWithContext(ctx, req)
if err != nil {
if err != nil && resp == nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If resp == nil we will panic below when we call resp.StatusCode. I think this logic needs reworked a bit, maybe we can check the StatusCode here (if resp != nil) and if it's a 405 continue, otherwise return the error

Copy link
Contributor Author

@bonifaido bonifaido Dec 7, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From looking at the code of RawRequestWithContext I can say, that resp is always set if there is no error returned.

@briankassouf briankassouf added this to the 1.0.1 milestone Dec 6, 2018
@jefferai jefferai modified the milestones: 1.0.1, 1.0.2 Dec 12, 2018
@jefferai
Copy link
Member

Going to merge and address concerns after, thanks!

@jefferai jefferai merged commit dbd195f into hashicorp:master Dec 12, 2018
@jefferai jefferai modified the milestones: 1.0.2, 1.0.1 Dec 12, 2018
@bonifaido bonifaido deleted the api-list-plugins-backward-fix branch December 12, 2018 21:50
@bonifaido bonifaido restored the api-list-plugins-backward-fix branch December 12, 2018 21:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants