Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[FEAT] Allow post-processor configuration to define a source image #252

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion post-processor/googlecompute-export/post-processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ type Config struct {
DiskType string `mapstructure:"disk_type"`
//The export instance machine type. Defaults to `"n1-highcpu-4"`.
MachineType string `mapstructure:"machine_type"`
// The export instance OS type. Defaults to `"debian-12-worker"`.Config
SourceImageFamily string `mapstructure:"source_image_family"`
//The Google Compute network id or URL to use for the export instance.
//Defaults to `"default"`. If the value is not a URL, it
//will be interpolated to `projects/((builder_project_id))/global/networks/((network))`.
Expand Down Expand Up @@ -115,6 +117,10 @@ func (p *PostProcessor) Configure(raws ...interface{}) error {
p.config.Network = "default"
}

if p.config.SourceImageFamily == "" {
p.config.SourceImageFamily = "debian-12-worker"
}

warns, err := p.config.Authentication.Prepare()
if err != nil {
errs = packersdk.MultiErrorAppend(errs, err)
Expand Down Expand Up @@ -181,7 +187,7 @@ func (p *PostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, artifa
Network: p.config.Network,
NetworkProjectId: builderProjectId,
StateTimeout: 5 * time.Minute,
SourceImageFamily: "debian-9-worker",
SourceImageFamily: p.config.SourceImageFamily,
SourceImageProjectId: []string{"compute-image-tools"},
Subnetwork: p.config.Subnetwork,
Zone: p.config.Zone,
Expand Down