Add Aiven credentials mutations (OpenSearch, Valkey, Kafka)#358
Merged
Conversation
Implement three new mutations that create temporary credentials by managing AivenApplication CRDs and polling for the resulting secrets: - createOpenSearchCredentials - createValkeyCredentials - createKafkaCredentials Each mutation creates/updates an AivenApplication CRD, waits for the Aivenator to provision a Secret (60s timeout), and returns the credentials to the caller. Activity log entries track who created credentials, for which service, with what permission level and TTL.
- Collapse three Create*Credentials into one parameterized createCredentials() with credentialRequest struct carrying buildSpec/extractCreds callbacks - Delete getSecretField (use map index directly) - Fix generateAppName dead code (unused name variable) - Delete KafkaPermission enum from Go code and GraphQL schema - Fix secretData: log unexpected non-string types instead of silent drop - Replace logCredentialCreation string params with credentialRequest struct - Rename loaders/NewLoaderContext to clients/NewClientContext - Factor TTL validation into single path (parse then validate once) - Replace init() with explicit Register() called from wiring code - Add tests for parseTTL, generateSecretName, generateAppName, secretData, waitForSecret, and createOrUpdateAivenApplication - Regenerate gqlgen output
…e init() - Base64-decode Kubernetes secret data values (dynamic client returns base64-encoded strings in the data field) - Add migration 0059 to register aiven:credentials:create authorization for Team member and Team owner roles - Use func init() for activity log registration instead of explicit Register() call, matching the codebase convention
thokra-nav
approved these changes
Mar 16, 2026
Contributor
thokra-nav
left a comment
There was a problem hiding this comment.
En integrasjonstest eller to hadde også vært fint :)
Add Lua integration tests for aiven credentials covering authz (4 tests) and input validation (3 tests). Fix TTL validation errors to use apierror.Errorf so they propagate as user-facing GraphQL errors instead of being swallowed as unhandled server errors.
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
Adds three new GraphQL mutations for creating temporary Aiven service credentials, replacing the broken
nais aiven create/getCLI flow (which relied on users having direct K8s access).createOpenSearchCredentials— creates temporary OpenSearch credentials with configurable permission (read/write/readwrite/admin) and TTLcreateValkeyCredentials— same pattern for Valkey instancescreateKafkaCredentials— creates temporary Kafka credentials (mTLS certs + broker info)How it works
Each mutation:
AivenApplicationCRD using the system-authenticated dynamic K8s clientFiles
internal/graph/schema/aiven_credentials.graphqlsinternal/persistence/aivencredentials/models.gointernal/persistence/aivencredentials/queries.gointernal/persistence/aivencredentials/activitylog.gointernal/persistence/aivencredentials/dataloader.gointernal/graph/aiven_credentials.resolvers.gointernal/auth/authz/queries.goCanCreateAivenCredentialsauth functioninternal/cmd/api/http.go.configs/gqlgen.yamlPart of the Aiven Credentials initiative. CLI side is next.