Skip to content

fix sweeper logic #2462

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions tencentcloud/services/antiddos/tencentcloud_sweeper_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package antiddos_test

import (
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)

func TestMain(m *testing.M) {
resource.TestMain(m)
}
11 changes: 11 additions & 0 deletions tencentcloud/services/apigateway/tencentcloud_sweeper_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package apigateway_test

import (
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)

func TestMain(m *testing.M) {
resource.TestMain(m)
}
11 changes: 11 additions & 0 deletions tencentcloud/services/apm/tencentcloud_sweeper_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package apm_test

import (
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)

func TestMain(m *testing.M) {
resource.TestMain(m)
}
11 changes: 11 additions & 0 deletions tencentcloud/services/as/tencentcloud_sweeper_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package as_test

import (
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)

func TestMain(m *testing.M) {
resource.TestMain(m)
}
11 changes: 11 additions & 0 deletions tencentcloud/services/audit/tencentcloud_sweeper_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package audit_test

import (
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)

func TestMain(m *testing.M) {
resource.TestMain(m)
}
11 changes: 11 additions & 0 deletions tencentcloud/services/bh/tencentcloud_sweeper_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package bh_test

import (
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)

func TestMain(m *testing.M) {
resource.TestMain(m)
}
11 changes: 11 additions & 0 deletions tencentcloud/services/bi/tencentcloud_sweeper_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package bi_test

import (
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)

func TestMain(m *testing.M) {
resource.TestMain(m)
}
11 changes: 11 additions & 0 deletions tencentcloud/services/cam/tencentcloud_sweeper_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package cam_test

import (
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)

func TestMain(m *testing.M) {
resource.TestMain(m)
}
11 changes: 11 additions & 0 deletions tencentcloud/services/cat/tencentcloud_sweeper_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package cat_test

import (
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)

func TestMain(m *testing.M) {
resource.TestMain(m)
}
11 changes: 11 additions & 0 deletions tencentcloud/services/cbs/tencentcloud_sweeper_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package cbs_test

import (
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)

func TestMain(m *testing.M) {
resource.TestMain(m)
}
11 changes: 11 additions & 0 deletions tencentcloud/services/ccn/tencentcloud_sweeper_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package ccn_test

import (
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)

func TestMain(m *testing.M) {
resource.TestMain(m)
}
11 changes: 11 additions & 0 deletions tencentcloud/services/cdb/tencentcloud_sweeper_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package cdb_test

import (
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)

func TestMain(m *testing.M) {
resource.TestMain(m)
}
11 changes: 11 additions & 0 deletions tencentcloud/services/cdh/tencentcloud_sweeper_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package cdh_test

import (
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)

func TestMain(m *testing.M) {
resource.TestMain(m)
}
11 changes: 11 additions & 0 deletions tencentcloud/services/cdn/tencentcloud_sweeper_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package cdn_test

import (
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)

func TestMain(m *testing.M) {
resource.TestMain(m)
}
11 changes: 11 additions & 0 deletions tencentcloud/services/cdwch/tencentcloud_sweeper_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package cdwch_test

import (
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)

func TestMain(m *testing.M) {
resource.TestMain(m)
}
11 changes: 11 additions & 0 deletions tencentcloud/services/cdwpg/tencentcloud_sweeper_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package cdwpg_test

import (
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)

func TestMain(m *testing.M) {
resource.TestMain(m)
}
11 changes: 11 additions & 0 deletions tencentcloud/services/cfs/tencentcloud_sweeper_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package cfs_test

import (
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)

func TestMain(m *testing.M) {
resource.TestMain(m)
}
11 changes: 11 additions & 0 deletions tencentcloud/services/cfw/tencentcloud_sweeper_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package cfw_test

import (
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)

func TestMain(m *testing.M) {
resource.TestMain(m)
}
11 changes: 11 additions & 0 deletions tencentcloud/services/chdfs/tencentcloud_sweeper_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package chdfs_test

import (
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)

func TestMain(m *testing.M) {
resource.TestMain(m)
}
11 changes: 11 additions & 0 deletions tencentcloud/services/ci/tencentcloud_sweeper_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package ci_test

import (
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)

func TestMain(m *testing.M) {
resource.TestMain(m)
}
11 changes: 11 additions & 0 deletions tencentcloud/services/ciam/tencentcloud_sweeper_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package ciam_test

import (
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)

func TestMain(m *testing.M) {
resource.TestMain(m)
}
11 changes: 11 additions & 0 deletions tencentcloud/services/ckafka/tencentcloud_sweeper_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package ckafka_test

import (
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)

func TestMain(m *testing.M) {
resource.TestMain(m)
}
9 changes: 4 additions & 5 deletions tencentcloud/services/clb/resource_tc_clb_instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"context"
"fmt"
"log"
"strings"
"testing"
"time"

Expand Down Expand Up @@ -51,15 +50,15 @@ func testSweepClbInstance(region string) error {
if len(res) > 0 {
for _, v := range res {
id := *v.LoadBalancerId
instanceName := *v.LoadBalancerName
//instanceName := *v.LoadBalancerName
createTime := tccommon.StringToTime(*v.CreateTime)

now := time.Now()
interval := now.Sub(createTime).Minutes()
// keep not delete
if strings.HasPrefix(instanceName, tcacctest.KeepResource) || strings.HasPrefix(instanceName, tcacctest.DefaultResource) {
continue
}
//if strings.HasPrefix(instanceName, tcacctest.KeepResource) || strings.HasPrefix(instanceName, tcacctest.DefaultResource) {
// continue
//}
// less than 30 minute, not delete
if tccommon.NeedProtect == 1 && int64(interval) < 30 {
continue
Expand Down
11 changes: 11 additions & 0 deletions tencentcloud/services/clb/tencentcloud_sweeper_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package clb_test

import (
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)

func TestMain(m *testing.M) {
resource.TestMain(m)
}
11 changes: 11 additions & 0 deletions tencentcloud/services/cls/tencentcloud_sweeper_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package cls

import (
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)

func TestMain(m *testing.M) {
resource.TestMain(m)
}
8 changes: 4 additions & 4 deletions tencentcloud/services/cos/resource_tc_cos_bucket_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ func testSweepCosBuckets(region string) error {
return fmt.Errorf("list buckets error: %s", err.Error())
}

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

for _, v := range buckets {
bucket := *v.Name
if !prefix.MatchString(bucket) {
continue
}
//if !prefix.MatchString(bucket) {
// continue
//}

// delete all object in the bucket before deleting bucket
if objects, err := cosService.ListObjects(ctx, bucket); err != nil {
Expand Down
11 changes: 11 additions & 0 deletions tencentcloud/services/cos/tencentcloud_sweeper_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package cos_test

import (
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)

func TestMain(m *testing.M) {
resource.TestMain(m)
}
11 changes: 11 additions & 0 deletions tencentcloud/services/crs/tencentcloud_sweeper_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package crs_test

import (
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)

func TestMain(m *testing.M) {
resource.TestMain(m)
}
11 changes: 11 additions & 0 deletions tencentcloud/services/css/tencentcloud_sweeper_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package css_test

import (
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)

func TestMain(m *testing.M) {
resource.TestMain(m)
}
9 changes: 4 additions & 5 deletions tencentcloud/services/cvm/resource_tc_instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"context"
"fmt"
"log"
"strings"
"testing"
"time"

Expand Down Expand Up @@ -43,14 +42,14 @@ func testSweepCvmInstance(region string) error {

for _, v := range instances {
instanceId := *v.InstanceId
instanceName := *v.InstanceName
//instanceName := *v.InstanceName
now := time.Now()
createTime := tccommon.StringToTime(*v.CreatedTime)
interval := now.Sub(createTime).Minutes()

if strings.HasPrefix(instanceName, tcacctest.KeepResource) || strings.HasPrefix(instanceName, tcacctest.DefaultResource) {
continue
}
//if strings.HasPrefix(instanceName, tcacctest.KeepResource) || strings.HasPrefix(instanceName, tcacctest.DefaultResource) {
// continue
//}

if tccommon.NeedProtect == 1 && int64(interval) < 30 {
continue
Expand Down
Loading