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

api: fix a panic and tweak some exported types #16237

Merged
merged 1 commit into from
Feb 22, 2023
Merged

api: fix a panic and tweak some exported types #16237

merged 1 commit into from
Feb 22, 2023

Conversation

shoenig
Copy link
Member

@shoenig shoenig commented Feb 21, 2023

This PR

  • fixes a panic in GetItems when looking up a variable that does not exist
  • deprecates GetItems in favor of GetVariableItems which avoids returning a pointer to a map
  • deprecates ErrVariableNotFound in favor of ErrVariablePathNotFound which is an actual error type
  • eliminates unused constant ErrVariableMissingItems
  • does some minor code cleanup to make linters happier

Fixes #16236
Fixes #16235
Fixes #16234

No backport - we don't tag the api module anyway

This PR
 - fixes a panic in GetItems when looking up a variable that does not exist.
 - deprecates GetItems in favor of GetVariableItems which avoids returning a pointer to a map
 - deprecates ErrVariableNotFound in favor of ErrVariablePathNotFound which is an actual error type
 - does some minor code cleanup to make linters happier
@@ -12,8 +12,16 @@ import (
)

const (
ErrVariableNotFound = "variable not found"
ErrVariableMissingItems = "variable missing Items field"
Copy link
Member Author

@shoenig shoenig Feb 21, 2023

Choose a reason for hiding this comment

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

note: ErrVariableMissingItems wasn't used so ... should be safe to just remove?

Copy link
Member

Choose a reason for hiding this comment

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

I checked in CT's nomad_var_get.go and nomad_var_list.go and found no consumers either. Technically breaking backcompat but I seriously doubt there are any real consumers.

@shoenig shoenig marked this pull request as ready for review February 21, 2023 14:47
@shoenig shoenig requested review from tgross and angrycub February 21, 2023 14:47
@@ -12,8 +12,16 @@ import (
)

const (
ErrVariableNotFound = "variable not found"
ErrVariableMissingItems = "variable missing Items field"
Copy link
Member

Choose a reason for hiding this comment

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

I checked in CT's nomad_var_get.go and nomad_var_list.go and found no consumers either. Technically breaking backcompat but I seriously doubt there are any real consumers.

Comment on lines +191 to +192
// todo(shoenig): seems like this could just return a *Variable instead of taking
// in a **Variable and modifying it?
Copy link
Member

Choose a reason for hiding this comment

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

I went back to look at the original PR for this and don't see any discussion of it. Maybe @angrycub will remember why we did this?

@shoenig shoenig added this to the 1.5.0 milestone Feb 21, 2023
@shoenig shoenig merged commit 2a0dde3 into main Feb 22, 2023
@shoenig shoenig deleted the api-vars-fixes branch February 22, 2023 14:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants