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

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

Closed
drewmullen opened this issue Apr 9, 2024 · 3 comments

Comments

@drewmullen
Copy link

drewmullen commented Apr 9, 2024

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?

Copy link

github-actions bot commented Apr 9, 2024

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
Copy link
Author

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

Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant