diff --git a/builder/null/artifact_export.go b/builder/null/artifact_export.go index e8d5dd0a6..c98c71acb 100644 --- a/builder/null/artifact_export.go +++ b/builder/null/artifact_export.go @@ -8,6 +8,7 @@ import ( // dummy Artifact implementation - does nothing type NullArtifact struct { + SourceImageId string } func (*NullArtifact) BuilderId() string { @@ -33,7 +34,7 @@ func (a *NullArtifact) State(name string) interface{} { registryimage.WithID(a.Id()), registryimage.WithProvider("null"), registryimage.WithRegion("null"), - registryimage.WithSourceID("null"), + registryimage.WithSourceID(a.SourceImageId), ) return img case "generated_data": diff --git a/builder/null/builder.go b/builder/null/builder.go index 5e2a7d369..cc7352934 100644 --- a/builder/null/builder.go +++ b/builder/null/builder.go @@ -59,6 +59,8 @@ func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) } // No errors, must've worked - artifact := &NullArtifact{} + artifact := &NullArtifact{ + SourceImageId: b.config.SourceImageID, + } return artifact, nil } diff --git a/builder/null/config.go b/builder/null/config.go index 39bec200a..ee5bca688 100644 --- a/builder/null/config.go +++ b/builder/null/config.go @@ -16,6 +16,10 @@ type Config struct { common.PackerConfig `mapstructure:",squash"` CommConfig communicator.Config `mapstructure:",squash"` + + // Is used by the packer team to test HCP Packer ancestry. This value will be pushed to HCP Packer as the source + // image of this build. + SourceImageID string `mapstructure:"source_image_id"` } func (c *Config) Prepare(raws ...interface{}) ([]string, error) { diff --git a/builder/null/config.hcl2spec.go b/builder/null/config.hcl2spec.go index 8d710f1e2..b230421c9 100644 --- a/builder/null/config.hcl2spec.go +++ b/builder/null/config.hcl2spec.go @@ -67,6 +67,7 @@ type FlatConfig struct { WinRMUseSSL *bool `mapstructure:"winrm_use_ssl" cty:"winrm_use_ssl" hcl:"winrm_use_ssl"` WinRMInsecure *bool `mapstructure:"winrm_insecure" cty:"winrm_insecure" hcl:"winrm_insecure"` WinRMUseNTLM *bool `mapstructure:"winrm_use_ntlm" cty:"winrm_use_ntlm" hcl:"winrm_use_ntlm"` + SourceImageID *string `mapstructure:"source_image_id" cty:"source_image_id" hcl:"source_image_id"` } // FlatMapstructure returns a new FlatConfig. @@ -138,6 +139,7 @@ func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec { "winrm_use_ssl": &hcldec.AttrSpec{Name: "winrm_use_ssl", Type: cty.Bool, Required: false}, "winrm_insecure": &hcldec.AttrSpec{Name: "winrm_insecure", Type: cty.Bool, Required: false}, "winrm_use_ntlm": &hcldec.AttrSpec{Name: "winrm_use_ntlm", Type: cty.Bool, Required: false}, + "source_image_id": &hcldec.AttrSpec{Name: "source_image_id", Type: cty.String, Required: false}, } return s }