-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add typegen for known core resources
- Loading branch information
1 parent
62ca8ec
commit 8c476f9
Showing
12 changed files
with
142 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"create-monokle-plugin": minor | ||
--- | ||
|
||
Add typegen for known core resources |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,5 +2,5 @@ | |
build | ||
dist | ||
node_modules | ||
src/crds/__generated__/** | ||
**/__generated__/** | ||
internal/server.cjs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 22 additions & 9 deletions
31
packages/create-monokle-plugin/template-validation-ts/package-lock.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
packages/create-monokle-plugin/template-validation-ts/src/plugin.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
import { definePlugin } from "@monokle/validation/custom"; | ||
import { noEmptyAnnotations } from "./rules/noEmptyAnnotations.js"; | ||
import { noExternalUrl } from "./rules/noExternalUrl.js"; | ||
import { sealedSecrets } from "./rules/sealedSecrets.js"; | ||
import { noPortMismatch } from "./rules/noPortMismatch.js"; | ||
|
||
export default definePlugin({ | ||
id: "YCP", | ||
name: "Your custom plugin", | ||
description: "Welcome to your first plugin!", | ||
rules: { | ||
noEmptyAnnotations, | ||
sealedSecrets, | ||
noPortMismatch, | ||
noExternalUrl, | ||
}, | ||
}); |
5 changes: 4 additions & 1 deletion
5
packages/create-monokle-plugin/template-validation-ts/src/rules/noEmptyAnnotations.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 7 additions & 2 deletions
9
packages/create-monokle-plugin/template-validation-ts/src/rules/noExternalUrl.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
packages/create-monokle-plugin/template-validation-ts/src/rules/noPortMismatch.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { defineRule } from "@monokle/validation/custom"; | ||
import { isDeployment } from "../schemas/__generated__/deployment.apps.v1.js"; | ||
import { isService } from "../schemas/__generated__/service.v1.js"; | ||
|
||
/** | ||
* An advanced example which uses related resources | ||
* | ||
* @remark use `npm run codegen` to generate types. | ||
*/ | ||
export const noPortMismatch = defineRule({ | ||
id: 2, | ||
description: "The target port should match any container port.", | ||
help: "Change to target port to a port that matching a container's port.", | ||
validate({ resources }, { getRelated, report }) { | ||
resources.filter(isService).forEach((service) => { | ||
const deployments = getRelated(service).filter(isDeployment); | ||
|
||
const validPorts = deployments.flatMap((d) => | ||
d.spec?.template.spec?.containers.flatMap((c) => | ||
c.ports?.flatMap((p) => p.containerPort) | ||
) | ||
); | ||
|
||
const servicePorts = service.spec?.ports ?? []; | ||
servicePorts.forEach((port, index: number) => { | ||
if (!validPorts.includes(Number(port.targetPort))) { | ||
report(service, { path: `spec.ports.${index}.targetPort` }); | ||
} | ||
}); | ||
}); | ||
}, | ||
}); |
16 changes: 0 additions & 16 deletions
16
packages/create-monokle-plugin/template-validation-ts/src/rules/sealedSecrets.ts
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters