-
-
Notifications
You must be signed in to change notification settings - Fork 6
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
Add support for custom VMware attributes #31
base: master
Are you sure you want to change the base?
Conversation
The VMware API has options for custom attributes. This is often used to configure IP-Addresses or ssh keys inside of a VM. This code extension allows users to provide a hash with all required data.
I've no idea how to add tests for this, but I use this in production for two weeks and it works fine. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense. Just some style notes and some edge case.
additionalExtraConfig = if host['extraConfig'] | ||
host['extraConfig'].map do |key, value| | ||
{ key: key, value: value } | ||
end | ||
else | ||
[] | ||
end | ||
extraConfig = [{ key: 'guestinfo.hostname', value: host['vmhostname'] }] + additionalExtraConfig |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this easier to read?
additionalExtraConfig = if host['extraConfig'] | |
host['extraConfig'].map do |key, value| | |
{ key: key, value: value } | |
end | |
else | |
[] | |
end | |
extraConfig = [{ key: 'guestinfo.hostname', value: host['vmhostname'] }] + additionalExtraConfig | |
extraConfig = [{ key: 'guestinfo.hostname', value: host['vmhostname'] }] | |
if host['extraConfig'] | |
extraConfig += host['extraConfig'].map do |key, value| | |
{ key: key, value: value } | |
end | |
end |
I also wonder what happens if guestinfo.hostname
is in host['extraConfig']
.
Makes me tempted to write:
extraConfig = { 'guestinfo.hostname' => host['vmhostname'] }
extraConfig.merge(host['extraConfig']) if host['extraConfig']
And later:
extraConfig: extraConfig.map { |k, v| { key: k, value: v } }
@bastelfreak want to change it some more, or just merge it? |
The VMware API has options for custom attributes. This is often used to configure IP-Addresses or ssh keys inside of a VM. This code extension allows users to provide a hash with all required data.