Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Print the current context when chectl is run #647

Merged
merged 5 commits into from
Apr 17, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions src/api/che.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
**********************************************************************/

import { che as chetypes } from '@eclipse-che/api'
import { CoreV1Api, KubeConfig, V1Pod, Watch } from '@kubernetes/client-node'
import { CoreV1Api, V1Pod, Watch } from '@kubernetes/client-node'
import axios, { AxiosInstance } from 'axios'
import * as cp from 'child_process'
import { cli } from 'cli-ux'
Expand All @@ -26,15 +26,13 @@ import { KubeHelper } from './kube'

export class CheHelper {
defaultCheResponseTimeoutMs = 3000
kc = new KubeConfig()
kube: KubeHelper
oc = new OpenShiftHelper()

private readonly axios: AxiosInstance

constructor(flags: any) {
this.kube = new KubeHelper(flags)
this.kc.loadFromDefault()

// Make axios ignore untrusted certificate error for self-signed certificate case.
const httpsAgent = new https.Agent({ rejectUnauthorized: false })
Expand All @@ -50,7 +48,7 @@ export class CheHelper {
* or if workspace ID wasn't specified but more than one workspace is found.
*/
async getWorkspacePodName(namespace: string, cheWorkspaceId: string): Promise<string> {
const k8sApi = this.kc.makeApiClient(CoreV1Api)
const k8sApi = KubeHelper.KUBE_CONFIG.makeApiClient(CoreV1Api)

const res = await k8sApi.listNamespacedPod(namespace)
const pods = res.body.items
Expand All @@ -74,7 +72,7 @@ export class CheHelper {
}

async getWorkspacePodContainers(namespace: string, cheWorkspaceId?: string): Promise<string[]> {
const k8sApi = this.kc.makeApiClient(CoreV1Api)
const k8sApi = KubeHelper.KUBE_CONFIG.makeApiClient(CoreV1Api)

const res = await k8sApi.listNamespacedPod(namespace)
const pods = res.body.items
Expand Down Expand Up @@ -408,7 +406,7 @@ export class CheHelper {
async watchNamespacedPods(namespace: string, podLabelSelector: string | undefined, directory: string): Promise<void> {
const processedContainers = new Map<string, Set<string>>()

const watcher = new Watch(this.kc)
const watcher = new Watch(KubeHelper.KUBE_CONFIG)
watcher.watch(`/api/v1/namespaces/${namespace}/pods`, {},
async (_phase: string, obj: any) => {
const pod = obj as V1Pod
Expand Down
Loading