googlecompute-export: use application default credential as same as googlecompute builder
This commit is contained in:
parent
6be3860412
commit
5dc6b18365
|
@ -2,7 +2,6 @@ package googlecomputeexport
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/mitchellh/multistep"
|
"github.com/mitchellh/multistep"
|
||||||
|
@ -83,13 +82,12 @@ func (p *PostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifact) (pac
|
||||||
exporterConfig.CalcTimeout()
|
exporterConfig.CalcTimeout()
|
||||||
|
|
||||||
// Set up credentials and GCE driver.
|
// Set up credentials and GCE driver.
|
||||||
b, err := ioutil.ReadFile(accountKeyFilePath)
|
if accountKeyFilePath != "" {
|
||||||
if err != nil {
|
err := googlecompute.ProcessAccountFile(&exporterConfig.Account, accountKeyFilePath)
|
||||||
err = fmt.Errorf("Error fetching account credentials: %s", err)
|
if err != nil {
|
||||||
return nil, p.config.KeepOriginalImage, err
|
return nil, p.config.KeepOriginalImage, err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
accountKeyContents := string(b)
|
|
||||||
googlecompute.ProcessAccountFile(&exporterConfig.Account, accountKeyContents)
|
|
||||||
driver, err := googlecompute.NewDriverGCE(ui, projectId, &exporterConfig.Account)
|
driver, err := googlecompute.NewDriverGCE(ui, projectId, &exporterConfig.Account)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, p.config.KeepOriginalImage, err
|
return nil, p.config.KeepOriginalImage, err
|
||||||
|
|
Loading…
Reference in New Issue