Skip to content

Commit

Permalink
fix(core): properly handle joining K8s api server url and path
Browse files Browse the repository at this point in the history
  • Loading branch information
eysi09 committed Jul 18, 2019
1 parent 9ecf8eb commit 8a56d19
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 25 deletions.
75 changes: 52 additions & 23 deletions garden-service/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions garden-service/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
"p-retry": "^4.1.0",
"path-is-inside": "^1.0.2",
"pluralize": "^8.0.0",
"proper-url-join": "^2.0.1",
"request": "^2.88.0",
"request-promise": "^4.2.4",
"source-map-support": "^0.5.12",
Expand Down
4 changes: 2 additions & 2 deletions garden-service/src/plugins/kubernetes/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
// No idea why tslint complains over this line
// tslint:disable-next-line:no-unused
import { IncomingMessage } from "http"
import { resolve } from "url"
import {
KubeConfig,
V1Secret,
Expand Down Expand Up @@ -37,6 +36,7 @@ import { GardenBaseError, RuntimeError, ConfigurationError } from "../../excepti
import { KubernetesResource, KubernetesServerResource, KubernetesServerList } from "./types"
import { LogEntry } from "../../logger/log-entry"
import { kubectl } from "./kubectl"
import { urlJoin } from "../../util/string"

interface ApiGroupMap {
[groupVersion: string]: V1APIGroup
Expand Down Expand Up @@ -261,7 +261,7 @@ export class KubeApi {

async request(log: LogEntry, path: string, opts: Omit<request.OptionsWithUrl, "url"> = {}): Promise<any> {
const baseUrl = this.config.getCurrentCluster()!.server
const url = resolve(baseUrl, path)
const url = urlJoin(baseUrl, path)

// set some default values
const requestOpts = {
Expand Down
2 changes: 2 additions & 0 deletions garden-service/src/util/string.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@

import _dedent = require("dedent")
import _deline = require("deline")
import _urlJoin = require("proper-url-join")

// Exporting these here for convenience and ease of imports (otherwise we need to require modules instead of using
// the import syntax, and it for some reason doesn't play nice with IDEs).
export const dedent = _dedent
export const deline = _deline
export const urlJoin = _urlJoin as (...args: string[]) => string

const gardenAnnotationPrefix = "garden.io/"

Expand Down

0 comments on commit 8a56d19

Please sign in to comment.