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:
parent
1b77b05ce2
commit
9dafa310f3
|
@ -19,7 +19,6 @@ type Config struct {
|
||||||
|
|
||||||
DiskSizeGb int64 `mapstructure:"disk_size"`
|
DiskSizeGb int64 `mapstructure:"disk_size"`
|
||||||
DiskType string `mapstructure:"disk_type"`
|
DiskType string `mapstructure:"disk_type"`
|
||||||
KeepOriginalImage bool `mapstructure:"keep_input_artifact"`
|
|
||||||
MachineType string `mapstructure:"machine_type"`
|
MachineType string `mapstructure:"machine_type"`
|
||||||
Network string `mapstructure:"network"`
|
Network string `mapstructure:"network"`
|
||||||
Paths []string `mapstructure:"paths"`
|
Paths []string `mapstructure:"paths"`
|
||||||
|
@ -80,7 +79,7 @@ func (p *PostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifact) (pac
|
||||||
err := fmt.Errorf(
|
err := fmt.Errorf(
|
||||||
"Unknown artifact type: %s\nCan only export from Google Compute Engine builder artifacts.",
|
"Unknown artifact type: %s\nCan only export from Google Compute Engine builder artifacts.",
|
||||||
artifact.BuilderId())
|
artifact.BuilderId())
|
||||||
return nil, p.config.KeepOriginalImage, false, err
|
return nil, false, false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
builderAccountFile := artifact.State("AccountFilePath").(string)
|
builderAccountFile := artifact.State("AccountFilePath").(string)
|
||||||
|
@ -98,13 +97,13 @@ func (p *PostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifact) (pac
|
||||||
if builderAccountFile != "" {
|
if builderAccountFile != "" {
|
||||||
err := googlecompute.ProcessAccountFile(&p.config.Account, builderAccountFile)
|
err := googlecompute.ProcessAccountFile(&p.config.Account, builderAccountFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, p.config.KeepOriginalImage, false, err
|
return nil, false, false, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if p.config.AccountFile != "" {
|
if p.config.AccountFile != "" {
|
||||||
err := googlecompute.ProcessAccountFile(&p.config.Account, p.config.AccountFile)
|
err := googlecompute.ProcessAccountFile(&p.config.Account, p.config.AccountFile)
|
||||||
if err != nil {
|
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)
|
driver, err := googlecompute.NewDriverGCE(ui, builderProjectId, &p.config.Account)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, p.config.KeepOriginalImage, false, err
|
return nil, false, false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set up the state.
|
// 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}
|
result := &Artifact{paths: p.config.Paths}
|
||||||
|
|
||||||
return result, p.config.KeepOriginalImage, false, nil
|
return result, false, false, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,6 @@ type Config struct {
|
||||||
ImageGuestOsFeatures []string `mapstructure:"image_guest_os_features"`
|
ImageGuestOsFeatures []string `mapstructure:"image_guest_os_features"`
|
||||||
ImageLabels map[string]string `mapstructure:"image_labels"`
|
ImageLabels map[string]string `mapstructure:"image_labels"`
|
||||||
ImageName string `mapstructure:"image_name"`
|
ImageName string `mapstructure:"image_name"`
|
||||||
KeepOriginalImage bool `mapstructure:"keep_input_artifact"`
|
|
||||||
SkipClean bool `mapstructure:"skip_clean"`
|
SkipClean bool `mapstructure:"skip_clean"`
|
||||||
|
|
||||||
Account googlecompute.AccountFile
|
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)
|
rawImageGcsPath, err := UploadToBucket(client, ui, artifact, p.config.Bucket, p.config.GCSObjectName)
|
||||||
if err != nil {
|
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)
|
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 {
|
if err != nil {
|
||||||
return nil, p.config.KeepOriginalImage, false, err
|
return nil, false, false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if !p.config.SkipClean {
|
if !p.config.SkipClean {
|
||||||
err = DeleteFromBucket(client, ui, p.config.Bucket, p.config.GCSObjectName)
|
err = DeleteFromBucket(client, ui, p.config.Bucket, p.config.GCSObjectName)
|
||||||
if err != nil {
|
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) {
|
func UploadToBucket(client *http.Client, ui packer.Ui, artifact packer.Artifact, bucket string, gcsObjectName string) (string, error) {
|
||||||
|
|
Loading…
Reference in New Issue