Commit a9648be5 authored by lalyos's avatar lalyos

Clarify error message in case of an atlas client connection failure

When a packer json contains an atlas postprocessor, and `packer validate` runned locally
in case of the missing ATLAS_TOKEN env var, the following error message is displayed:

* Error initializing client: authentication failed

It wasn't clear which plugin produced this message, so the amazon-ebs builder was the suspect
parent 2db039bf
...@@ -115,7 +115,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error { ...@@ -115,7 +115,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error {
p.client, err = atlas.NewClient(p.config.ServerAddr) p.client, err = atlas.NewClient(p.config.ServerAddr)
if err != nil { if err != nil {
errs = packer.MultiErrorAppend( errs = packer.MultiErrorAppend(
errs, fmt.Errorf("Error initializing client: %s", err)) errs, fmt.Errorf("Error initializing atlas client: %s", err))
return errs return errs
} }
} }
...@@ -126,8 +126,13 @@ func (p *PostProcessor) Configure(raws ...interface{}) error { ...@@ -126,8 +126,13 @@ func (p *PostProcessor) Configure(raws ...interface{}) error {
if !p.config.Test { if !p.config.Test {
// Verify the client // Verify the client
if err := p.client.Verify(); err != nil { if err := p.client.Verify(); err != nil {
errs = packer.MultiErrorAppend( if err == atlas.ErrAuth {
errs, fmt.Errorf("Error initializing client: %s", err)) errs = packer.MultiErrorAppend(
errs, fmt.Errorf("Error connecting to atlas server, please check your ATLAS_TOKEN env: %s", err))
} else {
errs = packer.MultiErrorAppend(
errs, fmt.Errorf("Error initializing atlas client: %s", err))
}
return errs return errs
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment