Skip to content

Commit

Permalink
add resource create action
Browse files Browse the repository at this point in the history
  • Loading branch information
bruceybian committed Feb 4, 2024
1 parent 853f6b1 commit 83576cc
Show file tree
Hide file tree
Showing 28 changed files with 32 additions and 28 deletions.
6 changes: 5 additions & 1 deletion tencentcloud/common/cloud_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ const (
DefaultSearchLogStartTimestamp = 1699346460000

DefaultTopicId = "aef50d54-b17d-4782-8618-a7873203ec29"

QueryGrammarRule = " AND "
)

// ResourceAccountInfo 资源账户信息
Expand All @@ -40,9 +42,11 @@ func GetResourceCreatorAccountInfo(client *connectivity.TencentCloudClient, reso
request.From = helper.IntInt64(DefaultSearchLogStartTimestamp)
request.To = helper.Int64(CurrentTimeMillisecond())
request.TopicId = helper.String(DefaultTopicId)
request.Query = helper.String(resourceCreateAction)

for _, r := range resources {
query := resourceCreateAction + QueryGrammarRule + r.Id
request.Query = helper.String(query)

response, err := client.UseClsClient().SearchLog(request)
if err != nil {
log.Printf("[CRITAL] search resource[%v] log data error: %v", r.Id, err.Error())
Expand Down
2 changes: 1 addition & 1 deletion tencentcloud/services/as/resource_tc_as_attachment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func testSweepAsAttachment(r string) error {
CreatTime: *v.CreatedTime,
})
}
tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "")
tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "CreateAutoScalingGroup")

for _, v := range scalingGroups {
scalingGroupId := *v.AutoScalingGroupId
Expand Down
2 changes: 1 addition & 1 deletion tencentcloud/services/cam/resource_tc_cam_group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func init() {
CreatTime: *v.CreateTime,
})
}
tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "")
tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "CreateGroup")

for _, v := range groups {
name := *v.GroupName
Expand Down
2 changes: 1 addition & 1 deletion tencentcloud/services/cbs/resource_tc_cbs_storage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func init() {
CreatTime: *v.CreateTime,
})
}
tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "")
tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "CreateDisks")

for i := range disks {
disk := disks[i]
Expand Down
2 changes: 1 addition & 1 deletion tencentcloud/services/ccn/resource_tc_ccn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func testSweepCcnInstance(region string) error {
CreatTime: v.CreateTime(),
})
}
tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "")
tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "CreateCcn")

for _, v := range instances {
instanceId := v.CcnId()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func testSweepMySQLInstance(region string) error {
CreatTime: *v.CreateTime,
})
}
tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "")
tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "CreateDBInstance")

for _, v := range items {
id := *v.InstanceId
Expand Down
2 changes: 1 addition & 1 deletion tencentcloud/services/clb/resource_tc_clb_instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func testSweepClbInstance(region string) error {
CreatTime: *v.CreateTime,
})
}
tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "")
tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "CreateLoadBalancer")

if len(res) > 0 {
for _, v := range res {
Expand Down
2 changes: 1 addition & 1 deletion tencentcloud/services/cls/resource_tc_cls_topic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func testSweepClsTopic(region string) error {
CreatTime: *v.CreateTime,
})
}
tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "")
tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "CreateTopic")

for _, v := range instances {
instanceId := v.TopicId
Expand Down
2 changes: 1 addition & 1 deletion tencentcloud/services/cos/resource_tc_cos_bucket_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func testSweepCosBuckets(region string) error {
CreatTime: v.CreationDate.Format("2006-01-02 15:04:05"),
})
}
tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "")
tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "PutBucket")

//prefix := regexp.MustCompile("^(tf|test)-")

Expand Down
2 changes: 1 addition & 1 deletion tencentcloud/services/scf/resource_tc_scf_function_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func init() {
CreatTime: *v.AddTime,
})
}
tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "")
tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "CreateFunction")

for _, fun := range funs {
createTime := tccommon.StringToTime(*fun.AddTime)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func init() {
CreatTime: *v.CreateTime,
})
}
tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "")
tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "CreateAccount")

for i := range accounts {
account := accounts[i]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func init() {
CreatTime: *v.CreateTime,
})
}
tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "")
tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "CreateDB")

for i := range dbs {
db := dbs[i]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func init() {
CreatTime: *v.CreateTime,
})
}
tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "")
tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "CreateDBInstances")

err = batchDeleteSQLServerInstances(ctx, service, instances)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func testSweepTcrCustomizedDomain(r string) error {
Name: *v.DomainName,
})
}
tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "")
tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "CreateInstanceCustomizedDomain")

for _, v := range domains {
delName := *v.DomainName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func testSweepTcrImmutableTagRule(r string) error {
Id: helper.Int64ToStr(*v.RuleId),
})
}
tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "")
tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "CreateImmutableTagRules")

for _, rule := range rules {
ruleId := helper.Int64ToStr(*rule.RuleId)
Expand Down
2 changes: 1 addition & 1 deletion tencentcloud/services/tcr/resource_tc_tcr_instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func init() {
CreatTime: *v.CreatedAt,
})
}
tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "")
tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "CreateInstance")

for i := range instances {
ins := instances[i]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func init() {
CreatTime: *v.CreationTime,
})
}
tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "")
tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "CreateNamespace")

for i := range namespaces {
n := namespaces[i]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func testSweepTCRRepository(r string) error {
CreatTime: *v.CreationTime,
})
}
tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "")
tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "CreateRepository")

for i := range repos {
n := repos[i]
Expand Down
2 changes: 1 addition & 1 deletion tencentcloud/services/tcr/resource_tc_tcr_token_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func init() {
CreatTime: *v.CreatedAt,
})
}
tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "")
tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "CreateInstanceToken")

for i := range tokens {
token := tokens[i]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func init() {
CreatTime: v.CreatedTime,
})
}
tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "")
tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "CreateCluster")

for _, v := range clusters {
id := v.ClusterId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func testNodePoolSweep(region string) error {
Name: *v.Name,
})
}
tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "")
tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "CreateClusterNodePool")

for i := range nodePools {
poolId := *nodePools[i].NodePoolId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func init() {
instanceIds = append(instanceIds, worker.InstanceId)
}

tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "")
tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "CreateClusterInstances")

err = service.DeleteClusterInstances(ctx, clusterId, instanceIds)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion tencentcloud/services/vpc/resource_tc_eni_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func testSweepEniInstance(region string) error {
CreatTime: *v.CreatedTime,
})
}
tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "")
tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "CreateNetworkInterface")

for _, v := range instances {
instanceId := *v.NetworkInterfaceId
Expand Down
2 changes: 1 addition & 1 deletion tencentcloud/services/vpc/resource_tc_ha_vip_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func testSweepHaVipInstance(region string) error {
CreatTime: *v.CreatedTime,
})
}
tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "")
tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "CreateHaVip")

for _, v := range instances {
instanceId := *v.HaVipId
Expand Down
2 changes: 1 addition & 1 deletion tencentcloud/services/vpc/resource_tc_nat_gateway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func testSweepNatInstance(region string) error {
CreatTime: *v.CreatedTime,
})
}
tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "")
tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "CreateNatGateway")

for _, v := range instances {
instanceId := *v.NatGatewayId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func testSweepSecurityGroups(region string) error {
CreatTime: *v.CreatedTime,
})
}
tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "")
tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "CreateSecurityGroup")

for _, v := range sgs {
name := *v.SecurityGroupName
Expand Down
2 changes: 1 addition & 1 deletion tencentcloud/services/vpc/resource_tc_subnet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func testSweepSubnet(region string) error {
CreatTime: v.CreateTime(),
})
}
tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "")
tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "CreateSubnet")

for _, v := range instances {

Expand Down
2 changes: 1 addition & 1 deletion tencentcloud/services/vpn/resource_tc_vpn_gateway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func testSweepVpnGateway(region string) error {
CreatTime: *v.CreatedTime,
})
}
tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "")
tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "CreateVpnGateway")

for _, v := range instances {

Expand Down

0 comments on commit 83576cc

Please sign in to comment.