-
Notifications
You must be signed in to change notification settings - Fork 7
pingone_davinci_application beta resource #1138
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
Open
henryrecker-pingidentity
wants to merge
102
commits into
main
Choose a base branch
from
DavinciApplicationResource
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 98 commits
Commits
Show all changes
102 commits
Select commit
Hold shift + click to select a range
3eb1b14
An initial draft of davinci codegen
henryrecker-pingidentity aeaa9ad
Updated fully-generated draft
henryrecker-pingidentity 6d75ebe
Initial working resource, moving legacy sdk funcs to separate child p…
henryrecker-pingidentity 99b8198
Fixes based on initial testing
henryrecker-pingidentity e662e89
Basic acceptance test
henryrecker-pingidentity 2891e68
Move retry logic for new sdk into framework package
henryrecker-pingidentity 0720ec4
Add tests for all variable types
henryrecker-pingidentity e895032
Handle secrets with separate sensitive attribute
henryrecker-pingidentity f157a31
Simplify error handling in new SDK
henryrecker-pingidentity e3089a6
Add resource-level validation
henryrecker-pingidentity 005626b
Check for id presence in error handling
henryrecker-pingidentity 79dc835
Use mux for a new provider with the new client
henryrecker-pingidentity 65aa4db
Merge branch 'main' into DavinciVarInitialGenDraft
henryrecker-pingidentity 3addb81
Move custom ValidateConfig to separate file
henryrecker-pingidentity e85bfcc
Reorder alphabetically
henryrecker-pingidentity bfc7636
Select region for acctest client
henryrecker-pingidentity a146439
Set user agent correctly
henryrecker-pingidentity 451c613
WIP generated dv connector instance
henryrecker-pingidentity 7009c41
Fix for unneeded error and diagnostics
henryrecker-pingidentity 6c65324
Regenerated resource and tests
henryrecker-pingidentity ebbb1bd
WIP
henryrecker-pingidentity 7ea3317
Handle non-UUID field
henryrecker-pingidentity 2ef8fd8
Handle non-uuid id and get basic tests working
henryrecker-pingidentity 6787d94
Add connector.id RequiresReplace, fix import regex, improve tests
henryrecker-pingidentity 53b7e70
Custom error for DV-ignored properties
henryrecker-pingidentity 63bb75e
Mark connector.id as required
henryrecker-pingidentity f33ecfc
Initial generated application resource with a successful create
henryrecker-pingidentity af5d041
Remove unneeded api_key_enabled attr
henryrecker-pingidentity 28c640a
Generate correct computed+optional+required
henryrecker-pingidentity d6d9edd
Generate with enum and validator fixes
henryrecker-pingidentity 7013c3f
Manual schema fixes
henryrecker-pingidentity e054ceb
Flesh out test HCL
henryrecker-pingidentity 2a39c61
Build update request after create
henryrecker-pingidentity fe2ef4b
Fix wrong ID for post-create update
henryrecker-pingidentity 530fab5
Davinci import regex
henryrecker-pingidentity f6aeadb
Schema defaults and set apiKeyEnabled in update
henryrecker-pingidentity a4edbe1
Test workarounds
henryrecker-pingidentity 8118149
Fix properties read on imports
henryrecker-pingidentity cfb0b29
Fix attr name
henryrecker-pingidentity dbaa08d
Move handwritten code to separate file
henryrecker-pingidentity 6670cfd
Add examples and generate docs
henryrecker-pingidentity 3802255
Add more extensive tests
henryrecker-pingidentity 38871e0
Regenerate doc
henryrecker-pingidentity 59dddf6
Remove superfluous notes
henryrecker-pingidentity 48f140c
Handle error in test region suffix build
henryrecker-pingidentity 236f685
Add SG domain and fix user agent append
henryrecker-pingidentity a4c6782
Improve error output when no error ID present
henryrecker-pingidentity b037a9b
Add examples and docs and lint
henryrecker-pingidentity 5a2d065
Initial complex properties test
henryrecker-pingidentity 1a6c370
Passing complex tests, with secrets commented out
henryrecker-pingidentity ff796cf
Implement jsontypes.NormalizedObfuscatable
henryrecker-pingidentity 8c20ed8
Use new json type in connector instance tests
henryrecker-pingidentity 5d7410b
Mark properties as sensitive and format tests
henryrecker-pingidentity 7409c77
Simplify test
henryrecker-pingidentity 52a7f9c
Add test to cover optional properties and drift detection
henryrecker-pingidentity 82a01c9
Cover modifying a sensitive attribute
henryrecker-pingidentity a3f4a25
Create davinci bootstrapped test env
henryrecker-pingidentity b2ef63e
Test bootstrapped and non bootstrapped DV env
henryrecker-pingidentity b4d09f7
Create davinci bootstrapped test env
henryrecker-pingidentity c45ef8e
Add tests covering bootstrapped DV env
henryrecker-pingidentity acd7171
Update to released client
henryrecker-pingidentity 3bda7d1
Extend application tests, default all oauth sets to empty
henryrecker-pingidentity 216179b
Create davinci bootstrapped test env
henryrecker-pingidentity c4f9092
Fill out tests for bootstrap and jwks
henryrecker-pingidentity a040cd6
Add examples and doc
henryrecker-pingidentity 9c1d3f8
Add placeholder expand value to env read calls
henryrecker-pingidentity 71da389
Changelog
henryrecker-pingidentity cccd787
Merge branch 'main' into DavinciVarInitialGenDraft
henryrecker-pingidentity 01d2be7
Merge branch 'main' into DavinciVarInitialGenDraft
henryrecker-pingidentity 23366ee
Fix mismatched provider schemas
henryrecker-pingidentity 218a4a3
Add missing test util method for new SDK
henryrecker-pingidentity e0685c8
Avoid printing empty errors
henryrecker-pingidentity 0e660f1
Update client version and remove placeholder expand values in tests
henryrecker-pingidentity ec21f58
Changelog update
henryrecker-pingidentity 8f86338
Cleanup
henryrecker-pingidentity 127fcbd
Schema cleanup
henryrecker-pingidentity 107c9d3
Cleanup todos
henryrecker-pingidentity da32ce1
Cleanup schema
henryrecker-pingidentity 93012ed
Lower-case region code when getting TLD
henryrecker-pingidentity 54c9173
Move davinci env creation sweep to separate file
henryrecker-pingidentity 8ff187a
Update client version
henryrecker-pingidentity 198e3d8
Add retry wrapper for new sdk
henryrecker-pingidentity 5e3ac55
Merge branch 'DavinciVarInitialGenDraft' into DavinciConnectorInstanc…
henryrecker-pingidentity 15413c9
Merge branch 'DavinciConnectorInstanceResource' into DavinciApplicati…
henryrecker-pingidentity 183b445
Fix forgotten conflict
henryrecker-pingidentity bc209df
Merge branch 'DavinciConnectorInstanceResource' into DavinciApplicati…
henryrecker-pingidentity 2cef201
Merge branch 'main' into DavinciConnectorInstanceResource
henryrecker-pingidentity 38da6d5
Marking connector instance as beta
henryrecker-pingidentity f9f5b07
Regenerate docs, removing beta resources
henryrecker-pingidentity b163e5f
Add note in beta.md with example test command
henryrecker-pingidentity a6ad025
Make command easier to copy
henryrecker-pingidentity 74a4d60
Remove duplicate sweep env creation
henryrecker-pingidentity 3149c94
Merge branch 'DavinciConnectorInstanceResource' into DavinciApplicati…
henryrecker-pingidentity c957fce
Mark davinci_application as beta
henryrecker-pingidentity 3f2456a
Fix incorrect test precheck
henryrecker-pingidentity 6dd1f76
Handle false value for enforce_signed_request_openid
c01a946
Merge branch 'main' into DavinciConnectorInstanceResource
henryrecker-pingidentity 304a686
Merge branch 'DavinciConnectorInstanceResource' into DavinciApplicati…
henryrecker-pingidentity d9ae6ba
Merge branch 'main' into DavinciApplicationResource
henryrecker-pingidentity ae83d73
Add null and unknown check
henryrecker-pingidentity f3949d0
Fix duplicate resource declaration
henryrecker-pingidentity 112cded
Replace example.com with pingidentity.com in tests
henryrecker-pingidentity 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| --- | ||
| page_title: "{{.Name}} {{.Type}} - {{.RenderedProviderName}}" | ||
| subcategory: "DaVinci" | ||
| description: |- | ||
| {{ .Description | plainmarkdown | trimspace | prefixlines " " }} | ||
| --- | ||
|
|
||
| # {{.Name}} ({{.Type}}) | ||
|
|
||
| {{ .Description | trimspace }} | ||
|
|
||
| {{ if .HasExample -}} | ||
| ## Example Usage | ||
|
|
||
| {{ tffile (printf "%s%s%s" "examples/resources/" .Name "/resource.tf") }} | ||
| {{- end }} | ||
|
|
||
| {{ .SchemaMarkdown | trimspace }} | ||
|
|
||
| {{ if .HasImport -}} | ||
| ## Import | ||
|
|
||
| Import is supported using the following syntax, where attributes in `<>` brackets are replaced with the relevant ID. For example, `<environment_id>` should be replaced with the ID of the environment to import from. | ||
|
|
||
| {{ codefile "shell" (printf "%s%s%s" "examples/resources/" .Name "/import.sh") }} | ||
| {{- end }} |
27 changes: 27 additions & 0 deletions
27
betatemplates/resources/davinci_connector_instance.md.tmpl
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,27 @@ | ||
| --- | ||
| page_title: "{{.Name}} {{.Type}} - {{.RenderedProviderName}}" | ||
| subcategory: "DaVinci" | ||
| description: |- | ||
| {{ .Description | plainmarkdown | trimspace | prefixlines " " }} | ||
| --- | ||
|
|
||
| # {{.Name}} ({{.Type}}) | ||
|
|
||
| {{ .Description | trimspace }} | ||
|
|
||
| {{ if .HasExample -}} | ||
| ## Example Usage | ||
|
|
||
| {{ tffile (printf "%s%s%s" "examples/resources/" .Name "/resource.tf") }} | ||
| {{- end }} | ||
|
|
||
| {{ .SchemaMarkdown | trimspace }} | ||
|
|
||
| {{ if .HasImport -}} | ||
| ## Import | ||
|
|
||
| Import is supported using the following syntax, where attributes in `<>` brackets are replaced with the relevant ID. For example, `<environment_id>` should be replaced with the ID of the environment to import from. | ||
|
|
||
| {{ codefile "shell" (printf "%s%s%s" "examples/resources/" .Name "/import.sh") }} | ||
| {{- end }} | ||
|
|
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 @@ | ||
| terraform import pingone_davinci_application.example <environment_id>/<application_id> |
44 changes: 44 additions & 0 deletions
44
examples/resources/pingone_davinci_application/resource.tf
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,44 @@ | ||
| resource "pingone_davinci_application" "my_awesome_application" { | ||
| environment_id = var.pingone_environment_id | ||
|
|
||
| name = "My Awesome Application" | ||
|
|
||
| oauth = { | ||
| grant_types = ["authorizationCode"] | ||
| scopes = ["openid", "profile"] | ||
| enforce_signed_request_openid = false | ||
| redirect_uris = ["https://auth.pingone.com/0000-0000-000/rp/callback/openid_connect"] | ||
| } | ||
| } | ||
|
|
||
| resource "pingone_davinci_application_flow_policy" "authentication_flow_policy" { | ||
| environment_id = var.pingone_environment_id | ||
| application_id = pingone_davinci_application.my_awesome_application.id | ||
|
|
||
| name = "PingOne - Authentication" | ||
| status = "enabled" | ||
|
|
||
| flow_distributions = [ | ||
| { | ||
| flow_id = pingone_davinci_flow.authentication.id | ||
| version = -1 | ||
| weight = 100 | ||
| } | ||
| ] | ||
| } | ||
|
|
||
| resource "pingone_davinci_application_flow_policy" "registration_flow_policy" { | ||
| environment_id = var.pingone_environment_id | ||
| application_id = pingone_davinci_application.my_awesome_application.id | ||
|
|
||
| name = "PingOne - Registration" | ||
| status = "enabled" | ||
|
|
||
| flow_distributions = [ | ||
| { | ||
| flow_id = pingone_davinci_flow.registration.id | ||
| version = -1 | ||
| weight = 100 | ||
| } | ||
| ] | ||
| } | ||
1 change: 1 addition & 0 deletions
1
examples/resources/pingone_davinci_connector_instance/import.sh
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 @@ | ||
| terraform import pingone_davinci_connector_instance.example <environment_id>/<instance_id> |
24 changes: 24 additions & 0 deletions
24
examples/resources/pingone_davinci_connector_instance/resource.tf
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,24 @@ | ||
| resource "pingone_davinci_connector_instance" "annotation_connector_example" { | ||
| environment_id = var.pingone_environment_id | ||
|
|
||
| connector = { | ||
| id = "annotationConnector" | ||
| } | ||
|
|
||
| name = "myAnnotationConnector" | ||
| } | ||
|
|
||
| resource "pingone_davinci_connector_instance" "crowdstrike_connector_example" { | ||
| environment_id = var.pingone_environment_id | ||
|
|
||
| connector = { | ||
| id = "crowdStrikeConnector" | ||
| } | ||
|
|
||
| name = "CrowdStrike" | ||
|
|
||
| properties = jsonencode({ | ||
| "clientId" : var.crowdstrike_client_id, | ||
| "clientSecret" : var.crowdstrike_client_secret | ||
| }) | ||
| } |
73 changes: 73 additions & 0 deletions
73
internal/framework/customtypes/jsontypes/normalized_obfuscatable_type.go
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,73 @@ | ||
| // Copyright © 2025 Ping Identity Corporation | ||
|
|
||
| package jsontypes | ||
|
|
||
| import ( | ||
| "context" | ||
| "fmt" | ||
|
|
||
| "github.com/hashicorp/terraform-plugin-framework/attr" | ||
| "github.com/hashicorp/terraform-plugin-framework/diag" | ||
| "github.com/hashicorp/terraform-plugin-framework/types/basetypes" | ||
| "github.com/hashicorp/terraform-plugin-go/tftypes" | ||
| ) | ||
|
|
||
| // Ensure the implementation satisfies the expected interfaces | ||
| var _ basetypes.StringTypable = NormalizedObfuscatableType{} | ||
|
|
||
| // NormalizedObfuscatableType is a custom type for handling JSON strings that might contain | ||
| // obfuscated fields (represented as a string with non-zero length made up of only asterisks). | ||
| // It allows for semantic equality checking that ignores these obfuscated fields. | ||
| type NormalizedObfuscatableType struct { | ||
| basetypes.StringType | ||
| } | ||
|
|
||
| func (t NormalizedObfuscatableType) Equal(o attr.Type) bool { | ||
| other, ok := o.(NormalizedObfuscatableType) | ||
|
|
||
| if !ok { | ||
| return false | ||
| } | ||
|
|
||
| return t.StringType.Equal(other.StringType) | ||
| } | ||
|
|
||
| func (t NormalizedObfuscatableType) String() string { | ||
| return "jsontypes.NormalizedObfuscatableType" | ||
| } | ||
|
|
||
| func (t NormalizedObfuscatableType) ValueFromString(ctx context.Context, in basetypes.StringValue) (basetypes.StringValuable, diag.Diagnostics) { | ||
| // NormalizedObfuscatableValue defined in the value type file | ||
| value := NormalizedObfuscatableValue{ | ||
| StringValue: in, | ||
| } | ||
|
|
||
| return value, nil | ||
| } | ||
|
|
||
| func (t NormalizedObfuscatableType) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error) { | ||
| attrValue, err := t.StringType.ValueFromTerraform(ctx, in) | ||
|
|
||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| stringValue, ok := attrValue.(basetypes.StringValue) | ||
|
|
||
| if !ok { | ||
| return nil, fmt.Errorf("unexpected value type of %T", attrValue) | ||
| } | ||
|
|
||
| stringValuable, diags := t.ValueFromString(ctx, stringValue) | ||
|
|
||
| if diags.HasError() { | ||
| return nil, fmt.Errorf("unexpected error converting StringValue to StringValuable: %v", diags) | ||
| } | ||
|
|
||
| return stringValuable, nil | ||
| } | ||
|
|
||
| func (t NormalizedObfuscatableType) ValueType(ctx context.Context) attr.Value { | ||
| // NormalizedObfuscatableValue defined in the value type file | ||
| return NormalizedObfuscatableValue{} | ||
| } |
150 changes: 150 additions & 0 deletions
150
internal/framework/customtypes/jsontypes/normalized_obfuscatable_value.go
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,150 @@ | ||
| // Copyright © 2025 Ping Identity Corporation | ||
|
|
||
| package jsontypes | ||
|
|
||
| import ( | ||
| "context" | ||
| "encoding/json" | ||
| "fmt" | ||
|
|
||
| "github.com/google/go-cmp/cmp" | ||
| "github.com/hashicorp/terraform-plugin-framework/attr" | ||
| "github.com/hashicorp/terraform-plugin-framework/attr/xattr" | ||
| "github.com/hashicorp/terraform-plugin-framework/diag" | ||
| "github.com/hashicorp/terraform-plugin-framework/types/basetypes" | ||
| ) | ||
|
|
||
| // Ensure the implementation satisfies the expected interfaces | ||
| var _ basetypes.StringValuable = NormalizedObfuscatableValue{} | ||
| var _ basetypes.StringValuableWithSemanticEquals = NormalizedObfuscatableValue{} | ||
| var _ xattr.ValidateableAttribute = NormalizedObfuscatableValue{} | ||
|
|
||
| // Alias useful in schemas and structs | ||
| type NormalizedObfuscatable = NormalizedObfuscatableValue | ||
|
|
||
| // NormalizedObfuscatableValue is a custom value for handling JSON strings that might contain | ||
| // obfuscated fields (represented as a string with non-zero length made up of only asterisks). | ||
| // It allows for semantic equality checking that ignores these obfuscated fields. | ||
| type NormalizedObfuscatableValue struct { | ||
| basetypes.StringValue | ||
| } | ||
|
|
||
| func (v NormalizedObfuscatableValue) Equal(o attr.Value) bool { | ||
| other, ok := o.(NormalizedObfuscatableValue) | ||
|
|
||
| if !ok { | ||
| return false | ||
| } | ||
|
|
||
| return v.StringValue.Equal(other.StringValue) | ||
| } | ||
|
|
||
| func (v NormalizedObfuscatableValue) Type(ctx context.Context) attr.Type { | ||
| return NormalizedObfuscatableType{} | ||
| } | ||
|
|
||
| func (v NormalizedObfuscatableValue) StringSemanticEquals(ctx context.Context, newValuable basetypes.StringValuable) (bool, diag.Diagnostics) { | ||
| var diags diag.Diagnostics | ||
|
|
||
| // The framework should always pass the correct value type, but always check | ||
| newValue, ok := newValuable.(NormalizedObfuscatableValue) | ||
|
|
||
| if !ok { | ||
| diags.AddError( | ||
| "JSON String Type Semantic Equality Check Error", | ||
| "An unexpected value type was received while performing semantic equality checks. "+ | ||
| "Please report this to the provider developers.\n\n"+ | ||
| "Expected Value Type: "+fmt.Sprintf("%T", v)+"\n"+ | ||
| "Got Value Type: "+fmt.Sprintf("%T", newValuable), | ||
| ) | ||
|
|
||
| return false, diags | ||
| } | ||
|
|
||
| return semanticCompareJsonIgnoreObfuscated(v.StringValue.ValueString(), newValue.StringValue.ValueString()), diags | ||
| } | ||
|
|
||
| // Semantically compare the json blobs, ignoring fields that are strings of asterisks, which may have been obfuscated | ||
| func semanticCompareJsonIgnoreObfuscated(json1, json2 string) bool { | ||
| var marshalled1, marshalled2 map[string]interface{} | ||
|
|
||
| // Unmarshal both JSON blobs into generic maps. Return false if parsing fails. | ||
| if err := json.Unmarshal([]byte(json1), &marshalled1); err != nil { | ||
| return false | ||
| } | ||
| if err := json.Unmarshal([]byte(json2), &marshalled2); err != nil { | ||
| return false | ||
| } | ||
|
|
||
| ignoreRedactedFields := cmp.FilterPath(func(p cmp.Path) bool { | ||
| // Get the values being compared at the current path | ||
| vx, vy := p.Last().Values() | ||
|
|
||
| if !vx.IsValid() || !vy.IsValid() { | ||
| return false | ||
| } | ||
|
|
||
| vxStr, okX := vx.Interface().(string) | ||
| vyStr, okY := vy.Interface().(string) | ||
|
|
||
| // If the values are strings, and one or both are strings of asterisks, we ignore this path | ||
| if okX && okY { | ||
| return isAllAsterisks(vxStr) || isAllAsterisks(vyStr) | ||
| } | ||
| return false | ||
| }, cmp.Ignore()) | ||
|
|
||
| return cmp.Equal(marshalled1, marshalled2, ignoreRedactedFields) | ||
| } | ||
|
|
||
| func isAllAsterisks(s string) bool { | ||
| if len(s) == 0 { | ||
| return false | ||
| } | ||
| for _, char := range s { | ||
| if char != '*' { | ||
| return false | ||
| } | ||
| } | ||
| return true | ||
| } | ||
|
|
||
| func NormalizedObfuscatableNull() NormalizedObfuscatableValue { | ||
| return NormalizedObfuscatableValue{ | ||
| StringValue: basetypes.NewStringNull(), | ||
| } | ||
| } | ||
|
|
||
| func NormalizedObfuscatableUnknown() NormalizedObfuscatableValue { | ||
| return NormalizedObfuscatableValue{ | ||
| StringValue: basetypes.NewStringUnknown(), | ||
| } | ||
| } | ||
|
|
||
| func NormalizedObfuscatableStringValue(value string) NormalizedObfuscatableValue { | ||
| return NormalizedObfuscatableValue{ | ||
| StringValue: basetypes.NewStringValue(value), | ||
| } | ||
| } | ||
|
|
||
| func NormalizedObfuscatableStringPointerValue(value *string) NormalizedObfuscatableValue { | ||
| return NormalizedObfuscatableValue{ | ||
| StringValue: basetypes.NewStringPointerValue(value), | ||
| } | ||
| } | ||
|
|
||
| func (v NormalizedObfuscatableValue) ValidateAttribute(ctx context.Context, req xattr.ValidateAttributeRequest, resp *xattr.ValidateAttributeResponse) { | ||
| if v.IsNull() || v.IsUnknown() { | ||
| return | ||
| } | ||
|
|
||
| // Validate that the string is valid JSON | ||
| var jsonData interface{} | ||
| if err := json.Unmarshal([]byte(v.ValueString()), &jsonData); err != nil { | ||
| resp.Diagnostics.AddAttributeError( | ||
| req.Path, | ||
| "JSON String Type Validation Error", | ||
| fmt.Sprintf("The value could not be unmarshalled as JSON: %s", err.Error()), | ||
| ) | ||
| } | ||
| } |
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
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.