hashicorp / packer

Packer is a tool for creating identical machine images for multiple platforms from a single source configuration.
http://www.packer.io
Other
15.03k stars 3.32k forks source link

[Plugin Development] How to run acc tests in VSCode to use advanced debugging features #12914

Closed drewmullen closed 4 months ago

drewmullen commented 4 months ago

This is my first time developing a Packer builder and I'm trying to debug an issue in my code. With Terraform Provider development I have a setup for vscode debuging which exposes runtime variables and allows me to declare break points, step into / over /out of functions, etc.

Using the below launch.json I can run a test in debug mode. However, its not finding my plugin:

2024/04/09 16:09:46 ui error: Error: Unknown source type harvester-img

  on ./harvester_builder_basic_test.pkr.hcl line 10:
  (source code not available)

known builders: [docker googlecompute virtualbox-ovf qemu amazon-ebssurrogate
amazon-ebs amazon-ebsvolume virtualbox-iso vagrant azure-dtl vsphere-clone
azure-chroot amazon-chroot file vsphere-iso vmware-iso vmware-vmx
amazon-instance null azure-arm virtualbox-vm]

Launch.json

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Launch a test function",
            "type": "go",
            "request": "launch",
            "mode": "auto",
            "program": "${fileDirname}",
            "env": { "PACKER_ACC": "true"}, 
            "args": [
                "-test.v",
                "-test.run",
                "^${selectedText}$"
            ],
            "showLog": true
        }
    ]
}

This seems to indicate to me that its looking for a pre-compiled binary... so if i add the PACKER_PLUGIN_PATH it can find the binary. HOWEVER, then its not actually using my source which means it doesnt respect break points...

            "env": { "PACKER_ACC": "true", "PACKER_PLUGIN_PATH": "${workspaceFolder}/"}, 

Yall have any idea how i can configure VSCode to compile this as part of the test run and use break points, etc?

github-actions[bot] commented 4 months ago
Hi 👋 thanks for reaching out.

For general questions we recommend reaching out to the [community forum](https://discuss.hashicorp.com/c/packer) for greater visibility.
As the GitHub issue tracker is only watched by a small subset of maintainers and is really reserved for bugs and enhancements, you'll have a better chance of finding someone who can help you in the forum.
We'll mark this issue as needs-reply to help inform maintainers that this question is awaiting a response.
If no activity is taken on this question within 30 days it will be automatically closed.

If you find the forum to be more helpful or if you've found the answer to your question elsewhere please feel free to post a response and close the issue.
drewmullen commented 4 months ago

After doing a few hours of research I am closing this issue and have opened a better scoped question on discuss: https://discuss.hashicorp.com/t/plugin-development-how-can-i-debug-my-step-functions/64796

github-actions[bot] commented 3 months ago

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.