Skip to content
This repository was archived by the owner on Jul 30, 2025. It is now read-only.

Commit 177457f

Browse files
starpitk8s-ci-robot
authored andcommitted
feat: s3 plugin
part of #7536
1 parent f51407b commit 177457f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+4603
-43
lines changed

.github/workflows/test.yaml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ env:
2121
WINDOW_HEIGHT: 1050
2222
RUNNING_KUI_TEST: true
2323
KUI_USE_PROXY: true
24+
MINIO_VERSION: minio_20210214040133.0.0
25+
MINIO_SHA256: d5d9489262b532158a6dfd3f093de685854d83e0caf02ccef2e3d83294cb8eda
2426

2527
jobs:
2628
api-browser:
@@ -196,3 +198,41 @@ jobs:
196198
TRAVIS_OS_NAME: osx
197199
TEST_FROM_BUILD: ${{ github.workspace }}/dist/electron/Kui-darwin-x64/Kui.app/Contents/MacOS/Kui
198200
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'
201+
202+
s3-electron:
203+
runs-on: ubuntu-latest
204+
strategy:
205+
matrix:
206+
node-version: [12.x]
207+
steps:
208+
- uses: actions/checkout@v2
209+
- name: Use Node.js ${{ matrix.node-version }}
210+
uses: actions/setup-node@v1
211+
with:
212+
node-version: ${{ matrix.node-version }}
213+
- name: Run Tests
214+
env:
215+
CLIENT: default
216+
MOCHA_RUN_TARGET: electron
217+
NEEDS_MINIO: true
218+
run: ./tools/travis/install.sh && npm run test1 s3
219+
220+
# this is a duplicate of s3-electron with one difference: `MOCHA_RUN_TARGET: webpack`
221+
s3-browser:
222+
runs-on: ubuntu-latest
223+
strategy:
224+
matrix:
225+
node-version: [12.x]
226+
steps:
227+
- uses: actions/checkout@v2
228+
- name: Use Node.js ${{ matrix.node-version }}
229+
uses: actions/setup-node@v1
230+
with:
231+
node-version: ${{ matrix.node-version }}
232+
- name: Run Tests
233+
env:
234+
CLIENT: default
235+
MOCHA_RUN_TARGET: webpack
236+
NEEDS_MINIO: true
237+
run: ./tools/travis/install.sh && npm run test1 s3
238+

bin/browsey

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env bash
2+
# -*- mode: shell-script
3+
4+
SCRIPTDIR=$(cd $(dirname "$0") && pwd)
5+
6+
KUI_COMMAND_PREFIX="browse" "$SCRIPTDIR"/kubectl-kui

bin/kubectl-kui

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,4 +87,4 @@ export KUI_ELECTRON_HOME="${KUI_ELECTRON_HOME-$NODE}"
8787
# exec "$NODE" -e 'require("'$HEADLESS'/kui.min.js").kiwi.main(process.argv)' . -- kubectl $@
8888

8989
# for now
90-
exec "$NODE" . -- kubectl $@
90+
exec "$NODE" . -- ${KUI_COMMAND_PREFIX-kubectl} $@

package-lock.json

Lines changed: 107 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
"@kui-shell/plugin-kubectl-flow-views": "file:plugins/plugin-kubectl-flow-views",
7070
"@kui-shell/plugin-patternfly4-themes": "file:plugins/plugin-patternfly4-themes",
7171
"@kui-shell/plugin-proxy-support": "file:plugins/plugin-proxy-support",
72+
"@kui-shell/plugin-s3": "file:plugins/plugin-s3",
7273
"@kui-shell/plugin-wskflow": "file:plugins/plugin-wskflow",
7374
"@kui-shell/react": "file:packages/react"
7475
},

packages/core/src/core/usage/pretty-code.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@
1414
* limitations under the License.
1515
*/
1616

17-
import colors from 'colors'
1817
import wrap from 'word-wrap'
18+
import colors from 'colors/safe'
19+
20+
import { isHeadless } from '../capabilities'
1921
import { Title, Option, Example, Usage, Related } from './types'
2022

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

2931
export function option(opts: string | string[]) {
30-
return typeof opts === 'string' ? colors.bold(opts) : opts.map(_ => colors.bold(_)).join(', ')
32+
return typeof opts === 'string'
33+
? colors.bold(opts) + colors.reset('')
34+
: opts.map(_ => colors.bold(_)).join(', ') + colors.reset('')
3135
}
3236

3337
export function title(_: Title) {
34-
return `${colors.bold.yellow(_.command)} ${_.doc}
38+
return `${colors.bold(colors.yellow(_.command))} ${colors.reset(_.doc)}
3539
`
3640
}
3741

@@ -59,9 +63,13 @@ export function usage(usages: Usage[]) {
5963
`
6064
}
6165

66+
function clickable(cmdline: string) {
67+
return isHeadless() ? command(cmdline) : `[${cmdline}](#kuiexec?command=${encodeURIComponent(cmdline)})`
68+
}
69+
6270
export function examples(examples: Example[], sectionTitle = 'Examples') {
6371
const data = examples.map(_ => ({
64-
command: `${indent}${command(_.command)}`,
72+
command: indent + clickable(_.command),
6573
doc: _.doc
6674
}))
6775

plugins/plugin-client-common/src/components/Content/Scalar/Ansi.tsx

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,11 @@
1717
import React from 'react'
1818
import { ansiToJson, AnserJsonEntry } from 'anser'
1919

20+
import Markdown from '../Markdown'
21+
2022
interface Props {
2123
children: string
24+
onRender?: () => void
2225
}
2326

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

45+
function content(source: string) {
46+
if (/kuiexec/.test(source)) {
47+
// special case for embedded links; Markdown trims prefix and suffix whitespace
48+
const match = source.match(/^(\s?)(\s*)/) // one \n is ok, because <pre> inserts a linebreak for us
49+
return (
50+
<React.Fragment>
51+
{match && match[1] && <pre>{match[1]}</pre>}
52+
<Markdown className="pre-wrap" source={source} />
53+
</React.Fragment>
54+
)
55+
} else {
56+
return source
57+
}
58+
}
59+
4260
export default function Ansi(props: Props) {
4361
// eslint-disable-next-line @typescript-eslint/camelcase
4462
const model = ansiToJson(props.children, { use_classes: true })
4563

64+
if (props.onRender) {
65+
props.onRender()
66+
}
67+
4668
return (
4769
<pre>
4870
{model.map(
49-
(_, idx) => _.content && React.createElement(tagOf(_), { key: idx, className: classOf(_) }, _.content)
71+
(_, idx) => _.content && React.createElement(tagOf(_), { key: idx, className: classOf(_) }, content(_.content))
5072
)}
5173
</pre>
5274
)

0 commit comments

Comments
 (0)