Skip to content

Commit 7767a7d

Browse files
authored
feat(secret): add option to generate passwords (#567)
1 parent 5f95d68 commit 7767a7d

File tree

3 files changed

+46
-0
lines changed

3 files changed

+46
-0
lines changed

packages/clients/src/api/secret/v1alpha1/index.gen.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export type {
2121
ListSecretsRequest,
2222
ListSecretsRequestOrderBy,
2323
ListSecretsResponse,
24+
PasswordGenerationParams,
2425
Secret,
2526
SecretStatus,
2627
SecretVersion,

packages/clients/src/api/secret/v1alpha1/marshalling.gen.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// If you have any remark or suggestion do not hesitate to open an issue.
33
import {
44
isJSONObject,
5+
resolveOneOf,
56
unmarshalArrayOfObject,
67
unmarshalDate,
78
} from '../../../bridge'
@@ -12,6 +13,7 @@ import type {
1213
CreateSecretVersionRequest,
1314
ListSecretVersionsResponse,
1415
ListSecretsResponse,
16+
PasswordGenerationParams,
1517
Secret,
1618
SecretVersion,
1719
UpdateSecretRequest,
@@ -96,6 +98,17 @@ export const unmarshalListSecretsResponse = (data: unknown) => {
9698
} as ListSecretsResponse
9799
}
98100

101+
const marshalPasswordGenerationParams = (
102+
request: PasswordGenerationParams,
103+
defaults: DefaultValues,
104+
): Record<string, unknown> => ({
105+
additional_chars: request.additionalChars,
106+
length: request.length,
107+
no_digits: request.noDigits,
108+
no_lowercase_letters: request.noLowercaseLetters,
109+
no_uppercase_letters: request.noUppercaseLetters,
110+
})
111+
99112
export const marshalCreateSecretRequest = (
100113
request: CreateSecretRequest,
101114
defaults: DefaultValues,
@@ -113,6 +126,14 @@ export const marshalCreateSecretVersionRequest = (
113126
data: request.data,
114127
description: request.description,
115128
disable_previous: request.disablePrevious,
129+
...resolveOneOf([
130+
{
131+
param: 'password_generation',
132+
value: request.passwordGeneration
133+
? marshalPasswordGenerationParams(request.passwordGeneration, defaults)
134+
: undefined,
135+
},
136+
]),
116137
})
117138

118139
export const marshalUpdateSecretRequest = (

packages/clients/src/api/secret/v1alpha1/types.gen.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,20 @@ export interface ListSecretsResponse {
4747
secrets: Secret[]
4848
}
4949

50+
/** Password generation params. */
51+
export interface PasswordGenerationParams {
52+
/** Length of the password to generate (between 1 and 1024). */
53+
length: number
54+
/** Do not include lower case letters by default in the alphabet. */
55+
noLowercaseLetters: boolean
56+
/** Do not include upper case letters by default in the alphabet. */
57+
noUppercaseLetters: boolean
58+
/** Do not include digits by default in the alphabet. */
59+
noDigits: boolean
60+
/** Additional ascii characters to be included in the alphabet. */
61+
additionalChars: string
62+
}
63+
5064
/** Secret. */
5165
export interface Secret {
5266
/** ID of the secret. */
@@ -196,6 +210,16 @@ export type CreateSecretVersionRequest = {
196210
* the previous version was already disabled, does nothing.
197211
*/
198212
disablePrevious: boolean
213+
/**
214+
* Options to generate a password. If specified, a random password will be
215+
* generated. The data field must be empty. By default, the generator will use
216+
* upper and lower case letters, and digits. This behavior can be tuned using
217+
* the generation params.
218+
*
219+
* One-of ('PasswordGeneration'): at most one of 'passwordGeneration' could be
220+
* set.
221+
*/
222+
passwordGeneration?: PasswordGenerationParams
199223
}
200224

201225
export type GetSecretVersionRequest = {

0 commit comments

Comments
 (0)