feat(api): add Credential kinds and the credentials block

Cozystack generates managed application passwords at Helm render time
and keeps them in a Secret tenants can read again at any time, which a
deployment whose policy requires a credential shown once cannot accept.
The accepted design moves generation into the API: an
ApplicationDefinition declares its accounts and the stored form of a
password in a credentials block, and each account gets a
core.cozystack.io Credential whose mint and revoke subresources take a
TokenRequest-shaped CredentialRequest.

This adds the types, the built-in password formats, which the migration
CLI shares so a converted release and a mint store the same form, and
the account helpers that name the Secrets and read their record.

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

Assisted-by: LLM
Signed-off-by: Timofei Larkin <lllamnyp@gmail.com>
This commit is contained in:
Timofei Larkin authored and IvanHunters committed 2026-11-17 11:09:29 +03:00
1 parent 060686cbc0
commit e0d90ab12c
14 files changed
+2311 -112

No files matched your search

@@ -1,4 +1,5 @@
API rule violation: list_type_missing,github.com/cozystack/cozystack/pkg/apis/apps/v1alpha1,ApplicationStatus,Conditions
API rule violation: list_type_missing,github.com/cozystack/cozystack/pkg/apis/core/v1alpha1,CredentialStatus,History
API rule violation: list_type_missing,github.com/cozystack/cozystack/pkg/apis/core/v1alpha1,OptionSpec,Items
API rule violation: list_type_missing,github.com/cozystack/cozystack/pkg/apis/core/v1alpha1,TapPackage,Tags
API rule violation: list_type_missing,github.com/cozystack/cozystack/pkg/apis/core/v1alpha1,TapSpec,Packages
@@ -0,0 +1,166 @@
/*
Copyright 2026.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package v1alpha1
import (
admissionregistrationv1 "k8s.io/api/admissionregistration/v1"
)
// ApplicationDefinitionCredentials declares the accounts of an application
// kind and how the Cozystack API stores their passwords. Its presence is what
// converts the kind: the API seeds one account Secret per account when an
// application is written, serves a core.cozystack.io Credential per account,
// and mints a password on request. The chart renders only references to the
// account Secrets and never a password. See
// design-proposals/user-secrets-api in cozystack/community.
type ApplicationDefinitionCredentials struct {
// Format is how a password is stored in the account Secret: the verifier the
// engine checks a login against, or the plaintext for an engine that needs it.
Format CredentialFormat `json:"format"`
// SecretLabels are added to every account Secret of the kind, for an operator
// that notices a changed Secret only when it carries a label.
// +optional
SecretLabels map[string]string `json:"secretLabels,omitempty"`
// ValuesPath makes the HelmRelease pull each tenant account's stored value
// into this values key, under u<sha256 hex of the user name>, for a chart
// whose operator cannot read a Secret. It starts with "_", which the
// Application API hides on read and refuses on write, so the value never
// appears in the application.
// +optional
// +kubebuilder:validation:Pattern=`^_[A-Za-z0-9_]*$`
ValuesPath string `json:"valuesPath,omitempty"`
// Accounts are the sources the kind's accounts come from. A kind may list
// several, for example a values map of tenant users and a static platform
// account.
// +kubebuilder:validation:MinItems=1
Accounts []CredentialAccountSource `json:"accounts"`
}
// CredentialFormatKind says where the function that turns a password into
// its stored value lives.
// +kubebuilder:validation:Enum=BuiltIn;Webhook
type CredentialFormatKind string
const (
// CredentialFormatBuiltIn names a function compiled into the API.
CredentialFormatBuiltIn CredentialFormatKind = "BuiltIn"
// CredentialFormatWebhook names an endpoint the API calls with the
// plaintext. Declared so a block can carry it without a schema change; the
// API refuses to serve a kind that uses it until the call is implemented.
CredentialFormatWebhook CredentialFormatKind = "Webhook"
)
// CredentialFormat selects the stored form of a password.
type CredentialFormat struct {
// Name of the format. The built-in names are scram-sha-256, mysql-native,
// sha256 and plaintext; a Webhook format carries any name.
// +kubebuilder:validation:MinLength=1
Name string `json:"name"`
// Kind defaults to BuiltIn.
// +optional
Kind CredentialFormatKind `json:"kind,omitempty"`
// Webhook is the endpoint of a Webhook format.
// +optional
Webhook *CredentialWebhook `json:"webhook,omitempty"`
}
// CredentialWebhook is the client configuration of a credentials webhook, in
// the shape every Kubernetes webhook uses.
type CredentialWebhook struct {
ClientConfig admissionregistrationv1.WebhookClientConfig `json:"clientConfig"`
// +optional
// +kubebuilder:validation:Minimum=1
// +kubebuilder:validation:Maximum=30
TimeoutSeconds *int32 `json:"timeoutSeconds,omitempty"`
}
// CredentialAccountSourceKind says how a source yields account names.
// +kubebuilder:validation:Enum=ValuesMap;ValuesList;Static;Expression;Webhook
type CredentialAccountSourceKind string
const (
// CredentialAccountsValuesMap takes the keys of a values map as accounts.
CredentialAccountsValuesMap CredentialAccountSourceKind = "ValuesMap"
// CredentialAccountsValuesList takes the name field of each object in a
// values list as an account. Declared, not served yet.
CredentialAccountsValuesList CredentialAccountSourceKind = "ValuesList"
// CredentialAccountsStatic is one fixed account.
CredentialAccountsStatic CredentialAccountSourceKind = "Static"
// CredentialAccountsExpression evaluates a CEL expression over the
// application. Declared, not served yet.
CredentialAccountsExpression CredentialAccountSourceKind = "Expression"
// CredentialAccountsWebhook asks an endpoint for the account list.
// Declared, not served yet.
CredentialAccountsWebhook CredentialAccountSourceKind = "Webhook"
)
// CredentialAccountOwner says whose account it is.
// +kubebuilder:validation:Enum=tenant;platform
type CredentialAccountOwner string
const (
// CredentialAccountOwnerTenant is the default: the account gets a
// Credential, an account Secret and a mint.
CredentialAccountOwnerTenant CredentialAccountOwner = "tenant"
// CredentialAccountOwnerPlatform marks an account the platform's own
// components log in with. The API does nothing for it, and a ValuesMap
// source skips its name.
CredentialAccountOwnerPlatform CredentialAccountOwner = "platform"
)
// CredentialAccountSource is one source of a kind's accounts. Which fields
// apply depends on Kind.
type CredentialAccountSource struct {
Kind CredentialAccountSourceKind `json:"kind"`
// Path is the values key a ValuesMap or ValuesList source reads, as a
// dotted path from the top of the application spec.
// +optional
Path string `json:"path,omitempty"`
// NameField is the field of each object a ValuesList source takes the
// account name from.
// +optional
NameField string `json:"nameField,omitempty"`
// Name is the account of a Static source.
// +optional
Name string `json:"name,omitempty"`
// When is a values key, as a dotted path, that switches a Static account
// on when it holds true; absent, the account is always on.
// +optional
When string `json:"when,omitempty"`
// Owner defaults to tenant.
// +optional
Owner CredentialAccountOwner `json:"owner,omitempty"`
// Expression is the CEL expression of an Expression source.
// +optional
Expression string `json:"expression,omitempty"`
// Webhook is the endpoint of a Webhook source.
// +optional
Webhook *CredentialWebhook `json:"webhook,omitempty"`
}
@@ -61,6 +61,11 @@ type ApplicationDefinitionSpec struct {
// Dashboard configuration for this resource
Dashboard *ApplicationDefinitionDashboard `json:"dashboard,omitempty"`
// Credentials declares the kind's accounts and how the API stores their
// passwords. Its presence converts the kind to platform-minted credentials.
// +optional
Credentials *ApplicationDefinitionCredentials `json:"credentials,omitempty"`
}
type ApplicationDefinitionApplication struct {
+96
View File
@@ -70,6 +70,36 @@ func (in *ApplicationDefinitionApplication) DeepCopy() *ApplicationDefinitionApp
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ApplicationDefinitionCredentials) DeepCopyInto(out *ApplicationDefinitionCredentials) {
*out = *in
in.Format.DeepCopyInto(&out.Format)
if in.SecretLabels != nil {
in, out := &in.SecretLabels, &out.SecretLabels
*out = make(map[string]string, len(*in))
for key, val := range *in {
(*out)[key] = val
}
}
if in.Accounts != nil {
in, out := &in.Accounts, &out.Accounts
*out = make([]CredentialAccountSource, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ApplicationDefinitionCredentials.
func (in *ApplicationDefinitionCredentials) DeepCopy() *ApplicationDefinitionCredentials {
if in == nil {
return nil
}
out := new(ApplicationDefinitionCredentials)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ApplicationDefinitionDashboard) DeepCopyInto(out *ApplicationDefinitionDashboard) {
*out = *in
@@ -241,6 +271,11 @@ func (in *ApplicationDefinitionSpec) DeepCopyInto(out *ApplicationDefinitionSpec
*out = new(ApplicationDefinitionDashboard)
(*in).DeepCopyInto(*out)
}
if in.Credentials != nil {
in, out := &in.Credentials, &out.Credentials
*out = new(ApplicationDefinitionCredentials)
(*in).DeepCopyInto(*out)
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ApplicationDefinitionSpec.
@@ -308,6 +343,67 @@ func (in *ComponentInstall) DeepCopy() *ComponentInstall {
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *CredentialAccountSource) DeepCopyInto(out *CredentialAccountSource) {
*out = *in
if in.Webhook != nil {
in, out := &in.Webhook, &out.Webhook
*out = new(CredentialWebhook)
(*in).DeepCopyInto(*out)
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CredentialAccountSource.
func (in *CredentialAccountSource) DeepCopy() *CredentialAccountSource {
if in == nil {
return nil
}
out := new(CredentialAccountSource)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *CredentialFormat) DeepCopyInto(out *CredentialFormat) {
*out = *in
if in.Webhook != nil {
in, out := &in.Webhook, &out.Webhook
*out = new(CredentialWebhook)
(*in).DeepCopyInto(*out)
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CredentialFormat.
func (in *CredentialFormat) DeepCopy() *CredentialFormat {
if in == nil {
return nil
}
out := new(CredentialFormat)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *CredentialWebhook) DeepCopyInto(out *CredentialWebhook) {
*out = *in
in.ClientConfig.DeepCopyInto(&out.ClientConfig)
if in.TimeoutSeconds != nil {
in, out := &in.TimeoutSeconds, &out.TimeoutSeconds
*out = new(int32)
**out = **in
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CredentialWebhook.
func (in *CredentialWebhook) DeepCopy() *CredentialWebhook {
if in == nil {
return nil
}
out := new(CredentialWebhook)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *DependencyStatus) DeepCopyInto(out *DependencyStatus) {
*out = *in
@@ -62,6 +62,272 @@ spec:
- plural
- singular
type: object
credentials:
description: |-
Credentials declares the kind's accounts and how the API stores their
passwords. Its presence converts the kind to platform-minted credentials.
properties:
accounts:
description: |-
Accounts are the sources the kind's accounts come from. A kind may list
several, for example a values map of tenant users and a static platform
account.
items:
description: |-
CredentialAccountSource is one source of a kind's accounts. Which fields
apply depends on Kind.
properties:
expression:
description: Expression is the CEL expression of an Expression
source.
type: string
kind:
description: CredentialAccountSourceKind says how a source
yields account names.
enum:
- ValuesMap
- ValuesList
- Static
- Expression
- Webhook
type: string
name:
description: Name is the account of a Static source.
type: string
nameField:
description: |-
NameField is the field of each object a ValuesList source takes the
account name from.
type: string
owner:
description: Owner defaults to tenant.
enum:
- tenant
- platform
type: string
path:
description: |-
Path is the values key a ValuesMap or ValuesList source reads, as a
dotted path from the top of the application spec.
type: string
webhook:
description: Webhook is the endpoint of a Webhook source.
properties:
clientConfig:
description: |-
WebhookClientConfig contains the information to make a TLS
connection with the webhook
properties:
caBundle:
description: |-
caBundle is a PEM encoded CA bundle which will be used to validate the webhook's server certificate.
If unspecified, system trust roots on the apiserver are used.
format: byte
type: string
service:
description: |-
service is a reference to the service for this webhook. Either
`service` or `url` must be specified.
If the webhook is running within the cluster, then you should use `service`.
properties:
name:
description: |-
name is the name of the service.
Required
type: string
namespace:
description: |-
namespace is the namespace of the service.
Required
type: string
path:
description: |-
path is an optional URL path which will be sent in any request to
this service.
type: string
port:
description: |-
port is the port on the service that hosts the webhook.
Default to 443 for backward compatibility.
`port` should be a valid port number (1-65535, inclusive).
format: int32
type: integer
required:
- name
- namespace
type: object
url:
description: |-
url gives the location of the webhook, in standard URL form
(`scheme://host:port/path`). Exactly one of `url` or `service`
must be specified.
The `host` should not refer to a service running in the cluster; use
the `service` field instead. The host might be resolved via external
DNS in some apiservers (e.g., `kube-apiserver` cannot resolve
in-cluster DNS as that would be a layering violation). `host` may
also be an IP address.
Please note that using `localhost` or `127.0.0.1` as a `host` is
risky unless you take great care to run this webhook on all hosts
which run an apiserver which might need to make calls to this
webhook. Such installs are likely to be non-portable, i.e., not easy
to turn up in a new cluster.
The scheme must be "https"; the URL must begin with "https://".
A path is optional, and if present may be any string permissible in
a URL. You may use the path to pass an arbitrary string to the
webhook, for example, a cluster identifier.
Attempting to use a user or basic auth e.g. "user:password@" is not
allowed. Fragments ("#...") and query parameters ("?...") are not
allowed, either.
type: string
type: object
timeoutSeconds:
format: int32
maximum: 30
minimum: 1
type: integer
required:
- clientConfig
type: object
when:
description: |-
When is a values key, as a dotted path, that switches a Static account
on when it holds true; absent, the account is always on.
type: string
required:
- kind
type: object
minItems: 1
type: array
format:
description: |-
Format is how a password is stored in the account Secret: the verifier the
engine checks a login against, or the plaintext for an engine that needs it.
properties:
kind:
description: Kind defaults to BuiltIn.
enum:
- BuiltIn
- Webhook
type: string
name:
description: |-
Name of the format. The built-in names are scram-sha-256, mysql-native,
sha256 and plaintext; a Webhook format carries any name.
minLength: 1
type: string
webhook:
description: Webhook is the endpoint of a Webhook format.
properties:
clientConfig:
description: |-
WebhookClientConfig contains the information to make a TLS
connection with the webhook
properties:
caBundle:
description: |-
caBundle is a PEM encoded CA bundle which will be used to validate the webhook's server certificate.
If unspecified, system trust roots on the apiserver are used.
format: byte
type: string
service:
description: |-
service is a reference to the service for this webhook. Either
`service` or `url` must be specified.
If the webhook is running within the cluster, then you should use `service`.
properties:
name:
description: |-
name is the name of the service.
Required
type: string
namespace:
description: |-
namespace is the namespace of the service.
Required
type: string
path:
description: |-
path is an optional URL path which will be sent in any request to
this service.
type: string
port:
description: |-
port is the port on the service that hosts the webhook.
Default to 443 for backward compatibility.
`port` should be a valid port number (1-65535, inclusive).
format: int32
type: integer
required:
- name
- namespace
type: object
url:
description: |-
url gives the location of the webhook, in standard URL form
(`scheme://host:port/path`). Exactly one of `url` or `service`
must be specified.
The `host` should not refer to a service running in the cluster; use
the `service` field instead. The host might be resolved via external
DNS in some apiservers (e.g., `kube-apiserver` cannot resolve
in-cluster DNS as that would be a layering violation). `host` may
also be an IP address.
Please note that using `localhost` or `127.0.0.1` as a `host` is
risky unless you take great care to run this webhook on all hosts
which run an apiserver which might need to make calls to this
webhook. Such installs are likely to be non-portable, i.e., not easy
to turn up in a new cluster.
The scheme must be "https"; the URL must begin with "https://".
A path is optional, and if present may be any string permissible in
a URL. You may use the path to pass an arbitrary string to the
webhook, for example, a cluster identifier.
Attempting to use a user or basic auth e.g. "user:password@" is not
allowed. Fragments ("#...") and query parameters ("?...") are not
allowed, either.
type: string
type: object
timeoutSeconds:
format: int32
maximum: 30
minimum: 1
type: integer
required:
- clientConfig
type: object
required:
- name
type: object
secretLabels:
additionalProperties:
type: string
description: |-
SecretLabels are added to every account Secret of the kind, for an operator
that notices a changed Secret only when it carries a label.
type: object
valuesPath:
description: |-
ValuesPath makes the HelmRelease pull each tenant account's stored value
into this values key, under u<sha256 hex of the user name>, for a chart
whose operator cannot read a Secret. It starts with "_", which the
Application API hides on read and refuses on write, so the value never
appears in the application.
pattern: ^_[A-Za-z0-9_]*$
type: string
required:
- accounts
- format
type: object
dashboard:
description: Dashboard configuration for this resource
properties:
+143
View File
@@ -0,0 +1,143 @@
// SPDX-License-Identifier: Apache-2.0
// Credential is the account record of one platform-generated credential of a
// managed application: who can know the live password and who changed it. It
// is a view over the account Secret the Cozystack API keeps per account, and
// it never carries the password or the stored verifier. The password is
// obtained once, through the mint subresource, and replaced through it. See
// design-proposals/user-secrets-api in cozystack/community.
package v1alpha1
import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// Credential is one account of a converted application.
type Credential struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec CredentialSpec `json:"spec,omitempty"`
Status CredentialStatus `json:"status,omitempty"`
}
// CredentialSpec identifies the account. It is derived from the application
// and read-only.
type CredentialSpec struct {
// Application is the managed application the account belongs to.
Application CredentialApplicationRef `json:"application"`
// User is the account name as the application declares it.
User string `json:"user"`
}
// CredentialApplicationRef names a managed application.
type CredentialApplicationRef struct {
APIGroup string `json:"apiGroup"`
Kind string `json:"kind"`
Name string `json:"name"`
}
// CredentialStatus is the account's record.
type CredentialStatus struct {
// Password says where the live password came from.
Password CredentialPasswordState `json:"password,omitempty"`
// History holds the last ten operations, newest first.
// +optional
History []CredentialHistoryEntry `json:"history,omitempty"`
}
// CredentialOrigin says who can know the live password.
type CredentialOrigin string
const (
// CredentialOriginNotIssued: the account was seeded with a random password
// the API discarded at once. Nobody can log in until someone mints.
CredentialOriginNotIssued CredentialOrigin = "NotIssued"
// CredentialOriginMigrated: the account went through the conversion with
// the password tenants could read before it; a mint should replace it.
CredentialOriginMigrated CredentialOrigin = "Migrated"
// CredentialOriginMinted: the password was shown once, to the caller of
// the mint recorded in At and By.
CredentialOriginMinted CredentialOrigin = "Minted"
// CredentialOriginRevoked: the live password is random and discarded, so
// nobody holds a working one until the next mint.
CredentialOriginRevoked CredentialOrigin = "Revoked"
)
// CredentialPasswordState records the operation that set the live password.
type CredentialPasswordState struct {
Origin CredentialOrigin `json:"origin,omitempty"`
// +optional
At metav1.Time `json:"at,omitempty"`
// +optional
By string `json:"by,omitempty"`
}
// CredentialOperation names a recorded operation on an account.
type CredentialOperation string
const (
CredentialOperationCreate CredentialOperation = "Create"
CredentialOperationMigrate CredentialOperation = "Migrate"
CredentialOperationMint CredentialOperation = "Mint"
CredentialOperationRevoke CredentialOperation = "Revoke"
)
// CredentialHistoryEntry is one recorded operation.
type CredentialHistoryEntry struct {
Operation CredentialOperation `json:"operation"`
At metav1.Time `json:"at"`
By string `json:"by"`
}
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// CredentialList is a list of Credential objects.
type CredentialList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []Credential `json:"items"`
}
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// CredentialRequest is the body and the answer of the mint and revoke
// subresources of a Credential, in the shape of a Kubernetes TokenRequest: a
// create on the subresource carries the request in spec and is answered with
// the result in status, and nothing is stored. The password in a mint's answer
// is the only place it ever exists outside the API's memory.
type CredentialRequest struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec CredentialRequestSpec `json:"spec,omitempty"`
Status CredentialRequestStatus `json:"status,omitempty"`
}
// CredentialRequestSpec carries the caller's preconditions.
type CredentialRequestSpec struct {
// +optional
Preconditions *CredentialRequestPreconditions `json:"preconditions,omitempty"`
}
// CredentialRequestPreconditions makes the operation conditional on the
// Credential being unchanged since the caller read it, so a mint cannot
// silently replace a password someone else just received.
type CredentialRequestPreconditions struct {
// ResourceVersion is the Credential's resourceVersion the caller last read.
// +optional
ResourceVersion string `json:"resourceVersion,omitempty"`
}
// CredentialRequestStatus is the result of a mint or a revoke.
type CredentialRequestStatus struct {
// Username is the account name as the engine knows it.
Username string `json:"username,omitempty"`
// Password is the new plaintext, present in a mint's answer only and
// shown once.
// +optional
Password string `json:"password,omitempty"`
// IssuedAt is when the operation took effect in the record.
IssuedAt metav1.Time `json:"issuedAt,omitempty"`
}
+44
View File
@@ -122,3 +122,47 @@ func (in TapPackage) OpenAPIModelName() string {
func (in TapVerify) OpenAPIModelName() string {
return "com.github.cozystack.cozystack.pkg.apis.core.v1alpha1.TapVerify"
}
func (in Credential) OpenAPIModelName() string {
return "com.github.cozystack.cozystack.pkg.apis.core.v1alpha1.Credential"
}
func (in CredentialApplicationRef) OpenAPIModelName() string {
return "com.github.cozystack.cozystack.pkg.apis.core.v1alpha1.CredentialApplicationRef"
}
func (in CredentialHistoryEntry) OpenAPIModelName() string {
return "com.github.cozystack.cozystack.pkg.apis.core.v1alpha1.CredentialHistoryEntry"
}
func (in CredentialList) OpenAPIModelName() string {
return "com.github.cozystack.cozystack.pkg.apis.core.v1alpha1.CredentialList"
}
func (in CredentialPasswordState) OpenAPIModelName() string {
return "com.github.cozystack.cozystack.pkg.apis.core.v1alpha1.CredentialPasswordState"
}
func (in CredentialRequest) OpenAPIModelName() string {
return "com.github.cozystack.cozystack.pkg.apis.core.v1alpha1.CredentialRequest"
}
func (in CredentialRequestPreconditions) OpenAPIModelName() string {
return "com.github.cozystack.cozystack.pkg.apis.core.v1alpha1.CredentialRequestPreconditions"
}
func (in CredentialRequestSpec) OpenAPIModelName() string {
return "com.github.cozystack.cozystack.pkg.apis.core.v1alpha1.CredentialRequestSpec"
}
func (in CredentialRequestStatus) OpenAPIModelName() string {
return "com.github.cozystack.cozystack.pkg.apis.core.v1alpha1.CredentialRequestStatus"
}
func (in CredentialSpec) OpenAPIModelName() string {
return "com.github.cozystack.cozystack.pkg.apis.core.v1alpha1.CredentialSpec"
}
func (in CredentialStatus) OpenAPIModelName() string {
return "com.github.cozystack.cozystack.pkg.apis.core.v1alpha1.CredentialStatus"
}
+4 -1
View File
@@ -65,7 +65,10 @@ func RegisterStaticTypes(scheme *runtime.Scheme) {
&OptionList{},
&Tap{},
&TapList{},
&Credential{},
&CredentialList{},
&CredentialRequest{},
)
metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
klog.V(1).Info("Registered static kinds: TenantNamespace, TenantSecret, TenantModule, Option, Tap")
klog.V(1).Info("Registered static kinds: TenantNamespace, TenantSecret, TenantModule, Option, Tap, Credential, CredentialRequest")
}
@@ -26,6 +26,240 @@ import (
runtime "k8s.io/apimachinery/pkg/runtime"
)
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *Credential) DeepCopyInto(out *Credential) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
out.Spec = in.Spec
in.Status.DeepCopyInto(&out.Status)
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Credential.
func (in *Credential) DeepCopy() *Credential {
if in == nil {
return nil
}
out := new(Credential)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *Credential) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
}
return nil
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *CredentialApplicationRef) DeepCopyInto(out *CredentialApplicationRef) {
*out = *in
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CredentialApplicationRef.
func (in *CredentialApplicationRef) DeepCopy() *CredentialApplicationRef {
if in == nil {
return nil
}
out := new(CredentialApplicationRef)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *CredentialHistoryEntry) DeepCopyInto(out *CredentialHistoryEntry) {
*out = *in
in.At.DeepCopyInto(&out.At)
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CredentialHistoryEntry.
func (in *CredentialHistoryEntry) DeepCopy() *CredentialHistoryEntry {
if in == nil {
return nil
}
out := new(CredentialHistoryEntry)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *CredentialList) DeepCopyInto(out *CredentialList) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ListMeta.DeepCopyInto(&out.ListMeta)
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]Credential, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CredentialList.
func (in *CredentialList) DeepCopy() *CredentialList {
if in == nil {
return nil
}
out := new(CredentialList)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *CredentialList) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
}
return nil
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *CredentialPasswordState) DeepCopyInto(out *CredentialPasswordState) {
*out = *in
in.At.DeepCopyInto(&out.At)
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CredentialPasswordState.
func (in *CredentialPasswordState) DeepCopy() *CredentialPasswordState {
if in == nil {
return nil
}
out := new(CredentialPasswordState)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *CredentialRequest) DeepCopyInto(out *CredentialRequest) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
in.Spec.DeepCopyInto(&out.Spec)
in.Status.DeepCopyInto(&out.Status)
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CredentialRequest.
func (in *CredentialRequest) DeepCopy() *CredentialRequest {
if in == nil {
return nil
}
out := new(CredentialRequest)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *CredentialRequest) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
}
return nil
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *CredentialRequestPreconditions) DeepCopyInto(out *CredentialRequestPreconditions) {
*out = *in
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CredentialRequestPreconditions.
func (in *CredentialRequestPreconditions) DeepCopy() *CredentialRequestPreconditions {
if in == nil {
return nil
}
out := new(CredentialRequestPreconditions)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *CredentialRequestSpec) DeepCopyInto(out *CredentialRequestSpec) {
*out = *in
if in.Preconditions != nil {
in, out := &in.Preconditions, &out.Preconditions
*out = new(CredentialRequestPreconditions)
**out = **in
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CredentialRequestSpec.
func (in *CredentialRequestSpec) DeepCopy() *CredentialRequestSpec {
if in == nil {
return nil
}
out := new(CredentialRequestSpec)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *CredentialRequestStatus) DeepCopyInto(out *CredentialRequestStatus) {
*out = *in
in.IssuedAt.DeepCopyInto(&out.IssuedAt)
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CredentialRequestStatus.
func (in *CredentialRequestStatus) DeepCopy() *CredentialRequestStatus {
if in == nil {
return nil
}
out := new(CredentialRequestStatus)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *CredentialSpec) DeepCopyInto(out *CredentialSpec) {
*out = *in
out.Application = in.Application
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CredentialSpec.
func (in *CredentialSpec) DeepCopy() *CredentialSpec {
if in == nil {
return nil
}
out := new(CredentialSpec)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *CredentialStatus) DeepCopyInto(out *CredentialStatus) {
*out = *in
in.Password.DeepCopyInto(&out.Password)
if in.History != nil {
in, out := &in.History, &out.History
*out = make([]CredentialHistoryEntry, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CredentialStatus.
func (in *CredentialStatus) DeepCopy() *CredentialStatus {
if in == nil {
return nil
}
out := new(CredentialStatus)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *Option) DeepCopyInto(out *Option) {
*out = *in
+368
View File
@@ -0,0 +1,368 @@
// SPDX-License-Identifier: Apache-2.0
// Package account is what the Cozystack API and the migration tooling share
// about account Secrets: their names, the labels and annotations that carry
// the record, and how a kind's credentials block yields the accounts of one
// application. It writes nothing itself.
package account
import (
"encoding/json"
"errors"
"fmt"
"regexp"
"strings"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/validation"
cozyv1alpha1 "github.com/cozystack/cozystack/api/v1alpha1"
appsv1alpha1 "github.com/cozystack/cozystack/pkg/apis/apps/v1alpha1"
corev1alpha1 "github.com/cozystack/cozystack/pkg/apis/core/v1alpha1"
"github.com/cozystack/cozystack/pkg/credentials/format"
)
const (
// AccountLabel marks a Secret the API writes for one account, so the
// Credential view can list by label without matching any other Secret of
// the application.
AccountLabel = "credentials.cozystack.io/account"
// OriginAnnotation holds the CredentialOrigin of the live password.
OriginAnnotation = "credentials.cozystack.io/origin"
// AtAnnotation holds when the live password was set, RFC 3339.
AtAnnotation = "credentials.cozystack.io/at"
// ByAnnotation holds who set the live password.
ByAnnotation = "credentials.cozystack.io/by"
// HistoryAnnotation holds the last HistoryLimit operations as a JSON list,
// newest first.
HistoryAnnotation = "credentials.cozystack.io/history"
// HistoryLimit bounds the history kept on the Secret; the audit log keeps
// every operation.
HistoryLimit = 10
// SecretSuffix follows the mapped account name in the Secret's name.
SecretSuffix = ".account"
// UsernameKey and PasswordKey are the two data keys of every account
// Secret, whatever the format.
UsernameKey = "username"
PasswordKey = "password"
)
// ErrNotBuilt marks a declared format or source kind the API cannot serve yet.
var ErrNotBuilt = errors.New("declared but not built")
var nonNameChars = regexp.MustCompile(`[^a-z0-9-]`)
// Account is one tenant account of an application.
type Account struct {
// Username as the application declares it and the engine knows it.
Username string
// Mapped is Username lowercased with every character outside [a-z0-9-]
// replaced by "-"; it names the Secret and the Credential.
Mapped string
}
// MapName returns the object-name form of a user name, or an error when the
// form is not a valid DNS label, which no Secret or Credential name can carry.
func MapName(username string) (string, error) {
mapped := nonNameChars.ReplaceAllString(strings.ToLower(username), "-")
if errs := validation.IsDNS1123Label(mapped); len(errs) > 0 {
return "", fmt.Errorf("user name %q maps to %q, which is not a valid name: %s", username, mapped, strings.Join(errs, "; "))
}
return mapped, nil
}
// SecretName is the account Secret of a user of a release.
func SecretName(release, mapped string) string {
return release + "." + mapped + SecretSuffix
}
// CredentialName is the Credential of a user of a release.
func CredentialName(release, mapped string) string {
return release + "." + mapped
}
// SplitCredentialName returns the release and mapped user of a Credential
// name. Release names carry no dot, so the first one separates them.
func SplitCredentialName(name string) (release, mapped string, ok bool) {
release, mapped, ok = strings.Cut(name, ".")
if !ok || release == "" || mapped == "" || strings.Contains(mapped, ".") {
return "", "", false
}
return release, mapped, true
}
// Validate reports whether the API can serve a kind with this block. A format
// or a source kind that is declared but not built, an unknown built-in format,
// or a source missing the field its kind needs, refuses the whole kind, as a
// kind with an invalid name schema is refused today.
func Validate(c *cozyv1alpha1.ApplicationDefinitionCredentials) error {
if c == nil {
return nil
}
switch c.Format.Kind {
case "", cozyv1alpha1.CredentialFormatBuiltIn:
if !format.Known(c.Format.Name) {
return fmt.Errorf("format %q is not a built-in format", c.Format.Name)
}
case cozyv1alpha1.CredentialFormatWebhook:
return fmt.Errorf("format kind Webhook: %w", ErrNotBuilt)
default:
return fmt.Errorf("format kind %q is unknown", c.Format.Kind)
}
if c.ValuesPath != "" && !strings.HasPrefix(c.ValuesPath, "_") {
return fmt.Errorf("valuesPath %q must start with \"_\"", c.ValuesPath)
}
if len(c.Accounts) == 0 {
return errors.New("accounts is empty")
}
for i, s := range c.Accounts {
switch s.Kind {
case cozyv1alpha1.CredentialAccountsValuesMap:
if s.Path == "" {
return fmt.Errorf("accounts[%d]: a ValuesMap source needs a path", i)
}
case cozyv1alpha1.CredentialAccountsStatic:
if s.Name == "" {
return fmt.Errorf("accounts[%d]: a Static source needs a name", i)
}
case cozyv1alpha1.CredentialAccountsValuesList, cozyv1alpha1.CredentialAccountsExpression, cozyv1alpha1.CredentialAccountsWebhook:
return fmt.Errorf("accounts[%d]: source kind %s: %w", i, s.Kind, ErrNotBuilt)
default:
return fmt.Errorf("accounts[%d]: source kind %q is unknown", i, s.Kind)
}
switch s.Owner {
case "", cozyv1alpha1.CredentialAccountOwnerTenant, cozyv1alpha1.CredentialAccountOwnerPlatform:
default:
return fmt.Errorf("accounts[%d]: owner %q is unknown", i, s.Owner)
}
}
return nil
}
// Resolve returns the tenant accounts of an application from its defaulted
// spec values, in declaration order. Platform accounts are left out, and a
// ValuesMap key that names one is skipped. Two users that map to one name,
// or a user whose name maps to an invalid one, are an error naming them.
func Resolve(c *cozyv1alpha1.ApplicationDefinitionCredentials, values map[string]any) ([]Account, error) {
if c == nil {
return nil, nil
}
platform := map[string]bool{}
for _, s := range c.Accounts {
if s.Kind == cozyv1alpha1.CredentialAccountsStatic && s.Owner == cozyv1alpha1.CredentialAccountOwnerPlatform {
platform[s.Name] = true
}
}
var accounts []Account
byMapped := map[string]string{}
add := func(username string) error {
mapped, err := MapName(username)
if err != nil {
return err
}
if other, dup := byMapped[mapped]; dup {
if other == username {
return nil
}
return fmt.Errorf("users %q and %q both map to the name %q; rename one of them", other, username, mapped)
}
byMapped[mapped] = username
accounts = append(accounts, Account{Username: username, Mapped: mapped})
return nil
}
for _, s := range c.Accounts {
switch s.Kind {
case cozyv1alpha1.CredentialAccountsValuesMap:
m, _ := Lookup(values, s.Path).(map[string]any)
for _, name := range sortedKeys(m) {
if platform[name] {
continue
}
if err := add(name); err != nil {
return nil, err
}
}
case cozyv1alpha1.CredentialAccountsStatic:
if s.Owner == cozyv1alpha1.CredentialAccountOwnerPlatform {
continue
}
if s.When != "" {
on, _ := Lookup(values, s.When).(bool)
if !on {
continue
}
}
if err := add(s.Name); err != nil {
return nil, err
}
}
}
return accounts, nil
}
// PlatformAccounts returns the names of the kind's platform accounts.
func PlatformAccounts(c *cozyv1alpha1.ApplicationDefinitionCredentials) []string {
if c == nil {
return nil
}
var names []string
for _, s := range c.Accounts {
if s.Kind == cozyv1alpha1.CredentialAccountsStatic && s.Owner == cozyv1alpha1.CredentialAccountOwnerPlatform {
names = append(names, s.Name)
}
}
return names
}
// ValuesMapPaths returns the paths of the kind's ValuesMap sources.
func ValuesMapPaths(c *cozyv1alpha1.ApplicationDefinitionCredentials) []string {
if c == nil {
return nil
}
var paths []string
for _, s := range c.Accounts {
if s.Kind == cozyv1alpha1.CredentialAccountsValuesMap {
paths = append(paths, s.Path)
}
}
return paths
}
// Lookup walks a dotted path through nested maps and returns what it finds,
// or nil where the path leaves the maps.
func Lookup(values map[string]any, path string) any {
var cur any = values
for _, key := range strings.Split(path, ".") {
m, ok := cur.(map[string]any)
if !ok {
return nil
}
cur, ok = m[key]
if !ok {
return nil
}
}
return cur
}
func sortedKeys(m map[string]any) []string {
keys := make([]string, 0, len(m))
for k := range m {
keys = append(keys, k)
}
// Declaration order inside a map is the sorted order: it is what a chart's
// range sees and what makes the seeding deterministic.
sortStrings(keys)
return keys
}
func sortStrings(s []string) {
for i := 1; i < len(s); i++ {
for j := i; j > 0 && s[j] < s[j-1]; j-- {
s[j], s[j-1] = s[j-1], s[j]
}
}
}
// Record is the per-account record an account Secret carries in its
// annotations and the Credential view shows.
type Record struct {
Origin corev1alpha1.CredentialOrigin
At metav1.Time
By string
History []corev1alpha1.CredentialHistoryEntry
}
// ReadRecord decodes the record of an account Secret. A Secret with no
// annotations yields an empty record rather than an error, so a Secret
// written by hand still lists.
func ReadRecord(sec *corev1.Secret) Record {
var r Record
ann := sec.GetAnnotations()
r.Origin = corev1alpha1.CredentialOrigin(ann[OriginAnnotation])
r.By = ann[ByAnnotation]
if at := ann[AtAnnotation]; at != "" {
if t, err := parseTime(at); err == nil {
r.At = t
}
}
if h := ann[HistoryAnnotation]; h != "" {
_ = json.Unmarshal([]byte(h), &r.History)
}
return r
}
// WriteRecord encodes the record into the Secret's annotations.
func WriteRecord(sec *corev1.Secret, r Record) {
if sec.Annotations == nil {
sec.Annotations = map[string]string{}
}
sec.Annotations[OriginAnnotation] = string(r.Origin)
sec.Annotations[ByAnnotation] = r.By
sec.Annotations[AtAnnotation] = r.At.UTC().Format(timeLayout)
history, _ := json.Marshal(r.History)
sec.Annotations[HistoryAnnotation] = string(history)
}
// Apply records an operation: the origin becomes the operation's, At and By
// are the operation's, and the entry goes to the front of the history, which
// keeps HistoryLimit entries.
func (r Record) Apply(op corev1alpha1.CredentialOperation, at metav1.Time, by string) Record {
r.Origin = originOf(op)
r.At = at
r.By = by
entry := corev1alpha1.CredentialHistoryEntry{Operation: op, At: at, By: by}
history := make([]corev1alpha1.CredentialHistoryEntry, 0, len(r.History)+1)
history = append(history, entry)
history = append(history, r.History...)
if len(history) > HistoryLimit {
history = history[:HistoryLimit]
}
r.History = history
return r
}
func originOf(op corev1alpha1.CredentialOperation) corev1alpha1.CredentialOrigin {
switch op {
case corev1alpha1.CredentialOperationMigrate:
return corev1alpha1.CredentialOriginMigrated
case corev1alpha1.CredentialOperationMint:
return corev1alpha1.CredentialOriginMinted
case corev1alpha1.CredentialOperationRevoke:
return corev1alpha1.CredentialOriginRevoked
}
return corev1alpha1.CredentialOriginNotIssued
}
const timeLayout = "2006-01-02T15:04:05Z"
func parseTime(s string) (metav1.Time, error) {
var t metav1.Time
err := t.UnmarshalQueryParameter(s)
return t, err
}
// Labels are the labels every account Secret of an application carries: the
// account marker, the application identity the view lists by, and the labels
// the kind's block names for its operator.
func Labels(c *cozyv1alpha1.ApplicationDefinitionCredentials, group, kind, name string) map[string]string {
labels := map[string]string{
AccountLabel: "true",
appsv1alpha1.ApplicationGroupLabel: group,
appsv1alpha1.ApplicationKindLabel: kind,
appsv1alpha1.ApplicationNameLabel: name,
}
if c != nil {
for k, v := range c.SecretLabels {
labels[k] = v
}
}
return labels
}
// IsAccountSecret reports whether a Secret is one the API writes for an
// account.
func IsAccountSecret(sec *corev1.Secret) bool {
return sec != nil && sec.Labels[AccountLabel] == "true"
}
+218
View File
@@ -0,0 +1,218 @@
// SPDX-License-Identifier: Apache-2.0
package account
import (
"errors"
"strings"
"testing"
"time"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
cozyv1alpha1 "github.com/cozystack/cozystack/api/v1alpha1"
corev1alpha1 "github.com/cozystack/cozystack/pkg/apis/core/v1alpha1"
)
func TestMapName(t *testing.T) {
tests := []struct {
in, want string
wantErr bool
}{
{in: "web", want: "web"},
{in: "Bob.Smith", want: "bob-smith"},
{in: "app_user", want: "app-user"},
{in: "-leading", wantErr: true},
{in: "", wantErr: true},
{in: strings.Repeat("a", 64), wantErr: true},
}
for _, tt := range tests {
got, err := MapName(tt.in)
if tt.wantErr {
if err == nil {
t.Errorf("MapName(%q) = %q, want an error", tt.in, got)
}
continue
}
if err != nil {
t.Errorf("MapName(%q): %v", tt.in, err)
continue
}
if got != tt.want {
t.Errorf("MapName(%q) = %q, want %q", tt.in, got, tt.want)
}
}
}
func TestNames(t *testing.T) {
if got := SecretName("postgres-orders", "web"); got != "postgres-orders.web.account" {
t.Errorf("SecretName = %q", got)
}
if got := CredentialName("postgres-orders", "web"); got != "postgres-orders.web" {
t.Errorf("CredentialName = %q", got)
}
release, mapped, ok := SplitCredentialName("postgres-orders.bob-smith")
if !ok || release != "postgres-orders" || mapped != "bob-smith" {
t.Errorf("SplitCredentialName = %q, %q, %v", release, mapped, ok)
}
for _, bad := range []string{"nodot", "a.b.c", ".x", "x."} {
if _, _, ok := SplitCredentialName(bad); ok {
t.Errorf("SplitCredentialName(%q) accepted", bad)
}
}
}
func block(sources ...cozyv1alpha1.CredentialAccountSource) *cozyv1alpha1.ApplicationDefinitionCredentials {
return &cozyv1alpha1.ApplicationDefinitionCredentials{
Format: cozyv1alpha1.CredentialFormat{Name: "scram-sha-256"},
Accounts: sources,
}
}
func valuesMap(path string) cozyv1alpha1.CredentialAccountSource {
return cozyv1alpha1.CredentialAccountSource{Kind: cozyv1alpha1.CredentialAccountsValuesMap, Path: path}
}
func static(name, when string, owner cozyv1alpha1.CredentialAccountOwner) cozyv1alpha1.CredentialAccountSource {
return cozyv1alpha1.CredentialAccountSource{Kind: cozyv1alpha1.CredentialAccountsStatic, Name: name, When: when, Owner: owner}
}
func TestValidate(t *testing.T) {
if err := Validate(nil); err != nil {
t.Errorf("nil block: %v", err)
}
if err := Validate(block(valuesMap("users"))); err != nil {
t.Errorf("valid block: %v", err)
}
notBuilt := []*cozyv1alpha1.ApplicationDefinitionCredentials{
{Format: cozyv1alpha1.CredentialFormat{Name: "apr1", Kind: cozyv1alpha1.CredentialFormatWebhook}, Accounts: []cozyv1alpha1.CredentialAccountSource{valuesMap("users")}},
block(cozyv1alpha1.CredentialAccountSource{Kind: cozyv1alpha1.CredentialAccountsValuesList, Path: "accounts", NameField: "name"}),
block(cozyv1alpha1.CredentialAccountSource{Kind: cozyv1alpha1.CredentialAccountsExpression, Expression: "spec.users"}),
block(cozyv1alpha1.CredentialAccountSource{Kind: cozyv1alpha1.CredentialAccountsWebhook}),
}
for i, b := range notBuilt {
err := Validate(b)
if !errors.Is(err, ErrNotBuilt) {
t.Errorf("notBuilt[%d]: got %v, want ErrNotBuilt", i, err)
}
}
invalid := []*cozyv1alpha1.ApplicationDefinitionCredentials{
{Format: cozyv1alpha1.CredentialFormat{Name: "apr1"}, Accounts: []cozyv1alpha1.CredentialAccountSource{valuesMap("users")}},
{Format: cozyv1alpha1.CredentialFormat{Name: "sha256"}, ValuesPath: "accounts", Accounts: []cozyv1alpha1.CredentialAccountSource{valuesMap("users")}},
{Format: cozyv1alpha1.CredentialFormat{Name: "sha256"}},
block(cozyv1alpha1.CredentialAccountSource{Kind: cozyv1alpha1.CredentialAccountsValuesMap}),
block(cozyv1alpha1.CredentialAccountSource{Kind: cozyv1alpha1.CredentialAccountsStatic}),
block(static("x", "", "nobody")),
}
for i, b := range invalid {
if err := Validate(b); err == nil || errors.Is(err, ErrNotBuilt) {
t.Errorf("invalid[%d]: got %v, want a validation error", i, err)
}
}
}
func TestResolve(t *testing.T) {
values := map[string]any{
"users": map[string]any{
"web": map[string]any{},
"Bob.Smith": map[string]any{},
"backup": map[string]any{},
},
"authEnabled": true,
"nested": map[string]any{"accounts": map[string]any{"deep": map[string]any{}}},
}
b := block(valuesMap("users"), static("backup", "", cozyv1alpha1.CredentialAccountOwnerPlatform), static("default", "authEnabled", ""), static("off", "missing", ""))
got, err := Resolve(b, values)
if err != nil {
t.Fatalf("resolve: %v", err)
}
want := []Account{{"Bob.Smith", "bob-smith"}, {"web", "web"}, {"default", "default"}}
if len(got) != len(want) {
t.Fatalf("got %v, want %v", got, want)
}
for i := range want {
if got[i] != want[i] {
t.Errorf("accounts[%d] = %v, want %v", i, got[i], want[i])
}
}
if got, err := Resolve(block(valuesMap("nested.accounts")), values); err != nil || len(got) != 1 || got[0].Username != "deep" {
t.Errorf("dotted path: %v, %v", got, err)
}
if got, err := Resolve(block(valuesMap("absent")), values); err != nil || len(got) != 0 {
t.Errorf("absent path: %v, %v", got, err)
}
collide := map[string]any{"users": map[string]any{"a_b": map[string]any{}, "a-b": map[string]any{}}}
if _, err := Resolve(block(valuesMap("users")), collide); err == nil || !strings.Contains(err.Error(), "a-b") {
t.Errorf("collision: %v", err)
}
bad := map[string]any{"users": map[string]any{"-x": map[string]any{}}}
if _, err := Resolve(block(valuesMap("users")), bad); err == nil {
t.Error("invalid name accepted")
}
if names := PlatformAccounts(b); len(names) != 1 || names[0] != "backup" {
t.Errorf("PlatformAccounts = %v", names)
}
if paths := ValuesMapPaths(b); len(paths) != 1 || paths[0] != "users" {
t.Errorf("ValuesMapPaths = %v", paths)
}
}
func TestRecordRoundTrip(t *testing.T) {
sec := &corev1.Secret{}
if r := ReadRecord(sec); r.Origin != "" || len(r.History) != 0 {
t.Errorf("empty Secret read as %+v", r)
}
at := metav1.NewTime(time.Date(2026, 10, 2, 9, 14, 7, 0, time.UTC))
r := Record{}.Apply(corev1alpha1.CredentialOperationCreate, at, "jane@example.org")
r = r.Apply(corev1alpha1.CredentialOperationMint, at, "jane@example.org")
WriteRecord(sec, r)
back := ReadRecord(sec)
if back.Origin != corev1alpha1.CredentialOriginMinted || back.By != "jane@example.org" || !back.At.Equal(&at) {
t.Errorf("record read back as %+v", back)
}
if len(back.History) != 2 || back.History[0].Operation != corev1alpha1.CredentialOperationMint || back.History[1].Operation != corev1alpha1.CredentialOperationCreate {
t.Errorf("history read back as %+v", back.History)
}
for range HistoryLimit + 5 {
r = r.Apply(corev1alpha1.CredentialOperationRevoke, at, "bob")
}
if len(r.History) != HistoryLimit {
t.Errorf("history has %d entries, want %d", len(r.History), HistoryLimit)
}
if r.Origin != corev1alpha1.CredentialOriginRevoked {
t.Errorf("origin %s after revoke", r.Origin)
}
}
func TestLabels(t *testing.T) {
b := &cozyv1alpha1.ApplicationDefinitionCredentials{SecretLabels: map[string]string{"cnpg.io/reload": "true"}}
l := Labels(b, "apps.cozystack.io", "Postgres", "orders")
for k, v := range map[string]string{
AccountLabel: "true",
"apps.cozystack.io/application.group": "apps.cozystack.io",
"apps.cozystack.io/application.kind": "Postgres",
"apps.cozystack.io/application.name": "orders",
"cnpg.io/reload": "true",
} {
if l[k] != v {
t.Errorf("label %s = %q, want %q", k, l[k], v)
}
}
if !IsAccountSecret(&corev1.Secret{ObjectMeta: metav1.ObjectMeta{Labels: l}}) {
t.Error("labelled Secret not recognised")
}
if IsAccountSecret(&corev1.Secret{}) {
t.Error("bare Secret recognised")
}
}
+137
View File
@@ -0,0 +1,137 @@
// SPDX-License-Identifier: Apache-2.0
// Package format turns a password into the value an engine stores to check
// it, and generates the passwords. It knows formats and no engines: a kind
// names one of these in the credentials block of its ApplicationDefinition,
// and the migration tooling imports the same functions, so the API and the
// migration write the same bytes.
package format
import (
"crypto/hmac"
"crypto/pbkdf2"
"crypto/rand"
"crypto/sha1"
"crypto/sha256"
"encoding/base64"
"encoding/hex"
"fmt"
"strings"
)
// Built-in format names.
const (
// ScramSHA256 is PostgreSQL's SCRAM-SHA-256 verifier,
// SCRAM-SHA-256$<iterations>:<salt>$<StoredKey>:<ServerKey>, which
// ALTER ROLE ... PASSWORD stores as it is.
ScramSHA256 = "scram-sha-256"
// MySQLNative is the mysql_native_password hash, "*" followed by the
// upper-case hex of SHA1(SHA1(password)), which mariadb-operator pastes
// into ALTER USER ... IDENTIFIED BY PASSWORD as it is.
MySQLNative = "mysql-native"
// SHA256 is the lower-case hex of SHA-256(password), ClickHouse's
// password_sha256_hex.
SHA256 = "sha256"
// Plaintext stores the password itself, for an engine whose operator or
// server computes its own verifier from it.
Plaintext = "plaintext"
)
// PasswordLength is the length of every generated password.
const PasswordLength = 32
// passwordAlphabet needs no escaping in SQL, connection URIs or shells, and
// 32 characters of it carry about 190 bits of entropy.
const passwordAlphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
// scramIterations is PostgreSQL's default for SCRAM-SHA-256.
const scramIterations = 4096
// scramSaltLength matches what PostgreSQL itself generates.
const scramSaltLength = 16
// Known reports whether name is a built-in format.
func Known(name string) bool {
switch name {
case ScramSHA256, MySQLNative, SHA256, Plaintext:
return true
}
return false
}
// GeneratePassword draws PasswordLength characters uniformly from the
// alphabet with crypto/rand. Rejection sampling keeps the draw unbiased: a
// byte is accepted only below the largest multiple of the alphabet size.
func GeneratePassword() (string, error) {
const limit = byte(256 - 256%len(passwordAlphabet))
out := make([]byte, 0, PasswordLength)
buf := make([]byte, PasswordLength*2)
for len(out) < PasswordLength {
if _, err := rand.Read(buf); err != nil {
return "", fmt.Errorf("read random bytes: %w", err)
}
for _, b := range buf {
if b >= limit {
continue
}
out = append(out, passwordAlphabet[int(b)%len(passwordAlphabet)])
if len(out) == PasswordLength {
break
}
}
}
return string(out), nil
}
// Encode returns the stored form of password in the named built-in format.
func Encode(name, password string) (string, error) {
switch name {
case ScramSHA256:
salt := make([]byte, scramSaltLength)
if _, err := rand.Read(salt); err != nil {
return "", fmt.Errorf("read salt: %w", err)
}
return encodeScramSHA256(password, salt, scramIterations)
case MySQLNative:
return encodeMySQLNative(password), nil
case SHA256:
sum := sha256.Sum256([]byte(password))
return hex.EncodeToString(sum[:]), nil
case Plaintext:
return password, nil
}
return "", fmt.Errorf("unknown password format %q", name)
}
// encodeScramSHA256 builds the verifier PostgreSQL stores for a SCRAM
// password (RFC 5802 with SHA-256, RFC 7677): the salted password through
// PBKDF2, the client key hashed into the stored key, and the server key.
// The password is used as is: the generated alphabet is plain ASCII, which
// SASLprep leaves unchanged.
func encodeScramSHA256(password string, salt []byte, iterations int) (string, error) {
salted, err := pbkdf2.Key(sha256.New, password, salt, iterations, sha256.Size)
if err != nil {
return "", fmt.Errorf("derive salted password: %w", err)
}
clientKey := hmacSHA256(salted, "Client Key")
storedKey := sha256.Sum256(clientKey)
serverKey := hmacSHA256(salted, "Server Key")
return fmt.Sprintf("SCRAM-SHA-256$%d:%s$%s:%s",
iterations,
base64.StdEncoding.EncodeToString(salt),
base64.StdEncoding.EncodeToString(storedKey[:]),
base64.StdEncoding.EncodeToString(serverKey),
), nil
}
func hmacSHA256(key []byte, message string) []byte {
mac := hmac.New(sha256.New, key)
mac.Write([]byte(message))
return mac.Sum(nil)
}
func encodeMySQLNative(password string) string {
first := sha1.Sum([]byte(password))
second := sha1.Sum(first[:])
return "*" + strings.ToUpper(hex.EncodeToString(second[:]))
}
+122
View File
@@ -0,0 +1,122 @@
// SPDX-License-Identifier: Apache-2.0
package format
import (
"crypto/hmac"
"crypto/pbkdf2"
"crypto/sha256"
"encoding/base64"
"regexp"
"strings"
"testing"
)
func TestGeneratePassword(t *testing.T) {
seen := map[string]bool{}
for range 64 {
p, err := GeneratePassword()
if err != nil {
t.Fatalf("generate: %v", err)
}
if len(p) != PasswordLength {
t.Fatalf("password %q has length %d, want %d", p, len(p), PasswordLength)
}
for _, c := range p {
if !strings.ContainsRune(passwordAlphabet, c) {
t.Fatalf("password %q carries %q outside the alphabet", p, c)
}
}
if seen[p] {
t.Fatalf("password %q generated twice", p)
}
seen[p] = true
}
}
// The verifier must be the canonical PostgreSQL form, since CNPG forwards it
// unchanged and PostgreSQL stores anything else as a plaintext password. The
// keys are recomputed here from the salt the verifier carries with the
// primitives RFC 5802 names, independently of the encoder's own helpers.
func TestEncodeScramSHA256(t *testing.T) {
const password = "pencil"
salt, err := base64.StdEncoding.DecodeString("W22ZaJ0SNY7soEsUEjb6gQ==")
if err != nil {
t.Fatal(err)
}
got, err := encodeScramSHA256(password, salt, 4096)
if err != nil {
t.Fatalf("encode: %v", err)
}
re := regexp.MustCompile(`^SCRAM-SHA-256\$(\d+):([A-Za-z0-9+/=]+)\$([A-Za-z0-9+/=]+):([A-Za-z0-9+/=]+)$`)
m := re.FindStringSubmatch(got)
if m == nil {
t.Fatalf("verifier %q is not in the canonical form", got)
}
if m[1] != "4096" {
t.Errorf("iterations %s, want 4096", m[1])
}
if m[2] != "W22ZaJ0SNY7soEsUEjb6gQ==" {
t.Errorf("salt %s, want the input salt", m[2])
}
salted, err := pbkdf2.Key(sha256.New, password, salt, 4096, 32)
if err != nil {
t.Fatal(err)
}
mac := hmac.New(sha256.New, salted)
mac.Write([]byte("Client Key"))
stored := sha256.Sum256(mac.Sum(nil))
mac = hmac.New(sha256.New, salted)
mac.Write([]byte("Server Key"))
server := mac.Sum(nil)
if want := base64.StdEncoding.EncodeToString(stored[:]); m[3] != want {
t.Errorf("StoredKey %s, want %s", m[3], want)
}
if want := base64.StdEncoding.EncodeToString(server); m[4] != want {
t.Errorf("ServerKey %s, want %s", m[4], want)
}
// A fresh salt every call, so two encodings of one password differ.
a, _ := Encode(ScramSHA256, password)
b, _ := Encode(ScramSHA256, password)
if a == b {
t.Errorf("two SCRAM encodings share a salt: %s", a)
}
}
func TestEncodeFixedVectors(t *testing.T) {
tests := []struct {
format, password, want string
}{
// MySQL's own PASSWORD('password').
{MySQLNative, "password", "*2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19"},
// SHA-256 of "abc", FIPS 180-2 example B.1.
{SHA256, "abc", "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad"},
{Plaintext, "as-is", "as-is"},
}
for _, tt := range tests {
got, err := Encode(tt.format, tt.password)
if err != nil {
t.Fatalf("%s: %v", tt.format, err)
}
if got != tt.want {
t.Errorf("%s(%q) = %q, want %q", tt.format, tt.password, got, tt.want)
}
}
}
func TestEncodeUnknownFormat(t *testing.T) {
if _, err := Encode("apr1", "x"); err == nil {
t.Fatal("expected an error for an unknown format")
}
for _, name := range []string{ScramSHA256, MySQLNative, SHA256, Plaintext} {
if !Known(name) {
t.Errorf("%s not known", name)
}
}
if Known("apr1") {
t.Error("apr1 reported known")
}
}
+507 -111
View File
@@ -36,117 +36,128 @@ import (
func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenAPIDefinition {
return map[string]common.OpenAPIDefinition{
v1alpha1.Application{}.OpenAPIModelName(): schema_pkg_apis_apps_v1alpha1_Application(ref),
v1alpha1.ApplicationList{}.OpenAPIModelName(): schema_pkg_apis_apps_v1alpha1_ApplicationList(ref),
v1alpha1.ApplicationStatus{}.OpenAPIModelName(): schema_pkg_apis_apps_v1alpha1_ApplicationStatus(ref),
corev1alpha1.Option{}.OpenAPIModelName(): schema_pkg_apis_core_v1alpha1_Option(ref),
corev1alpha1.OptionItem{}.OpenAPIModelName(): schema_pkg_apis_core_v1alpha1_OptionItem(ref),
corev1alpha1.OptionList{}.OpenAPIModelName(): schema_pkg_apis_core_v1alpha1_OptionList(ref),
corev1alpha1.OptionSpec{}.OpenAPIModelName(): schema_pkg_apis_core_v1alpha1_OptionSpec(ref),
corev1alpha1.Tap{}.OpenAPIModelName(): schema_pkg_apis_core_v1alpha1_Tap(ref),
corev1alpha1.TapList{}.OpenAPIModelName(): schema_pkg_apis_core_v1alpha1_TapList(ref),
corev1alpha1.TapPackage{}.OpenAPIModelName(): schema_pkg_apis_core_v1alpha1_TapPackage(ref),
corev1alpha1.TapSource{}.OpenAPIModelName(): schema_pkg_apis_core_v1alpha1_TapSource(ref),
corev1alpha1.TapSpec{}.OpenAPIModelName(): schema_pkg_apis_core_v1alpha1_TapSpec(ref),
corev1alpha1.TapVerify{}.OpenAPIModelName(): schema_pkg_apis_core_v1alpha1_TapVerify(ref),
corev1alpha1.TenantModule{}.OpenAPIModelName(): schema_pkg_apis_core_v1alpha1_TenantModule(ref),
corev1alpha1.TenantModuleList{}.OpenAPIModelName(): schema_pkg_apis_core_v1alpha1_TenantModuleList(ref),
corev1alpha1.TenantModuleStatus{}.OpenAPIModelName(): schema_pkg_apis_core_v1alpha1_TenantModuleStatus(ref),
corev1alpha1.TenantNamespace{}.OpenAPIModelName(): schema_pkg_apis_core_v1alpha1_TenantNamespace(ref),
corev1alpha1.TenantNamespaceList{}.OpenAPIModelName(): schema_pkg_apis_core_v1alpha1_TenantNamespaceList(ref),
corev1alpha1.TenantSecret{}.OpenAPIModelName(): schema_pkg_apis_core_v1alpha1_TenantSecret(ref),
corev1alpha1.TenantSecretList{}.OpenAPIModelName(): schema_pkg_apis_core_v1alpha1_TenantSecretList(ref),
sdnv1alpha1.ApplicationReference{}.OpenAPIModelName(): schema_pkg_apis_sdn_v1alpha1_ApplicationReference(ref),
sdnv1alpha1.EgressRule{}.OpenAPIModelName(): schema_pkg_apis_sdn_v1alpha1_EgressRule(ref),
sdnv1alpha1.FQDNSelector{}.OpenAPIModelName(): schema_pkg_apis_sdn_v1alpha1_FQDNSelector(ref),
sdnv1alpha1.IngressRule{}.OpenAPIModelName(): schema_pkg_apis_sdn_v1alpha1_IngressRule(ref),
sdnv1alpha1.PortProtocol{}.OpenAPIModelName(): schema_pkg_apis_sdn_v1alpha1_PortProtocol(ref),
sdnv1alpha1.PortRule{}.OpenAPIModelName(): schema_pkg_apis_sdn_v1alpha1_PortRule(ref),
sdnv1alpha1.SecurityGroup{}.OpenAPIModelName(): schema_pkg_apis_sdn_v1alpha1_SecurityGroup(ref),
sdnv1alpha1.SecurityGroupList{}.OpenAPIModelName(): schema_pkg_apis_sdn_v1alpha1_SecurityGroupList(ref),
sdnv1alpha1.SecurityGroupSpec{}.OpenAPIModelName(): schema_pkg_apis_sdn_v1alpha1_SecurityGroupSpec(ref),
v1.ConversionRequest{}.OpenAPIModelName(): schema_pkg_apis_apiextensions_v1_ConversionRequest(ref),
v1.ConversionResponse{}.OpenAPIModelName(): schema_pkg_apis_apiextensions_v1_ConversionResponse(ref),
v1.ConversionReview{}.OpenAPIModelName(): schema_pkg_apis_apiextensions_v1_ConversionReview(ref),
v1.CustomResourceColumnDefinition{}.OpenAPIModelName(): schema_pkg_apis_apiextensions_v1_CustomResourceColumnDefinition(ref),
v1.CustomResourceConversion{}.OpenAPIModelName(): schema_pkg_apis_apiextensions_v1_CustomResourceConversion(ref),
v1.CustomResourceDefinition{}.OpenAPIModelName(): schema_pkg_apis_apiextensions_v1_CustomResourceDefinition(ref),
v1.CustomResourceDefinitionCondition{}.OpenAPIModelName(): schema_pkg_apis_apiextensions_v1_CustomResourceDefinitionCondition(ref),
v1.CustomResourceDefinitionList{}.OpenAPIModelName(): schema_pkg_apis_apiextensions_v1_CustomResourceDefinitionList(ref),
v1.CustomResourceDefinitionNames{}.OpenAPIModelName(): schema_pkg_apis_apiextensions_v1_CustomResourceDefinitionNames(ref),
v1.CustomResourceDefinitionSpec{}.OpenAPIModelName(): schema_pkg_apis_apiextensions_v1_CustomResourceDefinitionSpec(ref),
v1.CustomResourceDefinitionStatus{}.OpenAPIModelName(): schema_pkg_apis_apiextensions_v1_CustomResourceDefinitionStatus(ref),
v1.CustomResourceDefinitionVersion{}.OpenAPIModelName(): schema_pkg_apis_apiextensions_v1_CustomResourceDefinitionVersion(ref),
v1.CustomResourceSubresourceScale{}.OpenAPIModelName(): schema_pkg_apis_apiextensions_v1_CustomResourceSubresourceScale(ref),
v1.CustomResourceSubresourceStatus{}.OpenAPIModelName(): schema_pkg_apis_apiextensions_v1_CustomResourceSubresourceStatus(ref),
v1.CustomResourceSubresources{}.OpenAPIModelName(): schema_pkg_apis_apiextensions_v1_CustomResourceSubresources(ref),
v1.CustomResourceValidation{}.OpenAPIModelName(): schema_pkg_apis_apiextensions_v1_CustomResourceValidation(ref),
v1.ExternalDocumentation{}.OpenAPIModelName(): schema_pkg_apis_apiextensions_v1_ExternalDocumentation(ref),
v1.JSON{}.OpenAPIModelName(): schema_pkg_apis_apiextensions_v1_JSON(ref),
v1.JSONSchemaProps{}.OpenAPIModelName(): schema_pkg_apis_apiextensions_v1_JSONSchemaProps(ref),
v1.JSONSchemaPropsOrArray{}.OpenAPIModelName(): schema_pkg_apis_apiextensions_v1_JSONSchemaPropsOrArray(ref),
v1.JSONSchemaPropsOrBool{}.OpenAPIModelName(): schema_pkg_apis_apiextensions_v1_JSONSchemaPropsOrBool(ref),
v1.JSONSchemaPropsOrStringArray{}.OpenAPIModelName(): schema_pkg_apis_apiextensions_v1_JSONSchemaPropsOrStringArray(ref),
v1.SelectableField{}.OpenAPIModelName(): schema_pkg_apis_apiextensions_v1_SelectableField(ref),
v1.ServiceReference{}.OpenAPIModelName(): schema_pkg_apis_apiextensions_v1_ServiceReference(ref),
v1.ValidationRule{}.OpenAPIModelName(): schema_pkg_apis_apiextensions_v1_ValidationRule(ref),
v1.WebhookClientConfig{}.OpenAPIModelName(): schema_pkg_apis_apiextensions_v1_WebhookClientConfig(ref),
v1.WebhookConversion{}.OpenAPIModelName(): schema_pkg_apis_apiextensions_v1_WebhookConversion(ref),
resource.Quantity{}.OpenAPIModelName(): schema_apimachinery_pkg_api_resource_Quantity(ref),
metav1.APIGroup{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_APIGroup(ref),
metav1.APIGroupList{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_APIGroupList(ref),
metav1.APIResource{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_APIResource(ref),
metav1.APIResourceList{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_APIResourceList(ref),
metav1.APIVersions{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_APIVersions(ref),
metav1.ApplyOptions{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_ApplyOptions(ref),
metav1.Condition{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_Condition(ref),
metav1.CreateOptions{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_CreateOptions(ref),
metav1.DeleteOptions{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_DeleteOptions(ref),
metav1.Duration{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_Duration(ref),
metav1.FieldSelectorRequirement{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_FieldSelectorRequirement(ref),
metav1.FieldsV1{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_FieldsV1(ref),
metav1.GetOptions{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_GetOptions(ref),
metav1.GroupKind{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_GroupKind(ref),
metav1.GroupResource{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_GroupResource(ref),
metav1.GroupVersion{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_GroupVersion(ref),
metav1.GroupVersionForDiscovery{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_GroupVersionForDiscovery(ref),
metav1.GroupVersionKind{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_GroupVersionKind(ref),
metav1.GroupVersionResource{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_GroupVersionResource(ref),
metav1.InternalEvent{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_InternalEvent(ref),
metav1.LabelSelector{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_LabelSelector(ref),
metav1.LabelSelectorRequirement{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_LabelSelectorRequirement(ref),
metav1.List{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_List(ref),
metav1.ListMeta{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_ListMeta(ref),
metav1.ListOptions{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_ListOptions(ref),
metav1.ManagedFieldsEntry{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_ManagedFieldsEntry(ref),
metav1.MicroTime{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_MicroTime(ref),
metav1.ObjectMeta{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_ObjectMeta(ref),
metav1.OwnerReference{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_OwnerReference(ref),
metav1.PartialObjectMetadata{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_PartialObjectMetadata(ref),
metav1.PartialObjectMetadataList{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_PartialObjectMetadataList(ref),
metav1.Patch{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_Patch(ref),
metav1.PatchOptions{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_PatchOptions(ref),
metav1.Preconditions{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_Preconditions(ref),
metav1.RootPaths{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_RootPaths(ref),
metav1.ServerAddressByClientCIDR{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_ServerAddressByClientCIDR(ref),
metav1.ShardInfo{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_ShardInfo(ref),
metav1.Status{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_Status(ref),
metav1.StatusCause{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_StatusCause(ref),
metav1.StatusDetails{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_StatusDetails(ref),
metav1.Table{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_Table(ref),
metav1.TableColumnDefinition{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_TableColumnDefinition(ref),
metav1.TableOptions{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_TableOptions(ref),
metav1.TableRow{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_TableRow(ref),
metav1.TableRowCondition{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_TableRowCondition(ref),
metav1.Time{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_Time(ref),
metav1.Timestamp{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_Timestamp(ref),
metav1.TypeMeta{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_TypeMeta(ref),
metav1.UpdateOptions{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_UpdateOptions(ref),
metav1.WatchEvent{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_WatchEvent(ref),
runtime.RawExtension{}.OpenAPIModelName(): schema_k8sio_apimachinery_pkg_runtime_RawExtension(ref),
runtime.TypeMeta{}.OpenAPIModelName(): schema_k8sio_apimachinery_pkg_runtime_TypeMeta(ref),
runtime.Unknown{}.OpenAPIModelName(): schema_k8sio_apimachinery_pkg_runtime_Unknown(ref),
version.Info{}.OpenAPIModelName(): schema_k8sio_apimachinery_pkg_version_Info(ref),
v1alpha1.Application{}.OpenAPIModelName(): schema_pkg_apis_apps_v1alpha1_Application(ref),
v1alpha1.ApplicationList{}.OpenAPIModelName(): schema_pkg_apis_apps_v1alpha1_ApplicationList(ref),
v1alpha1.ApplicationStatus{}.OpenAPIModelName(): schema_pkg_apis_apps_v1alpha1_ApplicationStatus(ref),
corev1alpha1.Credential{}.OpenAPIModelName(): schema_pkg_apis_core_v1alpha1_Credential(ref),
corev1alpha1.CredentialApplicationRef{}.OpenAPIModelName(): schema_pkg_apis_core_v1alpha1_CredentialApplicationRef(ref),
corev1alpha1.CredentialHistoryEntry{}.OpenAPIModelName(): schema_pkg_apis_core_v1alpha1_CredentialHistoryEntry(ref),
corev1alpha1.CredentialList{}.OpenAPIModelName(): schema_pkg_apis_core_v1alpha1_CredentialList(ref),
corev1alpha1.CredentialPasswordState{}.OpenAPIModelName(): schema_pkg_apis_core_v1alpha1_CredentialPasswordState(ref),
corev1alpha1.CredentialRequest{}.OpenAPIModelName(): schema_pkg_apis_core_v1alpha1_CredentialRequest(ref),
corev1alpha1.CredentialRequestPreconditions{}.OpenAPIModelName(): schema_pkg_apis_core_v1alpha1_CredentialRequestPreconditions(ref),
corev1alpha1.CredentialRequestSpec{}.OpenAPIModelName(): schema_pkg_apis_core_v1alpha1_CredentialRequestSpec(ref),
corev1alpha1.CredentialRequestStatus{}.OpenAPIModelName(): schema_pkg_apis_core_v1alpha1_CredentialRequestStatus(ref),
corev1alpha1.CredentialSpec{}.OpenAPIModelName(): schema_pkg_apis_core_v1alpha1_CredentialSpec(ref),
corev1alpha1.CredentialStatus{}.OpenAPIModelName(): schema_pkg_apis_core_v1alpha1_CredentialStatus(ref),
corev1alpha1.Option{}.OpenAPIModelName(): schema_pkg_apis_core_v1alpha1_Option(ref),
corev1alpha1.OptionItem{}.OpenAPIModelName(): schema_pkg_apis_core_v1alpha1_OptionItem(ref),
corev1alpha1.OptionList{}.OpenAPIModelName(): schema_pkg_apis_core_v1alpha1_OptionList(ref),
corev1alpha1.OptionSpec{}.OpenAPIModelName(): schema_pkg_apis_core_v1alpha1_OptionSpec(ref),
corev1alpha1.Tap{}.OpenAPIModelName(): schema_pkg_apis_core_v1alpha1_Tap(ref),
corev1alpha1.TapList{}.OpenAPIModelName(): schema_pkg_apis_core_v1alpha1_TapList(ref),
corev1alpha1.TapPackage{}.OpenAPIModelName(): schema_pkg_apis_core_v1alpha1_TapPackage(ref),
corev1alpha1.TapSource{}.OpenAPIModelName(): schema_pkg_apis_core_v1alpha1_TapSource(ref),
corev1alpha1.TapSpec{}.OpenAPIModelName(): schema_pkg_apis_core_v1alpha1_TapSpec(ref),
corev1alpha1.TapVerify{}.OpenAPIModelName(): schema_pkg_apis_core_v1alpha1_TapVerify(ref),
corev1alpha1.TenantModule{}.OpenAPIModelName(): schema_pkg_apis_core_v1alpha1_TenantModule(ref),
corev1alpha1.TenantModuleList{}.OpenAPIModelName(): schema_pkg_apis_core_v1alpha1_TenantModuleList(ref),
corev1alpha1.TenantModuleStatus{}.OpenAPIModelName(): schema_pkg_apis_core_v1alpha1_TenantModuleStatus(ref),
corev1alpha1.TenantNamespace{}.OpenAPIModelName(): schema_pkg_apis_core_v1alpha1_TenantNamespace(ref),
corev1alpha1.TenantNamespaceList{}.OpenAPIModelName(): schema_pkg_apis_core_v1alpha1_TenantNamespaceList(ref),
corev1alpha1.TenantSecret{}.OpenAPIModelName(): schema_pkg_apis_core_v1alpha1_TenantSecret(ref),
corev1alpha1.TenantSecretList{}.OpenAPIModelName(): schema_pkg_apis_core_v1alpha1_TenantSecretList(ref),
sdnv1alpha1.ApplicationReference{}.OpenAPIModelName(): schema_pkg_apis_sdn_v1alpha1_ApplicationReference(ref),
sdnv1alpha1.EgressRule{}.OpenAPIModelName(): schema_pkg_apis_sdn_v1alpha1_EgressRule(ref),
sdnv1alpha1.FQDNSelector{}.OpenAPIModelName(): schema_pkg_apis_sdn_v1alpha1_FQDNSelector(ref),
sdnv1alpha1.IngressRule{}.OpenAPIModelName(): schema_pkg_apis_sdn_v1alpha1_IngressRule(ref),
sdnv1alpha1.PortProtocol{}.OpenAPIModelName(): schema_pkg_apis_sdn_v1alpha1_PortProtocol(ref),
sdnv1alpha1.PortRule{}.OpenAPIModelName(): schema_pkg_apis_sdn_v1alpha1_PortRule(ref),
sdnv1alpha1.SecurityGroup{}.OpenAPIModelName(): schema_pkg_apis_sdn_v1alpha1_SecurityGroup(ref),
sdnv1alpha1.SecurityGroupList{}.OpenAPIModelName(): schema_pkg_apis_sdn_v1alpha1_SecurityGroupList(ref),
sdnv1alpha1.SecurityGroupSpec{}.OpenAPIModelName(): schema_pkg_apis_sdn_v1alpha1_SecurityGroupSpec(ref),
v1.ConversionRequest{}.OpenAPIModelName(): schema_pkg_apis_apiextensions_v1_ConversionRequest(ref),
v1.ConversionResponse{}.OpenAPIModelName(): schema_pkg_apis_apiextensions_v1_ConversionResponse(ref),
v1.ConversionReview{}.OpenAPIModelName(): schema_pkg_apis_apiextensions_v1_ConversionReview(ref),
v1.CustomResourceColumnDefinition{}.OpenAPIModelName(): schema_pkg_apis_apiextensions_v1_CustomResourceColumnDefinition(ref),
v1.CustomResourceConversion{}.OpenAPIModelName(): schema_pkg_apis_apiextensions_v1_CustomResourceConversion(ref),
v1.CustomResourceDefinition{}.OpenAPIModelName(): schema_pkg_apis_apiextensions_v1_CustomResourceDefinition(ref),
v1.CustomResourceDefinitionCondition{}.OpenAPIModelName(): schema_pkg_apis_apiextensions_v1_CustomResourceDefinitionCondition(ref),
v1.CustomResourceDefinitionList{}.OpenAPIModelName(): schema_pkg_apis_apiextensions_v1_CustomResourceDefinitionList(ref),
v1.CustomResourceDefinitionNames{}.OpenAPIModelName(): schema_pkg_apis_apiextensions_v1_CustomResourceDefinitionNames(ref),
v1.CustomResourceDefinitionSpec{}.OpenAPIModelName(): schema_pkg_apis_apiextensions_v1_CustomResourceDefinitionSpec(ref),
v1.CustomResourceDefinitionStatus{}.OpenAPIModelName(): schema_pkg_apis_apiextensions_v1_CustomResourceDefinitionStatus(ref),
v1.CustomResourceDefinitionVersion{}.OpenAPIModelName(): schema_pkg_apis_apiextensions_v1_CustomResourceDefinitionVersion(ref),
v1.CustomResourceSubresourceScale{}.OpenAPIModelName(): schema_pkg_apis_apiextensions_v1_CustomResourceSubresourceScale(ref),
v1.CustomResourceSubresourceStatus{}.OpenAPIModelName(): schema_pkg_apis_apiextensions_v1_CustomResourceSubresourceStatus(ref),
v1.CustomResourceSubresources{}.OpenAPIModelName(): schema_pkg_apis_apiextensions_v1_CustomResourceSubresources(ref),
v1.CustomResourceValidation{}.OpenAPIModelName(): schema_pkg_apis_apiextensions_v1_CustomResourceValidation(ref),
v1.ExternalDocumentation{}.OpenAPIModelName(): schema_pkg_apis_apiextensions_v1_ExternalDocumentation(ref),
v1.JSON{}.OpenAPIModelName(): schema_pkg_apis_apiextensions_v1_JSON(ref),
v1.JSONSchemaProps{}.OpenAPIModelName(): schema_pkg_apis_apiextensions_v1_JSONSchemaProps(ref),
v1.JSONSchemaPropsOrArray{}.OpenAPIModelName(): schema_pkg_apis_apiextensions_v1_JSONSchemaPropsOrArray(ref),
v1.JSONSchemaPropsOrBool{}.OpenAPIModelName(): schema_pkg_apis_apiextensions_v1_JSONSchemaPropsOrBool(ref),
v1.JSONSchemaPropsOrStringArray{}.OpenAPIModelName(): schema_pkg_apis_apiextensions_v1_JSONSchemaPropsOrStringArray(ref),
v1.SelectableField{}.OpenAPIModelName(): schema_pkg_apis_apiextensions_v1_SelectableField(ref),
v1.ServiceReference{}.OpenAPIModelName(): schema_pkg_apis_apiextensions_v1_ServiceReference(ref),
v1.ValidationRule{}.OpenAPIModelName(): schema_pkg_apis_apiextensions_v1_ValidationRule(ref),
v1.WebhookClientConfig{}.OpenAPIModelName(): schema_pkg_apis_apiextensions_v1_WebhookClientConfig(ref),
v1.WebhookConversion{}.OpenAPIModelName(): schema_pkg_apis_apiextensions_v1_WebhookConversion(ref),
resource.Quantity{}.OpenAPIModelName(): schema_apimachinery_pkg_api_resource_Quantity(ref),
metav1.APIGroup{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_APIGroup(ref),
metav1.APIGroupList{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_APIGroupList(ref),
metav1.APIResource{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_APIResource(ref),
metav1.APIResourceList{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_APIResourceList(ref),
metav1.APIVersions{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_APIVersions(ref),
metav1.ApplyOptions{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_ApplyOptions(ref),
metav1.Condition{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_Condition(ref),
metav1.CreateOptions{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_CreateOptions(ref),
metav1.DeleteOptions{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_DeleteOptions(ref),
metav1.Duration{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_Duration(ref),
metav1.FieldSelectorRequirement{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_FieldSelectorRequirement(ref),
metav1.FieldsV1{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_FieldsV1(ref),
metav1.GetOptions{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_GetOptions(ref),
metav1.GroupKind{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_GroupKind(ref),
metav1.GroupResource{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_GroupResource(ref),
metav1.GroupVersion{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_GroupVersion(ref),
metav1.GroupVersionForDiscovery{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_GroupVersionForDiscovery(ref),
metav1.GroupVersionKind{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_GroupVersionKind(ref),
metav1.GroupVersionResource{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_GroupVersionResource(ref),
metav1.InternalEvent{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_InternalEvent(ref),
metav1.LabelSelector{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_LabelSelector(ref),
metav1.LabelSelectorRequirement{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_LabelSelectorRequirement(ref),
metav1.List{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_List(ref),
metav1.ListMeta{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_ListMeta(ref),
metav1.ListOptions{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_ListOptions(ref),
metav1.ManagedFieldsEntry{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_ManagedFieldsEntry(ref),
metav1.MicroTime{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_MicroTime(ref),
metav1.ObjectMeta{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_ObjectMeta(ref),
metav1.OwnerReference{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_OwnerReference(ref),
metav1.PartialObjectMetadata{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_PartialObjectMetadata(ref),
metav1.PartialObjectMetadataList{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_PartialObjectMetadataList(ref),
metav1.Patch{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_Patch(ref),
metav1.PatchOptions{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_PatchOptions(ref),
metav1.Preconditions{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_Preconditions(ref),
metav1.RootPaths{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_RootPaths(ref),
metav1.ServerAddressByClientCIDR{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_ServerAddressByClientCIDR(ref),
metav1.ShardInfo{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_ShardInfo(ref),
metav1.Status{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_Status(ref),
metav1.StatusCause{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_StatusCause(ref),
metav1.StatusDetails{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_StatusDetails(ref),
metav1.Table{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_Table(ref),
metav1.TableColumnDefinition{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_TableColumnDefinition(ref),
metav1.TableOptions{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_TableOptions(ref),
metav1.TableRow{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_TableRow(ref),
metav1.TableRowCondition{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_TableRowCondition(ref),
metav1.Time{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_Time(ref),
metav1.Timestamp{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_Timestamp(ref),
metav1.TypeMeta{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_TypeMeta(ref),
metav1.UpdateOptions{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_UpdateOptions(ref),
metav1.WatchEvent{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_WatchEvent(ref),
runtime.RawExtension{}.OpenAPIModelName(): schema_k8sio_apimachinery_pkg_runtime_RawExtension(ref),
runtime.TypeMeta{}.OpenAPIModelName(): schema_k8sio_apimachinery_pkg_runtime_TypeMeta(ref),
runtime.Unknown{}.OpenAPIModelName(): schema_k8sio_apimachinery_pkg_runtime_Unknown(ref),
version.Info{}.OpenAPIModelName(): schema_k8sio_apimachinery_pkg_version_Info(ref),
}
}
@@ -319,6 +330,391 @@ func schema_pkg_apis_apps_v1alpha1_ApplicationStatus(ref common.ReferenceCallbac
}
}
func schema_pkg_apis_core_v1alpha1_Credential(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
Description: "Credential is one account of a converted application.",
Type: []string{"object"},
Properties: map[string]spec.Schema{
"kind": {
SchemaProps: spec.SchemaProps{
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{"string"},
Format: "",
},
},
"apiVersion": {
SchemaProps: spec.SchemaProps{
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{"string"},
Format: "",
},
},
"metadata": {
SchemaProps: spec.SchemaProps{
Default: map[string]interface{}{},
Ref: ref(metav1.ObjectMeta{}.OpenAPIModelName()),
},
},
"spec": {
SchemaProps: spec.SchemaProps{
Default: map[string]interface{}{},
Ref: ref(corev1alpha1.CredentialSpec{}.OpenAPIModelName()),
},
},
"status": {
SchemaProps: spec.SchemaProps{
Default: map[string]interface{}{},
Ref: ref(corev1alpha1.CredentialStatus{}.OpenAPIModelName()),
},
},
},
},
},
Dependencies: []string{
corev1alpha1.CredentialSpec{}.OpenAPIModelName(), corev1alpha1.CredentialStatus{}.OpenAPIModelName(), metav1.ObjectMeta{}.OpenAPIModelName()},
}
}
func schema_pkg_apis_core_v1alpha1_CredentialApplicationRef(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
Description: "CredentialApplicationRef names a managed application.",
Type: []string{"object"},
Properties: map[string]spec.Schema{
"apiGroup": {
SchemaProps: spec.SchemaProps{
Default: "",
Type: []string{"string"},
Format: "",
},
},
"kind": {
SchemaProps: spec.SchemaProps{
Default: "",
Type: []string{"string"},
Format: "",
},
},
"name": {
SchemaProps: spec.SchemaProps{
Default: "",
Type: []string{"string"},
Format: "",
},
},
},
Required: []string{"apiGroup", "kind", "name"},
},
},
}
}
func schema_pkg_apis_core_v1alpha1_CredentialHistoryEntry(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
Description: "CredentialHistoryEntry is one recorded operation.",
Type: []string{"object"},
Properties: map[string]spec.Schema{
"operation": {
SchemaProps: spec.SchemaProps{
Default: "",
Type: []string{"string"},
Format: "",
},
},
"at": {
SchemaProps: spec.SchemaProps{
Ref: ref(metav1.Time{}.OpenAPIModelName()),
},
},
"by": {
SchemaProps: spec.SchemaProps{
Default: "",
Type: []string{"string"},
Format: "",
},
},
},
Required: []string{"operation", "at", "by"},
},
},
Dependencies: []string{
metav1.Time{}.OpenAPIModelName()},
}
}
func schema_pkg_apis_core_v1alpha1_CredentialList(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
Description: "CredentialList is a list of Credential objects.",
Type: []string{"object"},
Properties: map[string]spec.Schema{
"kind": {
SchemaProps: spec.SchemaProps{
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{"string"},
Format: "",
},
},
"apiVersion": {
SchemaProps: spec.SchemaProps{
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{"string"},
Format: "",
},
},
"metadata": {
SchemaProps: spec.SchemaProps{
Default: map[string]interface{}{},
Ref: ref(metav1.ListMeta{}.OpenAPIModelName()),
},
},
"items": {
SchemaProps: spec.SchemaProps{
Type: []string{"array"},
Items: &spec.SchemaOrArray{
Schema: &spec.Schema{
SchemaProps: spec.SchemaProps{
Ref: ref(corev1alpha1.Credential{}.OpenAPIModelName()),
},
},
},
},
},
},
Required: []string{"items"},
},
},
Dependencies: []string{
corev1alpha1.Credential{}.OpenAPIModelName(), metav1.ListMeta{}.OpenAPIModelName()},
}
}
func schema_pkg_apis_core_v1alpha1_CredentialPasswordState(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
Description: "CredentialPasswordState records the operation that set the live password.",
Type: []string{"object"},
Properties: map[string]spec.Schema{
"origin": {
SchemaProps: spec.SchemaProps{
Type: []string{"string"},
Format: "",
},
},
"at": {
SchemaProps: spec.SchemaProps{
Ref: ref(metav1.Time{}.OpenAPIModelName()),
},
},
"by": {
SchemaProps: spec.SchemaProps{
Type: []string{"string"},
Format: "",
},
},
},
},
},
Dependencies: []string{
metav1.Time{}.OpenAPIModelName()},
}
}
func schema_pkg_apis_core_v1alpha1_CredentialRequest(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
Description: "CredentialRequest is the body and the answer of the mint and revoke subresources of a Credential, in the shape of a Kubernetes TokenRequest: a create on the subresource carries the request in spec and is answered with the result in status, and nothing is stored. The password in a mint's answer is the only place it ever exists outside the API's memory.",
Type: []string{"object"},
Properties: map[string]spec.Schema{
"kind": {
SchemaProps: spec.SchemaProps{
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{"string"},
Format: "",
},
},
"apiVersion": {
SchemaProps: spec.SchemaProps{
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{"string"},
Format: "",
},
},
"metadata": {
SchemaProps: spec.SchemaProps{
Default: map[string]interface{}{},
Ref: ref(metav1.ObjectMeta{}.OpenAPIModelName()),
},
},
"spec": {
SchemaProps: spec.SchemaProps{
Default: map[string]interface{}{},
Ref: ref(corev1alpha1.CredentialRequestSpec{}.OpenAPIModelName()),
},
},
"status": {
SchemaProps: spec.SchemaProps{
Default: map[string]interface{}{},
Ref: ref(corev1alpha1.CredentialRequestStatus{}.OpenAPIModelName()),
},
},
},
},
},
Dependencies: []string{
corev1alpha1.CredentialRequestSpec{}.OpenAPIModelName(), corev1alpha1.CredentialRequestStatus{}.OpenAPIModelName(), metav1.ObjectMeta{}.OpenAPIModelName()},
}
}
func schema_pkg_apis_core_v1alpha1_CredentialRequestPreconditions(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
Description: "CredentialRequestPreconditions makes the operation conditional on the Credential being unchanged since the caller read it, so a mint cannot silently replace a password someone else just received.",
Type: []string{"object"},
Properties: map[string]spec.Schema{
"resourceVersion": {
SchemaProps: spec.SchemaProps{
Description: "ResourceVersion is the Credential's resourceVersion the caller last read.",
Type: []string{"string"},
Format: "",
},
},
},
},
},
}
}
func schema_pkg_apis_core_v1alpha1_CredentialRequestSpec(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
Description: "CredentialRequestSpec carries the caller's preconditions.",
Type: []string{"object"},
Properties: map[string]spec.Schema{
"preconditions": {
SchemaProps: spec.SchemaProps{
Ref: ref(corev1alpha1.CredentialRequestPreconditions{}.OpenAPIModelName()),
},
},
},
},
},
Dependencies: []string{
corev1alpha1.CredentialRequestPreconditions{}.OpenAPIModelName()},
}
}
func schema_pkg_apis_core_v1alpha1_CredentialRequestStatus(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
Description: "CredentialRequestStatus is the result of a mint or a revoke.",
Type: []string{"object"},
Properties: map[string]spec.Schema{
"username": {
SchemaProps: spec.SchemaProps{
Description: "Username is the account name as the engine knows it.",
Type: []string{"string"},
Format: "",
},
},
"password": {
SchemaProps: spec.SchemaProps{
Description: "Password is the new plaintext, present in a mint's answer only and shown once.",
Type: []string{"string"},
Format: "",
},
},
"issuedAt": {
SchemaProps: spec.SchemaProps{
Description: "IssuedAt is when the operation took effect in the record.",
Ref: ref(metav1.Time{}.OpenAPIModelName()),
},
},
},
},
},
Dependencies: []string{
metav1.Time{}.OpenAPIModelName()},
}
}
func schema_pkg_apis_core_v1alpha1_CredentialSpec(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
Description: "CredentialSpec identifies the account. It is derived from the application and read-only.",
Type: []string{"object"},
Properties: map[string]spec.Schema{
"application": {
SchemaProps: spec.SchemaProps{
Description: "Application is the managed application the account belongs to.",
Default: map[string]interface{}{},
Ref: ref(corev1alpha1.CredentialApplicationRef{}.OpenAPIModelName()),
},
},
"user": {
SchemaProps: spec.SchemaProps{
Description: "User is the account name as the application declares it.",
Default: "",
Type: []string{"string"},
Format: "",
},
},
},
Required: []string{"application", "user"},
},
},
Dependencies: []string{
corev1alpha1.CredentialApplicationRef{}.OpenAPIModelName()},
}
}
func schema_pkg_apis_core_v1alpha1_CredentialStatus(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
Description: "CredentialStatus is the account's record.",
Type: []string{"object"},
Properties: map[string]spec.Schema{
"password": {
SchemaProps: spec.SchemaProps{
Description: "Password says where the live password came from.",
Default: map[string]interface{}{},
Ref: ref(corev1alpha1.CredentialPasswordState{}.OpenAPIModelName()),
},
},
"history": {
SchemaProps: spec.SchemaProps{
Description: "History holds the last ten operations, newest first.",
Type: []string{"array"},
Items: &spec.SchemaOrArray{
Schema: &spec.Schema{
SchemaProps: spec.SchemaProps{
Ref: ref(corev1alpha1.CredentialHistoryEntry{}.OpenAPIModelName()),
},
},
},
},
},
},
},
},
Dependencies: []string{
corev1alpha1.CredentialHistoryEntry{}.OpenAPIModelName(), corev1alpha1.CredentialPasswordState{}.OpenAPIModelName()},
}
}
func schema_pkg_apis_core_v1alpha1_Option(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{