Skip to content

Commit 9ce3a91

Browse files
author
Joshua Reed
committed
Updated with constant for GLOBAL section in INI file.
1 parent e5fe8b6 commit 9ce3a91

File tree

4 files changed

+10
-7
lines changed

4 files changed

+10
-7
lines changed

pkg/cloud/client.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ import (
2626

2727
//go:generate mockgen -destination=../mocks/mock_client.go -package=mocks sigs.k8s.io/cluster-api-provider-cloudstack/pkg/cloud Client
2828

29+
const GLOBAL = "Global"
30+
2931
type Client interface {
3032
VMIface
3133
NetworkIface
@@ -55,9 +57,9 @@ func NewClient(ccPath string) (Client, error) {
5557
c := &client{config: Config{VerifySSL: true}}
5658
if rawCfg, err := ini.Load(ccPath); err != nil {
5759
return nil, errors.Wrapf(err, "reading config at path %s", ccPath)
58-
} else if g := rawCfg.Section("Global"); len(g.Keys()) == 0 {
60+
} else if g := rawCfg.Section(GLOBAL); len(g.Keys()) == 0 {
5961
return nil, errors.New("section Global not found")
60-
} else if err = rawCfg.Section("Global").StrictMapTo(&c.config); err != nil {
62+
} else if err = rawCfg.Section(GLOBAL).StrictMapTo(&c.config); err != nil {
6163
return nil, errors.Wrapf(err, "parsing [Global] section from config at path %s", ccPath)
6264
}
6365

pkg/cloud/cloud_suite_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,9 @@ import (
3131
)
3232

3333
var (
34-
realCloudClient cloud.Client
35-
client cloud.Client
34+
// cloud.Client is our cloud package used to interact with ACS.
35+
realCloudClient cloud.Client // Real cloud client is a cloud client connected to a real Apache CloudStack instance.
36+
client cloud.Client // client is simply a pointer to a cloud client object intended to be swapped per test.
3637
realCSClient *cloudstack.CloudStackClient
3738
testDomainPath string // Needed in before and in after suite.
3839
)

pkg/cloud/isolated_network.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ func (c *client) GetOrCreateIsolatedNetwork(
247247
if err = c.CreateIsolatedNetwork(zone, isoNet); err != nil {
248248
return errors.Wrap(err, "creating a new isolated network")
249249
}
250-
} else {
250+
} else { // Network existed and was resolved. Set ID on isoNet CloudStackIsolatedNetwork in case it only had name set.
251251
isoNet.Spec.ID = net.ID
252252
}
253253

test/helpers/client.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ func NewCSClient() (*cloudstack.CloudStackClient, error) {
1515
ccPath := projDir + "/cloud-config"
1616
if rawCfg, err := ini.Load(ccPath); err != nil {
1717
return nil, errors.Wrapf(err, "reading config at path %s:", ccPath)
18-
} else if g := rawCfg.Section("Global"); len(g.Keys()) == 0 {
18+
} else if g := rawCfg.Section(cloud.GLOBAL); len(g.Keys()) == 0 {
1919
return nil, errors.New("section Global not found")
20-
} else if err = rawCfg.Section("Global").StrictMapTo(&conf); err != nil {
20+
} else if err = rawCfg.Section(cloud.GLOBAL).StrictMapTo(&conf); err != nil {
2121
return nil, errors.Wrapf(err, "parsing [Global] section from config at path %s:", ccPath)
2222
}
2323
csClient := cloudstack.NewAsyncClient(conf.APIURL, conf.APIKey, conf.SecretKey, conf.VerifySSL)

0 commit comments

Comments
 (0)