Skip to content

feat(zones): support v2 expression syntax for sysdig_secure_zone#712

Merged
Shadow649 merged 12 commits intomasterfrom
feat-zones-v2-support
Apr 3, 2026
Merged

feat(zones): support v2 expression syntax for sysdig_secure_zone#712
Shadow649 merged 12 commits intomasterfrom
feat-zones-v2-support

Conversation

@Shadow649
Copy link
Copy Markdown
Collaborator

This pull request significantly enhances the sysdig_secure_zone data source to support v2-compatible scope expressions, improves test coverage, and updates dependency versions. The main focus is on allowing richer scope filtering via expressions, ensuring backward compatibility, and providing robust validation with new unit and acceptance tests.

Enhancements to scope expression support:

  • Added support for v2-compatible scope expressions in the sysdig_secure_zone data source by introducing new schema fields (expression, field, operator, value, values) and merging legacy rules with v2 expressions based on scope ID. This enables richer and more flexible filtering in resource definitions. [1] [2] [3] [4] [5] [6]

Testing improvements:

  • Added new acceptance tests (TestAccDataSourceSysdigSecureZone_ByName, TestAccDataSourceSysdigSecureZone_ByID) to verify expression support and correct retrieval by name and ID, as well as helper methods for test configurations.
  • Introduced unit tests for the scope merging logic to ensure correct handling of partial matches, missing IDs, and graceful degradation when v2 data is unavailable.

Dependency and API updates:

  • Updated multiple dependencies in go.mod to newer versions, including terraform-plugin-sdk, terraform-plugin-log, and several indirect dependencies for improved compatibility and security. [1] [2] [3] [4]
  • Added a new ZoneV2Interface to the client and implemented a robust APIError type with improved error extraction from API responses. [1] [2] [3]
  • Introduced new model types for v2 zones in the client (ZonesV2Wrapper, ZoneV2).

These changes collectively modernize the provider's handling of secure zones, improve error reporting, and ensure comprehensive validation through testing.

Copilot AI review requested due to automatic review settings February 25, 2026 12:15
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request adds support for v2-compatible expression syntax to the sysdig_secure_zone resource and data source, enabling richer scope filtering while maintaining backward compatibility with legacy v1 rules syntax. The implementation includes comprehensive validation, extensive testing, and detailed migration documentation.

Changes:

  • Introduced structured expression blocks (field, operator, value/values) as a modern alternative to the deprecated string-based rules syntax
  • Added field validation that ensures expression fields are compatible with their target types (e.g., agent.tag.* for kubernetes/host, label.* based on cloud provider)
  • Implemented dual API support (v1/v2) with automatic categorization logic to route requests to the appropriate backend endpoint
  • Updated client layer with new ZoneV2Interface, APIError type for improved error handling, and models for v2 zones
  • Enhanced data source to merge v1 and v2 API responses, providing both rules and expression representations

Reviewed changes

Copilot reviewed 17 out of 18 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
website/docs/r/secure_zone.md Comprehensive documentation with migration guide from rules to expression syntax, including semantic changes for labels/agentTags
website/docs/d/secure_zone.md Data source documentation explaining dual representation (rules + expressions)
sysdig/resource_sysdig_secure_zone.go Main resource implementation with CRUD operations supporting both v1 (legacy rules) and v2 (expressions) APIs
sysdig/resource_sysdig_secure_zone_validation.go Field validation logic with target-type-aware allowlists and forward compatibility for unknown fields
sysdig/data_source_sysdig_secure_zone.go Data source merging v1 and v2 API responses to provide complete scope information
sysdig/internal/client/v2/zonesV2.go New v2 zones API client implementation
sysdig/internal/client/v2/model.go V2 zone models with custom JSON marshaling for API compatibility
sysdig/internal/client/v2/client.go Enhanced error handling with structured APIError type
sysdig/*_test.go Comprehensive unit and acceptance tests covering validation, migration, and CRUD operations
go.mod, go.sum Updated terraform-plugin-sdk and related dependencies to newer versions

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread sysdig/data_source_sysdig_secure_zone.go Outdated
Comment thread sysdig/data_source_sysdig_secure_zone.go Outdated
@Shadow649 Shadow649 force-pushed the feat-zones-v2-support branch from c055d12 to 3996614 Compare February 25, 2026 12:24
Copilot AI review requested due to automatic review settings February 25, 2026 12:24
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 17 out of 18 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread sysdig/resource_sysdig_secure_zone.go
Comment thread sysdig/resource_sysdig_secure_zone_test.go
Comment thread sysdig/resource_sysdig_secure_zone_migration_test.go Outdated
Comment thread sysdig/resource_sysdig_secure_zone_migration_test.go Outdated
@Shadow649 Shadow649 force-pushed the feat-zones-v2-support branch from 3996614 to 6505ef5 Compare February 26, 2026 08:45
Copilot AI review requested due to automatic review settings February 26, 2026 08:53
@Shadow649 Shadow649 force-pushed the feat-zones-v2-support branch from 97fb2cc to 7eeb5f6 Compare February 26, 2026 08:55
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 17 out of 18 changed files in this pull request and generated 7 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread sysdig/resource_sysdig_secure_zone.go
Comment thread sysdig/resource_sysdig_secure_zone.go
Comment thread sysdig/resource_sysdig_secure_zone.go Outdated
Comment thread website/docs/r/secure_zone.md Outdated
Comment thread website/docs/r/secure_zone.md
Comment thread sysdig/resource_sysdig_secure_zone_validation_test.go Outdated
Comment thread sysdig/resource_sysdig_secure_zone.go Outdated
@Shadow649 Shadow649 force-pushed the feat-zones-v2-support branch from 7eeb5f6 to f1c66dc Compare February 26, 2026 10:09
Copilot AI review requested due to automatic review settings February 26, 2026 10:26
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@Shadow649 Shadow649 force-pushed the feat-zones-v2-support branch from 22fe4ad to 383361a Compare February 26, 2026 11:38
Copilot AI review requested due to automatic review settings March 4, 2026 09:18
@Shadow649 Shadow649 force-pushed the feat-zones-v2-support branch from 383361a to 5ebdde9 Compare March 4, 2026 09:18
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 17 out of 18 changed files in this pull request and generated 8 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread sysdig/resource_sysdig_secure_zone_validation.go Outdated
Comment thread sysdig/resource_sysdig_secure_zone.go Outdated
Comment thread sysdig/internal/client/v2/model.go Outdated
Comment thread sysdig/common.go Outdated
Comment thread sysdig/data_source_sysdig_secure_zone.go Outdated
Comment thread sysdig/data_source_sysdig_secure_zone.go Outdated
Comment thread sysdig/internal/client/v2/client.go
Comment thread sysdig/resource_sysdig_secure_zone.go
Comment thread sysdig/data_source_sysdig_secure_zone.go Outdated
Comment thread sysdig/resource_sysdig_secure_zone.go Outdated
Comment thread sysdig/resource_sysdig_secure_zone_validation.go
Comment thread sysdig/resource_sysdig_secure_zone.go
Comment thread sysdig/common.go
Comment thread sysdig/resource_sysdig_secure_zone.go Outdated
Copilot AI review requested due to automatic review settings March 4, 2026 15:17
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 17 out of 18 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread sysdig/data_source_sysdig_secure_zone.go Outdated
Comment thread sysdig/resource_sysdig_secure_zone.go
Comment thread website/docs/r/secure_zone.md Outdated
Comment thread sysdig/resource_sysdig_secure_zone_migration_test.go Outdated
Copilot AI review requested due to automatic review settings March 5, 2026 09:18
@Shadow649 Shadow649 force-pushed the feat-zones-v2-support branch from 9cbec0a to 1b71eb7 Compare March 10, 2026 15:29
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 18 out of 19 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread sysdig/resource_sysdig_secure_zone.go
Copy link
Copy Markdown
Member

@tembleking tembleking left a comment

Choose a reason for hiding this comment

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

LGTM

@Shadow649 Shadow649 added this pull request to the merge queue Mar 30, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Mar 30, 2026
@Shadow649 Shadow649 added this pull request to the merge queue Mar 30, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Mar 30, 2026
@tembleking tembleking added this pull request to the merge queue Mar 31, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Mar 31, 2026
@tembleking tembleking added this pull request to the merge queue Apr 1, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Apr 1, 2026
@Shadow649 Shadow649 added this pull request to the merge queue Apr 1, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Apr 1, 2026
@Shadow649 Shadow649 added this pull request to the merge queue Apr 3, 2026
Merged via the queue into master with commit 5c44c13 Apr 3, 2026
481 of 529 checks passed
@Shadow649 Shadow649 deleted the feat-zones-v2-support branch April 3, 2026 15:31
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.

3 participants