mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Features to resource deployment to add arc control create in ARC extension (#10088)
* save not yet tested work * Merge from master. * Screeens Shared for Feeedback * Code complete * remove unneeded changes * remove unnecessary comma * remov wss * remove dead code * PR feedback * checkpoint fixes * PR & minor fixes * minor fix for feature of resourceType options being optional. * reverting experimental change * separating out changes for future featurework. * revert unneeded change * review feedback fixes * review feedback * rename InputFieldComponent to InputComponent
This commit is contained in:
@@ -14,39 +14,49 @@ export interface KubeClusterContext {
|
||||
}
|
||||
|
||||
export interface IKubeService {
|
||||
getDefautConfigPath(): string;
|
||||
getDefaultConfigPath(): string;
|
||||
getClusterContexts(configFile: string): Promise<KubeClusterContext[]>;
|
||||
}
|
||||
|
||||
export class KubeService implements IKubeService {
|
||||
getDefautConfigPath(): string {
|
||||
return path.join(os.homedir(), '.kube', 'config');
|
||||
getDefaultConfigPath(): string {
|
||||
return getDefaultKubeConfigPath();
|
||||
}
|
||||
|
||||
getClusterContexts(configFile: string): Promise<KubeClusterContext[]> {
|
||||
return fs.promises.access(configFile).catch((error) => {
|
||||
if (error && error.code === 'ENOENT') {
|
||||
return [];
|
||||
} else {
|
||||
throw error;
|
||||
}
|
||||
}).then(() => {
|
||||
const config = yamljs.load(configFile);
|
||||
const rawContexts = <any[]>config['contexts'];
|
||||
const currentContext = <string>config['current-context'];
|
||||
const contexts: KubeClusterContext[] = [];
|
||||
if (currentContext && rawContexts && rawContexts.length > 0) {
|
||||
rawContexts.forEach(rawContext => {
|
||||
const name = <string>rawContext['name'];
|
||||
if (name) {
|
||||
contexts.push({
|
||||
name: name,
|
||||
isCurrentContext: name === currentContext
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
return contexts;
|
||||
});
|
||||
return getKubeConfigClusterContexts(configFile);
|
||||
}
|
||||
}
|
||||
|
||||
export function getKubeConfigClusterContexts(configFile: string): Promise<KubeClusterContext[]> {
|
||||
return fs.promises.access(configFile).catch((error) => {
|
||||
if (error && error.code === 'ENOENT') {
|
||||
return [];
|
||||
}
|
||||
else {
|
||||
throw error;
|
||||
}
|
||||
}).then(() => {
|
||||
const config = yamljs.load(configFile);
|
||||
const rawContexts = <any[]>config['contexts'];
|
||||
const currentContext = <string>config['current-context'];
|
||||
const contexts: KubeClusterContext[] = [];
|
||||
if (currentContext && rawContexts && rawContexts.length > 0) {
|
||||
rawContexts.forEach(rawContext => {
|
||||
const name = <string>rawContext['name'];
|
||||
if (name) {
|
||||
contexts.push({
|
||||
name: name,
|
||||
isCurrentContext: name === currentContext
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
return contexts;
|
||||
});
|
||||
}
|
||||
|
||||
export function getDefaultKubeConfigPath(): string {
|
||||
return path.join(os.homedir(), '.kube', 'config');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user