Files
cozystack/packages/system/cozystack-controller/definitions/cozystack.io_credentialtemplates.yaml
T
Andrei Kvapil 9e7c684fe2 feat(api): add the CredentialTemplate kind
An application write in the Cozystack API that kept an account list, its
Secrets and the HelmRelease in step needed a cross-replica lock and
still raced. The accepted design (cozystack/community#137) moves the
account list to the chart instead: a kind's chart renders one
cozystack.io CredentialTemplate per account, naming the user, the stored
format and the Secret's labels, and its status mirrors the account
Secret's record so the Credential view reads templates only.

Tenants cannot write a template, and username is immutable because the
account Secret's name derives from it. valuesPath starts with "_" so the
Application API hides it on read and refuses it on write.

Design: https://github.com/cozystack/community/blob/main/design-proposals/user-secrets-api/README.md

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
2026-11-24 23:06:02 +01:00

222 lines
9.3 KiB
YAML

---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.16.4
name: credentialtemplates.cozystack.io
spec:
group: cozystack.io
names:
kind: CredentialTemplate
listKind: CredentialTemplateList
plural: credentialtemplates
singular: credentialtemplate
scope: Namespaced
versions:
- additionalPrinterColumns:
- jsonPath: .spec.username
name: User
type: string
- jsonPath: .spec.format.name
name: Format
type: string
- jsonPath: .status.password.origin
name: Origin
type: string
- jsonPath: .metadata.creationTimestamp
name: Age
type: date
name: v1alpha1
schema:
openAPIV3Schema:
description: |-
CredentialTemplate is one account of an application, rendered by the kind's
chart. A controller keeps its account Secret, named <name>.account, and the
Cozystack API mints and revokes through it. See
design-proposals/user-secrets-api in cozystack/community.
properties:
apiVersion:
description: |-
APIVersion defines the versioned schema of this representation of an object.
Servers should convert recognized schemas to the latest internal value, and
may reject unrecognized values.
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
type: string
kind:
description: |-
Kind is a string value representing the REST resource this object represents.
Servers may infer this from the endpoint the client submits requests to.
Cannot be updated.
In CamelCase.
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
type: string
metadata:
type: object
spec:
description: |-
CredentialTemplateSpec describes one account of an application and the
Secret that stores its password. A kind's chart renders one per account; a
tenant cannot write it.
properties:
format:
description: Format is how a password is stored in the account Secret.
properties:
name:
description: |-
Name is a built-in format: scram-sha-256, mysql-native, sha256 or
plaintext.
minLength: 1
type: string
required:
- name
type: object
secret:
description: |-
Secret describes the account Secret beyond its fixed username and
password keys.
properties:
labels:
additionalProperties:
type: string
description: |-
Labels are put on the account Secret, for an operator that notices a
changed Secret only when it carries a label.
type: object
x-kubernetes-validations:
- message: the credentials.cozystack.io/account label is reserved
rule: '!(''credentials.cozystack.io/account'' in self)'
type: object
username:
description: Username is the account name as the engine knows it.
minLength: 1
type: string
x-kubernetes-validations:
- message: username is immutable
rule: self == oldSelf
valuesPath:
description: |-
ValuesPath, for an engine whose operator reads no Secret, asks for the
stored value to be pulled into the release's values under
<valuesPath>.u<sha256 hex of the username>. It starts with "_", which
the Application API hides on read and refuses on write.
pattern: ^_[A-Za-z0-9_]*$
type: string
required:
- format
- username
type: object
status:
description: |-
CredentialTemplateStatus mirrors the record the account Secret keeps, so the
Credential view reads templates only.
properties:
conditions:
items:
description: Condition contains details for one aspect of the current
state of this API Resource.
properties:
lastTransitionTime:
description: |-
lastTransitionTime is the last time the condition transitioned from one status to another.
This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable.
format: date-time
type: string
message:
description: |-
message is a human readable message indicating details about the transition.
This may be an empty string.
maxLength: 32768
type: string
observedGeneration:
description: |-
observedGeneration represents the .metadata.generation that the condition was set based upon.
For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date
with respect to the current state of the instance.
format: int64
minimum: 0
type: integer
reason:
description: |-
reason contains a programmatic identifier indicating the reason for the condition's last transition.
Producers of specific condition types may define expected values and meanings for this field,
and whether the values are considered a guaranteed API.
The value should be a CamelCase string.
This field may not be empty.
maxLength: 1024
minLength: 1
pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$
type: string
status:
description: status of the condition, one of True, False, Unknown.
enum:
- "True"
- "False"
- Unknown
type: string
type:
description: type of condition in CamelCase or in foo.example.com/CamelCase.
maxLength: 316
pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$
type: string
required:
- lastTransitionTime
- message
- reason
- status
- type
type: object
type: array
x-kubernetes-list-map-keys:
- type
x-kubernetes-list-type: map
history:
description: History holds the last ten operations, newest first.
items:
description: CredentialTemplateHistoryEntry is one recorded operation
on the account.
properties:
at:
format: date-time
type: string
by:
type: string
operation:
description: Operation is Create, Migrate, Mint or Revoke.
type: string
required:
- at
- by
- operation
type: object
type: array
x-kubernetes-list-type: atomic
observedGeneration:
description: ObservedGeneration is the generation the controller last
acted on.
format: int64
type: integer
password:
description: Password says where the live password came from.
properties:
at:
format: date-time
type: string
by:
type: string
origin:
description: Origin is NotIssued, Migrated, Minted or Revoked.
type: string
type: object
secretResourceVersion:
description: |-
SecretResourceVersion is the resourceVersion of the account Secret this
status mirrors; empty while the account has no Secret.
type: string
type: object
type: object
served: true
storage: true
subresources:
status: {}