-
Notifications
You must be signed in to change notification settings - Fork 458
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
main: Add -version #444
main: Add -version #444
Conversation
The Travis error was: $ go get github.com/golang/lint/golint
package github.com/golang/lint/golint: code in directory /home/travis/gopath/src/github.com/golang/lint/golint expects import "golang.org/x/lint/golint"
The command "go get github.com/golang/lint/golint" failed and exited with 1 during . which sounds like a flake. Is there a way I can kick the tests without pushing a commit with a different hash? |
You just click "Restart build" on the travis page for the build. I just did it for you. |
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.
i tend to like the PR but we need to consider 2 cases , and maybe this can add complexity (connecting to remote server this add the complexity imho
- in case we provide the plugin as rpm/deb
- in case we have a remote kvm-server and we need to take the version ( libvirt-go version and the hyperv version)
Mostly in case 2 would need a sort of ssh-mechanism to go to the host..
Imho we could add an helper
script not in main for retrieving the version.
We might also investigate how other Provider upstream do it ( AWS etc)
@wking nice to cu here again 👍 😸 🌹
i think we can retrieve all teh values with This change will not be backward compatible with other Version of the plugins but is imho a good thing to have ! thx |
This is even easier, since we'll get the commit information built in. As it stands, folks who
The environment variable discussed here should address this.
I don't think we need to go beyond an environment variable for the URI. If someone needs to SSH to libvirtd, they can use SSH to tunnel a port and then set the URI to the local side of the tunnel.
This would allow for drift between the two binaries. I'd much rather stick to a single binary.
As I mentioned in my initial comment, I'm not aware of a way for Terraform to collect info like this over RPC. I think it would be awesome if that existed, and it already may, but either way, this integration is beyond me ;). I dunno if the other providers will have much guidance, since they likely link statically (so no need to wonder "what library version were we dynamically linked to?"). And there's only the one AWS, or at least "which AWS?" does not seem to be configurable, so querying libvirt doesn't seem to have an analog. Maybe other providers have guidance, but I'm content to model |
With the default URI resolved, I think this is good to go again. If there are any remaining issues that I need to address, please let me know. |
@wking yop I agree with you there ! I wll check once I have time for that |
I've pushed #445 with a fix for the Travis golint issue. |
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.
@MalloZup does LDFLAGS += -X main.version=$$(git describe --always --abbrev=40 --dirty)
work when we build with the tarball generated by _service?
Yop good point, I need to check. |
Something like: make build
test "$(./terraform-provider-libvirt -version | head -n1 | cut -c,50)" = "./terraform-provider-libvirt v" in Travis? (I just guessed for the |
I would have a unit test for the printversion function, especially because if we will refactor in future the name of the var which depends, we mighr break this feature, so better a sinple test. Foe @dmacvicar the service file is used for build thea pkg so feel free to ignore it , we need to check, but is more release pkg task . For.typos sorry , my hand are bigger the mobile phone keyboard 😸 |
@wking we build here: https://build.opensuse.org/package/show/systemsmanagement:terraform/terraform-provider-libvirt And while the tarball is generated from git, it currently does not include the .git subdirectory |
I dunno what's going on there. But
It just needs to call |
_service runs a sequence of services: checkout git, create a tarball, and then set_version service updates the version in the _service file based on the git revision/parent tag. What we would need to do is to keep the last commit of .git inside the tarball, but I am not sure how to do that. I am sure others have done it already. Better to ask internally inside SUSE, somebody would know. |
Oh no, it is even easier, we just need to do:
in the spec files, as the service already replaced the version in the spec, and this one is available as a macro. It would not be the exact version format as if somebody runs make from the command line, but I'd prefer to adapt the later to follow the version format of the spec file. |
I did some experiments and |
@dmacvicar nice. imho would be safe also to add a unit-test before merging it. I don\t feel confortable adding features (especially command-line args) untested, especially if we depend for variables used/definitd in other files. Awesome 👍 |
and keeping the discussion further, i was thinking to put the SPEC files here in github, so contributors could modify if needed. ( we use the same mechanism uyuni) Could be this douable? what is your pov? |
The patch finally made it through moderation and landed on the list here. I'll follow-up here if/when that lands.
You'll want the leading $ git checkout v0.5.0
$ git describe --always --abbrev=40 --dirty
48adac309dc181faad7ccd87d52d5e004d5798ec Oh, wait. Are you not signing your tags (or not giving them messages)? If all the tags are lightweight, we'll need to use: $ git describe --always --abbrev=40 --dirty --tags
v0.5.0 So I think you want a And can we rely on future tags being signed (or having a message)? Or do I need to add |
Give callers an easy way to extract both the plugin version and the dependency versions. With this commit: $ ./terraform-provider-libvirt -version ./terraform-provider-libvirt 48adac3-dirty Compiled against library: libvirt 3.9.0 Using library: libvirt 3.9.0 Running hypervisor: QEMU 2.9.0 Running against daemon: 3.9.0 The details are very similar to: $ virsh version --daemon Compiled against library: libvirt 3.9.0 Using library: libvirt 3.9.0 Using API: QEMU 3.9.0 Running hypervisor: QEMU 2.9.0 Running against daemon: 3.9.0 except the Go bindings do not currently expose the API version [1]. I've submitted a patch to libvirt-go adding ParseVersion there. But until then, carrying our own parseVersion shouldn't be too much trouble. Passing an empty string to NewConnect ends up passing a nil pointer through to virConnect [2], which will give us libvirt's internal default URI logic [3,4]. I hunted around for a way to expose the version information in Terraform. Currently: $ cat main.tf provider "libvirt" { uri = "qemu:///system" } $ terraform version Terraform v0.11.8 + provider.libvirt (unversioned) but the RPC API is not particularly clear to me, and the versions there may be extracted from plugin filenames and not from RPC calls. [1]: https://libvirt.org/git/?p=libvirt-go.git;a=blob;f=connect.go;h=8cc7cc771f7d258400175df47fcc8b3779ef4930;hb=9c5bdce3c18faad94cb383e7ec42f5122a8c7fa1#l313 [2]: https://libvirt.org/git/?p=libvirt-go.git;a=blob;f=connect.go;h=8cc7cc771f7d258400175df47fcc8b3779ef4930;hb=9c5bdce3c18faad94cb383e7ec42f5122a8c7fa1#l322 [3]: https://libvirt.org/html/libvirt-libvirt-host.html#virConnectOpen [4]: https://libvirt.org/uri.html#URI_default
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.
💘
I am having problems updating the .spec file. For non-SUSE we are fine, as we build with plain go build -ldflags "-X main.version=%{version}" . But for SUSE we use the |
@dmacvicar we might don\t use the macro? |
Catching up with 91d0e45 (main: Add -version, 2018-10-11, dmacvicar#444).
Catching up with 91d0e45 (main: Add -version, 2018-10-11, dmacvicar#444).
Give callers an easy way to extract both the plugin version and the dependency versions. With this commit:
The details are very similar to:
except the Go bindings do not currently expose the API version. I've submitted a patch to libvirt-go adding
ParseVersion
there. But until then, carrying our ownparseVersion
shouldn't be too much trouble.I hunted around for a way to expose this in Terraform. Currently:
but the RPC API is not particularly clear to me, and the versions there may be extracted from plugin filenames and not from RPC calls.