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
[FWaaS_V2] Add FW Group V2 datasource #1589
[FWaaS_V2] Add FW Group V2 datasource #1589
Conversation
Add dataSourceFWGroupV2 wuth tests Add docs Enable openstack_fw_group_v2 in provider.go
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit for proper log messages
|
||
pages, err := groups.List(networkingClient, listOpts).AllPages() | ||
if err != nil { | ||
return diag.Errorf("Unable to list Groups: %s", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
openstack_fw_group_v2
groups
Same in the messages below
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
* `group_id` - (Optional) The ID of the firewall group. | ||
|
||
* `tenant_id` - (Optional) - This argument conflict and interchangeable with | ||
`project_id`.The owner of the firewall group. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
`project_id`.The owner of the firewall group. | |
`project_id`. The owner of the firewall group. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix
`project_id`.The owner of the firewall group. | ||
|
||
* `project_id` - (Optional) - This argument conflict and interchangeable with | ||
`tenant_id`.The owner of the firewall group. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
`tenant_id`.The owner of the firewall group. | |
`tenant_id`. The owner of the firewall group. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix
"status": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Optional: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
status
is marked optional, but it's not set in the listOpts
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Decided to remove Optional
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why? It might be useful to filter groups, which are active.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Understood
Add
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you also adjust the docs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, sorry
|
||
"ports": { | ||
Type: schema.TypeList, | ||
Optional: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ports
marked as optional, but not used in the listOpts
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove Optional
, add Computed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here as well. What if you want to look for a group that is assigned to a particular port?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There may be problems with the order of the ports in the request.
We can only request a strictly matching list. If the resulting datasource is used to add a port to it, then we can get a loop.
We cannot query a group whose ports partially match. We will need to request a list of all groups and then filter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, makes sense
} | ||
|
||
if v, ok := d.GetOk("tenant_id"); ok { | ||
listOpts.ProjectID = v.(string) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
listOpts.ProjectID = v.(string) | |
listOpts.TenantID = v.(string) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix
|
||
group := allGroups[0] | ||
|
||
log.Printf("[DEBUG] Retrieved Group %s: %+v", group.ID, group) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
openstack_fw_group_v2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
* `admin_state_up` - Administrative up/down status for the firewall group. | ||
* `ingress_firewall_policy_id` - See Argument Reference above. | ||
* `egress_firewall_policy_id` - See Argument Reference above. | ||
* `ports` - Port(s) to associate this firewall group with. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* `ports` - Port(s) to associate this firewall group with. | |
* `ports` - Ports associated with the firewall group. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok
* `tenant_id` - See Argument Reference above. | ||
* `project_id` - See Argument Reference above. | ||
* `shared` - See Argument Reference above. | ||
* `admin_state_up` - Administrative up/down status for the firewall group. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The admin_state_up
should be defined in arguments as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
|
||
```hcl | ||
data "openstack_fw_group_v2" "group" { | ||
name = "tf_test_group" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
name = "tf_test_group" | |
name = "tf_test_group" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@kayrus @nikParasyr Great job, thank you! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
a136aee
into
terraform-provider-openstack:main
Add dataSourceFWGroupV2 with tests
Add docs
Enable openstack_fw_group_v2 in provider.go
Close #115