@kustodian/schema 1.3.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 -190
- package/src/common.ts +0 -268
- package/src/node-list.ts +0 -135
- package/src/profile.ts +0 -90
- package/src/sources.ts +0 -142
- package/src/template.ts +0 -129
package/src/profile.ts
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
|
|
3
|
-
import { api_version_schema } from './common.js';
|
|
4
|
-
import { taint_schema } from './node-list.js';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Node profile specification schema.
|
|
8
|
-
* Defines reusable configuration for labels, taints, and annotations.
|
|
9
|
-
*/
|
|
10
|
-
export const node_profile_spec_schema = z.object({
|
|
11
|
-
name: z.string().min(1).optional(),
|
|
12
|
-
description: z.string().optional(),
|
|
13
|
-
labels: z.record(z.union([z.string(), z.boolean(), z.number()])).optional(),
|
|
14
|
-
taints: z.array(taint_schema).optional(),
|
|
15
|
-
annotations: z.record(z.string()).optional(),
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
export type NodeProfileSpecType = z.infer<typeof node_profile_spec_schema>;
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Node profile metadata schema.
|
|
22
|
-
*/
|
|
23
|
-
export const node_profile_metadata_schema = z.object({
|
|
24
|
-
name: z.string().min(1),
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
export type NodeProfileMetadataType = z.infer<typeof node_profile_metadata_schema>;
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Standalone NodeProfile resource definition.
|
|
31
|
-
* Used for profile files at profiles/<profile-name>.yaml
|
|
32
|
-
*/
|
|
33
|
-
export const node_profile_resource_schema = z.object({
|
|
34
|
-
apiVersion: api_version_schema,
|
|
35
|
-
kind: z.literal('NodeProfile'),
|
|
36
|
-
metadata: node_profile_metadata_schema,
|
|
37
|
-
spec: node_profile_spec_schema,
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
export type NodeProfileResourceType = z.infer<typeof node_profile_resource_schema>;
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Validates a NodeProfile resource and returns the result.
|
|
44
|
-
*/
|
|
45
|
-
export function validate_node_profile_resource(
|
|
46
|
-
data: unknown,
|
|
47
|
-
): z.SafeParseReturnType<unknown, NodeProfileResourceType> {
|
|
48
|
-
return node_profile_resource_schema.safeParse(data);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Internal node profile type for use after loading.
|
|
53
|
-
*/
|
|
54
|
-
export interface NodeProfileType {
|
|
55
|
-
name: string;
|
|
56
|
-
display_name?: string;
|
|
57
|
-
description?: string;
|
|
58
|
-
labels?: Record<string, string | boolean | number>;
|
|
59
|
-
taints?: z.infer<typeof taint_schema>[];
|
|
60
|
-
annotations?: Record<string, string>;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Converts a NodeProfile resource to a NodeProfileType for internal use.
|
|
65
|
-
*/
|
|
66
|
-
export function node_profile_resource_to_profile(
|
|
67
|
-
resource: NodeProfileResourceType,
|
|
68
|
-
): NodeProfileType {
|
|
69
|
-
const profile: NodeProfileType = {
|
|
70
|
-
name: resource.metadata.name,
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
if (resource.spec.name !== undefined) {
|
|
74
|
-
profile.display_name = resource.spec.name;
|
|
75
|
-
}
|
|
76
|
-
if (resource.spec.description !== undefined) {
|
|
77
|
-
profile.description = resource.spec.description;
|
|
78
|
-
}
|
|
79
|
-
if (resource.spec.labels !== undefined) {
|
|
80
|
-
profile.labels = resource.spec.labels;
|
|
81
|
-
}
|
|
82
|
-
if (resource.spec.taints !== undefined) {
|
|
83
|
-
profile.taints = resource.spec.taints;
|
|
84
|
-
}
|
|
85
|
-
if (resource.spec.annotations !== undefined) {
|
|
86
|
-
profile.annotations = resource.spec.annotations;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
return profile;
|
|
90
|
-
}
|
package/src/sources.ts
DELETED
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Git reference - exactly one of branch, tag, or commit must be specified.
|
|
5
|
-
*/
|
|
6
|
-
export const git_ref_schema = z
|
|
7
|
-
.object({
|
|
8
|
-
branch: z.string().min(1).optional(),
|
|
9
|
-
tag: z.string().min(1).optional(),
|
|
10
|
-
commit: z.string().min(1).optional(),
|
|
11
|
-
})
|
|
12
|
-
.refine((data) => [data.branch, data.tag, data.commit].filter(Boolean).length === 1, {
|
|
13
|
-
message: "Exactly one of 'branch', 'tag', or 'commit' must be specified",
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
export type GitRefType = z.infer<typeof git_ref_schema>;
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Git source configuration for fetching templates from a Git repository.
|
|
20
|
-
*/
|
|
21
|
-
export const git_source_schema = z.object({
|
|
22
|
-
url: z.string().url(),
|
|
23
|
-
ref: git_ref_schema,
|
|
24
|
-
path: z.string().optional(),
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
export type GitSourceType = z.infer<typeof git_source_schema>;
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* HTTP archive source configuration for fetching templates from URLs.
|
|
31
|
-
* Supports tar.gz and zip archives.
|
|
32
|
-
*/
|
|
33
|
-
export const http_source_schema = z.object({
|
|
34
|
-
url: z.string().url(),
|
|
35
|
-
checksum: z.string().optional(),
|
|
36
|
-
headers: z.record(z.string(), z.string()).optional(),
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
export type HttpSourceType = z.infer<typeof http_source_schema>;
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* OCI artifact source configuration for pulling templates from OCI registries.
|
|
43
|
-
*/
|
|
44
|
-
export const oci_source_schema = z
|
|
45
|
-
.object({
|
|
46
|
-
registry: z.string().min(1),
|
|
47
|
-
repository: z.string().min(1),
|
|
48
|
-
tag: z.string().min(1).optional(),
|
|
49
|
-
digest: z.string().min(1).optional(),
|
|
50
|
-
})
|
|
51
|
-
.refine((data) => data.tag || data.digest, {
|
|
52
|
-
message: "Either 'tag' or 'digest' must be specified",
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
export type OciSourceType = z.infer<typeof oci_source_schema>;
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Duration format for TTL values.
|
|
59
|
-
* Examples: 30m, 1h, 24h, 7d
|
|
60
|
-
*/
|
|
61
|
-
export const duration_schema = z.string().regex(/^(\d+)(m|h|d)$/, {
|
|
62
|
-
message: "Duration must be in format: <number>(m|h|d), e.g., '30m', '1h', '7d'",
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Template source configuration - union of all source types.
|
|
67
|
-
* Exactly one of git, http, or oci must be specified.
|
|
68
|
-
*/
|
|
69
|
-
export const template_source_schema = z
|
|
70
|
-
.object({
|
|
71
|
-
name: z.string().min(1),
|
|
72
|
-
git: git_source_schema.optional(),
|
|
73
|
-
http: http_source_schema.optional(),
|
|
74
|
-
oci: oci_source_schema.optional(),
|
|
75
|
-
ttl: duration_schema.optional(),
|
|
76
|
-
})
|
|
77
|
-
.refine((data) => [data.git, data.http, data.oci].filter(Boolean).length === 1, {
|
|
78
|
-
message: "Exactly one of 'git', 'http', or 'oci' must be specified",
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
export type TemplateSourceType = z.infer<typeof template_source_schema>;
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Type guard for Git sources.
|
|
85
|
-
*/
|
|
86
|
-
export function is_git_source(
|
|
87
|
-
source: TemplateSourceType,
|
|
88
|
-
): source is TemplateSourceType & { git: GitSourceType } {
|
|
89
|
-
return source.git !== undefined;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Type guard for HTTP sources.
|
|
94
|
-
*/
|
|
95
|
-
export function is_http_source(
|
|
96
|
-
source: TemplateSourceType,
|
|
97
|
-
): source is TemplateSourceType & { http: HttpSourceType } {
|
|
98
|
-
return source.http !== undefined;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* Type guard for OCI sources.
|
|
103
|
-
*/
|
|
104
|
-
export function is_oci_source(
|
|
105
|
-
source: TemplateSourceType,
|
|
106
|
-
): source is TemplateSourceType & { oci: OciSourceType } {
|
|
107
|
-
return source.oci !== undefined;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* Determines if a source reference is mutable (requires TTL-based refresh).
|
|
112
|
-
* - Git branches: mutable
|
|
113
|
-
* - Git tags/commits: immutable
|
|
114
|
-
* - HTTP with checksum: immutable
|
|
115
|
-
* - HTTP without checksum: mutable
|
|
116
|
-
* - OCI 'latest' tag: mutable
|
|
117
|
-
* - OCI other tags/digests: immutable
|
|
118
|
-
*/
|
|
119
|
-
export function is_mutable_source(source: TemplateSourceType): boolean {
|
|
120
|
-
if (is_git_source(source)) {
|
|
121
|
-
return source.git.ref.branch !== undefined;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
if (is_http_source(source)) {
|
|
125
|
-
return source.http.checksum === undefined;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
if (is_oci_source(source)) {
|
|
129
|
-
return source.oci.tag === 'latest' && source.oci.digest === undefined;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
return true;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
* Validates a template source object and returns the result.
|
|
137
|
-
*/
|
|
138
|
-
export function validate_template_source(
|
|
139
|
-
data: unknown,
|
|
140
|
-
): z.SafeParseReturnType<unknown, TemplateSourceType> {
|
|
141
|
-
return template_source_schema.safeParse(data);
|
|
142
|
-
}
|
package/src/template.ts
DELETED
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
api_version_schema,
|
|
5
|
-
health_check_expr_schema,
|
|
6
|
-
health_check_schema,
|
|
7
|
-
metadata_schema,
|
|
8
|
-
namespace_config_schema,
|
|
9
|
-
substitution_schema,
|
|
10
|
-
} from './common.js';
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Raw dependency reference to an external Flux Kustomization.
|
|
14
|
-
* Used for dependencies outside the kustodian-generated system.
|
|
15
|
-
*/
|
|
16
|
-
export const raw_dependency_ref_schema = z.object({
|
|
17
|
-
raw: z.object({
|
|
18
|
-
name: z.string().min(1),
|
|
19
|
-
namespace: z.string().min(1),
|
|
20
|
-
}),
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
export type RawDependencyRefType = z.infer<typeof raw_dependency_ref_schema>;
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Dependency reference - either a string or a raw reference object.
|
|
27
|
-
*
|
|
28
|
-
* Supports three formats:
|
|
29
|
-
* - Within-template: `database`
|
|
30
|
-
* - Cross-template: `secrets/doppler`
|
|
31
|
-
* - Raw external: `{ raw: { name: 'legacy-infrastructure', namespace: 'gitops-system' } }`
|
|
32
|
-
*/
|
|
33
|
-
export const dependency_ref_schema = z.union([z.string(), raw_dependency_ref_schema]);
|
|
34
|
-
|
|
35
|
-
export type DependencyRefType = z.infer<typeof dependency_ref_schema>;
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Preservation mode for disabled kustomizations.
|
|
39
|
-
*
|
|
40
|
-
* - none: Delete all resources when disabled
|
|
41
|
-
* - stateful: Keep PVCs, Secrets, and ConfigMaps (default, safe)
|
|
42
|
-
* - custom: Keep only specified resource types
|
|
43
|
-
*/
|
|
44
|
-
export const preservation_mode_schema = z.enum(['none', 'stateful', 'custom']);
|
|
45
|
-
|
|
46
|
-
export type PreservationModeType = z.infer<typeof preservation_mode_schema>;
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Preservation policy for a kustomization when disabled.
|
|
50
|
-
*/
|
|
51
|
-
export const preservation_policy_schema = z.object({
|
|
52
|
-
mode: preservation_mode_schema.default('stateful'),
|
|
53
|
-
keep_resources: z.array(z.string()).optional(),
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
export type PreservationPolicyType = z.infer<typeof preservation_policy_schema>;
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* A single kustomization within a template.
|
|
60
|
-
* Maps to a Flux Kustomization resource.
|
|
61
|
-
*/
|
|
62
|
-
export const kustomization_schema = z.object({
|
|
63
|
-
name: z.string().min(1),
|
|
64
|
-
path: z.string().min(1),
|
|
65
|
-
namespace: namespace_config_schema.optional(),
|
|
66
|
-
depends_on: z.array(dependency_ref_schema).optional(),
|
|
67
|
-
substitutions: z.array(substitution_schema).optional(),
|
|
68
|
-
health_checks: z.array(health_check_schema).optional(),
|
|
69
|
-
health_check_exprs: z.array(health_check_expr_schema).optional(),
|
|
70
|
-
prune: z.boolean().optional().default(true),
|
|
71
|
-
wait: z.boolean().optional().default(true),
|
|
72
|
-
timeout: z.string().optional(),
|
|
73
|
-
retry_interval: z.string().optional(),
|
|
74
|
-
enabled: z.boolean().optional().default(true),
|
|
75
|
-
preservation: preservation_policy_schema.optional(),
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
export type KustomizationType = z.infer<typeof kustomization_schema>;
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Node label requirement - requires specific labels to be present on cluster nodes.
|
|
82
|
-
*/
|
|
83
|
-
export const node_label_requirement_schema = z.object({
|
|
84
|
-
type: z.literal('nodeLabel'),
|
|
85
|
-
key: z.string().min(1),
|
|
86
|
-
value: z.string().optional(),
|
|
87
|
-
atLeast: z.number().int().positive().default(1),
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
export type NodeLabelRequirementType = z.infer<typeof node_label_requirement_schema>;
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Template requirement - validates cluster prerequisites before deployment.
|
|
94
|
-
* Currently supports node label requirements, extensible for future types.
|
|
95
|
-
*/
|
|
96
|
-
export const template_requirement_schema = z.discriminatedUnion('type', [
|
|
97
|
-
node_label_requirement_schema,
|
|
98
|
-
]);
|
|
99
|
-
|
|
100
|
-
export type TemplateRequirementType = z.infer<typeof template_requirement_schema>;
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* Template specification containing kustomizations.
|
|
104
|
-
*/
|
|
105
|
-
export const template_spec_schema = z.object({
|
|
106
|
-
requirements: z.array(template_requirement_schema).optional(),
|
|
107
|
-
kustomizations: z.array(kustomization_schema).min(1),
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
export type TemplateSpecType = z.infer<typeof template_spec_schema>;
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* Complete Template resource definition.
|
|
114
|
-
*/
|
|
115
|
-
export const template_schema = z.object({
|
|
116
|
-
apiVersion: api_version_schema,
|
|
117
|
-
kind: z.literal('Template'),
|
|
118
|
-
metadata: metadata_schema,
|
|
119
|
-
spec: template_spec_schema,
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
export type TemplateType = z.infer<typeof template_schema>;
|
|
123
|
-
|
|
124
|
-
/**
|
|
125
|
-
* Validates a template object and returns the result.
|
|
126
|
-
*/
|
|
127
|
-
export function validate_template(data: unknown): z.SafeParseReturnType<unknown, TemplateType> {
|
|
128
|
-
return template_schema.safeParse(data);
|
|
129
|
-
}
|