Skip to content

Commit

Permalink
Convert to packer-plugin-sdk
Browse files Browse the repository at this point in the history
All dependencies updated. Go version bumped to 1.18. HCLv2 fixed to
v2.14.1 due to hashicorp/packer-plugin-sdk#131.
  • Loading branch information
angdraug committed Jan 7, 2023
1 parent 8ebe36b commit e38812e
Show file tree
Hide file tree
Showing 12 changed files with 648 additions and 288 deletions.
8 changes: 4 additions & 4 deletions builder/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import (
"context"

"github.com/hashicorp/hcl/v2/hcldec"
"github.com/hashicorp/packer/common"
"github.com/hashicorp/packer/helper/multistep"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer-plugin-sdk/multistep"
"github.com/hashicorp/packer-plugin-sdk/multistep/commonsteps"
"github.com/hashicorp/packer-plugin-sdk/packer"
)

const BuilderId = "angdraug.nspawn"
Expand Down Expand Up @@ -53,7 +53,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack
state.Put("ui", ui)
state.Put("machine", &machine)

b.runner = common.NewRunner(steps, b.config.PackerConfig, ui)
b.runner = commonsteps.NewRunner(steps, b.config.PackerConfig, ui)
b.runner.Run(ctx, state)

if rawErr, ok := state.GetOk("error"); ok {
Expand Down
2 changes: 1 addition & 1 deletion builder/communicator.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"io"
"os"

"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer-plugin-sdk/packer"
)

type Communicator struct {
Expand Down
9 changes: 5 additions & 4 deletions builder/config.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
//go:generate mapstructure-to-hcl2 -type Config
//go:generate packer-sdc struct-markdown
//go:generate packer-sdc mapstructure-to-hcl2 -type Config
package builder

import (
"fmt"
"os"
"time"

"github.com/hashicorp/packer/common"
"github.com/hashicorp/packer/helper/config"
"github.com/hashicorp/packer/template/interpolate"
"github.com/hashicorp/packer-plugin-sdk/common"
"github.com/hashicorp/packer-plugin-sdk/template/config"
"github.com/hashicorp/packer-plugin-sdk/template/interpolate"
)

type Config struct {
Expand Down
2 changes: 1 addition & 1 deletion builder/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"strings"
"time"

"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer-plugin-sdk/packer"
)

type ExecWrapper struct {
Expand Down
2 changes: 1 addition & 1 deletion builder/step_clone.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package builder
import (
"context"

"github.com/hashicorp/packer/helper/multistep"
"github.com/hashicorp/packer-plugin-sdk/multistep"
)

type StepClone struct{}
Expand Down
5 changes: 3 additions & 2 deletions builder/step_debootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"fmt"

"github.com/hashicorp/packer/helper/multistep"
"github.com/hashicorp/packer-plugin-sdk/multistep"
)

type StepDebootstrap struct{}
Expand All @@ -15,7 +15,8 @@ func (s *StepDebootstrap) Run(ctx context.Context, state multistep.StateBag) mul

args := []string{
"/usr/sbin/debootstrap",
"--include=apt-utils,dbus,iputils-ping,netbase,procps,systemd-container,systemd-resolved",
"--include=apt-utils,iputils-ping,netbase,procps," +
"dbus,systemd-container,systemd-resolved",
fmt.Sprintf("--cache-dir=%s", config.CacheDir),
}
if config.Variant != "" {
Expand Down
2 changes: 1 addition & 1 deletion builder/step_import.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package builder
import (
"context"

"github.com/hashicorp/packer/helper/multistep"
"github.com/hashicorp/packer-plugin-sdk/multistep"
)

type StepImport struct{}
Expand Down
4 changes: 2 additions & 2 deletions builder/step_prepare_target.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"context"
"fmt"

"github.com/hashicorp/packer/helper/multistep"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer-plugin-sdk/multistep"
"github.com/hashicorp/packer-plugin-sdk/packer"
)

type StepPrepareTarget struct{}
Expand Down
8 changes: 4 additions & 4 deletions builder/step_provision.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package builder
import (
"context"

"github.com/hashicorp/packer/common"
"github.com/hashicorp/packer/helper/multistep"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer-plugin-sdk/multistep"
"github.com/hashicorp/packer-plugin-sdk/multistep/commonsteps"
"github.com/hashicorp/packer-plugin-sdk/packer"
)

type StepProvision struct{}
Expand All @@ -19,7 +19,7 @@ func (s *StepProvision) Run(ctx context.Context, state multistep.StateBag) multi

comm := &Communicator{machine}

hookData := common.PopulateProvisionHookData(state)
hookData := commonsteps.PopulateProvisionHookData(state)

ui.Say("Running the provision hook")
if err := hook.Run(ctx, packer.HookProvision, ui, comm, hookData); err != nil {
Expand Down
89 changes: 83 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,12 +1,89 @@
module git.sr.ht/~angdraug/packer-builder-nspawn

go 1.15
go 1.18

require (
github.com/coreos/go-systemd/v22 v22.1.0
github.com/hashicorp/hcl/v2 v2.7.0
github.com/hashicorp/packer v1.6.4
github.com/zclconf/go-cty v1.5.0
github.com/coreos/go-systemd/v22 v22.5.0
github.com/hashicorp/hcl/v2 v2.14.1
github.com/hashicorp/packer-plugin-sdk v0.3.2
github.com/zclconf/go-cty v1.10.0
)

replace github.com/hashicorp/packer => github.com/angdraug/packer v1.6.4-ugorji-go-v1.1.13
require (
cloud.google.com/go v0.94.0 // indirect
cloud.google.com/go/storage v1.16.1 // 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/armon/go-metrics v0.3.9 // indirect
github.com/aws/aws-sdk-go v1.40.34 // 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.12.0 // indirect
github.com/godbus/dbus/v5 v5.0.4 // 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/golang/snappy v0.0.4 // indirect
github.com/google/go-cmp v0.5.6 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/googleapis/gax-go/v2 v2.1.0 // indirect
github.com/hashicorp/consul/api v1.10.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.1.0 // indirect
github.com/hashicorp/go-getter/s3/v2 v2.1.0 // indirect
github.com/hashicorp/go-getter/v2 v2.1.0 // indirect
github.com/hashicorp/go-hclog v0.16.2 // 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-sockaddr v1.0.2 // indirect
github.com/hashicorp/go-version v1.3.0 // indirect
github.com/hashicorp/golang-lru v0.5.4 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/hashicorp/serf v0.9.5 // indirect
github.com/hashicorp/vault/api v1.1.1 // indirect
github.com/hashicorp/vault/sdk v0.2.1 // indirect
github.com/hashicorp/yamux v0.0.0-20210826001029-26ff87cf9493 // indirect
github.com/jehiah/go-strftime v0.0.0-20171201141054-1d33003b3869 // indirect
github.com/jmespath/go-jmespath v0.4.0 // 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.8 // indirect
github.com/mattn/go-isatty v0.0.13 // 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.4.1 // 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/pierrec/lz4 v2.6.1+incompatible // 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.0.0-20220517005047-85d78b3ac167 // indirect
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2 // indirect
golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f // indirect
golang.org/x/sys v0.0.0-20211019181941-9d821ace8654 // indirect
golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac // indirect
google.golang.org/api v0.56.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20210831024726-fe130286e0e2 // indirect
google.golang.org/grpc v1.40.0 // indirect
google.golang.org/protobuf v1.27.1 // indirect
gopkg.in/square/go-jose.v2 v2.6.0 // indirect
)
Loading

0 comments on commit e38812e

Please sign in to comment.