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

packer-sdc plugin-check outputs cryptic error string: Version needs to be set #125

Open
mschuchard opened this issue Aug 22, 2022 · 2 comments
Labels
bug Something isn't working documentation Improvements or additions to documentation

Comments

@mschuchard
Copy link

When filing a bug, please include the following headings if possible. Any example text in this template can be deleted.

Overview of the Issue

Executing packer-sdc plugin-check <plugin binary> outputs the following error string:

2022/08/22 17:21:02 Version needs to be set

Although the packer-sdc documentation and usage has no information about this, and I saw no error message similar to this in the source code, I did notice there seems to be a potential secret requirement for plugins: a version/version.go file. This seemed like a possible fix. However, even after populating this file appropriately according to two other official plugins as a reference, the behavior did not deviate at all from the above. Thus, this behavior is unfortunately contrary to published documentation, usage, source code, and other official plugins as a reference.

I should also note the plugin currently passes acceptance testing with the latest version of Packer and the Packer SDK, so it should also conceivably pass the plugin-check too.

Reproduction Steps

packer-sdc plugin-check <plugin binary>

Packer Plugin SDK version

0.3.1

Operating system and Environment details

Ubuntu 22.04

Log Fragments and crash.log files

n/a

@mschuchard mschuchard added the bug Something isn't working label Aug 22, 2022
@mschuchard
Copy link
Author

Update that the plugin check also fails in goreleaser. I removed it from the hooks, and the released binaries install and behave completely correctly within a normal init/build workflow in Packer 1.7.10. This may help to debug, and also to further prove this error is a false positive.

@mschuchard
Copy link
Author

I figured this out eventually. The following is absent from documentation:

// version/version.go
package version

import "github.com/hashicorp/packer-plugin-sdk/version"

var (
  // Version is the main version number that is being run at the moment.
  Version = "1.2.0"

  // VersionPrerelease is A pre-release marker for the Version. If this is ""
  // (empty string) then it means that it is a final release. Otherwise, this
  // is a pre-release such as "dev" (in development), "beta", "rc1", etc.
  VersionPrerelease = ""

  // PluginVersion is used by the plugin set to allow Packer to recognize
  // what version this plugin is.
  PluginVersion = version.InitializePluginVersion(Version, VersionPrerelease)
)

// main.go
import "<module>/version"

func main() {
  ...
  packerPluginSet.SetVersion(version.PluginVersion)
}

This fixes the issue, so adding this information to the documentation would be sufficient here.

@nywilken nywilken added the documentation Improvements or additions to documentation label Jun 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants