-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Prince Rachit Sinha
committed
Jul 6, 2021
1 parent
63c2e50
commit 41ac7d8
Showing
2 changed files
with
14 additions
and
4 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 |
---|---|---|
@@ -1,23 +1,32 @@ | ||
import { werft } from './util/shell'; | ||
import { wipePreviewEnvironment, listAllPreviewNamespaces } from './util/kubectl'; | ||
import fs from 'fs'; | ||
|
||
|
||
async function wipeDevstaging() { | ||
async function wipeDevstaging(pathToKubeConfig: string) { | ||
const namespace_raw = process.env.NAMESPACE; | ||
const namespaces: string[] = []; | ||
if (namespace_raw === "<no value>" || !namespace_raw) { | ||
werft.log('wipe', "Going to wipe all namespaces"); | ||
listAllPreviewNamespaces("") | ||
listAllPreviewNamespaces(pathToKubeConfig) | ||
.map(ns => namespaces.push(ns)); | ||
} else { | ||
werft.log('wipe', `Going to wipe namespace ${namespace_raw}`); | ||
namespaces.push(namespace_raw); | ||
} | ||
|
||
for (const namespace of namespaces) { | ||
await wipePreviewEnvironment("", "gitpod", namespace, { slice: 'wipe' }); | ||
await wipePreviewEnvironment(pathToKubeConfig, "gitpod", namespace, { slice: 'wipe' }); | ||
} | ||
werft.done('wipe'); | ||
} | ||
|
||
wipeDevstaging() | ||
wipeDevstaging("") | ||
// if we have "/workspace/k3s-external.yaml" present that means a k3s ws cluster | ||
// exists, therefore, delete corresponding preview deployment from that cluster too | ||
// NOTE: Even for a non k3s ws deployment we will attempt to clean the preview. | ||
// This saves us from writing complex logic of querying meta cluster for registered workspaces | ||
// Since we use the same namespace to deploy in both dev and k3s cluster, this is safe | ||
if (fs.existsSync("/workspace/k3s-external.yaml")) { | ||
wipeDevstaging("/workspace/k3s-external.yaml") | ||
} |
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