Skip to content

Conversation

sidshas03
Copy link

  • Add 'type' field to cloudstack_network resource schema
  • Make 'cidr' field conditionally required based on network type
  • L2 networks: cidr not required, IP parameters skipped
  • L3 networks: cidr required, maintains backward compatibility
  • Add CustomizeDiff validation for proper type/cidr combinations
  • Update parseCIDR function to handle L2 networks without cidr
  • Update resource creation logic to skip IP config for L2 networks
  • Update read function to detect and set network type
  • Add comprehensive test coverage for L2 networks
  • Update documentation with L2 and L3 usage examples

Fixes #214

- Add 'type' field to cloudstack_network resource schema
- Make 'cidr' field conditionally required based on network type
- L2 networks: cidr not required, IP parameters skipped
- L3 networks: cidr required, maintains backward compatibility
- Add CustomizeDiff validation for proper type/cidr combinations
- Update parseCIDR function to handle L2 networks without cidr
- Update resource creation logic to skip IP config for L2 networks
- Update read function to detect and set network type
- Add comprehensive test coverage for L2 networks
- Update documentation with L2 and L3 usage examples

Fixes apache#214
@kiranchavala
Copy link
Collaborator

Thanks @sidshas03 , could you please check the test failures and rectify them

- Fix formatting issues in resource_cloudstack_network.go
- Fix formatting issues in resource_cloudstack_instance.go
- Ensures CI formatting checks pass without changing functionality
- Add TestResourceCloudStackNetworkSchema to validate schema structure
- Add TestParseCIDR to test CIDR parsing logic for both L2 and L3 networks
- Verify L2 networks return empty CIDR parsing results
- Verify L3 networks require CIDR and parse correctly
- All tests pass, ensuring functionality works as expected
- Add Apache License, Version 2.0 header to resource_cloudstack_network_parse_test.go
- Add Apache License, Version 2.0 header to resource_cloudstack_network_validation_test.go
- Addresses code review feedback from DaanHoogland
- Ensures compliance with Apache Software Foundation licensing requirements
@sidshas03 sidshas03 force-pushed the feature/l2-network-cidr-optional branch from 7676559 to 440ec8c Compare September 16, 2025 11:46
@sidshas03
Copy link
Author

Hi @DaanHoogland & @kiranchavala,

Just putting down the commit history clearly so you both know what happened and why:

  • First I added the unit tests for L2/L3 validation (e9b39ff). CI failed there because I had missed adding the Apache license headers.

  • Then I did some formatting fixes (46944cc).

  • After that there was a mistake commit which removed the test files (7676559). That was not correct, so I dropped it.

  • Latest commit (440ec8c) adds the proper Apache 2.0 license headers to the test files and keeps everything intact.

  • Now the branch has the tests intact, formatting is proper, and the license headers are in place.

  • Once you approver run, I’ll handle any CI failures with only safe fixes (no test deletions, no schema or validation changes).

Thanks for the reviews so far. Requesting you to please review the workflows when convenient.

- Remove trailing whitespace from test files
- Ensures CI formatting checks pass
- No functional changes to code logic
@kiranchavala
Copy link
Collaborator

@sidshas03 still there are test failures please look into them

…mizeDiff, normalize L2 in Read; plus errcheck fix

- Make type field Optional+Computed to prevent drift when config omits it
- Default type from cidr presence in CustomizeDiff (cidr present = L3, absent = L2)
- Normalize L2 networks in Read by clearing cidr/gateway to prevent plan drift
- Fix unchecked errors in resource_cloudstack_configuration.go
- Update validation tests to reflect new schema behavior

This ensures backward compatibility - existing configs without explicit type
will continue to work without modification.
@kiranchavala
Copy link
Collaborator

@sidshas03 could you please look into the failing tests

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.

cloudstack_network resource should not require "cidr" arg when network "type" is "L2"
3 participants