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

This commit is contained in:
Megan Marsh 2019-04-03 12:05:38 -07:00
parent 1b77b05ce2
commit 9dafa310f3
2 changed files with 16 additions and 18 deletions

View File

@ -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
}

View File

@ -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) {