Skip to content

Commit

Permalink
feat: initial odo catalog list enhancements
Browse files Browse the repository at this point in the history
Fixes #4485
  • Loading branch information
starpit committed May 6, 2020
1 parent f8513ef commit 8534267
Show file tree
Hide file tree
Showing 9 changed files with 163 additions and 2 deletions.
1 change: 0 additions & 1 deletion plugins/plugin-kubectl/oc/src/controller/raw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }))
}
40 changes: 40 additions & 0 deletions plugins/plugin-kubectl/odo/package.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
Original file line number Diff line number Diff line change
@@ -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<KubeOptions>) {
return doExecWithTable(args, undefined, 'odo', { verb: 'catalog', entityType: 'components' })
}
Original file line number Diff line number Diff line change
@@ -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<KubeOptions>) {
return doExecWithTable(args, undefined, 'odo', { verb: 'catalog', entityType: 'services' })
}
22 changes: 22 additions & 0 deletions plugins/plugin-kubectl/odo/src/controller/raw.ts
Original file line number Diff line number Diff line change
@@ -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 }))
}
42 changes: 42 additions & 0 deletions plugins/plugin-kubectl/odo/src/plugin.ts
Original file line number Diff line number Diff line change
@@ -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<KubeOptions>) => Promise<KResponse>) {
return (args: Arguments<KubeOptions>) => {
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)
}
9 changes: 9 additions & 0 deletions plugins/plugin-kubectl/odo/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "../../../node_modules/@kui-shell/builder/tsconfig-base.json",
"include": ["src/**/*"],
"compilerOptions": {
"composite": true,
"outDir": "mdist",
"rootDir": "src"
}
}
2 changes: 1 addition & 1 deletion plugins/plugin-kubectl/src/controller/kubectl/exec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ export async function doExecWithTable<O extends KubeOptions>(
): Promise<Table | MixedResponse> {
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,
Expand Down
3 changes: 3 additions & 0 deletions plugins/plugin-kubectl/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
{
"path": "oc"
},
{
"path": "odo"
},
{
"path": "tekton"
},
Expand Down

0 comments on commit 8534267

Please sign in to comment.