hashicorp / packer-plugin-vagrant

Packer plugin for Vagrant
https://packer.io
Mozilla Public License 2.0
13 stars 24 forks source link

[vagrant-cloud post-processor] support for checksum and checksum_type when creating/updating providers #31

Closed dweomer closed 2 years ago

dweomer commented 2 years ago

Community Note

Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request. Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request. If you are interested in working on this issue or have submitted a pull request, please leave a comment.

Description

Would be great if this plugin supported the recently-ish added support for provider checksums.

Use Case(s)

I am trying to leverage the vagrant-cloud post-processor as part of my setup and find it a bit frustrating to perform extra steps for box upload (attaching the checksum info).

Potential configuration

type Provider struct {
    Name         string `json:"name"`
    Url          string `json:"url,omitempty"`
    HostedToken  string `json:"hosted_token,omitempty"`
    UploadUrl    string `json:"upload_url,omitempty"`
    Checksum     string `json:"checksum,omitempty"`
    ChecksumType string `json:"checksum_type,omitempty"`}

Potential References

Makr91 commented 1 year ago

Sorry if this was solved somewhere else, but I seem to be unable to get this to work.

When I add the Value:

"sha256:{$checksum}"

I get the right sha256 in the Checksum dropdowns, but the Checksum shows up as:

{$checksum}

Here is my Post-Processor's setup:

 "post-processors": [
    [
      {
        "output": "builds/{{.Provider}}/{{ user `distro` }}-{{ user `distro_version` }}-{{ user `cm` }}-{{ user `vm_type` }}-{{ user `version` }}.box",
        "vagrantfile_template": "tpl/vagrantfile-{{ user `distro` }}{{ user `short_distro_version` }}-{{ user `vm_type` }}.tpl",
        "type": "vagrant"
      },
      {
        "access_token": "{{ user `vagrant_cloud_token` }}",
        "box_tag": "{{ user `box_tag` }}",
        "no_direct_upload": true,
        "type": "vagrant-cloud",
        "version": "{{ user `version` }}",
        "box_checksum": "sha256:{$checksum}"
      },
      {
        "type": "manifest",
        "output": "dist/{{ user `distro` }}-{{ user `distro_version` }}-{{ user `cm` }}-{{ user `vm_type` }}-{{ user `version` }}-manifest.json",
        "strip_path": false
      }
    ]
  ],

Maybe I am missing whether or not I need to run the Checksum Post-Processor before hand? When I tried doing so it kept erroring out that it expected the .box artifact.

Can someone update the documentation to clarify if this value needs to be a variable of some sort or expects input from a previous post-processor? I am currently not sure how you can know the value of the hash in this setup before you run packer.

To be clear, this variable is acting as a function that (is/is not) calculating the checksums, and then adding that to the metadata.json via the vagrant-cloud api?

dweomer commented 1 year ago

Maybe I am missing whether or not I need to run the Checksum Post-Processor before hand? When I tried doing so it kept erroring out that it expected the .box artifact.

Yeah, this was how I got around it, IIRC:

There are ways to maker Packer do it all in a single pass but everything I came up with was super hacky.