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:
Arvind Ranasaria
2020-04-29 12:11:48 -07:00
committed by GitHub
parent a9bfdf0fc9
commit 353115668c
21 changed files with 729 additions and 175 deletions

View File

@@ -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');
}