@spechtlabs/backstage-plugin-tailscale-backend 0.0.0-stage → 0.1.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/LICENSE +202 -0
- package/README.md +31 -2
- package/bin/backstage-tailscale-diff +4 -0
- package/config.schema.json +19 -0
- package/dist/access.cjs.js +113 -0
- package/dist/access.cjs.js.map +1 -0
- package/dist/cli.cjs.js +153 -0
- package/dist/cli.cjs.js.map +1 -0
- package/dist/cli.d.ts +2 -0
- package/dist/compile.cjs.js +878 -0
- package/dist/compile.cjs.js.map +1 -0
- package/dist/graph.cjs.js +165 -0
- package/dist/graph.cjs.js.map +1 -0
- package/dist/hujson.cjs.js +92 -0
- package/dist/hujson.cjs.js.map +1 -0
- package/dist/index.cjs.js +18 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.d.ts +64 -0
- package/dist/plugin.cjs.js +203 -0
- package/dist/plugin.cjs.js.map +1 -0
- package/dist/policyDiff.cjs.js +161 -0
- package/dist/policyDiff.cjs.js.map +1 -0
- package/dist/publish.cjs.js +159 -0
- package/dist/publish.cjs.js.map +1 -0
- package/dist/report.cjs.js +65 -0
- package/dist/report.cjs.js.map +1 -0
- package/package.json +96 -3
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var catalogModel = require('@backstage/catalog-model');
|
|
4
|
+
var compile = require('./compile.cjs.js');
|
|
5
|
+
|
|
6
|
+
function sectionCounts(policy) {
|
|
7
|
+
const tests = policy.tests.filter((t) => t.kind === "acl").length;
|
|
8
|
+
return [
|
|
9
|
+
["Groups", policy.groups.length],
|
|
10
|
+
["Hosts", policy.hosts.length],
|
|
11
|
+
["Tags", policy.tags.length],
|
|
12
|
+
["Node attributes", policy.nodeAttrs.length],
|
|
13
|
+
["Auto approvers", policy.autoApprovers.length],
|
|
14
|
+
["SSH rules", policy.ssh.length],
|
|
15
|
+
["Grants", policy.grants.length],
|
|
16
|
+
["Tests", tests],
|
|
17
|
+
["SSH tests", policy.tests.length - tests]
|
|
18
|
+
];
|
|
19
|
+
}
|
|
20
|
+
function pullRequestTitle(policy) {
|
|
21
|
+
const grants = policy.grants.length;
|
|
22
|
+
return `feat(tailscale): render ${policy.tailnet ?? policy.name} (${grants} grants, ${policy.ssh.length} SSH rules, ${policy.tests.length} tests)`;
|
|
23
|
+
}
|
|
24
|
+
function pullRequestBody(policy, baseUrl) {
|
|
25
|
+
const link = (ref) => {
|
|
26
|
+
const { kind, namespace, name } = catalogModel.parseEntityRef(ref);
|
|
27
|
+
const text = `\`${compile.shortRef(ref)}\``;
|
|
28
|
+
return baseUrl ? `[${text}](${baseUrl}/catalog/${namespace}/${kind.toLowerCase()}/${name})` : text;
|
|
29
|
+
};
|
|
30
|
+
const errors = policy.diagnostics.filter((d) => d.severity === "error");
|
|
31
|
+
const warnings = policy.diagnostics.filter((d) => d.severity === "warning");
|
|
32
|
+
const lines = [
|
|
33
|
+
`The tailnet policy for **${policy.title ?? policy.name}**${policy.tailnet ? ` (\`${policy.tailnet}\`)` : ""}, as Backstage renders it from ${link(policy.entityRef)} and its ${policy.parts.length - 1} parts.`,
|
|
34
|
+
"",
|
|
35
|
+
"| Section | Entries |",
|
|
36
|
+
"|---|---:|",
|
|
37
|
+
...sectionCounts(policy).map(([name, count]) => `| ${name} | ${count} |`),
|
|
38
|
+
""
|
|
39
|
+
];
|
|
40
|
+
const catalogGrants = policy.grants.filter((g) => g.origin === "catalog");
|
|
41
|
+
if (catalogGrants.length) {
|
|
42
|
+
lines.push(
|
|
43
|
+
`${catalogGrants.length} grants come from Components that consume an API across the tailnet; ${policy.catalog.covered.length} more consumptions are already allowed by a grant entity.`,
|
|
44
|
+
""
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
if (errors.length || warnings.length) {
|
|
48
|
+
lines.push("### Problems", "");
|
|
49
|
+
for (const d of [...errors, ...warnings]) {
|
|
50
|
+
lines.push(
|
|
51
|
+
`- ${d.severity === "error" ? "**Error**" : "Warning"}: ${d.entityRef ? `${link(d.entityRef)}: ` : ""}${d.message}`
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
lines.push("");
|
|
55
|
+
}
|
|
56
|
+
lines.push(
|
|
57
|
+
"Change the entities in the catalog, not this file: Backstage keeps this pull request up to date."
|
|
58
|
+
);
|
|
59
|
+
return lines.join("\n");
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
exports.pullRequestBody = pullRequestBody;
|
|
63
|
+
exports.pullRequestTitle = pullRequestTitle;
|
|
64
|
+
exports.sectionCounts = sectionCounts;
|
|
65
|
+
//# sourceMappingURL=report.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"report.cjs.js","sources":["../src/report.ts"],"sourcesContent":["import { parseEntityRef } from '@backstage/catalog-model';\nimport type { PolicyView } from '@spechtlabs/backstage-plugin-tailscale-common';\nimport { shortRef } from './compile';\n\n/** The policy's sections and how many entries each has. */\nexport function sectionCounts(policy: PolicyView) {\n const tests = policy.tests.filter(t => t.kind === 'acl').length;\n return [\n ['Groups', policy.groups.length],\n ['Hosts', policy.hosts.length],\n ['Tags', policy.tags.length],\n ['Node attributes', policy.nodeAttrs.length],\n ['Auto approvers', policy.autoApprovers.length],\n ['SSH rules', policy.ssh.length],\n ['Grants', policy.grants.length],\n ['Tests', tests],\n ['SSH tests', policy.tests.length - tests],\n ] as const;\n}\n\nexport function pullRequestTitle(policy: PolicyView) {\n const grants = policy.grants.length;\n return `feat(tailscale): render ${\n policy.tailnet ?? policy.name\n } (${grants} grants, ${policy.ssh.length} SSH rules, ${\n policy.tests.length\n } tests)`;\n}\n\n/** The pull request's description: what is in the file, and from where. */\nexport function pullRequestBody(policy: PolicyView, baseUrl?: string) {\n const link = (ref: string) => {\n const { kind, namespace, name } = parseEntityRef(ref);\n const text = `\\`${shortRef(ref)}\\``;\n return baseUrl\n ? `[${text}](${baseUrl}/catalog/${namespace}/${kind.toLowerCase()}/${name})`\n : text;\n };\n const errors = policy.diagnostics.filter(d => d.severity === 'error');\n const warnings = policy.diagnostics.filter(d => d.severity === 'warning');\n const lines = [\n `The tailnet policy for **${policy.title ?? policy.name}**${\n policy.tailnet ? ` (\\`${policy.tailnet}\\`)` : ''\n }, as Backstage renders it from ${link(policy.entityRef)} and its ${\n policy.parts.length - 1\n } parts.`,\n '',\n '| Section | Entries |',\n '|---|---:|',\n ...sectionCounts(policy).map(([name, count]) => `| ${name} | ${count} |`),\n '',\n ];\n const catalogGrants = policy.grants.filter(g => g.origin === 'catalog');\n if (catalogGrants.length) {\n lines.push(\n `${catalogGrants.length} grants come from Components that consume an API across the tailnet; ${policy.catalog.covered.length} more consumptions are already allowed by a grant entity.`,\n '',\n );\n }\n if (errors.length || warnings.length) {\n lines.push('### Problems', '');\n for (const d of [...errors, ...warnings]) {\n lines.push(\n `- ${d.severity === 'error' ? '**Error**' : 'Warning'}: ${\n d.entityRef ? `${link(d.entityRef)}: ` : ''\n }${d.message}`,\n );\n }\n lines.push('');\n }\n lines.push(\n 'Change the entities in the catalog, not this file: Backstage keeps this pull request up to date.',\n );\n return lines.join('\\n');\n}\n"],"names":["parseEntityRef","shortRef"],"mappings":";;;;;AAKO,SAAS,cAAc,MAAA,EAAoB;AAChD,EAAA,MAAM,KAAA,GAAQ,OAAO,KAAA,CAAM,MAAA,CAAO,OAAK,CAAA,CAAE,IAAA,KAAS,KAAK,CAAA,CAAE,MAAA;AACzD,EAAA,OAAO;AAAA,IACL,CAAC,QAAA,EAAU,MAAA,CAAO,MAAA,CAAO,MAAM,CAAA;AAAA,IAC/B,CAAC,OAAA,EAAS,MAAA,CAAO,KAAA,CAAM,MAAM,CAAA;AAAA,IAC7B,CAAC,MAAA,EAAQ,MAAA,CAAO,IAAA,CAAK,MAAM,CAAA;AAAA,IAC3B,CAAC,iBAAA,EAAmB,MAAA,CAAO,SAAA,CAAU,MAAM,CAAA;AAAA,IAC3C,CAAC,gBAAA,EAAkB,M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,CAAA,CAAE,SAAA,GAAY,CAAA,EAAG,IAAA,CAAK,EAAE,SAAS,CAAC,OAAO,EAC3C,CAAA,EAAG,EAAE,OAAO,CAAA;AAAA,OACd;AAAA,IACF;AACA,IAAA,KAAA,CAAM,KAAK,EAAE,CAAA;AAAA,EACf;AACA,EAAA,KAAA,CAAM,IAAA;AAAA,IACJ;AAAA,GACF;AACA,EAAA,OAAO,KAAA,CAAM,KAAK,IAAI,CAAA;AACxB;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,99 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spechtlabs/backstage-plugin-tailscale-backend",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Renders Tailscale tailnet policies from the Backstage catalog, serves them to the Tailscale frontend plugin, and publishes them to GitHub as a pull request or a push.",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"homepage": "https://github.com/SpechtLabs/backstage-plugin-tailscale/tree/main/plugins/tailscale-backend#readme",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/SpechtLabs/backstage-plugin-tailscale.git",
|
|
10
|
+
"directory": "plugins/tailscale-backend"
|
|
11
|
+
},
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/SpechtLabs/backstage-plugin-tailscale/issues"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"backstage",
|
|
17
|
+
"backstage-plugin",
|
|
18
|
+
"tailscale",
|
|
19
|
+
"tailnet",
|
|
20
|
+
"acl",
|
|
21
|
+
"policy"
|
|
22
|
+
],
|
|
23
|
+
"main": "dist/index.cjs.js",
|
|
24
|
+
"types": "dist/index.d.ts",
|
|
25
|
+
"publishConfig": {
|
|
26
|
+
"access": "public",
|
|
27
|
+
"main": "dist/index.cjs.js",
|
|
28
|
+
"types": "dist/index.d.ts"
|
|
29
|
+
},
|
|
30
|
+
"backstage": {
|
|
31
|
+
"role": "backend-plugin",
|
|
32
|
+
"pluginId": "tailscale",
|
|
33
|
+
"pluginPackages": [
|
|
34
|
+
"@spechtlabs/backstage-plugin-catalog-backend-module-tailscale",
|
|
35
|
+
"@spechtlabs/backstage-plugin-tailscale",
|
|
36
|
+
"@spechtlabs/backstage-plugin-tailscale-backend",
|
|
37
|
+
"@spechtlabs/backstage-plugin-tailscale-common"
|
|
38
|
+
],
|
|
39
|
+
"features": {
|
|
40
|
+
".": "@backstage/BackendFeature"
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
"sideEffects": false,
|
|
44
|
+
"files": [
|
|
45
|
+
"dist",
|
|
46
|
+
"bin",
|
|
47
|
+
"config.schema.json"
|
|
48
|
+
],
|
|
49
|
+
"scripts": {
|
|
50
|
+
"build": "backstage-cli package build",
|
|
51
|
+
"lint": "backstage-cli package lint",
|
|
52
|
+
"test": "backstage-cli package test",
|
|
53
|
+
"clean": "backstage-cli package clean",
|
|
54
|
+
"prepack": "backstage-cli package prepack",
|
|
55
|
+
"postpack": "backstage-cli package postpack"
|
|
56
|
+
},
|
|
57
|
+
"dependencies": {
|
|
58
|
+
"@backstage/backend-plugin-api": "^1.12.0",
|
|
59
|
+
"@backstage/catalog-model": "^1.10.3",
|
|
60
|
+
"@backstage/integration": "^2.2.0",
|
|
61
|
+
"@backstage/plugin-catalog-node": "^3.0.0",
|
|
62
|
+
"@backstage/types": "^1.2.2",
|
|
63
|
+
"@spechtlabs/backstage-plugin-tailscale-common": "^0.1.0",
|
|
64
|
+
"express-promise-router": "^4.1.1",
|
|
65
|
+
"jsonc-parser": "^2.2.1",
|
|
66
|
+
"yaml": "^2.9.1"
|
|
67
|
+
},
|
|
68
|
+
"devDependencies": {
|
|
69
|
+
"@backstage/cli": "^0.36.8"
|
|
70
|
+
},
|
|
71
|
+
"configSchema": "config.schema.json",
|
|
72
|
+
"bin": {
|
|
73
|
+
"backstage-tailscale-diff": "bin/backstage-tailscale-diff"
|
|
74
|
+
},
|
|
75
|
+
"exports": {
|
|
76
|
+
".": {
|
|
77
|
+
"backstage": "@backstage/BackendFeature",
|
|
78
|
+
"require": "./dist/index.cjs.js",
|
|
79
|
+
"types": "./dist/index.d.ts",
|
|
80
|
+
"default": "./dist/index.cjs.js"
|
|
81
|
+
},
|
|
82
|
+
"./cli": {
|
|
83
|
+
"require": "./dist/cli.cjs.js",
|
|
84
|
+
"types": "./dist/cli.d.ts",
|
|
85
|
+
"default": "./dist/cli.cjs.js"
|
|
86
|
+
},
|
|
87
|
+
"./package.json": "./package.json"
|
|
88
|
+
},
|
|
89
|
+
"typesVersions": {
|
|
90
|
+
"*": {
|
|
91
|
+
"cli": [
|
|
92
|
+
"dist/cli.d.ts"
|
|
93
|
+
],
|
|
94
|
+
"package.json": [
|
|
95
|
+
"package.json"
|
|
96
|
+
]
|
|
97
|
+
}
|
|
98
|
+
}
|
|
6
99
|
}
|