From 8cf9cb32a7e402874c14ee68b851f8440f5a71a7 Mon Sep 17 00:00:00 2001 From: Ryan Johnson Date: Thu, 13 Jun 2024 03:01:43 +0000 Subject: [PATCH] backport of commit 71c1afa767e2db8fafef8885e222b70438464764 --- .github/workflows/acceptance-test.yml | 6 +- .github/workflows/build.yml | 16 +- .github/workflows/create-release-branch.yml | 2 +- .github/workflows/go-test.yml | 14 +- .github/workflows/go-validate.yml | 18 +- .github/workflows/issue-comment-created.yml | 2 +- .github/workflows/issues-opened.yml | 2 +- .github/workflows/nightly-release.yml | 2 +- builder/file/version/version.go | 4 +- builder/null/version/version.go | 4 +- packer/plugin_discover_test.go | 2 +- packer_test/base_test.go | 36 -- packer_test/commands_test.go | 118 ----- packer_test/gadgets_test.go | 170 ------- packer_test/init_test.go | 74 --- packer_test/install_test.go | 100 ---- packer_test/loading_test.go | 239 --------- packer_test/pipe_checker_test.go | 247 --------- packer_test/plugin_test.go | 333 ------------ packer_test/plugin_tester/LICENSE | 375 -------------- packer_test/plugin_tester/README.md | 5 - .../plugin_tester/builder/dynamic/artifact.go | 35 -- .../plugin_tester/builder/dynamic/builder.go | 92 ---- .../builder/dynamic/builder.hcl2spec.go | 95 ---- .../builder/dynamic/builder_acc_test.go | 60 --- .../builder/dynamic/step_say_config.go | 39 -- .../dynamic/test-fixtures/template.pkr.hcl | 18 - .../plugin_tester/datasource/dynamic/data.go | 66 --- .../datasource/dynamic/data.hcl2spec.go | 102 ---- .../datasource/dynamic/data_acc_test.go | 65 --- .../dynamic/test-fixtures/template.pkr.hcl | 28 - .../plugin_tester/datasource/parrot/data.go | 52 -- .../datasource/parrot/data.hcl2spec.go | 54 -- .../plugin_tester/datasource/sleeper/data.go | 63 --- .../datasource/sleeper/data.hcl2spec.go | 54 -- packer_test/plugin_tester/docs/README.md | 78 --- .../docs/builders/builder-name.mdx | 63 --- .../docs/datasources/datasource-name.mdx | 78 --- .../post-processors/postprocessor-name.mdx | 59 --- .../docs/provisioners/provisioner-name.mdx | 62 --- packer_test/plugin_tester/example/README.md | 20 - .../plugin_tester/example/build.pkr.hcl | 43 -- .../plugin_tester/example/data.pkr.hcl | 6 - .../plugin_tester/example/variables.pkr.hcl | 7 - packer_test/plugin_tester/go.mod | 97 ---- packer_test/plugin_tester/go.sum | 480 ------------------ packer_test/plugin_tester/main.go | 34 -- .../post-processor/dynamic/post-processor.go | 62 --- .../dynamic/post-processor.hcl2spec.go | 79 --- .../dynamic/post-processor_acc_test.go | 60 --- .../dynamic/test-fixtures/template.pkr.hcl | 16 - .../provisioner/dynamic/provisioner.go | 64 --- .../dynamic/provisioner.hcl2spec.go | 79 --- .../dynamic/provisioner_acc_test.go | 60 --- .../dynamic/test-fixtures/template.pkr.hcl | 16 - packer_test/plugin_tester/version/version.go | 26 - packer_test/plugins_remove_test.go | 180 ------- packer_test/sample_config.json | 7 - packer_test/suite_test.go | 83 --- packer_test/templates/init/hashicups.pkr.hcl | 9 - .../templates/init/mixed_versions.pkr.hcl | 9 - packer_test/templates/init/non_gh.pkr.hcl | 14 - packer_test/templates/pin_1.0.9.pkr.hcl | 14 - .../templates/pre-release_constraint.pkr.hcl | 14 - packer_test/templates/simple.json | 6 - packer_test/templates/simple.pkr.hcl | 14 - post-processor/artifice/version/version.go | 4 +- post-processor/checksum/version/version.go | 4 +- post-processor/compress/benchmark.go | 4 +- post-processor/compress/version/version.go | 4 +- post-processor/manifest/version/version.go | 4 +- post-processor/shell-local/version/version.go | 4 +- provisioner/breakpoint/version/version.go | 4 +- provisioner/file/version/version.go | 4 +- provisioner/powershell/version/version.go | 4 +- provisioner/shell-local/version/version.go | 4 +- provisioner/shell/version/version.go | 4 +- provisioner/sleep/version/version.go | 4 +- .../windows-restart/version/version.go | 4 +- provisioner/windows-shell/version/version.go | 4 +- version/VERSION | 2 +- website/content/docs/commands/init.mdx | 26 +- .../communicator/SSH-not-required.mdx | 2 +- 83 files changed, 89 insertions(+), 4428 deletions(-) delete mode 100644 packer_test/base_test.go delete mode 100644 packer_test/commands_test.go delete mode 100644 packer_test/gadgets_test.go delete mode 100644 packer_test/init_test.go delete mode 100644 packer_test/install_test.go delete mode 100644 packer_test/loading_test.go delete mode 100644 packer_test/pipe_checker_test.go delete mode 100644 packer_test/plugin_test.go delete mode 100644 packer_test/plugin_tester/LICENSE delete mode 100644 packer_test/plugin_tester/README.md delete mode 100644 packer_test/plugin_tester/builder/dynamic/artifact.go delete mode 100644 packer_test/plugin_tester/builder/dynamic/builder.go delete mode 100644 packer_test/plugin_tester/builder/dynamic/builder.hcl2spec.go delete mode 100644 packer_test/plugin_tester/builder/dynamic/builder_acc_test.go delete mode 100644 packer_test/plugin_tester/builder/dynamic/step_say_config.go delete mode 100644 packer_test/plugin_tester/builder/dynamic/test-fixtures/template.pkr.hcl delete mode 100644 packer_test/plugin_tester/datasource/dynamic/data.go delete mode 100644 packer_test/plugin_tester/datasource/dynamic/data.hcl2spec.go delete mode 100644 packer_test/plugin_tester/datasource/dynamic/data_acc_test.go delete mode 100644 packer_test/plugin_tester/datasource/dynamic/test-fixtures/template.pkr.hcl delete mode 100644 packer_test/plugin_tester/datasource/parrot/data.go delete mode 100644 packer_test/plugin_tester/datasource/parrot/data.hcl2spec.go delete mode 100644 packer_test/plugin_tester/datasource/sleeper/data.go delete mode 100644 packer_test/plugin_tester/datasource/sleeper/data.hcl2spec.go delete mode 100644 packer_test/plugin_tester/docs/README.md delete mode 100644 packer_test/plugin_tester/docs/builders/builder-name.mdx delete mode 100644 packer_test/plugin_tester/docs/datasources/datasource-name.mdx delete mode 100644 packer_test/plugin_tester/docs/post-processors/postprocessor-name.mdx delete mode 100644 packer_test/plugin_tester/docs/provisioners/provisioner-name.mdx delete mode 100644 packer_test/plugin_tester/example/README.md delete mode 100644 packer_test/plugin_tester/example/build.pkr.hcl delete mode 100644 packer_test/plugin_tester/example/data.pkr.hcl delete mode 100644 packer_test/plugin_tester/example/variables.pkr.hcl delete mode 100644 packer_test/plugin_tester/go.mod delete mode 100644 packer_test/plugin_tester/go.sum delete mode 100644 packer_test/plugin_tester/main.go delete mode 100644 packer_test/plugin_tester/post-processor/dynamic/post-processor.go delete mode 100644 packer_test/plugin_tester/post-processor/dynamic/post-processor.hcl2spec.go delete mode 100644 packer_test/plugin_tester/post-processor/dynamic/post-processor_acc_test.go delete mode 100644 packer_test/plugin_tester/post-processor/dynamic/test-fixtures/template.pkr.hcl delete mode 100644 packer_test/plugin_tester/provisioner/dynamic/provisioner.go delete mode 100644 packer_test/plugin_tester/provisioner/dynamic/provisioner.hcl2spec.go delete mode 100644 packer_test/plugin_tester/provisioner/dynamic/provisioner_acc_test.go delete mode 100644 packer_test/plugin_tester/provisioner/dynamic/test-fixtures/template.pkr.hcl delete mode 100644 packer_test/plugin_tester/version/version.go delete mode 100644 packer_test/plugins_remove_test.go delete mode 100644 packer_test/sample_config.json delete mode 100644 packer_test/suite_test.go delete mode 100644 packer_test/templates/init/hashicups.pkr.hcl delete mode 100644 packer_test/templates/init/mixed_versions.pkr.hcl delete mode 100644 packer_test/templates/init/non_gh.pkr.hcl delete mode 100644 packer_test/templates/pin_1.0.9.pkr.hcl delete mode 100644 packer_test/templates/pre-release_constraint.pkr.hcl delete mode 100644 packer_test/templates/simple.json delete mode 100644 packer_test/templates/simple.pkr.hcl diff --git a/.github/workflows/acceptance-test.yml b/.github/workflows/acceptance-test.yml index 05746ba078d..126b751d060 100644 --- a/.github/workflows/acceptance-test.yml +++ b/.github/workflows/acceptance-test.yml @@ -19,7 +19,7 @@ jobs: outputs: go-version: ${{ steps.get-go-version.outputs.go-version }} steps: - - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 - name: 'Determine Go version' id: get-go-version # We use .go-version as our source of truth for current Go @@ -40,8 +40,8 @@ jobs: # Packer GH Token for API Rate Limiting PACKER_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} steps: - - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 - - uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1 + - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 + - uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 with: go-version: ${{ needs.get-go-version.outputs.go-version }} - name: IAM Assume Role diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index dd066fd0f72..93c52d1757f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -26,7 +26,7 @@ jobs: outputs: go-version: ${{ steps.get-go-version.outputs.go-version }} steps: - - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 - name: 'Determine Go version' id: get-go-version # We use .go-version as our source of truth for current Go @@ -44,7 +44,7 @@ jobs: product-prerelease-version: ${{ steps.set-product-version.outputs.prerelease-product-version }} set-ld-flags: ${{ steps.set-ld-flags.outputs.set-ld-flags }} steps: - - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 - name: set product version id: set-product-version uses: hashicorp/actions-set-product-version@v1 @@ -67,7 +67,7 @@ jobs: filepath: ${{ steps.generate-metadata-file.outputs.filepath }} steps: - name: 'Checkout directory' - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 - name: Generate metadata file id: generate-metadata-file uses: hashicorp/actions-generate-metadata@main @@ -105,7 +105,7 @@ jobs: GOPRIVATE: "github.com/hashicorp" GO111MODULE: on steps: - - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 - name: Go Build env: PRODUCT_VERSION: ${{ needs.set-product-version.outputs.product-version }} @@ -143,7 +143,7 @@ jobs: GO111MODULE: on steps: - - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 - name: Go Build env: PRODUCT_VERSION: ${{ needs.set-product-version.outputs.product-version }} @@ -213,7 +213,7 @@ jobs: GO111MODULE: on steps: - - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 - name: Go Build env: PRODUCT_VERSION: ${{ needs.set-product-version.outputs.product-version }} @@ -244,7 +244,7 @@ jobs: env: version: ${{ needs.set-product-version.outputs.product-version }} steps: - - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 - name: Docker Build (Action) uses: hashicorp/actions-docker-build@v2 with: @@ -274,7 +274,7 @@ jobs: env: version: ${{ needs.set-product-version.outputs.product-version }} steps: - - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 - name: Docker Build (Action) uses: hashicorp/actions-docker-build@v2 with: diff --git a/.github/workflows/create-release-branch.yml b/.github/workflows/create-release-branch.yml index 6dbbd711ff9..8eb406e3acf 100644 --- a/.github/workflows/create-release-branch.yml +++ b/.github/workflows/create-release-branch.yml @@ -4,7 +4,7 @@ jobs: create-branch: runs-on: ubuntu-latest steps: - - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 - uses: hashicorp/actions-create-release-branch@v1 with: token: ${{ secrets.ELEVATED_GITHUB_TOKEN }} diff --git a/.github/workflows/go-test.yml b/.github/workflows/go-test.yml index b58feb1220c..d9da6ff7469 100644 --- a/.github/workflows/go-test.yml +++ b/.github/workflows/go-test.yml @@ -24,7 +24,7 @@ jobs: outputs: go-version: ${{ steps.get-go-version.outputs.go-version }} steps: - - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 - name: 'Determine Go version' id: get-go-version run: | @@ -36,8 +36,8 @@ jobs: runs-on: ubuntu-latest name: Linux go tests steps: - - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 - - uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1 + - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 + - uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 with: go-version: ${{ needs.get-go-version.outputs.go-version }} - run: TESTARGS="-coverprofile=coverage.txt -covermode=atomic" make ci @@ -47,8 +47,8 @@ jobs: runs-on: macos-latest name: Darwin go tests steps: - - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 - - uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1 + - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 + - uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 with: go-version: ${{ needs.get-go-version.outputs.go-version }} - run: go test ./... -coverprofile=coverage.txt -covermode=atomic @@ -58,8 +58,8 @@ jobs: runs-on: windows-latest name: Windows go tests steps: - - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 - - uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1 + - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 + - uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 with: go-version: ${{ needs.get-go-version.outputs.go-version }} - run: go test ./... -coverprofile=coverage.txt -covermode=atomic diff --git a/.github/workflows/go-validate.yml b/.github/workflows/go-validate.yml index 008907cd43e..a6264a7d1c0 100644 --- a/.github/workflows/go-validate.yml +++ b/.github/workflows/go-validate.yml @@ -20,7 +20,7 @@ jobs: outputs: go-version: ${{ steps.get-go-version.outputs.go-version }} steps: - - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 - name: 'Determine Go version' id: get-go-version run: | @@ -32,8 +32,8 @@ jobs: runs-on: ubuntu-latest name: Go Mod Tidy steps: - - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 - - uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1 + - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 + - uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 with: go-version: ${{ needs.get-go-version.outputs.go-version }} - run: go mod tidy @@ -43,10 +43,10 @@ jobs: runs-on: ubuntu-latest name: Lint steps: - - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 with: fetch-depth: 0 - - uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1 + - uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 with: go-version: ${{ needs.get-go-version.outputs.go-version }} - run: echo "$GITHUB_SHA" @@ -59,8 +59,8 @@ jobs: runs-on: ubuntu-latest name: Fmt check steps: - - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 - - uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1 + - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 + - uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 with: go-version: ${{ needs.get-go-version.outputs.go-version }} - run: make fmt-check @@ -70,8 +70,8 @@ jobs: runs-on: ubuntu-latest name: Generate check steps: - - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 - - uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1 + - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 + - uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 with: go-version: ${{ needs.get-go-version.outputs.go-version }} - run: make generate-check diff --git a/.github/workflows/issue-comment-created.yml b/.github/workflows/issue-comment-created.yml index ce993807c0c..a74693b7178 100644 --- a/.github/workflows/issue-comment-created.yml +++ b/.github/workflows/issue-comment-created.yml @@ -15,7 +15,7 @@ jobs: if: ${{contains(github.event.issue.labels.*.name, 'waiting-reply') || contains(github.event.issue.labels.*.name, 'stale')}} runs-on: ubuntu-latest steps: - - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 - uses: actions-ecosystem/action-remove-labels@2ce5d41b4b6aa8503e285553f75ed56e0a40bae0 # v1.3.0 with: github_token: "${{ secrets.GITHUB_TOKEN }}" diff --git a/.github/workflows/issues-opened.yml b/.github/workflows/issues-opened.yml index 43b6aa78e6b..b3894b9082f 100644 --- a/.github/workflows/issues-opened.yml +++ b/.github/workflows/issues-opened.yml @@ -13,7 +13,7 @@ jobs: issues: write # for github/issue-labeler to create or remove labels runs-on: ubuntu-latest steps: - - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 - uses: github/issue-labeler@c1b0f9f52a63158c4adc09425e858e87b32e9685 # v3.4 with: repo-token: "${{ secrets.GITHUB_TOKEN }}" diff --git a/.github/workflows/nightly-release.yml b/.github/workflows/nightly-release.yml index bffc6da67e5..6a1696da0b8 100644 --- a/.github/workflows/nightly-release.yml +++ b/.github/workflows/nightly-release.yml @@ -24,7 +24,7 @@ jobs: needs: build-artifacts runs-on: ubuntu-latest steps: - - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 - name: Download built artifacts uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7 with: diff --git a/builder/file/version/version.go b/builder/file/version/version.go index 2620294cdca..2136829ae88 100644 --- a/builder/file/version/version.go +++ b/builder/file/version/version.go @@ -11,6 +11,6 @@ import ( var FilePluginVersion *version.PluginVersion func init() { - FilePluginVersion = version.NewPluginVersion( - packerVersion.Version, packerVersion.VersionPrerelease, packerVersion.VersionMetadata) + FilePluginVersion = version.InitializePluginVersion( + packerVersion.Version, packerVersion.VersionPrerelease) } diff --git a/builder/null/version/version.go b/builder/null/version/version.go index 47547b80609..27e53e312d1 100644 --- a/builder/null/version/version.go +++ b/builder/null/version/version.go @@ -11,6 +11,6 @@ import ( var NullPluginVersion *version.PluginVersion func init() { - NullPluginVersion = version.NewPluginVersion( - packerVersion.Version, packerVersion.VersionPrerelease, packerVersion.VersionMetadata) + NullPluginVersion = version.InitializePluginVersion( + packerVersion.Version, packerVersion.VersionPrerelease) } diff --git a/packer/plugin_discover_test.go b/packer/plugin_discover_test.go index 2098d07bdb0..de50136cdc8 100644 --- a/packer/plugin_discover_test.go +++ b/packer/plugin_discover_test.go @@ -306,7 +306,7 @@ func TestHelperPlugins(t *testing.T) { for _, mock := range allMocks { plugin, found := mock[pluginName] if found { - plugin.SetVersion(version.NewPluginVersion("1.0.0", "", "")) + plugin.SetVersion(version.InitializePluginVersion("1.0.0", "")) err := plugin.RunCommand(args...) if err != nil { fmt.Fprintf(os.Stderr, "%v\n", err) diff --git a/packer_test/base_test.go b/packer_test/base_test.go deleted file mode 100644 index 4fe675d3158..00000000000 --- a/packer_test/base_test.go +++ /dev/null @@ -1,36 +0,0 @@ -package packer_test - -import ( - "fmt" - "math/rand" - "os" - "os/exec" - "path/filepath" - "runtime" - "testing" -) - -// BuildTestPacker builds a new Packer binary based on the current state of the repository. -// -// If for some reason the binary cannot be built, we will immediately exit with an error. -func BuildTestPacker(t *testing.T) (string, error) { - testDir, err := currentDir() - if err != nil { - return "", fmt.Errorf("failed to compile packer binary: %s", err) - } - - packerCoreDir := filepath.Dir(testDir) - - outBin := filepath.Join(os.TempDir(), fmt.Sprintf("packer_core-%d", rand.Int())) - if runtime.GOOS == "windows" { - outBin = fmt.Sprintf("%s.exe", outBin) - } - - compileCommand := exec.Command("go", "build", "-C", packerCoreDir, "-o", outBin) - logs, err := compileCommand.CombinedOutput() - if err != nil { - t.Fatalf("failed to compile Packer core: %s\ncompilation logs: %s", err, logs) - } - - return outBin, nil -} diff --git a/packer_test/commands_test.go b/packer_test/commands_test.go deleted file mode 100644 index 8f6beb7e5e4..00000000000 --- a/packer_test/commands_test.go +++ /dev/null @@ -1,118 +0,0 @@ -package packer_test - -import ( - "fmt" - "os" - "os/exec" - "strings" - "sync" - "testing" -) - -type packerCommand struct { - once sync.Once - packerPath string - args []string - env map[string]string - stderr *strings.Builder - stdout *strings.Builder - workdir string - err error - t *testing.T -} - -// PackerCommand creates a skeleton of packer command with the ability to execute gadgets on the outputs of the command. -func (ts *PackerTestSuite) PackerCommand() *packerCommand { - stderr := &strings.Builder{} - stdout := &strings.Builder{} - - return &packerCommand{ - packerPath: ts.packerPath, - env: map[string]string{ - "PACKER_LOG": "1", - // Required for Windows, otherwise since we overwrite all - // the envvars for the test and Go relies on that envvar - // being set in order to return another path than - // C:\Windows by default - // - // If we don't have it, Packer immediately errors upon - // invocation as the temporary logfile that we write in - // case of Panic will fail to be created (unless tests - // are running as Administrator, but please don't). - "TMP": os.TempDir(), - }, - stderr: stderr, - stdout: stdout, - t: ts.T(), - } -} - -// NoVerbose removes the `PACKER_LOG=1` environment variable from the command -func (pc *packerCommand) NoVerbose() *packerCommand { - _, ok := pc.env["PACKER_LOG"] - if ok { - delete(pc.env, "PACKER_LOG") - } - return pc -} - -// SetWD changes the directory Packer is invoked from -func (pc *packerCommand) SetWD(dir string) *packerCommand { - pc.workdir = dir - return pc -} - -// UsePluginDir sets the plugin directory in the environment to `dir` -func (pc *packerCommand) UsePluginDir(dir string) *packerCommand { - return pc.AddEnv("PACKER_PLUGIN_PATH", dir) -} - -func (pc *packerCommand) SetArgs(args ...string) *packerCommand { - pc.args = args - return pc -} - -func (pc *packerCommand) AddEnv(key, val string) *packerCommand { - pc.env[key] = val - return pc -} - -// Run executes the packer command with the args/env requested and returns the -// output streams (stdout, stderr) -// -// Note: "Run" will only execute the command once, and return the streams and -// error from the only execution for every subsequent call -func (pc *packerCommand) Run() (string, string, error) { - pc.once.Do(pc.doRun) - - return pc.stdout.String(), pc.stderr.String(), pc.err -} - -func (pc *packerCommand) doRun() { - cmd := exec.Command(pc.packerPath, pc.args...) - for key, val := range pc.env { - cmd.Env = append(cmd.Env, fmt.Sprintf("%s=%s", key, val)) - } - cmd.Stdout = pc.stdout - cmd.Stderr = pc.stderr - - if pc.workdir != "" { - cmd.Dir = pc.workdir - } - - pc.err = cmd.Run() -} - -func (pc *packerCommand) Assert(checks ...Checker) { - stdout, stderr, err := pc.Run() - - checks = append(checks, PanicCheck{}) - - for _, check := range checks { - checkErr := check.Check(stdout, stderr, err) - if checkErr != nil { - checkerName := InferName(check) - pc.t.Errorf("check %q failed: %s", checkerName, checkErr) - } - } -} diff --git a/packer_test/gadgets_test.go b/packer_test/gadgets_test.go deleted file mode 100644 index 3ddd29e55a3..00000000000 --- a/packer_test/gadgets_test.go +++ /dev/null @@ -1,170 +0,0 @@ -package packer_test - -import ( - "fmt" - "reflect" - "strings" - "testing" -) - -type Stream int - -const ( - // BothStreams will use both stdout and stderr for performing a check - BothStreams Stream = iota - // OnlyStdout will only use stdout for performing a check - OnlyStdout - // OnlySterr will only use stderr for performing a check - OnlyStderr -) - -func (s Stream) String() string { - switch s { - case BothStreams: - return "Both streams" - case OnlyStdout: - return "Stdout" - case OnlyStderr: - return "Stderr" - } - - panic(fmt.Sprintf("Unknown stream value: %d", s)) -} - -// Checker represents anything that can be used in conjunction with Assert. -// -// The role of a checker is performing a test on a command's outputs/error, and -// return an error if the test fails. -// -// Note: the Check method is the only required, however during tests the name -// of the checker is printed out in case it fails, so it may be useful to have -// a custom string for this: the `Name() string` method is exactly what to -// implement for this kind of customization. -type Checker interface { - Check(stdout, stderr string, err error) error -} - -func InferName(c Checker) string { - if c == nil { - panic("nil checker - malformed test?") - } - - checkerType := reflect.TypeOf(c) - _, ok := checkerType.MethodByName("Name") - if !ok { - return checkerType.String() - } - - retVals := reflect.ValueOf(c).MethodByName("Name").Call([]reflect.Value{}) - if len(retVals) != 1 { - panic(fmt.Sprintf("Name function called - returned %d values. Must be one string only.", len(retVals))) - } - - return retVals[0].String() -} - -func MustSucceed() Checker { - return mustSucceed{} -} - -type mustSucceed struct{} - -func (_ mustSucceed) Check(stdout, stderr string, err error) error { - return err -} - -func MustFail() Checker { - return mustFail{} -} - -type mustFail struct{} - -func (_ mustFail) Check(stdout, stderr string, err error) error { - if err == nil { - return fmt.Errorf("unexpected command success") - } - return nil -} - -type grepOpts int - -const ( - // Invert the check, i.e. by default an empty grep fails, if this is set, a non-empty grep fails - grepInvert grepOpts = iota - // Only grep stderr - grepStderr - // Only grep stdout - grepStdout -) - -// Grep returns a checker that performs a regexp match on the command's output and returns an error if it failed -// -// Note: by default both streams will be checked by the grep -func Grep(expression string, opts ...grepOpts) Checker { - pc := PipeChecker{ - name: fmt.Sprintf("command | grep -E %q", expression), - stream: BothStreams, - pipers: []Pipe{ - PipeGrep(expression), - }, - check: ExpectNonEmptyInput(), - } - for _, opt := range opts { - switch opt { - case grepInvert: - pc.check = ExpectEmptyInput() - case grepStderr: - pc.stream = OnlyStderr - case grepStdout: - pc.stream = OnlyStdout - } - } - return pc -} - -type Dump struct { - t *testing.T -} - -func (d Dump) Check(stdout, stderr string, err error) error { - d.t.Logf("Dumping command result.") - d.t.Logf("Stdout: %s", stdout) - d.t.Logf("stderr: %s", stderr) - return nil -} - -type PanicCheck struct{} - -func (_ PanicCheck) Check(stdout, stderr string, _ error) error { - if strings.Contains(stdout, "= PACKER CRASH =") || strings.Contains(stderr, "= PACKER CRASH =") { - return fmt.Errorf("packer has crashed: this is never normal and should be investigated") - } - return nil -} - -// CustomCheck is meant to be a one-off checker with a user-provided function. -// -// Use this if none of the existing checkers match your use case, and it is not -// reusable/generic enough for use in other tests. -type CustomCheck struct { - name string - checkFunc func(stdout, stderr string, err error) error -} - -func (c CustomCheck) Check(stdout, stderr string, err error) error { - return c.checkFunc(stdout, stderr, err) -} - -func (c CustomCheck) Name() string { - return fmt.Sprintf("custom check - %s", c.name) -} - -// LineCountCheck builds a pipe checker to count the number of lines on stdout by default -// -// To change the stream(s) on which to perform the check, you can call SetStream on the -// returned pipe checker. -func LineCountCheck(lines int) *PipeChecker { - return MkPipeCheck(fmt.Sprintf("line count (%d)", lines), LineCount()). - SetTester(IntCompare(eq, lines)). - SetStream(OnlyStdout) -} diff --git a/packer_test/init_test.go b/packer_test/init_test.go deleted file mode 100644 index 6a9196a9439..00000000000 --- a/packer_test/init_test.go +++ /dev/null @@ -1,74 +0,0 @@ -package packer_test - -func (ts *PackerTestSuite) TestPackerInitForce() { - pluginPath, cleanup := ts.MakePluginDir() - defer cleanup() - - ts.Run("installs any missing plugins", func() { - ts.PackerCommand().UsePluginDir(pluginPath). - SetArgs("init", "--force", "./templates/init/hashicups.pkr.hcl"). - Assert(MustSucceed(), Grep("Installed plugin github.com/hashicorp/hashicups v1.0.2", grepStdout)) - }) - - ts.Run("reinstalls plugins matching version constraints", func() { - ts.PackerCommand().UsePluginDir(pluginPath). - SetArgs("init", "--force", "./templates/init/hashicups.pkr.hcl"). - Assert(MustSucceed(), Grep("Installed plugin github.com/hashicorp/hashicups v1.0.2", grepStdout)) - }) -} - -func (ts *PackerTestSuite) TestPackerInitUpgrade() { - pluginPath, cleanup := ts.MakePluginDir() - defer cleanup() - - cmd := ts.PackerCommand().UsePluginDir(pluginPath) - cmd.SetArgs("plugins", "install", "github.com/hashicorp/hashicups", "1.0.1") - cmd.Assert(MustSucceed(), Grep("Installed plugin github.com/hashicorp/hashicups v1.0.1", grepStdout)) - - _, _, err := cmd.Run() - if err != nil { - ts.T().Fatalf("packer plugins install failed to install previous version of hashicups: %q", err) - } - - ts.Run("upgrades a plugin to the latest matching version constraints", func() { - ts.PackerCommand().UsePluginDir(pluginPath). - SetArgs("init", "--upgrade", "./templates/init/hashicups.pkr.hcl"). - Assert(MustSucceed(), Grep("Installed plugin github.com/hashicorp/hashicups v1.0.2", grepStdout)) - }) -} - -func (ts *PackerTestSuite) TestPackerInitWithNonGithubSource() { - pluginPath, cleanup := ts.MakePluginDir() - defer cleanup() - - ts.Run("try installing from a non-github source, should fail", func() { - ts.PackerCommand().UsePluginDir(pluginPath). - SetArgs("init", "./templates/init/non_gh.pkr.hcl"). - Assert(MustFail(), Grep(`doesn't appear to be a valid "github.com" source address`, grepStdout)) - }) - - ts.Run("manually install plugin to the expected source", func() { - ts.PackerCommand().UsePluginDir(pluginPath). - SetArgs("plugins", "install", "--path", BuildSimplePlugin("1.0.10", ts.T()), "hubgit.com/hashicorp/tester"). - Assert(MustSucceed(), Grep("packer-plugin-tester_v1.0.10", grepStdout)) - }) - - ts.Run("re-run packer init on same template, should succeed silently", func() { - ts.PackerCommand().UsePluginDir(pluginPath). - SetArgs("init", "./templates/init/non_gh.pkr.hcl"). - Assert(MustSucceed(), - MkPipeCheck("no output in stdout").SetTester(ExpectEmptyInput()).SetStream(OnlyStdout)) - }) -} - -func (ts *PackerTestSuite) TestPackerInitWithMixedVersions() { - pluginPath, cleanup := ts.MakePluginDir() - defer cleanup() - - ts.Run("skips the plugin installation with mixed versions before exiting with an error", func() { - ts.PackerCommand().UsePluginDir(pluginPath). - SetArgs("init", "./templates/init/mixed_versions.pkr.hcl"). - Assert(MustFail(), - Grep("binary reported a pre-release version of 10.7.3-dev", grepStdout)) - }) -} diff --git a/packer_test/install_test.go b/packer_test/install_test.go deleted file mode 100644 index 1f039b51ef3..00000000000 --- a/packer_test/install_test.go +++ /dev/null @@ -1,100 +0,0 @@ -package packer_test - -func (ts *PackerTestSuite) TestInstallPluginWithMetadata() { - tempPluginDir, cleanup := ts.MakePluginDir() - defer cleanup() - - ts.Run("install plugin with metadata in version", func() { - ts.PackerCommand().UsePluginDir(tempPluginDir). - SetArgs("plugins", "install", "--path", BuildSimplePlugin("1.0.0+metadata", ts.T()), "github.com/hashicorp/tester"). - Assert(MustSucceed(), Grep("Successfully installed plugin", grepStdout)) - }) - - ts.Run("metadata plugin installed must not have metadata in its path", func() { - ts.PackerCommand().UsePluginDir(tempPluginDir). - SetArgs("plugins", "installed"). - Assert(MustSucceed(), Grep("packer-plugin-tester_v1.0.0[^+]", grepStdout)) - }) - - ts.Run("plugin with metadata should work with validate", func() { - ts.PackerCommand().UsePluginDir(tempPluginDir). - SetArgs("validate", "./templates/simple.pkr.hcl"). - Assert(MustSucceed(), Grep("packer-plugin-tester_v1.0.0[^+][^\\n]+plugin:", grepStderr)) - }) - - ts.Run("plugin with metadata should work with build", func() { - ts.PackerCommand().UsePluginDir(tempPluginDir). - SetArgs("build", "./templates/simple.pkr.hcl"). - Assert(MustSucceed(), Grep("packer-plugin-tester_v1.0.0[^+][^\\n]+plugin:", grepStderr)) - }) -} - -func (ts *PackerTestSuite) TestInstallPluginWithPath() { - tempPluginDir, cleanup := ts.MakePluginDir() - defer cleanup() - - ts.Run("install plugin with pre-release only", func() { - ts.PackerCommand().UsePluginDir(tempPluginDir). - SetArgs("plugins", "install", "--path", BuildSimplePlugin("1.0.0-dev", ts.T()), "github.com/hashicorp/tester"). - Assert(MustSucceed(), Grep("Successfully installed plugin", grepStdout)) - }) - - ts.Run("install same plugin with pre-release + metadata", func() { - ts.PackerCommand().UsePluginDir(tempPluginDir). - SetArgs("plugins", "install", "--path", BuildSimplePlugin("1.0.0-dev+metadata", ts.T()), "github.com/hashicorp/tester"). - Assert(MustSucceed(), Grep("Successfully installed plugin", grepStdout)) - }) - - ts.Run("list plugins, should only report one plugin", func() { - ts.PackerCommand().UsePluginDir(tempPluginDir). - SetArgs("plugins", "installed"). - Assert(MustSucceed(), - Grep("plugin-tester_v1.0.0-dev[^+]", grepStdout), - Grep("plugin-tester_v1.0.0-dev\\+", grepStdout, grepInvert), - LineCountCheck(1)) - }) -} - -func (ts *PackerTestSuite) TestInstallPluginPrerelease() { - pluginPath := BuildSimplePlugin("1.0.1-alpha1", ts.T()) - - pluginDir, cleanup := ts.MakePluginDir() - defer cleanup() - - ts.Run("try install plugin with alpha1 prerelease - should fail", func() { - ts.PackerCommand().UsePluginDir(pluginDir). - SetArgs("plugins", "install", "--path", pluginPath, "github.com/hashicorp/tester"). - Assert(MustFail(), Grep("Packer can only install plugin releases with this command", grepStdout)) - }) -} - -func (ts *PackerTestSuite) TestRemoteInstallWithPluginsInstall() { - pluginPath, cleanup := ts.MakePluginDir() - defer cleanup() - - ts.Run("install latest version of a remote plugin with packer plugins install", func() { - ts.PackerCommand().UsePluginDir(pluginPath). - SetArgs("plugins", "install", "github.com/hashicorp/hashicups"). - Assert(MustSucceed()) - }) -} - -func (ts *PackerTestSuite) TestRemoteInstallOfPreReleasePlugin() { - pluginPath, cleanup := ts.MakePluginDir() - defer cleanup() - - ts.Run("try to init with a pre-release constraint - should fail", func() { - ts.PackerCommand().UsePluginDir(pluginPath). - SetArgs("init", "templates/pre-release_constraint.pkr.hcl"). - Assert(MustFail(), - Grep("Invalid version constraint", grepStdout), - Grep("Unsupported prerelease for constraint", grepStdout)) - }) - - ts.Run("try to plugins install with a pre-release version - should fail", func() { - ts.PackerCommand().UsePluginDir(pluginPath). - SetArgs("plugin", "install", "github.com/hashicorp/hashicups", "1.0.2-dev"). - Assert(MustFail(), - Grep("Unsupported prerelease for constraint", grepStdout)) - }) -} diff --git a/packer_test/loading_test.go b/packer_test/loading_test.go deleted file mode 100644 index 1f1d8ceeef2..00000000000 --- a/packer_test/loading_test.go +++ /dev/null @@ -1,239 +0,0 @@ -package packer_test - -import ( - "crypto/sha256" - "fmt" - "os" - "path/filepath" -) - -func (ts *PackerTestSuite) TestLoadingOrder() { - pluginDir, cleanup := ts.MakePluginDir("1.0.9", "1.0.10") - defer cleanup() - - for _, command := range []string{"build", "validate"} { - tests := []struct { - name string - templatePath string - grepStr string - }{ - { - "HCL2 " + command + " - With required_plugins, 1.0.10 is the most recent and should load", - "./templates/simple.pkr.hcl", - "packer-plugin-tester_v1\\.0\\.10[^\n]+ plugin:", - }, - { - "JSON " + command + " - No required_plugins, 1.0.10 is the most recent and should load", - "./templates/simple.json", - "packer-plugin-tester_v1\\.0\\.10[^\n]+ plugin:", - }, - { - "HCL2 " + command + " - With required_plugins, 1.0.9 is pinned, so 1.0.9 should be used", - "./templates/pin_1.0.9.pkr.hcl", - "packer-plugin-tester_v1\\.0\\.9[^\n]+ plugin:", - }, - } - - for _, tt := range tests { - ts.Run(tt.name, func() { - ts.PackerCommand(). - SetArgs(command, tt.templatePath). - UsePluginDir(pluginDir). - Assert(MustSucceed(), Grep(tt.grepStr)) - }) - } - } -} - -func (ts *PackerTestSuite) TestLoadWithLegacyPluginName() { - pluginDir, cleanup := ts.MakePluginDir() - defer cleanup() - - plugin := BuildSimplePlugin("1.0.10", ts.T()) - - CopyFile(ts.T(), filepath.Join(pluginDir, "packer-plugin-tester"), plugin) - - ts.Run("only legacy plugins installed: expect build to fail", func() { - ts.Run("with required_plugins - expect prompt for packer init", func() { - ts.PackerCommand().UsePluginDir(pluginDir). - SetArgs("build", "templates/simple.pkr.hcl"). - Assert(MustFail(), - Grep("Did you run packer init for this project", grepStdout), - Grep("following plugins are required", grepStdout)) - }) - - ts.Run("JSON template, without required_plugins: should say the component is unknown", func() { - ts.PackerCommand().UsePluginDir(pluginDir). - SetArgs("build", "templates/simple.json"). - Assert(MustFail(), - Grep("The builder tester-dynamic is unknown by Packer", grepStdout)) - }) - }) - - pluginDir, cleanup = ts.MakePluginDir("1.0.0") - defer cleanup() - - CopyFile(ts.T(), filepath.Join(pluginDir, "packer-plugin-tester"), plugin) - - ts.Run("multiple plugins installed: one with no version in path, one with qualified name. Should pick-up the qualified one only.", func() { - ts.PackerCommand().UsePluginDir(pluginDir). - SetArgs("build", "templates/simple.pkr.hcl"). - Assert(MustSucceed(), Grep("packer-plugin-tester_v1\\.0\\.0[^\\n]+ plugin:", grepStderr)) - }) - - wd, cleanup := TempWorkdir(ts.T(), "./templates/simple.pkr.hcl") - defer cleanup() - - CopyFile(ts.T(), filepath.Join(wd, "packer-plugin-tester"), plugin) - - ts.Run("multiple plugins installed: 1.0.0 in plugin dir with sum, one in workdir (no version). Should load 1.0.0", func() { - ts.PackerCommand().UsePluginDir(pluginDir).SetWD(wd). - SetArgs("build", "simple.pkr.hcl"). - Assert(MustSucceed(), Grep("packer-plugin-tester_v1\\.0\\.0[^\\n]+ plugin:", grepStderr)) - }) -} - -func (ts *PackerTestSuite) TestLoadWithSHAMismatches() { - plugin := BuildSimplePlugin("1.0.10", ts.T()) - - ts.Run("move plugin with right name, but no SHA256SUM, should reject", func() { - pluginDir, cleanup := ts.MakePluginDir("1.0.9") - defer cleanup() - - pluginDestName := ExpectedInstalledName("1.0.10") - - CopyFile(ts.T(), filepath.Join(pluginDir, "github.com", "hashicorp", "tester", pluginDestName), plugin) - - ts.PackerCommand().UsePluginDir(pluginDir). - SetArgs("plugins", "installed"). - Assert(MustSucceed(), - Grep("packer-plugin-tester_v1\\.0\\.9[^\\n]+", grepStdout), - Grep("packer-plugin-tester_v1.0.10", grepStdout, grepInvert), - Grep("v1.0.10[^\\n]+ignoring possibly unsafe binary", grepStderr)) - }) - - ts.Run("move plugin with right name, invalid SHA256SUM, should reject", func() { - pluginDir, cleanup := ts.MakePluginDir("1.0.9") - defer cleanup() - - pluginDestName := ExpectedInstalledName("1.0.10") - CopyFile(ts.T(), filepath.Join(pluginDir, "github.com", "hashicorp", "tester", pluginDestName), plugin) - WriteFile(ts.T(), - filepath.Join(pluginDir, "github.com", "hashicorp", "tester", fmt.Sprintf("%s_SHA256SUM", pluginDestName)), - fmt.Sprintf("%x", sha256.New().Sum([]byte("Not the plugin's contents for sure.")))) - - ts.PackerCommand().UsePluginDir(pluginDir). - SetArgs("plugins", "installed"). - Assert(MustSucceed(), - Grep("packer-plugin-tester_v1\\.0\\.9[^\\n]+", grepStdout), - Grep("packer-plugin-tester_v1.0.10", grepInvert, grepStdout), - Grep("v1.0.10[^\\n]+ignoring possibly unsafe binary", grepStderr), - Grep(`Checksums \(\*sha256\.digest\) did not match.`, grepStderr)) - }) -} - -func (ts *PackerTestSuite) TestPluginPathEnvvarWithMultiplePaths() { - pluginDirOne, cleanup := ts.MakePluginDir("1.0.10") - defer cleanup() - - pluginDirTwo, cleanup := ts.MakePluginDir("1.0.9") - defer cleanup() - - pluginDirVal := fmt.Sprintf("%s%c%s", pluginDirOne, os.PathListSeparator, pluginDirTwo) - ts.Run("load plugin with two dirs - not supported anymore, should error", func() { - ts.PackerCommand().UsePluginDir(pluginDirVal). - SetArgs("plugins", "installed"). - Assert(MustFail(), - Grep("Multiple paths are no longer supported for PACKER_PLUGIN_PATH"), - MkPipeCheck("All envvars are suggested", - PipeGrep(`\* PACKER_PLUGIN_PATH=`), - LineCount()). - SetStream(OnlyStderr). - SetTester(IntCompare(eq, 2))) - }) -} - -func (ts *PackerTestSuite) TestInstallNonCanonicalPluginVersion() { - pluginPath, cleanup := ts.MakePluginDir() - defer cleanup() - - ManualPluginInstall(ts.T(), - filepath.Join(pluginPath, "github.com", "hashicorp", "tester"), - BuildSimplePlugin("1.0.10", ts.T()), - "001.00.010") - - ts.Run("try listing plugins with non-canonical version installed - report none", func() { - ts.PackerCommand().UsePluginDir(pluginPath). - SetArgs("plugins", "installed"). - Assert(MustSucceed(), - Grep(`version .* in path is non canonical`, grepStderr), - MkPipeCheck("no output in stdout").SetTester(ExpectEmptyInput()).SetStream(OnlyStdout)) - }) -} - -func (ts *PackerTestSuite) TestLoadPluginWithMetadataInName() { - pluginPath, cleanup := ts.MakePluginDir() - defer cleanup() - - ManualPluginInstall(ts.T(), - filepath.Join(pluginPath, "github.com", "hashicorp", "tester"), - BuildSimplePlugin("1.0.10+metadata", ts.T()), - "1.0.10+metadata") - - ts.Run("try listing plugins with metadata in name - report none", func() { - ts.PackerCommand().UsePluginDir(pluginPath). - SetArgs("plugins", "installed"). - Assert(MustSucceed(), - Grep("found version .* with metadata in the name", grepStderr), - MkPipeCheck("no output in stdout").SetTester(ExpectEmptyInput()).SetStream(OnlyStdout)) - }) -} - -func (ts *PackerTestSuite) TestLoadWithOnlyReleaseFlag() { - pluginPath, cleanup := ts.MakePluginDir("1.0.0", "1.0.1-dev") - defer cleanup() - - for _, cmd := range []string{"validate", "build"} { - ts.Run(fmt.Sprintf("run %s without --ignore-prerelease flag - pick 1.0.1-dev by default", cmd), func() { - ts.PackerCommand().UsePluginDir(pluginPath). - SetArgs(cmd, "./templates/simple.pkr.hcl"). - Assert(MustSucceed(), - Grep("packer-plugin-tester_v1.0.1-dev.*: plugin process exited", grepStderr)) - }) - - ts.Run(fmt.Sprintf("run %s with --ignore-prerelease flag - pick 1.0.0", cmd), func() { - ts.PackerCommand().UsePluginDir(pluginPath). - SetArgs(cmd, "--ignore-prerelease-plugins", "./templates/simple.pkr.hcl"). - Assert(MustSucceed(), - Grep("packer-plugin-tester_v1.0.0.*: plugin process exited", grepStderr)) - }) - } -} - -func (ts *PackerTestSuite) TestWithLegacyConfigAndComponents() { - pluginDir, cleanup := ts.MakePluginDir("1.0.0") - defer cleanup() - - workdir, cleanup := TempWorkdir(ts.T(), "./sample_config.json", "./templates/simple.json", "./templates/simple.pkr.hcl") - defer cleanup() - - for _, cmd := range []string{"validate", "build"} { - ts.Run(fmt.Sprintf("%s simple JSON template with config.json and components defined", cmd), func() { - ts.PackerCommand().UsePluginDir(pluginDir).SetWD(workdir). - SetArgs(cmd, "simple.json"). - AddEnv("PACKER_CONFIG", filepath.Join(workdir, "sample_config.json")). - Assert(MustFail(), - Grep("Your configuration file describes some legacy components", grepStderr), - Grep("packer-provisioner-super-shell", grepStderr)) - }) - - ts.Run(fmt.Sprintf("%s simple HCL2 template with config.json and components defined", cmd), func() { - ts.PackerCommand().UsePluginDir(pluginDir).SetWD(workdir). - SetArgs(cmd, "simple.pkr.hcl"). - AddEnv("PACKER_CONFIG", filepath.Join(workdir, "sample_config.json")). - Assert(MustFail(), - Grep("Your configuration file describes some legacy components", grepStderr), - Grep("packer-provisioner-super-shell", grepStderr)) - }) - } -} diff --git a/packer_test/pipe_checker_test.go b/packer_test/pipe_checker_test.go deleted file mode 100644 index b3b415349b9..00000000000 --- a/packer_test/pipe_checker_test.go +++ /dev/null @@ -1,247 +0,0 @@ -package packer_test - -import ( - "fmt" - "regexp" - "strconv" - "strings" - "testing" -) - -// Pipe is any command that allows piping two gadgets together -// -// There's always only one input and one output (stdout), mimicking essentially -// how pipes work in the UNIX-world. -type Pipe interface { - Process(input string) (string, error) -} - -// CustomPipe allows providing a simple function for piping inputs together -type CustomPipe func(string) (string, error) - -func (c CustomPipe) Process(input string) (string, error) { - return c(input) -} - -// PipeGrep performs a grep on an input and returns the matches, one-per-line. -// -// The expression passed as parameter will be compiled to a POSIX extended regexp. -func PipeGrep(expression string) Pipe { - re := regexp.MustCompilePOSIX(expression) - return CustomPipe(func(input string) (string, error) { - return strings.Join(re.FindAllString(input, -1), "\n"), nil - }) -} - -// LineCount counts the number of lines received -// -// This excludes empty lines. -func LineCount() Pipe { - return CustomPipe(func(s string) (string, error) { - lines := strings.FieldsFunc(s, func(r rune) bool { - return r == '\n' - }) - return fmt.Sprintf("%d\n", len(lines)), nil - }) -} - -// Tee pipes the output to stdout (as t.Logf) and forwards it, unaltered -// -// This is useful typically for troubleshooting a pipe that misbehaves -func Tee(t *testing.T) Pipe { - return CustomPipe(func(s string) (string, error) { - t.Logf(s) - return s, nil - }) -} - -// Tester is the end of a pipe for testing purposes. -// -// Once multiple commands have been piped together in a pipeline, we can -// perform some checks on that input, and decide if a test is a success or a -// failure. -type Tester interface { - Check(input string) error -} - -// CustomTester allows providing a function to check that the input is what we want -type CustomTester func(string) error - -func (ct CustomTester) Check(input string) error { - return ct(input) -} - -// ExpectNonEmptyInput errors if the result from the pipeline was empty -// -// Non-empty in this context means that the output contains characters that are -// non-whitespace, i.e. anything that `TrimSpace` (aka unicode.IsSpace) recognizes -// as whitespace. -func ExpectNonEmptyInput() Tester { - return CustomTester(func(in string) error { - in = strings.TrimSpace(in) - if in == "" { - return fmt.Errorf("input is empty, expected it not to") - } - return nil - }) -} - -// ExpectEmptyInput errors if the result from the pipeline was not empty -// -// Non-empty in this context means that the output contains characters that are -// non-whitespace, i.e. anything that `TrimSpace` (aka unicode.IsSpace) recognizes -// as whitespace. -func ExpectEmptyInput() Tester { - return CustomTester(func(in string) error { - in = strings.TrimSpace(in) - if in != "" { - return fmt.Errorf("input is not empty, expected it to be: %s", in) - } - return nil - }) -} - -type op int - -const ( - eq op = iota - ne - gt - ge - lt - le -) - -func (op op) String() string { - switch op { - case eq: - return "==" - case ne: - return "!=" - case gt: - return ">" - case ge: - return ">=" - case lt: - return "<" - case le: - return "<=" - } - - panic(fmt.Sprintf("Unknown operator %d", op)) -} - -// IntCompare reads the input from the pipeline and compares it to a value using `op` -// -// If the input is not an int, this fails. -func IntCompare(op op, value int) Tester { - return CustomTester(func(in string) error { - n, err := strconv.Atoi(strings.TrimSpace(in)) - if err != nil { - return fmt.Errorf("not an integer %q: %s", in, err) - } - - var result bool - switch op { - case eq: - result = n == value - case ne: - result = n != value - case gt: - result = n > value - case ge: - result = n >= value - case lt: - result = n < value - case le: - result = n <= value - default: - panic(fmt.Sprintf("Unsupported operator %d, make sure the operation is implemented for IntCompare", op)) - } - - if !result { - return fmt.Errorf("comparison failed: %d %s %d -> %t", n, op, value, result) - } - - return nil - }) -} - -// MkPipeCheck builds a new named PipeChecker -// -// Before it can be used, it will need a tester to be set, but this -// function is meant to make initialisation simpler. -func MkPipeCheck(name string, p ...Pipe) *PipeChecker { - return &PipeChecker{ - name: name, - pipers: p, - } -} - -// PipeChecker is a kind of checker that essentially lets users write mini -// gadgets that pipe inputs together, and compose those to end as a true/false -// statement, which translates to an error. -// -// Unlike pipes in a real command-line context, since we're dealing with -// finite gadgets to process data, we're sequentially running their Process -// function, and any processor that ends in an error will make the pipeline -// fail. -// -// Stream is provided so we know if we want to combine stdout/stderr for the -// pipeline, or if we want only to focus on either. -type PipeChecker struct { - name string - stream Stream - - pipers []Pipe - check Tester -} - -// SetTester sets the tester to use for a pipe checker -// -// This is required, otherwise running the pipe checker will fail -func (pc *PipeChecker) SetTester(t Tester) *PipeChecker { - pc.check = t - return pc -} - -// SetStream changes the stream(s) on which the PipeChecker will perform -// -// Defaults to BothStreams, i.e. stdout and stderr -func (pc *PipeChecker) SetStream(s Stream) *PipeChecker { - pc.stream = s - return pc -} - -func (pc PipeChecker) Check(stdout, stderr string, _ error) error { - if pc.check == nil { - return fmt.Errorf("%s - missing tester", pc.Name()) - } - - var pipeStr string - switch pc.stream { - case OnlyStdout: - pipeStr = stdout - case OnlyStderr: - pipeStr = stderr - case BothStreams: - pipeStr = fmt.Sprintf("%s\n%s", stdout, stderr) - } - - var err error - for i, pp := range pc.pipers { - pipeStr, err = pp.Process(pipeStr) - if err != nil { - return fmt.Errorf("pipeline failed during execution (%d): %s", i, err) - } - } - return pc.check.Check(pipeStr) -} - -func (pc PipeChecker) Name() string { - rawName := "|>?" - if pc.name != "" { - rawName = fmt.Sprintf("%s - %s", rawName, pc.name) - } - return rawName -} diff --git a/packer_test/plugin_test.go b/packer_test/plugin_test.go deleted file mode 100644 index a2e1b4aff24..00000000000 --- a/packer_test/plugin_test.go +++ /dev/null @@ -1,333 +0,0 @@ -package packer_test - -import ( - "crypto/sha256" - "fmt" - "io" - "os" - "os/exec" - "path/filepath" - "runtime" - "strings" - "sync" - "testing" - - "github.com/hashicorp/go-version" - "github.com/hashicorp/packer-plugin-sdk/plugin" -) - -var compiledPlugins = struct { - pluginVersions map[string]string - RWMutex sync.RWMutex -}{ - pluginVersions: map[string]string{}, -} - -func StorePluginVersion(pluginVersion, path string) { - compiledPlugins.RWMutex.Lock() - defer compiledPlugins.RWMutex.Unlock() - compiledPlugins.pluginVersions[pluginVersion] = path -} - -func LoadPluginVersion(pluginVersion string) (string, bool) { - compiledPlugins.RWMutex.RLock() - defer compiledPlugins.RWMutex.RUnlock() - - path, ok := compiledPlugins.pluginVersions[pluginVersion] - return path, ok -} - -var tempPluginBinaryPath = struct { - path string - once sync.Once -}{} - -// PluginBinaryDir returns the path to the directory where temporary binaries will be compiled -func PluginBinaryDir() string { - tempPluginBinaryPath.once.Do(func() { - tempDir, err := os.MkdirTemp("", "packer-core-acc-test-") - if err != nil { - panic(fmt.Sprintf("failed to create temporary directory for compiled plugins: %s", err)) - } - - tempPluginBinaryPath.path = tempDir - }) - - return tempPluginBinaryPath.path -} - -// LDFlags compiles the ldflags for the plugin to compile based on the information provided. -func LDFlags(version *version.Version) string { - pluginPackage := "github.com/hashicorp/packer-plugin-tester" - - ldflagsArg := fmt.Sprintf("-X %s/version.Version=%s", pluginPackage, version.Core()) - if version.Prerelease() != "" { - ldflagsArg = fmt.Sprintf("%s -X %s/version.VersionPrerelease=%s", ldflagsArg, pluginPackage, version.Prerelease()) - } - if version.Metadata() != "" { - ldflagsArg = fmt.Sprintf("%s -X %s/version.VersionMetadata=%s", ldflagsArg, pluginPackage, version.Metadata()) - } - - return ldflagsArg -} - -// BinaryName is the raw name of the plugin binary to produce -// -// It's expected to be in the "mini-plugin_[-][+]" format -func BinaryName(version *version.Version) string { - retStr := fmt.Sprintf("mini-plugin_%s", version.Core()) - if version.Prerelease() != "" { - retStr = fmt.Sprintf("%s-%s", retStr, version.Prerelease()) - } - if version.Metadata() != "" { - retStr = fmt.Sprintf("%s+%s", retStr, version.Metadata()) - } - - return retStr -} - -// ExpectedInstalledName is the expected full name of the plugin once installed. -func ExpectedInstalledName(versionStr string) string { - version.Must(version.NewVersion(versionStr)) - - versionStr = strings.ReplaceAll(versionStr, "v", "") - - ext := "" - if runtime.GOOS == "windows" { - ext = ".exe" - } - - return fmt.Sprintf("packer-plugin-tester_v%s_x%s.%s_%s_%s%s", - versionStr, - plugin.APIVersionMajor, - plugin.APIVersionMinor, - runtime.GOOS, runtime.GOARCH, ext) -} - -// BuildSimplePlugin creates a plugin that essentially does nothing. -// -// The plugin's code is contained in a subdirectory of this, and lets us -// change the attributes of the plugin binary itself, like the SDK version, -// the plugin's version, etc. -// -// The plugin is functional, and can be used to run builds with. -// There won't be anything substantial created though, its goal is only -// to validate the core functionality of Packer. -// -// The path to the plugin is returned, it won't be removed automatically -// though, deletion is the caller's responsibility. -func BuildSimplePlugin(versionString string, t *testing.T) string { - // Only build plugin binary if not already done beforehand - path, ok := LoadPluginVersion(versionString) - if ok { - return path - } - - v := version.Must(version.NewSemver(versionString)) - - t.Logf("Building plugin in version %v", v) - - testDir, err := currentDir() - if err != nil { - t.Fatalf("failed to compile plugin binary: %s", err) - } - - testerPluginDir := filepath.Join(testDir, "plugin_tester") - outBin := filepath.Join(PluginBinaryDir(), BinaryName(v)) - - compileCommand := exec.Command("go", "build", "-C", testerPluginDir, "-o", outBin, "-ldflags", LDFlags(v), ".") - logs, err := compileCommand.CombinedOutput() - if err != nil { - t.Fatalf("failed to compile plugin binary: %s\ncompiler logs: %s", err, logs) - } - - StorePluginVersion(v.String(), outBin) - - return outBin -} - -// currentDir returns the directory in which the current file is located. -// -// Since we're in tests it's reliable as they're supposed to run on the same -// machine the binary's compiled from, but goes to say it's not meant for use -// in distributed binaries. -func currentDir() (string, error) { - // pc uintptr, file string, line int, ok bool - _, testDir, _, ok := runtime.Caller(0) - if !ok { - return "", fmt.Errorf("couldn't get the location of the test suite file") - } - - return filepath.Dir(testDir), nil -} - -// MakePluginDir installs a list of plugins into a temporary directory and returns its path -// -// This can be set in the environment for a test through a function like t.SetEnv(), so -// packer will be able to use that directory for running its functions. -// -// Deletion of the directory is the caller's responsibility. -func (ts *PackerTestSuite) MakePluginDir(pluginVersions ...string) (pluginTempDir string, cleanup func()) { - t := ts.T() - - for _, ver := range pluginVersions { - BuildSimplePlugin(ver, t) - } - - var err error - - defer func() { - if err != nil { - if pluginTempDir != "" { - os.RemoveAll(pluginTempDir) - } - t.Fatalf("failed to prepare temporary plugin directory %q: %s", pluginTempDir, err) - } - }() - - pluginTempDir, err = os.MkdirTemp("", "packer-plugin-dir-temp-") - if err != nil { - return - } - - for _, pluginVersion := range pluginVersions { - path, ok := LoadPluginVersion(pluginVersion) - if !ok { - err = fmt.Errorf("failed to get path to version %q, was it compiled?", pluginVersion) - } - cmd := ts.PackerCommand().SetArgs("plugins", "install", "--path", path, "github.com/hashicorp/tester").AddEnv("PACKER_PLUGIN_PATH", pluginTempDir) - cmd.Assert(MustSucceed()) - out, stderr, cmdErr := cmd.Run() - if cmdErr != nil { - err = fmt.Errorf("failed to install tester plugin version %q: %s\nCommand stdout: %s\nCommand stderr: %s", pluginVersion, err, out, stderr) - return - } - } - - return pluginTempDir, func() { - err := os.RemoveAll(pluginTempDir) - if err != nil { - t.Logf("failed to remove temporary plugin directory %q: %s. This may need manual intervention.", pluginTempDir, err) - } - } -} - -// CopyFile essentially replicates the `cp` command, for a file only. -// -// # Permissions are copied over from the source to destination -// -// The function detects if destination is a directory or a file (existent or not). -// -// If this is the former, we append the source file's basename to the -// directory and create the file from that inferred path. -func CopyFile(t *testing.T, dest, src string) { - st, err := os.Stat(src) - if err != nil { - t.Fatalf("failed to stat origin file %q: %s", src, err) - } - - // If the stat call fails, we assume dest is the destination file. - dstStat, err := os.Stat(dest) - if err == nil && dstStat.IsDir() { - dest = filepath.Join(dest, filepath.Base(src)) - } - - destFD, err := os.OpenFile(dest, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, st.Mode().Perm()) - if err != nil { - t.Fatalf("failed to create cp destination file %q: %s", dest, err) - } - defer destFD.Close() - - srcFD, err := os.Open(src) - if err != nil { - t.Fatalf("failed to open source file to copy: %s", err) - } - defer srcFD.Close() - - _, err = io.Copy(destFD, srcFD) - if err != nil { - t.Fatalf("failed to copy from %q -> %q: %s", src, dest, err) - } -} - -// WriteFile writes `content` to a file `dest` -// -// The default permissions of that file is 0644 -func WriteFile(t *testing.T, dest string, content string) { - outFile, err := os.OpenFile(dest, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0644) - if err != nil { - t.Fatalf("failed to open/create %q: %s", dest, err) - } - defer outFile.Close() - - _, err = fmt.Fprintf(outFile, content) - if err != nil { - t.Fatalf("failed to write to file %q: %s", dest, err) - } -} - -// TempWorkdir creates a working directory for a Packer test with the list of files -// given as input. -// -// The files should either have a path relative to the test that invokes it, or should -// be absolute. -// Each file will be copied to the root of the workdir being created. -// -// If any file cannot be found, this function will fail -func TempWorkdir(t *testing.T, files ...string) (string, func()) { - var err error - tempDir, err := os.MkdirTemp("", "packer-test-workdir-") - if err != nil { - t.Fatalf("failed to create temporary working directory: %s", err) - } - - defer func() { - if err != nil { - os.RemoveAll(tempDir) - t.Errorf("failed to create temporary workdir: %s", err) - } - }() - - for _, file := range files { - CopyFile(t, tempDir, file) - } - - return tempDir, func() { - err := os.RemoveAll(tempDir) - if err != nil { - t.Logf("failed to remove temporary workdir %q: %s. This will need manual action.", tempDir, err) - } - } -} - -// SHA256Sum computes the SHA256 digest for an input file -// -// The digest is returned as a hexstring -func SHA256Sum(t *testing.T, file string) string { - fl, err := os.ReadFile(file) - if err != nil { - t.Fatalf("failed to compute sha256sum for %q: %s", file, err) - } - sha := sha256.New() - sha.Write(fl) - return fmt.Sprintf("%x", sha.Sum([]byte{})) -} - -// ManualPluginInstall emulates how Packer installs plugins with `packer plugins install` -// -// This is used for some tests if we want to install a plugin that cannot be installed -// through the normal commands (typically because Packer rejects it). -func ManualPluginInstall(t *testing.T, dest, srcPlugin, versionStr string) { - err := os.MkdirAll(dest, 0755) - if err != nil { - t.Fatalf("failed to create destination directories %q: %s", dest, err) - } - - pluginName := ExpectedInstalledName(versionStr) - destPath := filepath.Join(dest, pluginName) - - CopyFile(t, destPath, srcPlugin) - - shaPath := fmt.Sprintf("%s_SHA256SUM", destPath) - WriteFile(t, shaPath, SHA256Sum(t, destPath)) -} diff --git a/packer_test/plugin_tester/LICENSE b/packer_test/plugin_tester/LICENSE deleted file mode 100644 index c121cee6e5e..00000000000 --- a/packer_test/plugin_tester/LICENSE +++ /dev/null @@ -1,375 +0,0 @@ -Copyright (c) 2020 HashiCorp, Inc. - -Mozilla Public License Version 2.0 -================================== - -1. Definitions --------------- - -1.1. "Contributor" - means each individual or legal entity that creates, contributes to - the creation of, or owns Covered Software. - -1.2. "Contributor Version" - means the combination of the Contributions of others (if any) used - by a Contributor and that particular Contributor's Contribution. - -1.3. "Contribution" - means Covered Software of a particular Contributor. - -1.4. "Covered Software" - means Source Code Form to which the initial Contributor has attached - the notice in Exhibit A, the Executable Form of such Source Code - Form, and Modifications of such Source Code Form, in each case - including portions thereof. - -1.5. "Incompatible With Secondary Licenses" - means - - (a) that the initial Contributor has attached the notice described - in Exhibit B to the Covered Software; or - - (b) that the Covered Software was made available under the terms of - version 1.1 or earlier of the License, but not also under the - terms of a Secondary License. - -1.6. "Executable Form" - means any form of the work other than Source Code Form. - -1.7. "Larger Work" - means a work that combines Covered Software with other material, in - a separate file or files, that is not Covered Software. - -1.8. "License" - means this document. - -1.9. "Licensable" - means having the right to grant, to the maximum extent possible, - whether at the time of the initial grant or subsequently, any and - all of the rights conveyed by this License. - -1.10. "Modifications" - means any of the following: - - (a) any file in Source Code Form that results from an addition to, - deletion from, or modification of the contents of Covered - Software; or - - (b) any new file in Source Code Form that contains any Covered - Software. - -1.11. "Patent Claims" of a Contributor - means any patent claim(s), including without limitation, method, - process, and apparatus claims, in any patent Licensable by such - Contributor that would be infringed, but for the grant of the - License, by the making, using, selling, offering for sale, having - made, import, or transfer of either its Contributions or its - Contributor Version. - -1.12. "Secondary License" - means either the GNU General Public License, Version 2.0, the GNU - Lesser General Public License, Version 2.1, the GNU Affero General - Public License, Version 3.0, or any later versions of those - licenses. - -1.13. "Source Code Form" - means the form of the work preferred for making modifications. - -1.14. "You" (or "Your") - means an individual or a legal entity exercising rights under this - License. For legal entities, "You" includes any entity that - controls, is controlled by, or is under common control with You. For - purposes of this definition, "control" means (a) the power, direct - or indirect, to cause the direction or management of such entity, - whether by contract or otherwise, or (b) ownership of more than - fifty percent (50%) of the outstanding shares or beneficial - ownership of such entity. - -2. License Grants and Conditions --------------------------------- - -2.1. Grants - -Each Contributor hereby grants You a world-wide, royalty-free, -non-exclusive license: - -(a) under intellectual property rights (other than patent or trademark) - Licensable by such Contributor to use, reproduce, make available, - modify, display, perform, distribute, and otherwise exploit its - Contributions, either on an unmodified basis, with Modifications, or - as part of a Larger Work; and - -(b) under Patent Claims of such Contributor to make, use, sell, offer - for sale, have made, import, and otherwise transfer either its - Contributions or its Contributor Version. - -2.2. Effective Date - -The licenses granted in Section 2.1 with respect to any Contribution -become effective for each Contribution on the date the Contributor first -distributes such Contribution. - -2.3. Limitations on Grant Scope - -The licenses granted in this Section 2 are the only rights granted under -this License. No additional rights or licenses will be implied from the -distribution or licensing of Covered Software under this License. -Notwithstanding Section 2.1(b) above, no patent license is granted by a -Contributor: - -(a) for any code that a Contributor has removed from Covered Software; - or - -(b) for infringements caused by: (i) Your and any other third party's - modifications of Covered Software, or (ii) the combination of its - Contributions with other software (except as part of its Contributor - Version); or - -(c) under Patent Claims infringed by Covered Software in the absence of - its Contributions. - -This License does not grant any rights in the trademarks, service marks, -or logos of any Contributor (except as may be necessary to comply with -the notice requirements in Section 3.4). - -2.4. Subsequent Licenses - -No Contributor makes additional grants as a result of Your choice to -distribute the Covered Software under a subsequent version of this -License (see Section 10.2) or under the terms of a Secondary License (if -permitted under the terms of Section 3.3). - -2.5. Representation - -Each Contributor represents that the Contributor believes its -Contributions are its original creation(s) or it has sufficient rights -to grant the rights to its Contributions conveyed by this License. - -2.6. Fair Use - -This License is not intended to limit any rights You have under -applicable copyright doctrines of fair use, fair dealing, or other -equivalents. - -2.7. Conditions - -Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted -in Section 2.1. - -3. Responsibilities -------------------- - -3.1. Distribution of Source Form - -All distribution of Covered Software in Source Code Form, including any -Modifications that You create or to which You contribute, must be under -the terms of this License. You must inform recipients that the Source -Code Form of the Covered Software is governed by the terms of this -License, and how they can obtain a copy of this License. You may not -attempt to alter or restrict the recipients' rights in the Source Code -Form. - -3.2. Distribution of Executable Form - -If You distribute Covered Software in Executable Form then: - -(a) such Covered Software must also be made available in Source Code - Form, as described in Section 3.1, and You must inform recipients of - the Executable Form how they can obtain a copy of such Source Code - Form by reasonable means in a timely manner, at a charge no more - than the cost of distribution to the recipient; and - -(b) You may distribute such Executable Form under the terms of this - License, or sublicense it under different terms, provided that the - license for the Executable Form does not attempt to limit or alter - the recipients' rights in the Source Code Form under this License. - -3.3. Distribution of a Larger Work - -You may create and distribute a Larger Work under terms of Your choice, -provided that You also comply with the requirements of this License for -the Covered Software. If the Larger Work is a combination of Covered -Software with a work governed by one or more Secondary Licenses, and the -Covered Software is not Incompatible With Secondary Licenses, this -License permits You to additionally distribute such Covered Software -under the terms of such Secondary License(s), so that the recipient of -the Larger Work may, at their option, further distribute the Covered -Software under the terms of either this License or such Secondary -License(s). - -3.4. Notices - -You may not remove or alter the substance of any license notices -(including copyright notices, patent notices, disclaimers of warranty, -or limitations of liability) contained within the Source Code Form of -the Covered Software, except that You may alter any license notices to -the extent required to remedy known factual inaccuracies. - -3.5. Application of Additional Terms - -You may choose to offer, and to charge a fee for, warranty, support, -indemnity or liability obligations to one or more recipients of Covered -Software. However, You may do so only on Your own behalf, and not on -behalf of any Contributor. You must make it absolutely clear that any -such warranty, support, indemnity, or liability obligation is offered by -You alone, and You hereby agree to indemnify every Contributor for any -liability incurred by such Contributor as a result of warranty, support, -indemnity or liability terms You offer. You may include additional -disclaimers of warranty and limitations of liability specific to any -jurisdiction. - -4. Inability to Comply Due to Statute or Regulation ---------------------------------------------------- - -If it is impossible for You to comply with any of the terms of this -License with respect to some or all of the Covered Software due to -statute, judicial order, or regulation then You must: (a) comply with -the terms of this License to the maximum extent possible; and (b) -describe the limitations and the code they affect. Such description must -be placed in a text file included with all distributions of the Covered -Software under this License. Except to the extent prohibited by statute -or regulation, such description must be sufficiently detailed for a -recipient of ordinary skill to be able to understand it. - -5. Termination --------------- - -5.1. The rights granted under this License will terminate automatically -if You fail to comply with any of its terms. However, if You become -compliant, then the rights granted under this License from a particular -Contributor are reinstated (a) provisionally, unless and until such -Contributor explicitly and finally terminates Your grants, and (b) on an -ongoing basis, if such Contributor fails to notify You of the -non-compliance by some reasonable means prior to 60 days after You have -come back into compliance. Moreover, Your grants from a particular -Contributor are reinstated on an ongoing basis if such Contributor -notifies You of the non-compliance by some reasonable means, this is the -first time You have received notice of non-compliance with this License -from such Contributor, and You become compliant prior to 30 days after -Your receipt of the notice. - -5.2. If You initiate litigation against any entity by asserting a patent -infringement claim (excluding declaratory judgment actions, -counter-claims, and cross-claims) alleging that a Contributor Version -directly or indirectly infringes any patent, then the rights granted to -You by any and all Contributors for the Covered Software under Section -2.1 of this License shall terminate. - -5.3. In the event of termination under Sections 5.1 or 5.2 above, all -end user license agreements (excluding distributors and resellers) which -have been validly granted by You or Your distributors under this License -prior to termination shall survive termination. - -************************************************************************ -* * -* 6. Disclaimer of Warranty * -* ------------------------- * -* * -* Covered Software is provided under this License on an "as is" * -* basis, without warranty of any kind, either expressed, implied, or * -* statutory, including, without limitation, warranties that the * -* Covered Software is free of defects, merchantable, fit for a * -* particular purpose or non-infringing. The entire risk as to the * -* quality and performance of the Covered Software is with You. * -* Should any Covered Software prove defective in any respect, You * -* (not any Contributor) assume the cost of any necessary servicing, * -* repair, or correction. This disclaimer of warranty constitutes an * -* essential part of this License. No use of any Covered Software is * -* authorized under this License except under this disclaimer. * -* * -************************************************************************ - -************************************************************************ -* * -* 7. Limitation of Liability * -* -------------------------- * -* * -* Under no circumstances and under no legal theory, whether tort * -* (including negligence), contract, or otherwise, shall any * -* Contributor, or anyone who distributes Covered Software as * -* permitted above, be liable to You for any direct, indirect, * -* special, incidental, or consequential damages of any character * -* including, without limitation, damages for lost profits, loss of * -* goodwill, work stoppage, computer failure or malfunction, or any * -* and all other commercial damages or losses, even if such party * -* shall have been informed of the possibility of such damages. This * -* limitation of liability shall not apply to liability for death or * -* personal injury resulting from such party's negligence to the * -* extent applicable law prohibits such limitation. Some * -* jurisdictions do not allow the exclusion or limitation of * -* incidental or consequential damages, so this exclusion and * -* limitation may not apply to You. * -* * -************************************************************************ - -8. Litigation -------------- - -Any litigation relating to this License may be brought only in the -courts of a jurisdiction where the defendant maintains its principal -place of business and such litigation shall be governed by laws of that -jurisdiction, without reference to its conflict-of-law provisions. -Nothing in this Section shall prevent a party's ability to bring -cross-claims or counter-claims. - -9. Miscellaneous ----------------- - -This License represents the complete agreement concerning the subject -matter hereof. If any provision of this License is held to be -unenforceable, such provision shall be reformed only to the extent -necessary to make it enforceable. Any law or regulation which provides -that the language of a contract shall be construed against the drafter -shall not be used to construe this License against a Contributor. - -10. Versions of the License ---------------------------- - -10.1. New Versions - -Mozilla Foundation is the license steward. Except as provided in Section -10.3, no one other than the license steward has the right to modify or -publish new versions of this License. Each version will be given a -distinguishing version number. - -10.2. Effect of New Versions - -You may distribute the Covered Software under the terms of the version -of the License under which You originally received the Covered Software, -or under the terms of any subsequent version published by the license -steward. - -10.3. Modified Versions - -If you create software not governed by this License, and you want to -create a new license for such software, you may create and use a -modified version of this License if you rename the license and remove -any references to the name of the license steward (except to note that -such modified license differs from this License). - -10.4. Distributing Source Code Form that is Incompatible With Secondary -Licenses - -If You choose to distribute Source Code Form that is Incompatible With -Secondary Licenses under the terms of this version of the License, the -notice described in Exhibit B of this License must be attached. - -Exhibit A - Source Code Form License Notice -------------------------------------------- - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. - -If it is not possible or desirable to put the notice in a particular -file, then You may include the notice in a location (such as a LICENSE -file in a relevant directory) where a recipient would be likely to look -for such a notice. - -You may add additional accurate notices of copyright ownership. - -Exhibit B - "Incompatible With Secondary Licenses" Notice ---------------------------------------------------------- - - This Source Code Form is "Incompatible With Secondary Licenses", as - defined by the Mozilla Public License, v. 2.0. diff --git a/packer_test/plugin_tester/README.md b/packer_test/plugin_tester/README.md deleted file mode 100644 index 32f3fa71c05..00000000000 --- a/packer_test/plugin_tester/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# Packer Test Plugin - -This directory is meant to be a minimal plugin that we can use for testing Packer. -Any components defined in this plugin are not for use, as they virtually do nothing, and are only here to test Packer's core capabilitities - diff --git a/packer_test/plugin_tester/builder/dynamic/artifact.go b/packer_test/plugin_tester/builder/dynamic/artifact.go deleted file mode 100644 index bbb0a39658b..00000000000 --- a/packer_test/plugin_tester/builder/dynamic/artifact.go +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package dynamic - -// packersdk.Artifact implementation -type Artifact struct { - // StateData should store data such as GeneratedData - // to be shared with post-processors - StateData map[string]interface{} -} - -func (*Artifact) BuilderId() string { - return BuilderId -} - -func (a *Artifact) Files() []string { - return []string{} -} - -func (*Artifact) Id() string { - return "" -} - -func (a *Artifact) String() string { - return "" -} - -func (a *Artifact) State(name string) interface{} { - return a.StateData[name] -} - -func (a *Artifact) Destroy() error { - return nil -} diff --git a/packer_test/plugin_tester/builder/dynamic/builder.go b/packer_test/plugin_tester/builder/dynamic/builder.go deleted file mode 100644 index f3ae36cd2ba..00000000000 --- a/packer_test/plugin_tester/builder/dynamic/builder.go +++ /dev/null @@ -1,92 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -//go:generate packer-sdc mapstructure-to-hcl2 -type Config,NestedFirst,NestedSecond - -package dynamic - -import ( - "context" - - "github.com/hashicorp/hcl/v2/hcldec" - "github.com/hashicorp/packer-plugin-sdk/common" - "github.com/hashicorp/packer-plugin-sdk/multistep" - "github.com/hashicorp/packer-plugin-sdk/multistep/commonsteps" - "github.com/hashicorp/packer-plugin-sdk/packer" - "github.com/hashicorp/packer-plugin-sdk/template/config" -) - -const BuilderId = "dynamic.builder" - -type NestedSecond struct { - Name string `mapstructure:"name" required:"true"` -} - -type NestedFirst struct { - Name string `mapstructure:"name" required:"true"` - Nesteds []NestedSecond `mapstructure:"extra" required:"false"` -} - -type Config struct { - common.PackerConfig `mapstructure:",squash"` - Nesteds []NestedFirst `mapstructure:"extra" required:"false"` -} - -type Builder struct { - config Config - runner multistep.Runner -} - -func (b *Builder) ConfigSpec() hcldec.ObjectSpec { return b.config.FlatMapstructure().HCL2Spec() } - -func (b *Builder) Prepare(raws ...interface{}) (generatedVars []string, warnings []string, err error) { - err = config.Decode(&b.config, &config.DecodeOpts{ - PluginType: "packer.builder.dynamic", - Interpolate: true, - }, raws...) - if err != nil { - return nil, nil, err - } - // Return the placeholder for the generated data that will become available to provisioners and post-processors. - // If the builder doesn't generate any data, just return an empty slice of string: []string{} - buildGeneratedData := []string{"GeneratedMockData"} - return buildGeneratedData, nil, nil -} - -func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (packer.Artifact, error) { - steps := []multistep.Step{} - - steps = append(steps, - &StepSayConfig{ - b.config, - }, - new(commonsteps.StepProvision), - ) - - // Setup the state bag and initial state for the steps - state := new(multistep.BasicStateBag) - state.Put("hook", hook) - state.Put("ui", ui) - - // Set the value of the generated data that will become available to provisioners. - // To share the data with post-processors, use the StateData in the artifact. - state.Put("generated_data", map[string]interface{}{ - "GeneratedMockData": "mock-build-data", - }) - - // Run! - b.runner = commonsteps.NewRunner(steps, b.config.PackerConfig, ui) - b.runner.Run(ctx, state) - - // If there was an error, return that - if err, ok := state.GetOk("error"); ok { - return nil, err.(error) - } - - artifact := &Artifact{ - // Add the builder generated data to the artifact StateData so that post-processors - // can access them. - StateData: map[string]interface{}{"generated_data": state.Get("generated_data")}, - } - return artifact, nil -} diff --git a/packer_test/plugin_tester/builder/dynamic/builder.hcl2spec.go b/packer_test/plugin_tester/builder/dynamic/builder.hcl2spec.go deleted file mode 100644 index 0ea4a0f8e66..00000000000 --- a/packer_test/plugin_tester/builder/dynamic/builder.hcl2spec.go +++ /dev/null @@ -1,95 +0,0 @@ -// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. - -package dynamic - -import ( - "github.com/hashicorp/hcl/v2/hcldec" - "github.com/zclconf/go-cty/cty" -) - -// FlatConfig is an auto-generated flat version of Config. -// Where the contents of a field with a `mapstructure:,squash` tag are bubbled up. -type FlatConfig struct { - PackerBuildName *string `mapstructure:"packer_build_name" cty:"packer_build_name" hcl:"packer_build_name"` - PackerBuilderType *string `mapstructure:"packer_builder_type" cty:"packer_builder_type" hcl:"packer_builder_type"` - PackerCoreVersion *string `mapstructure:"packer_core_version" cty:"packer_core_version" hcl:"packer_core_version"` - PackerDebug *bool `mapstructure:"packer_debug" cty:"packer_debug" hcl:"packer_debug"` - PackerForce *bool `mapstructure:"packer_force" cty:"packer_force" hcl:"packer_force"` - PackerOnError *string `mapstructure:"packer_on_error" cty:"packer_on_error" hcl:"packer_on_error"` - PackerUserVars map[string]string `mapstructure:"packer_user_variables" cty:"packer_user_variables" hcl:"packer_user_variables"` - PackerSensitiveVars []string `mapstructure:"packer_sensitive_variables" cty:"packer_sensitive_variables" hcl:"packer_sensitive_variables"` - Nesteds []FlatNestedFirst `mapstructure:"extra" required:"false" cty:"extra" hcl:"extra"` -} - -// FlatMapstructure returns a new FlatConfig. -// FlatConfig is an auto-generated flat version of Config. -// Where the contents a fields with a `mapstructure:,squash` tag are bubbled up. -func (*Config) FlatMapstructure() interface{ HCL2Spec() map[string]hcldec.Spec } { - return new(FlatConfig) -} - -// HCL2Spec returns the hcl spec of a Config. -// This spec is used by HCL to read the fields of Config. -// The decoded values from this spec will then be applied to a FlatConfig. -func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec { - s := map[string]hcldec.Spec{ - "packer_build_name": &hcldec.AttrSpec{Name: "packer_build_name", Type: cty.String, Required: false}, - "packer_builder_type": &hcldec.AttrSpec{Name: "packer_builder_type", Type: cty.String, Required: false}, - "packer_core_version": &hcldec.AttrSpec{Name: "packer_core_version", Type: cty.String, Required: false}, - "packer_debug": &hcldec.AttrSpec{Name: "packer_debug", Type: cty.Bool, Required: false}, - "packer_force": &hcldec.AttrSpec{Name: "packer_force", Type: cty.Bool, Required: false}, - "packer_on_error": &hcldec.AttrSpec{Name: "packer_on_error", Type: cty.String, Required: false}, - "packer_user_variables": &hcldec.AttrSpec{Name: "packer_user_variables", Type: cty.Map(cty.String), Required: false}, - "packer_sensitive_variables": &hcldec.AttrSpec{Name: "packer_sensitive_variables", Type: cty.List(cty.String), Required: false}, - "extra": &hcldec.BlockListSpec{TypeName: "extra", Nested: hcldec.ObjectSpec((*FlatNestedFirst)(nil).HCL2Spec())}, - } - return s -} - -// FlatNestedFirst is an auto-generated flat version of NestedFirst. -// Where the contents of a field with a `mapstructure:,squash` tag are bubbled up. -type FlatNestedFirst struct { - Name *string `mapstructure:"name" required:"true" cty:"name" hcl:"name"` - Nesteds []FlatNestedSecond `mapstructure:"extra" required:"false" cty:"extra" hcl:"extra"` -} - -// FlatMapstructure returns a new FlatNestedFirst. -// FlatNestedFirst is an auto-generated flat version of NestedFirst. -// Where the contents a fields with a `mapstructure:,squash` tag are bubbled up. -func (*NestedFirst) FlatMapstructure() interface{ HCL2Spec() map[string]hcldec.Spec } { - return new(FlatNestedFirst) -} - -// HCL2Spec returns the hcl spec of a NestedFirst. -// This spec is used by HCL to read the fields of NestedFirst. -// The decoded values from this spec will then be applied to a FlatNestedFirst. -func (*FlatNestedFirst) HCL2Spec() map[string]hcldec.Spec { - s := map[string]hcldec.Spec{ - "name": &hcldec.AttrSpec{Name: "name", Type: cty.String, Required: false}, - "extra": &hcldec.BlockListSpec{TypeName: "extra", Nested: hcldec.ObjectSpec((*FlatNestedSecond)(nil).HCL2Spec())}, - } - return s -} - -// FlatNestedSecond is an auto-generated flat version of NestedSecond. -// Where the contents of a field with a `mapstructure:,squash` tag are bubbled up. -type FlatNestedSecond struct { - Name *string `mapstructure:"name" required:"true" cty:"name" hcl:"name"` -} - -// FlatMapstructure returns a new FlatNestedSecond. -// FlatNestedSecond is an auto-generated flat version of NestedSecond. -// Where the contents a fields with a `mapstructure:,squash` tag are bubbled up. -func (*NestedSecond) FlatMapstructure() interface{ HCL2Spec() map[string]hcldec.Spec } { - return new(FlatNestedSecond) -} - -// HCL2Spec returns the hcl spec of a NestedSecond. -// This spec is used by HCL to read the fields of NestedSecond. -// The decoded values from this spec will then be applied to a FlatNestedSecond. -func (*FlatNestedSecond) HCL2Spec() map[string]hcldec.Spec { - s := map[string]hcldec.Spec{ - "name": &hcldec.AttrSpec{Name: "name", Type: cty.String, Required: false}, - } - return s -} diff --git a/packer_test/plugin_tester/builder/dynamic/builder_acc_test.go b/packer_test/plugin_tester/builder/dynamic/builder_acc_test.go deleted file mode 100644 index 2d2ba54feeb..00000000000 --- a/packer_test/plugin_tester/builder/dynamic/builder_acc_test.go +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package dynamic - -import ( - _ "embed" - "fmt" - "io/ioutil" - "os" - "os/exec" - "regexp" - "testing" - - "github.com/hashicorp/packer-plugin-sdk/acctest" -) - -//go:embed test-fixtures/template.pkr.hcl -var testBuilderHCL2Basic string - -// Run with: PACKER_ACC=1 go test -count 1 -v ./builder/scaffolding/builder_acc_test.go -timeout=120m -func TestAccScaffoldingBuilder(t *testing.T) { - testCase := &acctest.PluginTestCase{ - Name: "scaffolding_builder_basic_test", - Setup: func() error { - return nil - }, - Teardown: func() error { - return nil - }, - Template: testBuilderHCL2Basic, - Type: "scaffolding-my-builder", - Check: func(buildCommand *exec.Cmd, logfile string) error { - if buildCommand.ProcessState != nil { - if buildCommand.ProcessState.ExitCode() != 0 { - return fmt.Errorf("Bad exit code. Logfile: %s", logfile) - } - } - - logs, err := os.Open(logfile) - if err != nil { - return fmt.Errorf("Unable find %s", logfile) - } - defer logs.Close() - - logsBytes, err := ioutil.ReadAll(logs) - if err != nil { - return fmt.Errorf("Unable to read %s", logfile) - } - logsString := string(logsBytes) - - buildGeneratedDataLog := "scaffolding-my-builder.basic-example: build generated data: mock-build-data" - if matched, _ := regexp.MatchString(buildGeneratedDataLog+".*", logsString); !matched { - t.Fatalf("logs doesn't contain expected foo value %q", logsString) - } - return nil - }, - } - acctest.TestPlugin(t, testCase) -} diff --git a/packer_test/plugin_tester/builder/dynamic/step_say_config.go b/packer_test/plugin_tester/builder/dynamic/step_say_config.go deleted file mode 100644 index f5fdf41ef34..00000000000 --- a/packer_test/plugin_tester/builder/dynamic/step_say_config.go +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package dynamic - -import ( - "context" - "fmt" - - "github.com/hashicorp/packer-plugin-sdk/multistep" - packersdk "github.com/hashicorp/packer-plugin-sdk/packer" -) - -// This is a definition of a builder step and should implement multistep.Step -type StepSayConfig struct { - cfg Config -} - -// Run should execute the purpose of this step -func (s *StepSayConfig) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { - ui := state.Get("ui").(packersdk.Ui) - - ui.Say("Dynamic builder invoked!") - for _, nf := range s.cfg.Nesteds { - ui.Say(fmt.Sprintf("Nested first: %s", nf.Name)) - for _, ns := range nf.Nesteds { - ui.Say(fmt.Sprintf("Nested second: %s.%s", nf.Name, ns.Name)) - } - } - - // Determines that should continue to the next step - return multistep.ActionContinue -} - -// Cleanup can be used to clean up any artifact created by the step. -// A step's clean up always run at the end of a build, regardless of whether provisioning succeeds or fails. -func (s *StepSayConfig) Cleanup(_ multistep.StateBag) { - // Nothing to clean -} diff --git a/packer_test/plugin_tester/builder/dynamic/test-fixtures/template.pkr.hcl b/packer_test/plugin_tester/builder/dynamic/test-fixtures/template.pkr.hcl deleted file mode 100644 index cb9693c55fe..00000000000 --- a/packer_test/plugin_tester/builder/dynamic/test-fixtures/template.pkr.hcl +++ /dev/null @@ -1,18 +0,0 @@ -# Copyright (c) HashiCorp, Inc. -# SPDX-License-Identifier: MPL-2.0 - -source "scaffolding-my-builder" "basic-example" { - mock = "mock-config" -} - -build { - sources = [ - "source.scaffolding-my-builder.basic-example" - ] - - provisioner "shell-local" { - inline = [ - "echo build generated data: ${build.GeneratedMockData}", - ] - } -} diff --git a/packer_test/plugin_tester/datasource/dynamic/data.go b/packer_test/plugin_tester/datasource/dynamic/data.go deleted file mode 100644 index f93d110b81b..00000000000 --- a/packer_test/plugin_tester/datasource/dynamic/data.go +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -//go:generate packer-sdc mapstructure-to-hcl2 -type Config,NestedFirst,NestedSecond,DatasourceOutput -package dynamic - -import ( - "log" - - "github.com/hashicorp/hcl/v2/hcldec" - "github.com/hashicorp/packer-plugin-sdk/hcl2helper" - "github.com/hashicorp/packer-plugin-sdk/template/config" - "github.com/zclconf/go-cty/cty" -) - -type NestedSecond struct { - Name string `mapstructure:"name" required:"true"` -} - -type NestedFirst struct { - Name string `mapstructure:"name" required:"true"` - Nesteds []NestedSecond `mapstructure:"extra" required:"false"` -} - -type Config struct { - Nesteds []NestedFirst `mapstructure:"extra" required:"false"` -} - -type Datasource struct { - config Config -} - -type DatasourceOutput struct { - Status string `mapstructure:"data"` -} - -func (d *Datasource) ConfigSpec() hcldec.ObjectSpec { - return d.config.FlatMapstructure().HCL2Spec() -} - -func (d *Datasource) Configure(raws ...interface{}) error { - err := config.Decode(&d.config, nil, raws...) - if err != nil { - return err - } - return nil -} - -func (d *Datasource) OutputSpec() hcldec.ObjectSpec { - return (&DatasourceOutput{}).FlatMapstructure().HCL2Spec() -} - -func (d *Datasource) Execute() (cty.Value, error) { - log.Printf("[DATASOURCE-DYNAMIC] Executing datasource dynamic") - for _, nest := range d.config.Nesteds { - log.Printf("[DATASOURCE-DYNAMIC] - First nest: %s", nest.Name) - for _, nestedConfig := range nest.Nesteds { - log.Printf("[DATASOURCE-DYNAMIC] - Second nest: %s.%s", nest.Name, nestedConfig.Name) - } - } - - output := DatasourceOutput{ - Status: "OK", - } - return hcl2helper.HCL2ValueFromConfig(output, d.OutputSpec()), nil -} diff --git a/packer_test/plugin_tester/datasource/dynamic/data.hcl2spec.go b/packer_test/plugin_tester/datasource/dynamic/data.hcl2spec.go deleted file mode 100644 index cd030dc03f8..00000000000 --- a/packer_test/plugin_tester/datasource/dynamic/data.hcl2spec.go +++ /dev/null @@ -1,102 +0,0 @@ -// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. - -package dynamic - -import ( - "github.com/hashicorp/hcl/v2/hcldec" - "github.com/zclconf/go-cty/cty" -) - -// FlatConfig is an auto-generated flat version of Config. -// Where the contents of a field with a `mapstructure:,squash` tag are bubbled up. -type FlatConfig struct { - Nesteds []FlatNestedFirst `mapstructure:"extra" required:"false" cty:"extra" hcl:"extra"` -} - -// FlatMapstructure returns a new FlatConfig. -// FlatConfig is an auto-generated flat version of Config. -// Where the contents a fields with a `mapstructure:,squash` tag are bubbled up. -func (*Config) FlatMapstructure() interface{ HCL2Spec() map[string]hcldec.Spec } { - return new(FlatConfig) -} - -// HCL2Spec returns the hcl spec of a Config. -// This spec is used by HCL to read the fields of Config. -// The decoded values from this spec will then be applied to a FlatConfig. -func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec { - s := map[string]hcldec.Spec{ - "extra": &hcldec.BlockListSpec{TypeName: "extra", Nested: hcldec.ObjectSpec((*FlatNestedFirst)(nil).HCL2Spec())}, - } - return s -} - -// FlatDatasourceOutput is an auto-generated flat version of DatasourceOutput. -// Where the contents of a field with a `mapstructure:,squash` tag are bubbled up. -type FlatDatasourceOutput struct { - Status *string `mapstructure:"data" cty:"data" hcl:"data"` -} - -// FlatMapstructure returns a new FlatDatasourceOutput. -// FlatDatasourceOutput is an auto-generated flat version of DatasourceOutput. -// Where the contents a fields with a `mapstructure:,squash` tag are bubbled up. -func (*DatasourceOutput) FlatMapstructure() interface{ HCL2Spec() map[string]hcldec.Spec } { - return new(FlatDatasourceOutput) -} - -// HCL2Spec returns the hcl spec of a DatasourceOutput. -// This spec is used by HCL to read the fields of DatasourceOutput. -// The decoded values from this spec will then be applied to a FlatDatasourceOutput. -func (*FlatDatasourceOutput) HCL2Spec() map[string]hcldec.Spec { - s := map[string]hcldec.Spec{ - "data": &hcldec.AttrSpec{Name: "data", Type: cty.String, Required: false}, - } - return s -} - -// FlatNestedFirst is an auto-generated flat version of NestedFirst. -// Where the contents of a field with a `mapstructure:,squash` tag are bubbled up. -type FlatNestedFirst struct { - Name *string `mapstructure:"name" required:"true" cty:"name" hcl:"name"` - Nesteds []FlatNestedSecond `mapstructure:"extra" required:"false" cty:"extra" hcl:"extra"` -} - -// FlatMapstructure returns a new FlatNestedFirst. -// FlatNestedFirst is an auto-generated flat version of NestedFirst. -// Where the contents a fields with a `mapstructure:,squash` tag are bubbled up. -func (*NestedFirst) FlatMapstructure() interface{ HCL2Spec() map[string]hcldec.Spec } { - return new(FlatNestedFirst) -} - -// HCL2Spec returns the hcl spec of a NestedFirst. -// This spec is used by HCL to read the fields of NestedFirst. -// The decoded values from this spec will then be applied to a FlatNestedFirst. -func (*FlatNestedFirst) HCL2Spec() map[string]hcldec.Spec { - s := map[string]hcldec.Spec{ - "name": &hcldec.AttrSpec{Name: "name", Type: cty.String, Required: false}, - "extra": &hcldec.BlockListSpec{TypeName: "extra", Nested: hcldec.ObjectSpec((*FlatNestedSecond)(nil).HCL2Spec())}, - } - return s -} - -// FlatNestedSecond is an auto-generated flat version of NestedSecond. -// Where the contents of a field with a `mapstructure:,squash` tag are bubbled up. -type FlatNestedSecond struct { - Name *string `mapstructure:"name" required:"true" cty:"name" hcl:"name"` -} - -// FlatMapstructure returns a new FlatNestedSecond. -// FlatNestedSecond is an auto-generated flat version of NestedSecond. -// Where the contents a fields with a `mapstructure:,squash` tag are bubbled up. -func (*NestedSecond) FlatMapstructure() interface{ HCL2Spec() map[string]hcldec.Spec } { - return new(FlatNestedSecond) -} - -// HCL2Spec returns the hcl spec of a NestedSecond. -// This spec is used by HCL to read the fields of NestedSecond. -// The decoded values from this spec will then be applied to a FlatNestedSecond. -func (*FlatNestedSecond) HCL2Spec() map[string]hcldec.Spec { - s := map[string]hcldec.Spec{ - "name": &hcldec.AttrSpec{Name: "name", Type: cty.String, Required: false}, - } - return s -} diff --git a/packer_test/plugin_tester/datasource/dynamic/data_acc_test.go b/packer_test/plugin_tester/datasource/dynamic/data_acc_test.go deleted file mode 100644 index fc5d18a1a4c..00000000000 --- a/packer_test/plugin_tester/datasource/dynamic/data_acc_test.go +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package dynamic - -import ( - _ "embed" - "fmt" - "io/ioutil" - "os" - "os/exec" - "regexp" - "testing" - - "github.com/hashicorp/packer-plugin-sdk/acctest" -) - -//go:embed test-fixtures/template.pkr.hcl -var testDatasourceHCL2Basic string - -// Run with: PACKER_ACC=1 go test -count 1 -v ./datasource/scaffolding/data_acc_test.go -timeout=120m -func TestAccScaffoldingDatasource(t *testing.T) { - testCase := &acctest.PluginTestCase{ - Name: "scaffolding_datasource_basic_test", - Setup: func() error { - return nil - }, - Teardown: func() error { - return nil - }, - Template: testDatasourceHCL2Basic, - Type: "scaffolding-my-datasource", - Check: func(buildCommand *exec.Cmd, logfile string) error { - if buildCommand.ProcessState != nil { - if buildCommand.ProcessState.ExitCode() != 0 { - return fmt.Errorf("Bad exit code. Logfile: %s", logfile) - } - } - - logs, err := os.Open(logfile) - if err != nil { - return fmt.Errorf("Unable find %s", logfile) - } - defer logs.Close() - - logsBytes, err := ioutil.ReadAll(logs) - if err != nil { - return fmt.Errorf("Unable to read %s", logfile) - } - logsString := string(logsBytes) - - fooLog := "null.basic-example: foo: foo-value" - barLog := "null.basic-example: bar: bar-value" - - if matched, _ := regexp.MatchString(fooLog+".*", logsString); !matched { - t.Fatalf("logs doesn't contain expected foo value %q", logsString) - } - if matched, _ := regexp.MatchString(barLog+".*", logsString); !matched { - t.Fatalf("logs doesn't contain expected bar value %q", logsString) - } - return nil - }, - } - acctest.TestPlugin(t, testCase) -} diff --git a/packer_test/plugin_tester/datasource/dynamic/test-fixtures/template.pkr.hcl b/packer_test/plugin_tester/datasource/dynamic/test-fixtures/template.pkr.hcl deleted file mode 100644 index f529d1ef18d..00000000000 --- a/packer_test/plugin_tester/datasource/dynamic/test-fixtures/template.pkr.hcl +++ /dev/null @@ -1,28 +0,0 @@ -# Copyright (c) HashiCorp, Inc. -# SPDX-License-Identifier: MPL-2.0 - -data "scaffolding-my-datasource" "test" { - mock = "mock-config" -} - -locals { - foo = data.scaffolding-my-datasource.test.foo - bar = data.scaffolding-my-datasource.test.bar -} - -source "null" "basic-example" { - communicator = "none" -} - -build { - sources = [ - "source.null.basic-example" - ] - - provisioner "shell-local" { - inline = [ - "echo foo: ${local.foo}", - "echo bar: ${local.bar}", - ] - } -} diff --git a/packer_test/plugin_tester/datasource/parrot/data.go b/packer_test/plugin_tester/datasource/parrot/data.go deleted file mode 100644 index dc3b0fe56be..00000000000 --- a/packer_test/plugin_tester/datasource/parrot/data.go +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -//go:generate packer-sdc mapstructure-to-hcl2 -type Config,DatasourceOutput -package parrot - -import ( - "github.com/hashicorp/hcl/v2/hcldec" - "github.com/hashicorp/packer-plugin-sdk/hcl2helper" - "github.com/hashicorp/packer-plugin-sdk/template/config" - "github.com/zclconf/go-cty/cty" -) - -type Config struct { - Input []string `mapstructure:"input" required:"true"` -} - -type Datasource struct { - config Config -} - -type DatasourceOutput struct { - Output []string `mapstructure:"out"` -} - -func (d *Datasource) ConfigSpec() hcldec.ObjectSpec { - return d.config.FlatMapstructure().HCL2Spec() -} - -func (d *Datasource) Configure(raws ...interface{}) error { - err := config.Decode(&d.config, nil, raws...) - if err != nil { - return err - } - return nil -} - -func (d *Datasource) OutputSpec() hcldec.ObjectSpec { - return (&DatasourceOutput{}).FlatMapstructure().HCL2Spec() -} - -func (d *Datasource) Execute() (cty.Value, error) { - out := []string{} - for _, d := range d.config.Input { - out = append(out, d) - } - - output := DatasourceOutput{ - Output: out, - } - return hcl2helper.HCL2ValueFromConfig(output, d.OutputSpec()), nil -} diff --git a/packer_test/plugin_tester/datasource/parrot/data.hcl2spec.go b/packer_test/plugin_tester/datasource/parrot/data.hcl2spec.go deleted file mode 100644 index 8c7ec8ad75f..00000000000 --- a/packer_test/plugin_tester/datasource/parrot/data.hcl2spec.go +++ /dev/null @@ -1,54 +0,0 @@ -// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. - -package parrot - -import ( - "github.com/hashicorp/hcl/v2/hcldec" - "github.com/zclconf/go-cty/cty" -) - -// FlatConfig is an auto-generated flat version of Config. -// Where the contents of a field with a `mapstructure:,squash` tag are bubbled up. -type FlatConfig struct { - Input []string `mapstructure:"input" required:"true" cty:"input" hcl:"input"` -} - -// FlatMapstructure returns a new FlatConfig. -// FlatConfig is an auto-generated flat version of Config. -// Where the contents a fields with a `mapstructure:,squash` tag are bubbled up. -func (*Config) FlatMapstructure() interface{ HCL2Spec() map[string]hcldec.Spec } { - return new(FlatConfig) -} - -// HCL2Spec returns the hcl spec of a Config. -// This spec is used by HCL to read the fields of Config. -// The decoded values from this spec will then be applied to a FlatConfig. -func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec { - s := map[string]hcldec.Spec{ - "input": &hcldec.AttrSpec{Name: "input", Type: cty.List(cty.String), Required: false}, - } - return s -} - -// FlatDatasourceOutput is an auto-generated flat version of DatasourceOutput. -// Where the contents of a field with a `mapstructure:,squash` tag are bubbled up. -type FlatDatasourceOutput struct { - Output []string `mapstructure:"out" cty:"out" hcl:"out"` -} - -// FlatMapstructure returns a new FlatDatasourceOutput. -// FlatDatasourceOutput is an auto-generated flat version of DatasourceOutput. -// Where the contents a fields with a `mapstructure:,squash` tag are bubbled up. -func (*DatasourceOutput) FlatMapstructure() interface{ HCL2Spec() map[string]hcldec.Spec } { - return new(FlatDatasourceOutput) -} - -// HCL2Spec returns the hcl spec of a DatasourceOutput. -// This spec is used by HCL to read the fields of DatasourceOutput. -// The decoded values from this spec will then be applied to a FlatDatasourceOutput. -func (*FlatDatasourceOutput) HCL2Spec() map[string]hcldec.Spec { - s := map[string]hcldec.Spec{ - "out": &hcldec.AttrSpec{Name: "out", Type: cty.List(cty.String), Required: false}, - } - return s -} diff --git a/packer_test/plugin_tester/datasource/sleeper/data.go b/packer_test/plugin_tester/datasource/sleeper/data.go deleted file mode 100644 index f6b2671b692..00000000000 --- a/packer_test/plugin_tester/datasource/sleeper/data.go +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -//go:generate packer-sdc mapstructure-to-hcl2 -type Config,DatasourceOutput -package sleeper - -import ( - "log" - "time" - - "github.com/hashicorp/hcl/v2/hcldec" - "github.com/hashicorp/packer-plugin-sdk/hcl2helper" - "github.com/hashicorp/packer-plugin-sdk/template/config" - "github.com/zclconf/go-cty/cty" -) - -type Config struct { - Duration string `mapstructure:"duration" required:"true"` -} - -type Datasource struct { - config Config - durationTime time.Duration -} - -type DatasourceOutput struct { - Status bool `mapstructure:"status"` -} - -func (d *Datasource) ConfigSpec() hcldec.ObjectSpec { - return d.config.FlatMapstructure().HCL2Spec() -} - -func (d *Datasource) Configure(raws ...interface{}) error { - err := config.Decode(&d.config, nil, raws...) - if err != nil { - return err - } - - dt, err := time.ParseDuration(d.config.Duration) - if err != nil { - return err - } - - d.durationTime = dt - - return nil -} - -func (d *Datasource) OutputSpec() hcldec.ObjectSpec { - return (&DatasourceOutput{}).FlatMapstructure().HCL2Spec() -} - -func (d *Datasource) Execute() (cty.Value, error) { - log.Printf("[sleeper] Sleeping for %s", d.config.Duration) - time.Sleep(d.durationTime) - log.Printf("[sleeper] Done sleeping!") - - output := DatasourceOutput{ - Status: true, - } - return hcl2helper.HCL2ValueFromConfig(output, d.OutputSpec()), nil -} diff --git a/packer_test/plugin_tester/datasource/sleeper/data.hcl2spec.go b/packer_test/plugin_tester/datasource/sleeper/data.hcl2spec.go deleted file mode 100644 index bb5230ffb7b..00000000000 --- a/packer_test/plugin_tester/datasource/sleeper/data.hcl2spec.go +++ /dev/null @@ -1,54 +0,0 @@ -// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. - -package sleeper - -import ( - "github.com/hashicorp/hcl/v2/hcldec" - "github.com/zclconf/go-cty/cty" -) - -// FlatConfig is an auto-generated flat version of Config. -// Where the contents of a field with a `mapstructure:,squash` tag are bubbled up. -type FlatConfig struct { - Duration *string `mapstructure:"duration" required:"true" cty:"duration" hcl:"duration"` -} - -// FlatMapstructure returns a new FlatConfig. -// FlatConfig is an auto-generated flat version of Config. -// Where the contents a fields with a `mapstructure:,squash` tag are bubbled up. -func (*Config) FlatMapstructure() interface{ HCL2Spec() map[string]hcldec.Spec } { - return new(FlatConfig) -} - -// HCL2Spec returns the hcl spec of a Config. -// This spec is used by HCL to read the fields of Config. -// The decoded values from this spec will then be applied to a FlatConfig. -func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec { - s := map[string]hcldec.Spec{ - "duration": &hcldec.AttrSpec{Name: "duration", Type: cty.String, Required: false}, - } - return s -} - -// FlatDatasourceOutput is an auto-generated flat version of DatasourceOutput. -// Where the contents of a field with a `mapstructure:,squash` tag are bubbled up. -type FlatDatasourceOutput struct { - Status *bool `mapstructure:"status" cty:"status" hcl:"status"` -} - -// FlatMapstructure returns a new FlatDatasourceOutput. -// FlatDatasourceOutput is an auto-generated flat version of DatasourceOutput. -// Where the contents a fields with a `mapstructure:,squash` tag are bubbled up. -func (*DatasourceOutput) FlatMapstructure() interface{ HCL2Spec() map[string]hcldec.Spec } { - return new(FlatDatasourceOutput) -} - -// HCL2Spec returns the hcl spec of a DatasourceOutput. -// This spec is used by HCL to read the fields of DatasourceOutput. -// The decoded values from this spec will then be applied to a FlatDatasourceOutput. -func (*FlatDatasourceOutput) HCL2Spec() map[string]hcldec.Spec { - s := map[string]hcldec.Spec{ - "status": &hcldec.AttrSpec{Name: "status", Type: cty.Bool, Required: false}, - } - return s -} diff --git a/packer_test/plugin_tester/docs/README.md b/packer_test/plugin_tester/docs/README.md deleted file mode 100644 index 869c33565b3..00000000000 --- a/packer_test/plugin_tester/docs/README.md +++ /dev/null @@ -1,78 +0,0 @@ -# Scaffolding Plugins - - - -## Installation - -### Using pre-built releases - -#### Using the `packer init` command - -Starting from version 1.7, Packer supports a new `packer init` command allowing -automatic installation of Packer plugins. Read the -[Packer documentation](https://www.packer.io/docs/commands/init) for more information. - -To install this plugin, copy and paste this code into your Packer configuration . -Then, run [`packer init`](https://www.packer.io/docs/commands/init). - -```hcl -packer { - required_plugins { - name = { - version = ">= 0.0.1" - source = "github.com/hashicorp/name" - } - } -} -``` - -#### Manual installation - -You can find pre-built binary releases of the plugin [here](https://github.com/hashicorp/packer-plugin-name/releases). -Once you have downloaded the latest archive corresponding to your target OS, -uncompress it to retrieve the plugin binary file corresponding to your platform. -To install the plugin, please follow the Packer documentation on -[installing a plugin](https://www.packer.io/docs/extending/plugins/#installing-plugins). - - -#### From Source - -If you prefer to build the plugin from its source code, clone the GitHub -repository locally and run the command `go build` from the root -directory. Upon successful compilation, a `packer-plugin-name` plugin -binary file can be found in the root directory. -To install the compiled plugin, please follow the official Packer documentation -on [installing a plugin](https://www.packer.io/docs/extending/plugins/#installing-plugins). - - -## Plugin Contents - -The Scaffolding plugin is intended as a starting point for creating Packer plugins, containing: - -### Builders - -- [builder](/docs/builders/builder-name.mdx) - The scaffolding builder is used to create endless Packer - plugins using a consistent plugin structure. - -### Provisioners - -- [provisioner](/docs/provisioners/provisioner-name.mdx) - The scaffolding provisioner is used to provisioner - Packer builds. - -### Post-processors - -- [post-processor](/docs/post-processors/postprocessor-name.mdx) - The scaffolding post-processor is used to - export scaffolding builds. - -### Data Sources - -- [data source](/docs/datasources/datasource-name.mdx) - The scaffolding data source is used to - export scaffolding data. - diff --git a/packer_test/plugin_tester/docs/builders/builder-name.mdx b/packer_test/plugin_tester/docs/builders/builder-name.mdx deleted file mode 100644 index 73f33f9fba6..00000000000 --- a/packer_test/plugin_tester/docs/builders/builder-name.mdx +++ /dev/null @@ -1,63 +0,0 @@ ---- -description: > - The scaffolding builder is used to create endless Packer plugins using - a consistent plugin structure. -page_title: Scaffolding - Builders -nav_title: Scaffolding ---- - -# Scaffolding - -Type: `scaffolding` - - - -The scaffolding builder is used to create endless Packer plugins using -a consistent plugin structure. - - - - -### Required - -- `mock` (string) - The name of the mock to use for the Scaffolding API. - - - - -### Optional - -- `mock_api_url` (string) - The Scaffolding API endpoint to connect to. - Defaults to https://example.com - - - - -### Example Usage - - -```hcl - source "scaffolding" "example" { - mock = "bird" - } - - build { - sources = ["source.scaffolding.example"] - } -``` - - diff --git a/packer_test/plugin_tester/docs/datasources/datasource-name.mdx b/packer_test/plugin_tester/docs/datasources/datasource-name.mdx deleted file mode 100644 index 66dcb2f177b..00000000000 --- a/packer_test/plugin_tester/docs/datasources/datasource-name.mdx +++ /dev/null @@ -1,78 +0,0 @@ ---- -description: > - The scaffolding data source is used to create endless Packer plugins using - a consistent plugin structure. -page_title: Scaffolding - Data Sources -nav_title: Scaffolding ---- - -# Scaffolding - -Type: `scaffolding` - - - -The scaffolding data source is used to create endless Packer plugins using -a consistent plugin structure. - - - - -### Required - -- `mock` (string) - The name of the mock to use for the Scaffolding API. - - - - -### Optional - -- `mock_api_url` (string) - The Scaffolding API endpoint to connect to. - Defaults to https://example.com - - - - - -### OutPut - -- `foo` (string) - The Scaffolding output foo value. -- `bar` (string) - The Scaffolding output bar value. - - - -### Example Usage - - -```hcl -data "scaffolding" "example" { - mock = "bird" - } - source "scaffolding" "example" { - mock = data.scaffolding.example.foo - } - - build { - sources = ["source.scaffolding.example"] - } -``` - - diff --git a/packer_test/plugin_tester/docs/post-processors/postprocessor-name.mdx b/packer_test/plugin_tester/docs/post-processors/postprocessor-name.mdx deleted file mode 100644 index df6c03b470d..00000000000 --- a/packer_test/plugin_tester/docs/post-processors/postprocessor-name.mdx +++ /dev/null @@ -1,59 +0,0 @@ ---- -description: > - The scaffolding post-processor is used to export Packer Scaffolding builds. -page_title: Scaffolding - Post-Processors -nav_title: Scaffolding ---- - -# Scaffolding - -Type: `scaffolding` - - - -The scaffolding post-processor is used to export Packer Scaffolding builds. - - - - -### Required - -- `mock` (string) - The output path where to save exported build to. - - - -### Optional - - - -### Example Usage - - -```hcl - source "scaffolding" "example" { - mock = "jay" - } - - build { - sources = ["source.scaffolding.example"] - - post-processor "scaffolding" { - mock = "builds/scaffolding.box" - } - } -``` - diff --git a/packer_test/plugin_tester/docs/provisioners/provisioner-name.mdx b/packer_test/plugin_tester/docs/provisioners/provisioner-name.mdx deleted file mode 100644 index 34930dfd109..00000000000 --- a/packer_test/plugin_tester/docs/provisioners/provisioner-name.mdx +++ /dev/null @@ -1,62 +0,0 @@ ---- -description: > - The scaffolding provisioner is used to provisioner Packer builds. -page_title: Scaffolding - Provisioners -nav_title: Scaffolding ---- - -# Scaffolding - -Type: `scaffolding` - - - -The scaffolding provisioner is used to provisioner Packer builds. - - - - -### Required - -- `mock` (string) - The name of the mock string to display. - - - - -### Optional - - - -### Example Usage - - -```hcl - source "null" "example" { - communicator = "none" - } - - build { - source "null.example" { - name = "jay" - } - - provisioner "scaffolding" { - mock = "mocking ${source.name}" - } - } -``` - diff --git a/packer_test/plugin_tester/example/README.md b/packer_test/plugin_tester/example/README.md deleted file mode 100644 index ced3cc8964f..00000000000 --- a/packer_test/plugin_tester/example/README.md +++ /dev/null @@ -1,20 +0,0 @@ -## The Example Folder - -This folder must contain a fully working example of the plugin usage. The example must define the `required_plugins` -block. A pre-defined GitHub Action will run `packer init`, `packer validate`, and `packer build` to test your plugin -with the latest version available of Packer. - -The folder can contain multiple HCL2 compatible files. The action will execute Packer at this folder level -running `packer init -upgrade .` and `packer build .`. - -If the plugin requires authentication, the configuration should be provided via GitHub Secrets and set as environment -variables in the [test-plugin-example.yml](/.github/workflows/test-plugin-example.yml) file. Example: - -```yml - - name: Build - working-directory: ${{ github.event.inputs.folder }} - run: PACKER_LOG=${{ github.event.inputs.logs }} packer build . - env: - AUTH_KEY: ${{ secrets.AUTH_KEY }} - AUTH_PASSWORD: ${{ secrets.AUTH_PASSWORD }} -``` \ No newline at end of file diff --git a/packer_test/plugin_tester/example/build.pkr.hcl b/packer_test/plugin_tester/example/build.pkr.hcl deleted file mode 100644 index 272fe80307c..00000000000 --- a/packer_test/plugin_tester/example/build.pkr.hcl +++ /dev/null @@ -1,43 +0,0 @@ -# Copyright (c) HashiCorp, Inc. -# SPDX-License-Identifier: MPL-2.0 - -packer { - required_plugins { - scaffolding = { - version = ">=v0.1.0" - source = "github.com/hashicorp/scaffolding" - } - } -} - -source "scaffolding-my-builder" "foo-example" { - mock = local.foo -} - -source "scaffolding-my-builder" "bar-example" { - mock = local.bar -} - -build { - sources = [ - "source.scaffolding-my-builder.foo-example", - ] - - source "source.scaffolding-my-builder.bar-example" { - name = "bar" - } - - provisioner "scaffolding-my-provisioner" { - only = ["scaffolding-my-builder.foo-example"] - mock = "foo: ${local.foo}" - } - - provisioner "scaffolding-my-provisioner" { - only = ["scaffolding-my-builder.bar"] - mock = "bar: ${local.bar}" - } - - post-processor "scaffolding-my-post-processor" { - mock = "post-processor mock-config" - } -} diff --git a/packer_test/plugin_tester/example/data.pkr.hcl b/packer_test/plugin_tester/example/data.pkr.hcl deleted file mode 100644 index 4e0f26411e4..00000000000 --- a/packer_test/plugin_tester/example/data.pkr.hcl +++ /dev/null @@ -1,6 +0,0 @@ -# Copyright (c) HashiCorp, Inc. -# SPDX-License-Identifier: MPL-2.0 - -data "scaffolding-my-datasource" "mock-data" { - mock = "mock-config" -} \ No newline at end of file diff --git a/packer_test/plugin_tester/example/variables.pkr.hcl b/packer_test/plugin_tester/example/variables.pkr.hcl deleted file mode 100644 index 8f524b7e783..00000000000 --- a/packer_test/plugin_tester/example/variables.pkr.hcl +++ /dev/null @@ -1,7 +0,0 @@ -# Copyright (c) HashiCorp, Inc. -# SPDX-License-Identifier: MPL-2.0 - -locals { - foo = data.scaffolding-my-datasource.mock-data.foo - bar = data.scaffolding-my-datasource.mock-data.bar -} \ No newline at end of file diff --git a/packer_test/plugin_tester/go.mod b/packer_test/plugin_tester/go.mod deleted file mode 100644 index d80f45d1efe..00000000000 --- a/packer_test/plugin_tester/go.mod +++ /dev/null @@ -1,97 +0,0 @@ -module github.com/hashicorp/packer-plugin-tester - -go 1.20 - -require ( - github.com/hashicorp/hcl/v2 v2.19.1 - github.com/hashicorp/packer-plugin-sdk v0.5.3 - github.com/zclconf/go-cty v1.13.3 -) - -require ( - cloud.google.com/go v0.105.0 // indirect - cloud.google.com/go/compute v1.12.1 // indirect - cloud.google.com/go/compute/metadata v0.1.1 // indirect - cloud.google.com/go/iam v0.6.0 // indirect - cloud.google.com/go/storage v1.27.0 // indirect - github.com/Azure/go-ntlmssp v0.0.0-20200615164410-66371956d46c // indirect - github.com/ChrisTrenkamp/goxpath v0.0.0-20210404020558-97928f7e12b6 // indirect - github.com/agext/levenshtein v1.2.3 // indirect - github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect - github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect - github.com/armon/go-metrics v0.4.1 // indirect - github.com/aws/aws-sdk-go v1.45.6 // indirect - github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect - github.com/cenkalti/backoff/v3 v3.2.2 // indirect - github.com/dylanmei/iso8601 v0.1.0 // indirect - github.com/fatih/color v1.14.1 // indirect - github.com/go-jose/go-jose/v3 v3.0.3 // indirect - github.com/gofrs/flock v0.8.1 // indirect - github.com/gofrs/uuid v4.0.0+incompatible // indirect - github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect - github.com/golang/protobuf v1.5.2 // indirect - github.com/google/go-cmp v0.5.9 // indirect - github.com/google/uuid v1.3.0 // indirect - github.com/googleapis/enterprise-certificate-proxy v0.2.0 // indirect - github.com/googleapis/gax-go/v2 v2.6.0 // indirect - github.com/hashicorp/consul/api v1.25.1 // indirect - github.com/hashicorp/errwrap v1.1.0 // indirect - github.com/hashicorp/go-cleanhttp v0.5.2 // indirect - github.com/hashicorp/go-getter/gcs/v2 v2.2.1 // indirect - github.com/hashicorp/go-getter/s3/v2 v2.2.1 // indirect - github.com/hashicorp/go-getter/v2 v2.2.1 // indirect - github.com/hashicorp/go-hclog v1.5.0 // indirect - github.com/hashicorp/go-immutable-radix v1.3.1 // indirect - github.com/hashicorp/go-multierror v1.1.1 // indirect - github.com/hashicorp/go-retryablehttp v0.7.0 // indirect - github.com/hashicorp/go-rootcerts v1.0.2 // indirect - github.com/hashicorp/go-safetemp v1.0.0 // indirect - github.com/hashicorp/go-secure-stdlib/parseutil v0.1.6 // indirect - github.com/hashicorp/go-secure-stdlib/strutil v0.1.2 // indirect - github.com/hashicorp/go-sockaddr v1.0.2 // indirect - github.com/hashicorp/go-version v1.6.0 // indirect - github.com/hashicorp/golang-lru v0.5.4 // indirect - github.com/hashicorp/hcl v1.0.0 // indirect - github.com/hashicorp/serf v0.10.1 // indirect - github.com/hashicorp/vault/api v1.10.0 // indirect - github.com/hashicorp/yamux v0.1.1 // indirect - github.com/jehiah/go-strftime v0.0.0-20171201141054-1d33003b3869 // indirect - github.com/jmespath/go-jmespath v0.4.0 // indirect - github.com/klauspost/compress v1.11.2 // indirect - github.com/kr/fs v0.1.0 // indirect - github.com/masterzen/simplexml v0.0.0-20190410153822-31eea3082786 // indirect - github.com/masterzen/winrm v0.0.0-20210623064412-3b76017826b0 // indirect - github.com/mattn/go-colorable v0.1.13 // indirect - github.com/mattn/go-isatty v0.0.17 // indirect - github.com/mitchellh/go-fs v0.0.0-20180402235330-b7b9ca407fff // indirect - github.com/mitchellh/go-homedir v1.1.0 // indirect - github.com/mitchellh/go-testing-interface v1.14.1 // indirect - github.com/mitchellh/go-wordwrap v1.0.1 // indirect - github.com/mitchellh/iochan v1.0.0 // indirect - github.com/mitchellh/mapstructure v1.5.0 // indirect - github.com/mitchellh/reflectwalk v1.0.0 // indirect - github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d // indirect - github.com/packer-community/winrmcp v0.0.0-20180921211025-c76d91c1e7db // indirect - github.com/pkg/sftp v1.13.2 // indirect - github.com/ryanuber/go-glob v1.0.0 // indirect - github.com/ugorji/go/codec v1.2.6 // indirect - github.com/ulikunitz/xz v0.5.10 // indirect - go.opencensus.io v0.23.0 // indirect - golang.org/x/crypto v0.21.0 // indirect - golang.org/x/exp v0.0.0-20230321023759-10a507213a29 // indirect - golang.org/x/net v0.23.0 // indirect - golang.org/x/oauth2 v0.1.0 // indirect - golang.org/x/sys v0.18.0 // indirect - golang.org/x/term v0.18.0 // indirect - golang.org/x/text v0.14.0 // indirect - golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac // indirect - golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect - google.golang.org/api v0.101.0 // indirect - google.golang.org/appengine v1.6.7 // indirect - google.golang.org/genproto v0.0.0-20221027153422-115e99e71e1c // indirect - google.golang.org/grpc v1.50.1 // indirect - google.golang.org/protobuf v1.28.1 // indirect - gopkg.in/yaml.v2 v2.3.0 // indirect -) - -replace github.com/zclconf/go-cty => github.com/nywilken/go-cty v1.13.3 // added by packer-sdc fix as noted in github.com/hashicorp/packer-plugin-sdk/issues/187 diff --git a/packer_test/plugin_tester/go.sum b/packer_test/plugin_tester/go.sum deleted file mode 100644 index 6a97cef0d5c..00000000000 --- a/packer_test/plugin_tester/go.sum +++ /dev/null @@ -1,480 +0,0 @@ -cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -cloud.google.com/go v0.105.0 h1:DNtEKRBAAzeS4KyIory52wWHuClNaXJ5x1F7xa4q+5Y= -cloud.google.com/go v0.105.0/go.mod h1:PrLgOJNe5nfE9UMxKxgXj4mD3voiP+YQ6gdt6KMFOKM= -cloud.google.com/go/compute v1.12.1 h1:gKVJMEyqV5c/UnpzjjQbo3Rjvvqpr9B1DFSbJC4OXr0= -cloud.google.com/go/compute v1.12.1/go.mod h1:e8yNOBcBONZU1vJKCvCoDw/4JQsA0dpM4x/6PIIOocU= -cloud.google.com/go/compute/metadata v0.1.1 h1:/sxEbyrm6cw+XOUw1YxBHlatV71z4vpnmO7z2IZ0h3I= -cloud.google.com/go/compute/metadata v0.1.1/go.mod h1:Z1VN+bulIf6bt4P/C37K4DyZYZEXYonfTBHHFPO/4UU= -cloud.google.com/go/iam v0.6.0 h1:nsqQC88kT5Iwlm4MeNGTpfMWddp6NB/UOLFTH6m1QfQ= -cloud.google.com/go/iam v0.6.0/go.mod h1:+1AH33ueBne5MzYccyMHtEKqLE4/kJOibtffMHDMFMc= -cloud.google.com/go/longrunning v0.1.1 h1:y50CXG4j0+qvEukslYFBCrzaXX0qpFbBzc3PchSu/LE= -cloud.google.com/go/storage v1.27.0 h1:YOO045NZI9RKfCj1c5A/ZtuuENUc8OAW+gHdGnDgyMQ= -cloud.google.com/go/storage v1.27.0/go.mod h1:x9DOL8TK/ygDUMieqwfhdpQryTeEkhGKMi80i/iqR2s= -github.com/Azure/go-ntlmssp v0.0.0-20180810175552-4a21cbd618b4/go.mod h1:chxPXzSsl7ZWRAuOIE23GDNzjWuZquvFlgA8xmpunjU= -github.com/Azure/go-ntlmssp v0.0.0-20200615164410-66371956d46c h1:/IBSNwUN8+eKzUzbJPqhK839ygXJ82sde8x3ogr6R28= -github.com/Azure/go-ntlmssp v0.0.0-20200615164410-66371956d46c/go.mod h1:chxPXzSsl7ZWRAuOIE23GDNzjWuZquvFlgA8xmpunjU= -github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/ChrisTrenkamp/goxpath v0.0.0-20170922090931-c385f95c6022/go.mod h1:nuWgzSkT5PnyOd+272uUmV0dnAnAn42Mk7PiQC5VzN4= -github.com/ChrisTrenkamp/goxpath v0.0.0-20210404020558-97928f7e12b6 h1:w0E0fgc1YafGEh5cROhlROMWXiNoZqApk2PDN0M1+Ns= -github.com/ChrisTrenkamp/goxpath v0.0.0-20210404020558-97928f7e12b6/go.mod h1:nuWgzSkT5PnyOd+272uUmV0dnAnAn42Mk7PiQC5VzN4= -github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= -github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo= -github.com/agext/levenshtein v1.2.3/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= -github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= -github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= -github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= -github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= -github.com/antchfx/xmlquery v1.3.5 h1:I7TuBRqsnfFuL11ruavGm911Awx9IqSdiU6W/ztSmVw= -github.com/antchfx/xpath v1.1.11 h1:WOFtK8TVAjLm3lbgqeP0arlHpvCEeTANeWZ/csPpJkQ= -github.com/apparentlymart/go-dump v0.0.0-20180507223929-23540a00eaa3 h1:ZSTrOEhiM5J5RFxEaFvMZVEAM1KvT1YzbEOwB2EAGjA= -github.com/apparentlymart/go-textseg/v13 v13.0.0 h1:Y+KvPE1NYz0xl601PVImeQfFyEy6iT90AvPUL1NNfNw= -github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkEghdlcqw7yxLeM89kiTRPUo= -github.com/apparentlymart/go-textseg/v15 v15.0.0 h1:uYvfpb3DyLSCGWnctWKGj857c6ew1u1fNQOlOtuGxQY= -github.com/apparentlymart/go-textseg/v15 v15.0.0/go.mod h1:K8XmNZdhEBkdlyDdvbmmsvpAG721bKi0joRfFdHIWJ4= -github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= -github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= -github.com/armon/go-metrics v0.4.1 h1:hR91U9KYmb6bLBYLQjyM+3j+rcd/UhE+G78SFnF8gJA= -github.com/armon/go-metrics v0.4.1/go.mod h1:E6amYzXo6aW1tqzoZGT755KkbgrJsSdpwZ+3JqfkOG4= -github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= -github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= -github.com/aws/aws-sdk-go v1.45.6 h1:Y2isQQBZsnO15dzUQo9YQRThtHgrV200XCH05BRHVJI= -github.com/aws/aws-sdk-go v1.45.6/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= -github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= -github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= -github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= -github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d h1:xDfNPAt8lFiC1UJrqV3uuy861HCTo708pDMbjHHdCas= -github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d/go.mod h1:6QX/PXZ00z/TKoufEY6K/a0k6AhaJrQKdFe6OfVXsa4= -github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= -github.com/cenkalti/backoff/v3 v3.2.2 h1:cfUAAO3yvKMYKPrvhDuHSwQnhZNk/RMHKdZqKTxfm6M= -github.com/cenkalti/backoff/v3 v3.2.2/go.mod h1:cIeZDE3IrqwwJl6VUwCN6trj1oXrTS4rc0ij+ULvLYs= -github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= -github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/circonus-labs/circonus-gometrics v2.3.1+incompatible/go.mod h1:nmEj6Dob7S7YxXgwXpfOuvO54S+tGdZdw9fuRZt25Ag= -github.com/circonus-labs/circonusllhist v0.1.3/go.mod h1:kMXHVDlOchFAehlya5ePtbp5jckzBHf4XRpQvBOLI+I= -github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= -github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= -github.com/dylanmei/iso8601 v0.1.0 h1:812NGQDBcqquTfH5Yeo7lwR0nzx/cKdsmf3qMjPURUI= -github.com/dylanmei/iso8601 v0.1.0/go.mod h1:w9KhXSgIyROl1DefbMYIE7UVSIvELTbMrCfx+QkYnoQ= -github.com/dylanmei/winrmtest v0.0.0-20210303004826-fbc9ae56efb6 h1:zWydSUQBJApHwpQ4guHi+mGyQN/8yN6xbKWdDtL3ZNM= -github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= -github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= -github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= -github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= -github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU= -github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= -github.com/fatih/color v1.14.1 h1:qfhVLaG5s+nCROl1zJsZRxFeYrHLqWroPOQ8BWiNb4w= -github.com/fatih/color v1.14.1/go.mod h1:2oHN61fhTpgcxD3TSWCgKDiH1+x4OiDVVGH8WlgGZGg= -github.com/go-jose/go-jose/v3 v3.0.3 h1:fFKWeig/irsp7XD2zBxvnmA/XaRWp5V3CBsZXJF7G7k= -github.com/go-jose/go-jose/v3 v3.0.3/go.mod h1:5b+7YgP7ZICgJDBdfjZaIt+H/9L9T/YQrVfLAMboGkQ= -github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= -github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= -github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= -github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= -github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= -github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68= -github.com/gofrs/flock v0.8.1 h1:+gYjHKf32LDeiEEFhQaotPbLuUXjY5ZqxKgXy7n59aw= -github.com/gofrs/flock v0.8.1/go.mod h1:F1TvTiK9OcQqauNUHlbJvyl9Qa1QvF/gOUDKA14jxHU= -github.com/gofrs/uuid v3.2.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= -github.com/gofrs/uuid v4.0.0+incompatible h1:1SD/1F5pU8p29ybwgQSwpQk+mwdRrXCYuPhW6m+TnJw= -github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= -github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= -github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= -github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE= -github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= -github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= -github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= -github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= -github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= -github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= -github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= -github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= -github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= -github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= -github.com/google/btree v1.0.1 h1:gK4Kx5IaGY9CD5sPJ36FHiBJ6ZXl0kilRiiCj+jdYp4= -github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= -github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= -github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/martian/v3 v3.2.1 h1:d8MncMlErDFTwQGBK1xhv026j9kqhvw1Qv9IbWT1VLQ= -github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/googleapis/enterprise-certificate-proxy v0.2.0 h1:y8Yozv7SZtlU//QXbezB6QkpuE6jMD2/gfzk4AftXjs= -github.com/googleapis/enterprise-certificate-proxy v0.2.0/go.mod h1:8C0jb7/mgJe/9KK8Lm7X9ctZC2t60YyIpYEI16jx0Qg= -github.com/googleapis/gax-go/v2 v2.6.0 h1:SXk3ABtQYDT/OH8jAyvEOQ58mgawq5C4o/4/89qN2ZU= -github.com/googleapis/gax-go/v2 v2.6.0/go.mod h1:1mjbznJAPHFpesgE5ucqfYEscaz5kMdcIDwU/6+DDoY= -github.com/hashicorp/consul/api v1.25.1 h1:CqrdhYzc8XZuPnhIYZWH45toM0LB9ZeYr/gvpLVI3PE= -github.com/hashicorp/consul/api v1.25.1/go.mod h1:iiLVwR/htV7mas/sy0O+XSuEnrdBUUydemjxcUrAt4g= -github.com/hashicorp/consul/sdk v0.14.1 h1:ZiwE2bKb+zro68sWzZ1SgHF3kRMBZ94TwOCFRF4ylPs= -github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= -github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I= -github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= -github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= -github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= -github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ= -github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48= -github.com/hashicorp/go-getter/gcs/v2 v2.2.1 h1:yZgDXYy5m4xogJV8hXzX5S/fM/rjJnBz+EzTeFrfLEM= -github.com/hashicorp/go-getter/gcs/v2 v2.2.1/go.mod h1:xzT3sNmGRipCRMpWz24fYHMvgb4MRn/smg5k2mhJ7Bo= -github.com/hashicorp/go-getter/s3/v2 v2.2.1 h1:Psuhz6iuCxJOd3kGinK46x+4BzcJgwff8BId7CuGPYU= -github.com/hashicorp/go-getter/s3/v2 v2.2.1/go.mod h1:KDqfEPgpwZIy+1sAplFX231CE+M6wdL5Q/j6OMbKSnw= -github.com/hashicorp/go-getter/v2 v2.2.1 h1:2JXqPZs1Jej67RtdTi0YZaEB2hEFB3fkBA4cPYKQwFQ= -github.com/hashicorp/go-getter/v2 v2.2.1/go.mod h1:EcJx6oZE8hmGuRR1l38QrfnyiujQbwsEAn11eHv6l2M= -github.com/hashicorp/go-hclog v0.9.2/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ= -github.com/hashicorp/go-hclog v1.5.0 h1:bI2ocEMgcVlz55Oj1xZNBsVi900c7II+fWDyV9o+13c= -github.com/hashicorp/go-hclog v1.5.0/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M= -github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= -github.com/hashicorp/go-immutable-radix v1.3.1 h1:DKHmCUm2hRBK510BaiZlwvpD40f8bJFeZnpfm2KLowc= -github.com/hashicorp/go-immutable-radix v1.3.1/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= -github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= -github.com/hashicorp/go-msgpack v0.5.5 h1:i9R9JSrqIz0QVLz3sz+i3YJdT7TTSLcfLLzJi9aZTuI= -github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= -github.com/hashicorp/go-multierror v1.1.0/go.mod h1:spPvp8C1qA32ftKqdAHm4hHTbPw+vmowP0z+KUhOZdA= -github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo= -github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= -github.com/hashicorp/go-retryablehttp v0.5.3/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs= -github.com/hashicorp/go-retryablehttp v0.7.0 h1:eu1EI/mbirUgP5C8hVsTNaGZreBDlYiwC1FZWkvQPQ4= -github.com/hashicorp/go-retryablehttp v0.7.0/go.mod h1:vAew36LZh98gCBJNLH42IQ1ER/9wtLZZ8meHqQvEYWY= -github.com/hashicorp/go-rootcerts v1.0.2 h1:jzhAVGtqPKbwpyCPELlgNWhE1znq+qwJtW5Oi2viEzc= -github.com/hashicorp/go-rootcerts v1.0.2/go.mod h1:pqUvnprVnM5bf7AOirdbb01K4ccR319Vf4pU3K5EGc8= -github.com/hashicorp/go-safetemp v1.0.0 h1:2HR189eFNrjHQyENnQMMpCiBAsRxzbTMIgBhEyExpmo= -github.com/hashicorp/go-safetemp v1.0.0/go.mod h1:oaerMy3BhqiTbVye6QuFhFtIceqFoDHxNAB65b+Rj1I= -github.com/hashicorp/go-secure-stdlib/parseutil v0.1.6 h1:om4Al8Oy7kCm/B86rLCLah4Dt5Aa0Fr5rYBG60OzwHQ= -github.com/hashicorp/go-secure-stdlib/parseutil v0.1.6/go.mod h1:QmrqtbKuxxSWTN3ETMPuB+VtEiBJ/A9XhoYGv8E1uD8= -github.com/hashicorp/go-secure-stdlib/strutil v0.1.1/go.mod h1:gKOamz3EwoIoJq7mlMIRBpVTAUn8qPCrEclOKKWhD3U= -github.com/hashicorp/go-secure-stdlib/strutil v0.1.2 h1:kes8mmyCpxJsI7FTwtzRqEy9CdjCtrXrXGuOpxEA7Ts= -github.com/hashicorp/go-secure-stdlib/strutil v0.1.2/go.mod h1:Gou2R9+il93BqX25LAKCLuM+y9U2T4hlwvT1yprcna4= -github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU= -github.com/hashicorp/go-sockaddr v1.0.2 h1:ztczhD1jLxIRjVejw8gFomI1BQZOe2WoVOu0SyteCQc= -github.com/hashicorp/go-sockaddr v1.0.2/go.mod h1:rB4wwRAUzs07qva3c5SdrY/NEtAUjGlgmH/UkBUC97A= -github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4= -github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= -github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= -github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8= -github.com/hashicorp/go-version v1.6.0 h1:feTTfFNnjP967rlCxM/I9g701jU+RN74YKx2mOkIeek= -github.com/hashicorp/go-version v1.6.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= -github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= -github.com/hashicorp/golang-lru v0.5.4 h1:YDjusn29QI/Das2iO9M0BHnIbxPeyuCHsjMW+lJfyTc= -github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= -github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= -github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= -github.com/hashicorp/hcl/v2 v2.19.1 h1://i05Jqznmb2EXqa39Nsvyan2o5XyMowW5fnCKW5RPI= -github.com/hashicorp/hcl/v2 v2.19.1/go.mod h1:ThLC89FV4p9MPW804KVbe/cEXoQ8NZEh+JtMeeGErHE= -github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= -github.com/hashicorp/mdns v1.0.4/go.mod h1:mtBihi+LeNXGtG8L9dX59gAEa12BDtBQSp4v/YAJqrc= -github.com/hashicorp/memberlist v0.5.0 h1:EtYPN8DpAURiapus508I4n9CzHs2W+8NZGbmmR/prTM= -github.com/hashicorp/memberlist v0.5.0/go.mod h1:yvyXLpo0QaGE59Y7hDTsTzDD25JYBZ4mHgHUZ8lrOI0= -github.com/hashicorp/packer-plugin-sdk v0.5.3 h1:rWQuRgUUnkf1O3UYymQZz/nJErLh4NFkuarOVEQK+Rs= -github.com/hashicorp/packer-plugin-sdk v0.5.3/go.mod h1:ntdZSJnc1LGGdMEXsYOxopZL1311QOTIbzVZH2EbN0U= -github.com/hashicorp/serf v0.10.1 h1:Z1H2J60yRKvfDYAOZLd2MU0ND4AH/WDz7xYHDWQsIPY= -github.com/hashicorp/serf v0.10.1/go.mod h1:yL2t6BqATOLGc5HF7qbFkTfXoPIY0WZdWHfEvMqbG+4= -github.com/hashicorp/vault/api v1.10.0 h1:/US7sIjWN6Imp4o/Rj1Ce2Nr5bki/AXi9vAW3p2tOJQ= -github.com/hashicorp/vault/api v1.10.0/go.mod h1:jo5Y/ET+hNyz+JnKDt8XLAdKs+AM0G5W0Vp1IrFI8N8= -github.com/hashicorp/yamux v0.1.1 h1:yrQxtgseBDrq9Y652vSRDvsKCJKOUD+GzTS4Y0Y8pvE= -github.com/hashicorp/yamux v0.1.1/go.mod h1:CtWFDAQgb7dxtzFs4tWbplKIe2jSi3+5vKbgIO0SLnQ= -github.com/jehiah/go-strftime v0.0.0-20171201141054-1d33003b3869 h1:IPJ3dvxmJ4uczJe5YQdrYB16oTJlGSC/OyZDqUk9xX4= -github.com/jehiah/go-strftime v0.0.0-20171201141054-1d33003b3869/go.mod h1:cJ6Cj7dQo+O6GJNiMx+Pa94qKj+TG8ONdKHgMNIyyag= -github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg= -github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= -github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8= -github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U= -github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= -github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= -github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= -github.com/klauspost/compress v1.11.2 h1:MiK62aErc3gIiVEtyzKfeOHgW7atJb5g/KNX5m3c2nQ= -github.com/klauspost/compress v1.11.2/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= -github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/kr/fs v0.1.0 h1:Jskdu9ieNAYnjxsi0LbQp1ulIKZV1LAFgK1tWhpZgl8= -github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= -github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= -github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pretty v0.2.0 h1:s5hAObm+yFO5uHYt5dYjxi2rXrsnmRpJx4OYvIWUaQs= -github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= -github.com/masterzen/simplexml v0.0.0-20160608183007-4572e39b1ab9/go.mod h1:kCEbxUJlNDEBNbdQMkPSp6yaKcRXVI6f4ddk8Riv4bc= -github.com/masterzen/simplexml v0.0.0-20190410153822-31eea3082786 h1:2ZKn+w/BJeL43sCxI2jhPLRv73oVVOjEKZjKkflyqxg= -github.com/masterzen/simplexml v0.0.0-20190410153822-31eea3082786/go.mod h1:kCEbxUJlNDEBNbdQMkPSp6yaKcRXVI6f4ddk8Riv4bc= -github.com/masterzen/winrm v0.0.0-20210623064412-3b76017826b0 h1:KqYuDbSr8I2X8H65InN8SafDEa0UaLRy6WEmxDqd0F0= -github.com/masterzen/winrm v0.0.0-20210623064412-3b76017826b0/go.mod h1:l31LCh9VvG43RJ83A5JLkFPjuz48cZAxBSLQLaIn1p8= -github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= -github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= -github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= -github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= -github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= -github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= -github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= -github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= -github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= -github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOAqxQCu2WE= -github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= -github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= -github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= -github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng= -github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= -github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= -github.com/miekg/dns v1.1.26/go.mod h1:bPDLeHnStXmXAq1m/Ch/hvfNHr14JKNPMBo3VZKjuso= -github.com/miekg/dns v1.1.41 h1:WMszZWJG0XmzbK9FEmzH2TVcqYzFesusSIB41b8KHxY= -github.com/miekg/dns v1.1.41/go.mod h1:p6aan82bvRIyn+zDIv9xYNUpwa73JcSh9BKwknJysuI= -github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc= -github.com/mitchellh/cli v1.1.0/go.mod h1:xcISNoH86gajksDmfB23e/pu+B+GeFRMYmoHXxx3xhI= -github.com/mitchellh/go-fs v0.0.0-20180402235330-b7b9ca407fff h1:bFJ74ac7ZK/jyislqiWdzrnENesFt43sNEBRh1xk/+g= -github.com/mitchellh/go-fs v0.0.0-20180402235330-b7b9ca407fff/go.mod h1:g7SZj7ABpStq3tM4zqHiVEG5un/DZ1+qJJKO7qx1EvU= -github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= -github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= -github.com/mitchellh/go-testing-interface v1.14.1 h1:jrgshOhYAUVNMAJiKbEu7EqAwgJJ2JqpQmpLJOu07cU= -github.com/mitchellh/go-testing-interface v1.14.1/go.mod h1:gfgS7OtZj6MA4U1UrDRp04twqAjfvlZyCfX3sDjEym8= -github.com/mitchellh/go-wordwrap v1.0.0/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= -github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQflz0v0= -github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTSsCt+hzestvNj0= -github.com/mitchellh/iochan v1.0.0 h1:C+X3KsSTLFVBr/tK1eYN/vs4rJcvsiLU338UhYPJWeY= -github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY= -github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= -github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= -github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= -github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= -github.com/mitchellh/reflectwalk v1.0.0 h1:9D+8oIskB4VJBN5SFlmc27fSlIBZaov1Wpk/IfikLNY= -github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= -github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= -github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= -github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= -github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d h1:VhgPp6v9qf9Agr/56bj7Y/xa04UccTW04VP0Qed4vnQ= -github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d/go.mod h1:YUTz3bUH2ZwIWBy3CJBeOBEugqcmXREj14T+iG/4k4U= -github.com/nywilken/go-cty v1.13.3 h1:03U99oXf3j3g9xgqAE3YGpixCjM8Mg09KZ0Ji9LzX0o= -github.com/nywilken/go-cty v1.13.3/go.mod h1:YKQzy/7pZ7iq2jNFzy5go57xdxdWoLLpaEp4u238AE0= -github.com/packer-community/winrmcp v0.0.0-20180921211025-c76d91c1e7db h1:9uViuKtx1jrlXLBW/pMnhOfzn3iSEdLase/But/IZRU= -github.com/packer-community/winrmcp v0.0.0-20180921211025-c76d91c1e7db/go.mod h1:f6Izs6JvFTdnRbziASagjZ2vmf55NSIkC/weStxCHqk= -github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= -github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0MwY= -github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= -github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= -github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/sftp v1.13.2 h1:taJnKntsWgU+qae21Rx52lIwndAdKrj0mfUNQsz1z4Q= -github.com/pkg/sftp v1.13.2/go.mod h1:LzqnAvaD5TWeNBsZpfKxSYn1MbjWwOsCIAFFJbpIsK8= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= -github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= -github.com/posener/complete v1.2.3/go.mod h1:WZIdtGGp+qx0sLrYKtIRAruyNpv6hFCicSgv7Sy7s/s= -github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= -github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= -github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU= -github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= -github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= -github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4= -github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= -github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= -github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A= -github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= -github.com/ryanuber/columnize v2.1.0+incompatible/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= -github.com/ryanuber/go-glob v1.0.0 h1:iQh3xXAumdQ+4Ufa5b25cRpC5TYKlno6hsv6Cb3pkBk= -github.com/ryanuber/go-glob v1.0.0/go.mod h1:807d1WSdnB0XRJzKNil9Om6lcp/3a0v4qIHxIXzX/Yc= -github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529 h1:nn5Wsu0esKSJiIVhscUtVbo7ada43DJhG55ua/hjS5I= -github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= -github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= -github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c= -github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= -github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= -github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= -github.com/stretchr/testify v1.8.3 h1:RP3t2pwF7cMEbC1dqtB6poj3niw/9gnV4Cjg5oW5gtY= -github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= -github.com/ugorji/go v1.2.6/go.mod h1:anCg0y61KIhDlPZmnH+so+RQbysYVyDko0IMgJv0Nn0= -github.com/ugorji/go/codec v1.2.6 h1:7kbGefxLoDBuYXOms4yD7223OpNMMPNPZxXk5TvFcyQ= -github.com/ugorji/go/codec v1.2.6/go.mod h1:V6TCNZ4PHqoHGFZuSG1W8nrCzzdgA2DozYxWFFpvxTw= -github.com/ulikunitz/xz v0.5.10 h1:t92gobL9l3HE202wg3rlk19F6X+JOxl9BBrCCMYEYd8= -github.com/ulikunitz/xz v0.5.10/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= -github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -github.com/zclconf/go-cty-debug v0.0.0-20191215020915-b22d67c1ba0b h1:FosyBZYxY34Wul7O/MSKey3txpPYyCqVO5ZyceuQJEI= -go.opencensus.io v0.23.0 h1:gqCw0LfLxScz8irSi8exQc7fyQ0fKQU/qnC/X8+V/1M= -go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= -golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/crypto v0.0.0-20190222235706-ffb98f73852f/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20190923035154-9ee001bba392/go.mod h1:/lpIB1dKB+9EgE3H3cr1v9wB50oz8l4C4h62xy7jSTY= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= -golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= -golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= -golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= -golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20230321023759-10a507213a29 h1:ooxPy7fPvB4kwsA2h+iBNHkAbp/4JxTSwCmvdjEYmug= -golang.org/x/exp v0.0.0-20230321023759-10a507213a29/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc= -golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= -golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= -golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= -golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20210410081132-afb366fc7cd1/go.mod h1:9tjilg8BloeKEkVJvy7fQ90B1CfIiPueXVOjqfkSzI8= -golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= -golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= -golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= -golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs= -golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= -golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= -golang.org/x/oauth2 v0.1.0 h1:isLCZuhj4v+tYv7eskaN4v/TM+A1begWWgyVJDdl1+Y= -golang.org/x/oauth2 v0.1.0/go.mod h1:G9FE4dLTsbXUu90h/Pf85g4w1D+SSAgR+q46nJZ8M4A= -golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.4.0 h1:zxkM55ReGkDlKSM+Fu41A+zmbZuaPVbGMzvvdUPznYQ= -golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190922100055-0a153f010e69/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190924154521-2837fb4f24fe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210303074136-134d130e1a04/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= -golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= -golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= -golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= -golang.org/x/term v0.18.0 h1:FcHjZXDMxI8mM3nwhX9HlKop4C0YQvCVCdwYl2wOtE8= -golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= -golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= -golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= -golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac h1:7zkz7BUtwNFFqcowJ+RIgu2MaV/MapERkDIy+mwPyjs= -golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= -golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20190907020128-2ca718005c18/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 h1:H2TDz8ibqkAF6YGhCdN3jS9O0/s90v0rJh3X/OLHEUk= -golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= -google.golang.org/api v0.101.0 h1:lJPPeEBIRxGpGLwnBTam1NPEM8Z2BmmXEd3z812pjwM= -google.golang.org/api v0.101.0/go.mod h1:CjxAAWWt3A3VrUE2IGDY2bgK5qhoG/OkyWVlYcP05MY= -google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= -google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c= -google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= -google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= -google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= -google.golang.org/genproto v0.0.0-20221027153422-115e99e71e1c h1:QgY/XxIAIeccR+Ca/rDdKubLIU9rcJ3xfy1DC/Wd2Oo= -google.golang.org/genproto v0.0.0-20221027153422-115e99e71e1c/go.mod h1:CGI5F/G+E5bKwmfYo09AXuVN4dD894kIKUFmVbP2/Fo= -google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= -google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= -google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= -google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= -google.golang.org/grpc v1.50.1 h1:DS/BukOZWp8s6p4Dt/tOaJaTQyPyOoCcrjroHuCeLzY= -google.golang.org/grpc v1.50.1/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= -google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= -google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= -google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= -google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= -google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= -google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= -google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= -google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= -gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= -gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU= -gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= -gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/packer_test/plugin_tester/main.go b/packer_test/plugin_tester/main.go deleted file mode 100644 index 11627307f9b..00000000000 --- a/packer_test/plugin_tester/main.go +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package main - -import ( - "fmt" - "os" - - "github.com/hashicorp/packer-plugin-sdk/plugin" - "github.com/hashicorp/packer-plugin-tester/builder/dynamic" - dynamicDS "github.com/hashicorp/packer-plugin-tester/datasource/dynamic" - "github.com/hashicorp/packer-plugin-tester/datasource/parrot" - "github.com/hashicorp/packer-plugin-tester/datasource/sleeper" - dynamicPP "github.com/hashicorp/packer-plugin-tester/post-processor/dynamic" - dynamicProv "github.com/hashicorp/packer-plugin-tester/provisioner/dynamic" - "github.com/hashicorp/packer-plugin-tester/version" -) - -func main() { - pps := plugin.NewSet() - pps.RegisterBuilder("dynamic", new(dynamic.Builder)) - pps.RegisterProvisioner("dynamic", new(dynamicProv.Provisioner)) - pps.RegisterPostProcessor("dynamic", new(dynamicPP.PostProcessor)) - pps.RegisterDatasource("dynamic", new(dynamicDS.Datasource)) - pps.RegisterDatasource("parrot", new(parrot.Datasource)) - pps.RegisterDatasource("sleeper", new(sleeper.Datasource)) - pps.SetVersion(version.PluginVersion) - err := pps.Run() - if err != nil { - fmt.Fprintln(os.Stderr, err.Error()) - os.Exit(1) - } -} diff --git a/packer_test/plugin_tester/post-processor/dynamic/post-processor.go b/packer_test/plugin_tester/post-processor/dynamic/post-processor.go deleted file mode 100644 index b62724c14a5..00000000000 --- a/packer_test/plugin_tester/post-processor/dynamic/post-processor.go +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -//go:generate packer-sdc mapstructure-to-hcl2 -type Config,NestedFirst,NestedSecond - -package dynamic - -import ( - "context" - "fmt" - - "github.com/hashicorp/hcl/v2/hcldec" - packersdk "github.com/hashicorp/packer-plugin-sdk/packer" - "github.com/hashicorp/packer-plugin-sdk/template/config" - "github.com/hashicorp/packer-plugin-sdk/template/interpolate" -) - -type NestedSecond struct { - Name string `mapstructure:"name" required:"true"` -} - -type NestedFirst struct { - Name string `mapstructure:"name" required:"true"` - Nesteds []NestedSecond `mapstructure:"extra" required:"false"` -} - -type Config struct { - Nesteds []NestedFirst `mapstructure:"extra" required:"false"` - ctx interpolate.Context -} - -type PostProcessor struct { - config Config -} - -func (p *PostProcessor) ConfigSpec() hcldec.ObjectSpec { return p.config.FlatMapstructure().HCL2Spec() } - -func (p *PostProcessor) Configure(raws ...interface{}) error { - err := config.Decode(&p.config, &config.DecodeOpts{ - PluginType: "packer.post-processor.dynamic", - Interpolate: true, - InterpolateContext: &p.config.ctx, - InterpolateFilter: &interpolate.RenderFilter{ - Exclude: []string{}, - }, - }, raws...) - if err != nil { - return err - } - return nil -} - -func (p *PostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, source packersdk.Artifact) (packersdk.Artifact, bool, bool, error) { - ui.Say(fmt.Sprintf("Called dynamic post-processor")) - for _, nst := range p.config.Nesteds { - ui.Say(fmt.Sprintf("Post-processor: nested one %s", nst.Name)) - for _, sec := range nst.Nesteds { - ui.Say(fmt.Sprintf("Post-processor: nested second %s.%s", nst.Name, sec.Name)) - } - } - return source, true, true, nil -} diff --git a/packer_test/plugin_tester/post-processor/dynamic/post-processor.hcl2spec.go b/packer_test/plugin_tester/post-processor/dynamic/post-processor.hcl2spec.go deleted file mode 100644 index b8a6c3c0dd1..00000000000 --- a/packer_test/plugin_tester/post-processor/dynamic/post-processor.hcl2spec.go +++ /dev/null @@ -1,79 +0,0 @@ -// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. - -package dynamic - -import ( - "github.com/hashicorp/hcl/v2/hcldec" - "github.com/zclconf/go-cty/cty" -) - -// FlatConfig is an auto-generated flat version of Config. -// Where the contents of a field with a `mapstructure:,squash` tag are bubbled up. -type FlatConfig struct { - Nesteds []FlatNestedFirst `mapstructure:"extra" required:"false" cty:"extra" hcl:"extra"` -} - -// FlatMapstructure returns a new FlatConfig. -// FlatConfig is an auto-generated flat version of Config. -// Where the contents a fields with a `mapstructure:,squash` tag are bubbled up. -func (*Config) FlatMapstructure() interface{ HCL2Spec() map[string]hcldec.Spec } { - return new(FlatConfig) -} - -// HCL2Spec returns the hcl spec of a Config. -// This spec is used by HCL to read the fields of Config. -// The decoded values from this spec will then be applied to a FlatConfig. -func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec { - s := map[string]hcldec.Spec{ - "extra": &hcldec.BlockListSpec{TypeName: "extra", Nested: hcldec.ObjectSpec((*FlatNestedFirst)(nil).HCL2Spec())}, - } - return s -} - -// FlatNestedFirst is an auto-generated flat version of NestedFirst. -// Where the contents of a field with a `mapstructure:,squash` tag are bubbled up. -type FlatNestedFirst struct { - Name *string `mapstructure:"name" required:"true" cty:"name" hcl:"name"` - Nesteds []FlatNestedSecond `mapstructure:"extra" required:"false" cty:"extra" hcl:"extra"` -} - -// FlatMapstructure returns a new FlatNestedFirst. -// FlatNestedFirst is an auto-generated flat version of NestedFirst. -// Where the contents a fields with a `mapstructure:,squash` tag are bubbled up. -func (*NestedFirst) FlatMapstructure() interface{ HCL2Spec() map[string]hcldec.Spec } { - return new(FlatNestedFirst) -} - -// HCL2Spec returns the hcl spec of a NestedFirst. -// This spec is used by HCL to read the fields of NestedFirst. -// The decoded values from this spec will then be applied to a FlatNestedFirst. -func (*FlatNestedFirst) HCL2Spec() map[string]hcldec.Spec { - s := map[string]hcldec.Spec{ - "name": &hcldec.AttrSpec{Name: "name", Type: cty.String, Required: false}, - "extra": &hcldec.BlockListSpec{TypeName: "extra", Nested: hcldec.ObjectSpec((*FlatNestedSecond)(nil).HCL2Spec())}, - } - return s -} - -// FlatNestedSecond is an auto-generated flat version of NestedSecond. -// Where the contents of a field with a `mapstructure:,squash` tag are bubbled up. -type FlatNestedSecond struct { - Name *string `mapstructure:"name" required:"true" cty:"name" hcl:"name"` -} - -// FlatMapstructure returns a new FlatNestedSecond. -// FlatNestedSecond is an auto-generated flat version of NestedSecond. -// Where the contents a fields with a `mapstructure:,squash` tag are bubbled up. -func (*NestedSecond) FlatMapstructure() interface{ HCL2Spec() map[string]hcldec.Spec } { - return new(FlatNestedSecond) -} - -// HCL2Spec returns the hcl spec of a NestedSecond. -// This spec is used by HCL to read the fields of NestedSecond. -// The decoded values from this spec will then be applied to a FlatNestedSecond. -func (*FlatNestedSecond) HCL2Spec() map[string]hcldec.Spec { - s := map[string]hcldec.Spec{ - "name": &hcldec.AttrSpec{Name: "name", Type: cty.String, Required: false}, - } - return s -} diff --git a/packer_test/plugin_tester/post-processor/dynamic/post-processor_acc_test.go b/packer_test/plugin_tester/post-processor/dynamic/post-processor_acc_test.go deleted file mode 100644 index 9da3b07e690..00000000000 --- a/packer_test/plugin_tester/post-processor/dynamic/post-processor_acc_test.go +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package dynamic - -import ( - _ "embed" - "fmt" - "io/ioutil" - "os" - "os/exec" - "regexp" - "testing" - - "github.com/hashicorp/packer-plugin-sdk/acctest" -) - -//go:embed test-fixtures/template.pkr.hcl -var testPostProcessorHCL2Basic string - -// Run with: PACKER_ACC=1 go test -count 1 -v ./post-processor/scaffolding/post-processor_acc_test.go -timeout=120m -func TestAccScaffoldingPostProcessor(t *testing.T) { - testCase := &acctest.PluginTestCase{ - Name: "scaffolding_post-processor_basic_test", - Setup: func() error { - return nil - }, - Teardown: func() error { - return nil - }, - Template: testPostProcessorHCL2Basic, - Type: "scaffolding-my-post-processor", - Check: func(buildCommand *exec.Cmd, logfile string) error { - if buildCommand.ProcessState != nil { - if buildCommand.ProcessState.ExitCode() != 0 { - return fmt.Errorf("Bad exit code. Logfile: %s", logfile) - } - } - - logs, err := os.Open(logfile) - if err != nil { - return fmt.Errorf("Unable find %s", logfile) - } - defer logs.Close() - - logsBytes, err := ioutil.ReadAll(logs) - if err != nil { - return fmt.Errorf("Unable to read %s", logfile) - } - logsString := string(logsBytes) - - postProcessorOutputLog := "post-processor mock: my-mock-config" - if matched, _ := regexp.MatchString(postProcessorOutputLog+".*", logsString); !matched { - t.Fatalf("logs doesn't contain expected foo value %q", logsString) - } - return nil - }, - } - acctest.TestPlugin(t, testCase) -} diff --git a/packer_test/plugin_tester/post-processor/dynamic/test-fixtures/template.pkr.hcl b/packer_test/plugin_tester/post-processor/dynamic/test-fixtures/template.pkr.hcl deleted file mode 100644 index 38c396f33e1..00000000000 --- a/packer_test/plugin_tester/post-processor/dynamic/test-fixtures/template.pkr.hcl +++ /dev/null @@ -1,16 +0,0 @@ -# Copyright (c) HashiCorp, Inc. -# SPDX-License-Identifier: MPL-2.0 - -source "null" "basic-example" { - communicator = "none" -} - -build { - sources = [ - "source.null.basic-example" - ] - - post-processor "scaffolding-my-post-processor" { - mock = "my-mock-config" - } -} diff --git a/packer_test/plugin_tester/provisioner/dynamic/provisioner.go b/packer_test/plugin_tester/provisioner/dynamic/provisioner.go deleted file mode 100644 index 6e737f6c189..00000000000 --- a/packer_test/plugin_tester/provisioner/dynamic/provisioner.go +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -//go:generate packer-sdc mapstructure-to-hcl2 -type Config,NestedFirst,NestedSecond - -package dynamic - -import ( - "context" - "fmt" - - "github.com/hashicorp/hcl/v2/hcldec" - "github.com/hashicorp/packer-plugin-sdk/packer" - "github.com/hashicorp/packer-plugin-sdk/template/config" - "github.com/hashicorp/packer-plugin-sdk/template/interpolate" -) - -type NestedSecond struct { - Name string `mapstructure:"name" required:"true"` -} - -type NestedFirst struct { - Name string `mapstructure:"name" required:"true"` - Nesteds []NestedSecond `mapstructure:"extra" required:"false"` -} - -type Config struct { - Nesteds []NestedFirst `mapstructure:"extra" required:"false"` - ctx interpolate.Context -} - -type Provisioner struct { - config Config -} - -func (p *Provisioner) ConfigSpec() hcldec.ObjectSpec { - return p.config.FlatMapstructure().HCL2Spec() -} - -func (p *Provisioner) Prepare(raws ...interface{}) error { - err := config.Decode(&p.config, &config.DecodeOpts{ - PluginType: "packer.provisioner.dynamic", - Interpolate: true, - InterpolateContext: &p.config.ctx, - InterpolateFilter: &interpolate.RenderFilter{ - Exclude: []string{}, - }, - }, raws...) - if err != nil { - return err - } - return nil -} - -func (p *Provisioner) Provision(_ context.Context, ui packer.Ui, _ packer.Communicator, generatedData map[string]interface{}) error { - ui.Say(fmt.Sprintf("Called dynamic provisioner")) - for _, nst := range p.config.Nesteds { - ui.Say(fmt.Sprintf("Provisioner: nested one %s", nst.Name)) - for _, sec := range nst.Nesteds { - ui.Say(fmt.Sprintf("Provisioner: nested second %s.%s", nst.Name, sec.Name)) - } - } - return nil -} diff --git a/packer_test/plugin_tester/provisioner/dynamic/provisioner.hcl2spec.go b/packer_test/plugin_tester/provisioner/dynamic/provisioner.hcl2spec.go deleted file mode 100644 index b8a6c3c0dd1..00000000000 --- a/packer_test/plugin_tester/provisioner/dynamic/provisioner.hcl2spec.go +++ /dev/null @@ -1,79 +0,0 @@ -// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. - -package dynamic - -import ( - "github.com/hashicorp/hcl/v2/hcldec" - "github.com/zclconf/go-cty/cty" -) - -// FlatConfig is an auto-generated flat version of Config. -// Where the contents of a field with a `mapstructure:,squash` tag are bubbled up. -type FlatConfig struct { - Nesteds []FlatNestedFirst `mapstructure:"extra" required:"false" cty:"extra" hcl:"extra"` -} - -// FlatMapstructure returns a new FlatConfig. -// FlatConfig is an auto-generated flat version of Config. -// Where the contents a fields with a `mapstructure:,squash` tag are bubbled up. -func (*Config) FlatMapstructure() interface{ HCL2Spec() map[string]hcldec.Spec } { - return new(FlatConfig) -} - -// HCL2Spec returns the hcl spec of a Config. -// This spec is used by HCL to read the fields of Config. -// The decoded values from this spec will then be applied to a FlatConfig. -func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec { - s := map[string]hcldec.Spec{ - "extra": &hcldec.BlockListSpec{TypeName: "extra", Nested: hcldec.ObjectSpec((*FlatNestedFirst)(nil).HCL2Spec())}, - } - return s -} - -// FlatNestedFirst is an auto-generated flat version of NestedFirst. -// Where the contents of a field with a `mapstructure:,squash` tag are bubbled up. -type FlatNestedFirst struct { - Name *string `mapstructure:"name" required:"true" cty:"name" hcl:"name"` - Nesteds []FlatNestedSecond `mapstructure:"extra" required:"false" cty:"extra" hcl:"extra"` -} - -// FlatMapstructure returns a new FlatNestedFirst. -// FlatNestedFirst is an auto-generated flat version of NestedFirst. -// Where the contents a fields with a `mapstructure:,squash` tag are bubbled up. -func (*NestedFirst) FlatMapstructure() interface{ HCL2Spec() map[string]hcldec.Spec } { - return new(FlatNestedFirst) -} - -// HCL2Spec returns the hcl spec of a NestedFirst. -// This spec is used by HCL to read the fields of NestedFirst. -// The decoded values from this spec will then be applied to a FlatNestedFirst. -func (*FlatNestedFirst) HCL2Spec() map[string]hcldec.Spec { - s := map[string]hcldec.Spec{ - "name": &hcldec.AttrSpec{Name: "name", Type: cty.String, Required: false}, - "extra": &hcldec.BlockListSpec{TypeName: "extra", Nested: hcldec.ObjectSpec((*FlatNestedSecond)(nil).HCL2Spec())}, - } - return s -} - -// FlatNestedSecond is an auto-generated flat version of NestedSecond. -// Where the contents of a field with a `mapstructure:,squash` tag are bubbled up. -type FlatNestedSecond struct { - Name *string `mapstructure:"name" required:"true" cty:"name" hcl:"name"` -} - -// FlatMapstructure returns a new FlatNestedSecond. -// FlatNestedSecond is an auto-generated flat version of NestedSecond. -// Where the contents a fields with a `mapstructure:,squash` tag are bubbled up. -func (*NestedSecond) FlatMapstructure() interface{ HCL2Spec() map[string]hcldec.Spec } { - return new(FlatNestedSecond) -} - -// HCL2Spec returns the hcl spec of a NestedSecond. -// This spec is used by HCL to read the fields of NestedSecond. -// The decoded values from this spec will then be applied to a FlatNestedSecond. -func (*FlatNestedSecond) HCL2Spec() map[string]hcldec.Spec { - s := map[string]hcldec.Spec{ - "name": &hcldec.AttrSpec{Name: "name", Type: cty.String, Required: false}, - } - return s -} diff --git a/packer_test/plugin_tester/provisioner/dynamic/provisioner_acc_test.go b/packer_test/plugin_tester/provisioner/dynamic/provisioner_acc_test.go deleted file mode 100644 index aae675a2c31..00000000000 --- a/packer_test/plugin_tester/provisioner/dynamic/provisioner_acc_test.go +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package dynamic - -import ( - _ "embed" - "fmt" - "io/ioutil" - "os" - "os/exec" - "regexp" - "testing" - - "github.com/hashicorp/packer-plugin-sdk/acctest" -) - -//go:embed test-fixtures/template.pkr.hcl -var testProvisionerHCL2Basic string - -// Run with: PACKER_ACC=1 go test -count 1 -v ./provisioner/scaffolding/provisioner_acc_test.go -timeout=120m -func TestAccScaffoldingProvisioner(t *testing.T) { - testCase := &acctest.PluginTestCase{ - Name: "scaffolding_provisioner_basic_test", - Setup: func() error { - return nil - }, - Teardown: func() error { - return nil - }, - Template: testProvisionerHCL2Basic, - Type: "scaffolding-my-provisioner", - Check: func(buildCommand *exec.Cmd, logfile string) error { - if buildCommand.ProcessState != nil { - if buildCommand.ProcessState.ExitCode() != 0 { - return fmt.Errorf("Bad exit code. Logfile: %s", logfile) - } - } - - logs, err := os.Open(logfile) - if err != nil { - return fmt.Errorf("Unable find %s", logfile) - } - defer logs.Close() - - logsBytes, err := ioutil.ReadAll(logs) - if err != nil { - return fmt.Errorf("Unable to read %s", logfile) - } - logsString := string(logsBytes) - - provisionerOutputLog := "null.basic-example: provisioner mock: my-mock-config" - if matched, _ := regexp.MatchString(provisionerOutputLog+".*", logsString); !matched { - t.Fatalf("logs doesn't contain expected foo value %q", logsString) - } - return nil - }, - } - acctest.TestPlugin(t, testCase) -} diff --git a/packer_test/plugin_tester/provisioner/dynamic/test-fixtures/template.pkr.hcl b/packer_test/plugin_tester/provisioner/dynamic/test-fixtures/template.pkr.hcl deleted file mode 100644 index ba856bbb9d8..00000000000 --- a/packer_test/plugin_tester/provisioner/dynamic/test-fixtures/template.pkr.hcl +++ /dev/null @@ -1,16 +0,0 @@ -# Copyright (c) HashiCorp, Inc. -# SPDX-License-Identifier: MPL-2.0 - -source "null" "basic-example" { - communicator = "none" -} - -build { - sources = [ - "source.null.basic-example" - ] - - provisioner "scaffolding-my-provisioner" { - mock = "my-mock-config" - } -} diff --git a/packer_test/plugin_tester/version/version.go b/packer_test/plugin_tester/version/version.go deleted file mode 100644 index f36f3228cd2..00000000000 --- a/packer_test/plugin_tester/version/version.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -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.0.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 = "" - - // VersionMetadata is anything related to the build that has some - // informational value. This won't impact version ordering. - VersionMetadata = "" - - // PluginVersion is used by the plugin set to allow Packer to recognize - // what version this plugin is. - PluginVersion = version.NewPluginVersion(Version, VersionPrerelease, VersionMetadata) -) diff --git a/packer_test/plugins_remove_test.go b/packer_test/plugins_remove_test.go deleted file mode 100644 index cc10b611376..00000000000 --- a/packer_test/plugins_remove_test.go +++ /dev/null @@ -1,180 +0,0 @@ -package packer_test - -import ( - "path/filepath" - "strings" -) - -func (ts *PackerTestSuite) TestPluginsRemoveWithSourceAddress() { - pluginPath, cleanup := ts.MakePluginDir("1.0.9", "1.0.10", "2.0.0") - defer cleanup() - - // Get installed plugins - if n := InstalledPlugins(ts, pluginPath); len(n) != 3 { - ts.T().Fatalf("Expected there to be 3 installed plugins but we got %v", n) - } - - ts.Run("plugins remove with source address removes all installed plugin versions", func() { - ts.PackerCommand().UsePluginDir(pluginPath). - SetArgs("plugins", "remove", "github.com/hashicorp/tester"). - Assert(MustSucceed(), - Grep("packer-plugin-tester_v1.0.9", grepStdout), - Grep("packer-plugin-tester_v1.0.10", grepStdout), - Grep("packer-plugin-tester_v2.0.0", grepStdout), - ) - }) - - // Get installed plugins after removal - if n := InstalledPlugins(ts, pluginPath); len(n) != 0 { - ts.T().Fatalf("Expected there to be 0 installed plugins but we got %v", n) - } - - ts.Run("plugins remove with incorrect source address exits non found error", func() { - ts.PackerCommand().UsePluginDir(pluginPath). - SetArgs("plugins", "remove", "github.com/hashicorp/testerONE"). - Assert( - MustFail(), - Grep("No installed plugin found matching the plugin constraints github.com/hashicorp/testerONE"), - ) - }) - - ts.Run("plugins remove with invalid source address exits with non-zero code", func() { - ts.PackerCommand().UsePluginDir(pluginPath). - SetArgs("plugins", "remove", "github.com/hashicorp/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/tester"). - Assert( - MustFail(), - Grep("The source URL must have at most 16 components"), - ) - }) -} - -func (ts *PackerTestSuite) TestPluginsRemoveWithSourceAddressAndVersion() { - pluginPath, cleanup := ts.MakePluginDir("1.0.9", "1.0.10", "2.0.0") - defer cleanup() - - // Get installed plugins - if n := InstalledPlugins(ts, pluginPath); len(n) != 3 { - ts.T().Fatalf("Expected there to be 3 installed plugins but we got %v", n) - } - - ts.Run("plugins remove with source address and version removes only the versioned plugin", func() { - ts.PackerCommand().UsePluginDir(pluginPath). - SetArgs("plugins", "remove", "github.com/hashicorp/tester", ">= 2.0.0"). - Assert(MustSucceed(), Grep("packer-plugin-tester_v2.0.0", grepStdout)) - }) - - ts.Run("plugins installed after single plugins remove outputs remaining installed plugins", func() { - ts.PackerCommand().UsePluginDir(pluginPath). - SetArgs("plugins", "installed"). - Assert( - MustSucceed(), - Grep("packer-plugin-tester_v1.0.9", grepStdout), - Grep("packer-plugin-tester_v1.0.10", grepStdout), - Grep("packer-plugin-tester_v2.0.0", grepInvert, grepStdout), - ) - }) - - // Get installed plugins after removal - if n := InstalledPlugins(ts, pluginPath); len(n) != 2 { - ts.T().Fatalf("Expected there to be 2 installed plugins but we got %v", n) - } -} - -func (ts *PackerTestSuite) TestPluginsRemoveWithLocalPath() { - pluginPath, cleanup := ts.MakePluginDir("1.0.9", "1.0.10") - defer cleanup() - - // Get installed plugins - plugins := InstalledPlugins(ts, pluginPath) - if len(plugins) != 2 { - ts.T().Fatalf("Expected there to be 2 installed plugins but we got %v", len(plugins)) - } - - ts.Run("plugins remove with a local path removes only the specified plugin", func() { - ts.PackerCommand().UsePluginDir(pluginPath). - SetArgs("plugins", "remove", plugins[0]). - Assert( - MustSucceed(), - Grep("packer-plugin-tester_v1.0.9", grepStdout), - Grep("packer-plugin-tester_v1.0.10", grepInvert, grepStdout), - ) - }) - ts.Run("plugins installed after calling plugins remove outputs remaining installed plugins", func() { - ts.PackerCommand().UsePluginDir(pluginPath). - SetArgs("plugins", "installed"). - Assert( - MustSucceed(), - Grep("packer-plugin-tester_v1.0.10", grepStdout), - Grep("packer-plugin-tester_v1.0.9", grepInvert, grepStdout), - ) - }) - - // Get installed plugins after removal - if n := InstalledPlugins(ts, pluginPath); len(n) != 1 { - ts.T().Fatalf("Expected there to be 1 installed plugins but we got %v", n) - } - - ts.Run("plugins remove with incomplete local path exits with a non-zero code", func() { - ts.PackerCommand().UsePluginDir(pluginPath). - SetArgs("plugins", "remove", filepath.Base(plugins[0])). - Assert( - MustFail(), - Grep("A source URL must at least contain a host and a path with 2 components", grepStdout), - ) - }) - - ts.Run("plugins remove with fake local path exits with a non-zero code", func() { - ts.PackerCommand().UsePluginDir(pluginPath). - SetArgs("plugins", "remove", ts.T().TempDir()). - Assert( - MustFail(), - Grep("is not under the plugin directory inferred by Packer", grepStdout), - ) - }) -} - -func (ts *PackerTestSuite) TestPluginsRemoveWithNoArguments() { - pluginPath, cleanup := ts.MakePluginDir("1.0.9") - defer cleanup() - - // Get installed plugins - if n := InstalledPlugins(ts, pluginPath); len(n) != 1 { - ts.T().Fatalf("Expected there to be 1 installed plugins but we got %v", n) - } - - ts.Run("plugins remove with no options returns non-zero with help text", func() { - ts.PackerCommand().UsePluginDir(pluginPath). - SetArgs("plugins", "remove"). - Assert( - MustFail(), - Grep("Usage: packer plugins remove ", grepStdout), - ) - }) - - // Get installed should remain the same - if n := InstalledPlugins(ts, pluginPath); len(n) != 1 { - ts.T().Fatalf("Expected there to be 1 installed plugins but we got %v", n) - } - -} - -func InstalledPlugins(ts *PackerTestSuite, dir string) []string { - ts.T().Helper() - - cmd := ts.PackerCommand().UsePluginDir(dir). - SetArgs("plugins", "installed") - cmd.Assert(MustSucceed()) - if ts.T().Failed() { - ts.T().Fatalf("Failed to execute plugin installed for %q", dir) - } - - out, _, _ := cmd.Run() - // Output will be split on '\n' after trimming all other white space - out = strings.TrimSpace(out) - plugins := strings.Fields(out) - n := len(plugins) - if n == 0 { - return nil - } - return plugins -} diff --git a/packer_test/sample_config.json b/packer_test/sample_config.json deleted file mode 100644 index 80f75581350..00000000000 --- a/packer_test/sample_config.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "disable_checkpoint": true, - "disable_checkpoint_signature": true, - "provisioners": { - "super-shell": "packer-provisioner-super-shell" - } -} diff --git a/packer_test/suite_test.go b/packer_test/suite_test.go deleted file mode 100644 index 0b6b98241cc..00000000000 --- a/packer_test/suite_test.go +++ /dev/null @@ -1,83 +0,0 @@ -package packer_test - -import ( - "os" - "sync" - "testing" - - "github.com/stretchr/testify/suite" -) - -type PackerTestSuite struct { - suite.Suite - // pluginsDirectory is the directory in which plugins are compiled. - // - // Those binaries are not necessarily meant to be used as-is, but - // instead should be used for composing plugin installation directories. - pluginsDirectory string - // packerPath is the location in which the Packer executable is compiled - // - // Since we don't necessarily want to manually compile Packer beforehand, - // we compile it on demand, and use this executable for the tests. - packerPath string -} - -func buildPluginVersion(waitgroup *sync.WaitGroup, versionString string, t *testing.T) { - waitgroup.Add(1) - go func() { - defer waitgroup.Done() - BuildSimplePlugin(versionString, t) - }() -} - -func (ts *PackerTestSuite) buildPluginBinaries(t *testing.T) { - wg := &sync.WaitGroup{} - - buildPluginVersion(wg, "1.0.0", t) - buildPluginVersion(wg, "1.0.0+metadata", t) - buildPluginVersion(wg, "1.0.1-alpha1", t) - buildPluginVersion(wg, "1.0.9", t) - buildPluginVersion(wg, "1.0.10", t) - - wg.Wait() -} - -func Test_PackerCoreSuite(t *testing.T) { - ts := &PackerTestSuite{} - - pluginsDirectory := PluginBinaryDir() - defer func() { - err := os.RemoveAll(pluginsDirectory) - if err != nil { - t.Logf("failed to cleanup directory %q: %s. This will need manual action", pluginsDirectory, err) - } - }() - - ts.pluginsDirectory = pluginsDirectory - ts.buildPluginBinaries(t) - - packerPath := os.Getenv("PACKER_CUSTOM_PATH") - if packerPath == "" { - var err error - t.Logf("Building test packer binary...") - packerPath, err = BuildTestPacker(t) - if err != nil { - t.Fatalf("failed to build Packer binary: %s", err) - } - } - ts.packerPath = packerPath - t.Logf("Done") - - defer func() { - if os.Getenv("PACKER_CUSTOM_PATH") != "" { - return - } - - err := os.Remove(ts.packerPath) - if err != nil { - t.Logf("failed to cleanup compiled packer binary %q: %s. This will need manual action", packerPath, err) - } - }() - - suite.Run(t, ts) -} diff --git a/packer_test/templates/init/hashicups.pkr.hcl b/packer_test/templates/init/hashicups.pkr.hcl deleted file mode 100644 index d6d735bf9fb..00000000000 --- a/packer_test/templates/init/hashicups.pkr.hcl +++ /dev/null @@ -1,9 +0,0 @@ -packer { - required_plugins { - tester = { - source = "github.com/hashicorp/hashicups" - version = ">= 1.0.2" - } - } -} - diff --git a/packer_test/templates/init/mixed_versions.pkr.hcl b/packer_test/templates/init/mixed_versions.pkr.hcl deleted file mode 100644 index d228643ee55..00000000000 --- a/packer_test/templates/init/mixed_versions.pkr.hcl +++ /dev/null @@ -1,9 +0,0 @@ -packer { - required_plugins { - tester = { - source = "github.com/mondoohq/cnspec" - version = "= 10.7.3" # plugin describe reports 10.7.x-dev so init must fail - } - } -} - diff --git a/packer_test/templates/init/non_gh.pkr.hcl b/packer_test/templates/init/non_gh.pkr.hcl deleted file mode 100644 index 5b23470dd36..00000000000 --- a/packer_test/templates/init/non_gh.pkr.hcl +++ /dev/null @@ -1,14 +0,0 @@ -packer { - required_plugins { - tester = { - source = "hubgit.com/hashicorp/tester" - version = ">= 1.0.9" - } - } -} - -source "tester-dynamic" "test" {} - -build { - sources = ["tester-dynamic.test"] -} diff --git a/packer_test/templates/pin_1.0.9.pkr.hcl b/packer_test/templates/pin_1.0.9.pkr.hcl deleted file mode 100644 index 5a13652770f..00000000000 --- a/packer_test/templates/pin_1.0.9.pkr.hcl +++ /dev/null @@ -1,14 +0,0 @@ -packer { - required_plugins { - tester = { - source = "github.com/hashicorp/tester" - version = "= 1.0.9" - } - } -} - -source "tester-dynamic" "test" {} - -build { - sources = ["tester-dynamic.test"] -} diff --git a/packer_test/templates/pre-release_constraint.pkr.hcl b/packer_test/templates/pre-release_constraint.pkr.hcl deleted file mode 100644 index c1e56b58333..00000000000 --- a/packer_test/templates/pre-release_constraint.pkr.hcl +++ /dev/null @@ -1,14 +0,0 @@ -packer { - required_plugins { - tester = { - source = "github.com/hashicorp/hashicups" - version = "= 1.0.2-dev" - } - } -} - -source "tester-dynamic" "test" {} - -build { - sources = ["tester-dynamic.test"] -} diff --git a/packer_test/templates/simple.json b/packer_test/templates/simple.json deleted file mode 100644 index f1239e9b321..00000000000 --- a/packer_test/templates/simple.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "builders": [{ - "type": "tester-dynamic", - "name": "test" - }] -} diff --git a/packer_test/templates/simple.pkr.hcl b/packer_test/templates/simple.pkr.hcl deleted file mode 100644 index 3db22017728..00000000000 --- a/packer_test/templates/simple.pkr.hcl +++ /dev/null @@ -1,14 +0,0 @@ -packer { - required_plugins { - tester = { - source = "github.com/hashicorp/tester" - version = ">= 1.0.0" - } - } -} - -source "tester-dynamic" "test" {} - -build { - sources = ["tester-dynamic.test"] -} diff --git a/post-processor/artifice/version/version.go b/post-processor/artifice/version/version.go index 4ec01444d5d..b329b365688 100644 --- a/post-processor/artifice/version/version.go +++ b/post-processor/artifice/version/version.go @@ -11,6 +11,6 @@ import ( var ArtificePluginVersion *version.PluginVersion func init() { - ArtificePluginVersion = version.NewPluginVersion( - packerVersion.Version, packerVersion.VersionPrerelease, packerVersion.VersionMetadata) + ArtificePluginVersion = version.InitializePluginVersion( + packerVersion.Version, packerVersion.VersionPrerelease) } diff --git a/post-processor/checksum/version/version.go b/post-processor/checksum/version/version.go index e1fc5cb9768..9e1eeb239d9 100644 --- a/post-processor/checksum/version/version.go +++ b/post-processor/checksum/version/version.go @@ -11,6 +11,6 @@ import ( var ChecksumPluginVersion *version.PluginVersion func init() { - ChecksumPluginVersion = version.NewPluginVersion( - packerVersion.Version, packerVersion.VersionPrerelease, packerVersion.VersionMetadata) + ChecksumPluginVersion = version.InitializePluginVersion( + packerVersion.Version, packerVersion.VersionPrerelease) } diff --git a/post-processor/compress/benchmark.go b/post-processor/compress/benchmark.go index 89f12d9dbd8..6f38ddc5a78 100644 --- a/post-processor/compress/benchmark.go +++ b/post-processor/compress/benchmark.go @@ -211,7 +211,7 @@ func (c *Compressor) BenchmarkLZ4Reader(b *testing.B) { } func (c *Compressor) BenchmarkXZWriter(b *testing.B) { - cw, _ := xz.NewWriter(c.w) + cw := xz.NewWriter(c.w) b.ResetTimer() _, err := io.Copy(cw, c.r) @@ -223,7 +223,7 @@ func (c *Compressor) BenchmarkXZWriter(b *testing.B) { } func (c *Compressor) BenchmarkXZReader(b *testing.B) { - cr, _ := xz.NewReader(c.w) + cr := xz.NewReader(c.w) b.ResetTimer() _, err := io.Copy(io.Discard, cr) diff --git a/post-processor/compress/version/version.go b/post-processor/compress/version/version.go index 005584e824b..75bfb46f656 100644 --- a/post-processor/compress/version/version.go +++ b/post-processor/compress/version/version.go @@ -11,6 +11,6 @@ import ( var CompressPluginVersion *version.PluginVersion func init() { - CompressPluginVersion = version.NewPluginVersion( - packerVersion.Version, packerVersion.VersionPrerelease, packerVersion.VersionMetadata) + CompressPluginVersion = version.InitializePluginVersion( + packerVersion.Version, packerVersion.VersionPrerelease) } diff --git a/post-processor/manifest/version/version.go b/post-processor/manifest/version/version.go index 5c786728c05..86f862f89fd 100644 --- a/post-processor/manifest/version/version.go +++ b/post-processor/manifest/version/version.go @@ -11,6 +11,6 @@ import ( var ManifestPluginVersion *version.PluginVersion func init() { - ManifestPluginVersion = version.NewPluginVersion( - packerVersion.Version, packerVersion.VersionPrerelease, packerVersion.VersionMetadata) + ManifestPluginVersion = version.InitializePluginVersion( + packerVersion.Version, packerVersion.VersionPrerelease) } diff --git a/post-processor/shell-local/version/version.go b/post-processor/shell-local/version/version.go index 938edae592b..1f602bc5f46 100644 --- a/post-processor/shell-local/version/version.go +++ b/post-processor/shell-local/version/version.go @@ -11,6 +11,6 @@ import ( var ShellLocalPluginVersion *version.PluginVersion func init() { - ShellLocalPluginVersion = version.NewPluginVersion( - packerVersion.Version, packerVersion.VersionPrerelease, packerVersion.VersionMetadata) + ShellLocalPluginVersion = version.InitializePluginVersion( + packerVersion.Version, packerVersion.VersionPrerelease) } diff --git a/provisioner/breakpoint/version/version.go b/provisioner/breakpoint/version/version.go index baca4c2a42e..2024c7e5a74 100644 --- a/provisioner/breakpoint/version/version.go +++ b/provisioner/breakpoint/version/version.go @@ -11,6 +11,6 @@ import ( var BreakpointPluginVersion *version.PluginVersion func init() { - BreakpointPluginVersion = version.NewPluginVersion( - packerVersion.Version, packerVersion.VersionPrerelease, packerVersion.VersionMetadata) + BreakpointPluginVersion = version.InitializePluginVersion( + packerVersion.Version, packerVersion.VersionPrerelease) } diff --git a/provisioner/file/version/version.go b/provisioner/file/version/version.go index 394590a7930..8451cf03227 100644 --- a/provisioner/file/version/version.go +++ b/provisioner/file/version/version.go @@ -11,6 +11,6 @@ import ( var FileProvisionerVersion *version.PluginVersion func init() { - FileProvisionerVersion = version.NewPluginVersion( - packerVersion.Version, packerVersion.VersionPrerelease, packerVersion.VersionMetadata) + FileProvisionerVersion = version.InitializePluginVersion( + packerVersion.Version, packerVersion.VersionPrerelease) } diff --git a/provisioner/powershell/version/version.go b/provisioner/powershell/version/version.go index a56593cfcf8..b0350e51cbd 100644 --- a/provisioner/powershell/version/version.go +++ b/provisioner/powershell/version/version.go @@ -11,6 +11,6 @@ import ( var PowershellPluginVersion *version.PluginVersion func init() { - PowershellPluginVersion = version.NewPluginVersion( - packerVersion.Version, packerVersion.VersionPrerelease, packerVersion.VersionMetadata) + PowershellPluginVersion = version.InitializePluginVersion( + packerVersion.Version, packerVersion.VersionPrerelease) } diff --git a/provisioner/shell-local/version/version.go b/provisioner/shell-local/version/version.go index 32e12df1a26..27e57fb5c0a 100644 --- a/provisioner/shell-local/version/version.go +++ b/provisioner/shell-local/version/version.go @@ -11,6 +11,6 @@ import ( var ShellLocalProvisionerVersion *version.PluginVersion func init() { - ShellLocalProvisionerVersion = version.NewPluginVersion( - packerVersion.Version, packerVersion.VersionPrerelease, packerVersion.VersionMetadata) + ShellLocalProvisionerVersion = version.InitializePluginVersion( + packerVersion.Version, packerVersion.VersionPrerelease) } diff --git a/provisioner/shell/version/version.go b/provisioner/shell/version/version.go index f73583ffeec..bb0b798efe2 100644 --- a/provisioner/shell/version/version.go +++ b/provisioner/shell/version/version.go @@ -11,6 +11,6 @@ import ( var ShellPluginVersion *version.PluginVersion func init() { - ShellPluginVersion = version.NewPluginVersion( - packerVersion.Version, packerVersion.VersionPrerelease, packerVersion.VersionMetadata) + ShellPluginVersion = version.InitializePluginVersion( + packerVersion.Version, packerVersion.VersionPrerelease) } diff --git a/provisioner/sleep/version/version.go b/provisioner/sleep/version/version.go index b66c3c7e880..3b0c4c2bf25 100644 --- a/provisioner/sleep/version/version.go +++ b/provisioner/sleep/version/version.go @@ -11,6 +11,6 @@ import ( var SleepProvisionerVersion *version.PluginVersion func init() { - SleepProvisionerVersion = version.NewPluginVersion( - packerVersion.Version, packerVersion.VersionPrerelease, packerVersion.VersionMetadata) + SleepProvisionerVersion = version.InitializePluginVersion( + packerVersion.Version, packerVersion.VersionPrerelease) } diff --git a/provisioner/windows-restart/version/version.go b/provisioner/windows-restart/version/version.go index 118766a8735..d178be5e559 100644 --- a/provisioner/windows-restart/version/version.go +++ b/provisioner/windows-restart/version/version.go @@ -11,6 +11,6 @@ import ( var WindowsRestartPluginVersion *version.PluginVersion func init() { - WindowsRestartPluginVersion = version.NewPluginVersion( - packerVersion.Version, packerVersion.VersionPrerelease, packerVersion.VersionMetadata) + WindowsRestartPluginVersion = version.InitializePluginVersion( + packerVersion.Version, packerVersion.VersionPrerelease) } diff --git a/provisioner/windows-shell/version/version.go b/provisioner/windows-shell/version/version.go index f0c47d30582..71885679439 100644 --- a/provisioner/windows-shell/version/version.go +++ b/provisioner/windows-shell/version/version.go @@ -11,6 +11,6 @@ import ( var WindowsShellPluginVersion *version.PluginVersion func init() { - WindowsShellPluginVersion = version.NewPluginVersion( - packerVersion.Version, packerVersion.VersionPrerelease, packerVersion.VersionMetadata) + WindowsShellPluginVersion = version.InitializePluginVersion( + packerVersion.Version, packerVersion.VersionPrerelease) } diff --git a/version/VERSION b/version/VERSION index 381cf02417c..095b6672767 100644 --- a/version/VERSION +++ b/version/VERSION @@ -1 +1 @@ -1.12.0-dev +1.11.1-dev diff --git a/website/content/docs/commands/init.mdx b/website/content/docs/commands/init.mdx index 99b734ca991..778c0760090 100644 --- a/website/content/docs/commands/init.mdx +++ b/website/content/docs/commands/init.mdx @@ -25,29 +25,49 @@ We recommend that you vet and verify any third-party plugins you want to install By default, Packer installs plugins into the plugins directory at `$HOME/.config/packer/plugins` on Unix and `%APPDATA%\packer.d\plugins` on Windows, but you can specify a different directory using the `PACKER_PLUGIN_PATH` environment variable. Refer to the [Packer configuration reference](/packer/docs/configure) for additional information. ## Usage + Use the following syntax to run the `packer init` command: ```shell-session -$ packer init +$ packer init ``` +The command will process any template file that ends with `pkr.hcl`. The template must contain all dependencies when running the command on a single template file. The command fails if the template is intended to be built as a bundle of partials. +For variable definitions, it is recommended to use the extensions `.pkrvars.hcl` or `.auto.pkrvars.hcl`. When you run `packer init` in the directory, these variable definition files will be automatically excluded from processing. + ## Examples -The following example installs the plugins specified in a template named `template.pkr.hcl`: +The following example installs the plugins specified in a template from the current directory: +```shell-session +$ packer init . +``` + +The following example installs the plugins specified in a template named `template.pkr.hcl` from the current directory: ```shell-session $ packer init template.pkr.hcl ``` +The following example installs the plugins specified in the `builds/foo/` directory: + +```shell-session +$ packer init builds/foo/. +``` + +The following example installs the plugins specified in a template from the `builds/foo/template.pkr.hcl` path: + +```shell-session +$ packer init builds/foo/template.pkr.hcl +``` + ## Arguments You can pass the following arguments: - Packer template: Specify the path to either an HCL2 template or a directory containing at least one valid HCL2 template and related dependencies. - ## Options - `-upgrade`: Use this option to upgrade plugins that are already installed to the latest available version. Packer upgrades to the latest version in accordance with the version constraints specified in the template. diff --git a/website/content/partials/packer-plugin-sdk/communicator/SSH-not-required.mdx b/website/content/partials/packer-plugin-sdk/communicator/SSH-not-required.mdx index e119862b90b..7655eaa19b5 100644 --- a/website/content/partials/packer-plugin-sdk/communicator/SSH-not-required.mdx +++ b/website/content/partials/packer-plugin-sdk/communicator/SSH-not-required.mdx @@ -78,7 +78,7 @@ **NOTE**: Guests using Windows with Win32-OpenSSH v9.1.0.0p1-Beta, scp (the default protocol for copying data) returns a non-zero error code since the MOTW cannot be set, which cause any file transfer to fail. As a workaround you can override the transfer protocol - with SFTP instead `ssh_file_transfer_method = "sftp"`. + with SFTP instead `ssh_file_transfer_protocol = "sftp"`. - `ssh_proxy_host` (string) - A SOCKS proxy host to use for SSH connection