Skip to content

Commit

Permalink
merge main (#1)
Browse files Browse the repository at this point in the history
* Update config.go (nutanix-cloud-native#63)

* fix cve (nutanix-cloud-native#64)

Co-authored-by: Christophe Jauffret <[email protected]>

* Bump aquasecurity/trivy-action from 0.7.1 to 0.8.0 (nutanix-cloud-native#66)

Bumps [aquasecurity/trivy-action](https://github.com/aquasecurity/trivy-action) from 0.7.1 to 0.8.0.
- [Release notes](https://github.com/aquasecurity/trivy-action/releases)
- [Commits](aquasecurity/trivy-action@0.7.1...0.8.0)

---
updated-dependencies:
- dependency-name: aquasecurity/trivy-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump github.com/hashicorp/hcl/v2 from 2.14.0 to 2.14.1 (nutanix-cloud-native#60)

Bumps [github.com/hashicorp/hcl/v2](https://github.com/hashicorp/hcl) from 2.14.0 to 2.14.1.
- [Release notes](https://github.com/hashicorp/hcl/releases)
- [Changelog](https://github.com/hashicorp/hcl/blob/main/CHANGELOG.md)
- [Commits](hashicorp/hcl@v2.14.0...v2.14.1)

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

Signed-off-by: dependabot[bot] <[email protected]>

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* adding force_deregister (nutanix-cloud-native#58)

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: lomeroe <[email protected]>
Co-authored-by: Christophe Jauffret <[email protected]>
Co-authored-by: Christophe Jauffret <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
  • Loading branch information
5 people authored Nov 7, 2022
1 parent 788d149 commit 370fdce
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 62 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
run: make build

- name: Trivy scan
uses: aquasecurity/trivy-action@0.7.1
uses: aquasecurity/trivy-action@0.8.0
with:
scan-type: "fs"
ignore-unfixed: true
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/trivy-scan.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
uses: actions/checkout@v3

- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@0.7.1
uses: aquasecurity/trivy-action@0.8.0
with:
scan-type: "fs"
format: "sarif"
Expand Down
6 changes: 4 additions & 2 deletions builder/nutanix/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,13 @@ const (

type Config struct {
common.PackerConfig `mapstructure:",squash"`
CommConfig communicator.Config `mapstructure:",squash"`
CommConfig communicator.Config `mapstructure:",squash"`
commonsteps.CDConfig `mapstructure:",squash"`
shutdowncommand.ShutdownConfig `mapstructure:",squash"`
ClusterConfig `mapstructure:",squash"`
VmConfig `mapstructure:",squash"`
ForceDeregister bool `mapstructure:"force_deregister" json:"force_deregister" required:"false"`
ForceDeregister bool `mapstructure:"force_deregister" json:"force_deregister" required:"false"`



ctx interpolate.Context
Expand Down Expand Up @@ -161,6 +162,7 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) {

errs = packersdk.MultiErrorAppend(errs, c.ShutdownConfig.Prepare(&c.ctx)...)
errs = packersdk.MultiErrorAppend(errs, c.CDConfig.Prepare(&c.ctx)...)
errs = packersdk.MultiErrorAppend(errs, c.CommConfig.Prepare(&c.ctx)...)

if errs != nil && len(errs.Errors) > 0 {
return warnings, errs
Expand Down
32 changes: 13 additions & 19 deletions builder/nutanix/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -739,34 +739,28 @@ func (d *NutanixDriver) SaveVMDisk(diskUUID string, imageName string, ForceDereg
}
if *ImageList.Metadata.TotalMatches==0 {
log.Println("Image with given Name not found, no need to deregister")
}
if *ImageList.Metadata.TotalMatches>1 {
log.Println("More than one mage with given Name found, will not deregister")
}
if *ImageList.Metadata.TotalMatches==1 {
log.Println("Exactly one mage with given Name found, will deregister")
} else if *ImageList.Metadata.TotalMatches>1 {
log.Println("More than one image with given Name found, will not deregister")
} else if *ImageList.Metadata.TotalMatches==1 {
log.Println("Exactly one image with given Name found, will deregister")

resp,err:= conn.V3.DeleteImage(*ImageList.Entities[0].Metadata.UUID)
if err != nil {
return nil, fmt.Errorf("error while DeleteImage, %s", err.Error())
}
taskUUID := resp.Status.ExecutionContext.TaskUUID.(string)
log.Printf("Wait until delete Image %s is finished, %s\n",*ImageList.Entities[0].Metadata.UUID,taskUUID)
// Wait for the Image to be deleted
for {
for i := 0; i < 1200; i++ {
resp, err := conn.V3.GetTask(taskUUID)
if err == nil {
if *resp.Status == "SUCCEEDED" {
log.Printf("existing image deleted")
break
} else {
log.Printf("Current status is: " + *resp.Status)
time.Sleep(5 * time.Second)
}
} else {
log.Printf("Error while Image Delete getting Task Status, %s", err.Error())
return nil, err
if err != nil || *resp.Status != "SUCCEEDED" {
<-time.After(1 * time.Second)
continue
}

if *resp.Status == "SUCCEEDED" {
break
}
return nil, fmt.Errorf("error while Image Delete getting Task Status, %s", err.Error())
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion example/source.nutanix.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ source "nutanix" "centos" {
subnet_name = var.nutanix_subnet
}

image_name ="centos-{{isotime `Jan-_2-15:04:05`}}"
image_name = "centos-packer-image"
force_deregister = true
user_data = "I2Nsb3VkLWNvbmZpZwp1c2VyczoKICAtIG5hbWU6IGNlbnRvcwogICAgc3VkbzogWydBTEw9KEFMTCkgTk9QQVNTV0Q6QUxMJ10KY2hwYXNzd2Q6CiAgbGlzdDogfAogICAgY2VudG9zOnBhY2tlcgogIGV4cGlyZTogRmFsc2UKc3NoX3B3YXV0aDogVHJ1ZQ=="

shutdown_command = "echo 'packer' | sudo -S shutdown -P now"
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
module github.com/nutanix-cloud-native/packer-plugin-nutanix

go 1.17
go 1.19

replace (
github.com/hashicorp/consul => github.com/hashicorp/consul v1.10.4
github.com/hashicorp/vault => github.com/hashicorp/vault v1.4.2
)

require (
github.com/hashicorp/hcl/v2 v2.14.0
github.com/hashicorp/hcl/v2 v2.14.1
github.com/hashicorp/packer-plugin-sdk v0.3.2
github.com/nutanix-cloud-native/prism-go-client v0.2.0
github.com/zclconf/go-cty v1.10.0
Expand Down Expand Up @@ -94,7 +94,7 @@ require (
golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f // indirect
golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10 // indirect
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/text v0.4.0 // 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
Expand Down
Loading

0 comments on commit 370fdce

Please sign in to comment.