-
Notifications
You must be signed in to change notification settings - Fork 626
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
DLP-655 Adds support for DLP profiles #1984
Conversation
changelog detected ✅ |
42b532e
to
dbf7cf6
Compare
first merge #1995 or decline it and merge only this one |
d36130f
to
96a6b00
Compare
.changelog/1984.txt
Outdated
```release-note:enhancement | ||
resource/cloudflare_dlp_profile: adds support for DLP profiles | ||
``` |
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.
```release-note:enhancement | |
resource/cloudflare_dlp_profile: adds support for DLP profiles | |
``` | |
```release-note:new-resource | |
cloudflare_dlp_profile | |
``` |
|
||
identifier := cloudflare.AccountIdentifier(d.Get("account_id").(string)) | ||
dlpProfile, err := client.GetDLPProfile(ctx, identifier, d.Id()) | ||
if err != nil { |
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.
you'll want to be more specific here as any error that bubbles up from GetDLPProfile
will remove the DLP profile from state.
if err != nil { | |
var notFoundError *cloudflare.NotFoundError | |
if errors.As(err, ¬FoundError) { |
} | ||
|
||
func resourceCloudflareDLPProfileImport(ctx context.Context, d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { | ||
attributes := strings.SplitN(d.Id(), "/", 3) |
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.
i think you can do accountID/dlpProfileID
for the import string instead. unless you're planning on supporting this at the zone level too?
Required: true, | ||
ForceNew: true, | ||
}, | ||
"id": { |
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.
id
is a reserved keyword in Terraform schemas that is automatically handled; you don't need an entry for it.
Required: true, | ||
ForceNew: true, | ||
ValidateFunc: validation.StringInSlice([]string{DLPProfileTypeCustom, DLPProfileTypePredefined}, false), | ||
Description: "The type of the profile - either 'predefined' or 'custom'.", |
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.
we can swap this to use the documentation helper and it will generate the correctly formatted output for the generated docs.
Description: "The type of the profile - either 'predefined' or 'custom'.", | |
Description: fmt.Sprintf("The type of the profile. %s", renderAvailableDocumentationValuesStringSlice([]string{DLPProfileTypeCustom, DLPProfileTypePredefined})), |
@@ -0,0 +1,99 @@ | |||
package provider |
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.
let's rename this file for consistency too; schema_dlp_profiles.go
-> schema_cloudflare_dlp_profiles.go
ad9ff50
to
a7dbcf6
Compare
pending getting the functionality enabled on the acceptance testing account. otherwise, we're looking good for now! |
acceptance tests are all passing now
|
This functionality has been released in v3.27.0 of the Terraform Cloudflare Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you! |
Builds will fail as this depends on the next cloudflare-go release