@kustodian/schema 1.4.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cluster.d.ts +1887 -0
- package/dist/cluster.d.ts.map +1 -0
- package/dist/common.d.ts +875 -0
- package/dist/common.d.ts.map +1 -0
- package/{src/index.ts → dist/index.d.ts} +2 -1
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4526 -0
- package/dist/node-list.d.ts +361 -0
- package/dist/node-list.d.ts.map +1 -0
- package/dist/profile.d.ts +166 -0
- package/dist/profile.d.ts.map +1 -0
- package/dist/sources.d.ts +338 -0
- package/dist/sources.d.ts.map +1 -0
- package/dist/template.d.ts +2630 -0
- package/dist/template.d.ts.map +1 -0
- package/package.json +15 -8
- package/src/cluster.ts +0 -191
- package/src/common.ts +0 -300
- package/src/node-list.ts +0 -135
- package/src/profile.ts +0 -90
- package/src/sources.ts +0 -142
- package/src/template.ts +0 -132
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"template.d.ts","sourceRoot":"","sources":["../src/template.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAaxB;;;GAGG;AACH,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;EAKpC,CAAC;AAEH,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAE7E;;;;;;;GAOG;AACH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;IAAmD,CAAC;AAEtF,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAEtE;;;;;;GAMG;AACH,eAAO,MAAM,wBAAwB,2CAAyC,CAAC;AAE/E,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAE5E;;GA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAgDzE,CAAC;AAEH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAE3D;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,OAAO,GAAG,CAAC,CAAC,mBAAmB,CAAC,OAAO,EAAE,YAAY,CAAC,CAE7F"}
|
package/package.json
CHANGED
|
@@ -1,23 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kustodian/schema",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "JSON Schema definitions for Kustodian YAML validation",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"main": "./
|
|
7
|
-
"types": "./
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
8
|
"exports": {
|
|
9
9
|
".": {
|
|
10
|
-
"types": "./
|
|
11
|
-
"import": "./
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
12
|
}
|
|
13
13
|
},
|
|
14
14
|
"files": [
|
|
15
|
-
"
|
|
15
|
+
"dist"
|
|
16
16
|
],
|
|
17
17
|
"scripts": {
|
|
18
18
|
"test": "bun test",
|
|
19
19
|
"test:watch": "bun test --watch",
|
|
20
|
-
"typecheck": "bun run tsc --noEmit"
|
|
20
|
+
"typecheck": "bun run tsc --noEmit",
|
|
21
|
+
"generate-schemas": "bun run ./scripts/generate-json-schemas.ts",
|
|
22
|
+
"build": "bun build src/index.ts --outdir dist --target node --format esm && tsc --emitDeclarationOnly --outDir dist",
|
|
23
|
+
"prepublishOnly": "bun run build"
|
|
21
24
|
},
|
|
22
25
|
"keywords": [
|
|
23
26
|
"kustodian",
|
|
@@ -33,9 +36,13 @@
|
|
|
33
36
|
"directory": "packages/schema"
|
|
34
37
|
},
|
|
35
38
|
"publishConfig": {
|
|
36
|
-
"
|
|
39
|
+
"access": "public",
|
|
40
|
+
"registry": "https://registry.npmjs.org"
|
|
37
41
|
},
|
|
38
42
|
"dependencies": {
|
|
39
43
|
"zod": "^3.25.30"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"zod-to-json-schema": "^3.25.1"
|
|
40
47
|
}
|
|
41
48
|
}
|
package/src/cluster.ts
DELETED
|
@@ -1,191 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
|
|
3
|
-
import { api_version_schema, metadata_schema, values_schema } from './common.js';
|
|
4
|
-
import { ssh_config_schema } from './node-list.js';
|
|
5
|
-
import { preservation_mode_schema } from './template.js';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Git repository configuration for a cluster.
|
|
9
|
-
*/
|
|
10
|
-
export const git_config_schema = z.object({
|
|
11
|
-
owner: z.string().min(1),
|
|
12
|
-
repository: z.string().min(1),
|
|
13
|
-
branch: z.string().min(1).optional().default('main'),
|
|
14
|
-
path: z.string().optional(),
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
export type GitConfigType = z.infer<typeof git_config_schema>;
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* OCI repository configuration for a cluster.
|
|
21
|
-
*/
|
|
22
|
-
export const oci_config_schema = z.object({
|
|
23
|
-
registry: z.string().min(1),
|
|
24
|
-
repository: z.string().min(1),
|
|
25
|
-
tag_strategy: z.enum(['cluster', 'git-sha', 'version', 'manual']).optional().default('git-sha'),
|
|
26
|
-
tag: z.string().optional(),
|
|
27
|
-
secret_ref: z.string().optional(),
|
|
28
|
-
provider: z.enum(['aws', 'azure', 'gcp', 'generic']).optional().default('generic'),
|
|
29
|
-
insecure: z.boolean().optional().default(false),
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
export type OciConfigType = z.infer<typeof oci_config_schema>;
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Kustomization override configuration within a cluster.
|
|
36
|
-
*
|
|
37
|
-
* Allows overriding kustomization enablement and preservation from template defaults.
|
|
38
|
-
*/
|
|
39
|
-
export const kustomization_override_schema = z.object({
|
|
40
|
-
enabled: z.boolean(),
|
|
41
|
-
preservation: z
|
|
42
|
-
.object({
|
|
43
|
-
mode: preservation_mode_schema,
|
|
44
|
-
keep_resources: z.array(z.string()).optional(),
|
|
45
|
-
})
|
|
46
|
-
.optional(),
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
export type KustomizationOverrideType = z.infer<typeof kustomization_override_schema>;
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Template enablement configuration within a cluster.
|
|
53
|
-
*/
|
|
54
|
-
export const template_config_schema = z.object({
|
|
55
|
-
name: z.string().min(1),
|
|
56
|
-
enabled: z.boolean().optional().default(true),
|
|
57
|
-
values: values_schema.optional(),
|
|
58
|
-
kustomizations: z
|
|
59
|
-
.record(
|
|
60
|
-
z.string(), // kustomization name
|
|
61
|
-
z.union([
|
|
62
|
-
z.boolean(), // Simple: just enabled/disabled
|
|
63
|
-
kustomization_override_schema, // Advanced: with preservation
|
|
64
|
-
]),
|
|
65
|
-
)
|
|
66
|
-
.optional(),
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
export type TemplateConfigType = z.infer<typeof template_config_schema>;
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* Plugin configuration within a cluster.
|
|
73
|
-
*/
|
|
74
|
-
export const plugin_config_schema = z.object({
|
|
75
|
-
name: z.string().min(1),
|
|
76
|
-
config: z.record(z.string(), z.unknown()).optional(),
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
export type PluginConfigType = z.infer<typeof plugin_config_schema>;
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Node defaults configuration within a cluster.
|
|
83
|
-
*/
|
|
84
|
-
export const node_defaults_schema = z.object({
|
|
85
|
-
label_prefix: z.string().optional(),
|
|
86
|
-
ssh: ssh_config_schema.optional(),
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
export type NodeDefaultsType = z.infer<typeof node_defaults_schema>;
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* GitHub repository configuration for GitOps metadata.
|
|
93
|
-
*/
|
|
94
|
-
export const github_config_schema = z.object({
|
|
95
|
-
organization: z.string().min(1),
|
|
96
|
-
repository: z.string().min(1),
|
|
97
|
-
branch: z.string().min(1).optional().default('main'),
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
export type GithubConfigType = z.infer<typeof github_config_schema>;
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* Bootstrap credential configuration for secret providers.
|
|
104
|
-
* Allows obtaining credentials from another secret provider.
|
|
105
|
-
*/
|
|
106
|
-
export const bootstrap_credential_schema = z.discriminatedUnion('type', [
|
|
107
|
-
z.object({
|
|
108
|
-
type: z.literal('1password'),
|
|
109
|
-
ref: z.string().min(1),
|
|
110
|
-
}),
|
|
111
|
-
z.object({
|
|
112
|
-
type: z.literal('doppler'),
|
|
113
|
-
project: z.string().min(1),
|
|
114
|
-
config: z.string().min(1),
|
|
115
|
-
secret: z.string().min(1),
|
|
116
|
-
}),
|
|
117
|
-
]);
|
|
118
|
-
|
|
119
|
-
export type BootstrapCredentialType = z.infer<typeof bootstrap_credential_schema>;
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* Doppler secret provider configuration at cluster level.
|
|
123
|
-
*/
|
|
124
|
-
export const doppler_config_schema = z.object({
|
|
125
|
-
project: z.string().min(1),
|
|
126
|
-
config: z.string().min(1),
|
|
127
|
-
service_token: bootstrap_credential_schema.optional(),
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
export type DopplerConfigType = z.infer<typeof doppler_config_schema>;
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* 1Password secret provider configuration at cluster level.
|
|
134
|
-
*/
|
|
135
|
-
export const onepassword_config_schema = z.object({
|
|
136
|
-
vault: z.string().min(1),
|
|
137
|
-
service_account_token: bootstrap_credential_schema.optional(),
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
export type OnePasswordConfigType = z.infer<typeof onepassword_config_schema>;
|
|
141
|
-
|
|
142
|
-
/**
|
|
143
|
-
* Secret providers configuration at cluster level.
|
|
144
|
-
*/
|
|
145
|
-
export const secrets_config_schema = z.object({
|
|
146
|
-
doppler: doppler_config_schema.optional(),
|
|
147
|
-
onepassword: onepassword_config_schema.optional(),
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
export type SecretsConfigType = z.infer<typeof secrets_config_schema>;
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
* Cluster specification.
|
|
154
|
-
*/
|
|
155
|
-
export const cluster_spec_schema = z
|
|
156
|
-
.object({
|
|
157
|
-
code: z.string().min(1).optional(),
|
|
158
|
-
domain: z.string().min(1),
|
|
159
|
-
git: git_config_schema.optional(),
|
|
160
|
-
oci: oci_config_schema.optional(),
|
|
161
|
-
github: github_config_schema.optional(),
|
|
162
|
-
templates: z.array(template_config_schema).optional(),
|
|
163
|
-
plugins: z.array(plugin_config_schema).optional(),
|
|
164
|
-
node_defaults: node_defaults_schema.optional(),
|
|
165
|
-
nodes: z.array(z.string()).optional(),
|
|
166
|
-
secrets: secrets_config_schema.optional(),
|
|
167
|
-
})
|
|
168
|
-
.refine((data) => data.git || data.oci, {
|
|
169
|
-
message: "Either 'git' or 'oci' must be specified",
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
export type ClusterSpecType = z.infer<typeof cluster_spec_schema>;
|
|
173
|
-
|
|
174
|
-
/**
|
|
175
|
-
* Complete Cluster resource definition.
|
|
176
|
-
*/
|
|
177
|
-
export const cluster_schema = z.object({
|
|
178
|
-
apiVersion: api_version_schema,
|
|
179
|
-
kind: z.literal('Cluster'),
|
|
180
|
-
metadata: metadata_schema,
|
|
181
|
-
spec: cluster_spec_schema,
|
|
182
|
-
});
|
|
183
|
-
|
|
184
|
-
export type ClusterType = z.infer<typeof cluster_schema>;
|
|
185
|
-
|
|
186
|
-
/**
|
|
187
|
-
* Validates a cluster object and returns the result.
|
|
188
|
-
*/
|
|
189
|
-
export function validate_cluster(data: unknown): z.SafeParseReturnType<unknown, ClusterType> {
|
|
190
|
-
return cluster_schema.safeParse(data);
|
|
191
|
-
}
|
package/src/common.ts
DELETED
|
@@ -1,300 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Common API version for all Kustodian resources.
|
|
5
|
-
*/
|
|
6
|
-
export const api_version_schema = z.literal('kustodian.io/v1');
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Standard metadata for all Kustodian resources.
|
|
10
|
-
*/
|
|
11
|
-
export const metadata_schema = z.object({
|
|
12
|
-
name: z.string().min(1),
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
export type MetadataType = z.infer<typeof metadata_schema>;
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Health check configuration for waiting on resources.
|
|
19
|
-
*/
|
|
20
|
-
export const health_check_schema = z.object({
|
|
21
|
-
kind: z.string().min(1),
|
|
22
|
-
name: z.string().min(1),
|
|
23
|
-
namespace: z.string().min(1).optional(),
|
|
24
|
-
api_version: z.string().min(1).optional(),
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
export type HealthCheckType = z.infer<typeof health_check_schema>;
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Health check expression configuration using CEL (Common Expression Language).
|
|
31
|
-
* Supports custom health check conditions via CEL expressions.
|
|
32
|
-
*/
|
|
33
|
-
export const health_check_expr_schema = z.object({
|
|
34
|
-
api_version: z.string().min(1),
|
|
35
|
-
kind: z.string().min(1),
|
|
36
|
-
namespace: z.string().min(1).optional(),
|
|
37
|
-
/** CEL expression for when resource is healthy/current */
|
|
38
|
-
current: z.string().min(1).optional(),
|
|
39
|
-
/** CEL expression for when resource has failed */
|
|
40
|
-
failed: z.string().min(1).optional(),
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
export type HealthCheckExprType = z.infer<typeof health_check_expr_schema>;
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Registry configuration for version substitutions.
|
|
47
|
-
*/
|
|
48
|
-
export const registry_config_schema = z.object({
|
|
49
|
-
/** Full image reference: registry/namespace/image or just namespace/image for Docker Hub */
|
|
50
|
-
image: z.string().min(1),
|
|
51
|
-
/** Registry type for API selection */
|
|
52
|
-
type: z.enum(['dockerhub', 'ghcr']).optional(),
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
export type RegistryConfigType = z.infer<typeof registry_config_schema>;
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Helm repository configuration for helm chart version substitutions.
|
|
59
|
-
* Supports both traditional Helm repositories and OCI registries.
|
|
60
|
-
*/
|
|
61
|
-
export const helm_config_schema = z
|
|
62
|
-
.object({
|
|
63
|
-
/** Helm chart repository URL (e.g., https://traefik.github.io/charts) */
|
|
64
|
-
repository: z.string().url().optional(),
|
|
65
|
-
/** OCI registry URL for Helm charts (e.g., oci://ghcr.io/traefik/helm) */
|
|
66
|
-
oci: z.string().startsWith('oci://').optional(),
|
|
67
|
-
/** Chart name */
|
|
68
|
-
chart: z.string().min(1),
|
|
69
|
-
})
|
|
70
|
-
.refine(
|
|
71
|
-
(data) => {
|
|
72
|
-
// Either repository or oci must be provided
|
|
73
|
-
return data.repository !== undefined || data.oci !== undefined;
|
|
74
|
-
},
|
|
75
|
-
{
|
|
76
|
-
message: "Either 'repository' or 'oci' must be specified",
|
|
77
|
-
},
|
|
78
|
-
);
|
|
79
|
-
|
|
80
|
-
export type HelmConfigType = z.infer<typeof helm_config_schema>;
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Generic substitution (backward compatible, default type).
|
|
84
|
-
*/
|
|
85
|
-
export const generic_substitution_schema = z.object({
|
|
86
|
-
type: z.literal('generic').optional(),
|
|
87
|
-
name: z.string().min(1),
|
|
88
|
-
default: z.string().optional(),
|
|
89
|
-
secret: z.string().optional(),
|
|
90
|
-
preserve_case: z.boolean().optional(),
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
export type GenericSubstitutionType = z.infer<typeof generic_substitution_schema>;
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* Version substitution for tracking container image versions.
|
|
97
|
-
*/
|
|
98
|
-
export const version_substitution_schema = z.object({
|
|
99
|
-
type: z.literal('version'),
|
|
100
|
-
name: z.string().min(1),
|
|
101
|
-
default: z.string().optional(),
|
|
102
|
-
/** Semver constraint: ^1.0.0, ~2.3.0, >=1.0.0 <2.0.0 */
|
|
103
|
-
constraint: z.string().optional(),
|
|
104
|
-
/** Registry configuration for fetching available versions */
|
|
105
|
-
registry: registry_config_schema,
|
|
106
|
-
/** Regex pattern for filtering valid tags (default: semver-like) */
|
|
107
|
-
tag_pattern: z.string().optional(),
|
|
108
|
-
/** Exclude pre-release versions (default: true) */
|
|
109
|
-
exclude_prerelease: z.boolean().optional(),
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
export type VersionSubstitutionType = z.infer<typeof version_substitution_schema>;
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Helm chart version substitution for tracking Helm chart versions.
|
|
116
|
-
*/
|
|
117
|
-
export const helm_substitution_schema = z.object({
|
|
118
|
-
type: z.literal('helm'),
|
|
119
|
-
name: z.string().min(1),
|
|
120
|
-
default: z.string().optional(),
|
|
121
|
-
/** Semver constraint: ^1.0.0, ~2.3.0, >=1.0.0 <2.0.0 */
|
|
122
|
-
constraint: z.string().optional(),
|
|
123
|
-
/** Helm repository configuration for fetching available chart versions */
|
|
124
|
-
helm: helm_config_schema,
|
|
125
|
-
/** Regex pattern for filtering valid tags (default: semver-like) */
|
|
126
|
-
tag_pattern: z.string().optional(),
|
|
127
|
-
/** Exclude pre-release versions (default: true) */
|
|
128
|
-
exclude_prerelease: z.boolean().optional(),
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
export type HelmSubstitutionType = z.infer<typeof helm_substitution_schema>;
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* Namespace substitution with Kubernetes naming validation.
|
|
135
|
-
*/
|
|
136
|
-
export const namespace_substitution_schema = z.object({
|
|
137
|
-
type: z.literal('namespace'),
|
|
138
|
-
name: z.string().min(1),
|
|
139
|
-
default: z.string().optional(),
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
export type NamespaceSubstitutionType = z.infer<typeof namespace_substitution_schema>;
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
* 1Password substitution for fetching secrets from 1Password vaults.
|
|
146
|
-
* Uses the op:// secret reference format, or shorthand with cluster defaults.
|
|
147
|
-
*/
|
|
148
|
-
export const onepassword_substitution_schema = z
|
|
149
|
-
.object({
|
|
150
|
-
type: z.literal('1password'),
|
|
151
|
-
name: z.string().min(1),
|
|
152
|
-
/** 1Password secret reference: op://vault/item[/section]/field, or shorthand item/field when vault is configured at cluster level */
|
|
153
|
-
ref: z.string().min(1).optional(),
|
|
154
|
-
/** Item name (shorthand, requires cluster-level vault configuration) */
|
|
155
|
-
item: z.string().min(1).optional(),
|
|
156
|
-
/** Field name (shorthand, requires cluster-level vault configuration) */
|
|
157
|
-
field: z.string().min(1).optional(),
|
|
158
|
-
/** Section name (optional, for shorthand references) */
|
|
159
|
-
section: z.string().optional(),
|
|
160
|
-
/** Optional default value if secret cannot be fetched */
|
|
161
|
-
default: z.string().optional(),
|
|
162
|
-
})
|
|
163
|
-
.refine(
|
|
164
|
-
(data) => {
|
|
165
|
-
// Either ref must be provided, or both item and field
|
|
166
|
-
return data.ref !== undefined || (data.item !== undefined && data.field !== undefined);
|
|
167
|
-
},
|
|
168
|
-
{
|
|
169
|
-
message: "Either 'ref' or both 'item' and 'field' must be specified",
|
|
170
|
-
},
|
|
171
|
-
);
|
|
172
|
-
|
|
173
|
-
export type OnePasswordSubstitutionType = z.infer<typeof onepassword_substitution_schema>;
|
|
174
|
-
|
|
175
|
-
/**
|
|
176
|
-
* Doppler substitution for fetching secrets from Doppler projects.
|
|
177
|
-
* Project and config can be omitted if configured at cluster level.
|
|
178
|
-
*/
|
|
179
|
-
export const doppler_substitution_schema = z.object({
|
|
180
|
-
type: z.literal('doppler'),
|
|
181
|
-
name: z.string().min(1),
|
|
182
|
-
/** Doppler project name (optional if configured at cluster level) */
|
|
183
|
-
project: z.string().min(1).optional(),
|
|
184
|
-
/** Doppler config name (optional if configured at cluster level, e.g., 'dev', 'stg', 'prd') */
|
|
185
|
-
config: z.string().min(1).optional(),
|
|
186
|
-
/** Secret key name in Doppler */
|
|
187
|
-
secret: z.string().min(1),
|
|
188
|
-
/** Optional default value if secret cannot be fetched */
|
|
189
|
-
default: z.string().optional(),
|
|
190
|
-
});
|
|
191
|
-
|
|
192
|
-
export type DopplerSubstitutionType = z.infer<typeof doppler_substitution_schema>;
|
|
193
|
-
|
|
194
|
-
/**
|
|
195
|
-
* Union of all substitution types.
|
|
196
|
-
* Supports backward compatibility: substitutions without 'type' are treated as generic.
|
|
197
|
-
*/
|
|
198
|
-
export const substitution_schema = z.union([
|
|
199
|
-
version_substitution_schema,
|
|
200
|
-
helm_substitution_schema,
|
|
201
|
-
namespace_substitution_schema,
|
|
202
|
-
onepassword_substitution_schema,
|
|
203
|
-
doppler_substitution_schema,
|
|
204
|
-
generic_substitution_schema, // Must be last due to optional 'type' field
|
|
205
|
-
]);
|
|
206
|
-
|
|
207
|
-
export type SubstitutionType = z.infer<typeof substitution_schema>;
|
|
208
|
-
|
|
209
|
-
/**
|
|
210
|
-
* Type guard for version substitutions.
|
|
211
|
-
*/
|
|
212
|
-
export function is_version_substitution(sub: SubstitutionType): sub is VersionSubstitutionType {
|
|
213
|
-
return 'type' in sub && sub.type === 'version';
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
/**
|
|
217
|
-
* Type guard for helm substitutions.
|
|
218
|
-
*/
|
|
219
|
-
export function is_helm_substitution(sub: SubstitutionType): sub is HelmSubstitutionType {
|
|
220
|
-
return 'type' in sub && sub.type === 'helm';
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
/**
|
|
224
|
-
* Type guard for namespace substitutions.
|
|
225
|
-
*/
|
|
226
|
-
export function is_namespace_substitution(sub: SubstitutionType): sub is NamespaceSubstitutionType {
|
|
227
|
-
return 'type' in sub && sub.type === 'namespace';
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
/**
|
|
231
|
-
* Type guard for generic substitutions.
|
|
232
|
-
*/
|
|
233
|
-
export function is_generic_substitution(sub: SubstitutionType): sub is GenericSubstitutionType {
|
|
234
|
-
return !('type' in sub) || sub.type === 'generic' || sub.type === undefined;
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
/**
|
|
238
|
-
* Type guard for 1Password substitutions.
|
|
239
|
-
*/
|
|
240
|
-
export function is_onepassword_substitution(
|
|
241
|
-
sub: SubstitutionType,
|
|
242
|
-
): sub is OnePasswordSubstitutionType {
|
|
243
|
-
return 'type' in sub && sub.type === '1password';
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
/**
|
|
247
|
-
* Type guard for Doppler substitutions.
|
|
248
|
-
*/
|
|
249
|
-
export function is_doppler_substitution(sub: SubstitutionType): sub is DopplerSubstitutionType {
|
|
250
|
-
return 'type' in sub && sub.type === 'doppler';
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
/**
|
|
254
|
-
* Namespace configuration with fallback behavior.
|
|
255
|
-
*/
|
|
256
|
-
export const namespace_config_schema = z.object({
|
|
257
|
-
default: z.string().min(1),
|
|
258
|
-
create: z.boolean().optional().default(true),
|
|
259
|
-
});
|
|
260
|
-
|
|
261
|
-
export type NamespaceConfigType = z.infer<typeof namespace_config_schema>;
|
|
262
|
-
|
|
263
|
-
/**
|
|
264
|
-
* Base auth configuration for kustomizations.
|
|
265
|
-
* This schema defines common fields that all auth providers share.
|
|
266
|
-
* Plugins (e.g., authelia, authentik) extend validation for provider-specific fields.
|
|
267
|
-
*/
|
|
268
|
-
export const auth_config_schema = z.object({
|
|
269
|
-
/** Auth provider plugin name (e.g., 'authelia', 'authentik') */
|
|
270
|
-
provider: z.string().min(1),
|
|
271
|
-
/** Provider-specific auth type (e.g., 'oidc', 'proxy', 'oauth2', 'saml') */
|
|
272
|
-
type: z.string().min(1),
|
|
273
|
-
/** Application identifier (used for client_id, slug, etc.) */
|
|
274
|
-
app_name: z.string().min(1),
|
|
275
|
-
/** Display name for the application */
|
|
276
|
-
app_display_name: z.string().optional(),
|
|
277
|
-
/** Application description */
|
|
278
|
-
app_description: z.string().optional(),
|
|
279
|
-
/** Application icon URL */
|
|
280
|
-
app_icon: z.string().optional(),
|
|
281
|
-
/** Application group/category */
|
|
282
|
-
app_group: z.string().optional(),
|
|
283
|
-
/** Application launch URL */
|
|
284
|
-
app_launch_url: z.string().optional(),
|
|
285
|
-
/** External host for the application */
|
|
286
|
-
external_host: z.string().optional(),
|
|
287
|
-
/** Internal service host (for proxy auth) */
|
|
288
|
-
internal_host: z.string().optional(),
|
|
289
|
-
/** Provider-specific configuration (validated by auth plugins) */
|
|
290
|
-
config: z.record(z.string(), z.unknown()).optional(),
|
|
291
|
-
});
|
|
292
|
-
|
|
293
|
-
export type AuthConfigType = z.infer<typeof auth_config_schema>;
|
|
294
|
-
|
|
295
|
-
/**
|
|
296
|
-
* Key-value pairs for substitution values.
|
|
297
|
-
*/
|
|
298
|
-
export const values_schema = z.record(z.string(), z.string());
|
|
299
|
-
|
|
300
|
-
export type ValuesType = z.infer<typeof values_schema>;
|
package/src/node-list.ts
DELETED
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
|
|
3
|
-
import { api_version_schema } from './common.js';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* SSH configuration schema.
|
|
7
|
-
*/
|
|
8
|
-
export const ssh_config_schema = z.object({
|
|
9
|
-
user: z.string().optional(),
|
|
10
|
-
key_path: z.string().optional(),
|
|
11
|
-
known_hosts_path: z.string().optional(),
|
|
12
|
-
port: z.number().int().positive().optional(),
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
export type SshConfigSchemaType = z.infer<typeof ssh_config_schema>;
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Kubernetes taint effect.
|
|
19
|
-
*/
|
|
20
|
-
export const taint_effect_schema = z.enum(['NoSchedule', 'PreferNoSchedule', 'NoExecute']);
|
|
21
|
-
|
|
22
|
-
export type TaintEffectType = z.infer<typeof taint_effect_schema>;
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Kubernetes taint schema.
|
|
26
|
-
*/
|
|
27
|
-
export const taint_schema = z.object({
|
|
28
|
-
key: z.string().min(1),
|
|
29
|
-
value: z.string().optional(),
|
|
30
|
-
effect: taint_effect_schema,
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
export type TaintSchemaType = z.infer<typeof taint_schema>;
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Node role in the cluster.
|
|
37
|
-
*/
|
|
38
|
-
export const node_role_schema = z.enum(['controller', 'worker', 'controller+worker']);
|
|
39
|
-
|
|
40
|
-
export type NodeRoleType = z.infer<typeof node_role_schema>;
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Single node definition schema (for inline use in NodeList).
|
|
44
|
-
*/
|
|
45
|
-
export const node_schema = z.object({
|
|
46
|
-
name: z.string().min(1),
|
|
47
|
-
role: node_role_schema,
|
|
48
|
-
address: z.string().min(1),
|
|
49
|
-
profile: z.string().min(1).optional(),
|
|
50
|
-
ssh: ssh_config_schema.optional(),
|
|
51
|
-
labels: z.record(z.union([z.string(), z.boolean(), z.number()])).optional(),
|
|
52
|
-
taints: z.array(taint_schema).optional(),
|
|
53
|
-
annotations: z.record(z.string()).optional(),
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
export type NodeSchemaType = z.infer<typeof node_schema>;
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Node metadata schema (for standalone Node resources).
|
|
60
|
-
*/
|
|
61
|
-
export const node_metadata_schema = z.object({
|
|
62
|
-
name: z.string().min(1),
|
|
63
|
-
cluster: z.string().min(1),
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
export type NodeMetadataType = z.infer<typeof node_metadata_schema>;
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Node spec schema (for standalone Node resources).
|
|
70
|
-
*/
|
|
71
|
-
export const node_spec_schema = z.object({
|
|
72
|
-
role: node_role_schema,
|
|
73
|
-
address: z.string().min(1),
|
|
74
|
-
profile: z.string().min(1).optional(),
|
|
75
|
-
ssh: ssh_config_schema.optional(),
|
|
76
|
-
labels: z.record(z.union([z.string(), z.boolean(), z.number()])).optional(),
|
|
77
|
-
taints: z.array(taint_schema).optional(),
|
|
78
|
-
annotations: z.record(z.string()).optional(),
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
export type NodeSpecType = z.infer<typeof node_spec_schema>;
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Standalone Node resource definition.
|
|
85
|
-
* Used for individual node files at clusters/<cluster>/nodes/<node>.yml
|
|
86
|
-
*/
|
|
87
|
-
export const node_resource_schema = z.object({
|
|
88
|
-
apiVersion: api_version_schema,
|
|
89
|
-
kind: z.literal('Node'),
|
|
90
|
-
metadata: node_metadata_schema,
|
|
91
|
-
spec: node_spec_schema,
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
export type NodeResourceType = z.infer<typeof node_resource_schema>;
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* Validates a Node resource and returns the result.
|
|
98
|
-
*/
|
|
99
|
-
export function validate_node_resource(
|
|
100
|
-
data: unknown,
|
|
101
|
-
): z.SafeParseReturnType<unknown, NodeResourceType> {
|
|
102
|
-
return node_resource_schema.safeParse(data);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* Converts a Node resource to a NodeType for internal use.
|
|
107
|
-
*/
|
|
108
|
-
export function node_resource_to_node(resource: NodeResourceType): NodeSchemaType {
|
|
109
|
-
const node: NodeSchemaType = {
|
|
110
|
-
name: resource.metadata.name,
|
|
111
|
-
role: resource.spec.role,
|
|
112
|
-
address: resource.spec.address,
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
if (resource.spec.profile !== undefined) {
|
|
116
|
-
node.profile = resource.spec.profile;
|
|
117
|
-
}
|
|
118
|
-
if (resource.spec.ssh !== undefined) {
|
|
119
|
-
node.ssh = resource.spec.ssh;
|
|
120
|
-
}
|
|
121
|
-
if (resource.spec.labels !== undefined) {
|
|
122
|
-
node.labels = resource.spec.labels;
|
|
123
|
-
}
|
|
124
|
-
if (resource.spec.taints !== undefined) {
|
|
125
|
-
node.taints = resource.spec.taints;
|
|
126
|
-
}
|
|
127
|
-
if (resource.spec.annotations !== undefined) {
|
|
128
|
-
node.annotations = resource.spec.annotations;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
return node;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
// NodeList is no longer a schema kind - it's just an internal construct
|
|
135
|
-
// Nodes are defined as individual Node resources and aggregated in code
|