From a91b8f68535b72cdf59426158dfa07e9236f196c Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 13 Dec 2013 19:32:01 -0800 Subject: [PATCH] builder/googlecompute: only load secrets/private key if given --- builder/googlecompute/config.go | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/builder/googlecompute/config.go b/builder/googlecompute/config.go index 29d69144d..f769980db 100644 --- a/builder/googlecompute/config.go +++ b/builder/googlecompute/config.go @@ -163,19 +163,23 @@ func NewConfig(raws ...interface{}) (*Config, []string, error) { } c.stateTimeout = stateTimeout - // Load the client secrets file. - cs, err := loadClientSecrets(c.ClientSecretsFile) - if err != nil { - errs = packer.MultiErrorAppend( - errs, fmt.Errorf("Failed parsing client secrets file: %s", err)) + if c.ClientSecretsFile != "" { + // Load the client secrets file. + cs, err := loadClientSecrets(c.ClientSecretsFile) + if err != nil { + errs = packer.MultiErrorAppend( + errs, fmt.Errorf("Failed parsing client secrets file: %s", err)) + } + c.clientSecrets = cs } - c.clientSecrets = cs - // Load the private key. - c.privateKeyBytes, err = processPrivateKeyFile(c.PrivateKeyFile, c.Passphrase) - if err != nil { - errs = packer.MultiErrorAppend( - errs, fmt.Errorf("Failed loading private key file: %s", err)) + if c.PrivateKeyFile != "" { + // Load the private key. + c.privateKeyBytes, err = processPrivateKeyFile(c.PrivateKeyFile, c.Passphrase) + if err != nil { + errs = packer.MultiErrorAppend( + errs, fmt.Errorf("Failed loading private key file: %s", err)) + } } // Check for any errors.