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

CIS Firewall Rules : added priority key #3998

Merged
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
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ require (
github.com/IBM/ibm-hpcs-tke-sdk v0.0.0-20211109141421-a4b61b05f7d1
github.com/IBM/ibm-hpcs-uko-sdk v0.0.4
github.com/IBM/keyprotect-go-client v0.7.0
github.com/IBM/networking-go-sdk v0.32.0
github.com/IBM/networking-go-sdk v0.33.0
github.com/IBM/platform-services-go-sdk v0.28.2
github.com/IBM/push-notifications-go-sdk v0.0.0-20210310100607-5790b96c47f5
github.com/IBM/scc-go-sdk/v3 v3.1.6
Expand Down
9 changes: 4 additions & 5 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ github.com/IBM-Cloud/bluemix-go v0.0.0-20220523145737-34645883de47/go.mod h1:tfN
github.com/IBM-Cloud/container-services-go-sdk v0.0.0-20220728135852-60ff775f7a8d h1:cHu5Iev9ggo1fktwmHbmPqDOkt3VYmdUGn1U7/Zb238=
github.com/IBM-Cloud/container-services-go-sdk v0.0.0-20220728135852-60ff775f7a8d/go.mod h1:xUQL9SGAjoZFd4GNjrjjtEpjpkgU7RFXRyHesbKTjiY=
github.com/IBM-Cloud/ibm-cloud-cli-sdk v0.5.3/go.mod h1:RiUvKuHKTBmBApDMUQzBL14pQUGKcx/IioKQPIcRQjs=
github.com/IBM-Cloud/power-go-client v1.1.11 h1:/qTWCCuSZsmiksvQSfhM+mZKkY/Vli/W6b82WoYD2NM=
github.com/IBM-Cloud/power-go-client v1.1.11/go.mod h1:Qfx0fNi+9hms+xu9Z6Euhu9088ByW6C/TCMLECTRWNE=
github.com/IBM-Cloud/power-go-client v1.1.12 h1:zL8Br83MHe1mDhFI+2YenQsHeYUtPzqw9oeFL9fmguE=
github.com/IBM-Cloud/power-go-client v1.1.12/go.mod h1:Qfx0fNi+9hms+xu9Z6Euhu9088ByW6C/TCMLECTRWNE=
github.com/IBM-Cloud/softlayer-go v1.0.5-tf h1:koUAyF9b6X78lLLruGYPSOmrfY2YcGYKOj/Ug9nbKNw=
Expand Down Expand Up @@ -58,8 +56,8 @@ github.com/IBM/ibm-hpcs-uko-sdk v0.0.4 h1:B3FEq830k/B7HjQqvQubxmz8PxOUvKYD2ZypDq
github.com/IBM/ibm-hpcs-uko-sdk v0.0.4/go.mod h1:MLVNHMYoKsvovJZ4v1gQCpIYtRDHTtoIHK6XztDZGsU=
github.com/IBM/keyprotect-go-client v0.7.0 h1:JstSHD14Lp6ihwQseyPuGcs1AjOBjAmcisP0dTBA6A0=
github.com/IBM/keyprotect-go-client v0.7.0/go.mod h1:SVr2ylV/fhSQPDiUjWirN9fsyWFCNNbt8GIT8hPJVjE=
github.com/IBM/networking-go-sdk v0.32.0 h1:QWd7CxC+Wzap+zWFfXMjbqB5LpvrB1KvNtIbKrWIkhA=
github.com/IBM/networking-go-sdk v0.32.0/go.mod h1:tVxXclpQs8nQJYPTr9ZPNC1voaPNQLy8iy/72oVfFtM=
github.com/IBM/networking-go-sdk v0.33.0 h1:+e4Q/io0y/I+LHKSa95gUM+CJfya6gHOelSWi+hkvBA=
github.com/IBM/networking-go-sdk v0.33.0/go.mod h1:7b/E21A6BmfycDuNmHjA+EhFm9iM8Wm4ULF9g93J+KE=
github.com/IBM/platform-services-go-sdk v0.28.2 h1:T5qT3XI7f3cGaMLU4v1RLsuL373K2VYfPQQeGCUauj0=
github.com/IBM/platform-services-go-sdk v0.28.2/go.mod h1:jy0Ahvj5Gkkua3Gd7t22bo0GfmHRQaPZcaqwfVgEY7k=
github.com/IBM/push-notifications-go-sdk v0.0.0-20210310100607-5790b96c47f5 h1:NPUhkoOCRuv3OFWt19PmwjXGGTKlvmbuPg9fUrBUNe4=
Expand Down Expand Up @@ -807,8 +805,9 @@ golang.org/x/sys v0.0.0-20210502180810-71e4cd670f79/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220330033206-e17cdc41300f h1:rlezHXNlxYWvBCzNses9Dlc7nGFaNMJeqLolcmQSSZY=
golang.org/x/sys v0.0.0-20220330033206-e17cdc41300f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220817070843-5a390386f1f2 h1:fqTvyMIIj+HRzMmnzr9NtpHP6uVpvB5fkHcgPDC4nu8=
golang.org/x/sys v0.0.0-20220817070843-5a390386f1f2/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 h1:JGgROgKl9N8DuW20oFS5gxc+lE67/N3FcwmBPMe7ArY=
Expand Down
22 changes: 15 additions & 7 deletions ibm/service/cis/resource_ibm_cis_firewall_rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func ResourceIBMCISFirewallrulesCreate(context context.Context, d *schema.Resour
crn := d.Get(cisID).(string)
zoneID, _, _ := flex.ConvertTftoCisTwoVar(d.Get(cisDomainID).(string))

var newFirewallRules firewallrulesv1.FirewallRuleInputWithFilterID
var newFirewallRules firewallrulesv1.FirewallRuleInput

if a, ok := d.GetOk(cisFirewallrulesAction); ok {
action := a.(string)
Expand All @@ -108,14 +108,18 @@ func ResourceIBMCISFirewallrulesCreate(context context.Context, d *schema.Resour
newFirewallRules.Description = &description
}
if id, ok := d.GetOk(cisFilterID); ok {
filterid := id.(string)
filterModel, _ := cisClient.NewFirewallRuleInputWithFilterIdFilter(filterid)
newFirewallRules.Filter = filterModel
filterID := id.(string)
filtersInterface := &firewallrulesv1.FirewallRuleInputFilter{ID: &filterID}
newFirewallRules.Filter = filtersInterface
}
if priority, ok := d.GetOk(cisFirewallrulesPriority); ok {
rulePriority := int64(priority.(int))
newFirewallRules.Priority = &rulePriority
}

opt := cisClient.NewCreateFirewallRulesOptions(xAuthtoken, crn, zoneID)

opt.SetFirewallRuleInputWithFilterID([]firewallrulesv1.FirewallRuleInputWithFilterID{newFirewallRules})
opt.SetFirewallRuleInput([]firewallrulesv1.FirewallRuleInput{newFirewallRules})

result, _, err := cisClient.CreateFirewallRulesWithContext(context, opt)
if err != nil || result == nil {
Expand Down Expand Up @@ -181,7 +185,8 @@ func ResourceIBMCISFirewallrulesUpdate(context context.Context, d *schema.Resour
if d.HasChange(cisFilterID) ||
d.HasChange(cisFirewallrulesAction) ||
d.HasChange(cisFirewallrulesPaused) ||
d.HasChange(cisFilterDescription) {
d.HasChange(cisFilterDescription) ||
d.HasChange(cisFirewallrulesPriority) {

Copy link
Collaborator

Choose a reason for hiding this comment

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

in update handle the support for change in priority

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added

var updatefirewallrules firewallrulesv1.FirewallRulesUpdateInputItem
updatefirewallrules.ID = &firewallruleID
Expand All @@ -198,7 +203,10 @@ func ResourceIBMCISFirewallrulesUpdate(context context.Context, d *schema.Resour
description := des.(string)
updatefirewallrules.Description = &description
}

if priority, ok := d.GetOk(cisFirewallrulesPriority); ok {
rulePriority := int64(priority.(int))
updatefirewallrules.Priority = &rulePriority
}
if id, ok := d.GetOk(cisFilterID); ok {
filterid := id.(string)
filterUpdate, _ := cisClient.NewFirewallRulesUpdateInputItemFilter(filterid)
Expand Down