Skip to content

Commit c80b4ab

Browse files
gtherondclaude
andcommitted
[1953] feat: App Credential expiration evaluation and Keystone error mapping
Adds three helpers in k8s/migration/pkg/utils/app_credentials.go for the Application Credentials sub-issue: - EvaluateAppCredExpiration(expiresAt, now) returns (within30, within7, expired) used by the controller to populate the Expiring/Expired Conditions. Boundary semantics: 7 and 30 days are inclusive; nil expiresAt (never expires) yields all-false; expiration in the past or exactly now yields expired=true. Constitution principle IV: 9 table-driven test cases. - MapKeystoneError(err) returns one of the Reason constants. Prefers typed gophercloud.ErrUnexpectedResponseCode (401 -> CredentialInvalidOrRevoked, 403 -> InsufficientRoles, 404 -> KeystoneUnreachable), falls back to string matching on the error message. Default for unrecognized errors is CredentialInvalidOrRevoked. 17 test cases cover typed errors, wrapped errors, and string fallbacks. - FetchAppCredentialDetails(ctx, providerClient, credID) queries Keystone for the Application Credential metadata via identity v3 applicationcredentials.Get. Returns nil, nil for benign "details unavailable" cases (no auth result, non-token auth, missing identity:get_application_credential scope on the credential); returns error only for unexpected failures. Wiring into the validate path lands in the follow-up commit. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 36944c8 commit c80b4ab

4 files changed

Lines changed: 255 additions & 0 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"nodes": [{"id": "home_flint_vjailbreak_k8s_migration_pkg_utils_app_credentials_go", "label": "app_credentials.go", "file_type": "code", "source_file": "/home/flint/vjailbreak/k8s/migration/pkg/utils/app_credentials.go", "source_location": "L1"}, {"id": "utils_appcredentialdetails", "label": "AppCredentialDetails", "file_type": "code", "source_file": "/home/flint/vjailbreak/k8s/migration/pkg/utils/app_credentials.go", "source_location": "L20"}, {"id": "utils_app_credentials_evaluateappcredexpiration", "label": "EvaluateAppCredExpiration()", "file_type": "code", "source_file": "/home/flint/vjailbreak/k8s/migration/pkg/utils/app_credentials.go", "source_location": "L35"}, {"id": "utils_app_credentials_fetchappcredentialdetails", "label": "FetchAppCredentialDetails()", "file_type": "code", "source_file": "/home/flint/vjailbreak/k8s/migration/pkg/utils/app_credentials.go", "source_location": "L61"}, {"id": "utils_app_credentials_mapkeystoneerror", "label": "MapKeystoneError()", "file_type": "code", "source_file": "/home/flint/vjailbreak/k8s/migration/pkg/utils/app_credentials.go", "source_location": "L108"}], "edges": [{"source": "home_flint_vjailbreak_k8s_migration_pkg_utils_app_credentials_go", "target": "go_pkg_context", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/home/flint/vjailbreak/k8s/migration/pkg/utils/app_credentials.go", "source_location": "L4", "weight": 1.0, "context": "import"}, {"source": "home_flint_vjailbreak_k8s_migration_pkg_utils_app_credentials_go", "target": "go_pkg_errors", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/home/flint/vjailbreak/k8s/migration/pkg/utils/app_credentials.go", "source_location": "L5", "weight": 1.0, "context": "import"}, {"source": "home_flint_vjailbreak_k8s_migration_pkg_utils_app_credentials_go", "target": "go_pkg_fmt", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/home/flint/vjailbreak/k8s/migration/pkg/utils/app_credentials.go", "source_location": "L6", "weight": 1.0, "context": "import"}, {"source": "home_flint_vjailbreak_k8s_migration_pkg_utils_app_credentials_go", "target": "go_pkg_net_http", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/home/flint/vjailbreak/k8s/migration/pkg/utils/app_credentials.go", "source_location": "L7", "weight": 1.0, "context": "import"}, {"source": "home_flint_vjailbreak_k8s_migration_pkg_utils_app_credentials_go", "target": "go_pkg_strings", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/home/flint/vjailbreak/k8s/migration/pkg/utils/app_credentials.go", "source_location": "L8", "weight": 1.0, "context": "import"}, {"source": "home_flint_vjailbreak_k8s_migration_pkg_utils_app_credentials_go", "target": "go_pkg_time", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/home/flint/vjailbreak/k8s/migration/pkg/utils/app_credentials.go", "source_location": "L9", "weight": 1.0, "context": "import"}, {"source": "home_flint_vjailbreak_k8s_migration_pkg_utils_app_credentials_go", "target": "go_pkg_github_com_gophercloud_gophercloud_v2", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/home/flint/vjailbreak/k8s/migration/pkg/utils/app_credentials.go", "source_location": "L11", "weight": 1.0, "context": "import"}, {"source": "home_flint_vjailbreak_k8s_migration_pkg_utils_app_credentials_go", "target": "go_pkg_github_com_gophercloud_gophercloud_v2_openstack", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/home/flint/vjailbreak/k8s/migration/pkg/utils/app_credentials.go", "source_location": "L12", "weight": 1.0, "context": "import"}, {"source": "home_flint_vjailbreak_k8s_migration_pkg_utils_app_credentials_go", "target": "go_pkg_github_com_gophercloud_gophercloud_v2_openstack_identity_v3_applicationcredentials", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/home/flint/vjailbreak/k8s/migration/pkg/utils/app_credentials.go", "source_location": "L13", "weight": 1.0, "context": "import"}, {"source": "home_flint_vjailbreak_k8s_migration_pkg_utils_app_credentials_go", "target": "go_pkg_github_com_gophercloud_gophercloud_v2_openstack_identity_v3_tokens", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/home/flint/vjailbreak/k8s/migration/pkg/utils/app_credentials.go", "source_location": "L14", "weight": 1.0, "context": "import"}, {"source": "home_flint_vjailbreak_k8s_migration_pkg_utils_app_credentials_go", "target": "utils_appcredentialdetails", "relation": "contains", "confidence": "EXTRACTED", "source_file": "/home/flint/vjailbreak/k8s/migration/pkg/utils/app_credentials.go", "source_location": "L20", "weight": 1.0}, {"source": "home_flint_vjailbreak_k8s_migration_pkg_utils_app_credentials_go", "target": "utils_app_credentials_evaluateappcredexpiration", "relation": "contains", "confidence": "EXTRACTED", "source_file": "/home/flint/vjailbreak/k8s/migration/pkg/utils/app_credentials.go", "source_location": "L35", "weight": 1.0}, {"source": "home_flint_vjailbreak_k8s_migration_pkg_utils_app_credentials_go", "target": "utils_app_credentials_fetchappcredentialdetails", "relation": "contains", "confidence": "EXTRACTED", "source_file": "/home/flint/vjailbreak/k8s/migration/pkg/utils/app_credentials.go", "source_location": "L61", "weight": 1.0}, {"source": "home_flint_vjailbreak_k8s_migration_pkg_utils_app_credentials_go", "target": "utils_app_credentials_mapkeystoneerror", "relation": "contains", "confidence": "EXTRACTED", "source_file": "/home/flint/vjailbreak/k8s/migration/pkg/utils/app_credentials.go", "source_location": "L108", "weight": 1.0}], "raw_calls": [{"caller_nid": "utils_app_credentials_evaluateappcredexpiration", "callee": "Before", "is_member_call": true, "source_file": "/home/flint/vjailbreak/k8s/migration/pkg/utils/app_credentials.go", "source_location": "L39"}, {"caller_nid": "utils_app_credentials_evaluateappcredexpiration", "callee": "Sub", "is_member_call": true, "source_file": "/home/flint/vjailbreak/k8s/migration/pkg/utils/app_credentials.go", "source_location": "L42"}, {"caller_nid": "utils_app_credentials_fetchappcredentialdetails", "callee": "Errorf", "is_member_call": false, "source_file": "/home/flint/vjailbreak/k8s/migration/pkg/utils/app_credentials.go", "source_location": "L63"}, {"caller_nid": "utils_app_credentials_fetchappcredentialdetails", "callee": "Errorf", "is_member_call": false, "source_file": "/home/flint/vjailbreak/k8s/migration/pkg/utils/app_credentials.go", "source_location": "L66"}, {"caller_nid": "utils_app_credentials_fetchappcredentialdetails", "callee": "GetAuthResult", "is_member_call": true, "source_file": "/home/flint/vjailbreak/k8s/migration/pkg/utils/app_credentials.go", "source_location": "L69"}, {"caller_nid": "utils_app_credentials_fetchappcredentialdetails", "callee": "Errorf", "is_member_call": false, "source_file": "/home/flint/vjailbreak/k8s/migration/pkg/utils/app_credentials.go", "source_location": "L71"}, {"caller_nid": "utils_app_credentials_fetchappcredentialdetails", "callee": "ExtractUser", "is_member_call": true, "source_file": "/home/flint/vjailbreak/k8s/migration/pkg/utils/app_credentials.go", "source_location": "L78"}, {"caller_nid": "utils_app_credentials_fetchappcredentialdetails", "callee": "Errorf", "is_member_call": false, "source_file": "/home/flint/vjailbreak/k8s/migration/pkg/utils/app_credentials.go", "source_location": "L80"}, {"caller_nid": "utils_app_credentials_fetchappcredentialdetails", "callee": "NewIdentityV3", "is_member_call": false, "source_file": "/home/flint/vjailbreak/k8s/migration/pkg/utils/app_credentials.go", "source_location": "L83"}, {"caller_nid": "utils_app_credentials_fetchappcredentialdetails", "callee": "Errorf", "is_member_call": false, "source_file": "/home/flint/vjailbreak/k8s/migration/pkg/utils/app_credentials.go", "source_location": "L85"}, {"caller_nid": "utils_app_credentials_fetchappcredentialdetails", "callee": "Extract", "is_member_call": true, "source_file": "/home/flint/vjailbreak/k8s/migration/pkg/utils/app_credentials.go", "source_location": "L88"}, {"caller_nid": "utils_app_credentials_fetchappcredentialdetails", "callee": "Get", "is_member_call": false, "source_file": "/home/flint/vjailbreak/k8s/migration/pkg/utils/app_credentials.go", "source_location": "L88"}, {"caller_nid": "utils_app_credentials_fetchappcredentialdetails", "callee": "Errorf", "is_member_call": false, "source_file": "/home/flint/vjailbreak/k8s/migration/pkg/utils/app_credentials.go", "source_location": "L93"}, {"caller_nid": "utils_app_credentials_mapkeystoneerror", "callee": "As", "is_member_call": false, "source_file": "/home/flint/vjailbreak/k8s/migration/pkg/utils/app_credentials.go", "source_location": "L114"}, {"caller_nid": "utils_app_credentials_mapkeystoneerror", "callee": "Error", "is_member_call": true, "source_file": "/home/flint/vjailbreak/k8s/migration/pkg/utils/app_credentials.go", "source_location": "L125"}, {"caller_nid": "utils_app_credentials_mapkeystoneerror", "callee": "Contains", "is_member_call": false, "source_file": "/home/flint/vjailbreak/k8s/migration/pkg/utils/app_credentials.go", "source_location": "L127"}, {"caller_nid": "utils_app_credentials_mapkeystoneerror", "callee": "Contains", "is_member_call": false, "source_file": "/home/flint/vjailbreak/k8s/migration/pkg/utils/app_credentials.go", "source_location": "L127"}, {"caller_nid": "utils_app_credentials_mapkeystoneerror", "callee": "Contains", "is_member_call": false, "source_file": "/home/flint/vjailbreak/k8s/migration/pkg/utils/app_credentials.go", "source_location": "L127"}, {"caller_nid": "utils_app_credentials_mapkeystoneerror", "callee": "Contains", "is_member_call": false, "source_file": "/home/flint/vjailbreak/k8s/migration/pkg/utils/app_credentials.go", "source_location": "L129"}, {"caller_nid": "utils_app_credentials_mapkeystoneerror", "callee": "Contains", "is_member_call": false, "source_file": "/home/flint/vjailbreak/k8s/migration/pkg/utils/app_credentials.go", "source_location": "L129"}, {"caller_nid": "utils_app_credentials_mapkeystoneerror", "callee": "Contains", "is_member_call": false, "source_file": "/home/flint/vjailbreak/k8s/migration/pkg/utils/app_credentials.go", "source_location": "L131"}, {"caller_nid": "utils_app_credentials_mapkeystoneerror", "callee": "Contains", "is_member_call": false, "source_file": "/home/flint/vjailbreak/k8s/migration/pkg/utils/app_credentials.go", "source_location": "L131"}, {"caller_nid": "utils_app_credentials_mapkeystoneerror", "callee": "Contains", "is_member_call": false, "source_file": "/home/flint/vjailbreak/k8s/migration/pkg/utils/app_credentials.go", "source_location": "L131"}, {"caller_nid": "utils_app_credentials_mapkeystoneerror", "callee": "Contains", "is_member_call": false, "source_file": "/home/flint/vjailbreak/k8s/migration/pkg/utils/app_credentials.go", "source_location": "L133"}, {"caller_nid": "utils_app_credentials_mapkeystoneerror", "callee": "Contains", "is_member_call": false, "source_file": "/home/flint/vjailbreak/k8s/migration/pkg/utils/app_credentials.go", "source_location": "L133"}, {"caller_nid": "utils_app_credentials_mapkeystoneerror", "callee": "Contains", "is_member_call": false, "source_file": "/home/flint/vjailbreak/k8s/migration/pkg/utils/app_credentials.go", "source_location": "L133"}, {"caller_nid": "utils_app_credentials_mapkeystoneerror", "callee": "Contains", "is_member_call": false, "source_file": "/home/flint/vjailbreak/k8s/migration/pkg/utils/app_credentials.go", "source_location": "L135"}, {"caller_nid": "utils_app_credentials_mapkeystoneerror", "callee": "Contains", "is_member_call": false, "source_file": "/home/flint/vjailbreak/k8s/migration/pkg/utils/app_credentials.go", "source_location": "L135"}, {"caller_nid": "utils_app_credentials_mapkeystoneerror", "callee": "Contains", "is_member_call": false, "source_file": "/home/flint/vjailbreak/k8s/migration/pkg/utils/app_credentials.go", "source_location": "L135"}]}

0 commit comments

Comments
 (0)