From e7cc681c67fdc66b7251bce90381072c8e957d61 Mon Sep 17 00:00:00 2001 From: Adrien Delorme Date: Tue, 23 Mar 2021 12:31:13 +0100 Subject: [PATCH] Add http_content func to serve variables from HTTP @ preseed (#10801) This imports hashicorp/packer-plugin-sdk#43 * code generate things * update docs * update guides * update examples We want to add a new guide. --- builder/vmware/iso/builder.go | 7 +------ builder/vmware/iso/config.hcl2spec.go | 2 ++ builder/vmware/vmx/builder.go | 7 +------ builder/vmware/vmx/config.hcl2spec.go | 2 ++ 4 files changed, 6 insertions(+), 12 deletions(-) diff --git a/builder/vmware/iso/builder.go b/builder/vmware/iso/builder.go index 9ef6f656..7b712356 100644 --- a/builder/vmware/iso/builder.go +++ b/builder/vmware/iso/builder.go @@ -117,12 +117,7 @@ func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) }, &vmwcommon.StepSuppressMessages{}, &vmwcommon.StepHTTPIPDiscover{}, - &commonsteps.StepHTTPServer{ - HTTPDir: b.config.HTTPDir, - HTTPPortMin: b.config.HTTPPortMin, - HTTPPortMax: b.config.HTTPPortMax, - HTTPAddress: b.config.HTTPAddress, - }, + commonsteps.HTTPServerFromHTTPConfig(&b.config.HTTPConfig), &vmwcommon.StepConfigureVNC{ Enabled: !b.config.DisableVNC && !b.config.VNCOverWebsocket, VNCBindAddress: b.config.VNCBindAddress, diff --git a/builder/vmware/iso/config.hcl2spec.go b/builder/vmware/iso/config.hcl2spec.go index 72415742..9ee645c8 100644 --- a/builder/vmware/iso/config.hcl2spec.go +++ b/builder/vmware/iso/config.hcl2spec.go @@ -19,6 +19,7 @@ type FlatConfig struct { PackerUserVars map[string]string `mapstructure:"packer_user_variables" cty:"packer_user_variables" hcl:"packer_user_variables"` PackerSensitiveVars []string `mapstructure:"packer_sensitive_variables" cty:"packer_sensitive_variables" hcl:"packer_sensitive_variables"` HTTPDir *string `mapstructure:"http_directory" cty:"http_directory" hcl:"http_directory"` + HTTPContent map[string]string `mapstructure:"http_content" cty:"http_content" hcl:"http_content"` HTTPPortMin *int `mapstructure:"http_port_min" cty:"http_port_min" hcl:"http_port_min"` HTTPPortMax *int `mapstructure:"http_port_max" cty:"http_port_max" hcl:"http_port_max"` HTTPAddress *string `mapstructure:"http_bind_address" cty:"http_bind_address" hcl:"http_bind_address"` @@ -167,6 +168,7 @@ func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec { "packer_user_variables": &hcldec.AttrSpec{Name: "packer_user_variables", Type: cty.Map(cty.String), Required: false}, "packer_sensitive_variables": &hcldec.AttrSpec{Name: "packer_sensitive_variables", Type: cty.List(cty.String), Required: false}, "http_directory": &hcldec.AttrSpec{Name: "http_directory", Type: cty.String, Required: false}, + "http_content": &hcldec.AttrSpec{Name: "http_content", Type: cty.Map(cty.String), Required: false}, "http_port_min": &hcldec.AttrSpec{Name: "http_port_min", Type: cty.Number, Required: false}, "http_port_max": &hcldec.AttrSpec{Name: "http_port_max", Type: cty.Number, Required: false}, "http_bind_address": &hcldec.AttrSpec{Name: "http_bind_address", Type: cty.String, Required: false}, diff --git a/builder/vmware/vmx/builder.go b/builder/vmware/vmx/builder.go index dbf8b1b5..b8ec9190 100644 --- a/builder/vmware/vmx/builder.go +++ b/builder/vmware/vmx/builder.go @@ -108,12 +108,7 @@ func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) }, &vmwcommon.StepSuppressMessages{}, &vmwcommon.StepHTTPIPDiscover{}, - &commonsteps.StepHTTPServer{ - HTTPDir: b.config.HTTPDir, - HTTPPortMin: b.config.HTTPPortMin, - HTTPPortMax: b.config.HTTPPortMax, - HTTPAddress: b.config.HTTPAddress, - }, + commonsteps.HTTPServerFromHTTPConfig(&b.config.HTTPConfig), &vmwcommon.StepUploadVMX{ RemoteType: b.config.RemoteType, }, diff --git a/builder/vmware/vmx/config.hcl2spec.go b/builder/vmware/vmx/config.hcl2spec.go index 0af743f1..f1876592 100644 --- a/builder/vmware/vmx/config.hcl2spec.go +++ b/builder/vmware/vmx/config.hcl2spec.go @@ -19,6 +19,7 @@ type FlatConfig struct { PackerUserVars map[string]string `mapstructure:"packer_user_variables" cty:"packer_user_variables" hcl:"packer_user_variables"` PackerSensitiveVars []string `mapstructure:"packer_sensitive_variables" cty:"packer_sensitive_variables" hcl:"packer_sensitive_variables"` HTTPDir *string `mapstructure:"http_directory" cty:"http_directory" hcl:"http_directory"` + HTTPContent map[string]string `mapstructure:"http_content" cty:"http_content" hcl:"http_content"` HTTPPortMin *int `mapstructure:"http_port_min" cty:"http_port_min" hcl:"http_port_min"` HTTPPortMax *int `mapstructure:"http_port_max" cty:"http_port_max" hcl:"http_port_max"` HTTPAddress *string `mapstructure:"http_bind_address" cty:"http_bind_address" hcl:"http_bind_address"` @@ -149,6 +150,7 @@ func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec { "packer_user_variables": &hcldec.AttrSpec{Name: "packer_user_variables", Type: cty.Map(cty.String), Required: false}, "packer_sensitive_variables": &hcldec.AttrSpec{Name: "packer_sensitive_variables", Type: cty.List(cty.String), Required: false}, "http_directory": &hcldec.AttrSpec{Name: "http_directory", Type: cty.String, Required: false}, + "http_content": &hcldec.AttrSpec{Name: "http_content", Type: cty.Map(cty.String), Required: false}, "http_port_min": &hcldec.AttrSpec{Name: "http_port_min", Type: cty.Number, Required: false}, "http_port_max": &hcldec.AttrSpec{Name: "http_port_max", Type: cty.Number, Required: false}, "http_bind_address": &hcldec.AttrSpec{Name: "http_bind_address", Type: cty.String, Required: false},