Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: hashicorp/packer
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.10.2
Choose a base ref
...
head repository: hashicorp/packer
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v1.10.3
Choose a head ref

Commits on Mar 6, 2024

  1. Bumped product version to 1.10.3.

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    843d9af View commit details

Commits on Mar 7, 2024

  1. backport of commit b366ff2

    lbajolet-hashicorp committed Mar 7, 2024
    Copy the full SHA
    4c5a7cc View commit details
  2. Merge pull request #12872 from hashicorp/backport/fmt_fwd_parse_error…

    …s/strongly-crisp-donkey
    
    This pull request was automerged via backport-assistant
    hc-github-team-packer authored Mar 7, 2024
    Copy the full SHA
    ca098bc View commit details

Commits on Mar 11, 2024

  1. backport of commit 0e18da0

    nywilken committed Mar 11, 2024
    Copy the full SHA
    879f41d View commit details
  2. Merge pull request #12876 from hashicorp/backport/update/integration-…

    …script-commands/apparently-strong-pug
    
    This pull request was automerged via backport-assistant
    hc-github-team-packer authored Mar 11, 2024
    Copy the full SHA
    cafd0a2 View commit details

Commits on Mar 12, 2024

  1. backport of commit 41b2215

    pavedroad committed Mar 12, 2024
    Copy the full SHA
    5b51a8b View commit details
  2. Merge pull request #12881 from hashicorp/backport/main/reliably-polit…

    …e-rhino
    
    This pull request was automerged via backport-assistant
    hc-github-team-packer authored Mar 12, 2024
    Copy the full SHA
    134ea09 View commit details

Commits on Apr 11, 2024

  1. Backport Build Metadata Phase 1 Release (#12910)

    * Packer tracks Version and Plugins Metadata (#12860)
    
    * HPR-1537: Packer Core sends metadata to HCP Packer in UpdateBuild API (#12891)
    
    * Use latest version of hcp-sdk-go
    
    Remove loggers and move AddMetadataToBuild method to Version
    
    * Update hcp-sdk-go
    devashish-patel authored Apr 11, 2024
    Copy the full SHA
    4560d79 View commit details
  2. backport of commit 95a164c

    nywilken committed Apr 11, 2024
    Copy the full SHA
    1a5e48f View commit details
  3. backport of commit 51b8a1f

    nywilken committed Apr 11, 2024
    Copy the full SHA
    28a30c6 View commit details
  4. backport of commit e2c54a3

    nywilken committed Apr 11, 2024
    Copy the full SHA
    f7f599c View commit details
  5. backport of commit 623ba9e

    Wilken Rivera authored Apr 11, 2024
    Copy the full SHA
    da2da3c View commit details

Commits on Apr 15, 2024

  1. Report metadata only when the build completes (#12922)

    * Report metadata only when the build completes
    
    * Lint lord
    devashish-patel authored Apr 15, 2024
    Copy the full SHA
    ee0eb39 View commit details
  2. Bump github.com/go-jose/go-jose/v3 to address GHSA-c5q2-7r4c-mv6g

    nywilken committed Apr 15, 2024
    Copy the full SHA
    48ebd30 View commit details

Commits on Apr 16, 2024

  1. backport of commit de25c29

    lbajolet-hashicorp committed Apr 16, 2024
    Copy the full SHA
    d5a7e73 View commit details
  2. backport of commit b6748cd

    lbajolet-hashicorp committed Apr 16, 2024
    Copy the full SHA
    35d8bfc View commit details
  3. backport of commit 317858e

    lbajolet-hashicorp committed Apr 16, 2024
    Copy the full SHA
    575299e View commit details
  4. Merge pull request #12929 from hashicorp/backport/workflow_build_only…

    …_push_release_images/forcibly-willing-chow
    
    This pull request was automerged via backport-assistant
    hc-github-team-packer authored Apr 16, 2024
    Copy the full SHA
    b4d5787 View commit details
  5. version: embed version/VERSION as version string

    Since we have both version/version.go and version/VERSION to specify
    version strings, both are a bit redundant.
    
    As version/VERSION is supposed to be the source of truth now, we are
    using it to derive the version information we used to rely on in Packer
    and its subcommands.
    
    Note: doing this prevents us from changing the version/prerelease
    through ldflags though as we derive Version/VersionPrerelease from the
    rawVersion variable.
    lbajolet-hashicorp authored and nywilken committed Apr 16, 2024
    Copy the full SHA
    1d6a2e7 View commit details
  6. Merge pull request #12931 from hashicorp/backport/sec/add-LICENSE-to-…

    …release-binaries/initially-able-ghost
    
    This pull request was automerged via backport-assistant
    hc-github-team-packer authored Apr 16, 2024
    Copy the full SHA
    dc2c663 View commit details

Commits on Apr 22, 2024

  1. Updated CHANGELOG 1.10.3

    nywilken committed Apr 22, 2024
    Copy the full SHA
    d8fbaef View commit details
20 changes: 15 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -40,7 +40,7 @@ jobs:
outputs:
product-version: ${{ steps.set-product-version.outputs.product-version }}
base-product-version: ${{ steps.set-product-version.outputs.base-product-version }}
product-date: ${{ steps.get-product-version.outputs.product-date }}
product-date: ${{ steps.set-product-version.outputs.product-date }}
product-prerelease-version: ${{ steps.set-product-version.outputs.prerelease-product-version }}
set-ld-flags: ${{ steps.set-ld-flags.outputs.set-ld-flags }}
steps:
@@ -121,6 +121,7 @@ jobs:
arch: ${{ matrix.goarch }}
reproducible: report
instructions: |-
cp LICENSE "$TARGET_DIR/LICENSE.txt"
go build -o "$BIN_PATH" -ldflags="$LD_FLAGS" -trimpath -buildvcs=false
build-linux:
@@ -158,8 +159,15 @@ jobs:
arch: ${{ matrix.goarch }}
reproducible: report
instructions: |-
cp LICENSE "$TARGET_DIR/LICENSE.txt"
go build -o "$BIN_PATH" -ldflags="$LD_FLAGS" -trimpath -buildvcs=false
- name: Copy license file to config_dir
if: ${{ matrix.goos == 'linux' }}
env:
LICENSE_DIR: ".release/linux/package/usr/share/doc/${{ env.REPO_NAME }}"
run: |
mkdir -p "$LICENSE_DIR" && cp LICENSE "$LICENSE_DIR/LICENSE.txt"
- name: Linux Packaging
uses: hashicorp/actions-packaging-linux@v1
with:
@@ -173,6 +181,7 @@ jobs:
binary: "dist/${{ env.REPO_NAME }}"
deb_depends: "openssl"
rpm_depends: "openssl"
config_dir: ".release/linux/package/"
- name: Add Linux Package names to env
run: |
echo "RPM_PACKAGE=$(basename out/*.rpm)" >> $GITHUB_ENV
@@ -220,6 +229,7 @@ jobs:
arch: ${{ matrix.goarch }}
reproducible: report
instructions: |-
cp LICENSE "$TARGET_DIR/LICENSE.txt"
go build -o "$BIN_PATH" -ldflags="$LD_FLAGS" -tags netcgo -trimpath -buildvcs=false
build-docker-light:
@@ -242,10 +252,10 @@ jobs:
target: release-light
arch: ${{ matrix.arch }}
tags: |
docker.io/hashicorp/${{ env.REPO_NAME }}:light
${{ steps.set-product-version.output.prerelease-product-version == '' && format('docker.io/hashicorp/{0}:light', env.REPO_NAME) }}
docker.io/hashicorp/${{ env.REPO_NAME }}:light-${{ env.version }}
docker.io/hashicorp/${{ env.REPO_NAME }}:${{ env.version }}
public.ecr.aws/hashicorp/${{ env.REPO_NAME }}:light
${{ steps.set-product-version.output.prerelease-product-version == '' && format('public.ecr.aws/hashicorp/{0}:light', env.REPO_NAME) }}
public.ecr.aws/hashicorp/${{ env.REPO_NAME }}:light-${{ env.version }}
public.ecr.aws/hashicorp/${{ env.REPO_NAME }}:${{ env.version }}
dev_tags: |
@@ -272,9 +282,9 @@ jobs:
target: release-full
arch: ${{ matrix.arch }}
tags: |
docker.io/hashicorp/${{ env.REPO_NAME }}:full
${{ steps.set-product-version.output.prerelease-product-version == '' && format('docker.io/hashicorp/{0}:full', env.REPO_NAME) }}
docker.io/hashicorp/${{ env.REPO_NAME }}:full-${{ env.version }}
public.ecr.aws/hashicorp/${{ env.REPO_NAME }}:full
${{ steps.set-product-version.output.prerelease-product-version == '' && format('public.ecr.aws/hashicorp/{0}:full', env.REPO_NAME) }}
public.ecr.aws/hashicorp/${{ env.REPO_NAME }}:full-${{ env.version }}
dev_tags: |
docker.io/hashicorppreview/${{ env.REPO_NAME }}:full-${{ env.version }}
17 changes: 2 additions & 15 deletions .release/ci.hcl
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ project "packer" {
organization = "hashicorp"
repository = "packer"
release_branches = [
"main",
"main",
"release/**"
]
}
@@ -139,21 +139,8 @@ event "post-publish-website" {
}
}

event "bump-version" {
depends = ["post-publish-website"]
action "bump-version" {
organization = "hashicorp"
repository = "crt-workflows-common"
workflow = "bump-version"
}

notification {
on = "fail"
}
}

event "update-ironbank" {
depends = ["bump-version"]
depends = ["post-publish-website"]
action "update-ironbank" {
organization = "hashicorp"
repository = "crt-workflows-common"
4 changes: 4 additions & 0 deletions .release/docker/README.md
Original file line number Diff line number Diff line change
@@ -2,6 +2,10 @@

The root of this repository contains the officially supported HashiCorp Dockerfile to build the hashicorp/packer docker image. The `dev` docker image should be built for local dev and testing, while the production docker image, `release`, is built in CI and makes use of CI-built binaries. The `light` and `full` docker images are built using the official binaries from releases.hashicorp.com.

## License

This image is licensed under (BUSL-1.1)[https://github.com/hashicorp/packer/blob/main/LICENSE].

## Build

Refer to the Makefile of this repository, especially the `docker` and `docker-dev` targets to build a local version of the dev image based on the sources available.
86 changes: 19 additions & 67 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,74 +1,26 @@
## 1.11.0 (Upcoming)
## 1.10.3 (April 22, 2024)

### NOTES:
* **Breaking Change**: Support for loading single-component plugins has been removed from Packer. [GH-12785](https://github.com/hashicorp/packer/pull/12785)

* **Breaking Change**: Support for loading plugin binaries following
the naming convention of packer-plugin-name has been dropped. Packer will now only load
plugins stored under PACKER_PLUGIN_PATH using the expected namespaced
directory and CHECKSUM files. This change drops support for loading plugin
binaries in Packer's executable directory or a template's current working
directory. [GH-12828](https://github.com/hashicorp/packer/pull/12828)

```shell
/Users/dev/.packer.d/plugins
└── github.com
└── hashicorp
└── happycloud
├── packer-plugin-happycloud_v0.0.1_x5.0_darwin_arm64
└── packer-plugin-happycloud_v0.0.1_x5.0_darwin_arm64_SHA256SUM
```
### NOTES
* A LICENSE.txt file has been added to the Packer release artifacts.
[12981](https://github.com/hashicorp/packer/pull/12931)

### IMPROVEMENTS:
* core: Move to predictable plugin loading schema - Packer will now only load
plugins stored under PACKER_PLUGIN_PATH using the expected namespaced
directory and CHECKSUM files.
[GH-12828](https://github.com/hashicorp/packer/pull/12828)
* core: Remove support loading single-component plugins.
[GH-12785](https://github.com/hashicorp/packer/pull/12785)
* core: Packer now considers development binaries when evaluating plugin
version constraints. This work allows users to use binaries with versions
reported as "x.y.z-dev" to be used with the Packer `required_plugins`
block. [GH-12828](https://github.com/hashicorp/packer/pull/12828)

Given the specified version constraint only versions greater than or equal to 1.1.0 will be considered.

```hcl
amazon = {
source = "github.com/hashicorp/amazon"
version = ">= 1.1.0"
}
```
If a development binary is installed, Packer will use it if:

1. It is the highest compatible version installed.
2. There is no final plugin version with the same version number installed alongside it.

```shell
/Users/dev/.packer.d/plugins
└─ github.com
└─ hashicorp
└── amazon
├── packer-plugin-amazon_v1.1.0_x5.0_darwin_arm64
├── packer-plugin-amazon_v1.1.0_x5.0_darwin_arm64_SHA256SUM
├── packer-plugin-amazon_v1.1.1-dev_x5.0_darwin_arm64
└── packer-plugin-amazon_v1.1.1-dev_x5.0_darwin_arm64_SHA256SUM
```

Version 1.1.1-dev of the Amazon plugin will match the specified version constraint and be used for executing the Packer build.
### FEATURES
* Packer users can now track Packer version and plugin versions used for each
build artifact in HCP Packer.
[GH-12891](https://github.com/hashicorp/packer/pull/12891)
[GH-12910](https://github.com/hashicorp/packer/pull/12910)
[GH-12923](https://github.com/hashicorp/packer/pull/12923)
[GH-12926](https://github.com/hashicorp/packer/pull/12926)

If, however, a 1.1.1 release version of the plugin is available, it will have precedence over the development binary.
### SECURITY
* Bump github.com/go-jose/go-jose/v3 to address GHSA-c5q2-7r4c-mv6g.
[GH-12928](https://github.com/hashicorp/packer/pull/12928)
* Bump golang.org/x/net to v0.24.0 to address GO-2024-2687.
[GH-12924](https://github.com/hashicorp/packer/pull/12924)

```shell
/Users/dev/.packer.d/plugins
└─ github.com
└─ hashicorp
└── amazon
├── packer-plugin-amazon_v1.1.1-dev_x5.0_darwin_arm64
├── packer-plugin-amazon_v1.1.1-dev_x5.0_darwin_arm64_SHA256SUM
├── packer-plugin-amazon_v1.1.1_x5.0_darwin_arm64
└── packer-plugin-amazon_v1.1.1_x5.0_darwin_arm64_SHA256SUM
```
### BUG FIXES
* cmd/fmt: Display information error when Packer `fmt` fails due to HCL2
parsing error. [GH-12870](https://github.com/hashicorp/packer/pull/12870)

## 1.10.2 (March 6, 2024)

4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -45,11 +45,13 @@ LABEL name="Packer" \
version=$PRODUCT_VERSION \
release=$PRODUCT_VERSION \
summary="Packer is a tool for creating identical machine images for multiple platforms from a single source configuration." \
description="Packer is a tool for creating identical machine images for multiple platforms from a single source configuration. Please submit issues to https://github.com/hashicorp/packer/issues"
description="Packer is a tool for creating identical machine images for multiple platforms from a single source configuration. Please submit issues to https://github.com/hashicorp/packer/issues" \
org.opencontainers.image.licenses="BUSL-1.1"

RUN apk add --no-cache git bash wget openssl gnupg xorriso

COPY dist/$TARGETOS/$TARGETARCH/$BIN_NAME /bin/
COPY LICENSE /usr/share/doc/$PRODUCT_NAME/LICENSE.txt

ENTRYPOINT ["/bin/packer"]

15 changes: 15 additions & 0 deletions command/fmt_test.go
Original file line number Diff line number Diff line change
@@ -177,3 +177,18 @@ func Test_fmt_pipe(t *testing.T) {
})
}
}

const malformedTemplate = "test-fixtures/fmt_errs/malformed.pkr.hcl"

func TestFmtParseError(t *testing.T) {
p := helperCommand(t, "fmt", malformedTemplate)
outs, err := p.CombinedOutput()
if err == nil {
t.Errorf("Expected failure to format file, but command did not fail")
}
strLogs := string(outs)

if !strings.Contains(strLogs, "An argument or block definition is required here.") {
t.Errorf("Expected some diags about parse error, found none")
}
}
14 changes: 14 additions & 0 deletions command/test-fixtures/fmt_errs/malformed.pkr.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
variable "region" {
type =string
}

invalid

source "amazon-ebs" "example" {
region = var.region
}

build {
sources = ["source.amazon-ebs.example"]
}

12 changes: 6 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
@@ -22,7 +22,7 @@ require (
github.com/hashicorp/go-uuid v1.0.3
github.com/hashicorp/go-version v1.6.0
github.com/hashicorp/hcl/v2 v2.19.1
github.com/hashicorp/hcp-sdk-go v0.85.0
github.com/hashicorp/hcp-sdk-go v0.91.0
github.com/hashicorp/packer-plugin-amazon v1.2.1
github.com/hashicorp/packer-plugin-sdk v0.5.2
github.com/jehiah/go-strftime v0.0.0-20171201141054-1d33003b3869
@@ -44,13 +44,13 @@ require (
github.com/ulikunitz/xz v0.5.10
github.com/zclconf/go-cty v1.13.3
github.com/zclconf/go-cty-yaml v1.0.1
golang.org/x/crypto v0.17.0 // indirect
golang.org/x/crypto v0.22.0 // indirect
golang.org/x/mod v0.13.0
golang.org/x/net v0.19.0
golang.org/x/net v0.24.0
golang.org/x/oauth2 v0.15.0
golang.org/x/sync v0.4.0
golang.org/x/sys v0.15.0 // indirect
golang.org/x/term v0.15.0 // indirect
golang.org/x/sys v0.19.0 // indirect
golang.org/x/term v0.19.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/tools v0.14.0
google.golang.org/api v0.128.0 // indirect
@@ -98,7 +98,7 @@ require (
github.com/fatih/color v1.14.1 // indirect
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
github.com/go-git/go-billy/v5 v5.5.0 // indirect
github.com/go-jose/go-jose/v3 v3.0.1 // indirect
github.com/go-jose/go-jose/v3 v3.0.3 // indirect
github.com/go-logr/logr v1.3.0 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
32 changes: 19 additions & 13 deletions go.sum
Original file line number Diff line number Diff line change
@@ -136,8 +136,8 @@ github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399 h1:eMj
github.com/go-git/go-git/v5 v5.11.0 h1:XIZc1p+8YzypNr34itUfSvYJcv+eYdTnTvOZ2vD3cA4=
github.com/go-git/go-git/v5 v5.11.0/go.mod h1:6GFcX2P3NM7FPBfpePbpLd21XxsgdAt+lKqXmCUiUCY=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
github.com/go-jose/go-jose/v3 v3.0.1 h1:pWmKFVtt+Jl0vBZTIpz/eAKwsm6LkIxDVVbFHKkchhA=
github.com/go-jose/go-jose/v3 v3.0.1/go.mod h1:RNkWWRld676jZEYoV3+XK8L2ZnNSvIsxFMht0mSX+u8=
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=
@@ -299,8 +299,8 @@ 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/hcp-sdk-go v0.85.0 h1:RDXpIf4gIGfz6je8Qq0FGg+8kwj7KboQTOxnklWyVJk=
github.com/hashicorp/hcp-sdk-go v0.85.0/go.mod h1:vQ4fzdL1AmhIAbCw+4zmFe5Hbpajj3NvRWkJoVuxmAk=
github.com/hashicorp/hcp-sdk-go v0.91.0 h1:XFJuB/KWP7kh6u3c/ruUy/lSA272vRrHJ1kzusMx9zw=
github.com/hashicorp/hcp-sdk-go v0.91.0/go.mod h1:vQ4fzdL1AmhIAbCw+4zmFe5Hbpajj3NvRWkJoVuxmAk=
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=
@@ -558,7 +558,6 @@ golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnf
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-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20190911031432-227b76d455e7/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20190923035154-9ee001bba392/go.mod h1:/lpIB1dKB+9EgE3H3cr1v9wB50oz8l4C4h62xy7jSTY=
golang.org/x/crypto v0.0.0-20200414173820-0848c9571904/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200422194213-44a606286825/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
@@ -570,8 +569,9 @@ golang.org/x/crypto v0.0.0-20220314234659-1baeb1ce4c0b/go.mod h1:IxCIyHEi3zRg3s0
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4=
golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU=
golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k=
golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4=
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30=
golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
@@ -610,8 +610,9 @@ golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug
golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY=
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc=
golang.org/x/net v0.19.0 h1:zTwKpTd2XuCqf8huc7Fo2iSy+4RHPd10s4KzeTnVr1c=
golang.org/x/net v0.19.0/go.mod h1:CfAk/cbD4CthTvqiEl8NpboMuiuOYsAr/7NOjZJtv1U=
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w=
golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.15.0 h1:s8pnnxNVzjWyrvYdFUQq5llS1PX2zhPXmccZv99h7uQ=
@@ -666,15 +667,19 @@ golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc=
golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
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.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o=
golang.org/x/sys v0.19.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.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc=
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U=
golang.org/x/term v0.15.0 h1:y/Oo/a/q3IXu26lQgl04j/gjuBDOBlx7X6Om1j2CPW4=
golang.org/x/term v0.15.0/go.mod h1:BDl952bC7+uMoWR75FIrCDx79TPU9oHkTZ9yRbYOrX0=
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.19.0 h1:+ThwsDv+tYfnJFhF4L8jITxu1tdTWRTZpdsWgEgjL6Q=
golang.org/x/term v0.19.0/go.mod h1:2CuTdWZ7KHSQwUzKva0cbMg6q2DMI3Mmxp+gKJbskEk=
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=
@@ -684,6 +689,7 @@ golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
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.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
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-20220210224613-90d013bbcef8 h1:vVKdlvoWBphwdxWKrFZEuM0kGgGLxUOYcY4U/2Vjg44=
3 changes: 2 additions & 1 deletion hcl2template/formatter.go
Original file line number Diff line number Diff line change
@@ -12,6 +12,7 @@ import (
"path/filepath"
"strings"

"github.com/hashicorp/go-multierror"
"github.com/hashicorp/hcl/v2"
"github.com/hashicorp/hcl/v2/hclparse"
"github.com/hashicorp/hcl/v2/hclwrite"
@@ -135,7 +136,7 @@ func (f *HCL2Formatter) processFile(filename string) ([]byte, error) {

_, diags := f.parser.ParseHCL(inSrc, filename)
if diags.HasErrors() {
return nil, fmt.Errorf("failed to parse HCL %s", filename)
return nil, multierror.Append(nil, diags.Errs()...)
}

outSrc := hclwrite.Format(inSrc)
2 changes: 1 addition & 1 deletion hcl2template/parser.go
Original file line number Diff line number Diff line change
@@ -157,7 +157,7 @@ func (p *Parser) Parse(filename string, varFiles []string, argVars map[string]st
// Before we go further, we'll check to make sure this version can read
// all files, so we can produce a version-related error message rather than
// potentially-confusing downstream errors.
versionDiags := cfg.CheckCoreVersionRequirements(p.CorePackerVersion)
versionDiags := cfg.CheckCoreVersionRequirements(p.CorePackerVersion.Core())
diags = append(diags, versionDiags...)
if versionDiags.HasErrors() {
return cfg, diags
3 changes: 3 additions & 0 deletions hcl2template/types.build.hcp_packer_registry_test.go
Original file line number Diff line number Diff line change
@@ -57,6 +57,7 @@ func Test_ParseHCPPackerRegistryBlock(t *testing.T) {
Builder: emptyMockBuilder,
Provisioners: []packer.CoreBuildProvisioner{},
PostProcessors: [][]packer.CoreBuildPostProcessor{},
BuilderType: "virtualbox-iso",
},
},
false,
@@ -110,6 +111,7 @@ func Test_ParseHCPPackerRegistryBlock(t *testing.T) {
Builder: emptyMockBuilder,
Provisioners: []packer.CoreBuildProvisioner{},
PostProcessors: [][]packer.CoreBuildPostProcessor{},
BuilderType: "virtualbox-iso",
},
},
false,
@@ -241,6 +243,7 @@ func Test_ParseHCPPackerRegistryBlock(t *testing.T) {
Provisioners: []packer.CoreBuildProvisioner{},
PostProcessors: [][]packer.CoreBuildPostProcessor{},
Prepared: true,
BuilderType: "null",
},
},
false,
34 changes: 21 additions & 13 deletions hcl2template/types.build_test.go
Original file line number Diff line number Diff line change
@@ -283,6 +283,7 @@ func TestParse_build(t *testing.T) {
[]packersdk.Build{
&packer.CoreBuild{
Type: "virtualbox-iso.ubuntu-1204",
BuilderType: "virtualbox-iso",
Prepared: true,
Builder: emptyMockBuilder,
Provisioners: []packer.CoreBuildProvisioner{},
@@ -317,6 +318,7 @@ func TestParse_build(t *testing.T) {
},
&packer.CoreBuild{
Type: "amazon-ebs.aws-ubuntu-16.04",
BuilderType: "amazon-ebs",
Prepared: true,
Builder: emptyMockBuilder,
Provisioners: []packer.CoreBuildProvisioner{},
@@ -397,9 +399,10 @@ func TestParse_build(t *testing.T) {
false, false,
[]packersdk.Build{
&packer.CoreBuild{
Type: "virtualbox-iso.ubuntu-1204",
Prepared: true,
Builder: emptyMockBuilder,
Type: "virtualbox-iso.ubuntu-1204",
BuilderType: "virtualbox-iso",
Prepared: true,
Builder: emptyMockBuilder,
Provisioners: []packer.CoreBuildProvisioner{
{
PType: "shell",
@@ -427,9 +430,10 @@ func TestParse_build(t *testing.T) {
PostProcessors: [][]packer.CoreBuildPostProcessor{},
},
&packer.CoreBuild{
Type: "amazon-ebs.aws-ubuntu-16.04",
Prepared: true,
Builder: emptyMockBuilder,
Type: "amazon-ebs.aws-ubuntu-16.04",
BuilderType: "amazon-ebs",
Prepared: true,
Builder: emptyMockBuilder,
Provisioners: []packer.CoreBuildProvisioner{
{
PType: "file",
@@ -486,9 +490,10 @@ func TestParse_build(t *testing.T) {
false, false,
[]packersdk.Build{
&packer.CoreBuild{
Type: "virtualbox-iso.ubuntu-1204",
Prepared: true,
Builder: emptyMockBuilder,
Type: "virtualbox-iso.ubuntu-1204",
BuilderType: "virtualbox-iso",
Prepared: true,
Builder: emptyMockBuilder,
Provisioners: []packer.CoreBuildProvisioner{
{
PType: "shell",
@@ -550,6 +555,7 @@ func TestParse_build(t *testing.T) {
&packer.CoreBuild{
BuildName: "build-name",
Type: "virtualbox-iso.ubuntu-1204",
BuilderType: "virtualbox-iso",
Prepared: true,
Builder: emptyMockBuilder,
Provisioners: []packer.CoreBuildProvisioner{},
@@ -604,6 +610,7 @@ func TestParse_build(t *testing.T) {
&packer.CoreBuild{
BuildName: "test-build",
Type: "virtualbox-iso.ubuntu-1204",
BuilderType: "virtualbox-iso",
Prepared: true,
Builder: emptyMockBuilder,
Provisioners: []packer.CoreBuildProvisioner{},
@@ -659,10 +666,11 @@ func TestParse_build(t *testing.T) {
false, false,
[]packersdk.Build{
&packer.CoreBuild{
BuildName: "build-name-test",
Type: "virtualbox-iso.ubuntu-1204",
Prepared: true,
Builder: emptyMockBuilder,
BuildName: "build-name-test",
Type: "virtualbox-iso.ubuntu-1204",
BuilderType: "virtualbox-iso",
Prepared: true,
Builder: emptyMockBuilder,
Provisioners: []packer.CoreBuildProvisioner{
{
PName: "build-name-test",
2 changes: 2 additions & 0 deletions hcl2template/types.datasource_test.go
Original file line number Diff line number Diff line change
@@ -57,6 +57,7 @@ func TestParse_datasource(t *testing.T) {
[]packersdk.Build{
&packer.CoreBuild{
Type: "null.test",
BuilderType: "null",
Builder: &null.Builder{},
Provisioners: []packer.CoreBuildProvisioner{},
PostProcessors: [][]packer.CoreBuildPostProcessor{},
@@ -134,6 +135,7 @@ func TestParse_datasource(t *testing.T) {
[]packersdk.Build{
&packer.CoreBuild{
Type: "null.test",
BuilderType: "null",
Builder: &null.Builder{},
Provisioners: []packer.CoreBuildProvisioner{},
PostProcessors: [][]packer.CoreBuildPostProcessor{},
1 change: 1 addition & 0 deletions hcl2template/types.packer_config.go
Original file line number Diff line number Diff line change
@@ -622,6 +622,7 @@ func (cfg *PackerConfig) GetBuilds(opts packer.GetBuildsOptions) ([]packersdk.Bu

decoded, _ := decodeHCL2Spec(srcUsage.Body, cfg.EvalContext(BuildContext, nil), builder)
pcb.HCLConfig = decoded
pcb.BuilderType = srcUsage.Type

// If the builder has provided a list of to-be-generated variables that
// should be made accessible to provisioners, pass that list into
10 changes: 6 additions & 4 deletions hcl2template/types.packer_config_test.go
Original file line number Diff line number Diff line change
@@ -208,8 +208,9 @@ func TestParser_complete(t *testing.T) {
false, false,
[]packersdk.Build{
&packer.CoreBuild{
Type: "virtualbox-iso.ubuntu-1204",
Prepared: true,
Type: "virtualbox-iso.ubuntu-1204",
BuilderType: "virtualbox-iso",
Prepared: true,
Builder: &MockBuilder{
Config: MockConfig{
NestedMockConfig: NestedMockConfig{
@@ -319,8 +320,9 @@ func TestParser_complete(t *testing.T) {
},
},
&packer.CoreBuild{
Type: "amazon-ebs.ubuntu-1604",
Prepared: true,
Type: "amazon-ebs.ubuntu-1604",
BuilderType: "amazon-ebs",
Prepared: true,
Builder: &MockBuilder{
Config: MockConfig{
NestedMockConfig: NestedMockConfig{
1 change: 1 addition & 0 deletions hcl2template/types.source_test.go
Original file line number Diff line number Diff line change
@@ -55,6 +55,7 @@ func TestParse_source(t *testing.T) {
[]packersdk.Build{
&packer.CoreBuild{
Type: "null.test",
BuilderType: "null",
Builder: &null.Builder{},
Provisioners: []packer.CoreBuildProvisioner{},
PostProcessors: [][]packer.CoreBuildPostProcessor{},
13 changes: 10 additions & 3 deletions hcl2template/types.variables_test.go
Original file line number Diff line number Diff line change
@@ -129,6 +129,7 @@ func TestParse_variables(t *testing.T) {
[]packersdk.Build{
&packer.CoreBuild{
Type: "null.test",
BuilderType: "null",
Builder: &null.Builder{},
Provisioners: []packer.CoreBuildProvisioner{},
PostProcessors: [][]packer.CoreBuildPostProcessor{},
@@ -293,6 +294,7 @@ func TestParse_variables(t *testing.T) {
[]packersdk.Build{
&packer.CoreBuild{
Type: "null",
BuilderType: "null",
Builder: &null.Builder{},
Provisioners: []packer.CoreBuildProvisioner{},
PostProcessors: [][]packer.CoreBuildPostProcessor{},
@@ -379,6 +381,7 @@ func TestParse_variables(t *testing.T) {
[]packersdk.Build{
&packer.CoreBuild{
Type: "null.test",
BuilderType: "null",
Builder: &null.Builder{},
Provisioners: []packer.CoreBuildProvisioner{},
PostProcessors: [][]packer.CoreBuildPostProcessor{},
@@ -442,6 +445,7 @@ func TestParse_variables(t *testing.T) {
[]packersdk.Build{
&packer.CoreBuild{
Type: "null.test",
BuilderType: "null",
Builder: &null.Builder{},
Provisioners: []packer.CoreBuildProvisioner{},
PostProcessors: [][]packer.CoreBuildPostProcessor{},
@@ -483,6 +487,7 @@ func TestParse_variables(t *testing.T) {
[]packersdk.Build{
&packer.CoreBuild{
Type: "null.test",
BuilderType: "null",
Builder: &null.Builder{},
Provisioners: []packer.CoreBuildProvisioner{},
PostProcessors: [][]packer.CoreBuildPostProcessor{},
@@ -538,9 +543,10 @@ func TestParse_variables(t *testing.T) {
},
false, false,
[]packersdk.Build{&packer.CoreBuild{
Type: "null.null-builder",
Prepared: true,
Builder: &null.Builder{},
Type: "null.null-builder",
BuilderType: "null",
Prepared: true,
Builder: &null.Builder{},
Provisioners: []packer.CoreBuildProvisioner{
{
PType: "shell",
@@ -627,6 +633,7 @@ func TestParse_variables(t *testing.T) {
[]packersdk.Build{
&packer.CoreBuild{
Type: "null.test",
BuilderType: "null",
Builder: &null.Builder{},
Provisioners: []packer.CoreBuildProvisioner{},
PostProcessors: [][]packer.CoreBuildPostProcessor{},
2 changes: 2 additions & 0 deletions internal/hcp/api/service_build.go
Original file line number Diff line number Diff line change
@@ -58,6 +58,7 @@ func (c *Client) UpdateBuild(
buildLabels map[string]string,
buildStatus hcpPackerModels.HashicorpCloudPacker20230101BuildStatus,
artifacts []*hcpPackerModels.HashicorpCloudPacker20230101ArtifactCreateBody,
metadata *hcpPackerModels.HashicorpCloudPacker20230101BuildMetadata,
) (string, error) {

params := hcpPackerAPI.NewPackerServiceUpdateBuildParamsWithContext(ctx)
@@ -76,6 +77,7 @@ func (c *Client) UpdateBuild(
Platform: platform,
SourceExternalIdentifier: sourceExternalIdentifier,
Status: &buildStatus,
Metadata: metadata,
}

resp, err := c.Packer.PackerServiceUpdateBuild(params, nil)
13 changes: 10 additions & 3 deletions internal/hcp/registry/hcl.go
Original file line number Diff line number Diff line change
@@ -70,6 +70,7 @@ func (h *HCLRegistry) StartBuild(ctx context.Context, build sdkpacker.Build) err
if ok {
name = cb.Type
}

return h.bucket.startBuild(ctx, name)
}

@@ -80,12 +81,18 @@ func (h *HCLRegistry) CompleteBuild(
artifacts []sdkpacker.Artifact,
buildErr error,
) ([]sdkpacker.Artifact, error) {
name := build.Name()
buildName := build.Name()
cb, ok := build.(*packer.CoreBuild)
if ok {
name = cb.Type
buildName = cb.Type
}

buildMetadata := cb.GetMetadata()
err := h.bucket.Version.AddMetadataToBuild(ctx, buildName, buildMetadata)
if err != nil {
return nil, err
}
return h.bucket.completeBuild(ctx, name, artifacts, buildErr)
return h.bucket.completeBuild(ctx, buildName, artifacts, buildErr)
}

// VersionStatusSummary prints a status report in the UI if the version is not yet done
11 changes: 9 additions & 2 deletions internal/hcp/registry/json.go
Original file line number Diff line number Diff line change
@@ -83,7 +83,8 @@ func (h *JSONRegistry) PopulateVersion(ctx context.Context) error {

// StartBuild is invoked when one build for the configuration is starting to be processed
func (h *JSONRegistry) StartBuild(ctx context.Context, build sdkpacker.Build) error {
return h.bucket.startBuild(ctx, build.Name())
name := build.Name()
return h.bucket.startBuild(ctx, name)
}

// CompleteBuild is invoked when one build for the configuration has finished
@@ -93,7 +94,13 @@ func (h *JSONRegistry) CompleteBuild(
artifacts []sdkpacker.Artifact,
buildErr error,
) ([]sdkpacker.Artifact, error) {
return h.bucket.completeBuild(ctx, build.Name(), artifacts, buildErr)
buildName := build.Name()
buildMetadata := build.(*packer.CoreBuild).GetMetadata()
err := h.bucket.Version.AddMetadataToBuild(ctx, buildName, buildMetadata)
if err != nil {
return nil, err
}
return h.bucket.completeBuild(ctx, buildName, artifacts, buildErr)
}

// VersionStatusSummary prints a status report in the UI if the version is not yet done
3 changes: 3 additions & 0 deletions internal/hcp/registry/types.bucket.go
Original file line number Diff line number Diff line change
@@ -213,6 +213,7 @@ func (bucket *Bucket) UpdateBuildStatus(
nil,
status,
nil,
nil,
)
if err != nil {
return err
@@ -285,6 +286,7 @@ func (bucket *Bucket) markBuildComplete(ctx context.Context, name string) error
buildToUpdate.Labels,
status,
artifacts,
&buildToUpdate.Metadata,
)
if err != nil {
return err
@@ -535,6 +537,7 @@ func (bucket *Bucket) HeartbeatBuild(ctx context.Context, build string) (func(),
nil,
hcpPackerModels.HashicorpCloudPacker20230101BuildStatusBUILDRUNNING,
nil,
nil,
)
if err != nil {
log.Printf("[ERROR] failed to send heartbeat for build %q: %s", build, err)
1 change: 1 addition & 0 deletions internal/hcp/registry/types.builds.go
Original file line number Diff line number Diff line change
@@ -19,6 +19,7 @@ type Build struct {
Labels map[string]string
Artifacts map[string]packerSDKRegistry.Image
Status hcpPackerModels.HashicorpCloudPacker20230101BuildStatus
Metadata hcpPackerModels.HashicorpCloudPacker20230101BuildMetadata
}

// NewBuildFromCloudPackerBuild converts a HashicorpCloudPackerBuild to a local build that can be tracked and
28 changes: 28 additions & 0 deletions internal/hcp/registry/types.version.go
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@
package registry

import (
"context"
"errors"
"fmt"
"math/rand"
@@ -16,6 +17,7 @@ import (
sdkpacker "github.com/hashicorp/packer-plugin-sdk/packer"
packerSDKRegistry "github.com/hashicorp/packer-plugin-sdk/packer/registry/image"
"github.com/hashicorp/packer/internal/hcp/env"
"github.com/hashicorp/packer/packer"
"github.com/oklog/ulid"
)

@@ -174,3 +176,29 @@ func (version *Version) statusSummary(ui sdkpacker.Ui) {

ui.Say(buf.String())
}

// AddMetadataToBuild adds metadata to a build in the HCP Packer registry.
func (version *Version) AddMetadataToBuild(
ctx context.Context, buildName string, metadata packer.BuildMetadata,
) error {
buildToUpdate, err := version.Build(buildName)
if err != nil {
return err
}

packerMetadata := make(map[string]interface{})
packerMetadata["version"] = metadata.PackerVersion

var pluginsMetadata []map[string]interface{}
for _, plugin := range metadata.Plugins {
pluginMetadata := map[string]interface{}{
"version": plugin.Description.Version,
"name": plugin.Name,
}
pluginsMetadata = append(pluginsMetadata, pluginMetadata)
}
packerMetadata["plugins"] = pluginsMetadata

buildToUpdate.Metadata.Packer = packerMetadata
return nil
}
40 changes: 40 additions & 0 deletions packer/build.go
Original file line number Diff line number Diff line change
@@ -52,6 +52,46 @@ type CoreBuild struct {
prepareCalled bool
}

type BuildMetadata struct {
PackerVersion string
Plugins map[string]PluginDetails
}

func (b *CoreBuild) getPluginsMetadata() map[string]PluginDetails {
resp := map[string]PluginDetails{}

builderPlugin, builderPluginOk := PluginsDetailsStorage[fmt.Sprintf("%q-%q", PluginComponentBuilder, b.BuilderType)]
if builderPluginOk {
resp[builderPlugin.Name] = builderPlugin
}

for _, pp := range b.PostProcessors {
for _, p := range pp {
postprocessorsPlugin, postprocessorsPluginOk := PluginsDetailsStorage[fmt.Sprintf("%q-%q", PluginComponentPostProcessor, p.PType)]
if postprocessorsPluginOk {
resp[postprocessorsPlugin.Name] = postprocessorsPlugin
}
}
}

for _, pv := range b.Provisioners {
provisionerPlugin, provisionerPluginOk := PluginsDetailsStorage[fmt.Sprintf("%q-%q", PluginComponentProvisioner, pv.PType)]
if provisionerPluginOk {
resp[provisionerPlugin.Name] = provisionerPlugin
}
}

return resp
}

func (b *CoreBuild) GetMetadata() BuildMetadata {
metadata := BuildMetadata{
PackerVersion: version.FormattedVersion(),
Plugins: b.getPluginsMetadata(),
}
return metadata
}

// CoreBuildPostProcessor Keeps track of the post-processor and the
// configuration of the post-processor used within a build.
type CoreBuildPostProcessor struct {
28 changes: 28 additions & 0 deletions packer/plugin.go
Original file line number Diff line number Diff line change
@@ -264,6 +264,11 @@ func (c *PluginConfig) DiscoverMultiPlugin(pluginName, pluginPath string) error
}

pluginPrefix := pluginName + "-"
pluginDetails := PluginDetails{
Name: pluginName,
Description: desc,
PluginPath: pluginPath,
}

for _, builderName := range desc.Builders {
builderName := builderName // copy to avoid pointer overwrite issue
@@ -274,6 +279,8 @@ func (c *PluginConfig) DiscoverMultiPlugin(pluginName, pluginPath string) error
c.Builders.Set(key, func() (packersdk.Builder, error) {
return c.Client(pluginPath, "start", "builder", builderName).Builder()
})
PluginsDetailsStorage[fmt.Sprintf("%q-%q", PluginComponentBuilder, key)] = pluginDetails

}

if len(desc.Builders) > 0 {
@@ -289,6 +296,7 @@ func (c *PluginConfig) DiscoverMultiPlugin(pluginName, pluginPath string) error
c.PostProcessors.Set(key, func() (packersdk.PostProcessor, error) {
return c.Client(pluginPath, "start", "post-processor", postProcessorName).PostProcessor()
})
PluginsDetailsStorage[fmt.Sprintf("%q-%q", PluginComponentPostProcessor, key)] = pluginDetails
}

if len(desc.PostProcessors) > 0 {
@@ -304,6 +312,8 @@ func (c *PluginConfig) DiscoverMultiPlugin(pluginName, pluginPath string) error
c.Provisioners.Set(key, func() (packersdk.Provisioner, error) {
return c.Client(pluginPath, "start", "provisioner", provisionerName).Provisioner()
})
PluginsDetailsStorage[fmt.Sprintf("%q-%q", PluginComponentProvisioner, key)] = pluginDetails

}
if len(desc.Provisioners) > 0 {
log.Printf("found external %v provisioner from %s plugin", desc.Provisioners, pluginName)
@@ -318,6 +328,7 @@ func (c *PluginConfig) DiscoverMultiPlugin(pluginName, pluginPath string) error
c.DataSources.Set(key, func() (packersdk.Datasource, error) {
return c.Client(pluginPath, "start", "datasource", datasourceName).Datasource()
})
PluginsDetailsStorage[fmt.Sprintf("%q-%q", PluginComponentDataSource, key)] = pluginDetails
}
if len(desc.Datasources) > 0 {
log.Printf("found external %v datasource from %s plugin", desc.Datasources, pluginName)
@@ -423,3 +434,20 @@ func (c *PluginConfig) discoverInstalledComponents(path string) error {

return nil
}

type PluginComponentType string

const (
PluginComponentBuilder PluginComponentType = "builder"
PluginComponentPostProcessor PluginComponentType = "post-processor"
PluginComponentProvisioner PluginComponentType = "provisioner"
PluginComponentDataSource PluginComponentType = "data-source"
)

type PluginDetails struct {
Name string
Description pluginsdk.SetDescription
PluginPath string
}

var PluginsDetailsStorage = map[string]PluginDetails{}
2 changes: 1 addition & 1 deletion version/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.10.2
1.10.3
38 changes: 29 additions & 9 deletions version/version.go
Original file line number Diff line number Diff line change
@@ -4,6 +4,10 @@
package version

import (
_ "embed"
"fmt"
"strings"

"github.com/hashicorp/go-version"
pluginVersion "github.com/hashicorp/packer-plugin-sdk/version"
)
@@ -16,21 +20,24 @@ var (
// Whether cgo is enabled or not; set at build time
CgoEnabled bool

//go:embed VERSION
rawVersion string

// The next version number that will be released. This will be updated after every release
// Version must conform to the format expected by github.com/hashicorp/go-version
// for tests to work.
// A pre-release marker for the version can also be specified (e.g -dev). If this is omitted
// The main version number that is being run at the moment.

Version = "1.10.2"

Version string
// 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 = "dev"

VersionMetadata = ""
VersionPrerelease string
// VersionMetadata may be added to give more non-normalised information on a build
// like a commit SHA for example.
//
// Ex: 1.0.0-dev+metadata
VersionMetadata string
)

var PackerVersion *pluginVersion.PluginVersion
@@ -45,8 +52,21 @@ func FormattedVersion() string {
var SemVer *version.Version

func init() {
PackerVersion = pluginVersion.InitializePluginVersion(Version, VersionPrerelease)
SemVer = PackerVersion.SemVer()
var err error

// Note: we use strings.TrimSpace on the version read from version/VERSION
// as it could have trailing whitespaces that must not be part of the
// version string, otherwise version.NewSemver will reject it.
SemVer, err = version.NewSemver(strings.TrimSpace(rawVersion))
if err != nil {
panic(fmt.Sprintf("Invalid semver version specified in 'version/VERSION' (%q): %s", rawVersion, err))
}

Version = SemVer.Core().String()
VersionPrerelease = SemVer.Prerelease()
VersionMetadata = SemVer.Metadata()

PackerVersion = pluginVersion.InitializePluginVersion(SemVer.Core().String(), SemVer.Prerelease())
}

// String returns the complete version string, including prerelease
2 changes: 1 addition & 1 deletion website/content/docs/plugins/creation/index.mdx
Original file line number Diff line number Diff line change
@@ -203,7 +203,7 @@ wget https://github.com/hashicorp/packer-plugin-scaffolding/archive/refs/heads/m
unzip main.zip
cp packer-plugin-scaffolding-main/.web-docs/metadata.hcl .web-docs/
cp -r packer-plugin-scaffolding-main/.web-docs/scripts/ .web-docs/scripts/
cp .github/workflows/notify-integration-release-via-* .github/workflows/
cp packer-plugin-scaffolding-main/.github/workflows/notify-integration-release-via-* .github/workflows/

# Remove downloaded scaffolding project
rm main.zip
Original file line number Diff line number Diff line change
@@ -28,7 +28,7 @@ input variables, input variables remain as the single source of input to a
template that a user can easily discover using `packer inspect`.

When the environment variable is not set at all -- not even with the empty
string -- the value returned by `env` will be an an empty string. It will still
string -- the value returned by `env` will be an empty string. It will still
be possible to set it using other means but you could use [custom validation
rules](/packer/docs/templates/hcl_templates/variables#custom-validation-rules) to error in that case
to make sure it is set, for example:
2 changes: 1 addition & 1 deletion website/content/guides/1.7-template-upgrade.mdx
Original file line number Diff line number Diff line change
@@ -65,7 +65,7 @@ we suggest you reach out to the plugin maintainers and ask for an upgrade; the P
maintainer-focused guide [here](/packer/guides/1.7-plugin-upgrade).

Check the table below to better understand whether your plugin is compatible with `packer init`, with manual
installation, or with both for the the Packer version you are using.
installation, or with both for the Packer version you are using.

| Packer Core Version | Single Component Plugin - API v4 | Single Component Plugin - API v5.0 | Multi Component Plugin - API v5.0 |
| ------------------- | ------------------------------------------------- | ------------------------------------------------- | --------------------------------------------------------- |
Original file line number Diff line number Diff line change
@@ -76,7 +76,7 @@
File Transfer Protocol.

**NOTE**: Guests using Windows with Win32-OpenSSH v9.1.0.0p1-Beta, scp
(the default protocol for copying data) returns a a non-zero error code since the MOTW
(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_protocol = "sftp"`.