Skip to content

Commit fe9d843

Browse files
committed
perf(config):Add list_policies switch
1 parent f8e5d9e commit fe9d843

File tree

5 files changed

+13
-4
lines changed

5 files changed

+13
-4
lines changed

pkg/providers/alibaba/ram/users.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"time"
66

77
"github.com/404tk/cloudtoolkit/pkg/schema"
8+
"github.com/404tk/cloudtoolkit/utils"
89
"github.com/404tk/cloudtoolkit/utils/logger"
910
"github.com/aliyun/alibaba-cloud-sdk-go/sdk"
1011
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials"
@@ -77,7 +78,9 @@ func (d *Driver) GetRamUser(ctx context.Context) ([]schema.User, error) {
7778
}
7879
}
7980

80-
_user.Policies = listPoliciesForUser(client, _user.UserName)
81+
if utils.ListPolicies {
82+
_user.Policies = listPoliciesForUser(client, _user.UserName)
83+
}
8184

8285
list = append(list, _user)
8386
select {

pkg/providers/tencent/cam/users.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"fmt"
66

77
"github.com/404tk/cloudtoolkit/pkg/schema"
8+
"github.com/404tk/cloudtoolkit/utils"
89
"github.com/404tk/cloudtoolkit/utils/logger"
910
cam "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cam/v20190116"
1011
"github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common"
@@ -46,7 +47,9 @@ func (d *Driver) GetCamUser(ctx context.Context) ([]schema.User, error) {
4647
if *user.ConsoleLogin == 1 {
4748
_user.EnableLogin = true
4849
}
49-
_user.Policies = listAttachedUserAllPolicies(client, user.Uin)
50+
if utils.ListPolicies {
51+
_user.Policies = listAttachedUserAllPolicies(client, user.Uin)
52+
}
5053

5154
list = append(list, _user)
5255
}

runner/banner.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const banner = `
1212
`
1313

1414
// Version is the current version of cloudtoolkit
15-
const Version = `0.1.2`
15+
const Version = `0.1.3`
1616

1717
// showBanner is used to show the banner to the user
1818
func ShowBanner() {

runner/init.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ func InitConfig() {
2424
}
2525

2626
utils.DoSave = viper.GetBool("common.log_enable")
27+
utils.ListPolicies = viper.GetBool("common.list_policies")
2728
utils.LogDir = viper.GetString("common.log_dir")
2829
utils.Cloudlist = viper.GetStringSlice("cloudlist")
2930

@@ -40,7 +41,8 @@ func InitConfig() {
4041
}
4142

4243
const defaultConfigFile = `common:
43-
log_enable: true
44+
log_enable: false
45+
list_policies: false
4446
log_dir: logs
4547
4648
cloudlist:

utils/const.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ const (
2929

3030
var (
3131
DoSave bool
32+
ListPolicies bool
3233
LogDir string
3334
Cloudlist []string
3435
BackdoorUser string

0 commit comments

Comments
 (0)