diff --git a/plugins/plugin-kubectl/oc/src/controller/raw.ts b/plugins/plugin-kubectl/oc/src/controller/raw.ts index b0a2b8a3a5c..c8f41d90163 100644 --- a/plugins/plugin-kubectl/oc/src/controller/raw.ts +++ b/plugins/plugin-kubectl/oc/src/controller/raw.ts @@ -19,5 +19,4 @@ import { doNativeExec, defaultFlags, commandPrefix } from '@kui-shell/plugin-kub export default async (registrar: Registrar) => { registrar.listen(`/${commandPrefix}/_oc`, doNativeExec, Object.assign({}, defaultFlags, { requiresLocal: true })) - registrar.listen(`/${commandPrefix}/_odo`, doNativeExec, Object.assign({}, defaultFlags, { requiresLocal: true })) } diff --git a/plugins/plugin-kubectl/odo/package.json b/plugins/plugin-kubectl/odo/package.json new file mode 100644 index 00000000000..5a02be698ee --- /dev/null +++ b/plugins/plugin-kubectl/odo/package.json @@ -0,0 +1,40 @@ +{ + "name": "@kui-shell/plugin-openshift", + "version": "1.0.1", + "description": "Kui OpenShift support", + "license": "Apache-2.0", + "keywords": [ + "kubernetes", + "kubectl", + "openshift", + "redhat", + "cli", + "ui", + "kui", + "plugin" + ], + "author": "@starpit", + "contributors": [ + "Mengting Yan" + ], + "homepage": "https://github.com/IBM/kui#readme", + "bugs": { + "url": "https://github.com/IBM/kui/issues/new" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/IBM/kui.git" + }, + "main": "dist/index.js", + "module": "mdist/index.js", + "types": "mdist/index.d.ts", + "dependencies": { + "@kui-shell/plugin-kubectl": "*" + }, + "krew": { + "commandPrefix": "kubeui" + }, + "publishConfig": { + "access": "public" + } +} diff --git a/plugins/plugin-kubectl/odo/src/controller/odo/catalog/list/components.ts b/plugins/plugin-kubectl/odo/src/controller/odo/catalog/list/components.ts new file mode 100644 index 00000000000..684caa7bc48 --- /dev/null +++ b/plugins/plugin-kubectl/odo/src/controller/odo/catalog/list/components.ts @@ -0,0 +1,23 @@ +/* + * Copyright 2020 IBM Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Arguments } from '@kui-shell/core' + +import { doExecWithTable, KubeOptions } from '@kui-shell/plugin-kubectl' + +export default function doList(args: Arguments) { + return doExecWithTable(args, undefined, 'odo', { verb: 'catalog', entityType: 'components' }) +} diff --git a/plugins/plugin-kubectl/odo/src/controller/odo/catalog/list/services.ts b/plugins/plugin-kubectl/odo/src/controller/odo/catalog/list/services.ts new file mode 100644 index 00000000000..d37c2a01ae1 --- /dev/null +++ b/plugins/plugin-kubectl/odo/src/controller/odo/catalog/list/services.ts @@ -0,0 +1,23 @@ +/* + * Copyright 2020 IBM Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Arguments } from '@kui-shell/core' + +import { doExecWithTable, KubeOptions } from '@kui-shell/plugin-kubectl' + +export default function doList(args: Arguments) { + return doExecWithTable(args, undefined, 'odo', { verb: 'catalog', entityType: 'services' }) +} diff --git a/plugins/plugin-kubectl/odo/src/controller/raw.ts b/plugins/plugin-kubectl/odo/src/controller/raw.ts new file mode 100644 index 00000000000..1cdcd275ee4 --- /dev/null +++ b/plugins/plugin-kubectl/odo/src/controller/raw.ts @@ -0,0 +1,22 @@ +/* + * Copyright 2020 IBM Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Registrar } from '@kui-shell/core' +import { doNativeExec, defaultFlags, commandPrefix } from '@kui-shell/plugin-kubectl' + +export default async (registrar: Registrar) => { + registrar.listen(`/${commandPrefix}/_odo`, doNativeExec, Object.assign({}, defaultFlags, { requiresLocal: true })) +} diff --git a/plugins/plugin-kubectl/odo/src/plugin.ts b/plugins/plugin-kubectl/odo/src/plugin.ts new file mode 100644 index 00000000000..a0a77b7e49e --- /dev/null +++ b/plugins/plugin-kubectl/odo/src/plugin.ts @@ -0,0 +1,42 @@ +/* + * Copyright 2019 IBM Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Arguments, KResponse, Registrar } from '@kui-shell/core' + +import { isUsage, doHelp, commandPrefix, defaultFlags, KubeOptions } from '@kui-shell/plugin-kubectl' + +import raw from './controller/raw' + +import catalogListComponents from './controller/odo/catalog/list/components' +import catalogListServices from './controller/odo/catalog/list/services' + +function withHelp(handler: (args: Arguments) => Promise) { + return (args: Arguments) => { + if (isUsage(args)) { + // special case: get --help/-h + return doHelp('odo', args) + } + + return handler(args) + } +} + +export default (registrar: Registrar) => { + raw(registrar) + + registrar.listen(`/${commandPrefix}/odo/catalog/list/components`, withHelp(catalogListComponents), defaultFlags) + registrar.listen(`/${commandPrefix}/odo/catalog/list/services`, withHelp(catalogListServices), defaultFlags) +} diff --git a/plugins/plugin-kubectl/odo/tsconfig.json b/plugins/plugin-kubectl/odo/tsconfig.json new file mode 100644 index 00000000000..ce1cc27991a --- /dev/null +++ b/plugins/plugin-kubectl/odo/tsconfig.json @@ -0,0 +1,9 @@ +{ + "extends": "../../../node_modules/@kui-shell/builder/tsconfig-base.json", + "include": ["src/**/*"], + "compilerOptions": { + "composite": true, + "outDir": "mdist", + "rootDir": "src" + } +} diff --git a/plugins/plugin-kubectl/src/controller/kubectl/exec.ts b/plugins/plugin-kubectl/src/controller/kubectl/exec.ts index c69425ab6c0..09810fc28b4 100644 --- a/plugins/plugin-kubectl/src/controller/kubectl/exec.ts +++ b/plugins/plugin-kubectl/src/controller/kubectl/exec.ts @@ -214,7 +214,7 @@ export async function doExecWithTable( ): Promise { const response = usePty ? { content: { stdout: await doExecWithStdoutViaPty(args, prepare), stderr: undefined } } - : await doExecWithoutPty(args, prepare) + : await doExecWithoutPty(args, prepare, command) const table = stringToTable( response.content.stdout, diff --git a/plugins/plugin-kubectl/tsconfig.json b/plugins/plugin-kubectl/tsconfig.json index 26612380db0..5f06e1ae682 100644 --- a/plugins/plugin-kubectl/tsconfig.json +++ b/plugins/plugin-kubectl/tsconfig.json @@ -30,6 +30,9 @@ { "path": "oc" }, + { + "path": "odo" + }, { "path": "tekton" },