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

feat: datasource for virtual machines #498

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

castorsky
Copy link

I have implemented one of datasources which was requested in #196.

This datasource searches the vSphere cluster for some VMs that matches specified filters and returns VM name for one (and only one) machine. I have chosen such behavior because it will be straightforward for vsphere-clone builder - there will be no need for user to manipulate lists in locals.

I have included some tests and documentation for datasource.

By strange coincidence issues for vSphere and Proxmox datasources share the same ID. =)

Partially closes #196

@castorsky castorsky requested a review from a team as a code owner December 5, 2024 01:56
@tenthirtyam tenthirtyam changed the title feature: datasource for virtual machines [issue 196] feat: datasource for virtual machines Dec 5, 2024
@tenthirtyam tenthirtyam self-requested a review December 5, 2024 02:27
@tenthirtyam tenthirtyam added this to the v1.5.0 milestone Dec 5, 2024
@tenthirtyam
Copy link
Collaborator

Thanks @castorsky. I’ll review this week.

docs/README.md Outdated Show resolved Hide resolved
Copy link
Collaborator

@tenthirtyam tenthirtyam left a comment

Choose a reason for hiding this comment

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

Thanks for this pull request - this is great to see and could be a basis for many additional data sources.

Added suggestions for changes along with other comments.

Let me know if you have any questions or concerns.

Ryan Johnson
Distinguished Engineer, VMware by Broadcom

@castorsky
Copy link
Author

castorsky commented Dec 6, 2024

Ryan, thank you for the very detailed review of my work. I will do my best to correct the plugin in the next few days.

@castorsky
Copy link
Author

@tenthirtyam, I rewrote the code as per your recommendations, with one exception: package virtual_machine was renamed to virtualmachine (not virtual-machine):

  • found that some other plugins use this naming style;
  • Go guidelines are against hyphens and underscores in package names;
  • to me, double hyphens in names look like two levels of nesting (in this case, they are not);

@tenthirtyam
Copy link
Collaborator

Awesome! I'll do another review early this week!

@tenthirtyam tenthirtyam force-pushed the feature/datasource-virtual_machine branch from 43f01ae to 24c8260 Compare December 8, 2024 19:57
Copy link
Collaborator

@tenthirtyam tenthirtyam left a comment

Choose a reason for hiding this comment

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

Question: Since tags can long pass more than one tag category and name, should it be represented as singular tag?

Also, it looks like a go fmt ./... is needed for the CI.

.web-docs/components/data-source/virtualmachine/README.md Outdated Show resolved Hide resolved
.web-docs/components/data-source/virtualmachine/README.md Outdated Show resolved Hide resolved
.web-docs/components/data-source/virtualmachine/README.md Outdated Show resolved Hide resolved
.web-docs/components/data-source/virtualmachine/README.md Outdated Show resolved Hide resolved
datasource/virtualmachine/data.go Outdated Show resolved Hide resolved
datasource/virtualmachine/data.go Outdated Show resolved Hide resolved
datasource/virtualmachine/data.go Outdated Show resolved Hide resolved
datasource/virtualmachine/data.go Show resolved Hide resolved
docs/datasources/virtualmachine.mdx Outdated Show resolved Hide resolved
@tenthirtyam tenthirtyam force-pushed the feature/datasource-virtual_machine branch from 24c8260 to 6894968 Compare December 9, 2024 16:13
@tenthirtyam
Copy link
Collaborator

Also, it looks like a go fmt ./... is needed for the CI.

I took care of the fmt on the last commit and the CI is good now.

@tenthirtyam tenthirtyam force-pushed the feature/datasource-virtual_machine branch 2 times, most recently from b571315 to 9c69cf3 Compare December 9, 2024 16:30
@tenthirtyam tenthirtyam self-requested a review December 9, 2024 16:31
@tenthirtyam
Copy link
Collaborator

Hi @castorsky 👋 - I've pushed updates to your branch with the requested changes from 2024-12-08. I'll do another review today and then plan to test the functionality along with Lucas.

@tenthirtyam tenthirtyam force-pushed the feature/datasource-virtual_machine branch 2 times, most recently from 0bca530 to fc85e56 Compare December 9, 2024 16:49
@tenthirtyam tenthirtyam dismissed their stale review December 9, 2024 16:51

Ready for next round of reviews.

- Made minor changes to documentation.
- Standard `errors` and `fmt` were used for custom errors.
- field `Node` was renamed to `Host`.
- field `VmTags` was renamed to `Tags`
- package `virtual_machine` was renamed to `virtualmachine`
- `driver` and `testing` were moved to `common` location
@tenthirtyam tenthirtyam force-pushed the feature/datasource-virtual_machine branch from fc85e56 to 6fdd994 Compare December 9, 2024 16:57
@castorsky
Copy link
Author

castorsky commented Dec 9, 2024

Hi @tenthirtyam! I agree with you about tag(s) field and renamed it. It was the network_adapters in the vsphere-iso builder that confused me. =)

And drop info about dynamic blocks in datasource.
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.

Add support for data sources
2 participants