Skip to content

Commit

Permalink
feat: s3 plugin
Browse files Browse the repository at this point in the history
part of #7536
  • Loading branch information
starpit authored and k8s-ci-robot committed Jun 7, 2021
1 parent f51407b commit 177457f
Show file tree
Hide file tree
Showing 68 changed files with 4,603 additions and 43 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ env:
WINDOW_HEIGHT: 1050
RUNNING_KUI_TEST: true
KUI_USE_PROXY: true
MINIO_VERSION: minio_20210214040133.0.0
MINIO_SHA256: d5d9489262b532158a6dfd3f093de685854d83e0caf02ccef2e3d83294cb8eda

jobs:
api-browser:
Expand Down Expand Up @@ -196,3 +198,41 @@ jobs:
TRAVIS_OS_NAME: osx
TEST_FROM_BUILD: ${{ github.workspace }}/dist/electron/Kui-darwin-x64/Kui.app/Contents/MacOS/Kui
run: ./tools/travis/install.sh && (which jq || brew install jq) && npx concurrently -n COPY 'npm run test1 core-standalone' && npx concurrently -n CORE,EDIT,SUP1,SUP2 'npm run test1 core' 'npm run test2 core-support' 'npm run test3 editor' 'npm run test4 core-support2'

s3-electron:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Run Tests
env:
CLIENT: default
MOCHA_RUN_TARGET: electron
NEEDS_MINIO: true
run: ./tools/travis/install.sh && npm run test1 s3

# this is a duplicate of s3-electron with one difference: `MOCHA_RUN_TARGET: webpack`
s3-browser:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Run Tests
env:
CLIENT: default
MOCHA_RUN_TARGET: webpack
NEEDS_MINIO: true
run: ./tools/travis/install.sh && npm run test1 s3

6 changes: 6 additions & 0 deletions bin/browsey
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash
# -*- mode: shell-script

SCRIPTDIR=$(cd $(dirname "$0") && pwd)

KUI_COMMAND_PREFIX="browse" "$SCRIPTDIR"/kubectl-kui
2 changes: 1 addition & 1 deletion bin/kubectl-kui
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,4 @@ export KUI_ELECTRON_HOME="${KUI_ELECTRON_HOME-$NODE}"
# exec "$NODE" -e 'require("'$HEADLESS'/kui.min.js").kiwi.main(process.argv)' . -- kubectl $@

# for now
exec "$NODE" . -- kubectl $@
exec "$NODE" . -- ${KUI_COMMAND_PREFIX-kubectl} $@
115 changes: 107 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
"@kui-shell/plugin-kubectl-flow-views": "file:plugins/plugin-kubectl-flow-views",
"@kui-shell/plugin-patternfly4-themes": "file:plugins/plugin-patternfly4-themes",
"@kui-shell/plugin-proxy-support": "file:plugins/plugin-proxy-support",
"@kui-shell/plugin-s3": "file:plugins/plugin-s3",
"@kui-shell/plugin-wskflow": "file:plugins/plugin-wskflow",
"@kui-shell/react": "file:packages/react"
},
Expand Down
16 changes: 12 additions & 4 deletions packages/core/src/core/usage/pretty-code.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@
* limitations under the License.
*/

import colors from 'colors'
import wrap from 'word-wrap'
import colors from 'colors/safe'

import { isHeadless } from '../capabilities'
import { Title, Option, Example, Usage, Related } from './types'

export function command(cmdline: string) {
Expand All @@ -27,11 +29,13 @@ export function intro(paragraph: string) {
}

export function option(opts: string | string[]) {
return typeof opts === 'string' ? colors.bold(opts) : opts.map(_ => colors.bold(_)).join(', ')
return typeof opts === 'string'
? colors.bold(opts) + colors.reset('')
: opts.map(_ => colors.bold(_)).join(', ') + colors.reset('')
}

export function title(_: Title) {
return `${colors.bold.yellow(_.command)} ${_.doc}
return `${colors.bold(colors.yellow(_.command))} ${colors.reset(_.doc)}
`
}

Expand Down Expand Up @@ -59,9 +63,13 @@ export function usage(usages: Usage[]) {
`
}

function clickable(cmdline: string) {
return isHeadless() ? command(cmdline) : `[${cmdline}](#kuiexec?command=${encodeURIComponent(cmdline)})`
}

export function examples(examples: Example[], sectionTitle = 'Examples') {
const data = examples.map(_ => ({
command: `${indent}${command(_.command)}`,
command: indent + clickable(_.command),
doc: _.doc
}))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@
import React from 'react'
import { ansiToJson, AnserJsonEntry } from 'anser'

import Markdown from '../Markdown'

interface Props {
children: string
onRender?: () => void
}

const decos = {
Expand All @@ -39,14 +42,33 @@ function classOf(entry: AnserJsonEntry) {
return `${fg} ${bg} ${deco.join(' ')}`
}

function content(source: string) {
if (/kuiexec/.test(source)) {
// special case for embedded links; Markdown trims prefix and suffix whitespace
const match = source.match(/^(\s?)(\s*)/) // one \n is ok, because <pre> inserts a linebreak for us
return (
<React.Fragment>
{match && match[1] && <pre>{match[1]}</pre>}
<Markdown className="pre-wrap" source={source} />
</React.Fragment>
)
} else {
return source
}
}

export default function Ansi(props: Props) {
// eslint-disable-next-line @typescript-eslint/camelcase
const model = ansiToJson(props.children, { use_classes: true })

if (props.onRender) {
props.onRender()
}

return (
<pre>
{model.map(
(_, idx) => _.content && React.createElement(tagOf(_), { key: idx, className: classOf(_) }, _.content)
(_, idx) => _.content && React.createElement(tagOf(_), { key: idx, className: classOf(_) }, content(_.content))
)}
</pre>
)
Expand Down
Loading

0 comments on commit 177457f

Please sign in to comment.