@intentius/chant-lexicon-k8s 0.101.0 → 0.102.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/actions/apps.d.ts +4 -4
- package/dist/actions/apps.d.ts.map +1 -1
- package/dist/actions/core.d.ts +5 -5
- package/dist/actions/core.d.ts.map +1 -1
- package/dist/actions/networking.d.ts.map +1 -1
- package/dist/codegen/generate-typescript.d.ts +2 -2
- package/dist/codegen/generate-typescript.d.ts.map +1 -1
- package/dist/codegen/generate.d.ts.map +1 -1
- package/dist/codegen/naming.d.ts.map +1 -1
- package/dist/codegen/versions.d.ts.map +1 -1
- package/dist/components/capability-plugin.d.ts.map +1 -1
- package/dist/composites/catalog.d.ts.map +1 -1
- package/dist/composites/cockroachdb-cluster.d.ts +2 -2
- package/dist/composites/gke-otel-collector.d.ts.map +1 -1
- package/dist/composites/index.d.ts +1 -0
- package/dist/composites/index.d.ts.map +1 -1
- package/dist/composites/otel-collector-agent.d.ts +19 -1
- package/dist/composites/otel-collector-agent.d.ts.map +1 -1
- package/dist/composites/otel-collector-node.d.ts +88 -0
- package/dist/composites/otel-collector-node.d.ts.map +1 -0
- package/dist/composites/otel-collector-shape.d.ts.map +1 -1
- package/dist/composites/otel-collector.d.ts +9 -1
- package/dist/composites/otel-collector.d.ts.map +1 -1
- package/dist/composites/ray-cluster.d.ts +6 -6
- package/dist/composites/ray-job.d.ts +5 -5
- package/dist/composites/ray-service.d.ts +6 -6
- package/dist/crd/crd-sources.d.ts.map +1 -1
- package/dist/crd/loader.d.ts.map +1 -1
- package/dist/crd/oci-chart.d.ts +50 -0
- package/dist/crd/oci-chart.d.ts.map +1 -0
- package/dist/crd/types.d.ts +5 -0
- package/dist/crd/types.d.ts.map +1 -1
- package/dist/effect-receipt-row.d.ts.map +1 -1
- package/dist/generated/index.d.ts +752 -729
- package/dist/generated/index.d.ts.map +1 -1
- package/dist/import/embedded.d.ts +4 -2
- package/dist/import/embedded.d.ts.map +1 -1
- package/dist/import/generator.d.ts.map +1 -1
- package/dist/import/parser.d.ts.map +1 -1
- package/dist/import/testdata/embedded/fixtures.d.ts +6 -0
- package/dist/import/testdata/embedded/fixtures.d.ts.map +1 -1
- package/dist/integrity.json +6 -5
- package/dist/lint/audit-catalog.d.ts.map +1 -1
- package/dist/lint/post-synth/index.d.ts.map +1 -1
- package/dist/lint/post-synth/otel-placement-helpers.d.ts.map +1 -1
- package/dist/lint/post-synth/wk8605.d.ts +23 -0
- package/dist/lint/post-synth/wk8605.d.ts.map +1 -0
- package/dist/manifest.json +1 -1
- package/dist/meta.json +156 -17
- package/dist/okf/index.md +4 -0
- package/dist/okf/rules/WK8605.md +11 -0
- package/dist/okf/types/APIGroup.md +3 -3
- package/dist/okf/types/APIGroupList.md +1 -1
- package/dist/okf/types/APIResourceList.md +1 -1
- package/dist/okf/types/APIService.md +1 -1
- package/dist/okf/types/APIServiceList.md +2 -2
- package/dist/okf/types/APIVersions.md +1 -1
- package/dist/okf/types/BatchJob.md +1 -1
- package/dist/okf/types/CSIDriver.md +1 -1
- package/dist/okf/types/CSIDriverList.md +2 -2
- package/dist/okf/types/CSINode.md +1 -1
- package/dist/okf/types/CSINodeList.md +2 -2
- package/dist/okf/types/CSIStorageCapacity.md +2 -2
- package/dist/okf/types/CSIStorageCapacityList.md +2 -2
- package/dist/okf/types/CertificateSigningRequest.md +1 -1
- package/dist/okf/types/CertificateSigningRequestList.md +2 -2
- package/dist/okf/types/ClusterRole.md +1 -1
- package/dist/okf/types/ClusterRoleBindingList.md +2 -2
- package/dist/okf/types/ClusterRoleList.md +2 -2
- package/dist/okf/types/ClusterTrustBundle.md +1 -1
- package/dist/okf/types/ClusterTrustBundleList.md +2 -2
- package/dist/okf/types/ComponentStatus.md +1 -1
- package/dist/okf/types/ComponentStatusList.md +2 -2
- package/dist/okf/types/ConfigMapList.md +2 -2
- package/dist/okf/types/ControllerRevisionList.md +2 -2
- package/dist/okf/types/CoreEventList.md +2 -2
- package/dist/okf/types/CronJob.md +1 -1
- package/dist/okf/types/CronJobList.md +2 -2
- package/dist/okf/types/CustomResourceDefinition.md +1 -1
- package/dist/okf/types/CustomResourceDefinitionList.md +2 -2
- package/dist/okf/types/DaemonSet.md +1 -1
- package/dist/okf/types/DaemonSetList.md +2 -2
- package/dist/okf/types/DeleteOptions.md +1 -1
- package/dist/okf/types/Deploy.md +1 -1
- package/dist/okf/types/DeploymentList.md +2 -2
- package/dist/okf/types/DeviceClass.md +1 -1
- package/dist/okf/types/DeviceClassList.md +2 -2
- package/dist/okf/types/DeviceTaintRule.md +1 -1
- package/dist/okf/types/DeviceTaintRuleList.md +2 -2
- package/dist/okf/types/EndpointSlice.md +2 -2
- package/dist/okf/types/EndpointSliceList.md +2 -2
- package/dist/okf/types/Endpoints.md +1 -1
- package/dist/okf/types/EndpointsList.md +2 -2
- package/dist/okf/types/Event.md +2 -2
- package/dist/okf/types/EventsEvent.md +2 -2
- package/dist/okf/types/EventsEventList.md +2 -2
- package/dist/okf/types/Eviction.md +1 -1
- package/dist/okf/types/FlowSchema.md +1 -1
- package/dist/okf/types/FlowSchemaList.md +2 -2
- package/dist/okf/types/GrafanaDashboard.md +14 -0
- package/dist/okf/types/GrafanaDatasource.md +14 -0
- package/dist/okf/types/GrafanaFolder.md +14 -0
- package/dist/okf/types/HorizontalPodAutoscaler.md +1 -1
- package/dist/okf/types/HorizontalPodAutoscalerList.md +2 -2
- package/dist/okf/types/IPAddress.md +1 -1
- package/dist/okf/types/IPAddressList.md +2 -2
- package/dist/okf/types/Ing.md +1 -1
- package/dist/okf/types/IngressClass.md +1 -1
- package/dist/okf/types/IngressClassList.md +2 -2
- package/dist/okf/types/IngressList.md +2 -2
- package/dist/okf/types/JobList.md +2 -2
- package/dist/okf/types/Lease.md +1 -1
- package/dist/okf/types/LeaseCandidate.md +1 -1
- package/dist/okf/types/LeaseCandidateList.md +2 -2
- package/dist/okf/types/LeaseList.md +2 -2
- package/dist/okf/types/LimitRange.md +1 -1
- package/dist/okf/types/LimitRangeList.md +2 -2
- package/dist/okf/types/LocalSubjectAccessReview.md +1 -1
- package/dist/okf/types/MutatingAdmissionPolicy.md +1 -1
- package/dist/okf/types/MutatingAdmissionPolicyBinding.md +1 -1
- package/dist/okf/types/MutatingAdmissionPolicyBindingList.md +2 -2
- package/dist/okf/types/MutatingAdmissionPolicyList.md +2 -2
- package/dist/okf/types/MutatingWebhookConfiguration.md +1 -1
- package/dist/okf/types/MutatingWebhookConfigurationList.md +2 -2
- package/dist/okf/types/Namespace.md +1 -1
- package/dist/okf/types/NamespaceList.md +2 -2
- package/dist/okf/types/NetPol.md +1 -1
- package/dist/okf/types/NetworkPolicyList.md +2 -2
- package/dist/okf/types/Node.md +1 -1
- package/dist/okf/types/NodeList.md +2 -2
- package/dist/okf/types/PersistentVolume.md +1 -1
- package/dist/okf/types/PersistentVolumeClaimList.md +2 -2
- package/dist/okf/types/PersistentVolumeList.md +2 -2
- package/dist/okf/types/PodCertificateRequest.md +1 -1
- package/dist/okf/types/PodCertificateRequestList.md +2 -2
- package/dist/okf/types/PodDisruptionBudgetList.md +2 -2
- package/dist/okf/types/PodList.md +2 -2
- package/dist/okf/types/PodTemplateList.md +2 -2
- package/dist/okf/types/PriorityClassList.md +2 -2
- package/dist/okf/types/PriorityLevelConfiguration.md +1 -1
- package/dist/okf/types/PriorityLevelConfigurationList.md +2 -2
- package/dist/okf/types/ReplicaSet.md +1 -1
- package/dist/okf/types/ReplicaSetList.md +2 -2
- package/dist/okf/types/ReplicationController.md +1 -1
- package/dist/okf/types/ReplicationControllerList.md +2 -2
- package/dist/okf/types/ResourceClaim.md +1 -1
- package/dist/okf/types/ResourceClaimList.md +2 -2
- package/dist/okf/types/ResourceClaimTemplate.md +1 -1
- package/dist/okf/types/ResourceClaimTemplateList.md +2 -2
- package/dist/okf/types/ResourceQuota.md +1 -1
- package/dist/okf/types/ResourceQuotaList.md +2 -2
- package/dist/okf/types/ResourceSlice.md +1 -1
- package/dist/okf/types/ResourceSliceList.md +2 -2
- package/dist/okf/types/RoleBindingList.md +2 -2
- package/dist/okf/types/RoleList.md +2 -2
- package/dist/okf/types/RuntimeClass.md +2 -2
- package/dist/okf/types/RuntimeClassList.md +2 -2
- package/dist/okf/types/Scale.md +1 -1
- package/dist/okf/types/SecretList.md +2 -2
- package/dist/okf/types/SelfSubjectAccessReview.md +1 -1
- package/dist/okf/types/SelfSubjectRulesReview.md +1 -1
- package/dist/okf/types/Service.md +1 -1
- package/dist/okf/types/ServiceAccountList.md +2 -2
- package/dist/okf/types/ServiceCIDR.md +1 -1
- package/dist/okf/types/ServiceCIDRList.md +2 -2
- package/dist/okf/types/ServiceList.md +2 -2
- package/dist/okf/types/StatefulSet.md +1 -1
- package/dist/okf/types/StatefulSetList.md +2 -2
- package/dist/okf/types/Status.md +2 -2
- package/dist/okf/types/StorageClass.md +1 -1
- package/dist/okf/types/StorageClassList.md +2 -2
- package/dist/okf/types/StorageVersionMigration.md +1 -1
- package/dist/okf/types/StorageVersionMigrationList.md +2 -2
- package/dist/okf/types/SubjectAccessReview.md +1 -1
- package/dist/okf/types/TokenRequest.md +1 -1
- package/dist/okf/types/TokenReview.md +1 -1
- package/dist/okf/types/ValidatingAdmissionPolicy.md +1 -1
- package/dist/okf/types/ValidatingAdmissionPolicyBinding.md +1 -1
- package/dist/okf/types/ValidatingAdmissionPolicyBindingList.md +2 -2
- package/dist/okf/types/ValidatingAdmissionPolicyList.md +2 -2
- package/dist/okf/types/ValidatingWebhookConfiguration.md +1 -1
- package/dist/okf/types/ValidatingWebhookConfigurationList.md +2 -2
- package/dist/okf/types/VolumeAttachment.md +1 -1
- package/dist/okf/types/VolumeAttachmentList.md +2 -2
- package/dist/okf/types/VolumeAttributesClassList.md +2 -2
- package/dist/op/activities/argo.d.ts.map +1 -1
- package/dist/op/activities/index.d.ts +3 -3
- package/dist/op/activities/index.d.ts.map +1 -1
- package/dist/op/activities/wait-for-ready.d.ts.map +1 -1
- package/dist/op/builders.d.ts.map +1 -1
- package/dist/rules/wk8605.ts +131 -0
- package/dist/skills/chant-k8s.md +1 -1
- package/dist/spec/parse.d.ts +27 -0
- package/dist/spec/parse.d.ts.map +1 -1
- package/dist/types/index.d.ts +5360 -972
- package/dist/variables.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/codegen/declarations.test.ts +118 -0
- package/src/codegen/generate-typescript.ts +69 -4
- package/src/codegen/generate.ts +15 -6
- package/src/composites/catalog.ts +6 -0
- package/src/composites/gke-otel-collector.ts +6 -1
- package/src/composites/index.ts +1 -0
- package/src/composites/otel-collector-agent.ts +39 -2
- package/src/composites/otel-collector-node.test.ts +174 -0
- package/src/composites/otel-collector-node.ts +213 -0
- package/src/composites/otel-collector.ts +15 -1
- package/src/crd/crd-sources.ts +26 -0
- package/src/crd/loader.test.ts +9 -1
- package/src/crd/loader.ts +26 -3
- package/src/crd/oci-chart.test.ts +149 -0
- package/src/crd/oci-chart.ts +178 -0
- package/src/crd/types.ts +5 -0
- package/src/generated/index.d.ts +5360 -972
- package/src/generated/index.ts +23 -0
- package/src/generated/lexicon-k8s.json +156 -17
- package/src/generated/operations.json +48 -0
- package/src/import/embedded-live.test.ts +46 -4
- package/src/import/embedded-roundtrip.test.ts +73 -7
- package/src/import/embedded-types.e2e.test.ts +3 -1
- package/src/import/embedded.test.ts +64 -0
- package/src/import/embedded.ts +31 -2
- package/src/import/generator.test.ts +19 -0
- package/src/import/generator.ts +20 -2
- package/src/import/testdata/embedded/README.md +4 -1
- package/src/import/testdata/embedded/alertmanager-configmap.yaml +91 -0
- package/src/import/testdata/embedded/fixtures.ts +18 -0
- package/src/import/testdata/embedded/grafana-operator-dashboard.yaml +363 -0
- package/src/import/testdata/embedded/grafana-v2-dashboard-configmap.yaml +851 -0
- package/src/lint/audit-catalog.ts +1 -0
- package/src/lint/post-synth/index.ts +2 -0
- package/src/lint/post-synth/post-synth.test.ts +3 -3
- package/src/lint/post-synth/wk8605.test.ts +141 -0
- package/src/lint/post-synth/wk8605.ts +131 -0
- package/src/skills/chant-k8s.md +1 -1
- package/src/spec/parse.test.ts +118 -0
- package/src/spec/parse.ts +250 -29
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pull a Helm chart out of an OCI registry over plain HTTP, and read its files.
|
|
3
|
+
*
|
|
4
|
+
* Generation used to shell out to `helm pull` for these. A machine without
|
|
5
|
+
* helm on PATH (a fresh CI runner, a container) then dropped the chart's kinds
|
|
6
|
+
* with only a warning, and the generated surface depended on which tools the
|
|
7
|
+
* host happened to have. The registry API is three requests, and a chart is a
|
|
8
|
+
* small gzipped tarball, so neither needs the binary.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { createHash } from "crypto";
|
|
12
|
+
import { gunzipSync } from "zlib";
|
|
13
|
+
import { fetchWithRetry } from "@intentius/chant/codegen/fetch";
|
|
14
|
+
|
|
15
|
+
/** The layer media type Helm pushes a chart's content under. */
|
|
16
|
+
export const HELM_CHART_LAYER = "application/vnd.cncf.helm.chart.content.v1.tar+gzip";
|
|
17
|
+
|
|
18
|
+
const MANIFEST_ACCEPT = [
|
|
19
|
+
"application/vnd.oci.image.manifest.v1+json",
|
|
20
|
+
"application/vnd.docker.distribution.manifest.v2+json",
|
|
21
|
+
].join(", ");
|
|
22
|
+
|
|
23
|
+
type Fetch = (url: string, init?: RequestInit) => Promise<Response>;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* The two kinds of request a pull makes. `probe` must return a 401 as a
|
|
27
|
+
* response (the registry's auth challenge); `get` throws on any failure and
|
|
28
|
+
* retries transient ones.
|
|
29
|
+
*/
|
|
30
|
+
export interface OciHttp {
|
|
31
|
+
probe: Fetch;
|
|
32
|
+
get: Fetch;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const defaultHttp: OciHttp = {
|
|
36
|
+
probe: (url, init) => fetch(url, init),
|
|
37
|
+
get: (url, init) => fetchWithRetry(url, undefined, undefined, init),
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export interface OciChartRef {
|
|
41
|
+
/** Registry host, e.g. "ghcr.io". */
|
|
42
|
+
host: string;
|
|
43
|
+
/** Repository path inside the registry, e.g. "codriverlabs/helm/kube-microvm-operator". */
|
|
44
|
+
repository: string;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** Split an `oci://host/repo/path` chart reference. */
|
|
48
|
+
export function parseOciRef(chart: string): OciChartRef {
|
|
49
|
+
const m = /^oci:\/\/([^/]+)\/(.+)$/.exec(chart);
|
|
50
|
+
if (!m) throw new Error(`not an oci:// chart reference: ${chart}`);
|
|
51
|
+
return { host: m[1], repository: m[2].replace(/\/+$/, "") };
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Get an anonymous pull token, following the registry's own challenge
|
|
56
|
+
* (`WWW-Authenticate: Bearer realm=...,service=...`). Returns undefined when
|
|
57
|
+
* the registry does not ask for one.
|
|
58
|
+
*/
|
|
59
|
+
async function anonymousToken(ref: OciChartRef, http: OciHttp): Promise<string | undefined> {
|
|
60
|
+
const probe = await http.probe(`https://${ref.host}/v2/`);
|
|
61
|
+
if (probe.status !== 401) return undefined;
|
|
62
|
+
const challenge = probe.headers.get("www-authenticate") ?? "";
|
|
63
|
+
const params = Object.fromEntries(
|
|
64
|
+
[...challenge.matchAll(/(\w+)="([^"]*)"/g)].map((m) => [m[1], m[2]]),
|
|
65
|
+
);
|
|
66
|
+
if (!/^bearer/i.test(challenge) || !params.realm) {
|
|
67
|
+
throw new Error(`registry ${ref.host} asks for auth this loader does not speak: ${challenge || "(no challenge)"}`);
|
|
68
|
+
}
|
|
69
|
+
const url = new URL(params.realm);
|
|
70
|
+
if (params.service) url.searchParams.set("service", params.service);
|
|
71
|
+
url.searchParams.set("scope", `repository:${ref.repository}:pull`);
|
|
72
|
+
const res = await http.get(url.toString());
|
|
73
|
+
const body = (await res.json()) as { token?: string; access_token?: string };
|
|
74
|
+
const token = body.token ?? body.access_token;
|
|
75
|
+
if (!token) throw new Error(`registry ${ref.host} returned no token for ${ref.repository}`);
|
|
76
|
+
return token;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Download a chart's content layer (the .tgz `helm pull` would fetch).
|
|
81
|
+
*
|
|
82
|
+
* @param digest When given ("sha256:..."), the layer must have this digest.
|
|
83
|
+
* Pinning it makes the source content-addressed: a re-pushed
|
|
84
|
+
* tag fails loudly instead of changing generated output.
|
|
85
|
+
*/
|
|
86
|
+
export async function pullOciChart(
|
|
87
|
+
chart: string,
|
|
88
|
+
version: string,
|
|
89
|
+
digest?: string,
|
|
90
|
+
http: OciHttp = defaultHttp,
|
|
91
|
+
): Promise<Buffer> {
|
|
92
|
+
const ref = parseOciRef(chart);
|
|
93
|
+
const token = await anonymousToken(ref, http);
|
|
94
|
+
const auth: Record<string, string> = token ? { Authorization: `Bearer ${token}` } : {};
|
|
95
|
+
const base = `https://${ref.host}/v2/${ref.repository}`;
|
|
96
|
+
|
|
97
|
+
const manifestRes = await http.get(`${base}/manifests/${version}`, {
|
|
98
|
+
headers: { ...auth, Accept: MANIFEST_ACCEPT },
|
|
99
|
+
});
|
|
100
|
+
const manifest = (await manifestRes.json()) as { layers?: Array<{ mediaType: string; digest: string }> };
|
|
101
|
+
const layer = manifest.layers?.find((l) => l.mediaType === HELM_CHART_LAYER);
|
|
102
|
+
if (!layer) {
|
|
103
|
+
throw new Error(`${chart}:${version} has no layer of type ${HELM_CHART_LAYER}; is it a Helm chart?`);
|
|
104
|
+
}
|
|
105
|
+
if (digest && layer.digest !== digest) {
|
|
106
|
+
throw new Error(
|
|
107
|
+
`${chart}:${version} chart layer is ${layer.digest}, but the source pins ${digest}. ` +
|
|
108
|
+
"The tag was re-pushed; review the new chart and update the pin.",
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const blobRes = await http.get(`${base}/blobs/${layer.digest}`, { headers: auth });
|
|
113
|
+
const blob = Buffer.from(await blobRes.arrayBuffer());
|
|
114
|
+
const actual = `sha256:${createHash("sha256").update(blob).digest("hex")}`;
|
|
115
|
+
if (actual !== layer.digest) {
|
|
116
|
+
throw new Error(`${chart}:${version} chart layer downloaded as ${actual}, expected ${layer.digest}`);
|
|
117
|
+
}
|
|
118
|
+
return blob;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Read the regular files out of a gzipped tarball, as path to content.
|
|
123
|
+
* Handles ustar, plus the pax (`x`) and GNU (`L`) long-name records Helm's
|
|
124
|
+
* Go archiver may write.
|
|
125
|
+
*/
|
|
126
|
+
export function readTarGz(tgz: Buffer): Map<string, Buffer> {
|
|
127
|
+
const tar = gunzipSync(tgz);
|
|
128
|
+
const files = new Map<string, Buffer>();
|
|
129
|
+
let offset = 0;
|
|
130
|
+
let longName: string | undefined;
|
|
131
|
+
|
|
132
|
+
const field = (start: number, len: number): string => {
|
|
133
|
+
const raw = tar.subarray(offset + start, offset + start + len);
|
|
134
|
+
const nul = raw.indexOf(0);
|
|
135
|
+
return raw.subarray(0, nul === -1 ? raw.length : nul).toString("utf8");
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
while (offset + 512 <= tar.length) {
|
|
139
|
+
// Two zero blocks end the archive; one is enough to stop reading.
|
|
140
|
+
if (tar.subarray(offset, offset + 512).every((b) => b === 0)) break;
|
|
141
|
+
|
|
142
|
+
const size = parseInt(field(124, 12).trim() || "0", 8);
|
|
143
|
+
const type = field(156, 1) || "0";
|
|
144
|
+
const prefix = field(345, 155);
|
|
145
|
+
const name = longName ?? (prefix ? `${prefix}/${field(0, 100)}` : field(0, 100));
|
|
146
|
+
const data = tar.subarray(offset + 512, offset + 512 + size);
|
|
147
|
+
longName = undefined;
|
|
148
|
+
|
|
149
|
+
if (type === "x") {
|
|
150
|
+
const path = /(?:^|\n)\d+ path=([^\n]*)\n/.exec(data.toString("utf8"));
|
|
151
|
+
if (path) longName = path[1];
|
|
152
|
+
} else if (type === "L") {
|
|
153
|
+
longName = data.toString("utf8").replace(/\0+$/, "");
|
|
154
|
+
} else if (type === "0" || type === "\0") {
|
|
155
|
+
files.set(name, Buffer.from(data));
|
|
156
|
+
}
|
|
157
|
+
offset += 512 + Math.ceil(size / 512) * 512;
|
|
158
|
+
}
|
|
159
|
+
return files;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* The YAML files directly inside `<chart dir>/<subdir>/`, sorted by path so
|
|
164
|
+
* the concatenation does not depend on archive order.
|
|
165
|
+
*/
|
|
166
|
+
export function chartYamlFiles(files: Map<string, Buffer>, subdir: string): Array<[string, string]> {
|
|
167
|
+
const dir = subdir.replace(/^\/+|\/+$/g, "");
|
|
168
|
+
return [...files.entries()]
|
|
169
|
+
.filter(([path]) => {
|
|
170
|
+
// Strip the single top-level chart directory, whatever it is named.
|
|
171
|
+
const rest = path.split("/").slice(1).join("/");
|
|
172
|
+
if (!rest.startsWith(`${dir}/`)) return false;
|
|
173
|
+
const leaf = rest.slice(dir.length + 1);
|
|
174
|
+
return !leaf.includes("/") && (leaf.endsWith(".yaml") || leaf.endsWith(".yml"));
|
|
175
|
+
})
|
|
176
|
+
.sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))
|
|
177
|
+
.map(([path, buf]) => [path, buf.toString("utf8")]);
|
|
178
|
+
}
|
package/src/crd/types.ts
CHANGED
|
@@ -28,6 +28,11 @@ export interface CRDSource {
|
|
|
28
28
|
chart?: string;
|
|
29
29
|
/** Chart version for type="helm". Required: an unpinned source is not auditable. */
|
|
30
30
|
version?: string;
|
|
31
|
+
/**
|
|
32
|
+
* Digest of an `oci://` chart's content layer ("sha256:..."). Optional; when
|
|
33
|
+
* set, a re-pushed tag fails generation instead of changing its output.
|
|
34
|
+
*/
|
|
35
|
+
digest?: string;
|
|
31
36
|
/**
|
|
32
37
|
* Directory inside the chart holding the CRDs. Defaults to Helm's own
|
|
33
38
|
* convention, "crds". Charts that instead template their CRDs need this
|