From 9dafa310f3c0199049e9a16d456f9064e9e52f5a Mon Sep 17 00:00:00 2001 From: Megan Marsh Date: Wed, 3 Apr 2019 12:05:38 -0700 Subject: [PATCH] remove redundant keep_input_artifact code from googlecompute-export and googlecompute-import pps. The behavior coded here was already enforced by the core postprocessor code in packer/build.go --- .../googlecompute-export/post-processor.go | 25 +++++++++---------- .../googlecompute-import/post-processor.go | 9 +++---- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/post-processor/googlecompute-export/post-processor.go b/post-processor/googlecompute-export/post-processor.go index 0d11b0c85..1ce45ea8e 100644 --- a/post-processor/googlecompute-export/post-processor.go +++ b/post-processor/googlecompute-export/post-processor.go @@ -17,14 +17,13 @@ type Config struct { AccountFile string `mapstructure:"account_file"` - DiskSizeGb int64 `mapstructure:"disk_size"` - DiskType string `mapstructure:"disk_type"` - KeepOriginalImage bool `mapstructure:"keep_input_artifact"` - MachineType string `mapstructure:"machine_type"` - Network string `mapstructure:"network"` - Paths []string `mapstructure:"paths"` - Subnetwork string `mapstructure:"subnetwork"` - Zone string `mapstructure:"zone"` + DiskSizeGb int64 `mapstructure:"disk_size"` + DiskType string `mapstructure:"disk_type"` + MachineType string `mapstructure:"machine_type"` + Network string `mapstructure:"network"` + Paths []string `mapstructure:"paths"` + Subnetwork string `mapstructure:"subnetwork"` + Zone string `mapstructure:"zone"` Account googlecompute.AccountFile ctx interpolate.Context @@ -80,7 +79,7 @@ func (p *PostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifact) (pac err := fmt.Errorf( "Unknown artifact type: %s\nCan only export from Google Compute Engine builder artifacts.", artifact.BuilderId()) - return nil, p.config.KeepOriginalImage, false, err + return nil, false, false, err } builderAccountFile := artifact.State("AccountFilePath").(string) @@ -98,13 +97,13 @@ func (p *PostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifact) (pac if builderAccountFile != "" { err := googlecompute.ProcessAccountFile(&p.config.Account, builderAccountFile) if err != nil { - return nil, p.config.KeepOriginalImage, false, err + return nil, false, false, err } } if p.config.AccountFile != "" { err := googlecompute.ProcessAccountFile(&p.config.Account, p.config.AccountFile) if err != nil { - return nil, p.config.KeepOriginalImage, false, err + return nil, false, false, err } } @@ -141,7 +140,7 @@ func (p *PostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifact) (pac driver, err := googlecompute.NewDriverGCE(ui, builderProjectId, &p.config.Account) if err != nil { - return nil, p.config.KeepOriginalImage, false, err + return nil, false, false, err } // Set up the state. @@ -169,5 +168,5 @@ func (p *PostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifact) (pac result := &Artifact{paths: p.config.Paths} - return result, p.config.KeepOriginalImage, false, nil + return result, false, false, nil } diff --git a/post-processor/googlecompute-import/post-processor.go b/post-processor/googlecompute-import/post-processor.go index 9ff930f1c..a211af39b 100644 --- a/post-processor/googlecompute-import/post-processor.go +++ b/post-processor/googlecompute-import/post-processor.go @@ -31,7 +31,6 @@ type Config struct { ImageGuestOsFeatures []string `mapstructure:"image_guest_os_features"` ImageLabels map[string]string `mapstructure:"image_labels"` ImageName string `mapstructure:"image_name"` - KeepOriginalImage bool `mapstructure:"keep_input_artifact"` SkipClean bool `mapstructure:"skip_clean"` Account googlecompute.AccountFile @@ -114,22 +113,22 @@ func (p *PostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifact) (pac rawImageGcsPath, err := UploadToBucket(client, ui, artifact, p.config.Bucket, p.config.GCSObjectName) if err != nil { - return nil, p.config.KeepOriginalImage, false, err + return nil, false, false, err } gceImageArtifact, err := CreateGceImage(client, ui, p.config.ProjectId, rawImageGcsPath, p.config.ImageName, p.config.ImageDescription, p.config.ImageFamily, p.config.ImageLabels, p.config.ImageGuestOsFeatures) if err != nil { - return nil, p.config.KeepOriginalImage, false, err + return nil, false, false, err } if !p.config.SkipClean { err = DeleteFromBucket(client, ui, p.config.Bucket, p.config.GCSObjectName) if err != nil { - return nil, p.config.KeepOriginalImage, false, err + return nil, false, false, err } } - return gceImageArtifact, p.config.KeepOriginalImage, false, nil + return gceImageArtifact, false, false, nil } func UploadToBucket(client *http.Client, ui packer.Ui, artifact packer.Artifact, bucket string, gcsObjectName string) (string, error) {