Skip to content

Commit

Permalink
Fixes #92
Browse files Browse the repository at this point in the history
  • Loading branch information
ashishth09 committed May 12, 2017
1 parent f6f2568 commit 9da88d1
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 63 deletions.
64 changes: 38 additions & 26 deletions builtin/providers/ibmcloud/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package ibmcloud

import (
"errors"
"fmt"
"log"
"os"
"time"
Expand All @@ -13,6 +14,8 @@ import (
"github.com/IBM-Bluemix/bluemix-go/api/account/accountv2"
"github.com/IBM-Bluemix/bluemix-go/api/cf/cfv2"
"github.com/IBM-Bluemix/bluemix-go/api/k8scluster/k8sclusterv1"
"github.com/IBM-Bluemix/bluemix-go/bmxerror"
"github.com/IBM-Bluemix/bluemix-go/endpoints"
bxsession "github.com/IBM-Bluemix/bluemix-go/session"
)

Expand Down Expand Up @@ -172,11 +175,12 @@ func (c *Config) ClientSession() (interface{}, error) {
return nil, err
}

session := clientSession{
session: sess,
}

if sess.BluemixSession == nil {
log.Println("Skipping Bluemix Clients configuration")
session := clientSession{
session: sess,
}
return session, nil
}

Expand All @@ -199,33 +203,41 @@ func (c *Config) ClientSession() (interface{}, error) {
}
accountAPI := accClient.Accounts()

clusterClient, err := k8sclusterv1.New(sess.BluemixSession)
if err != nil {
return nil, err
}
clustersAPI := clusterClient.Clusters()
clusterWorkerAPI := clusterClient.Workers()
clusterSubnetsAPI := clusterClient.Subnets()
clusterWebhookAPI := clusterClient.WebHooks()

session := clientSession{
session: sess,

csClient: clustersAPI,
csSubnet: clusterSubnetsAPI,
csWorker: clusterWorkerAPI,
csWebHook: clusterWebhookAPI,
skipClusterConfig := c.SkipServiceConfig.Contains("cluster")

cfOrgClient: orgAPI,
cfServiceInstanceClient: serviceInstanceAPI,
cfServiceKeysClient: serviceKeysAPI,
cfServicePlanClient: servicePlanAPI,
cfServiceOfferingsClient: serviceOfferringAPI,
cfSpaceClient: spaceAPI,
if !skipClusterConfig {
clusterClient, err := k8sclusterv1.New(sess.BluemixSession)
if err != nil {
if apiErr, ok := err.(bmxerror.Error); ok {
if apiErr.Code() == endpoints.ErrCodeServiceEndpoint {
return nil, fmt.Errorf(`Cluster service doesn't exist in the region %q.\nTo remediate the problem please skip the cluster service configuration by specifying "cluster" in skip_service_configuration in the provider block`, c.Region)

bluemixAccountClient: accountAPI,
}
}
return nil, err
}
clustersAPI := clusterClient.Clusters()
clusterWorkerAPI := clusterClient.Workers()
clusterSubnetsAPI := clusterClient.Subnets()
clusterWebhookAPI := clusterClient.WebHooks()

session.csClient = clustersAPI
session.csSubnet = clusterSubnetsAPI
session.csWorker = clusterWorkerAPI
session.csWebHook = clusterWebhookAPI

} else {
log.Println("Skipping cluster configuration")
}

session.cfOrgClient = orgAPI
session.cfServiceInstanceClient = serviceInstanceAPI
session.cfServiceKeysClient = serviceKeysAPI
session.cfServicePlanClient = servicePlanAPI
session.cfServiceOfferingsClient = serviceOfferringAPI
session.cfSpaceClient = spaceAPI
session.bluemixAccountClient = accountAPI

return session, nil
}

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 11 additions & 5 deletions vendor/github.com/IBM-Bluemix/bluemix-go/endpoints/endpoints.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

56 changes: 28 additions & 28 deletions vendor/vendor.json
Original file line number Diff line number Diff line change
Expand Up @@ -389,80 +389,80 @@
{
"checksumSHA1": "uXoiqDVU3TZxsSfbeVKP60Gmtzo=",
"path": "github.com/IBM-Bluemix/bluemix-go",
"revision": "362904bd1c6d939837d106772ffe378e4c36285a",
"revisionTime": "2017-05-10T12:44:42Z"
"revision": "424f9c5b3a7a5d8b209fe337493e1d0717bf3b46",
"revisionTime": "2017-05-12T19:21:55Z"
},
{
"checksumSHA1": "i79PeKQLMC6r4u4H7KDTNzMMbSo=",
"path": "github.com/IBM-Bluemix/bluemix-go/api/account/accountv2",
"revision": "362904bd1c6d939837d106772ffe378e4c36285a",
"revisionTime": "2017-05-10T12:44:42Z"
"revision": "424f9c5b3a7a5d8b209fe337493e1d0717bf3b46",
"revisionTime": "2017-05-12T19:21:55Z"
},
{
"checksumSHA1": "qAdyQ7iezAj/cMtoOm1NLYiTMF8=",
"path": "github.com/IBM-Bluemix/bluemix-go/api/cf/cfv2",
"revision": "362904bd1c6d939837d106772ffe378e4c36285a",
"revisionTime": "2017-05-10T12:44:42Z"
"revision": "424f9c5b3a7a5d8b209fe337493e1d0717bf3b46",
"revisionTime": "2017-05-12T19:21:55Z"
},
{
"checksumSHA1": "p42EedBTf9mwostBJjXX5QjJoHA=",
"path": "github.com/IBM-Bluemix/bluemix-go/api/k8scluster/k8sclusterv1",
"revision": "362904bd1c6d939837d106772ffe378e4c36285a",
"revisionTime": "2017-05-10T12:44:42Z"
"revision": "424f9c5b3a7a5d8b209fe337493e1d0717bf3b46",
"revisionTime": "2017-05-12T19:21:55Z"
},
{
"checksumSHA1": "nGL+HGbR0VSA5GWURG0FHmnZKU4=",
"checksumSHA1": "2dS1wigwpyW5ixKmyOPrUeLWW1c=",
"path": "github.com/IBM-Bluemix/bluemix-go/authentication",
"revision": "362904bd1c6d939837d106772ffe378e4c36285a",
"revisionTime": "2017-05-10T12:44:42Z"
"revision": "424f9c5b3a7a5d8b209fe337493e1d0717bf3b46",
"revisionTime": "2017-05-12T19:21:55Z"
},
{
"checksumSHA1": "YBML7SGPWwMvtuJFqSyTjtxvPYs=",
"path": "github.com/IBM-Bluemix/bluemix-go/bmxerror",
"revision": "362904bd1c6d939837d106772ffe378e4c36285a",
"revisionTime": "2017-05-10T12:44:42Z"
"revision": "424f9c5b3a7a5d8b209fe337493e1d0717bf3b46",
"revisionTime": "2017-05-12T19:21:55Z"
},
{
"checksumSHA1": "CnOI3bB+qKzMlr8p0XuxPalIKko=",
"path": "github.com/IBM-Bluemix/bluemix-go/client",
"revision": "362904bd1c6d939837d106772ffe378e4c36285a",
"revisionTime": "2017-05-10T12:44:42Z"
"revision": "424f9c5b3a7a5d8b209fe337493e1d0717bf3b46",
"revisionTime": "2017-05-12T19:21:55Z"
},
{
"checksumSHA1": "3MRpIixjbF/sPGwa0z6VOGU1JsA=",
"checksumSHA1": "BqwaZM5Nf6lTTlcpkfucuT2ZYhk=",
"path": "github.com/IBM-Bluemix/bluemix-go/endpoints",
"revision": "362904bd1c6d939837d106772ffe378e4c36285a",
"revisionTime": "2017-05-10T12:44:42Z"
"revision": "424f9c5b3a7a5d8b209fe337493e1d0717bf3b46",
"revisionTime": "2017-05-12T19:21:55Z"
},
{
"checksumSHA1": "WSGgwampernftuHCz6XiOfFpcoM=",
"path": "github.com/IBM-Bluemix/bluemix-go/helpers",
"revision": "362904bd1c6d939837d106772ffe378e4c36285a",
"revisionTime": "2017-05-10T12:44:42Z"
"revision": "424f9c5b3a7a5d8b209fe337493e1d0717bf3b46",
"revisionTime": "2017-05-12T19:21:55Z"
},
{
"checksumSHA1": "GwQQNVaNODYWHyAUFw/PAvr+ePY=",
"path": "github.com/IBM-Bluemix/bluemix-go/http",
"revision": "362904bd1c6d939837d106772ffe378e4c36285a",
"revisionTime": "2017-05-10T12:44:42Z"
"revision": "424f9c5b3a7a5d8b209fe337493e1d0717bf3b46",
"revisionTime": "2017-05-12T19:21:55Z"
},
{
"checksumSHA1": "+YWMAtV5wQvcHDWzPmsZ1hRA1ic=",
"path": "github.com/IBM-Bluemix/bluemix-go/rest",
"revision": "362904bd1c6d939837d106772ffe378e4c36285a",
"revisionTime": "2017-05-10T12:44:42Z"
"revision": "424f9c5b3a7a5d8b209fe337493e1d0717bf3b46",
"revisionTime": "2017-05-12T19:21:55Z"
},
{
"checksumSHA1": "n5SnBu2teZIcsVylQbtHrqBExZY=",
"path": "github.com/IBM-Bluemix/bluemix-go/session",
"revision": "362904bd1c6d939837d106772ffe378e4c36285a",
"revisionTime": "2017-05-10T12:44:42Z"
"revision": "424f9c5b3a7a5d8b209fe337493e1d0717bf3b46",
"revisionTime": "2017-05-12T19:21:55Z"
},
{
"checksumSHA1": "WKFwS8jLgaJThltcgWFKjwyMlCI=",
"path": "github.com/IBM-Bluemix/bluemix-go/trace",
"revision": "362904bd1c6d939837d106772ffe378e4c36285a",
"revisionTime": "2017-05-10T12:44:42Z"
"revision": "424f9c5b3a7a5d8b209fe337493e1d0717bf3b46",
"revisionTime": "2017-05-12T19:21:55Z"
},
{
"checksumSHA1": "B+GonfgNwOAJMEe0WUHQGATRtMA=",
Expand Down
5 changes: 3 additions & 2 deletions website/source/docs/providers/ibmcloud/index.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,11 @@ See `skip_service_configuration` in the Argument Reference below.
The below configuration will direct the provider to not configure the softlayer client and hence
not complain if softlayer_username and softlayer_api_key are missing in the provider.

```
provider "ibmcloud" {
skip_service_configuration = ["softlayer"]
}
```


## Argument Reference
Expand All @@ -128,5 +130,4 @@ The following arguments are supported in the `provider` block:

* `region` - (Optional) The Bluemix region. It can also be sourced from the `BM_REGION` or `BLUEMIX_REGION` environment variable. The former variable has higher precedence. Default value: `us-south`.

* `skip_service_configuration` - (Optional, Set) The options allows one to skip configuring the provider for IBM Cloud services which the user may not create. Supported values are - `bluemix` and `softlayer`. This is useful when a user has credentials for only a particular service for example SoftLayer. In that case provider will not complain about the absence of `bluemix_api_key`.

* `skip_service_configuration` - (Optional, Set) The options allows one to skip configuring the provider for IBM Cloud services which the user may not create. Supported values are - `bluemix`, `softlayer` and `cluster`. This is useful when a user has credentials for only a particular service for example SoftLayer. In that case provider will not complain about the absence of `bluemix_api_key`.

0 comments on commit 9da88d1

Please sign in to comment.