Architecture & Extension Points¶
The extension is modular and focused on safe CLI execution plus lightweight manifest detection.
Core modules¶
ManifestDetector (src/utils/manifestDetector.ts)¶
- Parses YAML (multi-document supported) using
js-yaml. - Checks for
apiVersion,kind,metadatato confirm Kubernetes resources. - Detects kustomization resources and
kustomization.yamlfiles.
CliExecutor (src/utils/cliExecutor.ts)¶
- Wraps
kubectlandkustomizeviaexecFilefor safety. - Commands:
applyManifest,validateManifest,buildKustomize,applyKustomize. - Includes availability checks, context/namespace options, and dry-run support.
ManifestCodeLensProvider (src/providers/codeLensProvider.ts)¶
- Provides Code Lens buttons in YAML editors when manifests are detected.
Output Channel (src/utils/outputChannel.ts)¶
- Dedicated output channel with helpers for success/error messages and command logging.
Data flow (apply manifest)¶
User click
→ CodeLens command
→ manifestCommands.applyManifest
→ CliExecutor.applyManifest
→ kubectl apply -f <file>
→ Log output + notification
Extension points¶
- New commands: add a handler in
manifestCommands.ts, register inextension.ts, and expose viapackage.json. - Additional menu entries: extend
contributes.menusinpackage.json. - New settings: add to
contributes.configurationand read withworkspace.getConfiguration('k8s-manifest'). - Providers: register additional VS Code providers (hover, diagnostics, etc.) in
extension.ts.
Performance & security notes¶
- YAML parsing runs on document open; for very large files consider caching if you extend the code.
- CLI calls use
execFile(notexec) to avoid shell injection. - Credentials are handled by the existing
kubectlconfiguration—no new secret handling in the extension.