Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: separate tray menu into new plugin-kubectl-tray-menu #9036

Merged
merged 1 commit into from
Sep 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 84 additions & 0 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 @@ -67,6 +67,7 @@
"@kui-shell/plugin-git": "file:plugins/plugin-git",
"@kui-shell/plugin-iter8": "file:plugins/plugin-iter8",
"@kui-shell/plugin-kubectl": "file:plugins/plugin-kubectl",
"@kui-shell/plugin-kubectl-tray-menu": "file:plugins/plugin-kubectl-tray-menu",
"@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",
Expand Down
3 changes: 3 additions & 0 deletions plugins/plugin-kubectl-tray-menu/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dist
mdist
build
10 changes: 10 additions & 0 deletions plugins/plugin-kubectl-tray-menu/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
build
src
tests/data/*
tests/data/k8s/*
!tests/data/k8s/headless/*
dist/test/*
dist/test/k8s2/*
!dist/test/k8s2/headless-create-pod.js
tsconfig*
/*.tgz
51 changes: 51 additions & 0 deletions plugins/plugin-kubectl-tray-menu/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
"name": "@kui-shell/plugin-kubectl",
"version": "11.4.0",
"description": "Kubernetes visualization plugin for kubernetes",
"license": "Apache-2.0",
"keywords": [
"kubernetes",
"kubectl",
"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",
"typedocMain": "src/index.ts",
"module": "mdist/index.js",
"types": "mdist/index.d.ts",
"dependencies": {
"@kui-shell/jsonpath": "1.1.1",
"bytes-iec": "3.1.1",
"command-exists": "1.2.9",
"debug": "4.3.4",
"fs-extra": "10.1.0",
"js-yaml": "4.1.0",
"needle": "3.1.0",
"parse-duration": "1.0.2",
"pluralize": "8.0.0",
"semver": "7.3.7",
"tmp": "0.2.1",
"uuid": "9.0.0"
},
"krew": {
"commandPrefix": "kubeui"
},
"publishConfig": {
"access": "public"
},
"gitHead": "89de9f78e8a1a2bdd29d2e17d7c608ab006c6d32"
}
27 changes: 27 additions & 0 deletions plugins/plugin-kubectl-tray-menu/src/preload.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Copyright 2018 The Kubernetes Authors
*
* 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 { Capabilities } from '@kui-shell/core'

/**
* This is the module
*
*/
export default async function preloadKubectlTrayMenu() {
if (Capabilities.inElectron()) {
import('./tray/init').then(_ => _.default())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,11 @@ export default async function initTray() {
.catch(err => {
console.error('Error initializing tray menu', err)
})

// rebroadcast renderer-side config change events to the main process
const { onKubectlConfigChangeEvents } = await import('@kui-shell/plugin-kubectl')
onKubectlConfigChangeEvents(async () => {
import('./events').then(_ => _.emitRefreshFromRenderer())
})
}
}
10 changes: 10 additions & 0 deletions plugins/plugin-kubectl-tray-menu/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "../../node_modules/@kui-shell/builder/tsconfig-base.json",
"include": ["src/**/*"],
"compilerOptions": {
"composite": true,
"outDir": "mdist",
"rootDir": "src",
"baseUrl": "."
}
}
6 changes: 1 addition & 5 deletions plugins/plugin-kubectl/src/controller/kubectl/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import { Arguments, Capabilities, Events, Registrar } from '@kui-shell/core'
import { Arguments, Events, Registrar } from '@kui-shell/core'

import flags from './flags'
import { doExecWithPty } from './exec'
Expand All @@ -41,10 +41,6 @@ const mutators = [
export function emitKubectlConfigChangeEvent(type: ConfigChangeEventType, namespace?: string, context?: string) {
try {
Events.eventChannelUnsafe.emit(kubectlConfigChangeChannel, type, namespace, context)

if (Capabilities.inElectron()) {
import('../../tray/events').then(_ => _.emitRefreshFromRenderer())
}
} catch (err) {
console.error('Error in onKubectlConfigChangeEvent handler', err)
}
Expand Down
2 changes: 0 additions & 2 deletions plugins/plugin-kubectl/src/non-headless-preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import Debug from 'debug'
import { PreloadRegistrar } from '@kui-shell/core'

import initTray from './tray/init'
import registerPluginTabState from './tab-state'
import podMode from './lib/view/modes/pods'
import yamlMode from './lib/view/modes/yaml'
Expand All @@ -44,7 +43,6 @@ import tabCompletionProvider from './lib/tab-completion'
import { notebookVFS } from '@kui-shell/plugin-core-support'

export default async (registrar: PreloadRegistrar) => {
initTray()
registerPluginTabState()

// register modes
Expand Down
3 changes: 3 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
{
"path": "plugins/plugin-kubectl"
},
{
"path": "plugins/plugin-kubectl-tray-menu"
},
{
"path": "plugins/plugin-proxy-support"
},
Expand Down