-
Notifications
You must be signed in to change notification settings - Fork 0
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
chore: remove retention field, clean up params/comments & write basic tests #2
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
1796bc8
chore: remove retention field, clean up dangling params/comments and …
parthpnx 6cd24fc
fix: error handling and fix to provicer constraints
parthpnx aacc93f
fix: error checking
parthpnx 71e94d0
fix: should not delete log group when resource is removed.
parthpnx 9347090
fix: pass through context to resource operations.
parthpnx 6fee54a
fix: return error with diagnostics
parthpnx 820f77d
fix: update logic and re-introduce delete funciton reporting nil
parthpnx 0e6cd53
fix: comment on delete fucntion
parthpnx 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 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 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 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 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 |
---|---|---|
@@ -1,31 +1,14 @@ | ||
package loggroup | ||
|
||
import ( | ||
// "github.com/aws/aws-sdk-go-v2/aws/session" | ||
|
||
"context" | ||
|
||
"github.com/aws/aws-sdk-go-v2/aws" | ||
"github.com/aws/aws-sdk-go-v2/service/cloudwatchlogs" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||
) | ||
|
||
// Delete the log anomaly detector. | ||
func Delete(d *schema.ResourceData, m interface{}) error { | ||
cfg := m.(aws.Config) | ||
c := cloudwatchlogs.NewFromConfig(cfg) | ||
|
||
LogGroupName := d.Get(Name).(string) | ||
|
||
_, err := c.DeleteLogGroup( | ||
context.TODO(), | ||
&cloudwatchlogs.DeleteLogGroupInput{ | ||
LogGroupName: &LogGroupName, | ||
}, | ||
) | ||
if err != nil { | ||
return err | ||
} | ||
// Delete the log group. | ||
func Delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { | ||
|
||
return nil | ||
return diag.Diagnostics{} | ||
} |
This file contains 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 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,44 @@ | ||
package loggroup | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestTrimLogGroupARNWildcardSuffix(t *testing.T) { | ||
t.Parallel() | ||
|
||
tests := []struct { | ||
name string | ||
arn string | ||
want string | ||
}{ | ||
{ | ||
name: "ARN with wildcard suffix", | ||
arn: "arn:aws:logs:us-west-2:123456789012:log-group:my-log-group:*", | ||
want: "arn:aws:logs:us-west-2:123456789012:log-group:my-log-group", | ||
}, | ||
{ | ||
name: "ARN without wildcard suffix", | ||
arn: "arn:aws:logs:us-west-2:123456789012:log-group:my-log-group", | ||
want: "arn:aws:logs:us-west-2:123456789012:log-group:my-log-group", | ||
}, | ||
{ | ||
name: "Empty ARN", | ||
arn: "", | ||
want: "", | ||
}, | ||
{ | ||
name: "ARN with multiple wildcard suffixes", | ||
arn: "arn:aws:logs:us-west-2:123456789012:log-group:my-log-group:*:*", | ||
want: "arn:aws:logs:us-west-2:123456789012:log-group:my-log-group:*", | ||
}, | ||
} | ||
|
||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
if got := TrimLogGroupARNWildcardSuffix(tt.arn); got != tt.want { | ||
t.Errorf("TrimLogGroupARNWildcardSuffix() = %v, want %v", got, tt.want) | ||
} | ||
}) | ||
} | ||
} |
This file contains 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
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.
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 we use context?
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.
and because we aren't using the retention policy we haven't used the context variable to flow through.