Compare commits

...

24 Commits
v0.7.0 ... main

Author SHA1 Message Date
Dom Delnano
756f4d7e1a
Merge pull request #141 from ddelnano/ddelnano/fix-gob-export-fields-issue
Fix issues related to packer-plugin-sdk#187
2024-06-14 07:29:08 -04:00
Dom Del Nano
4894eca5d3 Use packer-sdc fix to address go-cty issues
Signed-off-by: Dom Del Nano <ddelnano@gmail.com>
2024-06-14 04:27:51 -07:00
Dom Delnano
d111a01612
Merge pull request #139 from ddelnano/dependabot/go_modules/golang.org/x/crypto-0.24.0
Bump golang.org/x/crypto from 0.21.0 to 0.24.0
2024-06-11 16:40:31 -07:00
dependabot[bot]
fc6694679c
Bump golang.org/x/crypto from 0.21.0 to 0.24.0
Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.21.0 to 0.24.0.
- [Commits](https://github.com/golang/crypto/compare/v0.21.0...v0.24.0)

---
updated-dependencies:
- dependency-name: golang.org/x/crypto
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-06-11 07:05:56 +00:00
Dom Delnano
36658a7875
Merge pull request #126 from ddelnano/dependabot/go_modules/github.com/hashicorp/hcl/v2-2.20.1
Bump github.com/hashicorp/hcl/v2 from 2.12.0 to 2.20.1
2024-06-10 07:13:48 -07:00
dependabot[bot]
deba45ef3a
Bump github.com/hashicorp/hcl/v2 from 2.12.0 to 2.20.1
Bumps [github.com/hashicorp/hcl/v2](https://github.com/hashicorp/hcl) from 2.12.0 to 2.20.1.
- [Release notes](https://github.com/hashicorp/hcl/releases)
- [Changelog](https://github.com/hashicorp/hcl/blob/main/CHANGELOG.md)
- [Commits](https://github.com/hashicorp/hcl/compare/v2.12.0...v2.20.1)

---
updated-dependencies:
- dependency-name: github.com/hashicorp/hcl/v2
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-06-10 14:05:46 +00:00
Dom Delnano
1e9c3eb66a
Merge pull request #124 from ddelnano/dependabot/go_modules/google.golang.org/protobuf-1.33.0
Bump google.golang.org/protobuf from 1.30.0 to 1.33.0
2024-06-10 07:03:58 -07:00
Dom Delnano
7077d1e374
Merge pull request #125 from ddelnano/dependabot/go_modules/github.com/zclconf/go-cty-1.14.4
Bump github.com/zclconf/go-cty from 1.10.0 to 1.14.4
2024-06-10 07:03:42 -07:00
Dom Delnano
54738803d5
Merge pull request #129 from melck/feat-vnc-debug
[FEATURE] Disable exclusive VNC connection when packer in debug mode
2024-06-10 07:02:36 -07:00
Dom Delnano
0ff8fa1e77
Merge pull request #132 from ddelnano/dependabot/go_modules/golang.org/x/net-0.23.0
Bump golang.org/x/net from 0.21.0 to 0.23.0
2024-06-04 23:28:15 -07:00
Dom Del Nano
4b07607b11 Validate .goreleaser.yml file with 'goreleaser check'
Signed-off-by: Dom Del Nano <ddelnano@gmail.com>
2024-06-04 23:20:13 -07:00
Dom Del Nano
bf1383d1e8 Use packer-plugin-skaffolding goreleaser action version
Signed-off-by: Dom Del Nano <ddelnano@gmail.com>
2024-06-04 23:15:17 -07:00
Dom Del Nano
13c2a1d78a Replace deprecated --rm-dist goreleaser flag with --clean 2024-06-04 23:04:25 -07:00
Dom Delnano
2a36fae810
Merge pull request #137 from ddelnano/ddelnano/ensure-version-is-set-via-linker-on-releases
Fix plugin installation on 1.11.0 and later by fixing release version detection
2024-06-04 22:57:01 -07:00
Dom Del Nano
c411df4b02 Use correct version package from the main package
Signed-off-by: Dom Del Nano <ddelnano@gmail.com>
2024-06-04 22:54:42 -07:00
Dom Del Nano
cc03e4a10c Ensure version package exists and matches existing linker variable on release
Signed-off-by: Dom Del Nano <ddelnano@gmail.com>
2024-06-04 22:46:35 -07:00
dependabot[bot]
7147cb4592
Bump golang.org/x/net from 0.21.0 to 0.23.0
Bumps [golang.org/x/net](https://github.com/golang/net) from 0.21.0 to 0.23.0.
- [Commits](https://github.com/golang/net/compare/v0.21.0...v0.23.0)

---
updated-dependencies:
- dependency-name: golang.org/x/net
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-19 13:13:36 +00:00
Melchior NOGUES
1b20fbac99
Disable exclusive VNC connection when packer in debug mode 2024-04-10 14:00:36 +02:00
dependabot[bot]
6c9ee9dc94
Bump github.com/zclconf/go-cty from 1.10.0 to 1.14.4
Bumps [github.com/zclconf/go-cty](https://github.com/zclconf/go-cty) from 1.10.0 to 1.14.4.
- [Release notes](https://github.com/zclconf/go-cty/releases)
- [Changelog](https://github.com/zclconf/go-cty/blob/main/CHANGELOG.md)
- [Commits](https://github.com/zclconf/go-cty/compare/v1.10.0...v1.14.4)

---
updated-dependencies:
- dependency-name: github.com/zclconf/go-cty
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-03-21 07:23:16 +00:00
dependabot[bot]
b38a3b67bc
Bump google.golang.org/protobuf from 1.30.0 to 1.33.0
Bumps google.golang.org/protobuf from 1.30.0 to 1.33.0.

---
updated-dependencies:
- dependency-name: google.golang.org/protobuf
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-03-13 22:51:32 +00:00
Dom Delnano
a776a46e1e
Merge pull request #122 from ddelnano/dependabot/go_modules/golang.org/x/crypto-0.21.0
Bump golang.org/x/crypto from 0.19.0 to 0.21.0
2024-03-05 21:48:52 -08:00
dependabot[bot]
d11786a294
Bump golang.org/x/crypto from 0.19.0 to 0.21.0
Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.19.0 to 0.21.0.
- [Commits](https://github.com/golang/crypto/compare/v0.19.0...v0.21.0)

---
updated-dependencies:
- dependency-name: golang.org/x/crypto
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-03-06 05:46:40 +00:00
Dom Delnano
7a9e710071
Merge pull request #123 from ddelnano/upgrade-go-1-20
Upgrade go to 1.20 to reflect latest packer-plugins-sdk go version an…
2024-03-05 21:44:08 -08:00
Dom Del Nano
88e56ca729 Upgrade go to 1.20 to reflect latest packer-plugins-sdk go version and unblock gomod upgrades
Signed-off-by: Dom Del Nano <ddelnano@gmail.com>
2024-03-05 21:35:34 -08:00
10 changed files with 82 additions and 1316 deletions

View File

@ -19,6 +19,6 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.17
go-version: "1.20"
- name: Run go tests
run: go test -race -count 1 ./... -timeout=3m

View File

@ -25,7 +25,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.17
go-version: "1.20"
- name: Describe plugin
id: plugin_describe
run: echo "::set-output name=api_version::$(go run . describe | jq -r '.api_version')"
@ -36,10 +36,10 @@ jobs:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
uses: goreleaser/goreleaser-action@f82d6c1c344bcacabba2c841718984797f664a6b # v4.2.0
with:
version: latest
args: release --rm-dist
args: release --clean
env:
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

1
.go-version Normal file
View File

@ -0,0 +1 @@
1.20.11

View File

@ -1,3 +1,4 @@
version: 2
# This is an example goreleaser.yaml file with some sane defaults.
# Make sure to check the documentation at http://goreleaser.com
env:
@ -70,4 +71,4 @@ release:
draft: false
changelog:
skip: true
disable: true

View File

@ -45,7 +45,7 @@ If you are using an older version of packer or are still using json templates yo
### Dependencies
* Packer >= v1.7.1 (https://packer.io)
* XenServer / Citrix Hypervisor > 7.6
* Golang 1.17
* Golang 1.20
## Compile the plugin

View File

@ -32,8 +32,8 @@ type StepTypeBootCommand struct {
Ctx interpolate.Context
}
func (self *StepTypeBootCommand) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction {
config := state.Get("commonconfig").(CommonConfig)
func (step *StepTypeBootCommand) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction {
config := state.Get("config").(Config)
ui := state.Get("ui").(packer.Ui)
c := state.Get("client").(*Connection)
httpPort := state.Get("http_port").(int)
@ -74,7 +74,8 @@ func (self *StepTypeBootCommand) Run(ctx context.Context, state multistep.StateB
}
locationPieces := strings.SplitAfter(location, "/")
consoleHost := strings.TrimSuffix(locationPieces[2], "/")
ui.Say(fmt.Sprintf("Connecting to the VM console VNC over xapi via %s", consoleHost))
ui.Say("Connecting to VNC over XAPI...")
log.Printf("Connecting to host: %s", consoleHost)
conn, err := net.Dial("tcp", fmt.Sprintf("%s:443", consoleHost))
if err != nil {
@ -95,7 +96,7 @@ func (self *StepTypeBootCommand) Run(ctx context.Context, state multistep.StateB
httpReq := fmt.Sprintf("CONNECT %s HTTP/1.0\r\nHost: %s\r\nCookie: session_id=%s\r\n\r\n", consoleLocation, consoleHost, c.session)
fmt.Printf("Sending the follow http req: %v", httpReq)
ui.Say(fmt.Sprintf("Making HTTP request to initiate VNC connection: %s", httpReq))
ui.Message(fmt.Sprintf("Making HTTP request to initiate VNC connection: %s", httpReq))
_, err = io.WriteString(tlsConn, httpReq)
if err != nil {
@ -114,9 +115,9 @@ func (self *StepTypeBootCommand) Run(ctx context.Context, state multistep.StateB
return multistep.ActionHalt
}
ui.Say(fmt.Sprintf("Received response: %s", string(buffer)))
ui.Message(fmt.Sprintf("Received response: %s", string(buffer)))
vncClient, err := vnc.Client(tlsConn, &vnc.ClientConfig{Exclusive: true})
vncClient, err := vnc.Client(tlsConn, &vnc.ClientConfig{Exclusive: !config.PackerDebug})
if err != nil {
err := fmt.Errorf("Error establishing VNC session: %s", err)
@ -142,7 +143,7 @@ func (self *StepTypeBootCommand) Run(ctx context.Context, state multistep.StateB
localIp := strings.Split(envVar, " ")[0]
ui.Message(fmt.Sprintf("Found local IP: %s", localIp))
self.Ctx.Data = &bootCommandTemplateData{
step.Ctx.Data = &bootCommandTemplateData{
config.VMName,
localIp,
uint(httpPort),
@ -151,7 +152,7 @@ func (self *StepTypeBootCommand) Run(ctx context.Context, state multistep.StateB
ui.Say("Typing boot commands over VNC...")
for _, command := range config.BootCommand {
command, err := interpolate.Render(command, &self.Ctx)
command, err := interpolate.Render(command, &step.Ctx)
if err != nil {
err := fmt.Errorf("Error preparing boot command: %s", err)
state.Put("error", err)
@ -167,12 +168,10 @@ func (self *StepTypeBootCommand) Run(ctx context.Context, state multistep.StateB
vncSendString(vncClient, command)
}
ui.Say("Finished typing.")
return multistep.ActionContinue
}
func (self *StepTypeBootCommand) Cleanup(multistep.StateBag) {}
func (step *StepTypeBootCommand) Cleanup(multistep.StateBag) {}
// Taken from qemu's builder plugin - not an exported function.
func vncSendString(c *vnc.ClientConn, original string) {

27
go.mod
View File

@ -1,15 +1,15 @@
module github.com/xenserver/packer-builder-xenserver
go 1.17
go 1.20
require (
github.com/amfranz/go-xmlrpc-client v0.0.0-20190612172737-76858463955d
github.com/hashicorp/hcl/v2 v2.12.0
github.com/hashicorp/hcl/v2 v2.20.1
github.com/hashicorp/packer-plugin-sdk v0.3.0
github.com/mitchellh/go-vnc v0.0.0-20150629162542-723ed9867aed
github.com/terra-farm/go-xen-api-client v0.0.2
github.com/zclconf/go-cty v1.10.0
golang.org/x/crypto v0.19.0
github.com/zclconf/go-cty v1.14.4
golang.org/x/crypto v0.24.0
)
require (
@ -22,6 +22,7 @@ require (
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.3.9 // indirect
github.com/aws/aws-sdk-go v1.40.34 // indirect
github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect
@ -33,7 +34,7 @@ require (
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.2.3 // indirect
github.com/googleapis/gax-go/v2 v2.7.1 // indirect
@ -80,20 +81,24 @@ require (
github.com/ugorji/go/codec v1.2.6 // indirect
github.com/ulikunitz/xz v0.5.10 // indirect
go.opencensus.io v0.24.0 // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/mod v0.17.0 // indirect
golang.org/x/net v0.25.0 // indirect
golang.org/x/oauth2 v0.7.0 // indirect
golang.org/x/sync v0.3.0 // indirect
golang.org/x/sys v0.17.0 // indirect
golang.org/x/term v0.17.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/sys v0.21.0 // indirect
golang.org/x/term v0.21.0 // indirect
golang.org/x/text v0.16.0 // indirect
golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac // indirect
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
google.golang.org/api v0.114.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect
google.golang.org/grpc v1.56.3 // indirect
google.golang.org/protobuf v1.30.0 // indirect
google.golang.org/protobuf v1.33.0 // indirect
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect
gopkg.in/square/go-jose.v2 v2.6.0 // indirect
gopkg.in/yaml.v2 v2.4.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

1299
go.sum

File diff suppressed because it is too large Load Diff

18
main.go
View File

@ -6,30 +6,16 @@ import (
"github.com/xenserver/packer-builder-xenserver/builder/xenserver/iso"
"github.com/xenserver/packer-builder-xenserver/builder/xenserver/xva"
"github.com/xenserver/packer-builder-xenserver/version"
"github.com/hashicorp/packer-plugin-sdk/plugin"
"github.com/hashicorp/packer-plugin-sdk/version"
)
var (
// Version is the main version number that is being run at the moment.
Version = "v0.6.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 = ""
// PluginVersion is used by the plugin set to allow Packer to recognize
// what version this plugin is.
PluginVersion = version.InitializePluginVersion(Version, VersionPrerelease)
)
func main() {
pps := plugin.NewSet()
pps.RegisterBuilder("iso", new(iso.Builder))
pps.RegisterBuilder("xva", new(xva.Builder))
pps.SetVersion(PluginVersion)
pps.SetVersion(version.PluginVersion)
err := pps.Run()
if err != nil {
fmt.Fprintln(os.Stderr, err.Error())

19
version/version.go Normal file
View File

@ -0,0 +1,19 @@
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 = "v0.6.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 = "dev"
// PluginVersion is used by the plugin set to allow Packer to recognize
// what version this plugin is.
PluginVersion = version.InitializePluginVersion(Version, VersionPrerelease)
)