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

[FWaaS_V2] Add FW Group V2 datasource #1589

Conversation

Koodt
Copy link
Contributor

@Koodt Koodt commented Jun 29, 2023

Add dataSourceFWGroupV2 with tests
Add docs
Enable openstack_fw_group_v2 in provider.go

Close #115

Add dataSourceFWGroupV2 wuth tests
Add docs
Enable openstack_fw_group_v2 in provider.go
Copy link
Member

@nikParasyr nikParasyr left a 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)
Copy link
Member

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@nikParasyr nikParasyr requested a review from kayrus June 29, 2023 10:41
* `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.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
`project_id`.The owner of the firewall group.
`project_id`. The owner of the firewall group.

Copy link
Contributor Author

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.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
`tenant_id`.The owner of the firewall group.
`tenant_id`. The owner of the firewall group.

Copy link
Contributor Author

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,
Copy link
Collaborator

@kayrus kayrus Jun 29, 2023

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Add

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Decided to remove Optional

Copy link
Collaborator

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Understood
Add

Copy link
Collaborator

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?

Copy link
Contributor Author

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,
Copy link
Collaborator

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Remove Optional, add Computed

Copy link
Collaborator

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?

Copy link
Contributor Author

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.

Copy link
Collaborator

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)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
listOpts.ProjectID = v.(string)
listOpts.TenantID = v.(string)

Copy link
Contributor Author

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)
Copy link
Member

Choose a reason for hiding this comment

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

openstack_fw_group_v2

Copy link
Contributor Author

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.
Copy link
Collaborator

@kayrus kayrus Jun 29, 2023

Choose a reason for hiding this comment

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

Suggested change
* `ports` - Port(s) to associate this firewall group with.
* `ports` - Ports associated with the firewall group.

Copy link
Contributor Author

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.
Copy link
Collaborator

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.

Copy link
Contributor Author

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"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
name = "tf_test_group"
name = "tf_test_group"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@Koodt
Copy link
Contributor Author

Koodt commented Jun 29, 2023

@kayrus @nikParasyr Great job, thank you!
Merge?)

Copy link
Collaborator

@kayrus kayrus left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@nikParasyr nikParasyr merged commit a136aee into terraform-provider-openstack:main Jun 29, 2023
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feature request: support for FWaaS v2.0
3 participants