resource/pingone_application: add export support - #137
Closed
samir-gandhi wants to merge 3 commits into
Closed
Conversation
…sources pingone-go-client only covers DaVinci, Environments, Connectors, and ConfigurationManagement APIs, so the ~92 open Platform/SSO/Authorize/MFA/ Protect/Verify export-support issues cannot be implemented against it. Add patrickcping/pingone-go-sdk-v2/management (the SDK terraform-provider- pingone itself uses) as a second client on Client, built lazily since it performs an OAuth exchange at construction time rather than on first request.
The go:embed directive listed pingone/base and pingone/davinci explicitly, so every new resource category (sso, platform, mfa, ...) would require editing this file — violating the "new resource requires zero edits to existing files" invariant. A single pingone/*/*.yaml wildcard covers any category subdirectory automatically.
Adds a schema-driven definition and Go handler for pingone_application, covering OIDC, SAML, External Link, and WS-Fed application types (the four the pingone_application Terraform resource schema actually supports). The management SDK's ReadOneApplication200Response is a discriminated union with 7 possible variants; a custom handler unwraps it via GetActualInstance() and projects the result into a flat struct with one nilable field per supported variant, letting the generic object/ nested_attributes engine emit exactly one *_options block per resource. The 3 built-in PingOne system application types (Admin Console, Portal, Self Service) have no corresponding schema block in the provider and are skipped with a warning (c.AddWarning) rather than exported incorrectly. Also bumps the hardcoded definition-count assertions in internal/schema/integration_test.go and the sorted resource-type list in internal/platform/pingone/dispatch_test.go, both of which track the total number of registered definitions/resources and needed updating for the new pingone_application entry. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Regression Test Results
✅ No regressions detectedAll export configurations produced compatible output. Generated by regression workflow • View run |
Contributor
Author
|
Superseded by the |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
pingone_application, covering the 4 application types thepingone_applicationTerraform resource schema actually supports: OIDC, SAML, External Link, and WS-Fed.ReadOneApplication200Response(and theEntityArrayEmbedded.Applicationslist item type) is a discriminated union with 7 possible variants. A custom Go handler (internal/platform/pingone/resource_sso_application.go) unwraps the union viaGetActualInstance()and projects the result into a flatapplicationDatastruct with one nilable field per supported variant (OIDC,SAML,ExternalLink,WSFED). The YAML definition then models each variant as a plainobject+nested_attributesblock — because exactly one variant field is non-nil, the generic engine naturally emits only the one matching*_optionsblock per resource.Scope decision: the 3 built-in PingOne system application types —
ApplicationPingOneAdminConsole,ApplicationPingOnePortal,ApplicationPingOneSelfService— have no corresponding nested schema block in thepingone_applicationTerraform resource (confirmed against the provider docs). They are provisioned automatically per environment and cannot be declaratively created/imported via this resource. Rather than silently emit an invalid resource block, the handler skips them and records a warning viac.AddWarning(visible inpingcli-terraformeroutput). This was verified live: the target test environment had all 3 system app types present, and each produced a clear skip warning while the 3 real OIDC/WORKER applications exported correctly.Dependency: base SDK integration (#132, adding the
pingone-go-sdk-v2/managementclient) is a prerequisite — this PR should not be merged before #132.Files changed
definitions/pingone/sso/application.yaml— new YAML definition (newssocategory directory)internal/platform/pingone/resource_sso_application.go— new Go handler, registerspingone_applicationas a resource type distinct from the pre-existingpingone_davinci_application(different filename to avoid colliding withresource_application.go, which remains untouched)internal/platform/pingone/resource_sso_application_test.go— new unit testsinternal/platform/pingone/dispatch_test.go,internal/schema/integration_test.go— bumped hardcoded resource/definition-count assertions (same pattern used by the sibling pilot resourcespingone_group/pingone_population/pingone_resource)contributing/RESOURCE_COVERAGE.md— flippedpingone_applicationto ✅.changelog/pr-137.txt— changelog entryTest plan
go run ./tools/validate-definitions definitions/— all 9 definitions passgo build ./...,go vet ./...,go fmt ./...— cleango test ./internal/... -v -count=1— all packages pass, including:TestPingOneApplicationRegistered— new resource registeredTestDaVinciApplicationStillRegistered— regression guard confirmingpingone_davinci_applicationis untouchedTestSSOAndDaVinciApplicationAreDistinctResourceTypesTestToApplicationData_OIDC,TestToApplicationData_SAML,TestToApplicationData_ExternalLink,TestToApplicationData_WSFED(+ nested-block variants) — union unwrapping for all 4 supported typesTestToApplicationData_SkipsAdminConsole,_SkipsPortal,_SkipsSelfService— system app type skip behaviorTestToApplicationData_NilInput,_UnknownType— edge casesWEB_APPOIDC, 2WORKEROIDC; 3 system apps correctly skipped with warnings). Verifiedenvironment_idresolves tovar.pingone_environment_id, no unresolved raw UUIDs for reference-eligible fields (icon IDs are correctly left as raw UUIDs — no exportable resource type owns them), andpingone_davinci_application.tfoutput is unchanged.make regression-local— PASS, only acceptable additions (newpingone_application.tffile + a new fallback variable for the not-yet-exportedpingone_key_rotation_policy_idreference)Known gaps / follow-ups
oidc_options.certificate_based_authenticationandoidc_options.mobile_app.pushare present in the Terraform provider schema but have no backing field in the management SDK struct — not modeled (nothing to source from the API).pingone_key,pingone_key_rotation_policy, andpingone_gatewayfall back to Terraform variables since none of those resource types are exported yet — expected until those resources land.Closes #67