diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index 181322d..c4640bb 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -53,7 +53,7 @@ jobs: run: make build - name: Trivy scan - uses: aquasecurity/trivy-action@0.6.2 + uses: aquasecurity/trivy-action@0.7.1 with: scan-type: "fs" ignore-unfixed: true diff --git a/.github/workflows/synopsys-schedule.yaml b/.github/workflows/synopsys-schedule.yaml new file mode 100644 index 0000000..d44e0d7 --- /dev/null +++ b/.github/workflows/synopsys-schedule.yaml @@ -0,0 +1,29 @@ +name: Black Duck Intelligent Policy Check +on: + schedule: + - cron: "0 0 * * *" + +jobs: + security: + if: github.repository == 'nutanix-cloud-native/packer-plugin-nutanix' + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup Go + uses: actions/setup-go@v3 + with: + go-version: "^1.17" + + - name: Build Project + run: make build + + - name: Run Synopsys Detect + uses: synopsys-sig/detect-action@v0.3.3 + with: + scan-mode: INTELLIGENT + github-token: ${{ secrets.GITHUB_TOKEN }} + detect-version: 7.9.0 + blackduck-url: ${{ secrets.BLACKDUCK_URL }} + blackduck-api-token: ${{ secrets.BLACKDUCK_API_TOKEN }} diff --git a/.github/workflows/synopsys.yaml b/.github/workflows/synopsys.yaml index 3a61f91..33738bb 100644 --- a/.github/workflows/synopsys.yaml +++ b/.github/workflows/synopsys.yaml @@ -3,8 +3,6 @@ on: pull_request: branches: - main - schedule: - - cron: '0 0 * * *' push: jobs: @@ -18,13 +16,13 @@ jobs: - name: Setup Go uses: actions/setup-go@v3 with: - go-version: '^1.17' + go-version: "^1.17" - - name: Build Project + - name: Build Project run: make build - + - name: Run Synopsys Detect - uses: synopsys-sig/detect-action@v0.3.2 + uses: synopsys-sig/detect-action@v0.3.3 with: github-token: ${{ secrets.GITHUB_TOKEN }} detect-version: 7.9.0 diff --git a/.github/workflows/trivy-scan.yaml b/.github/workflows/trivy-scan.yaml index 11fc6ac..5847a3f 100644 --- a/.github/workflows/trivy-scan.yaml +++ b/.github/workflows/trivy-scan.yaml @@ -20,7 +20,7 @@ jobs: uses: actions/checkout@v3 - name: Run Trivy vulnerability scanner - uses: aquasecurity/trivy-action@0.6.2 + uses: aquasecurity/trivy-action@0.7.1 with: scan-type: "fs" format: "sarif" diff --git a/builder/nutanix/config.go b/builder/nutanix/config.go index 1b16ed7..576dd65 100644 --- a/builder/nutanix/config.go +++ b/builder/nutanix/config.go @@ -29,12 +29,12 @@ 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 diff --git a/builder/nutanix/driver.go b/builder/nutanix/driver.go index f2e4cb5..a747c1a 100644 --- a/builder/nutanix/driver.go +++ b/builder/nutanix/driver.go @@ -665,12 +665,10 @@ 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()) diff --git a/example/source.nutanix.pkr.hcl b/example/source.nutanix.pkr.hcl index 96cfb51..319c734 100644 --- a/example/source.nutanix.pkr.hcl +++ b/example/source.nutanix.pkr.hcl @@ -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" diff --git a/go.mod b/go.mod index b3c6249..015a32d 100644 --- a/go.mod +++ b/go.mod @@ -8,8 +8,8 @@ replace ( ) require ( - github.com/hashicorp/hcl/v2 v2.13.0 - github.com/hashicorp/packer-plugin-sdk v0.3.1 + github.com/hashicorp/hcl/v2 v2.14.0 + 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 ) @@ -90,7 +90,7 @@ require ( 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-20220802222814-0bcc04d9c69b // indirect + golang.org/x/net v0.0.0-20220909164309-bea034e7d591 // indirect 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 diff --git a/go.sum b/go.sum index ba86bba..5a01bfe 100644 --- a/go.sum +++ b/go.sum @@ -380,16 +380,17 @@ github.com/hashicorp/hc-install v0.3.2/go.mod h1:xMG6Tr8Fw1WFjlxH0A9v61cW15pFwgE 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.12.0/go.mod h1:FwWsfWEjyV/CMj8s/gqAuiviY72rJ1/oayI9WftqcKg= -github.com/hashicorp/hcl/v2 v2.13.0 h1:0Apadu1w6M11dyGFxWnmhhcMjkbAiKCv7G1r/2QgCNc= github.com/hashicorp/hcl/v2 v2.13.0/go.mod h1:e4z5nxYlWNPdDSNYX+ph14EvWYMFm3eP0zIUqPc2jr0= +github.com/hashicorp/hcl/v2 v2.14.0 h1:jX6+Q38Ly9zaAJlAjnFVyeNSNCKKW8D0wvyg7vij5Wc= +github.com/hashicorp/hcl/v2 v2.14.0/go.mod h1:e4z5nxYlWNPdDSNYX+ph14EvWYMFm3eP0zIUqPc2jr0= github.com/hashicorp/logutils v1.0.0 h1:dLEQVugN8vlakKOUE3ihGLTZJRB4j+M2cdTm/ORI65Y= github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= github.com/hashicorp/mdns v1.0.1/go.mod h1:4gW7WsVCke5TE7EPeYliwHlRUyBtfCwuFwuMg2DmyNY= github.com/hashicorp/memberlist v0.2.2/go.mod h1:MS2lj3INKhZjWNqd3N0m3J+Jxf3DAOnAH9VT3Sh9MUE= github.com/hashicorp/memberlist v0.2.4 h1:OOhYzSvFnkFQXm1ysE8RjXTHsqSRDyP4emusC9K7DYg= github.com/hashicorp/memberlist v0.2.4/go.mod h1:MS2lj3INKhZjWNqd3N0m3J+Jxf3DAOnAH9VT3Sh9MUE= -github.com/hashicorp/packer-plugin-sdk v0.3.1 h1:Gr/mnihsdUcPfGiruFL93BQkiFh3EFPwyxxTWkwvRsQ= -github.com/hashicorp/packer-plugin-sdk v0.3.1/go.mod h1:+GzydiXdn0CkueigqXBsX4Poz5gfmFXZ/DkxKt4fmt4= +github.com/hashicorp/packer-plugin-sdk v0.3.2 h1:4Kqq7B8CRDMbfZmkloyz11t1hfqazJuBbW8ZFo4QlN4= +github.com/hashicorp/packer-plugin-sdk v0.3.2/go.mod h1:XZRvL9kRqJJtB6rf9Lu2zWLJbf2/4ImWXDjp9O9UQGE= github.com/hashicorp/serf v0.9.5 h1:EBWvyu9tcRszt3Bxp3KNssBMP1KuHWyO51lz9+786iM= github.com/hashicorp/serf v0.9.5/go.mod h1:UWDWwZeL5cuWDJdl0C6wrvrUwEqtQ4ZKBKKENpqIUyk= github.com/hashicorp/terraform-exec v0.16.1/go.mod h1:aj0lVshy8l+MHhFNoijNHtqTJQI3Xlowv5EOsEaGO7M= @@ -745,8 +746,8 @@ golang.org/x/net v0.0.0-20210503060351-7fd8e65b6420/go.mod h1:9nx3DQGgdP8bBQD5qx golang.org/x/net v0.0.0-20210614182718-04defd469f4e/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20220802222814-0bcc04d9c69b h1:3ogNYyK4oIQdIKzTu68hQrr4iuVxF3AxKl9Aj/eDrw0= -golang.org/x/net v0.0.0-20220802222814-0bcc04d9c69b/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= +golang.org/x/net v0.0.0-20220909164309-bea034e7d591 h1:D0B/7al0LLrVC8aWF4+oxpv/m8bc7ViFfVS8/gXGdqI= +golang.org/x/net v0.0.0-20220909164309-bea034e7d591/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=