Skip to content

Commit

Permalink
Validate SoftLayer and Bluemix Credentials to be present in the config
Browse files Browse the repository at this point in the history
  • Loading branch information
ashishth09 committed May 12, 2017
1 parent 0394bfb commit ddb4417
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions builtin/providers/ibmcloud/config.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ibmcloud

import (
"errors"
"log"
"os"
"time"
Expand Down Expand Up @@ -231,8 +232,12 @@ func (c *Config) ClientSession() (interface{}, error) {
func newSession(c *Config) (*Session, error) {
ibmcloudSession := &Session{}
skipBluemix, skipSoftLayer := c.SkipServiceConfig.Contains("bluemix"), c.SkipServiceConfig.Contains("softlayer")

if !skipSoftLayer {
log.Println("Configuring SoftLayer Session ")
if c.SoftLayerUserName == "" || c.SoftLayerAPIKey == "" {
return nil, errors.New("softlayer_username and softlayer_api_key must be provided. Please see the documentation on how to configure them")
}
softlayerSession := &slsession.Session{
Endpoint: c.SoftLayerEndpointURL,
Timeout: c.SoftLayerTimeout,
Expand All @@ -244,6 +249,9 @@ func newSession(c *Config) (*Session, error) {
}
if !skipBluemix {
log.Println("Configuring Bluemix Session")
if c.BluemixAPIKey == "" {
return nil, errors.New("bluemix_api_key must be provided. Please see the documentation on how to configure it")
}
var sess *bxsession.Session
bmxConfig := &bluemix.Config{
BluemixAPIKey: c.BluemixAPIKey,
Expand Down

0 comments on commit ddb4417

Please sign in to comment.