-
Notifications
You must be signed in to change notification settings - Fork 55
feat(zones): support v2 expression syntax for sysdig_secure_zone #712
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
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
4896d0b
feat(zones): support v2 expression syntax for sysdig_secure_zone
Shadow649 ef39f44
fix copilot comments
Shadow649 8cadfc2
address code review comments
Shadow649 f46b3b4
Apply suggestions from code review
Shadow649 f55f7dc
move to a better name
Shadow649 0dc51c0
address code review comment about serialization and comments
Shadow649 b9897f1
add timeout
Shadow649 647b999
add tests for common api responses
Shadow649 1eb46dd
flattening functions
Shadow649 8e36619
apply reviewer suggestion
Shadow649 676f808
fixing error message
Shadow649 1b71eb7
mod tidy
Shadow649 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| package sysdig | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| v2 "github.com/draios/terraform-provider-sysdig/sysdig/internal/client/v2" | ||
| ) | ||
|
|
||
| func TestGetZoneScopes_MatchByID(t *testing.T) { | ||
| zoneV2 := &v2.ZoneV2{ | ||
| Scopes: []v2.ScopeV2{ | ||
| { | ||
| Filters: []v2.FilterV2{ | ||
| { | ||
| ID: 10, | ||
| ResourceType: "kubernetes", | ||
| Expressions: []v2.ExpressionV2{ | ||
| {Field: "cluster", Operator: "in", Values: []string{"a"}}, | ||
| }, | ||
| }, | ||
| { | ||
| ID: 20, | ||
| ResourceType: "kubernetes", | ||
| Expressions: []v2.ExpressionV2{ | ||
| {Field: "cluster", Operator: "in", Values: []string{"b"}}, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| } | ||
|
|
||
| result := getZoneScopes(zoneV2) | ||
| if len(result) != 2 { | ||
| t.Fatalf("expected 2 scopes, got %d", len(result)) | ||
| } | ||
|
|
||
| // Verify each scope got its own expressions by checking the ID-expression pairing. | ||
| for _, raw := range result { | ||
| scope := raw.(map[string]any) | ||
| id := scope[SchemaIDKey].(int) | ||
| exprs, ok := scope[SchemaExpressionKey].([]any) | ||
| if !ok || len(exprs) != 1 { | ||
| t.Fatalf("scope ID=%d: expected 1 expression, got %v", id, scope[SchemaExpressionKey]) | ||
| } | ||
| expr := exprs[0].(map[string]any) | ||
| vals := expr["values"].([]string) | ||
| if id == 10 && vals[0] != "a" { | ||
| t.Errorf("scope ID=10: expected values [a], got %v", vals) | ||
| } | ||
| if id == 20 && vals[0] != "b" { | ||
| t.Errorf("scope ID=20: expected values [b], got %v", vals) | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.