-
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.
Closes #406
- Loading branch information
Showing
8 changed files
with
124 additions
and
32 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* 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 * as execa from "execa" | ||
import { RuntimeError } from "../../../exceptions" | ||
import { LogEntry } from "../../../logger/log-entry" | ||
|
||
export async function configureMicrok8sAddons(log: LogEntry, addons: string[]) { | ||
let status = "" | ||
|
||
try { | ||
status = await execa.stdout("microk8s.status") | ||
} catch { | ||
// This is caught below. | ||
} | ||
|
||
if (!status.includes("microk8s is running")) { | ||
throw new RuntimeError(`Unable to get microk8s status. Is the cluster installed and running?`, { | ||
status, | ||
}) | ||
} | ||
|
||
const missingAddons = addons.filter(addon => !status.includes(`${addon}: enabled`)) | ||
|
||
if (missingAddons.length > 0) { | ||
log.info({ section: "microk8s", msg: `enabling required addons (${missingAddons.join(", ")})` }) | ||
await execa("microk8s.enable", missingAddons) | ||
} | ||
} |
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,23 @@ | ||
/* | ||
* 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 * as execa from "execa" | ||
|
||
/** | ||
* Automatically set docker environment variables for minikube | ||
* TODO: it would be better to explicitly provide those to docker instead of using process.env | ||
*/ | ||
export async function setMinikubeDockerEnv() { | ||
const minikubeEnv = await execa.stdout("minikube", ["docker-env", "--shell=bash"]) | ||
for (const line of minikubeEnv.split("\n")) { | ||
const matched = line.match(/^export (\w+)="(.+)"$/) | ||
if (matched) { | ||
process.env[matched[1]] = matched[2] | ||
} | ||
} | ||
} |
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