@intentius/chant-lexicon-k3s 0.124.30 → 0.124.32
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/codegen/docs-cli.js +3 -0
- package/dist/codegen/docs.js +83 -0
- package/dist/codegen/generate-cli.js +7 -0
- package/dist/codegen/generate-lexicon.js +39 -0
- package/dist/codegen/generate-typescript.js +38 -0
- package/dist/codegen/generate.js +93 -0
- package/dist/codegen/naming.js +34 -0
- package/dist/codegen/package.js +23 -0
- package/dist/codegen/parse.js +313 -0
- package/dist/describe-resources.js +200 -0
- package/dist/generated/index.js +10 -0
- package/dist/generated/runtime.js +4 -0
- package/dist/index.js +14 -0
- package/dist/lint/audit-catalog.js +16 -0
- package/dist/lint/audit-lineage.js +5 -0
- package/dist/lint/post-synth/index.js +16 -0
- package/dist/lint/post-synth/k3s-helpers.js +24 -0
- package/dist/lint/post-synth/k3s101.js +48 -0
- package/dist/lint/post-synth/k3s102.js +52 -0
- package/dist/lint/post-synth/k3s103.js +30 -0
- package/dist/lint/post-synth/k3s104.js +37 -0
- package/dist/lint/post-synth/k3s105.js +44 -0
- package/dist/lint/post-synth/k3s106.js +47 -0
- package/dist/lint/post-synth/k3s107.js +58 -0
- package/dist/lint/rules/index.js +4 -0
- package/dist/lint/rules/token-literal.js +78 -0
- package/dist/lsp/completions.d.ts.map +1 -1
- package/dist/lsp/completions.js +19 -0
- package/dist/lsp/hover.d.ts.map +1 -1
- package/dist/lsp/hover.js +33 -0
- package/dist/op/activities/index.js +21 -0
- package/dist/op/activities/k3s.js +112 -0
- package/dist/op/builders.js +31 -0
- package/dist/package-cli.js +19 -0
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +119 -0
- package/dist/serializer.js +169 -0
- package/dist/spec/fetch.js +72 -0
- package/dist/validate-cli.js +4 -0
- package/dist/validate.js +35 -0
- package/package.json +7 -7
- package/src/codegen/package.ts +2 -2
- package/src/lsp/completions.ts +2 -1
- package/src/lsp/hover.ts +2 -1
- package/src/plugin.ts +2 -1
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* k3s CLI flag-definition fetching — downloads the pinned Go sources that
|
|
3
|
+
* define the server and agent flag surfaces, and caches them locally.
|
|
4
|
+
*
|
|
5
|
+
* k3s publishes no JSON Schema for config.yaml. The config file's keys ARE
|
|
6
|
+
* the CLI flag names ("Every flag can be a config key", docs.k3s.io), and
|
|
7
|
+
* the flags are defined as urfave/cli struct literals in pkg/cli/cmds/.
|
|
8
|
+
* Those literals carry name, usage, default and hidden-ness, so the tagged
|
|
9
|
+
* source tree is the machine-readable spec (#1599) — the same channel the
|
|
10
|
+
* k3s binary itself is built from, pinned the same way k3d pins its
|
|
11
|
+
* schema.json.
|
|
12
|
+
*/
|
|
13
|
+
import { join } from "path";
|
|
14
|
+
import { homedir } from "os";
|
|
15
|
+
import { fetchWithCache, clearCacheFile } from "@intentius/chant/codegen/fetch";
|
|
16
|
+
/**
|
|
17
|
+
* Pinned upstream k3s release.
|
|
18
|
+
*
|
|
19
|
+
* Bump this constant (and re-generate) when adopting a newer k3s release.
|
|
20
|
+
* The acceptance test's rancher/k3s image tag derives from it (`+` → `-`).
|
|
21
|
+
*/
|
|
22
|
+
export const K3S_VERSION = "v1.36.3+k3s1";
|
|
23
|
+
/** Docker image tag form of the pin: `+` is not legal in a tag. */
|
|
24
|
+
export const K3S_IMAGE_TAG = K3S_VERSION.replace("+", "-");
|
|
25
|
+
/**
|
|
26
|
+
* The files that define flags reachable from the server and agent flag
|
|
27
|
+
* lists. server.go owns ServerFlags; agent.go owns the agent command's
|
|
28
|
+
* flags plus the shared node/token flag vars; config.go, root.go and
|
|
29
|
+
* log.go define the shared vars both lists reference (ConfigFlag,
|
|
30
|
+
* DebugFlag, VLevel, LogFile, ...).
|
|
31
|
+
*/
|
|
32
|
+
const SPEC_FILES = ["server.go", "agent.go", "config.go", "root.go", "log.go"];
|
|
33
|
+
function rawUrl(file) {
|
|
34
|
+
// '+' must be percent-encoded in the raw.githubusercontent path.
|
|
35
|
+
const tag = encodeURIComponent(K3S_VERSION);
|
|
36
|
+
return `https://raw.githubusercontent.com/k3s-io/k3s/${tag}/pkg/cli/cmds/${file}`;
|
|
37
|
+
}
|
|
38
|
+
function cachePath(file) {
|
|
39
|
+
return join(homedir(), ".chant", `k3s-${K3S_VERSION}-${file}`);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Fetch all pinned spec files, keyed by filename.
|
|
43
|
+
*/
|
|
44
|
+
export async function fetchSpecFiles(force) {
|
|
45
|
+
const files = {};
|
|
46
|
+
for (const file of SPEC_FILES) {
|
|
47
|
+
const data = await fetchWithCache({ url: rawUrl(file), cacheFile: cachePath(file) }, force);
|
|
48
|
+
files[file] = data.toString("utf-8");
|
|
49
|
+
}
|
|
50
|
+
return files;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Fetch the spec as a Map<typeName, Buffer> compatible with the
|
|
54
|
+
* generatePipeline fetchSchemas callback.
|
|
55
|
+
*
|
|
56
|
+
* Single entry keyed "K3s::Config" whose buffer is a JSON envelope of the
|
|
57
|
+
* fetched files — the parse step needs them together to resolve flag-var
|
|
58
|
+
* references across files.
|
|
59
|
+
*/
|
|
60
|
+
export async function fetchSchemas(force) {
|
|
61
|
+
const files = await fetchSpecFiles(force);
|
|
62
|
+
const schemas = new Map();
|
|
63
|
+
schemas.set("K3s::Config", Buffer.from(JSON.stringify(files), "utf-8"));
|
|
64
|
+
return schemas;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Clear the cached spec files.
|
|
68
|
+
*/
|
|
69
|
+
export function clearCache() {
|
|
70
|
+
for (const file of SPEC_FILES)
|
|
71
|
+
clearCacheFile(cachePath(file));
|
|
72
|
+
}
|
package/dist/validate.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validate generated lexicon-k3s artifacts.
|
|
3
|
+
*
|
|
4
|
+
* Thin wrapper around the core validation framework
|
|
5
|
+
* with k3s-specific configuration.
|
|
6
|
+
*/
|
|
7
|
+
import { dirname } from "path";
|
|
8
|
+
import { fileURLToPath } from "url";
|
|
9
|
+
import { validateLexiconArtifacts } from "@intentius/chant/codegen/validate";
|
|
10
|
+
/**
|
|
11
|
+
* Every entity class, plus load-bearing config keys whose disappearance
|
|
12
|
+
* from a regeneration would mean the parser silently lost part of the
|
|
13
|
+
* flag surface (#1599): the join/identity block, the etcd S3 keys the
|
|
14
|
+
* lint layer references, and one representative per flag type.
|
|
15
|
+
*/
|
|
16
|
+
const REQUIRED_NAMES = [
|
|
17
|
+
"Server",
|
|
18
|
+
"Agent",
|
|
19
|
+
"Registries",
|
|
20
|
+
"Mirror",
|
|
21
|
+
"RegistryConfig",
|
|
22
|
+
"RegistryAuth",
|
|
23
|
+
"RegistryTLS",
|
|
24
|
+
];
|
|
25
|
+
/**
|
|
26
|
+
* Validate the generated lexicon-k3s artifacts.
|
|
27
|
+
*/
|
|
28
|
+
export async function validate(opts) {
|
|
29
|
+
const basePath = opts?.basePath ?? dirname(dirname(fileURLToPath(import.meta.url)));
|
|
30
|
+
return validateLexiconArtifacts({
|
|
31
|
+
lexiconJsonFilename: "lexicon-k3s.json",
|
|
32
|
+
requiredNames: REQUIRED_NAMES,
|
|
33
|
+
basePath,
|
|
34
|
+
});
|
|
35
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intentius/chant-lexicon-k3s",
|
|
3
|
-
"version": "0.124.
|
|
3
|
+
"version": "0.124.32",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"src/",
|
|
@@ -10,22 +10,22 @@
|
|
|
10
10
|
".": {
|
|
11
11
|
"development": "./src/index.ts",
|
|
12
12
|
"types": "./dist/index.d.ts",
|
|
13
|
-
"default": "./
|
|
13
|
+
"default": "./dist/index.js"
|
|
14
14
|
},
|
|
15
15
|
"./*": {
|
|
16
16
|
"development": "./src/*.ts",
|
|
17
17
|
"types": "./dist/*.d.ts",
|
|
18
|
-
"default": "./
|
|
18
|
+
"default": "./dist/*.js"
|
|
19
19
|
},
|
|
20
20
|
"./op/activities": {
|
|
21
21
|
"development": "./src/op/activities/index.ts",
|
|
22
22
|
"types": "./dist/op/activities/index.d.ts",
|
|
23
|
-
"default": "./
|
|
23
|
+
"default": "./dist/op/activities/index.js"
|
|
24
24
|
},
|
|
25
25
|
"./lint/post-synth": {
|
|
26
26
|
"development": "./src/lint/post-synth/index.ts",
|
|
27
27
|
"types": "./dist/lint/post-synth/index.d.ts",
|
|
28
|
-
"default": "./
|
|
28
|
+
"default": "./dist/lint/post-synth/index.js"
|
|
29
29
|
},
|
|
30
30
|
"./manifest": "./dist/manifest.json",
|
|
31
31
|
"./meta": "./dist/meta.json",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"generate": "npx tsx src/codegen/generate-cli.ts",
|
|
36
36
|
"validate": "npx tsx src/validate-cli.ts",
|
|
37
37
|
"docs": "npx tsx src/codegen/docs-cli.ts",
|
|
38
|
-
"build": "../../scripts/tsc7.sh -p tsconfig.build.json && tsc-alias -p tsconfig.build.json
|
|
38
|
+
"build": "../../scripts/tsc7.sh -p tsconfig.build.json --sourceMap false && tsc-alias -p tsconfig.build.json",
|
|
39
39
|
"prepack": "npm run generate && npm run bundle && npm run validate && npm run build",
|
|
40
40
|
"bundle": "tsx src/package-cli.ts"
|
|
41
41
|
},
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"access": "public"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
|
-
"@intentius/chant": "^0.124.
|
|
53
|
+
"@intentius/chant": "^0.124.32"
|
|
54
54
|
},
|
|
55
55
|
"description": "k3s lexicon for chant — the k3s distro's host configuration as declarable data",
|
|
56
56
|
"license": "Apache-2.0",
|
package/src/codegen/package.ts
CHANGED
|
@@ -3,13 +3,13 @@ import type { PackagePipelineConfig } from "@intentius/chant/codegen/package";
|
|
|
3
3
|
import { k3sPlugin } from "../plugin";
|
|
4
4
|
import { generate } from "./generate";
|
|
5
5
|
import { dirname } from "path";
|
|
6
|
-
import {
|
|
6
|
+
import { moduleSourceDir } from "@intentius/chant/module-source";
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Package the k3s lexicon for distribution.
|
|
10
10
|
*/
|
|
11
11
|
export async function packageLexicon(options?: { verbose?: boolean; force?: boolean }) {
|
|
12
|
-
const srcDir =
|
|
12
|
+
const srcDir = moduleSourceDir(import.meta.url);
|
|
13
13
|
|
|
14
14
|
const { spec, stats } = await packagePipeline({
|
|
15
15
|
generate: (opts) => generate({ verbose: opts?.verbose, force: opts?.force }),
|
package/src/lsp/completions.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { createRequire } from "module";
|
|
2
|
+
import { moduleSourceUrl } from "@intentius/chant/module-source";
|
|
2
3
|
import type { CompletionContext, CompletionItem } from "@intentius/chant/lsp/types";
|
|
3
4
|
import {
|
|
4
5
|
LexiconIndex,
|
|
5
6
|
lexiconCompletions,
|
|
6
7
|
type LexiconEntry,
|
|
7
8
|
} from "@intentius/chant/lsp/lexicon-providers";
|
|
8
|
-
const require = createRequire(import.meta.url);
|
|
9
|
+
const require = createRequire(moduleSourceUrl(import.meta.url));
|
|
9
10
|
|
|
10
11
|
let cachedIndex: LexiconIndex | null = null;
|
|
11
12
|
|
package/src/lsp/hover.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { createRequire } from "module";
|
|
2
|
+
import { moduleSourceUrl } from "@intentius/chant/module-source";
|
|
2
3
|
import type { HoverContext, HoverInfo } from "@intentius/chant/lsp/types";
|
|
3
4
|
import {
|
|
4
5
|
LexiconIndex,
|
|
5
6
|
lexiconHover,
|
|
6
7
|
type LexiconEntry,
|
|
7
8
|
} from "@intentius/chant/lsp/lexicon-providers";
|
|
8
|
-
const require = createRequire(import.meta.url);
|
|
9
|
+
const require = createRequire(moduleSourceUrl(import.meta.url));
|
|
9
10
|
|
|
10
11
|
let cachedIndex: LexiconIndex | null = null;
|
|
11
12
|
|
package/src/plugin.ts
CHANGED
|
@@ -6,6 +6,7 @@ import type { McpToolContribution, McpResourceContribution } from "@intentius/ch
|
|
|
6
6
|
import { readFileSync } from "fs";
|
|
7
7
|
import { dirname, join } from "path";
|
|
8
8
|
import { fileURLToPath } from "url";
|
|
9
|
+
import { moduleSourceDir } from "@intentius/chant/module-source";
|
|
9
10
|
import { LABEL_OWNERSHIP_KEYS } from "@intentius/chant/ownership";
|
|
10
11
|
import { k3sSerializer } from "./serializer";
|
|
11
12
|
import { rules } from "./lint/rules";
|
|
@@ -99,7 +100,7 @@ export const k3sPlugin: LexiconPlugin = {
|
|
|
99
100
|
|
|
100
101
|
skills() {
|
|
101
102
|
const skills: SkillDefinition[] = [];
|
|
102
|
-
const dir =
|
|
103
|
+
const dir = moduleSourceDir(import.meta.url);
|
|
103
104
|
const entries = [
|
|
104
105
|
{
|
|
105
106
|
file: "chant-k3s.md",
|