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

Deal with no flags passed to Server#destroy #125

Merged
merged 1 commit into from
Dec 12, 2022

Conversation

ekohl
Copy link
Contributor

@ekohl ekohl commented Dec 5, 2022

In 085a7c8 it became possible to pass flags to Server#destroy but if the caller didn't pass flags in opts it failed because it was essentially nil.zero? which isn't defined.

I wasn't sure if I should drop the defaults for flags in options, but decided to keep it in to "document" the API.

In 085a7c8 it became possible to pass
flags to Server#destroy but if the caller didn't pass flags in opts it
failed because it was essentially nil.zero? which isn't defined.

Fixes: 085a7c8
Copy link

@adamruzicka adamruzicka left a comment

Choose a reason for hiding this comment

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

Yes, this could work, although to me it doesn't express the intent as clearly as it could. What would you say to something like this as a counter proposal?

def destroy(options = {})
  defaults = {:destroy_volumes => false, :flags => 0}
  options = defaults.merge(options)
  # ...
end

I know this is a matter of personal taste so I won't insist on it.

@ekohl
Copy link
Contributor Author

ekohl commented Dec 7, 2022

Good question. What I'd actually prefer is def destroy(destroy_volumes: false, flags: 0, **kwargs) but that's probably breaking the API and have issues with Ruby < 2.7.

@adamruzicka
Copy link

Yes, that would be even better. Do we have to keep compatibility with eol rubies? It is breaking the api, but we will have to do that eventually anyway

@ekohl
Copy link
Contributor Author

ekohl commented Dec 8, 2022

I don't know to be honest. I also don't know if we need to remain compatible with some generic fog interface for destroy(). If we don't, kwargs could actually be dropped.

@ekohl
Copy link
Contributor Author

ekohl commented Dec 12, 2022

For now I'm going to merge this. In Foreman we now pin to >= 0.9.0 (https://github.com/theforeman/foreman/blob/339fe635ffa37d52e7174be401e9b54af20c5681/bundler.d/libvirt.rb#L2) and that means that a new release on Debian would break if we change the API. So this isn't a long term solution, but it makes the code safer.

@ekohl ekohl merged commit 4cd5729 into fog:master Dec 12, 2022
@ekohl ekohl deleted the deal-with-no-flags branch December 12, 2022 12:21
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.

None yet

2 participants