From 11f85adb9c3188a2f63c5060661b47601bc0f523 Mon Sep 17 00:00:00 2001 From: mike9107 <9107mgarcia@gmail.com> Date: Thu, 29 Feb 2024 21:31:17 -0500 Subject: [PATCH] add omit_external_ip field to export post-processor --- .../components/post-processor/googlecompute-export/README.md | 2 ++ .../googlecompute-export/Config-not-required.mdx | 2 ++ post-processor/googlecompute-export/post-processor.go | 3 +++ post-processor/googlecompute-export/post-processor.hcl2spec.go | 2 ++ 4 files changed, 9 insertions(+) diff --git a/.web-docs/components/post-processor/googlecompute-export/README.md b/.web-docs/components/post-processor/googlecompute-export/README.md index 1bfbef7e..a698de39 100644 --- a/.web-docs/components/post-processor/googlecompute-export/README.md +++ b/.web-docs/components/post-processor/googlecompute-export/README.md @@ -74,6 +74,8 @@ the [authentication](/packer/integrations/hashicorp/googlecompute#authentication - `service_account_email` (string) - Service Account Email +- `omit_external_ip` (bool) - If true, the exporter instance will not have an external IP. + diff --git a/docs-partials/post-processor/googlecompute-export/Config-not-required.mdx b/docs-partials/post-processor/googlecompute-export/Config-not-required.mdx index 8350a990..1f94bdd0 100644 --- a/docs-partials/post-processor/googlecompute-export/Config-not-required.mdx +++ b/docs-partials/post-processor/googlecompute-export/Config-not-required.mdx @@ -35,4 +35,6 @@ - `service_account_email` (string) - Service Account Email +- `omit_external_ip` (bool) - If true, the exporter instance will not have an external IP. + diff --git a/post-processor/googlecompute-export/post-processor.go b/post-processor/googlecompute-export/post-processor.go index 0f253e87..82b860ad 100644 --- a/post-processor/googlecompute-export/post-processor.go +++ b/post-processor/googlecompute-export/post-processor.go @@ -68,6 +68,8 @@ type Config struct { Zone string `mapstructure:"zone"` IAP bool `mapstructure-to-hcl2:",skip"` ServiceAccountEmail string `mapstructure:"service_account_email"` + //If true, the exporter instance will not have an external IP. + OmitExternalIP bool `mapstructure:"omit_external_ip" required:"false"` ctx interpolate.Context } @@ -183,6 +185,7 @@ func (p *PostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, artifa SourceImageProjectId: []string{"compute-image-tools"}, Subnetwork: p.config.Subnetwork, Zone: p.config.Zone, + OmitExternalIP: p.config.OmitExternalIP, Scopes: []string{ "https://www.googleapis.com/auth/compute", "https://www.googleapis.com/auth/devstorage.full_control", diff --git a/post-processor/googlecompute-export/post-processor.hcl2spec.go b/post-processor/googlecompute-export/post-processor.hcl2spec.go index edadf88c..6b3ca170 100644 --- a/post-processor/googlecompute-export/post-processor.hcl2spec.go +++ b/post-processor/googlecompute-export/post-processor.hcl2spec.go @@ -33,6 +33,7 @@ type FlatConfig struct { Subnetwork *string `mapstructure:"subnetwork" cty:"subnetwork" hcl:"subnetwork"` Zone *string `mapstructure:"zone" cty:"zone" hcl:"zone"` ServiceAccountEmail *string `mapstructure:"service_account_email" cty:"service_account_email" hcl:"service_account_email"` + OmitExternalIP *bool `mapstructure:"omit_external_ip" required:"false" cty:"omit_external_ip" hcl:"omit_external_ip"` } // FlatMapstructure returns a new FlatConfig. @@ -70,6 +71,7 @@ func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec { "subnetwork": &hcldec.AttrSpec{Name: "subnetwork", Type: cty.String, Required: false}, "zone": &hcldec.AttrSpec{Name: "zone", Type: cty.String, Required: false}, "service_account_email": &hcldec.AttrSpec{Name: "service_account_email", Type: cty.String, Required: false}, + "omit_external_ip": &hcldec.AttrSpec{Name: "omit_external_ip", Type: cty.Bool, Required: false}, } return s }