-
Notifications
You must be signed in to change notification settings - Fork 273
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(k8s): add uninstall-garden-services command
This cleans up everything in the garden-system namespace, as well as related cluster-wide resources.
- Loading branch information
Showing
6 changed files
with
80 additions
and
24 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
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
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
38 changes: 38 additions & 0 deletions
38
garden-service/src/plugins/kubernetes/commands/uninstall-garden-services.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,38 @@ | ||
/* | ||
* Copyright (C) 2018 Garden Technologies, Inc. <[email protected]> | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
*/ | ||
|
||
import chalk from "chalk" | ||
import { PluginCommand } from "../../../types/plugin/command" | ||
import { getKubernetesSystemVariables } from "../init" | ||
import { KubernetesPluginContext } from "../config" | ||
import { getSystemGarden } from "../system" | ||
|
||
export const uninstallGardenServices: PluginCommand = { | ||
name: "uninstall-garden-services", | ||
description: "Clean up all installed cluster-wide Garden services.", | ||
|
||
handler: async ({ ctx, log }) => { | ||
const entry = log.info({ | ||
msg: chalk.bold.magenta( | ||
`Removing cluster-wide services for ${chalk.white(ctx.environmentName)} environment`, | ||
), | ||
}) | ||
|
||
const k8sCtx = <KubernetesPluginContext>ctx | ||
const variables = getKubernetesSystemVariables(k8sCtx.provider.config) | ||
|
||
const sysGarden = await getSystemGarden(k8sCtx, variables || {}) | ||
const actions = await sysGarden.getActionHelper() | ||
|
||
const result = await actions.deleteEnvironment(entry) | ||
|
||
log.info(chalk.green("Done!")) | ||
|
||
return { result } | ||
}, | ||
} |
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
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