Skip to content

Update provider to use explicitly version v0.1.0#10

Merged
gabriel-samfira merged 1 commit intocloudbase:mainfrom
fabi200123:set-version-v0.1.0
Sep 13, 2024
Merged

Update provider to use explicitly version v0.1.0#10
gabriel-samfira merged 1 commit intocloudbase:mainfrom
fabi200123:set-version-v0.1.0

Conversation

@fabi200123
Copy link
Contributor

  • Update the provider to use version v0.1.0 explicitly

provider/lxd.go Outdated

var _ execution.ExternalProvider = &LXD{}

var version = "v0.1.0"
Copy link
Member

Choose a reason for hiding this comment

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

This is not the interface version. This is the provider version.... The GetVersion() command gets the provider version. Not the interface version.

This needs to be 0.0.0-unknown by default. This will then be set by:

-ldflags "-extldflags '-static' -s -w -X main.Version=$VERSION" .

which also needs to be updated to no longer try to set the Version in main.go.

Also, this variable must be exported.

provider/lxd.go Outdated

// GetVersion returns the interface version of the provider.
func (l *LXD) GetVersion(ctx context.Context) string {
fmt.Println(version)
Copy link
Member

Choose a reason for hiding this comment

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

This doesn't feel right. We either return a string or just print it, but not both. This function gets called in garm-provider-common here:

https://github.com/cloudbase/garm-provider-common/blob/899c120c80ce01a42e94cc2319e1e1df6407e4ff/execution/v0.1.0/execution.go#L159-L161

Which in turn gets used by the provider here:

result, err := execution.Run(ctx, prov, executionEnv)

the result of which is printed here:

if len(result) > 0 {
fmt.Fprint(os.Stdout, result)
}

if you test these changes with:

GARM_COMMAND="GetVersion" ./garm-provider-lxd

you will most likely get the version printed twice.

@gabriel-samfira gabriel-samfira merged commit 1130dc9 into cloudbase:main Sep 13, 2024
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.

2 participants