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

Add support for custom VMware attributes #31

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bastelfreak
Copy link
Member

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.

@bastelfreak bastelfreak self-assigned this May 7, 2024
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.
@bastelfreak bastelfreak marked this pull request as ready for review May 21, 2024 08:01
@bastelfreak
Copy link
Member Author

I've no idea how to add tests for this, but I use this in production for two weeks and it works fine.

Copy link
Member

@ekohl ekohl left a 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.

Comment on lines +76 to +83
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
Copy link
Member

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?

Suggested change
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 } }

@TheMeier
Copy link

TheMeier commented Jun 2, 2024

@bastelfreak want to change it some more, or just merge it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants