Skip to content

Commit

Permalink
Merge pull request #618 from garden-io/update-helm
Browse files Browse the repository at this point in the history
improvement(k8s): update helm to v2.13.0
  • Loading branch information
thsig authored Mar 12, 2019
2 parents 8e8d25a + 9d61d71 commit 5021f93
Show file tree
Hide file tree
Showing 9 changed files with 1,503 additions and 1,565 deletions.
21 changes: 20 additions & 1 deletion commitlint.config.js
Original file line number Diff line number Diff line change
@@ -1 +1,20 @@
module.exports = {extends: ['@commitlint/config-conventional']};
module.exports = {
extends: ['@commitlint/config-conventional'],
rules: {
// Extend to add improvement key
"type-enum": [2, "always", [
"build",
"chore",
"ci",
"docs",
"feat",
"fix",
"improvement",
"perf",
"refactor",
"revert",
"style",
"test",
]]
}
};
12 changes: 6 additions & 6 deletions garden-service/src/plugins/kubernetes/helm/helm-cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,24 @@ const helmCmd = new BinaryCmd({
name: "helm",
specs: {
darwin: {
url: "https://storage.googleapis.com/kubernetes-helm/helm-v2.11.0-darwin-amd64.tar.gz",
sha256: "551b13a398749ae3e0a5c54d3078f6e3bee552c5d6a0bf6f338cab64ce38ab0f",
url: "https://storage.googleapis.com/kubernetes-helm/helm-v2.13.0-darwin-amd64.tar.gz",
sha256: "166318b2159613f87a7cb02af1614c96244b3d3c119f8e010429c1b4449681d5",
extract: {
format: "tar",
executablePath: ["darwin-amd64", "helm"],
},
},
linux: {
url: "https://storage.googleapis.com/kubernetes-helm/helm-v2.11.0-linux-amd64.tar.gz",
sha256: "02a4751586d6a80f6848b58e7f6bd6c973ffffadc52b4c06652db7def02773a1",
url: "https://storage.googleapis.com/kubernetes-helm/helm-v2.13.0-linux-amd64.tar.gz",
sha256: "15eca6ad225a8279de80c7ced42305e24bc5ac60bb7d96f2d2fa4af86e02c794",
extract: {
format: "tar",
executablePath: ["linux-amd64", "helm"],
},
},
win32: {
url: "https://storage.googleapis.com/kubernetes-helm/helm-v2.11.0-windows-amd64.zip",
sha256: "04dd84691f18170a82b02656cd1ec9f32c5a66893abe5498b4ea63c941eae12a",
url: "https://storage.googleapis.com/kubernetes-helm/helm-v2.13.0-windows-amd64.zip",
sha256: "63fdb71ad6fac0572a21ad81da7508b1f0cae960ea944670f4d2f7fbaf23acb2",
extract: {
format: "zip",
executablePath: ["windows-amd64", "helm.exe"],
Expand Down
2 changes: 1 addition & 1 deletion garden-service/src/plugins/kubernetes/hot-reload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ async function getLocalRsyncPort(ctx: PluginContext, log: LogEntry, targetDeploy
throw error
})

proc.stdout.on("data", (line) => {
proc.stdout!.on("data", (line) => {
// This is unfortunately the best indication that we have that the connection is up...
log.silly(`[${targetDeployment} port forwarder] ${line}`)

Expand Down
4 changes: 2 additions & 2 deletions garden-service/src/plugins/kubernetes/logs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ async function followLogs({ context, namespace, service, selector, stream, log,
const proc = await stern.spawn({ args, log })
let timestamp: Date | undefined

proc.stdout
proc.stdout!
.pipe(JSONStream.parse(["message"], (message) => {
const [timestampStr, msg] = splitFirst(message, " ")
try {
Expand All @@ -75,7 +75,7 @@ async function getLogs({ context, namespace, service, selector, stream, tail }:
const proc = kubectl(context, namespace).spawn(kubectlArgs)
let timestamp: Date

proc.stdout
proc.stdout!
.pipe(split())
.on("data", (s) => {
if (!s) {
Expand Down
59 changes: 31 additions & 28 deletions garden-service/src/util/ext-tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { Extract } from "unzipper"
import { createHash } from "crypto"
import * as uuid from "uuid"
import * as spawn from "cross-spawn"
const AsyncLock = require("async-lock")

const globalGardenPath = join(homedir(), ".garden")
const toolsPath = join(globalGardenPath, "tools")
Expand Down Expand Up @@ -68,6 +69,7 @@ export class BinaryCmd extends Cmd {
name: string
spec: BinarySpec

private lock: any
private toolPath: string
private versionDirname: string
private versionPath: string
Expand All @@ -88,6 +90,8 @@ export class BinaryCmd extends Cmd {
)
}

this.lock = new AsyncLock()

this.name = spec.name
this.spec = platformSpec
this.toolPath = join(toolsPath, this.name)
Expand All @@ -102,43 +106,42 @@ export class BinaryCmd extends Cmd {
}

private async download(log: LogEntry) {
// TODO: use lockfile to avoid multiple downloads of the same thing
// (we avoid a race condition by downloading to a temporary path, so it's more about efficiency)

if (await pathExists(this.executablePath)) {
return
}
return this.lock.acquire("download", async () => {
if (await pathExists(this.executablePath)) {
return
}

const tmpPath = join(this.toolPath, this.versionDirname + "." + uuid.v4().substr(0, 8))
const tmpExecutable = join(tmpPath, ...this.executableSubpath)
const tmpPath = join(this.toolPath, this.versionDirname + "." + uuid.v4().substr(0, 8))
const tmpExecutable = join(tmpPath, ...this.executableSubpath)

const logEntry = log.verbose(`Fetching ${this.name}...`)
const debug = logEntry.debug(`Downloading ${this.spec.url}...`)
const logEntry = log.verbose(`Fetching ${this.name}...`)
const debug = logEntry.debug(`Downloading ${this.spec.url}...`)

await ensureDir(tmpPath)
await ensureDir(tmpPath)

try {
await this.fetch(tmpPath, log)
try {
await this.fetch(tmpPath, log)

if (!(await pathExists(tmpExecutable))) {
throw new ConfigurationError(
`Archive ${this.spec.url} does not contain a file at ${join(...this.spec.extract!.executablePath)}`,
{ name: this.name, spec: this.spec },
)
}
if (!(await pathExists(tmpExecutable))) {
throw new ConfigurationError(
`Archive ${this.spec.url} does not contain a file at ${join(...this.spec.extract!.executablePath)}`,
{ name: this.name, spec: this.spec },
)
}

await chmod(tmpExecutable, 0o755)
await move(tmpPath, this.versionPath, { overwrite: true })
await chmod(tmpExecutable, 0o755)
await move(tmpPath, this.versionPath, { overwrite: true })

} finally {
// make sure tmp path is cleared after errors
if (await pathExists(tmpPath)) {
await remove(tmpPath)
} finally {
// make sure tmp path is cleared after errors
if (await pathExists(tmpPath)) {
await remove(tmpPath)
}
}
}

debug && debug.setSuccess("Done")
logEntry.setSuccess(`Fetched ${this.name}`)
debug && debug.setSuccess("Done")
logEntry.setSuccess(`Fetched ${this.name}`)
})
}

async exec({ cwd, args, log, timeout }: ExecParams) {
Expand Down
6 changes: 3 additions & 3 deletions garden-service/src/util/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,17 +211,17 @@ export function spawn(cmd: string, args: string[], opts: SpawnOpts = {}) {

} else {
// We ensure the output strings never exceed the MAX_BUFFER_SIZE
proc.stdout.on("data", (s) => {
proc.stdout!.on("data", (s) => {
result.output = naivelyTruncateBytes(result.output + s)
result.stdout! = naivelyTruncateBytes(result.stdout! + s)
})

proc.stderr.on("data", (s) => {
proc.stderr!.on("data", (s) => {
result.stderr! = naivelyTruncateBytes(result.stderr! + s)
})

if (data) {
proc.stdin.end(data)
proc.stdin!.end(data)
}
}

Expand Down
Loading

0 comments on commit 5021f93

Please sign in to comment.