Skip to content
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

feat/cfw #2149

Merged
merged 10 commits into from
Sep 28, 2023
Merged

feat/cfw #2149

merged 10 commits into from
Sep 28, 2023

Conversation

SevenEarth
Copy link
Collaborator

feat/cfw

@SevenEarth SevenEarth added the run check run check label Sep 27, 2023
@SevenEarth SevenEarth added run check run check and removed run check run check labels Sep 28, 2023
go.mod Outdated
@@ -100,7 +100,10 @@ require (
gopkg.in/yaml.v2 v2.4.0
)

require github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/waf v1.0.754
require (
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里为啥要单独一个 require 呢

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这是go mod自动生成的 非人为

natInsId = v.(string)
}

if v, _ := d.GetOkExists("status"); v != nil {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

好上面使用的 GetOk, 什么情况下使用 GetOkExists ,什么情况下使用 GetOk 呢

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

一般包含0 false 这种参数 就需要用GetOkExists 正常字符串用GetOk

"ap-taipei-6": "中国台北六区",
}

var ZONE_MAP_CN2EN = map[string]string{
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ZONE目前是写死的是吧,后面如果扩Zone后,这里要更新吗

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这些是全部的zone映射,如果后续扩zone,这里需要更新

return err
}

ruleUuid := *response.Response.RuleUuids[0]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

response.Response.RuleUuids可能为空吗

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

只要err为nil RuleUuids就不为空

Steps: []resource.TestStep{
{
Config: testAccCfwVpcPolicy,
Check: resource.ComposeTestCheckFunc(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里每个字段都check下?

resource.TestCheckResourceAttrSet("tencentcloud_cfw_nat_firewall_switch.example", "id"),
resource.TestCheckResourceAttrSet("tencentcloud_cfw_nat_firewall_switch.example", "nat_ins_id"),
resource.TestCheckResourceAttrSet("tencentcloud_cfw_nat_firewall_switch.example", "subnet_id"),
resource.TestCheckResourceAttrSet("tencentcloud_cfw_nat_firewall_switch.example", "enable"),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check下属性的值?

Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrSet("tencentcloud_cfw_address_template.example", "id"),
resource.TestCheckResourceAttrSet("tencentcloud_cfw_address_template.example", "name"),
resource.TestCheckResourceAttrSet("tencentcloud_cfw_address_template.example", "detail"),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check下字段值

intrusionDefenseRule.EndTime = helper.String(v.(string))
}

if v, ok := d.GetOk("comment"); ok {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不需要判断下 hasChange吗

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

必填值 不需要hasChange

resource.TestCheckResourceAttrSet("tencentcloud_cfw_block_ignore_list.example", "direction"),
resource.TestCheckResourceAttrSet("tencentcloud_cfw_block_ignore_list.example", "comment"),
resource.TestCheckResourceAttrSet("tencentcloud_cfw_block_ignore_list.example", "start_time"),
resource.TestCheckResourceAttrSet("tencentcloud_cfw_block_ignore_list.example", "end_time"),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check下字段的值

{
Config: testAccCfwAddressTemplateUpdate,
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrSet("tencentcloud_cfw_address_template.example", "id"),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check下字段值

Config: testAccCfwEdgeFirewallSwitchUpdate,
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrSet("tencentcloud_cfw_edge_firewall_switch.example", "id"),
resource.TestCheckResourceAttrSet("tencentcloud_cfw_edge_firewall_switch.example", "public_ip"),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check下字段值

return err
}

ruleUuid := *response.Response.RuleUuid[0]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

response.Response.RuleUuid可能为空吗

if v, ok := d.GetOk("description"); ok {
modifyRuleItem.Description = helper.String(v.(string))
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里应该有些字段需要加haschange判断吧

resource.TestCheckResourceAttrSet("tencentcloud_cfw_edge_policy.example", "source_type"),
resource.TestCheckResourceAttrSet("tencentcloud_cfw_edge_policy.example", "target_content"),
resource.TestCheckResourceAttrSet("tencentcloud_cfw_edge_policy.example", "target_type"),
resource.TestCheckResourceAttrSet("tencentcloud_cfw_edge_policy.example", "protocol"),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

字段值Check下


edgeIpSwitch.PublicIp = &publicIp

if v, ok := d.GetOk("subnet_id"); ok {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里需要判断hansChange?

resource.TestCheckResourceAttrSet("tencentcloud_cfw_edge_policy.example", "protocol"),
resource.TestCheckResourceAttrSet("tencentcloud_cfw_edge_policy.example", "rule_action"),
resource.TestCheckResourceAttrSet("tencentcloud_cfw_edge_policy.example", "port"),
resource.TestCheckResourceAttrSet("tencentcloud_cfw_edge_policy.example", "direction"),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check字段值

Copy link
Collaborator

@andrew-tx andrew-tx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

go.mod Outdated
require github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/waf v1.0.759
>>>>>>> 980b4317f5abdb75718178af297400be12062e6e
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里有冲突了

@@ -1685,8 +1685,31 @@ Waf
tencentcloud_waf_saas_domain
tencentcloud_waf_clb_instance
tencentcloud_waf_saas_instance
<<<<<<< HEAD
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里也有冲突

{
Config: testAccCfwNatInstance,
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrSet("tencentcloud_cfw_nat_instance.example", "id"),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

后面补下其它字段的check逻辑

resource.TestCheckResourceAttrSet("tencentcloud_cfw_nat_policy.example", "target_content"),
resource.TestCheckResourceAttrSet("tencentcloud_cfw_nat_policy.example", "target_type"),
resource.TestCheckResourceAttrSet("tencentcloud_cfw_nat_policy.example", "protocol"),
resource.TestCheckResourceAttrSet("tencentcloud_cfw_nat_policy.example", "rule_action"),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

后面完善用例时增加字段check逻辑

Example Usage

```hcl
resource "tencentcloud_cfw_sync_asset" "example" {}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个是一个Operation?

@andrew-tx andrew-tx merged commit b186bef into master Sep 28, 2023
@andrew-tx andrew-tx deleted the feat/cfw branch September 28, 2023 13:46
hellertang pushed a commit that referenced this pull request Oct 10, 2023
* feat/cfw

* feat/cfw

* feat/cfw

* feat/cfw

* feat/cfw

* feat/cfw

* feat/cfw
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
run check run check
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants