Skip to content

Commit c045337

Browse files
committed
update go-common
Signed-off-by: Markus Blaschke <mblaschke82@gmail.com>
1 parent b0c30ce commit c045337

File tree

4 files changed

+7
-27
lines changed

4 files changed

+7
-27
lines changed

auditor/auditor.azure.go

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -14,38 +14,15 @@ func (auditor *AzureAuditor) getSubscriptionList(ctx context.Context) (list map[
1414
auditor.locks.subscriptions.Lock()
1515
defer auditor.locks.subscriptions.Unlock()
1616

17-
list = map[string]subscriptions.Subscription{}
18-
1917
if val, ok := auditor.cache.Get("subscriptions"); ok {
2018
// fetched from cache
2119
list = val.(map[string]subscriptions.Subscription)
2220
return
2321
}
2422

25-
client := subscriptions.NewClientWithBaseURI(auditor.azure.client.Environment.ResourceManagerEndpoint)
26-
auditor.decorateAzureClient(&client.Client, auditor.azure.client.GetAuthorizer())
27-
28-
if len(auditor.Opts.Azure.Subscription) == 0 {
29-
result, err := client.ListComplete(ctx)
30-
if err != nil {
31-
auditor.logger.Panic(err)
32-
}
33-
34-
for result.NotDone() {
35-
subscription := result.Value()
36-
list[to.String(subscription.SubscriptionID)] = subscription
37-
if result.NextWithContext(ctx) != nil {
38-
break
39-
}
40-
}
41-
} else {
42-
for _, subId := range auditor.Opts.Azure.Subscription {
43-
result, err := client.Get(ctx, subId)
44-
if err != nil {
45-
auditor.logger.Panic(err)
46-
}
47-
list[to.String(result.SubscriptionID)] = result
48-
}
23+
list, err := auditor.azure.client.ListSubscriptions(ctx)
24+
if err != nil {
25+
auditor.logger.Panic(err)
4926
}
5027

5128
auditor.logger.Infof("found %v Azure Subscriptions (cache update)", len(list))

auditor/auditor.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,7 @@ func (auditor *AzureAuditor) initAzure() {
354354
auditor.logger.Panic(err)
355355
}
356356
auditor.azure.client.SetUserAgent(auditor.UserAgent)
357+
auditor.azure.client.SetSubscriptionFilter(auditor.Opts.Azure.Subscription...)
357358
}
358359

359360
func (auditor *AzureAuditor) initMsGraph() {

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ require (
2020
github.com/robertkrimen/otto v0.0.0-20211024170158-b87d35c0b86f
2121
github.com/robfig/cron/v3 v3.0.1
2222
github.com/sirupsen/logrus v1.8.1
23-
github.com/webdevops/go-common v0.0.0-20220601204543-8cd933661a41
23+
github.com/webdevops/go-common v0.0.0-20220616112601-a22e7e1a99bb
2424
gopkg.in/yaml.v3 v3.0.1
2525
)
2626

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,8 @@ github.com/stretchr/testify v1.7.2 h1:4jaiDzPyXQvSd7D0EjG45355tLlV3VOECpq10pLC+8
312312
github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals=
313313
github.com/webdevops/go-common v0.0.0-20220601204543-8cd933661a41 h1:FmyeqHcY/zhPSF9eEW3HpD3Ls/BKfCTs6cPFZcYWeYw=
314314
github.com/webdevops/go-common v0.0.0-20220601204543-8cd933661a41/go.mod h1:8dTX+tlTqPcn+7WQpytFK1HSkSEq6+YfVwjbHiJlNBI=
315+
github.com/webdevops/go-common v0.0.0-20220616112601-a22e7e1a99bb h1:hGh+sXh0zSojcPB2dtS98jPOpUOzrt/NtPmOEL3NEyQ=
316+
github.com/webdevops/go-common v0.0.0-20220616112601-a22e7e1a99bb/go.mod h1:8dTX+tlTqPcn+7WQpytFK1HSkSEq6+YfVwjbHiJlNBI=
315317
github.com/yosida95/uritemplate/v3 v3.0.2 h1:Ed3Oyj9yrmi9087+NczuL5BwkIc4wvTb5zIM+UJPGz4=
316318
github.com/yosida95/uritemplate/v3 v3.0.2/go.mod h1:ILOh0sOhIJR3+L/8afwt/kE++YT040gmv5BQTMR2HP4=
317319
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=

0 commit comments

Comments
 (0)