mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Merge branch 'master' into fix/ignore-clusters-with-corrupted-kubeconfig
This commit is contained in:
commit
607ebb599b
@ -58,6 +58,7 @@ jobs:
|
|||||||
- script: make test-extensions
|
- script: make test-extensions
|
||||||
displayName: Run In-tree Extension tests
|
displayName: Run In-tree Extension tests
|
||||||
- bash: |
|
- bash: |
|
||||||
|
set -e
|
||||||
rm -rf extensions/telemetry
|
rm -rf extensions/telemetry
|
||||||
make integration-win
|
make integration-win
|
||||||
git checkout extensions/telemetry
|
git checkout extensions/telemetry
|
||||||
@ -102,6 +103,7 @@ jobs:
|
|||||||
- script: make test-extensions
|
- script: make test-extensions
|
||||||
displayName: Run In-tree Extension tests
|
displayName: Run In-tree Extension tests
|
||||||
- bash: |
|
- bash: |
|
||||||
|
set -e
|
||||||
rm -rf extensions/telemetry
|
rm -rf extensions/telemetry
|
||||||
make integration-mac
|
make integration-mac
|
||||||
git checkout extensions/telemetry
|
git checkout extensions/telemetry
|
||||||
@ -159,6 +161,7 @@ jobs:
|
|||||||
sudo chown -R $USER $HOME/.kube $HOME/.minikube
|
sudo chown -R $USER $HOME/.kube $HOME/.minikube
|
||||||
displayName: Install integration test dependencies
|
displayName: Install integration test dependencies
|
||||||
- bash: |
|
- bash: |
|
||||||
|
set -e
|
||||||
rm -rf extensions/telemetry
|
rm -rf extensions/telemetry
|
||||||
xvfb-run --auto-servernum --server-args='-screen 0, 1600x900x24' make integration-linux
|
xvfb-run --auto-servernum --server-args='-screen 0, 1600x900x24' make integration-linux
|
||||||
git checkout extensions/telemetry
|
git checkout extensions/telemetry
|
||||||
|
|||||||
17
.dependabot/config.yml
Normal file
17
.dependabot/config.yml
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
# See https://docs.github.com/en/free-pro-team@latest/github/administering-a-repository/configuration-options-for-dependency-updates
|
||||||
|
# for config options
|
||||||
|
|
||||||
|
version: 2
|
||||||
|
updates:
|
||||||
|
- package-ecosystem: "npm"
|
||||||
|
directory: "/"
|
||||||
|
schedule:
|
||||||
|
interval: "daily"
|
||||||
|
open-pull-requests-limit: 4
|
||||||
|
reviewers:
|
||||||
|
- "lensapp/lens-maintainers"
|
||||||
|
labels:
|
||||||
|
- "dependencies"
|
||||||
|
versioning-strategy:
|
||||||
|
lockfile-only: false
|
||||||
|
increase: true
|
||||||
@ -46,6 +46,8 @@ module.exports = {
|
|||||||
"avoidEscape": true,
|
"avoidEscape": true,
|
||||||
"allowTemplateLiterals": true,
|
"allowTemplateLiterals": true,
|
||||||
}],
|
}],
|
||||||
|
"linebreak-style": ["error", "unix"],
|
||||||
|
"eol-last": ["error", "always"],
|
||||||
"semi": ["error", "always"],
|
"semi": ["error", "always"],
|
||||||
"object-shorthand": "error",
|
"object-shorthand": "error",
|
||||||
"prefer-template": "error",
|
"prefer-template": "error",
|
||||||
@ -101,6 +103,8 @@ module.exports = {
|
|||||||
}],
|
}],
|
||||||
"semi": "off",
|
"semi": "off",
|
||||||
"@typescript-eslint/semi": ["error"],
|
"@typescript-eslint/semi": ["error"],
|
||||||
|
"linebreak-style": ["error", "unix"],
|
||||||
|
"eol-last": ["error", "always"],
|
||||||
"object-shorthand": "error",
|
"object-shorthand": "error",
|
||||||
"prefer-template": "error",
|
"prefer-template": "error",
|
||||||
"template-curly-spacing": "error",
|
"template-curly-spacing": "error",
|
||||||
@ -162,6 +166,8 @@ module.exports = {
|
|||||||
}],
|
}],
|
||||||
"semi": "off",
|
"semi": "off",
|
||||||
"@typescript-eslint/semi": ["error"],
|
"@typescript-eslint/semi": ["error"],
|
||||||
|
"linebreak-style": ["error", "unix"],
|
||||||
|
"eol-last": ["error", "always"],
|
||||||
"object-shorthand": "error",
|
"object-shorthand": "error",
|
||||||
"prefer-template": "error",
|
"prefer-template": "error",
|
||||||
"template-curly-spacing": "error",
|
"template-curly-spacing": "error",
|
||||||
|
|||||||
30
.github/release-drafter.yml
vendored
Normal file
30
.github/release-drafter.yml
vendored
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
exclude-labels:
|
||||||
|
- 'skip-changelog'
|
||||||
|
categories:
|
||||||
|
- title: '🚀 Features'
|
||||||
|
labels:
|
||||||
|
- 'enhancement'
|
||||||
|
- title: '🐛 Bug Fixes'
|
||||||
|
labels:
|
||||||
|
- 'bug'
|
||||||
|
- title: '🧰 Maintenance'
|
||||||
|
labels:
|
||||||
|
- 'chore'
|
||||||
|
- 'area/ci'
|
||||||
|
- 'area/tests'
|
||||||
|
- 'dependencies'
|
||||||
|
|
||||||
|
template: |
|
||||||
|
## Changes since $PREVIOUS_TAG
|
||||||
|
|
||||||
|
$CHANGES
|
||||||
|
|
||||||
|
### Download
|
||||||
|
|
||||||
|
- Lens v$RESOLVED_VERSION - Linux
|
||||||
|
- [AppImage](https://github.com/lensapp/lens/releases/download/v$RESOLVED_VERSION/Lens-$RESOLVED_VERSION.x86_64.AppImage)
|
||||||
|
- [DEB](https://github.com/lensapp/lens/releases/download/v$RESOLVED_VERSION/Lens-$RESOLVED_VERSION.amd64.deb)
|
||||||
|
- [RPM](https://github.com/lensapp/lens/releases/download/v$RESOLVED_VERSION/Lens-$RESOLVED_VERSION.x86_64.rpm)
|
||||||
|
- [Snapcraft](https://snapcraft.io/kontena-lens)
|
||||||
|
- [Lens v$RESOLVED_VERSION - MacOS](https://github.com/lensapp/lens/releases/download/v$RESOLVED_VERSION/Lens-$RESOLVED_VERSION.dmg)
|
||||||
|
- [Lens v$RESOLVED_VERSION - Windows](https://github.com/lensapp/lens/releases/download/v$RESOLVED_VERSION/Lens-Setup-$RESOLVED_VERSION.exe)
|
||||||
4
.github/workflows/main.yml
vendored
4
.github/workflows/main.yml
vendored
@ -83,12 +83,12 @@ jobs:
|
|||||||
mike deploy --push master
|
mike deploy --push master
|
||||||
|
|
||||||
- name: Get the release version
|
- name: Get the release version
|
||||||
if: contains(github.ref, 'refs/tags/v') # && !github.event.release.prerelease (generate pre-release docs until Lens 4.0.0 is GA, see #1408)
|
if: contains(github.ref, 'refs/tags/v') && !github.event.release.prerelease
|
||||||
id: get_version
|
id: get_version
|
||||||
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
|
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
|
||||||
|
|
||||||
- name: mkdocs deploy new release
|
- name: mkdocs deploy new release
|
||||||
if: contains(github.ref, 'refs/tags/v') # && !github.event.release.prerelease (generate pre-release docs until Lens 4.0.0 is GA, see #1408)
|
if: contains(github.ref, 'refs/tags/v') && !github.event.release.prerelease
|
||||||
run: |
|
run: |
|
||||||
mike deploy --push --update-aliases ${{ steps.get_version.outputs.VERSION }} latest
|
mike deploy --push --update-aliases ${{ steps.get_version.outputs.VERSION }} latest
|
||||||
mike set-default --push ${{ steps.get_version.outputs.VERSION }}
|
mike set-default --push ${{ steps.get_version.outputs.VERSION }}
|
||||||
|
|||||||
16
.github/workflows/release-drafter.yml
vendored
Normal file
16
.github/workflows/release-drafter.yml
vendored
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
name: Release Drafter
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
# branches to consider in the event; optional, defaults to all
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
update_release_draft:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
# Drafts your next Release notes as Pull Requests are merged into "master"
|
||||||
|
- uses: release-drafter/release-drafter@v5
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
|
||||||
2
Makefile
2
Makefile
@ -12,7 +12,7 @@ endif
|
|||||||
binaries/client:
|
binaries/client:
|
||||||
yarn download-bins
|
yarn download-bins
|
||||||
|
|
||||||
node_modules:
|
node_modules: yarn.lock
|
||||||
yarn install --frozen-lockfile
|
yarn install --frozen-lockfile
|
||||||
yarn check --verify-tree --integrity
|
yarn check --verify-tree --integrity
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 23 KiB |
BIN
build/icons/512x512@2x.png
Normal file
BIN
build/icons/512x512@2x.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 51 KiB |
@ -43,6 +43,7 @@ You can use theme-based CSS Variables to style an extension according to the act
|
|||||||
## Button Colors
|
## Button Colors
|
||||||
- `--buttonPrimaryBackground`: button background color for primary actions.
|
- `--buttonPrimaryBackground`: button background color for primary actions.
|
||||||
- `--buttonDefaultBackground`: default button background color.
|
- `--buttonDefaultBackground`: default button background color.
|
||||||
|
- `--buttonLightBackground`: light button background color.
|
||||||
- `--buttonAccentBackground`: accent button background color.
|
- `--buttonAccentBackground`: accent button background color.
|
||||||
- `--buttonDisabledBackground`: disabled button background color.
|
- `--buttonDisabledBackground`: disabled button background color.
|
||||||
|
|
||||||
|
|||||||
@ -40,7 +40,7 @@ This extension can register custom app menus that will be displayed on OS native
|
|||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
``` typescript
|
```typescript
|
||||||
import { LensMainExtension, windowManager } from "@k8slens/extensions"
|
import { LensMainExtension, windowManager } from "@k8slens/extensions"
|
||||||
|
|
||||||
export default class ExampleMainExtension extends LensMainExtension {
|
export default class ExampleMainExtension extends LensMainExtension {
|
||||||
@ -92,7 +92,7 @@ export default class ExampleMainExtension extends LensRendererExtension {
|
|||||||
|
|
||||||
This extension can register custom global pages (views) to Lens's main window. The global page is a full-screen page that hides all other content from a window.
|
This extension can register custom global pages (views) to Lens's main window. The global page is a full-screen page that hides all other content from a window.
|
||||||
|
|
||||||
``` typescript
|
```typescript
|
||||||
import React from "react"
|
import React from "react"
|
||||||
import { Component, LensRendererExtension } from "@k8slens/extensions"
|
import { Component, LensRendererExtension } from "@k8slens/extensions"
|
||||||
import { ExamplePage } from "./src/example-page"
|
import { ExamplePage } from "./src/example-page"
|
||||||
@ -123,7 +123,7 @@ export default class ExampleRendererExtension extends LensRendererExtension {
|
|||||||
|
|
||||||
This extension can register custom app preferences. It is responsible for storing a state for custom preferences.
|
This extension can register custom app preferences. It is responsible for storing a state for custom preferences.
|
||||||
|
|
||||||
``` typescript
|
```typescript
|
||||||
import React from "react"
|
import React from "react"
|
||||||
import { LensRendererExtension } from "@k8slens/extensions"
|
import { LensRendererExtension } from "@k8slens/extensions"
|
||||||
import { myCustomPreferencesStore } from "./src/my-custom-preferences-store"
|
import { myCustomPreferencesStore } from "./src/my-custom-preferences-store"
|
||||||
@ -147,7 +147,7 @@ export default class ExampleRendererExtension extends LensRendererExtension {
|
|||||||
|
|
||||||
This extension can register custom cluster pages. These pages are visible in a cluster menu when a cluster is opened.
|
This extension can register custom cluster pages. These pages are visible in a cluster menu when a cluster is opened.
|
||||||
|
|
||||||
``` typescript
|
```typescript
|
||||||
import React from "react"
|
import React from "react"
|
||||||
import { LensRendererExtension } from "@k8slens/extensions";
|
import { LensRendererExtension } from "@k8slens/extensions";
|
||||||
import { ExampleIcon, ExamplePage } from "./src/page"
|
import { ExampleIcon, ExamplePage } from "./src/page"
|
||||||
@ -180,7 +180,7 @@ export default class ExampleExtension extends LensRendererExtension {
|
|||||||
|
|
||||||
This extension can register installable features for a cluster. These features are visible in the "Cluster Settings" page.
|
This extension can register installable features for a cluster. These features are visible in the "Cluster Settings" page.
|
||||||
|
|
||||||
``` typescript
|
```typescript
|
||||||
import React from "react"
|
import React from "react"
|
||||||
import { LensRendererExtension } from "@k8slens/extensions"
|
import { LensRendererExtension } from "@k8slens/extensions"
|
||||||
import { MyCustomFeature } from "./src/my-custom-feature"
|
import { MyCustomFeature } from "./src/my-custom-feature"
|
||||||
@ -209,18 +209,20 @@ export default class ExampleExtension extends LensRendererExtension {
|
|||||||
|
|
||||||
This extension can register custom icons and text to a status bar area.
|
This extension can register custom icons and text to a status bar area.
|
||||||
|
|
||||||
``` typescript
|
```typescript
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { Component, LensRendererExtension, Navigation } from "@k8slens/extensions";
|
import { Component, LensRendererExtension, Navigation } from "@k8slens/extensions";
|
||||||
|
|
||||||
export default class ExampleExtension extends LensRendererExtension {
|
export default class ExampleExtension extends LensRendererExtension {
|
||||||
statusBarItems = [
|
statusBarItems = [
|
||||||
{
|
{
|
||||||
item: (
|
components: {
|
||||||
<div className="flex align-center gaps hover-highlight" onClick={() => this.navigate("/example-page")} >
|
Item: (
|
||||||
<Component.Icon material="favorite" />
|
<div className="flex align-center gaps hover-highlight" onClick={() => this.navigate("/example-page")} >
|
||||||
</div>
|
<Component.Icon material="favorite" />
|
||||||
)
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@ -231,7 +233,7 @@ export default class ExampleExtension extends LensRendererExtension {
|
|||||||
|
|
||||||
This extension can register custom menu items (actions) for specified Kubernetes kinds/apiVersions.
|
This extension can register custom menu items (actions) for specified Kubernetes kinds/apiVersions.
|
||||||
|
|
||||||
``` typescript
|
```typescript
|
||||||
import React from "react"
|
import React from "react"
|
||||||
import { LensRendererExtension } from "@k8slens/extensions";
|
import { LensRendererExtension } from "@k8slens/extensions";
|
||||||
import { CustomMenuItem, CustomMenuItemProps } from "./src/custom-menu-item"
|
import { CustomMenuItem, CustomMenuItemProps } from "./src/custom-menu-item"
|
||||||
@ -254,7 +256,7 @@ export default class ExampleExtension extends LensRendererExtension {
|
|||||||
|
|
||||||
This extension can register custom details (content) for specified Kubernetes kinds/apiVersions.
|
This extension can register custom details (content) for specified Kubernetes kinds/apiVersions.
|
||||||
|
|
||||||
``` typescript
|
```typescript
|
||||||
import React from "react"
|
import React from "react"
|
||||||
import { LensRendererExtension } from "@k8slens/extensions";
|
import { LensRendererExtension } from "@k8slens/extensions";
|
||||||
import { CustomKindDetails, CustomKindDetailsProps } from "./src/custom-kind-details"
|
import { CustomKindDetails, CustomKindDetailsProps } from "./src/custom-kind-details"
|
||||||
|
|||||||
@ -42,7 +42,7 @@ Next, you'll try changing the way the new menu item appears in the UI. You'll ch
|
|||||||
|
|
||||||
Open `my-first-lens-ext/renderer.tsx` and change the value of `title` from `"Hello World"` to `"Hello Lens"`:
|
Open `my-first-lens-ext/renderer.tsx` and change the value of `title` from `"Hello World"` to `"Hello Lens"`:
|
||||||
|
|
||||||
```tsx
|
```typescript
|
||||||
clusterPageMenus = [
|
clusterPageMenus = [
|
||||||
{
|
{
|
||||||
target: { pageId: "hello" },
|
target: { pageId: "hello" },
|
||||||
|
|||||||
BIN
docs/extensions/guides/images/clusterpagemenus.png
Normal file
BIN
docs/extensions/guides/images/clusterpagemenus.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 251 KiB |
BIN
docs/extensions/guides/images/globalpagemenus.png
Normal file
BIN
docs/extensions/guides/images/globalpagemenus.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 145 KiB |
@ -1,15 +1,28 @@
|
|||||||
# Renderer Extension
|
# Renderer Extension
|
||||||
|
|
||||||
The renderer extension api is the interface to Lens's renderer process (Lens runs in main and renderer processes).
|
The Renderer Extension API is the interface to Lens's renderer process. Lens runs in both the main and renderer processes. The Renderer Extension API allows you to access, configure, and customize Lens data, add custom Lens UI elements, and run custom code in Lens's renderer process.
|
||||||
It allows you to access, configure, and customize Lens data, add custom Lens UI elements, and generally run custom code in Lens's renderer process.
|
|
||||||
The custom Lens UI elements that can be added include global pages, cluster pages, cluster page menus, cluster features, app preferences, status bar items, KubeObject menu items, and KubeObject details items.
|
The custom Lens UI elements that you can add include:
|
||||||
These UI elements are based on React components.
|
|
||||||
|
* [Cluster pages](#clusterpages)
|
||||||
|
* [Cluster page menus](#clusterpagemenus)
|
||||||
|
* [Global pages](#globalpages)
|
||||||
|
* [Global page menus](#globalpagemenus)
|
||||||
|
* [Cluster features](#clusterfeatures)
|
||||||
|
* [App preferences](#apppreferences)
|
||||||
|
* [Status bar items](#statusbaritems)
|
||||||
|
* [KubeObject menu items](#kubeobjectmenuitems)
|
||||||
|
* [KubeObject detail items](#kubeobjectdetailitems)
|
||||||
|
|
||||||
|
All UI elements are based on React components.
|
||||||
|
|
||||||
## `LensRendererExtension` Class
|
## `LensRendererExtension` Class
|
||||||
|
|
||||||
To create a renderer extension simply extend the `LensRendererExtension` class:
|
### `onActivate()` and `onDeactivate()` Methods
|
||||||
|
|
||||||
``` typescript
|
To create a renderer extension, extend the `LensRendererExtension` class:
|
||||||
|
|
||||||
|
```typescript
|
||||||
import { LensRendererExtension } from "@k8slens/extensions";
|
import { LensRendererExtension } from "@k8slens/extensions";
|
||||||
|
|
||||||
export default class ExampleExtensionMain extends LensRendererExtension {
|
export default class ExampleExtensionMain extends LensRendererExtension {
|
||||||
@ -23,23 +36,23 @@ export default class ExampleExtensionMain extends LensRendererExtension {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
There are two methods that you can implement to facilitate running your custom code.
|
Two methods enable you to run custom code: `onActivate()` and `onDeactivate()`. Enabling your extension calls `onActivate()` and disabling your extension calls `onDeactivate()`. You can initiate custom code by implementing `onActivate()`. Implementing `onDeactivate()` gives you the opportunity to clean up after your extension.
|
||||||
`onActivate()` is called when your extension has been successfully enabled.
|
|
||||||
By implementing `onActivate()` you can initiate your custom code.
|
!!! info
|
||||||
`onDeactivate()` is called when the extension is disabled (typically from the [Lens Extensions Page]()) and when implemented gives you a chance to clean up after your extension, if necessary.
|
Disable extensions from the Lens Extensions page:
|
||||||
The example above simply logs messages when the extension is enabled and disabled.
|
|
||||||
|
1. Navigate to **File** > **Extensions** in the top menu bar. (On Mac, it is **Lens** > **Extensions**.)
|
||||||
|
2. Click **Disable** on the extension you want to disable.
|
||||||
|
|
||||||
|
The example above logs messages when the extension is enabled and disabled.
|
||||||
|
|
||||||
### `clusterPages`
|
### `clusterPages`
|
||||||
|
|
||||||
Cluster pages appear as part of the cluster dashboard.
|
Cluster pages appear in the cluster dashboard. Use cluster pages to display information about or add functionality to the active cluster. It is also possible to include custom details from other clusters. Use your extension to access Kubernetes resources in the active cluster with [`clusterStore`](../stores#clusterstore).
|
||||||
They are accessible from the side bar, and are shown in the menu list after *Custom Resources*.
|
|
||||||
It is conventional to use a cluster page to show information or provide functionality pertaining to the active cluster, along with custom data and functionality your extension may have.
|
|
||||||
However, it is not limited to the active cluster.
|
|
||||||
Also, your extension can gain access to the Kubernetes resources in the active cluster in a straightforward manner using the [`clusterStore`](../stores#clusterstore).
|
|
||||||
|
|
||||||
The following example adds a cluster page definition to a `LensRendererExtension` subclass:
|
Add a cluster page definition to a `LensRendererExtension` subclass with the following example:
|
||||||
|
|
||||||
``` typescript
|
```typescript
|
||||||
import { LensRendererExtension } from "@k8slens/extensions";
|
import { LensRendererExtension } from "@k8slens/extensions";
|
||||||
import { ExampleIcon, ExamplePage } from "./page"
|
import { ExampleIcon, ExamplePage } from "./page"
|
||||||
import React from "react"
|
import React from "react"
|
||||||
@ -56,14 +69,15 @@ export default class ExampleExtension extends LensRendererExtension {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Cluster pages are objects matching the `PageRegistration` interface.
|
`clusterPages` is an array of objects that satisfy the `PageRegistration` interface. The properties of the `clusterPages` array objects are defined as follows:
|
||||||
The `id` field identifies the page, and at its simplest is just a string identifier, as shown in the example above.
|
|
||||||
The 'id' field can also convey route path details, such as variable parameters provided to a page ([See example below]()).
|
|
||||||
The `components` field matches the `PageComponents` interface for wich there is one field, `Page`.
|
|
||||||
`Page` is of type ` React.ComponentType<any>`, which gives you great flexibility in defining the appearance and behaviour of your page.
|
|
||||||
For the example above `ExamplePage` can be defined in `page.tsx`:
|
|
||||||
|
|
||||||
``` typescript
|
* `id` is a string that identifies the page.
|
||||||
|
* `components` matches the `PageComponents` interface for which there is one field, `Page`.
|
||||||
|
* `Page` is of type ` React.ComponentType<any>`. It offers flexibility in defining the appearance and behavior of your page.
|
||||||
|
|
||||||
|
`ExamplePage` in the example above can be defined in `page.tsx`:
|
||||||
|
|
||||||
|
```typescript
|
||||||
import { LensRendererExtension } from "@k8slens/extensions";
|
import { LensRendererExtension } from "@k8slens/extensions";
|
||||||
import React from "react"
|
import React from "react"
|
||||||
|
|
||||||
@ -78,16 +92,17 @@ export class ExamplePage extends React.Component<{ extension: LensRendererExtens
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Note that the `ExamplePage` class defines a property named `extension`.
|
Note that the `ExamplePage` class defines the `extension` property. This allows the `ExampleExtension` object to be passed in the cluster page definition in the React style. This way, `ExamplePage` can access all `ExampleExtension` subclass data.
|
||||||
This allows the `ExampleExtension` object to be passed in React-style in the cluster page definition, so that `ExamplePage` can access any `ExampleExtension` subclass data.
|
|
||||||
|
The above example shows how to create a cluster page, but not how to make that page available to the Lens user. Use `clusterPageMenus`, covered in the next section, to add cluster pages to the Lens UI.
|
||||||
|
|
||||||
### `clusterPageMenus`
|
### `clusterPageMenus`
|
||||||
|
|
||||||
The above example code shows how to create a cluster page but not how to make it available to the Lens user.
|
`clusterPageMenus` allows you to add cluster page menu items to the secondary left nav.
|
||||||
Cluster pages are typically made available through a menu item in the cluster dashboard sidebar.
|
|
||||||
Expanding on the above example a cluster page menu is added to the `ExampleExtension` definition:
|
|
||||||
|
|
||||||
``` typescript
|
By expanding on the above example, you can add a cluster page menu item to the `ExampleExtension` definition:
|
||||||
|
|
||||||
|
```typescript
|
||||||
import { LensRendererExtension } from "@k8slens/extensions";
|
import { LensRendererExtension } from "@k8slens/extensions";
|
||||||
import { ExampleIcon, ExamplePage } from "./page"
|
import { ExampleIcon, ExamplePage } from "./page"
|
||||||
import React from "react"
|
import React from "react"
|
||||||
@ -114,16 +129,18 @@ export default class ExampleExtension extends LensRendererExtension {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Cluster page menus are objects matching the `ClusterPageMenuRegistration` interface.
|
`clusterPageMenus` is an array of objects that satisfy the `ClusterPageMenuRegistration` interface. This element defines how the cluster page menu item will appear and what it will do when you click it. The properties of the `clusterPageMenus` array objects are defined as follows:
|
||||||
They define the appearance of the cluster page menu item in the cluster dashboard sidebar and the behaviour when the cluster page menu item is activated (typically by a mouse click).
|
|
||||||
The example above uses the `target` field to set the behaviour as a link to the cluster page with `id` of `"hello"`.
|
|
||||||
This is done by setting `target`'s `pageId` field to `"hello"`.
|
|
||||||
The cluster page menu item's appearance is defined by setting the `title` field to the text that is to be displayed in the cluster dashboard sidebar.
|
|
||||||
The `components` field is used to set an icon that appears to the left of the `title` text in the sidebar.
|
|
||||||
Thus when the `"Hello World"` menu item is activated the cluster dashboard will show the contents of `ExamplePage`.
|
|
||||||
This example requires the definition of another React-based component, `ExampleIcon`, which has been added to `page.tsx`:
|
|
||||||
|
|
||||||
``` typescript
|
* `target` links to the relevant cluster page using `pageId`.
|
||||||
|
* `pageId` takes the value of the relevant cluster page's `id` property.
|
||||||
|
* `title` sets the name of the cluster page menu item that will appear in the left side menu.
|
||||||
|
* `components` is used to set an icon that appears to the left of the `title` text in the left side menu.
|
||||||
|
|
||||||
|
The above example creates a menu item that reads **Hello World**. When users click **Hello World**, the cluster dashboard will show the contents of `Example Page`.
|
||||||
|
|
||||||
|
This example requires the definition of another React-based component, `ExampleIcon`, which has been added to `page.tsx`, as follows:
|
||||||
|
|
||||||
|
```typescript
|
||||||
import { LensRendererExtension, Component } from "@k8slens/extensions";
|
import { LensRendererExtension, Component } from "@k8slens/extensions";
|
||||||
import React from "react"
|
import React from "react"
|
||||||
|
|
||||||
@ -142,16 +159,15 @@ export class ExamplePage extends React.Component<{ extension: LensRendererExtens
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
`ExampleIcon` introduces one of Lens's built-in components available to extension developers, the `Component.Icon`.
|
Lens includes various built-in components available for extension developers to use. One of these is the `Component.Icon`, introduced in `ExampleIcon`, which you can use to access any of the [icons](https://material.io/resources/icons/) available at [Material Design](https://material.io). The properties that `Component.Icon` uses are defined as follows:
|
||||||
Built in are the [Material Design](https://material.io) [icons](https://material.io/resources/icons/).
|
|
||||||
One can be selected by name via the `material` field.
|
|
||||||
`ExampleIcon` also sets a tooltip, shown when the Lens user hovers over the icon with a mouse, by setting the `tooltip` field.
|
|
||||||
|
|
||||||
A cluster page menu can also be used to define a foldout submenu in the cluster dashboard sidebar.
|
* `material` takes the name of the icon you want to use.
|
||||||
This enables the grouping of cluster pages.
|
* `tooltip` sets the text you want to appear when a user hovers over the icon.
|
||||||
The following example shows how to specify a submenu having two menu items:
|
|
||||||
|
|
||||||
``` typescript
|
`clusterPageMenus` can also be used to define sub menu items, so that you can create groups of cluster pages. The following example groups two sub menu items under one parent menu item:
|
||||||
|
|
||||||
|
|
||||||
|
```typescript
|
||||||
import { LensRendererExtension } from "@k8slens/extensions";
|
import { LensRendererExtension } from "@k8slens/extensions";
|
||||||
import { ExampleIcon, ExamplePage } from "./page"
|
import { ExampleIcon, ExamplePage } from "./page"
|
||||||
import React from "react"
|
import React from "react"
|
||||||
@ -201,7 +217,8 @@ export default class ExampleExtension extends LensRendererExtension {
|
|||||||
```
|
```
|
||||||
|
|
||||||
The above defines two cluster pages and three cluster page menu objects.
|
The above defines two cluster pages and three cluster page menu objects.
|
||||||
The cluster page definitons are straightforward.
|
The cluster page definitions are straightforward.
|
||||||
|
The three cluster page menu objects include one parent menu item and two sub menu items.
|
||||||
The first cluster page menu object defines the parent of a foldout submenu.
|
The first cluster page menu object defines the parent of a foldout submenu.
|
||||||
Setting the `id` field in a cluster page menu definition implies that it is defining a foldout submenu.
|
Setting the `id` field in a cluster page menu definition implies that it is defining a foldout submenu.
|
||||||
Also note that the `target` field is not specified (it is ignored if the `id` field is specified).
|
Also note that the `target` field is not specified (it is ignored if the `id` field is specified).
|
||||||
@ -209,19 +226,19 @@ This cluster page menu object specifies the `title` and `components` fields, whi
|
|||||||
Initially the submenu is hidden.
|
Initially the submenu is hidden.
|
||||||
Activating this menu item toggles on and off the appearance of the submenu below it.
|
Activating this menu item toggles on and off the appearance of the submenu below it.
|
||||||
The remaining two cluster page menu objects define the contents of the submenu.
|
The remaining two cluster page menu objects define the contents of the submenu.
|
||||||
A cluster page menu object is defined to be a submenu item by setting the `parentId` field to the id of the parent of a foldout submenu, `"example"` in this case
|
A cluster page menu object is defined to be a submenu item by setting the `parentId` field to the id of the parent of a foldout submenu, `"example"` in this case.
|
||||||
|
|
||||||
|
This is what the example will look like, including how the menu item will appear in the secondary left nav:
|
||||||
|
|
||||||
### `globalPages`
|
### `globalPages`
|
||||||
|
|
||||||
Global pages appear independently of the cluster dashboard and they fill the Lens UI space.
|
Global pages are independent of the cluster dashboard and can fill the entire Lens UI. Their primary use is to display information and provide functionality across clusters, including customized data and functionality unique to your extension.
|
||||||
A global page is typically triggered from the cluster menu using a [global page menu](#globalpagemenus).
|
|
||||||
They can also be triggered by a [custom app menu selection](../main-extension#appmenus) from a Main Extension or a [custom status bar item](#statusbaritems).
|
Typically, you would use a [global page menu](#globalpagemenus) located in the left nav to trigger a global page. You can also trigger a global page with a [custom app menu selection](../main-extension#appmenus) from a Main Extension or a [custom status bar item](#statusbaritems). Unlike cluster pages, users can trigger global pages even when there is no active cluster.
|
||||||
Global pages can appear even when there is no active cluster, unlike cluster pages.
|
|
||||||
It is conventional to use a global page to show information and provide functionality relevant across clusters, along with custom data and functionality that your extension may have.
|
|
||||||
|
|
||||||
The following example defines a `LensRendererExtension` subclass with a single global page definition:
|
The following example defines a `LensRendererExtension` subclass with a single global page definition:
|
||||||
|
|
||||||
``` typescript
|
```typescript
|
||||||
import { LensRendererExtension } from '@k8slens/extensions';
|
import { LensRendererExtension } from '@k8slens/extensions';
|
||||||
import { HelpPage } from './page';
|
import { HelpPage } from './page';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
@ -238,14 +255,15 @@ export default class HelpExtension extends LensRendererExtension {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Global pages are objects matching the `PageRegistration` interface.
|
`globalPages` is an array of objects that satisfy the `PageRegistration` interface. The properties of the `globalPages` array objects are defined as follows:
|
||||||
The `id` field identifies the page, and at its simplest is just a string identifier, as shown in the example above.
|
|
||||||
The 'id' field can also convey route path details, such as variable parameters provided to a page ([See example below]()).
|
|
||||||
The `components` field matches the `PageComponents` interface for which there is one field, `Page`.
|
|
||||||
`Page` is of type ` React.ComponentType<any>`, which gives you great flexibility in defining the appearance and behaviour of your page.
|
|
||||||
For the example above `HelpPage` can be defined in `page.tsx`:
|
|
||||||
|
|
||||||
``` typescript
|
* `id` is a string that identifies the page.
|
||||||
|
* `components` matches the `PageComponents` interface for which there is one field, `Page`.
|
||||||
|
* `Page` is of type `React.ComponentType<any>`. It offers flexibility in defining the appearance and behavior of your page.
|
||||||
|
|
||||||
|
`HelpPage` in the example above can be defined in `page.tsx`:
|
||||||
|
|
||||||
|
```typescript
|
||||||
import { LensRendererExtension } from "@k8slens/extensions";
|
import { LensRendererExtension } from "@k8slens/extensions";
|
||||||
import React from "react"
|
import React from "react"
|
||||||
|
|
||||||
@ -260,22 +278,21 @@ export class HelpPage extends React.Component<{ extension: LensRendererExtension
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Note that the `HelpPage` class defines a property named `extension`.
|
Note that the `HelpPage` class defines the `extension` property. This allows the `HelpExtension` object to be passed in the global page definition in the React-style. This way, `HelpPage` can access all `HelpExtension` subclass data.
|
||||||
This allows the `HelpExtension` object to be passed in React-style in the global page definition, so that `HelpPage` can access any `HelpExtension` subclass data.
|
|
||||||
|
|
||||||
This example code shows how to create a global page but not how to make it available to the Lens user.
|
This example code shows how to create a global page, but not how to make that page available to the Lens user. Global pages can be made available in the following ways:
|
||||||
Global pages are typically made available through a number of ways.
|
|
||||||
Menu items can be added to the Lens app menu system and set to open a global page when activated (See [`appMenus` in the Main Extension guide](../main-extension#appmenus)).
|
* To add global pages to the top menu bar, see [`appMenus`](../main-extension#appmenus) in the Main Extension guide.
|
||||||
Interactive elements can be placed on the status bar (the blue strip along the bottom of the Lens UI) and can be configured to link to a global page when activated (See [`statusBarItems`](#statusbaritems)).
|
* To add global pages as an interactive element in the blue status bar along the bottom of the Lens UI, see [`statusBarItems`](#statusbaritems).
|
||||||
As well, global pages can be made accessible from the cluster menu, which is the vertical strip along the left side of the Lens UI showing the available cluster icons, and the Add Cluster icon.
|
* To add global pages to the left side menu, see [`globalPageMenus`](#globalpagemenus).
|
||||||
Global page menu icons that are defined using [`globalPageMenus`](#globalpagemenus) appear below the Add Cluster icon.
|
|
||||||
|
|
||||||
### `globalPageMenus`
|
### `globalPageMenus`
|
||||||
|
|
||||||
Global page menus connect a global page to the cluster menu, which is the vertical strip along the left side of the Lens UI showing the available cluster icons, and the Add Cluster icon.
|
`globalPageMenus` allows you to add global page menu items to the left nav.
|
||||||
Expanding on the example from [`globalPages`](#globalPages) a global page menu is added to the `HelpExtension` definition:
|
|
||||||
|
|
||||||
``` typescript
|
By expanding on the above example, you can add a global page menu item to the `HelpExtension` definition:
|
||||||
|
|
||||||
|
```typescript
|
||||||
import { LensRendererExtension } from "@k8slens/extensions";
|
import { LensRendererExtension } from "@k8slens/extensions";
|
||||||
import { HelpIcon, HelpPage } from "./page"
|
import { HelpIcon, HelpPage } from "./page"
|
||||||
import React from "react"
|
import React from "react"
|
||||||
@ -302,16 +319,18 @@ export default class HelpExtension extends LensRendererExtension {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Global page menus are objects matching the `PageMenuRegistration` interface.
|
`globalPageMenus` is an array of objects that satisfy the `PageMenuRegistration` interface. This element defines how the global page menu item will appear and what it will do when you click it. The properties of the `globalPageMenus` array objects are defined as follows:
|
||||||
They define the appearance of the global page menu item in the cluster menu and the behaviour when the global page menu item is activated (typically by a mouse click).
|
|
||||||
The example above uses the `target` field to set the behaviour as a link to the global page with `id` of `"help"`.
|
|
||||||
This is done by setting `target`'s `pageId` field to `"help"`.
|
|
||||||
The global page menu item's appearance is defined by setting the `title` field to the text that is to be displayed as a tooltip in the cluster menu.
|
|
||||||
The `components` field is used to set an icon that appears in the cluster menu.
|
|
||||||
Thus when the `"Help"` icon is activated the contents of `ExamplePage` will be shown.
|
|
||||||
This example requires the definition of another React-based component, `HelpIcon`, which has been added to `page.tsx`:
|
|
||||||
|
|
||||||
``` typescript
|
* `target` links to the relevant global page using `pageId`.
|
||||||
|
* `pageId` takes the value of the relevant global page's `id` property.
|
||||||
|
* `title` sets the name of the global page menu item that will display as a tooltip in the left nav.
|
||||||
|
* `components` is used to set an icon that appears in the left nav.
|
||||||
|
|
||||||
|
The above example creates a "Help" icon menu item. When users click the icon, the Lens UI will display the contents of `ExamplePage`.
|
||||||
|
|
||||||
|
This example requires the definition of another React-based component, `HelpIcon`. Update `page.tsx` from the example above with the `HelpIcon` definition, as follows:
|
||||||
|
|
||||||
|
```typescript
|
||||||
import { LensRendererExtension, Component } from "@k8slens/extensions";
|
import { LensRendererExtension, Component } from "@k8slens/extensions";
|
||||||
import React from "react"
|
import React from "react"
|
||||||
|
|
||||||
@ -330,18 +349,25 @@ export class HelpPage extends React.Component<{ extension: LensRendererExtension
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
`HelpIcon` introduces one of Lens's built-in components available to extension developers, the `Component.Icon`.
|
Lens includes various built-in components available for extension developers to use. One of these is the `Component.Icon`, introduced in `HelpIcon`, which you can use to access any of the [icons](https://material.io/resources/icons/) available at [Material Design](https://material.io). The property that `Component.Icon` uses is defined as follows:
|
||||||
Built in are the [Material Design](https://material.io) [icons](https://material.io/resources/icons/).
|
|
||||||
One can be selected by name via the `material` field.
|
* `material` takes the name of the icon you want to use.
|
||||||
|
|
||||||
|
This is what the example will look like, including how the menu item will appear in the left nav:
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
### `clusterFeatures`
|
### `clusterFeatures`
|
||||||
|
|
||||||
Cluster features are Kubernetes resources that can be applied to and managed within the active cluster.
|
Cluster features are Kubernetes resources that can be applied to and managed within the active cluster.
|
||||||
They can be installed/uninstalled by the Lens user from the [cluster settings page]().
|
They can be installed and uninstalled by the Lens user from the cluster **Settings** page.
|
||||||
|
|
||||||
|
!!! info
|
||||||
|
To access the cluster **Settings** page, right-click the relevant cluster in the left side menu and click **Settings**.
|
||||||
|
|
||||||
The following example shows how to add a cluster feature as part of a `LensRendererExtension`:
|
The following example shows how to add a cluster feature as part of a `LensRendererExtension`:
|
||||||
|
|
||||||
``` typescript
|
```typescript
|
||||||
import { LensRendererExtension } from "@k8slens/extensions"
|
import { LensRendererExtension } from "@k8slens/extensions"
|
||||||
import { ExampleFeature } from "./src/example-feature"
|
import { ExampleFeature } from "./src/example-feature"
|
||||||
import React from "react"
|
import React from "react"
|
||||||
@ -364,34 +390,44 @@ export default class ExampleFeatureExtension extends LensRendererExtension {
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
The `title` and `components.Description` fields provide content that appears on the cluster settings page, in the **Features** section.
|
|
||||||
The `feature` field must specify an instance which extends the abstract class `ClusterFeature.Feature`, and specifically implement the following methods:
|
|
||||||
|
|
||||||
``` typescript
|
The properties of the `clusterFeatures` array objects are defined as follows:
|
||||||
|
|
||||||
|
* `title` and `components.Description` provide content that appears on the cluster settings page, in the **Features** section.
|
||||||
|
* `feature` specifies an instance which extends the abstract class `ClusterFeature.Feature`, and specifically implements the following methods:
|
||||||
|
|
||||||
|
```typescript
|
||||||
abstract install(cluster: Cluster): Promise<void>;
|
abstract install(cluster: Cluster): Promise<void>;
|
||||||
abstract upgrade(cluster: Cluster): Promise<void>;
|
abstract upgrade(cluster: Cluster): Promise<void>;
|
||||||
abstract uninstall(cluster: Cluster): Promise<void>;
|
abstract uninstall(cluster: Cluster): Promise<void>;
|
||||||
abstract updateStatus(cluster: Cluster): Promise<ClusterFeatureStatus>;
|
abstract updateStatus(cluster: Cluster): Promise<ClusterFeatureStatus>;
|
||||||
```
|
```
|
||||||
|
|
||||||
The `install()` method is typically called by Lens when a user has indicated that this feature is to be installed (i.e. clicked **Install** for the feature on the cluster settings page).
|
The four methods listed above are defined as follows:
|
||||||
The implementation of this method should install kubernetes resources using the `applyResources()` method, or by directly accessing the kubernetes api ([`K8sApi`](tbd)).
|
|
||||||
|
|
||||||
The `upgrade()` method is typically called by Lens when a user has indicated that this feature is to be upgraded (i.e. clicked **Upgrade** for the feature on the cluster settings page).
|
* The `install()` method installs Kubernetes resources using the `applyResources()` method, or by directly accessing the [Kubernetes API](../api/README.md).
|
||||||
The implementation of this method should upgrade the kubernetes resources already installed, if relevant to the feature.
|
This method is typically called when a user indicates that they want to install the feature (i.e., by clicking **Install** for the feature in the cluster settings page).
|
||||||
|
|
||||||
The `uninstall()` method is typically called by Lens when a user has indicated that this feature is to be uninstalled (i.e. clicked **Uninstall** for the feature on the cluster settings page).
|
* The `upgrade()` method upgrades the Kubernetes resources already installed, if they are relevant to the feature.
|
||||||
The implementation of this method should uninstall kubernetes resources using the kubernetes api (`K8sApi`)
|
This method is typically called when a user indicates that they want to upgrade the feature (i.e., by clicking **Upgrade** for the feature in the cluster settings page).
|
||||||
|
|
||||||
The `updateStatus()` method is called periodically by Lens to determine details about the feature's current status.
|
* The `uninstall()` method uninstalls Kubernetes resources using the [Kubernetes API](../api/README.md).
|
||||||
The implementation of this method should provide the current status information in the `status` field of the `ClusterFeature.Feature` parent class.
|
This method is typically called when a user indicates that they want to uninstall the feature (i.e., by clicking **Uninstall** for the feature in the cluster settings page).
|
||||||
The `status.currentVersion` and `status.latestVersion` fields may be displayed by Lens in describing the feature.
|
|
||||||
The `status.installed` field should be set to true if the feature is currently installed, otherwise false.
|
* The `updateStatus()` method provides the current status information in the `status` field of the `ClusterFeature.Feature` parent class.
|
||||||
Also, Lens relies on the `status.canUpgrade` field to determine if the feature can be upgraded (i.e a new version could be available) so the implementation should set the `status.canUpgrade` field according to specific rules for the feature, if relevant.
|
Lens periodically calls this method to determine details about the feature's current status.
|
||||||
|
The implementation of this method should uninstall Kubernetes resources using the Kubernetes api (`K8sApi`)
|
||||||
|
Consider using the following properties with `updateStatus()`:
|
||||||
|
|
||||||
|
* `status.currentVersion` and `status.latestVersion` may be displayed by Lens in the feature's description.
|
||||||
|
|
||||||
|
* `status.installed` should be set to `true` if the feature is installed, and `false` otherwise.
|
||||||
|
|
||||||
|
* `status.canUpgrade` is set according to a rule meant to determine whether the feature can be upgraded. This rule can involve `status.currentVersion` and `status.latestVersion`, if desired.
|
||||||
|
|
||||||
The following shows a very simple implementation of a `ClusterFeature`:
|
The following shows a very simple implementation of a `ClusterFeature`:
|
||||||
|
|
||||||
``` typescript
|
```typescript
|
||||||
import { ClusterFeature, Store, K8sApi } from "@k8slens/extensions";
|
import { ClusterFeature, Store, K8sApi } from "@k8slens/extensions";
|
||||||
import * as path from "path";
|
import * as path from "path";
|
||||||
|
|
||||||
@ -435,9 +471,9 @@ export class ExampleFeature extends ClusterFeature.Feature {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
This example implements the `install()` method by simply invoking the helper `applyResources()` method.
|
This example implements the `install()` method by invoking the helper `applyResources()` method.
|
||||||
`applyResources()` tries to apply all resources read from all files found in the folder path provided.
|
`applyResources()` tries to apply all resources read from all files found in the folder path provided.
|
||||||
In this case this folder path is the `../resources` subfolder relative to current source code's folder.
|
In this case the folder path is the `../resources` subfolder relative to the current source code's folder.
|
||||||
The file `../resources/example-pod.yml` could contain:
|
The file `../resources/example-pod.yml` could contain:
|
||||||
|
|
||||||
``` yaml
|
``` yaml
|
||||||
@ -451,21 +487,21 @@ spec:
|
|||||||
image: nginx
|
image: nginx
|
||||||
```
|
```
|
||||||
|
|
||||||
The `upgrade()` method in the example above is implemented by simply invoking the `install()` method.
|
The example above implements the four methods as follows:
|
||||||
Depending on the feature to be supported by an extension, upgrading may require additional and/or different steps.
|
|
||||||
|
|
||||||
The `uninstall()` method is implemented in the example above by utilizing the [`K8sApi`](tbd) provided by Lens to simply delete the `example-pod` pod applied by the `install()` method.
|
* It implements `upgrade()` by invoking the `install()` method. Depending on the feature to be supported by an extension, upgrading may require additional and/or different steps.
|
||||||
|
|
||||||
The `updateStatus()` method is implemented above by using the [`K8sApi`](tbd) as well, this time to get information from the `example-pod` pod, in particular to determine if it is installed, what version is associated with it, and if it can be upgraded.
|
* It implements `uninstall()` by utilizing the [Kubernetes API](../api/README.md) which Lens provides to delete the `example-pod` applied by the `install()` method.
|
||||||
How the status is updated for a specific cluster feature is up to the implementation.
|
|
||||||
|
* It implements `updateStatus()` by using the [Kubernetes API](../api/README.md) which Lens provides to determine whether the `example-pod` is installed, what version is associated with it, and whether it can be upgraded. The implementation determines what the status is for a specific cluster feature.
|
||||||
|
|
||||||
### `appPreferences`
|
### `appPreferences`
|
||||||
|
|
||||||
The Preferences page is a built-in global page.
|
The Lens **Preferences** page is a built-in global page. You can use Lens extensions to add custom preferences to the Preferences page, providing a single location for users to configure global options.
|
||||||
Extensions can add custom preferences to the Preferences page, thus providing a single location for users to configure global options, for Lens and extensions alike.
|
|
||||||
The following example demonstrates adding a custom preference:
|
The following example demonstrates adding a custom preference:
|
||||||
|
|
||||||
``` typescript
|
```typescript
|
||||||
import { LensRendererExtension } from "@k8slens/extensions";
|
import { LensRendererExtension } from "@k8slens/extensions";
|
||||||
import { ExamplePreferenceHint, ExamplePreferenceInput } from "./src/example-preference";
|
import { ExamplePreferenceHint, ExamplePreferenceInput } from "./src/example-preference";
|
||||||
import { observable } from "mobx";
|
import { observable } from "mobx";
|
||||||
@ -487,15 +523,22 @@ export default class ExampleRendererExtension extends LensRendererExtension {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
App preferences are objects matching the `AppPreferenceRegistration` interface.
|
`appPreferences` is an array of objects that satisfies the `AppPreferenceRegistration` interface. The properties of the `appPreferences` array objects are defined as follows:
|
||||||
The `title` field specifies the text to show as the heading on the Preferences page.
|
|
||||||
The `components` field specifies two `React.Component` objects defining the interface for the preference.
|
|
||||||
`Input` should specify an interactive input element for your preference and `Hint` should provide descriptive information for the preference, which is shown below the `Input` element.
|
|
||||||
`ExamplePreferenceInput` expects its React props set to an `ExamplePreferenceProps` instance, which is how `ExampleRendererExtension` handles the state of the preference input.
|
|
||||||
`ExampleRendererExtension` has the field `preference`, which is provided to `ExamplePreferenceInput` when it is created.
|
|
||||||
In this example `ExamplePreferenceInput`, `ExamplePreferenceHint`, and `ExamplePreferenceProps` are defined in `./src/example-preference.tsx`:
|
|
||||||
|
|
||||||
``` typescript
|
* `title` sets the heading text displayed on the Preferences page.
|
||||||
|
* `components` specifies two `React.Component` objects that define the interface for the preference.
|
||||||
|
* `Input` specifies an interactive input element for the preference.
|
||||||
|
* `Hint` provides descriptive information for the preference, shown below the `Input` element.
|
||||||
|
|
||||||
|
!!! note
|
||||||
|
Note that the input and the hint can be comprised of more sophisticated elements, according to the needs of the extension.
|
||||||
|
|
||||||
|
`ExamplePreferenceInput` expects its React props to be set to an `ExamplePreferenceProps` instance. This is how `ExampleRendererExtension` handles the state of the preference input.
|
||||||
|
`ExampleRendererExtension` has a `preference` field, which you will add to `ExamplePreferenceInput`.
|
||||||
|
|
||||||
|
In this example `ExamplePreferenceInput`, `ExamplePreferenceHint`, and `ExamplePreferenceProps` are defined in `./src/example-preference.tsx` as follows:
|
||||||
|
|
||||||
|
```typescript
|
||||||
import { Component } from "@k8slens/extensions";
|
import { Component } from "@k8slens/extensions";
|
||||||
import { observer } from "mobx-react";
|
import { observer } from "mobx-react";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
@ -530,30 +573,28 @@ export class ExamplePreferenceHint extends React.Component {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
`ExamplePreferenceInput` implements a simple checkbox (using Lens's `Component.Checkbox`).
|
`ExamplePreferenceInput` implements a simple checkbox using Lens's `Component.Checkbox` using the following properties:
|
||||||
It provides `label` as the text to display next to the checkbox and an `onChange` function, which reacts to the checkbox state change.
|
|
||||||
The checkbox's `value` is initially set to `preference.enabled`.
|
* `label` sets the text that displays next to the checkbox.
|
||||||
`ExamplePreferenceInput` is defined with React props of `ExamplePreferenceProps` type, which is an object with a single field, `enabled`.
|
* `value` is initially set to `preference.enabled`.
|
||||||
This is used to indicate the state of the preference, and is bound to the checkbox state in `onChange`.
|
* `onChange` is a function that responds when the state of the checkbox changes.
|
||||||
|
|
||||||
|
`ExamplePreferenceInput` is defined with the `ExamplePreferenceProps` React props. This is an object with the single `enabled` property. It is used to indicate the state of the preference, and it is bound to the checkbox state in `onChange`.
|
||||||
|
|
||||||
`ExamplePreferenceHint` is a simple text span.
|
`ExamplePreferenceHint` is a simple text span.
|
||||||
Note that the input and the hint could comprise of more sophisticated elements, according to the needs of the extension.
|
|
||||||
|
|
||||||
Note that the above example introduces decorators `observable` and `observer` from the [`mobx`](https://mobx.js.org/README.html) and [`mobx-react`](https://github.com/mobxjs/mobx-react#mobx-react) packages.
|
The above example introduces the decorators `observable` and `observer` from the [`mobx`](https://mobx.js.org/README.html) and [`mobx-react`](https://github.com/mobxjs/mobx-react#mobx-react) packages. `mobx` simplifies state management. Without it, this example would not visually update the checkbox properly when the user activates it. [Lens uses `mobx`](../working-with-mobx) extensively for state management of its own UI elements. We recommend that extensions rely on it, as well.
|
||||||
`mobx` simplifies state management and without it this example would not visually update the checkbox properly when the user activates it.
|
Alternatively, you can use React's state management, though `mobx` is typically simpler to use.
|
||||||
[Lens uses `mobx` extensively for state management](../working-with-mobx) of its own UI elements and it is recommended that extensions rely on it too.
|
|
||||||
Alternatively, React's state management can be used, though `mobx` is typically simpler to use.
|
|
||||||
|
|
||||||
Also note that an extension's state data can be managed using an `ExtensionStore` object, which conveniently handles persistence and synchronization.
|
Note that you can manage an extension's state data using an `ExtensionStore` object, which conveniently handles persistence and synchronization. To simplify this guide, the example above defines a `preference` field in the `ExampleRendererExtension` class definition to hold the extension's state. However, we recommend that you manage your extension's state data using [`ExtensionStore`](../stores#extensionstore).
|
||||||
The example above defined a `preference` field in the `ExampleRendererExtension` class definition to hold the extension's state primarily to simplify the code for this guide, but it is recommended to manage your extension's state data using [`ExtensionStore`](../stores#extensionstore)
|
|
||||||
|
|
||||||
### `statusBarItems`
|
### `statusBarItems`
|
||||||
|
|
||||||
The Status bar is the blue strip along the bottom of the Lens UI.
|
The status bar is the blue strip along the bottom of the Lens UI. `statusBarItems` are `React.ReactNode` types. They can be used to display status information, or act as links to global pages as well as external pages.
|
||||||
Status bar items are `React.ReactNode` types, which can be used to convey status information, or act as a link to a global page, or even an external page.
|
|
||||||
|
|
||||||
The following example adds a status bar item definition, as well as a global page definition, to a `LensRendererExtension` subclass, and configures the status bar item to navigate to the global page upon activation (normally a mouse click):
|
The following example adds a `statusBarItems` definition and a `globalPages` definition to a `LensRendererExtension` subclass. It configures the status bar item to navigate to the global page upon activation (normally a mouse click):
|
||||||
|
|
||||||
``` typescript
|
```typescript
|
||||||
import { LensRendererExtension } from '@k8slens/extensions';
|
import { LensRendererExtension } from '@k8slens/extensions';
|
||||||
import { HelpIcon, HelpPage } from "./page"
|
import { HelpIcon, HelpPage } from "./page"
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
@ -570,39 +611,41 @@ export default class HelpExtension extends LensRendererExtension {
|
|||||||
|
|
||||||
statusBarItems = [
|
statusBarItems = [
|
||||||
{
|
{
|
||||||
item: (
|
components: {
|
||||||
<div
|
Item: (
|
||||||
className="flex align-center gaps"
|
<div
|
||||||
onClick={() => this.navigate("help")}
|
className="flex align-center gaps"
|
||||||
>
|
onClick={() => this.navigate("help")}
|
||||||
<HelpIcon />
|
>
|
||||||
My Status Bar Item
|
<HelpIcon />
|
||||||
</div>
|
My Status Bar Item
|
||||||
),
|
</div>
|
||||||
|
)
|
||||||
|
},
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
The `item` field of a status bar item specifies the `React.Component` to be shown on the status bar.
|
The properties of the `statusBarItems` array objects are defined as follows:
|
||||||
By default items are added starting from the right side of the status bar.
|
|
||||||
Typically, `item` would specify an icon and/or a short string of text, considering the limited space on the status bar.
|
* `Item` specifies the `React.Component` that will be shown on the status bar. By default, items are added starting from the right side of the status bar. Due to limited space in the status bar, `Item` will typically specify only an icon or a short string of text. The example above reuses the `HelpIcon` from the [`globalPageMenus` guide](#globalpagemenus).
|
||||||
In the example above the `HelpIcon` from the [`globalPageMenus` guide](#globalpagemenus) is reused.
|
* `onClick` determines what the `statusBarItem` does when it is clicked. In the example, `onClick` is set to a function that calls the `LensRendererExtension` `navigate()` method. `navigate` takes the `id` of the associated global page as a parameter. Thus, clicking the status bar item activates the associated global pages.
|
||||||
Also, the `item` provides a link to the global page by setting the `onClick` property to a function that calls the `LensRendererExtension` `navigate()` method.
|
|
||||||
`navigate()` takes as a parameter the id of the global page, which is shown when `navigate()` is called.
|
|
||||||
|
|
||||||
### `kubeObjectMenuItems`
|
### `kubeObjectMenuItems`
|
||||||
|
|
||||||
An extension can add custom menu items (including actions) for specific Kubernetes resource kinds/apiVersions.
|
An extension can add custom menu items (`kubeObjectMenuItems`) for specific Kubernetes resource kinds and apiVersions.
|
||||||
These menu items appear under the `...` for each listed resource in the cluster dashboard, and on the title bar of the details page for a specific resource:
|
`kubeObjectMenuItems` appear under the vertical ellipsis for each listed resource in the cluster dashboard:
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
They also appear on the title bar of the details page for specific resources:
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
The following example shows how to add a menu for Namespace resources, and associate an action with it:
|
The following example shows how to add a `kubeObjectMenuItems` for namespace resources with an associated action:
|
||||||
|
|
||||||
``` typescript
|
```typescript
|
||||||
import React from "react"
|
import React from "react"
|
||||||
import { LensRendererExtension } from "@k8slens/extensions";
|
import { LensRendererExtension } from "@k8slens/extensions";
|
||||||
import { NamespaceMenuItem } from "./src/namespace-menu-item"
|
import { NamespaceMenuItem } from "./src/namespace-menu-item"
|
||||||
@ -621,12 +664,13 @@ export default class ExampleExtension extends LensRendererExtension {
|
|||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Kube object menu items are objects matching the `KubeObjectMenuRegistration` interface.
|
`kubeObjectMenuItems` is an array of objects matching the `KubeObjectMenuRegistration` interface. The example above adds a menu item for namespaces in the cluster dashboard. The properties of the `kubeObjectMenuItems` array objects are defined as follows:
|
||||||
The `kind` field specifies the kubernetes resource type to apply this menu item to, and the `apiVersion` field specifies the kubernetes api to use in relation to this resource type.
|
|
||||||
This example adds a menu item for namespaces in the cluster dashboard.
|
* `kind` specifies the Kubernetes resource type the menu item will apply to.
|
||||||
The `components` field defines the menu item's appearance and behaviour.
|
* `apiVersion` specifies the Kubernetes API version number to use with the resource type.
|
||||||
The `MenuItem` field provides a function that returns a `React.Component` given a set of menu item properties.
|
* `components` defines the menu item's appearance and behavior.
|
||||||
In this example a `NamespaceMenuItem` object is returned.
|
* `MenuItem` provides a function that returns a `React.Component` given a set of menu item properties. In this example a `NamespaceMenuItem` object is returned.
|
||||||
|
|
||||||
`NamespaceMenuItem` is defined in `./src/namespace-menu-item.tsx`:
|
`NamespaceMenuItem` is defined in `./src/namespace-menu-item.tsx`:
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
@ -661,24 +705,20 @@ export function NamespaceMenuItem(props: Component.KubeObjectMenuProps<K8sApi.Na
|
|||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
`NamespaceMenuItem` returns a `Component.MenuItem` defining the menu item's appearance (icon and text) and behaviour when activated via the `onClick` property.
|
`NamespaceMenuItem` returns a `Component.MenuItem` which defines the menu item's appearance and its behavior when activated via the `onClick` property. In the example, `getPods()` opens a terminal tab and runs `kubectl` to get a list of pods running in the current namespace.
|
||||||
`getPods()` shows how to open a terminal tab and run a command, specifically it runs `kubectl` to get a list of pods running in the current namespace.
|
|
||||||
See [`Component.terminalStore.sendCommand`](api-docs?) for more details on running terminal commands.
|
The name of the namespace is retrieved from `props` passed into `NamespaceMenuItem()`. `namespace` is the `props.object`, which is of type `K8sApi.Namespace`. `K8sApi.Namespace` is the API for accessing namespaces. The current namespace in this example is simply given by `namespace.getName()`. Thus, `kubeObjectMenuItems` afford convenient access to the specific resource selected by the user.
|
||||||
The name of the namespace is retrieved from `props` passed into `NamespaceMenuItem()`.
|
|
||||||
`namespace` is the `props.object`, which is of type `K8sApi.Namespace`.
|
|
||||||
This is the api for accessing namespaces, and the current namespace in this example is simply given by `namespace.getName()`.
|
|
||||||
Thus kube object menu items are afforded convenient access to the specific resource selected by the user.
|
|
||||||
|
|
||||||
### `kubeObjectDetailItems`
|
### `kubeObjectDetailItems`
|
||||||
|
|
||||||
An extension can add custom details (content) for specified Kubernetes resource kinds/apiVersions.
|
An extension can add custom details (`kubeObjectDetailItems`) for specified Kubernetes resource kinds and apiVersions.
|
||||||
These custom details appear on the details page for a specific resource, such as a Namespace:
|
These custom details appear on the details page for a specific resource, such as a Namespace as shown here:
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
The following example shows how to add a tabulated list of pods to the Namespace resource details page:
|
The following example shows how to use `kubeObjectDetailItems` to add a tabulated list of pods to the Namespace resource details page:
|
||||||
|
|
||||||
``` typescript
|
```typescript
|
||||||
import React from "react"
|
import React from "react"
|
||||||
import { LensRendererExtension } from "@k8slens/extensions";
|
import { LensRendererExtension } from "@k8slens/extensions";
|
||||||
import { NamespaceDetailsItem } from "./src/namespace-details-item"
|
import { NamespaceDetailsItem } from "./src/namespace-details-item"
|
||||||
@ -697,12 +737,13 @@ export default class ExampleExtension extends LensRendererExtension {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Kube object detail items are objects matching the `KubeObjectDetailRegistration` interface.
|
`kubeObjectDetailItems` is an array of objects matching the `KubeObjectDetailRegistration` interface. This example above adds a detail item for namespaces in the cluster dashboard. The properties of the `kubeObjectDetailItems` array objects are defined as follows:
|
||||||
The `kind` field specifies the kubernetes resource type to apply this detail item to, and the `apiVersion` field specifies the kubernetes api to use in relation to this resource type.
|
|
||||||
This example adds a detail item for namespaces in the cluster dashboard.
|
* `kind` specifies the Kubernetes resource type the detail item will apply to.
|
||||||
The `components` field defines the detail item's appearance and behaviour.
|
* `apiVersion` specifies the Kubernetes API version number to use with the resource type.
|
||||||
The `Details` field provides a function that returns a `React.Component` given a set of detail item properties.
|
* `components` defines the detail item's appearance and behavior.
|
||||||
In this example a `NamespaceDetailsItem` object is returned.
|
* `Details` provides a function that returns a `React.Component` given a set of detail item properties. In this example a `NamespaceDetailsItem` object is returned.
|
||||||
|
|
||||||
`NamespaceDetailsItem` is defined in `./src/namespace-details-item.tsx`:
|
`NamespaceDetailsItem` is defined in `./src/namespace-details-item.tsx`:
|
||||||
|
|
||||||
``` typescript
|
``` typescript
|
||||||
@ -732,21 +773,22 @@ export class NamespaceDetailsItem extends React.Component<Component.KubeObjectDe
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Since `NamespaceDetailsItem` extends `React.Component<Component.KubeObjectDetailsProps<K8sApi.Namespace>>` it can access the current namespace object (type `K8sApi.Namespace`) through `this.props.object`.
|
Since `NamespaceDetailsItem` extends `React.Component<Component.KubeObjectDetailsProps<K8sApi.Namespace>>`, it can access the current namespace object (type `K8sApi.Namespace`) through `this.props.object`.
|
||||||
This object can be queried for many details about the current namespace.
|
You can query this object for many details about the current namespace.
|
||||||
In this example the namespace's name is obtained in `componentDidMount()` using the `K8sApi.Namespace` `getName()` method.
|
In the example above, `componentDidMount()` gets the namespace's name using the `K8sApi.Namespace` `getName()` method.
|
||||||
The namespace's name is needed to limit the list of pods to only those in this namespace.
|
Use the namespace's name to limit the list of pods only to those in the relevant namespace.
|
||||||
To get the list of pods this example uses the kubernetes pods api, specifically the `K8sApi.podsApi.list()` method.
|
To get this list of pods, this example uses the Kubernetes pods API `K8sApi.podsApi.list()` method.
|
||||||
The `K8sApi.podsApi` is automatically configured for the currently active cluster.
|
The `K8sApi.podsApi` is automatically configured for the active cluster.
|
||||||
|
|
||||||
Note that `K8sApi.podsApi.list()` is an asynchronous method, and ideally getting the pods list should be done before rendering the `NamespaceDetailsItem`.
|
Note that `K8sApi.podsApi.list()` is an asynchronous method.
|
||||||
|
Getting the pods list should occur prior to rendering the `NamespaceDetailsItem`.
|
||||||
It is a common technique in React development to await async calls in `componentDidMount()`.
|
It is a common technique in React development to await async calls in `componentDidMount()`.
|
||||||
However, `componentDidMount()` is called right after the first call to `render()`.
|
However, `componentDidMount()` is called right after the first call to `render()`.
|
||||||
In order to effect a subsequent `render()` call React must be made aware of a state change.
|
In order to effect a subsequent `render()` call, React must be made aware of a state change.
|
||||||
Like in the [`appPreferences` guide](#apppreferences), [`mobx`](https://mobx.js.org/README.html) and [`mobx-react`](https://github.com/mobxjs/mobx-react#mobx-react) are used to ensure `NamespaceDetailsItem` renders when the pods list is updated.
|
Like in the [`appPreferences` guide](#apppreferences), [`mobx`](https://mobx.js.org/README.html) and [`mobx-react`](https://github.com/mobxjs/mobx-react#mobx-react) are used to ensure `NamespaceDetailsItem` renders when the pods list updates.
|
||||||
This is done simply by marking the `pods` field as an `observable` and the `NamespaceDetailsItem` class itself as an `observer`.
|
This is done simply by marking the `pods` field as an `observable` and the `NamespaceDetailsItem` class itself as an `observer`.
|
||||||
|
|
||||||
Finally, the `NamespaceDetailsItem` is rendered using the `render()` method.
|
Finally, the `NamespaceDetailsItem` renders using the `render()` method.
|
||||||
Details are placed in drawers, and using `Component.DrawerTitle` provides a separator from details above this one.
|
Details are placed in drawers, and using `Component.DrawerTitle` provides a separator from details above this one.
|
||||||
Multiple details in a drawer can be placed in `<Component.DrawerItem>` elements for further separation, if desired.
|
Multiple details in a drawer can be placed in `<Component.DrawerItem>` elements for further separation, if desired.
|
||||||
The rest of this example's details are defined in `PodsDetailsList`, found in `./pods-details-list.tsx`:
|
The rest of this example's details are defined in `PodsDetailsList`, found in `./pods-details-list.tsx`:
|
||||||
@ -800,6 +842,9 @@ export class PodsDetailsList extends React.Component<Props> {
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
For each pod the name, age, and status are obtained using the `K8sApi.Pod` methods.
|
Obtain the name, age, and status for each pod using the `K8sApi.Pod` methods. Construct the table using the `Component.Table` and related elements.
|
||||||
|
|
||||||
|
|
||||||
|
For each pod the name, age, and status are obtained using the `K8sApi.Pod` methods.
|
||||||
The table is constructed using the `Component.Table` and related elements.
|
The table is constructed using the `Component.Table` and related elements.
|
||||||
See [`Component` documentation](url?) for further details.
|
See [`Component` documentation](https://docs.k8slens.dev/master/extensions/api/modules/_renderer_api_components_/) for further details.
|
||||||
|
|||||||
@ -1,18 +1,16 @@
|
|||||||
# Stores
|
# Stores
|
||||||
|
|
||||||
Stores are components that persist and synchronize state data. Lens utilizes a number of stores for maintaining a variety of state information.
|
Stores are components that persist and synchronize state data. Lens uses a number of stores to maintain various kinds of state information, including:
|
||||||
A few of these are exposed by the extensions api for use by the extension developer.
|
|
||||||
|
|
||||||
- The `ClusterStore` manages cluster state data such as cluster details, and which cluster is active.
|
* The `ClusterStore` manages cluster state data (such as cluster details), and it tracks which cluster is active.
|
||||||
- The `WorkspaceStore` similarly manages workspace state data, such as workspace name, and which clusters belong to a given workspace.
|
* The `WorkspaceStore` manages workspace state data (such as the workspace name), and and it tracks which clusters belong to a given workspace.
|
||||||
- The `ExtensionStore` is a store for managing custom extension state data.
|
* The `ExtensionStore` manages custom extension state data.
|
||||||
|
|
||||||
|
This guide focuses on the `ExtensionStore`.
|
||||||
|
|
||||||
## ExtensionStore
|
## ExtensionStore
|
||||||
|
|
||||||
Extension developers can create their own store for managing state data by extending the `ExtensionStore` class.
|
Extension developers can create their own store for managing state data by extending the `ExtensionStore` class. This guide shows how to create a store for the [`appPreferences`](../renderer-extension#apppreferences) guide example, which demonstrates how to add a custom preference to the **Preferences** page. The preference is a simple boolean that indicates whether or not something is enabled. However, in the example, the enabled state is not stored anywhere, and it reverts to the default when Lens is restarted.
|
||||||
This guide shows how to create a store for the [`appPreferences` guide example](../renderer-extension#apppreferences), which demonstrates how to add a custom preference to the Preferences page.
|
|
||||||
The preference is a simple boolean that indicates whether something is enabled or not.
|
|
||||||
The problem with that example is that the enabled state is not stored anywhere, and reverts to the default the next time Lens is started.
|
|
||||||
|
|
||||||
The following example code creates a store for the `appPreferences` guide example:
|
The following example code creates a store for the `appPreferences` guide example:
|
||||||
|
|
||||||
@ -53,25 +51,14 @@ export class ExamplePreferencesStore extends Store.ExtensionStore<ExamplePrefere
|
|||||||
export const examplePreferencesStore = ExamplePreferencesStore.getInstance<ExamplePreferencesStore>();
|
export const examplePreferencesStore = ExamplePreferencesStore.getInstance<ExamplePreferencesStore>();
|
||||||
```
|
```
|
||||||
|
|
||||||
First the extension's data model is defined using a simple type, `ExamplePreferencesModel`, which has a single field, `enabled`, representing the preference's state.
|
First, our example defines the extension's data model using the simple `ExamplePreferencesModel` type. This has a single field, `enabled`, which represents the preference's state. `ExamplePreferencesStore` extends `Store.ExtensionStore`, which is based on the `ExamplePreferencesModel`. The `enabled` field is added to the `ExamplePreferencesStore` class to hold the "live" or current state of the preference. Note the use of the `observable` decorator on the `enabled` field. The [`appPreferences`](../renderer-extension#apppreferences) guide example uses [MobX](https://mobx.js.org/README.html) for the UI state management, ensuring the checkbox updates when it's activated by the user.
|
||||||
`ExamplePreferencesStore` extends `Store.ExtensionStore`, based on the `ExamplePreferencesModel`.
|
|
||||||
The field `enabled` is added to the `ExamplePreferencesStore` class to hold the "live" or current state of the preference.
|
|
||||||
Note the use of the `observer` decorator on the `enabled` field.
|
|
||||||
As for the [`appPreferences` guide example](../renderer-extension#apppreferences), [`mobx`](https://mobx.js.org/README.html) is used for the UI state management, ensuring the checkbox updates when activated by the user.
|
|
||||||
|
|
||||||
Then the constructor and two abstract methods are implemented.
|
Next, our example implements the constructor and two abstract methods. The constructor specifies the name of the store (`"example-preferences-store"`) and the default (initial) value for the preference state (`enabled: false`). Lens internals call the `fromStore()` method when the store loads. It gives the extension the opportunity to retrieve the stored state data values based on the defined data model. The `enabled` field of the `ExamplePreferencesStore` is set to the value from the store whenever `fromStore()` is invoked. The `toJSON()` method is complementary to `fromStore()`. It is called when the store is being saved.
|
||||||
In the constructor, the name of the store (`"example-preferences-store"`), and the default (initial) value for the preference state (`enabled: false`) are specified.
|
`toJSON()` must provide a JSON serializable object, facilitating its storage in JSON format. The `toJS()` function from [`mobx`](https://mobx.js.org/README.html) is convenient for this purpose, and is used here.
|
||||||
The `fromStore()` method is called by Lens internals when the store is loaded, and gives the extension the opportunity to retrieve the stored state data values based on the defined data model.
|
|
||||||
Here, the `enabled` field of the `ExamplePreferencesStore` is set to the value from the store whenever `fromStore()` is invoked.
|
|
||||||
The `toJSON()` method is complementary to `fromStore()`, and is called when the store is being saved.
|
|
||||||
`toJSON()` must provide a JSON serializable object, facilitating its storage in JSON format.
|
|
||||||
The `toJS()` function from [`mobx`](https://mobx.js.org/README.html) is convenient for this purpose, and is used here.
|
|
||||||
|
|
||||||
Finally, `examplePreferencesStore` is created by calling `ExamplePreferencesStore.getInstance<ExamplePreferencesStore>()`, and exported for use by other parts of the extension.
|
Finally, `examplePreferencesStore` is created by calling `ExamplePreferencesStore.getInstance<ExamplePreferencesStore>()`, and exported for use by other parts of the extension. Note that `examplePreferencesStore` is a singleton. Calling this function again will not create a new store.
|
||||||
Note that `examplePreferencesStore` is a singleton, calling this function again will not create a new store.
|
|
||||||
|
|
||||||
The following example code, modified from the [`appPreferences` guide example](../renderer-extension#apppreferences) demonstrates how to use the extension store.
|
The following example code, modified from the [`appPreferences`](../renderer-extension#apppreferences) guide demonstrates how to use the extension store. `examplePreferencesStore` must be loaded in the main process, where loaded stores are automatically saved when exiting Lens. This can be done in `./main.ts`:
|
||||||
`examplePreferencesStore` must be loaded in the main process, where loaded stores are automatically saved when exiting Lens. This can be done in `./main.ts`:
|
|
||||||
|
|
||||||
``` typescript
|
``` typescript
|
||||||
import { LensMainExtension } from "@k8slens/extensions";
|
import { LensMainExtension } from "@k8slens/extensions";
|
||||||
@ -84,8 +71,8 @@ export default class ExampleMainExtension extends LensMainExtension {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Here, `examplePreferencesStore` is loaded with `examplePreferencesStore.loadExtension(this)`, which is conveniently called from the `onActivate()` method of `ExampleMainExtension`.
|
Here, `examplePreferencesStore` loads with `examplePreferencesStore.loadExtension(this)`, which is conveniently called from the `onActivate()` method of `ExampleMainExtension`.
|
||||||
Similarly, `examplePreferencesStore` must be loaded in the renderer process where the `appPreferences` are handled. This can be done in `./renderer.ts`:
|
Similarly, `examplePreferencesStore` must load in the renderer process where the `appPreferences` are handled. This can be done in `./renderer.ts`:
|
||||||
|
|
||||||
``` typescript
|
``` typescript
|
||||||
import { LensRendererExtension } from "@k8slens/extensions";
|
import { LensRendererExtension } from "@k8slens/extensions";
|
||||||
@ -111,8 +98,7 @@ export default class ExampleRendererExtension extends LensRendererExtension {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Again, `examplePreferencesStore.loadExtension(this)` is called to load `examplePreferencesStore`, this time from the `onActivate()` method of `ExampleRendererExtension`.
|
Again, `examplePreferencesStore.loadExtension(this)` is called to load `examplePreferencesStore`, this time from the `onActivate()` method of `ExampleRendererExtension`. There is no longer the need for the `preference` field in the `ExampleRendererExtension` class because the props for `ExamplePreferenceInput` is now `examplePreferencesStore`.
|
||||||
Also, there is no longer the need for the `preference` field in the `ExampleRendererExtension` class, as the props for `ExamplePreferenceInput` is now `examplePreferencesStore`.
|
|
||||||
`ExamplePreferenceInput` is defined in `./src/example-preference.tsx`:
|
`ExamplePreferenceInput` is defined in `./src/example-preference.tsx`:
|
||||||
|
|
||||||
``` typescript
|
``` typescript
|
||||||
@ -151,5 +137,5 @@ export class ExamplePreferenceHint extends React.Component {
|
|||||||
```
|
```
|
||||||
|
|
||||||
The only change here is that `ExamplePreferenceProps` defines its `preference` field as an `ExamplePreferencesStore` type.
|
The only change here is that `ExamplePreferenceProps` defines its `preference` field as an `ExamplePreferencesStore` type.
|
||||||
Everything else works as before except now the `enabled` state persists across Lens restarts because it is managed by the
|
Everything else works as before, except that now the `enabled` state persists across Lens restarts because it is managed by the
|
||||||
`examplePreferencesStore`.
|
`examplePreferencesStore`.
|
||||||
@ -1,23 +1,26 @@
|
|||||||
# Working with mobx
|
# Working with MobX
|
||||||
|
|
||||||
## Introduction
|
## Introduction
|
||||||
|
|
||||||
Lens uses `mobx` as its state manager on top of React's state management system.
|
Lens uses MobX on top of React's state management system.
|
||||||
This helps with having a more declarative style of managing state, as opposed to `React`'s native `setState` mechanism.
|
The result is a more declarative state management style, rather than React's native `setState` mechanism.
|
||||||
You should already have a basic understanding of how `React` handles state ([read here](https://reactjs.org/docs/faq-state.html) for more information).
|
|
||||||
However, if you do not, here is a quick overview.
|
|
||||||
|
|
||||||
- A `React.Component` is generic over both `Props` and `State` (with default empty object types).
|
You can review how React handles state management [here](https://reactjs.org/docs/faq-state.html).
|
||||||
- `Props` should be considered read-only from the point of view of the component and is the mechanism for passing in "arguments" to a component.
|
|
||||||
- `State` is a component's internal state and can be read by accessing the parent field `state`.
|
|
||||||
- `State` **must** be updated using the `setState` parent method which merges the new data with the old state.
|
|
||||||
- `React` does do some optimizations around re-rendering components after quick successions of `setState` calls.
|
|
||||||
|
|
||||||
## How mobx works:
|
The following is a quick overview:
|
||||||
|
|
||||||
`mobx` is a package that provides an abstraction over `React`'s state management. The three main concepts are:
|
* `React.Component` is generic with respect to both `props` and `state` (which default to the empty object type).
|
||||||
- `observable`: data stored in the component's `state`
|
* `props` should be considered read-only from the point of view of the component, and it is the mechanism for passing in arguments to a component.
|
||||||
- `action`: a function that modifies any `observable` data
|
* `state` is a component's internal state, and can be read by accessing the super-class field `state`.
|
||||||
- `computed`: data that is derived from `observable` data but is not actually stored. Think of this as computing `isEmpty` vs an `observable` field called `count`.
|
* `state` **must** be updated using the `setState` parent method which merges the new data with the old state.
|
||||||
|
* React does some optimizations around re-rendering components after quick successions of `setState` calls.
|
||||||
|
|
||||||
Further reading is available from `mobx`'s [website](https://mobx.js.org/the-gist-of-mobx.html).
|
## How MobX Works:
|
||||||
|
|
||||||
|
MobX is a package that provides an abstraction over React's state management system. The three main concepts are:
|
||||||
|
|
||||||
|
* `observable` is a marker for data stored in the component's `state`.
|
||||||
|
* `action` is a function that modifies any `observable` data.
|
||||||
|
* `computed` is a marker for data that is derived from `observable` data, but that is not actually stored. Think of this as computing `isEmpty` rather than an observable field called `count`.
|
||||||
|
|
||||||
|
Further reading is available on the [MobX website](https://mobx.js.org/the-gist-of-mobx.html).
|
||||||
|
|||||||
@ -10,7 +10,7 @@ For example, I have a component `GlobalPageMenuIcon` and want to test if `props.
|
|||||||
|
|
||||||
My component `GlobalPageMenuIcon`
|
My component `GlobalPageMenuIcon`
|
||||||
|
|
||||||
```tsx
|
```typescript
|
||||||
import React from "react"
|
import React from "react"
|
||||||
import { Component: { Icon } } from "@k8slens/extensions";
|
import { Component: { Icon } } from "@k8slens/extensions";
|
||||||
|
|
||||||
|
|||||||
@ -5,7 +5,7 @@ Lens is lightweight and simple to install. You'll be up and running in just a fe
|
|||||||
|
|
||||||
## System Requirements
|
## System Requirements
|
||||||
|
|
||||||
Review the [System Requirements](/supporting/requirements/) to check if your computer configuration is supported.
|
Review the [System Requirements](../supporting/requirements.md) to check if your computer configuration is supported.
|
||||||
|
|
||||||
|
|
||||||
## macOS
|
## macOS
|
||||||
|
|||||||
@ -4,7 +4,7 @@ Lens has integration to Helm making it easy to install and manage Helm charts an
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
## Managing Helm Reporistories
|
## Managing Helm Repositories
|
||||||
|
|
||||||
Used Helm repositories are possible to configure in the [Preferences](/getting-started/preferences). Lens app will fetch available Helm repositories from the [Artifact HUB](https://artifacthub.io/) and automatically add `bitnami` repository by default if no other repositories are already configured. If any other repositories are needed to add, those can be added manually via command line. **Note!** Configured Helm repositories are added globally to user's computer, so other processes can see those as well.
|
Used Helm repositories are possible to configure in the [Preferences](/getting-started/preferences). Lens app will fetch available Helm repositories from the [Artifact HUB](https://artifacthub.io/) and automatically add `bitnami` repository by default if no other repositories are already configured. If any other repositories are needed to add, those can be added manually via command line. **Note!** Configured Helm repositories are added globally to user's computer, so other processes can see those as well.
|
||||||
|
|
||||||
|
|||||||
17
extensions/example-extension/package-lock.json
generated
17
extensions/example-extension/package-lock.json
generated
@ -2796,7 +2796,8 @@
|
|||||||
"version": "1.3.0",
|
"version": "1.3.0",
|
||||||
"resolved": "https://registry.npmjs.org/growly/-/growly-1.3.0.tgz",
|
"resolved": "https://registry.npmjs.org/growly/-/growly-1.3.0.tgz",
|
||||||
"integrity": "sha1-8QdIy+dq+WS3yWyTxrzCivEgwIE=",
|
"integrity": "sha1-8QdIy+dq+WS3yWyTxrzCivEgwIE=",
|
||||||
"dev": true
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
},
|
},
|
||||||
"har-schema": {
|
"har-schema": {
|
||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
@ -3226,6 +3227,7 @@
|
|||||||
"resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-2.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-2.2.0.tgz",
|
||||||
"integrity": "sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==",
|
"integrity": "sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"is-docker": "^2.0.0"
|
"is-docker": "^2.0.0"
|
||||||
}
|
}
|
||||||
@ -4367,6 +4369,7 @@
|
|||||||
"resolved": "https://registry.npmjs.org/node-notifier/-/node-notifier-8.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/node-notifier/-/node-notifier-8.0.1.tgz",
|
||||||
"integrity": "sha512-BvEXF+UmsnAfYfoapKM9nGxnP+Wn7P91YfXmrKnfcYCx6VBeoN5Ez5Ogck6I8Bi5k4RlpqRYaw75pAwzX9OphA==",
|
"integrity": "sha512-BvEXF+UmsnAfYfoapKM9nGxnP+Wn7P91YfXmrKnfcYCx6VBeoN5Ez5Ogck6I8Bi5k4RlpqRYaw75pAwzX9OphA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"growly": "^1.3.0",
|
"growly": "^1.3.0",
|
||||||
"is-wsl": "^2.2.0",
|
"is-wsl": "^2.2.0",
|
||||||
@ -4381,6 +4384,7 @@
|
|||||||
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz",
|
||||||
"integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==",
|
"integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"yallist": "^4.0.0"
|
"yallist": "^4.0.0"
|
||||||
}
|
}
|
||||||
@ -4390,6 +4394,7 @@
|
|||||||
"resolved": "https://registry.npmjs.org/semver/-/semver-7.3.4.tgz",
|
"resolved": "https://registry.npmjs.org/semver/-/semver-7.3.4.tgz",
|
||||||
"integrity": "sha512-tCfb2WLjqFAtXn4KEdxIhalnRtoKFN7nAwj0B3ZXCbQloV2tq5eDbcTmT68JJD3nRJq24/XgxtQKFIpQdtvmVw==",
|
"integrity": "sha512-tCfb2WLjqFAtXn4KEdxIhalnRtoKFN7nAwj0B3ZXCbQloV2tq5eDbcTmT68JJD3nRJq24/XgxtQKFIpQdtvmVw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"lru-cache": "^6.0.0"
|
"lru-cache": "^6.0.0"
|
||||||
}
|
}
|
||||||
@ -4399,6 +4404,7 @@
|
|||||||
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
|
||||||
"integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==",
|
"integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"isexe": "^2.0.0"
|
"isexe": "^2.0.0"
|
||||||
}
|
}
|
||||||
@ -4407,7 +4413,8 @@
|
|||||||
"version": "4.0.0",
|
"version": "4.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz",
|
||||||
"integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==",
|
"integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==",
|
||||||
"dev": true
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -5398,7 +5405,8 @@
|
|||||||
"version": "0.1.1",
|
"version": "0.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/shellwords/-/shellwords-0.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/shellwords/-/shellwords-0.1.1.tgz",
|
||||||
"integrity": "sha512-vFwSUfQvqybiICwZY5+DAWIPLKsWO31Q91JSKl3UYv+K5c2QRPzn0qzec6QPu1Qc9eHYItiP3NdJqNVqetYAww==",
|
"integrity": "sha512-vFwSUfQvqybiICwZY5+DAWIPLKsWO31Q91JSKl3UYv+K5c2QRPzn0qzec6QPu1Qc9eHYItiP3NdJqNVqetYAww==",
|
||||||
"dev": true
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
},
|
},
|
||||||
"signal-exit": {
|
"signal-exit": {
|
||||||
"version": "3.0.3",
|
"version": "3.0.3",
|
||||||
@ -6275,7 +6283,8 @@
|
|||||||
"version": "8.3.1",
|
"version": "8.3.1",
|
||||||
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.1.tgz",
|
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.1.tgz",
|
||||||
"integrity": "sha512-FOmRr+FmWEIG8uhZv6C2bTgEVXsHk08kE7mPlrBbEe+c3r9pjceVPgupIfNIhc4yx55H69OXANrUaSuu9eInKg==",
|
"integrity": "sha512-FOmRr+FmWEIG8uhZv6C2bTgEVXsHk08kE7mPlrBbEe+c3r9pjceVPgupIfNIhc4yx55H69OXANrUaSuu9eInKg==",
|
||||||
"dev": true
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
},
|
},
|
||||||
"v8-to-istanbul": {
|
"v8-to-istanbul": {
|
||||||
"version": "7.0.0",
|
"version": "7.0.0",
|
||||||
|
|||||||
17
extensions/license-menu-item/package-lock.json
generated
17
extensions/license-menu-item/package-lock.json
generated
@ -2868,7 +2868,8 @@
|
|||||||
"version": "1.3.0",
|
"version": "1.3.0",
|
||||||
"resolved": "https://registry.npmjs.org/growly/-/growly-1.3.0.tgz",
|
"resolved": "https://registry.npmjs.org/growly/-/growly-1.3.0.tgz",
|
||||||
"integrity": "sha1-8QdIy+dq+WS3yWyTxrzCivEgwIE=",
|
"integrity": "sha1-8QdIy+dq+WS3yWyTxrzCivEgwIE=",
|
||||||
"dev": true
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
},
|
},
|
||||||
"har-schema": {
|
"har-schema": {
|
||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
@ -3298,6 +3299,7 @@
|
|||||||
"resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-2.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-2.2.0.tgz",
|
||||||
"integrity": "sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==",
|
"integrity": "sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"is-docker": "^2.0.0"
|
"is-docker": "^2.0.0"
|
||||||
}
|
}
|
||||||
@ -4460,6 +4462,7 @@
|
|||||||
"resolved": "https://registry.npmjs.org/node-notifier/-/node-notifier-8.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/node-notifier/-/node-notifier-8.0.1.tgz",
|
||||||
"integrity": "sha512-BvEXF+UmsnAfYfoapKM9nGxnP+Wn7P91YfXmrKnfcYCx6VBeoN5Ez5Ogck6I8Bi5k4RlpqRYaw75pAwzX9OphA==",
|
"integrity": "sha512-BvEXF+UmsnAfYfoapKM9nGxnP+Wn7P91YfXmrKnfcYCx6VBeoN5Ez5Ogck6I8Bi5k4RlpqRYaw75pAwzX9OphA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"growly": "^1.3.0",
|
"growly": "^1.3.0",
|
||||||
"is-wsl": "^2.2.0",
|
"is-wsl": "^2.2.0",
|
||||||
@ -4474,6 +4477,7 @@
|
|||||||
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz",
|
||||||
"integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==",
|
"integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"yallist": "^4.0.0"
|
"yallist": "^4.0.0"
|
||||||
}
|
}
|
||||||
@ -4483,6 +4487,7 @@
|
|||||||
"resolved": "https://registry.npmjs.org/semver/-/semver-7.3.4.tgz",
|
"resolved": "https://registry.npmjs.org/semver/-/semver-7.3.4.tgz",
|
||||||
"integrity": "sha512-tCfb2WLjqFAtXn4KEdxIhalnRtoKFN7nAwj0B3ZXCbQloV2tq5eDbcTmT68JJD3nRJq24/XgxtQKFIpQdtvmVw==",
|
"integrity": "sha512-tCfb2WLjqFAtXn4KEdxIhalnRtoKFN7nAwj0B3ZXCbQloV2tq5eDbcTmT68JJD3nRJq24/XgxtQKFIpQdtvmVw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"lru-cache": "^6.0.0"
|
"lru-cache": "^6.0.0"
|
||||||
}
|
}
|
||||||
@ -4492,6 +4497,7 @@
|
|||||||
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
|
||||||
"integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==",
|
"integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"isexe": "^2.0.0"
|
"isexe": "^2.0.0"
|
||||||
}
|
}
|
||||||
@ -4500,7 +4506,8 @@
|
|||||||
"version": "4.0.0",
|
"version": "4.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz",
|
||||||
"integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==",
|
"integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==",
|
||||||
"dev": true
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -5516,7 +5523,8 @@
|
|||||||
"version": "0.1.1",
|
"version": "0.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/shellwords/-/shellwords-0.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/shellwords/-/shellwords-0.1.1.tgz",
|
||||||
"integrity": "sha512-vFwSUfQvqybiICwZY5+DAWIPLKsWO31Q91JSKl3UYv+K5c2QRPzn0qzec6QPu1Qc9eHYItiP3NdJqNVqetYAww==",
|
"integrity": "sha512-vFwSUfQvqybiICwZY5+DAWIPLKsWO31Q91JSKl3UYv+K5c2QRPzn0qzec6QPu1Qc9eHYItiP3NdJqNVqetYAww==",
|
||||||
"dev": true
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
},
|
},
|
||||||
"signal-exit": {
|
"signal-exit": {
|
||||||
"version": "3.0.3",
|
"version": "3.0.3",
|
||||||
@ -6406,7 +6414,8 @@
|
|||||||
"version": "8.3.1",
|
"version": "8.3.1",
|
||||||
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.1.tgz",
|
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.1.tgz",
|
||||||
"integrity": "sha512-FOmRr+FmWEIG8uhZv6C2bTgEVXsHk08kE7mPlrBbEe+c3r9pjceVPgupIfNIhc4yx55H69OXANrUaSuu9eInKg==",
|
"integrity": "sha512-FOmRr+FmWEIG8uhZv6C2bTgEVXsHk08kE7mPlrBbEe+c3r9pjceVPgupIfNIhc4yx55H69OXANrUaSuu9eInKg==",
|
||||||
"dev": true
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
},
|
},
|
||||||
"v8-to-istanbul": {
|
"v8-to-istanbul": {
|
||||||
"version": "7.0.0",
|
"version": "7.0.0",
|
||||||
|
|||||||
12
extensions/metrics-cluster-feature/package-lock.json
generated
12
extensions/metrics-cluster-feature/package-lock.json
generated
@ -2816,7 +2816,8 @@
|
|||||||
"version": "1.3.0",
|
"version": "1.3.0",
|
||||||
"resolved": "https://registry.npmjs.org/growly/-/growly-1.3.0.tgz",
|
"resolved": "https://registry.npmjs.org/growly/-/growly-1.3.0.tgz",
|
||||||
"integrity": "sha1-8QdIy+dq+WS3yWyTxrzCivEgwIE=",
|
"integrity": "sha1-8QdIy+dq+WS3yWyTxrzCivEgwIE=",
|
||||||
"dev": true
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
},
|
},
|
||||||
"har-schema": {
|
"har-schema": {
|
||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
@ -3246,6 +3247,7 @@
|
|||||||
"resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-2.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-2.2.0.tgz",
|
||||||
"integrity": "sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==",
|
"integrity": "sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"is-docker": "^2.0.0"
|
"is-docker": "^2.0.0"
|
||||||
}
|
}
|
||||||
@ -4394,6 +4396,7 @@
|
|||||||
"resolved": "https://registry.npmjs.org/node-notifier/-/node-notifier-8.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/node-notifier/-/node-notifier-8.0.1.tgz",
|
||||||
"integrity": "sha512-BvEXF+UmsnAfYfoapKM9nGxnP+Wn7P91YfXmrKnfcYCx6VBeoN5Ez5Ogck6I8Bi5k4RlpqRYaw75pAwzX9OphA==",
|
"integrity": "sha512-BvEXF+UmsnAfYfoapKM9nGxnP+Wn7P91YfXmrKnfcYCx6VBeoN5Ez5Ogck6I8Bi5k4RlpqRYaw75pAwzX9OphA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"growly": "^1.3.0",
|
"growly": "^1.3.0",
|
||||||
"is-wsl": "^2.2.0",
|
"is-wsl": "^2.2.0",
|
||||||
@ -4408,6 +4411,7 @@
|
|||||||
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
|
||||||
"integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==",
|
"integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"isexe": "^2.0.0"
|
"isexe": "^2.0.0"
|
||||||
}
|
}
|
||||||
@ -5434,7 +5438,8 @@
|
|||||||
"version": "0.1.1",
|
"version": "0.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/shellwords/-/shellwords-0.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/shellwords/-/shellwords-0.1.1.tgz",
|
||||||
"integrity": "sha512-vFwSUfQvqybiICwZY5+DAWIPLKsWO31Q91JSKl3UYv+K5c2QRPzn0qzec6QPu1Qc9eHYItiP3NdJqNVqetYAww==",
|
"integrity": "sha512-vFwSUfQvqybiICwZY5+DAWIPLKsWO31Q91JSKl3UYv+K5c2QRPzn0qzec6QPu1Qc9eHYItiP3NdJqNVqetYAww==",
|
||||||
"dev": true
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
},
|
},
|
||||||
"signal-exit": {
|
"signal-exit": {
|
||||||
"version": "3.0.3",
|
"version": "3.0.3",
|
||||||
@ -6311,7 +6316,8 @@
|
|||||||
"version": "8.3.1",
|
"version": "8.3.1",
|
||||||
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.1.tgz",
|
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.1.tgz",
|
||||||
"integrity": "sha512-FOmRr+FmWEIG8uhZv6C2bTgEVXsHk08kE7mPlrBbEe+c3r9pjceVPgupIfNIhc4yx55H69OXANrUaSuu9eInKg==",
|
"integrity": "sha512-FOmRr+FmWEIG8uhZv6C2bTgEVXsHk08kE7mPlrBbEe+c3r9pjceVPgupIfNIhc4yx55H69OXANrUaSuu9eInKg==",
|
||||||
"dev": true
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
},
|
},
|
||||||
"v8-to-istanbul": {
|
"v8-to-istanbul": {
|
||||||
"version": "7.0.0",
|
"version": "7.0.0",
|
||||||
|
|||||||
17
extensions/node-menu/package-lock.json
generated
17
extensions/node-menu/package-lock.json
generated
@ -2796,7 +2796,8 @@
|
|||||||
"version": "1.3.0",
|
"version": "1.3.0",
|
||||||
"resolved": "https://registry.npmjs.org/growly/-/growly-1.3.0.tgz",
|
"resolved": "https://registry.npmjs.org/growly/-/growly-1.3.0.tgz",
|
||||||
"integrity": "sha1-8QdIy+dq+WS3yWyTxrzCivEgwIE=",
|
"integrity": "sha1-8QdIy+dq+WS3yWyTxrzCivEgwIE=",
|
||||||
"dev": true
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
},
|
},
|
||||||
"har-schema": {
|
"har-schema": {
|
||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
@ -3226,6 +3227,7 @@
|
|||||||
"resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-2.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-2.2.0.tgz",
|
||||||
"integrity": "sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==",
|
"integrity": "sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"is-docker": "^2.0.0"
|
"is-docker": "^2.0.0"
|
||||||
}
|
}
|
||||||
@ -4382,6 +4384,7 @@
|
|||||||
"resolved": "https://registry.npmjs.org/node-notifier/-/node-notifier-8.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/node-notifier/-/node-notifier-8.0.1.tgz",
|
||||||
"integrity": "sha512-BvEXF+UmsnAfYfoapKM9nGxnP+Wn7P91YfXmrKnfcYCx6VBeoN5Ez5Ogck6I8Bi5k4RlpqRYaw75pAwzX9OphA==",
|
"integrity": "sha512-BvEXF+UmsnAfYfoapKM9nGxnP+Wn7P91YfXmrKnfcYCx6VBeoN5Ez5Ogck6I8Bi5k4RlpqRYaw75pAwzX9OphA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"growly": "^1.3.0",
|
"growly": "^1.3.0",
|
||||||
"is-wsl": "^2.2.0",
|
"is-wsl": "^2.2.0",
|
||||||
@ -4396,6 +4399,7 @@
|
|||||||
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz",
|
||||||
"integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==",
|
"integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"yallist": "^4.0.0"
|
"yallist": "^4.0.0"
|
||||||
}
|
}
|
||||||
@ -4405,6 +4409,7 @@
|
|||||||
"resolved": "https://registry.npmjs.org/semver/-/semver-7.3.4.tgz",
|
"resolved": "https://registry.npmjs.org/semver/-/semver-7.3.4.tgz",
|
||||||
"integrity": "sha512-tCfb2WLjqFAtXn4KEdxIhalnRtoKFN7nAwj0B3ZXCbQloV2tq5eDbcTmT68JJD3nRJq24/XgxtQKFIpQdtvmVw==",
|
"integrity": "sha512-tCfb2WLjqFAtXn4KEdxIhalnRtoKFN7nAwj0B3ZXCbQloV2tq5eDbcTmT68JJD3nRJq24/XgxtQKFIpQdtvmVw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"lru-cache": "^6.0.0"
|
"lru-cache": "^6.0.0"
|
||||||
}
|
}
|
||||||
@ -4414,6 +4419,7 @@
|
|||||||
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
|
||||||
"integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==",
|
"integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"isexe": "^2.0.0"
|
"isexe": "^2.0.0"
|
||||||
}
|
}
|
||||||
@ -4422,7 +4428,8 @@
|
|||||||
"version": "4.0.0",
|
"version": "4.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz",
|
||||||
"integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==",
|
"integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==",
|
||||||
"dev": true
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -5438,7 +5445,8 @@
|
|||||||
"version": "0.1.1",
|
"version": "0.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/shellwords/-/shellwords-0.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/shellwords/-/shellwords-0.1.1.tgz",
|
||||||
"integrity": "sha512-vFwSUfQvqybiICwZY5+DAWIPLKsWO31Q91JSKl3UYv+K5c2QRPzn0qzec6QPu1Qc9eHYItiP3NdJqNVqetYAww==",
|
"integrity": "sha512-vFwSUfQvqybiICwZY5+DAWIPLKsWO31Q91JSKl3UYv+K5c2QRPzn0qzec6QPu1Qc9eHYItiP3NdJqNVqetYAww==",
|
||||||
"dev": true
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
},
|
},
|
||||||
"signal-exit": {
|
"signal-exit": {
|
||||||
"version": "3.0.3",
|
"version": "3.0.3",
|
||||||
@ -6315,7 +6323,8 @@
|
|||||||
"version": "8.3.1",
|
"version": "8.3.1",
|
||||||
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.1.tgz",
|
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.1.tgz",
|
||||||
"integrity": "sha512-FOmRr+FmWEIG8uhZv6C2bTgEVXsHk08kE7mPlrBbEe+c3r9pjceVPgupIfNIhc4yx55H69OXANrUaSuu9eInKg==",
|
"integrity": "sha512-FOmRr+FmWEIG8uhZv6C2bTgEVXsHk08kE7mPlrBbEe+c3r9pjceVPgupIfNIhc4yx55H69OXANrUaSuu9eInKg==",
|
||||||
"dev": true
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
},
|
},
|
||||||
"v8-to-istanbul": {
|
"v8-to-istanbul": {
|
||||||
"version": "7.0.0",
|
"version": "7.0.0",
|
||||||
|
|||||||
656
extensions/pod-menu/package-lock.json
generated
656
extensions/pod-menu/package-lock.json
generated
@ -626,7 +626,644 @@
|
|||||||
},
|
},
|
||||||
"@k8slens/extensions": {
|
"@k8slens/extensions": {
|
||||||
"version": "file:../../src/extensions/npm/extensions",
|
"version": "file:../../src/extensions/npm/extensions",
|
||||||
"dev": true
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"@material-ui/core": "*",
|
||||||
|
"@types/node": "*",
|
||||||
|
"@types/react-select": "*",
|
||||||
|
"conf": "^7.0.1"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@babel/runtime": {
|
||||||
|
"version": "7.12.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.12.5.tgz",
|
||||||
|
"integrity": "sha512-plcc+hbExy3McchJCEQG3knOsuh3HH+Prx1P6cLIkET/0dLuQDEnrT+s27Axgc9bqfsmNUNHfscgMUdBpC9xfg==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"regenerator-runtime": "^0.13.4"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"@emotion/hash": {
|
||||||
|
"version": "0.8.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@emotion/hash/-/hash-0.8.0.tgz",
|
||||||
|
"integrity": "sha512-kBJtf7PH6aWwZ6fka3zQ0p6SBYzx4fl1LoZXE2RrnYST9Xljm7WfKJrU4g/Xr3Beg72MLrp1AWNUmuYJTL7Cow==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
|
"@material-ui/core": {
|
||||||
|
"version": "4.11.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/@material-ui/core/-/core-4.11.2.tgz",
|
||||||
|
"integrity": "sha512-/D1+AQQeYX/WhT/FUk78UCRj8ch/RCglsQLYujYTIqPSJlwZHKcvHidNeVhODXeApojeXjkl0tWdk5C9ofwOkQ==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"@babel/runtime": "^7.4.4",
|
||||||
|
"@material-ui/styles": "^4.11.2",
|
||||||
|
"@material-ui/system": "^4.11.2",
|
||||||
|
"@material-ui/types": "^5.1.0",
|
||||||
|
"@material-ui/utils": "^4.11.2",
|
||||||
|
"@types/react-transition-group": "^4.2.0",
|
||||||
|
"clsx": "^1.0.4",
|
||||||
|
"hoist-non-react-statics": "^3.3.2",
|
||||||
|
"popper.js": "1.16.1-lts",
|
||||||
|
"prop-types": "^15.7.2",
|
||||||
|
"react-is": "^16.8.0 || ^17.0.0",
|
||||||
|
"react-transition-group": "^4.4.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"@material-ui/styles": {
|
||||||
|
"version": "4.11.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/@material-ui/styles/-/styles-4.11.2.tgz",
|
||||||
|
"integrity": "sha512-xbItf8zkfD3FuGoD9f2vlcyPf9jTEtj9YTJoNNV+NMWaSAHXgrW6geqRoo/IwBuMjqpwqsZhct13e2nUyU9Ljw==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"@babel/runtime": "^7.4.4",
|
||||||
|
"@emotion/hash": "^0.8.0",
|
||||||
|
"@material-ui/types": "^5.1.0",
|
||||||
|
"@material-ui/utils": "^4.11.2",
|
||||||
|
"clsx": "^1.0.4",
|
||||||
|
"csstype": "^2.5.2",
|
||||||
|
"hoist-non-react-statics": "^3.3.2",
|
||||||
|
"jss": "^10.0.3",
|
||||||
|
"jss-plugin-camel-case": "^10.0.3",
|
||||||
|
"jss-plugin-default-unit": "^10.0.3",
|
||||||
|
"jss-plugin-global": "^10.0.3",
|
||||||
|
"jss-plugin-nested": "^10.0.3",
|
||||||
|
"jss-plugin-props-sort": "^10.0.3",
|
||||||
|
"jss-plugin-rule-value-function": "^10.0.3",
|
||||||
|
"jss-plugin-vendor-prefixer": "^10.0.3",
|
||||||
|
"prop-types": "^15.7.2"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"@material-ui/system": {
|
||||||
|
"version": "4.11.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/@material-ui/system/-/system-4.11.2.tgz",
|
||||||
|
"integrity": "sha512-BELFJEel5E+5DMiZb6XXT3peWRn6UixRvBtKwSxqntmD0+zwbbfCij6jtGwwdJhN1qX/aXrKu10zX31GBaeR7A==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"@babel/runtime": "^7.4.4",
|
||||||
|
"@material-ui/utils": "^4.11.2",
|
||||||
|
"csstype": "^2.5.2",
|
||||||
|
"prop-types": "^15.7.2"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"@material-ui/types": {
|
||||||
|
"version": "5.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@material-ui/types/-/types-5.1.0.tgz",
|
||||||
|
"integrity": "sha512-7cqRjrY50b8QzRSYyhSpx4WRw2YuO0KKIGQEVk5J8uoz2BanawykgZGoWEqKm7pVIbzFDN0SpPcVV4IhOFkl8A==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
|
"@material-ui/utils": {
|
||||||
|
"version": "4.11.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/@material-ui/utils/-/utils-4.11.2.tgz",
|
||||||
|
"integrity": "sha512-Uul8w38u+PICe2Fg2pDKCaIG7kOyhowZ9vjiC1FsVwPABTW8vPPKfF6OvxRq3IiBaI1faOJmgdvMG7rMJARBhA==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"@babel/runtime": "^7.4.4",
|
||||||
|
"prop-types": "^15.7.2",
|
||||||
|
"react-is": "^16.8.0 || ^17.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"@types/node": {
|
||||||
|
"version": "14.14.21",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/node/-/node-14.14.21.tgz",
|
||||||
|
"integrity": "sha512-cHYfKsnwllYhjOzuC5q1VpguABBeecUp24yFluHpn/BQaVxB1CuQ1FSRZCzrPxrkIfWISXV2LbeoBthLWg0+0A==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
|
"@types/prop-types": {
|
||||||
|
"version": "15.7.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.3.tgz",
|
||||||
|
"integrity": "sha512-KfRL3PuHmqQLOG+2tGpRO26Ctg+Cq1E01D2DMriKEATHgWLfeNDmq9e29Q9WIky0dQ3NPkd1mzYH8Lm936Z9qw==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
|
"@types/react": {
|
||||||
|
"version": "17.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/react/-/react-17.0.0.tgz",
|
||||||
|
"integrity": "sha512-aj/L7RIMsRlWML3YB6KZiXB3fV2t41+5RBGYF8z+tAKU43Px8C3cYUZsDvf1/+Bm4FK21QWBrDutu8ZJ/70qOw==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"@types/prop-types": "*",
|
||||||
|
"csstype": "^3.0.2"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"csstype": {
|
||||||
|
"version": "3.0.6",
|
||||||
|
"resolved": "https://registry.npmjs.org/csstype/-/csstype-3.0.6.tgz",
|
||||||
|
"integrity": "sha512-+ZAmfyWMT7TiIlzdqJgjMb7S4f1beorDbWbsocyK4RaiqA5RTX3K14bnBWmmA9QEM0gRdsjyyrEmcyga8Zsxmw==",
|
||||||
|
"dev": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"@types/react-dom": {
|
||||||
|
"version": "17.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-17.0.0.tgz",
|
||||||
|
"integrity": "sha512-lUqY7OlkF/RbNtD5nIq7ot8NquXrdFrjSOR6+w9a9RFQevGi1oZO1dcJbXMeONAPKtZ2UrZOEJ5UOCVsxbLk/g==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"@types/react": "*"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"@types/react-select": {
|
||||||
|
"version": "3.1.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/react-select/-/react-select-3.1.2.tgz",
|
||||||
|
"integrity": "sha512-ygvR/2FL87R2OLObEWFootYzkvm67LRA+URYEAcBuvKk7IXmdsnIwSGm60cVXGaqkJQHozb2Cy1t94tCYb6rJA==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"@types/react": "*",
|
||||||
|
"@types/react-dom": "*",
|
||||||
|
"@types/react-transition-group": "*"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"@types/react-transition-group": {
|
||||||
|
"version": "4.4.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/react-transition-group/-/react-transition-group-4.4.0.tgz",
|
||||||
|
"integrity": "sha512-/QfLHGpu+2fQOqQaXh8MG9q03bFENooTb/it4jr5kKaZlDQfWvjqWZg48AwzPVMBHlRuTRAY7hRHCEOXz5kV6w==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"@types/react": "*"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"ajv": {
|
||||||
|
"version": "6.12.6",
|
||||||
|
"resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz",
|
||||||
|
"integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"fast-deep-equal": "^3.1.1",
|
||||||
|
"fast-json-stable-stringify": "^2.0.0",
|
||||||
|
"json-schema-traverse": "^0.4.1",
|
||||||
|
"uri-js": "^4.2.2"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"atomically": {
|
||||||
|
"version": "1.7.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/atomically/-/atomically-1.7.0.tgz",
|
||||||
|
"integrity": "sha512-Xcz9l0z7y9yQ9rdDaxlmaI4uJHf/T8g9hOEzJcsEqX2SjCj4J20uK7+ldkDHMbpJDK76wF7xEIgxc/vSlsfw5w==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
|
"clsx": {
|
||||||
|
"version": "1.1.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/clsx/-/clsx-1.1.1.tgz",
|
||||||
|
"integrity": "sha512-6/bPho624p3S2pMyvP5kKBPXnI3ufHLObBFCfgx+LkeR5lg2XYy2hqZqUf45ypD8COn2bhgGJSUE+l5dhNBieA==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
|
"conf": {
|
||||||
|
"version": "7.1.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/conf/-/conf-7.1.2.tgz",
|
||||||
|
"integrity": "sha512-r8/HEoWPFn4CztjhMJaWNAe5n+gPUCSaJ0oufbqDLFKsA1V8JjAG7G+p0pgoDFAws9Bpk2VtVLLXqOBA7WxLeg==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"ajv": "^6.12.2",
|
||||||
|
"atomically": "^1.3.1",
|
||||||
|
"debounce-fn": "^4.0.0",
|
||||||
|
"dot-prop": "^5.2.0",
|
||||||
|
"env-paths": "^2.2.0",
|
||||||
|
"json-schema-typed": "^7.0.3",
|
||||||
|
"make-dir": "^3.1.0",
|
||||||
|
"onetime": "^5.1.0",
|
||||||
|
"pkg-up": "^3.1.0",
|
||||||
|
"semver": "^7.3.2"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"css-vendor": {
|
||||||
|
"version": "2.0.8",
|
||||||
|
"resolved": "https://registry.npmjs.org/css-vendor/-/css-vendor-2.0.8.tgz",
|
||||||
|
"integrity": "sha512-x9Aq0XTInxrkuFeHKbYC7zWY8ai7qJ04Kxd9MnvbC1uO5DagxoHQjm4JvG+vCdXOoFtCjbL2XSZfxmoYa9uQVQ==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"@babel/runtime": "^7.8.3",
|
||||||
|
"is-in-browser": "^1.0.2"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"csstype": {
|
||||||
|
"version": "2.6.14",
|
||||||
|
"resolved": "https://registry.npmjs.org/csstype/-/csstype-2.6.14.tgz",
|
||||||
|
"integrity": "sha512-2mSc+VEpGPblzAxyeR+vZhJKgYg0Og0nnRi7pmRXFYYxSfnOnW8A5wwQb4n4cE2nIOzqKOAzLCaEX6aBmNEv8A==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
|
"debounce-fn": {
|
||||||
|
"version": "4.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/debounce-fn/-/debounce-fn-4.0.0.tgz",
|
||||||
|
"integrity": "sha512-8pYCQiL9Xdcg0UPSD3d+0KMlOjp+KGU5EPwYddgzQ7DATsg4fuUDjQtsYLmWjnk2obnNHgV3vE2Y4jejSOJVBQ==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"mimic-fn": "^3.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"dom-helpers": {
|
||||||
|
"version": "5.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/dom-helpers/-/dom-helpers-5.2.0.tgz",
|
||||||
|
"integrity": "sha512-Ru5o9+V8CpunKnz5LGgWXkmrH/20cGKwcHwS4m73zIvs54CN9epEmT/HLqFJW3kXpakAFkEdzgy1hzlJe3E4OQ==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"@babel/runtime": "^7.8.7",
|
||||||
|
"csstype": "^3.0.2"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"csstype": {
|
||||||
|
"version": "3.0.6",
|
||||||
|
"resolved": "https://registry.npmjs.org/csstype/-/csstype-3.0.6.tgz",
|
||||||
|
"integrity": "sha512-+ZAmfyWMT7TiIlzdqJgjMb7S4f1beorDbWbsocyK4RaiqA5RTX3K14bnBWmmA9QEM0gRdsjyyrEmcyga8Zsxmw==",
|
||||||
|
"dev": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"dot-prop": {
|
||||||
|
"version": "5.3.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/dot-prop/-/dot-prop-5.3.0.tgz",
|
||||||
|
"integrity": "sha512-QM8q3zDe58hqUqjraQOmzZ1LIH9SWQJTlEKCH4kJ2oQvLZk7RbQXvtDM2XEq3fwkV9CCvvH4LA0AV+ogFsBM2Q==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"is-obj": "^2.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"env-paths": {
|
||||||
|
"version": "2.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/env-paths/-/env-paths-2.2.0.tgz",
|
||||||
|
"integrity": "sha512-6u0VYSCo/OW6IoD5WCLLy9JUGARbamfSavcNXry/eu8aHVFei6CD3Sw+VGX5alea1i9pgPHW0mbu6Xj0uBh7gA==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
|
"fast-deep-equal": {
|
||||||
|
"version": "3.1.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz",
|
||||||
|
"integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
|
"fast-json-stable-stringify": {
|
||||||
|
"version": "2.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz",
|
||||||
|
"integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
|
"find-up": {
|
||||||
|
"version": "3.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz",
|
||||||
|
"integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"locate-path": "^3.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"hoist-non-react-statics": {
|
||||||
|
"version": "3.3.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/hoist-non-react-statics/-/hoist-non-react-statics-3.3.2.tgz",
|
||||||
|
"integrity": "sha512-/gGivxi8JPKWNm/W0jSmzcMPpfpPLc3dY/6GxhX2hQ9iGj3aDfklV4ET7NjKpSinLpJ5vafa9iiGIEZg10SfBw==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"react-is": "^16.7.0"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"react-is": {
|
||||||
|
"version": "16.13.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz",
|
||||||
|
"integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==",
|
||||||
|
"dev": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"hyphenate-style-name": {
|
||||||
|
"version": "1.0.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/hyphenate-style-name/-/hyphenate-style-name-1.0.4.tgz",
|
||||||
|
"integrity": "sha512-ygGZLjmXfPHj+ZWh6LwbC37l43MhfztxetbFCoYTM2VjkIUpeHgSNn7QIyVFj7YQ1Wl9Cbw5sholVJPzWvC2MQ==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
|
"indefinite-observable": {
|
||||||
|
"version": "2.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/indefinite-observable/-/indefinite-observable-2.0.1.tgz",
|
||||||
|
"integrity": "sha512-G8vgmork+6H9S8lUAg1gtXEj2JxIQTo0g2PbFiYOdjkziSI0F7UYBiVwhZRuixhBCNGczAls34+5HJPyZysvxQ==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"symbol-observable": "1.2.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"is-in-browser": {
|
||||||
|
"version": "1.1.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/is-in-browser/-/is-in-browser-1.1.3.tgz",
|
||||||
|
"integrity": "sha1-Vv9NtoOgeMYILrldrX3GLh0E+DU=",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
|
"is-obj": {
|
||||||
|
"version": "2.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/is-obj/-/is-obj-2.0.0.tgz",
|
||||||
|
"integrity": "sha512-drqDG3cbczxxEJRoOXcOjtdp1J/lyp1mNn0xaznRs8+muBhgQcrnbspox5X5fOw0HnMnbfDzvnEMEtqDEJEo8w==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
|
"js-tokens": {
|
||||||
|
"version": "4.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz",
|
||||||
|
"integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
|
"json-schema-traverse": {
|
||||||
|
"version": "0.4.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz",
|
||||||
|
"integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
|
"json-schema-typed": {
|
||||||
|
"version": "7.0.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/json-schema-typed/-/json-schema-typed-7.0.3.tgz",
|
||||||
|
"integrity": "sha512-7DE8mpG+/fVw+dTpjbxnx47TaMnDfOI1jwft9g1VybltZCduyRQPJPvc+zzKY9WPHxhPWczyFuYa6I8Mw4iU5A==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
|
"jss": {
|
||||||
|
"version": "10.5.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/jss/-/jss-10.5.0.tgz",
|
||||||
|
"integrity": "sha512-B6151NvG+thUg3murLNHRPLxTLwQ13ep4SH5brj4d8qKtogOx/jupnpfkPGSHPqvcwKJaCLctpj2lEk+5yGwMw==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"@babel/runtime": "^7.3.1",
|
||||||
|
"csstype": "^3.0.2",
|
||||||
|
"indefinite-observable": "^2.0.1",
|
||||||
|
"is-in-browser": "^1.1.3",
|
||||||
|
"tiny-warning": "^1.0.2"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"csstype": {
|
||||||
|
"version": "3.0.6",
|
||||||
|
"resolved": "https://registry.npmjs.org/csstype/-/csstype-3.0.6.tgz",
|
||||||
|
"integrity": "sha512-+ZAmfyWMT7TiIlzdqJgjMb7S4f1beorDbWbsocyK4RaiqA5RTX3K14bnBWmmA9QEM0gRdsjyyrEmcyga8Zsxmw==",
|
||||||
|
"dev": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"jss-plugin-camel-case": {
|
||||||
|
"version": "10.5.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/jss-plugin-camel-case/-/jss-plugin-camel-case-10.5.0.tgz",
|
||||||
|
"integrity": "sha512-GSjPL0adGAkuoqeYiXTgO7PlIrmjv5v8lA6TTBdfxbNYpxADOdGKJgIEkffhlyuIZHlPuuiFYTwUreLUmSn7rg==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"@babel/runtime": "^7.3.1",
|
||||||
|
"hyphenate-style-name": "^1.0.3",
|
||||||
|
"jss": "10.5.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"jss-plugin-default-unit": {
|
||||||
|
"version": "10.5.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/jss-plugin-default-unit/-/jss-plugin-default-unit-10.5.0.tgz",
|
||||||
|
"integrity": "sha512-rsbTtZGCMrbcb9beiDd+TwL991NGmsAgVYH0hATrYJtue9e+LH/Gn4yFD1ENwE+3JzF3A+rPnM2JuD9L/SIIWw==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"@babel/runtime": "^7.3.1",
|
||||||
|
"jss": "10.5.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"jss-plugin-global": {
|
||||||
|
"version": "10.5.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/jss-plugin-global/-/jss-plugin-global-10.5.0.tgz",
|
||||||
|
"integrity": "sha512-FZd9+JE/3D7HMefEG54fEC0XiQ9rhGtDHAT/ols24y8sKQ1D5KIw6OyXEmIdKFmACgxZV2ARQ5pAUypxkk2IFQ==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"@babel/runtime": "^7.3.1",
|
||||||
|
"jss": "10.5.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"jss-plugin-nested": {
|
||||||
|
"version": "10.5.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/jss-plugin-nested/-/jss-plugin-nested-10.5.0.tgz",
|
||||||
|
"integrity": "sha512-ejPlCLNlEGgx8jmMiDk/zarsCZk+DV0YqXfddpgzbO9Toamo0HweCFuwJ3ZO40UFOfqKwfpKMVH/3HUXgxkTMg==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"@babel/runtime": "^7.3.1",
|
||||||
|
"jss": "10.5.0",
|
||||||
|
"tiny-warning": "^1.0.2"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"jss-plugin-props-sort": {
|
||||||
|
"version": "10.5.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/jss-plugin-props-sort/-/jss-plugin-props-sort-10.5.0.tgz",
|
||||||
|
"integrity": "sha512-kTLRvrOetFKz5vM88FAhLNeJIxfjhCepnvq65G7xsAQ/Wgy7HwO1BS/2wE5mx8iLaAWC6Rj5h16mhMk9sKdZxg==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"@babel/runtime": "^7.3.1",
|
||||||
|
"jss": "10.5.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"jss-plugin-rule-value-function": {
|
||||||
|
"version": "10.5.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/jss-plugin-rule-value-function/-/jss-plugin-rule-value-function-10.5.0.tgz",
|
||||||
|
"integrity": "sha512-jXINGr8BSsB13JVuK274oEtk0LoooYSJqTBCGeBu2cG/VJ3+4FPs1gwLgsq24xTgKshtZ+WEQMVL34OprLidRA==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"@babel/runtime": "^7.3.1",
|
||||||
|
"jss": "10.5.0",
|
||||||
|
"tiny-warning": "^1.0.2"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"jss-plugin-vendor-prefixer": {
|
||||||
|
"version": "10.5.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/jss-plugin-vendor-prefixer/-/jss-plugin-vendor-prefixer-10.5.0.tgz",
|
||||||
|
"integrity": "sha512-rux3gmfwDdOKCLDx0IQjTwTm03IfBa+Rm/hs747cOw5Q7O3RaTUIMPKjtVfc31Xr/XI9Abz2XEupk1/oMQ7zRA==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"@babel/runtime": "^7.3.1",
|
||||||
|
"css-vendor": "^2.0.8",
|
||||||
|
"jss": "10.5.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"locate-path": {
|
||||||
|
"version": "3.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz",
|
||||||
|
"integrity": "sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"p-locate": "^3.0.0",
|
||||||
|
"path-exists": "^3.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"loose-envify": {
|
||||||
|
"version": "1.4.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz",
|
||||||
|
"integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"js-tokens": "^3.0.0 || ^4.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"lru-cache": {
|
||||||
|
"version": "6.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz",
|
||||||
|
"integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"yallist": "^4.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"make-dir": {
|
||||||
|
"version": "3.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz",
|
||||||
|
"integrity": "sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"semver": "^6.0.0"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"semver": {
|
||||||
|
"version": "6.3.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz",
|
||||||
|
"integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==",
|
||||||
|
"dev": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"mimic-fn": {
|
||||||
|
"version": "3.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-3.1.0.tgz",
|
||||||
|
"integrity": "sha512-Ysbi9uYW9hFyfrThdDEQuykN4Ey6BuwPD2kpI5ES/nFTDn/98yxYNLZJcgUAKPT/mcrLLKaGzJR9YVxJrIdASQ==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
|
"object-assign": {
|
||||||
|
"version": "4.1.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
|
||||||
|
"integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
|
"onetime": {
|
||||||
|
"version": "5.1.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/onetime/-/onetime-5.1.2.tgz",
|
||||||
|
"integrity": "sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"mimic-fn": "^2.1.0"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"mimic-fn": {
|
||||||
|
"version": "2.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz",
|
||||||
|
"integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==",
|
||||||
|
"dev": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"p-limit": {
|
||||||
|
"version": "2.3.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz",
|
||||||
|
"integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"p-try": "^2.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"p-locate": {
|
||||||
|
"version": "3.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz",
|
||||||
|
"integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"p-limit": "^2.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"p-try": {
|
||||||
|
"version": "2.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz",
|
||||||
|
"integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
|
"path-exists": {
|
||||||
|
"version": "3.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz",
|
||||||
|
"integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
|
"pkg-up": {
|
||||||
|
"version": "3.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/pkg-up/-/pkg-up-3.1.0.tgz",
|
||||||
|
"integrity": "sha512-nDywThFk1i4BQK4twPQ6TA4RT8bDY96yeuCVBWL3ePARCiEKDRSrNGbFIgUJpLp+XeIR65v8ra7WuJOFUBtkMA==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"find-up": "^3.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"popper.js": {
|
||||||
|
"version": "1.16.1-lts",
|
||||||
|
"resolved": "https://registry.npmjs.org/popper.js/-/popper.js-1.16.1-lts.tgz",
|
||||||
|
"integrity": "sha512-Kjw8nKRl1m+VrSFCoVGPph93W/qrSO7ZkqPpTf7F4bk/sqcfWK019dWBUpE/fBOsOQY1dks/Bmcbfn1heM/IsA==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
|
"prop-types": {
|
||||||
|
"version": "15.7.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.7.2.tgz",
|
||||||
|
"integrity": "sha512-8QQikdH7//R2vurIJSutZ1smHYTcLpRWEOlHnzcWHmBYrOGUysKwSsrC89BCiFj3CbrfJ/nXFdJepOVrY1GCHQ==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"loose-envify": "^1.4.0",
|
||||||
|
"object-assign": "^4.1.1",
|
||||||
|
"react-is": "^16.8.1"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"react-is": {
|
||||||
|
"version": "16.13.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz",
|
||||||
|
"integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==",
|
||||||
|
"dev": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"punycode": {
|
||||||
|
"version": "2.1.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz",
|
||||||
|
"integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
|
"react-is": {
|
||||||
|
"version": "17.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/react-is/-/react-is-17.0.1.tgz",
|
||||||
|
"integrity": "sha512-NAnt2iGDXohE5LI7uBnLnqvLQMtzhkiAOLXTmv+qnF9Ky7xAPcX8Up/xWIhxvLVGJvuLiNc4xQLtuqDRzb4fSA==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
|
"react-transition-group": {
|
||||||
|
"version": "4.4.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/react-transition-group/-/react-transition-group-4.4.1.tgz",
|
||||||
|
"integrity": "sha512-Djqr7OQ2aPUiYurhPalTrVy9ddmFCCzwhqQmtN+J3+3DzLO209Fdr70QrN8Z3DsglWql6iY1lDWAfpFiBtuKGw==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"@babel/runtime": "^7.5.5",
|
||||||
|
"dom-helpers": "^5.0.1",
|
||||||
|
"loose-envify": "^1.4.0",
|
||||||
|
"prop-types": "^15.6.2"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"regenerator-runtime": {
|
||||||
|
"version": "0.13.7",
|
||||||
|
"resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.7.tgz",
|
||||||
|
"integrity": "sha512-a54FxoJDIr27pgf7IgeQGxmqUNYrcV338lf/6gH456HZ/PhX+5BcwHXG9ajESmwe6WRO0tAzRUrRmNONWgkrew==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
|
"semver": {
|
||||||
|
"version": "7.3.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/semver/-/semver-7.3.4.tgz",
|
||||||
|
"integrity": "sha512-tCfb2WLjqFAtXn4KEdxIhalnRtoKFN7nAwj0B3ZXCbQloV2tq5eDbcTmT68JJD3nRJq24/XgxtQKFIpQdtvmVw==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"lru-cache": "^6.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"symbol-observable": {
|
||||||
|
"version": "1.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/symbol-observable/-/symbol-observable-1.2.0.tgz",
|
||||||
|
"integrity": "sha512-e900nM8RRtGhlV36KGEU9k65K3mPb1WV70OdjfxlG2EAuM1noi/E/BaW/uMhL7bPEssK8QV57vN3esixjUvcXQ==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
|
"tiny-warning": {
|
||||||
|
"version": "1.0.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/tiny-warning/-/tiny-warning-1.0.3.tgz",
|
||||||
|
"integrity": "sha512-lBN9zLN/oAf68o3zNXYrdCt1kP8WsiGW8Oo2ka41b2IM5JL/S1CTyX1rW0mb/zSuJun0ZUrDxx4sqvYS2FWzPA==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
|
"uri-js": {
|
||||||
|
"version": "4.4.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz",
|
||||||
|
"integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"punycode": "^2.1.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"yallist": {
|
||||||
|
"version": "4.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz",
|
||||||
|
"integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==",
|
||||||
|
"dev": true
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"@sinonjs/commons": {
|
"@sinonjs/commons": {
|
||||||
"version": "1.8.1",
|
"version": "1.8.1",
|
||||||
@ -2796,7 +3433,8 @@
|
|||||||
"version": "1.3.0",
|
"version": "1.3.0",
|
||||||
"resolved": "https://registry.npmjs.org/growly/-/growly-1.3.0.tgz",
|
"resolved": "https://registry.npmjs.org/growly/-/growly-1.3.0.tgz",
|
||||||
"integrity": "sha1-8QdIy+dq+WS3yWyTxrzCivEgwIE=",
|
"integrity": "sha1-8QdIy+dq+WS3yWyTxrzCivEgwIE=",
|
||||||
"dev": true
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
},
|
},
|
||||||
"har-schema": {
|
"har-schema": {
|
||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
@ -3226,6 +3864,7 @@
|
|||||||
"resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-2.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-2.2.0.tgz",
|
||||||
"integrity": "sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==",
|
"integrity": "sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"is-docker": "^2.0.0"
|
"is-docker": "^2.0.0"
|
||||||
}
|
}
|
||||||
@ -4382,6 +5021,7 @@
|
|||||||
"resolved": "https://registry.npmjs.org/node-notifier/-/node-notifier-8.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/node-notifier/-/node-notifier-8.0.1.tgz",
|
||||||
"integrity": "sha512-BvEXF+UmsnAfYfoapKM9nGxnP+Wn7P91YfXmrKnfcYCx6VBeoN5Ez5Ogck6I8Bi5k4RlpqRYaw75pAwzX9OphA==",
|
"integrity": "sha512-BvEXF+UmsnAfYfoapKM9nGxnP+Wn7P91YfXmrKnfcYCx6VBeoN5Ez5Ogck6I8Bi5k4RlpqRYaw75pAwzX9OphA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"growly": "^1.3.0",
|
"growly": "^1.3.0",
|
||||||
"is-wsl": "^2.2.0",
|
"is-wsl": "^2.2.0",
|
||||||
@ -4396,6 +5036,7 @@
|
|||||||
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz",
|
||||||
"integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==",
|
"integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"yallist": "^4.0.0"
|
"yallist": "^4.0.0"
|
||||||
}
|
}
|
||||||
@ -4405,6 +5046,7 @@
|
|||||||
"resolved": "https://registry.npmjs.org/semver/-/semver-7.3.4.tgz",
|
"resolved": "https://registry.npmjs.org/semver/-/semver-7.3.4.tgz",
|
||||||
"integrity": "sha512-tCfb2WLjqFAtXn4KEdxIhalnRtoKFN7nAwj0B3ZXCbQloV2tq5eDbcTmT68JJD3nRJq24/XgxtQKFIpQdtvmVw==",
|
"integrity": "sha512-tCfb2WLjqFAtXn4KEdxIhalnRtoKFN7nAwj0B3ZXCbQloV2tq5eDbcTmT68JJD3nRJq24/XgxtQKFIpQdtvmVw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"lru-cache": "^6.0.0"
|
"lru-cache": "^6.0.0"
|
||||||
}
|
}
|
||||||
@ -4414,6 +5056,7 @@
|
|||||||
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
|
||||||
"integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==",
|
"integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"isexe": "^2.0.0"
|
"isexe": "^2.0.0"
|
||||||
}
|
}
|
||||||
@ -4422,7 +5065,8 @@
|
|||||||
"version": "4.0.0",
|
"version": "4.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz",
|
||||||
"integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==",
|
"integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==",
|
||||||
"dev": true
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -5438,7 +6082,8 @@
|
|||||||
"version": "0.1.1",
|
"version": "0.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/shellwords/-/shellwords-0.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/shellwords/-/shellwords-0.1.1.tgz",
|
||||||
"integrity": "sha512-vFwSUfQvqybiICwZY5+DAWIPLKsWO31Q91JSKl3UYv+K5c2QRPzn0qzec6QPu1Qc9eHYItiP3NdJqNVqetYAww==",
|
"integrity": "sha512-vFwSUfQvqybiICwZY5+DAWIPLKsWO31Q91JSKl3UYv+K5c2QRPzn0qzec6QPu1Qc9eHYItiP3NdJqNVqetYAww==",
|
||||||
"dev": true
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
},
|
},
|
||||||
"signal-exit": {
|
"signal-exit": {
|
||||||
"version": "3.0.3",
|
"version": "3.0.3",
|
||||||
@ -6315,7 +6960,8 @@
|
|||||||
"version": "8.3.1",
|
"version": "8.3.1",
|
||||||
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.1.tgz",
|
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.1.tgz",
|
||||||
"integrity": "sha512-FOmRr+FmWEIG8uhZv6C2bTgEVXsHk08kE7mPlrBbEe+c3r9pjceVPgupIfNIhc4yx55H69OXANrUaSuu9eInKg==",
|
"integrity": "sha512-FOmRr+FmWEIG8uhZv6C2bTgEVXsHk08kE7mPlrBbEe+c3r9pjceVPgupIfNIhc4yx55H69OXANrUaSuu9eInKg==",
|
||||||
"dev": true
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
},
|
},
|
||||||
"v8-to-istanbul": {
|
"v8-to-istanbul": {
|
||||||
"version": "7.0.0",
|
"version": "7.0.0",
|
||||||
|
|||||||
@ -9,13 +9,9 @@ export class PodLogsMenu extends React.Component<PodLogsMenuProps> {
|
|||||||
Navigation.hideDetails();
|
Navigation.hideDetails();
|
||||||
const pod = this.props.object;
|
const pod = this.props.object;
|
||||||
|
|
||||||
Component.createPodLogsTab({
|
Component.logTabStore.createPodTab({
|
||||||
pod,
|
selectedPod: pod,
|
||||||
containers: pod.getContainers(),
|
|
||||||
initContainers: pod.getInitContainers(),
|
|
||||||
selectedContainer: container,
|
selectedContainer: container,
|
||||||
showTimestamps: false,
|
|
||||||
previous: false,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
9
extensions/survey/main.ts
Normal file
9
extensions/survey/main.ts
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
import { LensMainExtension } from "@k8slens/extensions";
|
||||||
|
import { surveyPreferencesStore } from "./src/survey-preferences-store";
|
||||||
|
|
||||||
|
export default class SurveyMainExtension extends LensMainExtension {
|
||||||
|
|
||||||
|
async onActivate() {
|
||||||
|
await surveyPreferencesStore.loadExtension(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
7928
extensions/survey/package-lock.json
generated
Normal file
7928
extensions/survey/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
28
extensions/survey/package.json
Normal file
28
extensions/survey/package.json
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
{
|
||||||
|
"name": "lens-survey",
|
||||||
|
"version": "0.1.0",
|
||||||
|
"description": "Lens survey",
|
||||||
|
"main": "dist/main.js",
|
||||||
|
"renderer": "dist/renderer.js",
|
||||||
|
"lens": {
|
||||||
|
"metadata": {},
|
||||||
|
"styles": []
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"build": "webpack -p",
|
||||||
|
"dev": "webpack --watch",
|
||||||
|
"test": "jest --passWithNoTests --env=jsdom src $@"
|
||||||
|
},
|
||||||
|
"dependencies": {},
|
||||||
|
"devDependencies": {
|
||||||
|
"@k8slens/extensions": "file:../../src/extensions/npm/extensions",
|
||||||
|
"got": "^11.8.1",
|
||||||
|
"jest": "^26.6.3",
|
||||||
|
"node-machine-id": "^1.1.12",
|
||||||
|
"react": "^16.13.1",
|
||||||
|
"refiner-js": "^1.0.1",
|
||||||
|
"ts-loader": "^8.0.4",
|
||||||
|
"typescript": "^4.0.3",
|
||||||
|
"webpack": "^4.44.2"
|
||||||
|
}
|
||||||
|
}
|
||||||
24
extensions/survey/renderer.tsx
Normal file
24
extensions/survey/renderer.tsx
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
import { LensRendererExtension } from "@k8slens/extensions";
|
||||||
|
import { survey } from "./src/survey";
|
||||||
|
import { SurveyPreferenceHint, SurveyPreferenceInput } from "./src/survey-preference";
|
||||||
|
import { surveyPreferencesStore } from "./src/survey-preferences-store";
|
||||||
|
import React from "react";
|
||||||
|
|
||||||
|
export default class SurveyRendererExtension extends LensRendererExtension {
|
||||||
|
appPreferences = [
|
||||||
|
{
|
||||||
|
title: "In-App Surveys",
|
||||||
|
components: {
|
||||||
|
Hint: () => <SurveyPreferenceHint/>,
|
||||||
|
Input: () => <SurveyPreferenceInput survey={surveyPreferencesStore}/>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
];
|
||||||
|
async onActivate() {
|
||||||
|
// Activate extension only on main renderer
|
||||||
|
if (window.location.hostname === "localhost") {
|
||||||
|
await surveyPreferencesStore.loadExtension(this);
|
||||||
|
survey.start();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
3
extensions/survey/src/refiner-js.d.ts
vendored
Normal file
3
extensions/survey/src/refiner-js.d.ts
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
declare module "refiner-js" {
|
||||||
|
export default function Refiner(key: string, value: string|object|number|Boolean|Array): void;
|
||||||
|
}
|
||||||
27
extensions/survey/src/survey-preference.tsx
Normal file
27
extensions/survey/src/survey-preference.tsx
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
import { Component } from "@k8slens/extensions";
|
||||||
|
import React from "react";
|
||||||
|
import { observer } from "mobx-react";
|
||||||
|
import { SurveyPreferencesStore } from "./survey-preferences-store";
|
||||||
|
|
||||||
|
@observer
|
||||||
|
export class SurveyPreferenceInput extends React.Component<{survey: SurveyPreferencesStore}, {}> {
|
||||||
|
render() {
|
||||||
|
const { survey } = this.props;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Component.Checkbox
|
||||||
|
label="Allow in-app surveys"
|
||||||
|
value={survey.enabled}
|
||||||
|
onChange={v => survey.enabled = v }
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class SurveyPreferenceHint extends React.Component {
|
||||||
|
render() {
|
||||||
|
return (
|
||||||
|
<span>This will allow you to participate in surveys to improve the Lens experience.</span>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
36
extensions/survey/src/survey-preferences-store.ts
Normal file
36
extensions/survey/src/survey-preferences-store.ts
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
import { Store } from "@k8slens/extensions";
|
||||||
|
import { observable, toJS, when } from "mobx";
|
||||||
|
|
||||||
|
export type SurveyPreferencesModel = {
|
||||||
|
enabled: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
|
export class SurveyPreferencesStore extends Store.ExtensionStore<SurveyPreferencesModel> {
|
||||||
|
|
||||||
|
@observable enabled = true;
|
||||||
|
|
||||||
|
whenEnabled = when(() => this.enabled);
|
||||||
|
|
||||||
|
private constructor() {
|
||||||
|
super({
|
||||||
|
configName: "preferences-store",
|
||||||
|
defaults: {
|
||||||
|
enabled: true
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
protected fromStore({ enabled }: SurveyPreferencesModel): void {
|
||||||
|
this.enabled = enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
toJSON(): SurveyPreferencesModel {
|
||||||
|
return toJS({
|
||||||
|
enabled: this.enabled
|
||||||
|
}, {
|
||||||
|
recurseEverything: true
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const surveyPreferencesStore = SurveyPreferencesStore.getInstance<SurveyPreferencesStore>();
|
||||||
46
extensions/survey/src/survey.ts
Normal file
46
extensions/survey/src/survey.ts
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
import { Util } from "@k8slens/extensions";
|
||||||
|
import { machineId } from "node-machine-id";
|
||||||
|
import Refiner from "refiner-js";
|
||||||
|
import got from "got";
|
||||||
|
import { surveyPreferencesStore } from "./survey-preferences-store";
|
||||||
|
|
||||||
|
type SurveyIdResponse = {
|
||||||
|
surveyId: string;
|
||||||
|
};
|
||||||
|
export class Survey extends Util.Singleton {
|
||||||
|
static readonly PROJECT_ID = "af468d00-4f8f-11eb-b01d-23b6562fef43";
|
||||||
|
protected anonymousId: string;
|
||||||
|
|
||||||
|
private constructor() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
async start() {
|
||||||
|
await surveyPreferencesStore.whenEnabled;
|
||||||
|
|
||||||
|
const surveyId = await this.fetchSurveyId();
|
||||||
|
|
||||||
|
if (surveyId) {
|
||||||
|
Refiner("setProject", Survey.PROJECT_ID);
|
||||||
|
Refiner("identifyUser", {
|
||||||
|
id: surveyId,
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async fetchSurveyId() {
|
||||||
|
try {
|
||||||
|
const surveyApi = process.env.SURVEY_API_URL || "https://survey.k8slens.dev";
|
||||||
|
const anonymousId = await machineId();
|
||||||
|
const { body } = await got(`${surveyApi}/api/survey-id?anonymousId=${anonymousId}`, { responseType: "json"});
|
||||||
|
|
||||||
|
return (body as SurveyIdResponse).surveyId;
|
||||||
|
} catch(error) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const survey = Survey.getInstance<Survey>();
|
||||||
29
extensions/survey/tsconfig.json
Normal file
29
extensions/survey/tsconfig.json
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"outDir": "dist",
|
||||||
|
"baseUrl": ".",
|
||||||
|
"module": "CommonJS",
|
||||||
|
"target": "ES2017",
|
||||||
|
"lib": ["ESNext", "DOM", "DOM.Iterable"],
|
||||||
|
"moduleResolution": "Node",
|
||||||
|
"sourceMap": false,
|
||||||
|
"declaration": false,
|
||||||
|
"strict": false,
|
||||||
|
"noImplicitAny": true,
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"allowSyntheticDefaultImports": true,
|
||||||
|
"experimentalDecorators": true,
|
||||||
|
"jsx": "react",
|
||||||
|
"paths": {
|
||||||
|
"*": [
|
||||||
|
"node_modules/*",
|
||||||
|
"../../types/*"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"include": [
|
||||||
|
"renderer.ts",
|
||||||
|
"src/**/*"
|
||||||
|
]
|
||||||
|
}
|
||||||
67
extensions/survey/webpack.config.js
Normal file
67
extensions/survey/webpack.config.js
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
const path = require("path");
|
||||||
|
|
||||||
|
module.exports = [
|
||||||
|
{
|
||||||
|
entry: "./main.ts",
|
||||||
|
context: __dirname,
|
||||||
|
target: "electron-main",
|
||||||
|
mode: "production",
|
||||||
|
module: {
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
test: /\.tsx?$/,
|
||||||
|
use: "ts-loader",
|
||||||
|
exclude: /node_modules/,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
externals: [
|
||||||
|
{
|
||||||
|
"@k8slens/extensions": "var global.LensExtensions",
|
||||||
|
"react": "var global.React",
|
||||||
|
"mobx": "var global.Mobx"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
resolve: {
|
||||||
|
extensions: [ ".tsx", ".ts", ".js" ],
|
||||||
|
},
|
||||||
|
output: {
|
||||||
|
libraryTarget: "commonjs2",
|
||||||
|
globalObject: "this",
|
||||||
|
filename: "main.js",
|
||||||
|
path: path.resolve(__dirname, "dist"),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
entry: "./renderer.tsx",
|
||||||
|
context: __dirname,
|
||||||
|
target: "electron-renderer",
|
||||||
|
mode: "production",
|
||||||
|
module: {
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
test: /\.tsx?$/,
|
||||||
|
use: "ts-loader",
|
||||||
|
exclude: /node_modules/,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
externals: [
|
||||||
|
{
|
||||||
|
"@k8slens/extensions": "var global.LensExtensions",
|
||||||
|
"react": "var global.React",
|
||||||
|
"mobx": "var global.Mobx",
|
||||||
|
"mobx-react": "var global.MobxReact"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
resolve: {
|
||||||
|
extensions: [ ".tsx", ".ts", ".js" ],
|
||||||
|
},
|
||||||
|
output: {
|
||||||
|
libraryTarget: "commonjs2",
|
||||||
|
globalObject: "this",
|
||||||
|
filename: "renderer.js",
|
||||||
|
path: path.resolve(__dirname, "dist"),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
17
extensions/telemetry/package-lock.json
generated
17
extensions/telemetry/package-lock.json
generated
@ -2901,7 +2901,8 @@
|
|||||||
"version": "1.3.0",
|
"version": "1.3.0",
|
||||||
"resolved": "https://registry.npmjs.org/growly/-/growly-1.3.0.tgz",
|
"resolved": "https://registry.npmjs.org/growly/-/growly-1.3.0.tgz",
|
||||||
"integrity": "sha1-8QdIy+dq+WS3yWyTxrzCivEgwIE=",
|
"integrity": "sha1-8QdIy+dq+WS3yWyTxrzCivEgwIE=",
|
||||||
"dev": true
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
},
|
},
|
||||||
"har-schema": {
|
"har-schema": {
|
||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
@ -3337,6 +3338,7 @@
|
|||||||
"resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-2.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-2.2.0.tgz",
|
||||||
"integrity": "sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==",
|
"integrity": "sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"is-docker": "^2.0.0"
|
"is-docker": "^2.0.0"
|
||||||
}
|
}
|
||||||
@ -4533,6 +4535,7 @@
|
|||||||
"resolved": "https://registry.npmjs.org/node-notifier/-/node-notifier-8.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/node-notifier/-/node-notifier-8.0.1.tgz",
|
||||||
"integrity": "sha512-BvEXF+UmsnAfYfoapKM9nGxnP+Wn7P91YfXmrKnfcYCx6VBeoN5Ez5Ogck6I8Bi5k4RlpqRYaw75pAwzX9OphA==",
|
"integrity": "sha512-BvEXF+UmsnAfYfoapKM9nGxnP+Wn7P91YfXmrKnfcYCx6VBeoN5Ez5Ogck6I8Bi5k4RlpqRYaw75pAwzX9OphA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"growly": "^1.3.0",
|
"growly": "^1.3.0",
|
||||||
"is-wsl": "^2.2.0",
|
"is-wsl": "^2.2.0",
|
||||||
@ -4547,6 +4550,7 @@
|
|||||||
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz",
|
||||||
"integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==",
|
"integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"yallist": "^4.0.0"
|
"yallist": "^4.0.0"
|
||||||
}
|
}
|
||||||
@ -4556,6 +4560,7 @@
|
|||||||
"resolved": "https://registry.npmjs.org/semver/-/semver-7.3.4.tgz",
|
"resolved": "https://registry.npmjs.org/semver/-/semver-7.3.4.tgz",
|
||||||
"integrity": "sha512-tCfb2WLjqFAtXn4KEdxIhalnRtoKFN7nAwj0B3ZXCbQloV2tq5eDbcTmT68JJD3nRJq24/XgxtQKFIpQdtvmVw==",
|
"integrity": "sha512-tCfb2WLjqFAtXn4KEdxIhalnRtoKFN7nAwj0B3ZXCbQloV2tq5eDbcTmT68JJD3nRJq24/XgxtQKFIpQdtvmVw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"lru-cache": "^6.0.0"
|
"lru-cache": "^6.0.0"
|
||||||
}
|
}
|
||||||
@ -4564,13 +4569,15 @@
|
|||||||
"version": "8.3.2",
|
"version": "8.3.2",
|
||||||
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",
|
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",
|
||||||
"integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==",
|
"integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==",
|
||||||
"dev": true
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
},
|
},
|
||||||
"which": {
|
"which": {
|
||||||
"version": "2.0.2",
|
"version": "2.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
|
||||||
"integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==",
|
"integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"isexe": "^2.0.0"
|
"isexe": "^2.0.0"
|
||||||
}
|
}
|
||||||
@ -4579,7 +4586,8 @@
|
|||||||
"version": "4.0.0",
|
"version": "4.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz",
|
||||||
"integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==",
|
"integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==",
|
||||||
"dev": true
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -5595,7 +5603,8 @@
|
|||||||
"version": "0.1.1",
|
"version": "0.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/shellwords/-/shellwords-0.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/shellwords/-/shellwords-0.1.1.tgz",
|
||||||
"integrity": "sha512-vFwSUfQvqybiICwZY5+DAWIPLKsWO31Q91JSKl3UYv+K5c2QRPzn0qzec6QPu1Qc9eHYItiP3NdJqNVqetYAww==",
|
"integrity": "sha512-vFwSUfQvqybiICwZY5+DAWIPLKsWO31Q91JSKl3UYv+K5c2QRPzn0qzec6QPu1Qc9eHYItiP3NdJqNVqetYAww==",
|
||||||
"dev": true
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
},
|
},
|
||||||
"signal-exit": {
|
"signal-exit": {
|
||||||
"version": "3.0.3",
|
"version": "3.0.3",
|
||||||
|
|||||||
@ -1,82 +1,26 @@
|
|||||||
/*
|
|
||||||
Cluster tests are run if there is a pre-existing minikube cluster. Before running cluster tests the TEST_NAMESPACE
|
|
||||||
namespace is removed, if it exists, from the minikube cluster. Resources are created as part of the cluster tests in the
|
|
||||||
TEST_NAMESPACE namespace. This is done to minimize destructive impact of the cluster tests on an existing minikube
|
|
||||||
cluster and vice versa.
|
|
||||||
*/
|
|
||||||
import { Application } from "spectron";
|
import { Application } from "spectron";
|
||||||
import * as util from "../helpers/utils";
|
import * as utils from "../helpers/utils";
|
||||||
import { spawnSync } from "child_process";
|
import { listHelmRepositories } from "../helpers/utils";
|
||||||
|
import { fail } from "assert";
|
||||||
|
|
||||||
|
|
||||||
jest.setTimeout(60000);
|
jest.setTimeout(60000);
|
||||||
|
|
||||||
// FIXME (!): improve / simplify all css-selectors + use [data-test-id="some-id"] (already used in some tests below)
|
// FIXME (!): improve / simplify all css-selectors + use [data-test-id="some-id"] (already used in some tests below)
|
||||||
describe("Lens integration tests", () => {
|
describe("Lens integration tests", () => {
|
||||||
const TEST_NAMESPACE = "integration-tests";
|
|
||||||
const BACKSPACE = "\uE003";
|
|
||||||
let app: Application;
|
let app: Application;
|
||||||
const appStart = async () => {
|
|
||||||
app = util.setup();
|
|
||||||
await app.start();
|
|
||||||
// Wait for splash screen to be closed
|
|
||||||
while (await app.client.getWindowCount() > 1);
|
|
||||||
await app.client.windowByIndex(0);
|
|
||||||
await app.client.waitUntilWindowLoaded();
|
|
||||||
};
|
|
||||||
const clickWhatsNew = async (app: Application) => {
|
|
||||||
await app.client.waitUntilTextExists("h1", "What's new?");
|
|
||||||
await app.client.click("button.primary");
|
|
||||||
await app.client.waitUntilTextExists("h1", "Welcome");
|
|
||||||
};
|
|
||||||
const minikubeReady = (): boolean => {
|
|
||||||
// determine if minikube is running
|
|
||||||
{
|
|
||||||
const { status } = spawnSync("minikube status", { shell: true });
|
|
||||||
|
|
||||||
if (status !== 0) {
|
|
||||||
console.warn("minikube not running");
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Remove TEST_NAMESPACE if it already exists
|
|
||||||
{
|
|
||||||
const { status } = spawnSync(`minikube kubectl -- get namespace ${TEST_NAMESPACE}`, { shell: true });
|
|
||||||
|
|
||||||
if (status === 0) {
|
|
||||||
console.warn(`Removing existing ${TEST_NAMESPACE} namespace`);
|
|
||||||
|
|
||||||
const { status, stdout, stderr } = spawnSync(
|
|
||||||
`minikube kubectl -- delete namespace ${TEST_NAMESPACE}`,
|
|
||||||
{ shell: true },
|
|
||||||
);
|
|
||||||
|
|
||||||
if (status !== 0) {
|
|
||||||
console.warn(`Error removing ${TEST_NAMESPACE} namespace: ${stderr.toString()}`);
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log(stdout.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
const ready = minikubeReady();
|
|
||||||
|
|
||||||
describe("app start", () => {
|
describe("app start", () => {
|
||||||
beforeAll(appStart, 20000);
|
beforeAll(async () => app = await utils.appStart(), 20000);
|
||||||
|
|
||||||
afterAll(async () => {
|
afterAll(async () => {
|
||||||
if (app?.isRunning()) {
|
if (app?.isRunning()) {
|
||||||
await util.tearDown(app);
|
await utils.tearDown(app);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
it('shows "whats new"', async () => {
|
it('shows "whats new"', async () => {
|
||||||
await clickWhatsNew(app);
|
await utils.clickWhatsNew(app);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('shows "add cluster"', async () => {
|
it('shows "add cluster"', async () => {
|
||||||
@ -93,7 +37,13 @@ describe("Lens integration tests", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("ensures helm repos", async () => {
|
it("ensures helm repos", async () => {
|
||||||
await app.client.waitUntilTextExists("div.repos #message-bitnami", "bitnami"); // wait for the helm-cli to fetch the bitnami repo
|
const repos = await listHelmRepositories();
|
||||||
|
|
||||||
|
if (!repos[0]) {
|
||||||
|
fail("Lens failed to add Bitnami repository");
|
||||||
|
}
|
||||||
|
|
||||||
|
await app.client.waitUntilTextExists("div.repos #message-bitnami", repos[0].name); // wait for the helm-cli to fetch the repo(s)
|
||||||
await app.client.click("#HelmRepoSelect"); // click the repo select to activate the drop-down
|
await app.client.click("#HelmRepoSelect"); // click the repo select to activate the drop-down
|
||||||
await app.client.waitUntilTextExists("div.Select__option", ""); // wait for at least one option to appear (any text)
|
await app.client.waitUntilTextExists("div.Select__option", ""); // wait for at least one option to appear (any text)
|
||||||
});
|
});
|
||||||
@ -104,470 +54,4 @@ describe("Lens integration tests", () => {
|
|||||||
await app.client.keys("Meta");
|
await app.client.keys("Meta");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
util.describeIf(ready)("workspaces", () => {
|
|
||||||
beforeAll(appStart, 20000);
|
|
||||||
|
|
||||||
afterAll(async () => {
|
|
||||||
if (app && app.isRunning()) {
|
|
||||||
return util.tearDown(app);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
it("creates new workspace", async () => {
|
|
||||||
await clickWhatsNew(app);
|
|
||||||
await app.client.click("#current-workspace .Icon");
|
|
||||||
await app.client.click('a[href="/workspaces"]');
|
|
||||||
await app.client.click(".Workspaces button.Button");
|
|
||||||
await app.client.keys("test-workspace");
|
|
||||||
await app.client.click(".Workspaces .Input.description input");
|
|
||||||
await app.client.keys("test description");
|
|
||||||
await app.client.click(".Workspaces .workspace.editing .Icon");
|
|
||||||
await app.client.waitUntilTextExists(".workspace .name a", "test-workspace");
|
|
||||||
});
|
|
||||||
|
|
||||||
it("adds cluster in default workspace", async () => {
|
|
||||||
await addMinikubeCluster(app);
|
|
||||||
await app.client.waitUntilTextExists("pre.kube-auth-out", "Authentication proxy started");
|
|
||||||
await app.client.waitForExist(`iframe[name="minikube"]`);
|
|
||||||
await app.client.waitForVisible(".ClustersMenu .ClusterIcon.active");
|
|
||||||
});
|
|
||||||
|
|
||||||
it("adds cluster in test-workspace", async () => {
|
|
||||||
await app.client.click("#current-workspace .Icon");
|
|
||||||
await app.client.waitForVisible('.WorkspaceMenu li[title="test description"]');
|
|
||||||
await app.client.click('.WorkspaceMenu li[title="test description"]');
|
|
||||||
await addMinikubeCluster(app);
|
|
||||||
await app.client.waitUntilTextExists("pre.kube-auth-out", "Authentication proxy started");
|
|
||||||
await app.client.waitForExist(`iframe[name="minikube"]`);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("checks if default workspace has active cluster", async () => {
|
|
||||||
await app.client.click("#current-workspace .Icon");
|
|
||||||
await app.client.waitForVisible(".WorkspaceMenu > li:first-of-type");
|
|
||||||
await app.client.click(".WorkspaceMenu > li:first-of-type");
|
|
||||||
await app.client.waitForVisible(".ClustersMenu .ClusterIcon.active");
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
const addMinikubeCluster = async (app: Application) => {
|
|
||||||
await app.client.click("div.add-cluster");
|
|
||||||
await app.client.waitUntilTextExists("div", "Select kubeconfig file");
|
|
||||||
await app.client.click("div.Select__control"); // show the context drop-down list
|
|
||||||
await app.client.waitUntilTextExists("div", "minikube");
|
|
||||||
|
|
||||||
if (!await app.client.$("button.primary").isEnabled()) {
|
|
||||||
await app.client.click("div.minikube"); // select minikube context
|
|
||||||
} // else the only context, which must be 'minikube', is automatically selected
|
|
||||||
await app.client.click("div.Select__control"); // hide the context drop-down list (it might be obscuring the Add cluster(s) button)
|
|
||||||
await app.client.click("button.primary"); // add minikube cluster
|
|
||||||
};
|
|
||||||
const waitForMinikubeDashboard = async (app: Application) => {
|
|
||||||
await app.client.waitUntilTextExists("pre.kube-auth-out", "Authentication proxy started");
|
|
||||||
await app.client.waitForExist(`iframe[name="minikube"]`);
|
|
||||||
await app.client.frame("minikube");
|
|
||||||
await app.client.waitUntilTextExists("span.link-text", "Cluster");
|
|
||||||
};
|
|
||||||
|
|
||||||
util.describeIf(ready)("cluster tests", () => {
|
|
||||||
let clusterAdded = false;
|
|
||||||
const addCluster = async () => {
|
|
||||||
await clickWhatsNew(app);
|
|
||||||
await addMinikubeCluster(app);
|
|
||||||
await waitForMinikubeDashboard(app);
|
|
||||||
await app.client.click('a[href="/nodes"]');
|
|
||||||
await app.client.waitUntilTextExists("div.TableCell", "Ready");
|
|
||||||
};
|
|
||||||
|
|
||||||
describe("cluster add", () => {
|
|
||||||
beforeAll(appStart, 20000);
|
|
||||||
|
|
||||||
afterAll(async () => {
|
|
||||||
if (app && app.isRunning()) {
|
|
||||||
return util.tearDown(app);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
it("allows to add a cluster", async () => {
|
|
||||||
await addCluster();
|
|
||||||
clusterAdded = true;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
const appStartAddCluster = async () => {
|
|
||||||
if (clusterAdded) {
|
|
||||||
await appStart();
|
|
||||||
await addCluster();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
describe("cluster pages", () => {
|
|
||||||
|
|
||||||
beforeAll(appStartAddCluster, 40000);
|
|
||||||
|
|
||||||
afterAll(async () => {
|
|
||||||
if (app && app.isRunning()) {
|
|
||||||
return util.tearDown(app);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
const tests: {
|
|
||||||
drawer?: string
|
|
||||||
drawerId?: string
|
|
||||||
pages: {
|
|
||||||
name: string,
|
|
||||||
href: string,
|
|
||||||
expectedSelector: string,
|
|
||||||
expectedText: string
|
|
||||||
}[]
|
|
||||||
}[] = [{
|
|
||||||
drawer: "",
|
|
||||||
drawerId: "",
|
|
||||||
pages: [{
|
|
||||||
name: "Cluster",
|
|
||||||
href: "cluster",
|
|
||||||
expectedSelector: "div.ClusterOverview div.label",
|
|
||||||
expectedText: "Master"
|
|
||||||
}]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
drawer: "",
|
|
||||||
drawerId: "",
|
|
||||||
pages: [{
|
|
||||||
name: "Nodes",
|
|
||||||
href: "nodes",
|
|
||||||
expectedSelector: "h5.title",
|
|
||||||
expectedText: "Nodes"
|
|
||||||
}]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
drawer: "Workloads",
|
|
||||||
drawerId: "workloads",
|
|
||||||
pages: [{
|
|
||||||
name: "Overview",
|
|
||||||
href: "workloads",
|
|
||||||
expectedSelector: "h5.box",
|
|
||||||
expectedText: "Overview"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "Pods",
|
|
||||||
href: "pods",
|
|
||||||
expectedSelector: "h5.title",
|
|
||||||
expectedText: "Pods"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "Deployments",
|
|
||||||
href: "deployments",
|
|
||||||
expectedSelector: "h5.title",
|
|
||||||
expectedText: "Deployments"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "DaemonSets",
|
|
||||||
href: "daemonsets",
|
|
||||||
expectedSelector: "h5.title",
|
|
||||||
expectedText: "Daemon Sets"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "StatefulSets",
|
|
||||||
href: "statefulsets",
|
|
||||||
expectedSelector: "h5.title",
|
|
||||||
expectedText: "Stateful Sets"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "ReplicaSets",
|
|
||||||
href: "replicasets",
|
|
||||||
expectedSelector: "h5.title",
|
|
||||||
expectedText: "Replica Sets"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "Jobs",
|
|
||||||
href: "jobs",
|
|
||||||
expectedSelector: "h5.title",
|
|
||||||
expectedText: "Jobs"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "CronJobs",
|
|
||||||
href: "cronjobs",
|
|
||||||
expectedSelector: "h5.title",
|
|
||||||
expectedText: "Cron Jobs"
|
|
||||||
}]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
drawer: "Configuration",
|
|
||||||
drawerId: "config",
|
|
||||||
pages: [{
|
|
||||||
name: "ConfigMaps",
|
|
||||||
href: "configmaps",
|
|
||||||
expectedSelector: "h5.title",
|
|
||||||
expectedText: "Config Maps"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "Secrets",
|
|
||||||
href: "secrets",
|
|
||||||
expectedSelector: "h5.title",
|
|
||||||
expectedText: "Secrets"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "Resource Quotas",
|
|
||||||
href: "resourcequotas",
|
|
||||||
expectedSelector: "h5.title",
|
|
||||||
expectedText: "Resource Quotas"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "HPA",
|
|
||||||
href: "hpa",
|
|
||||||
expectedSelector: "h5.title",
|
|
||||||
expectedText: "Horizontal Pod Autoscalers"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "Pod Disruption Budgets",
|
|
||||||
href: "poddisruptionbudgets",
|
|
||||||
expectedSelector: "h5.title",
|
|
||||||
expectedText: "Pod Disruption Budgets"
|
|
||||||
}]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
drawer: "Network",
|
|
||||||
drawerId: "networks",
|
|
||||||
pages: [{
|
|
||||||
name: "Services",
|
|
||||||
href: "services",
|
|
||||||
expectedSelector: "h5.title",
|
|
||||||
expectedText: "Services"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "Endpoints",
|
|
||||||
href: "endpoints",
|
|
||||||
expectedSelector: "h5.title",
|
|
||||||
expectedText: "Endpoints"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "Ingresses",
|
|
||||||
href: "ingresses",
|
|
||||||
expectedSelector: "h5.title",
|
|
||||||
expectedText: "Ingresses"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "Network Policies",
|
|
||||||
href: "network-policies",
|
|
||||||
expectedSelector: "h5.title",
|
|
||||||
expectedText: "Network Policies"
|
|
||||||
}]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
drawer: "Storage",
|
|
||||||
drawerId: "storage",
|
|
||||||
pages: [{
|
|
||||||
name: "Persistent Volume Claims",
|
|
||||||
href: "persistent-volume-claims",
|
|
||||||
expectedSelector: "h5.title",
|
|
||||||
expectedText: "Persistent Volume Claims"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "Persistent Volumes",
|
|
||||||
href: "persistent-volumes",
|
|
||||||
expectedSelector: "h5.title",
|
|
||||||
expectedText: "Persistent Volumes"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "Storage Classes",
|
|
||||||
href: "storage-classes",
|
|
||||||
expectedSelector: "h5.title",
|
|
||||||
expectedText: "Storage Classes"
|
|
||||||
}]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
drawer: "",
|
|
||||||
drawerId: "",
|
|
||||||
pages: [{
|
|
||||||
name: "Namespaces",
|
|
||||||
href: "namespaces",
|
|
||||||
expectedSelector: "h5.title",
|
|
||||||
expectedText: "Namespaces"
|
|
||||||
}]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
drawer: "",
|
|
||||||
drawerId: "",
|
|
||||||
pages: [{
|
|
||||||
name: "Events",
|
|
||||||
href: "events",
|
|
||||||
expectedSelector: "h5.title",
|
|
||||||
expectedText: "Events"
|
|
||||||
}]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
drawer: "Apps",
|
|
||||||
drawerId: "apps",
|
|
||||||
pages: [{
|
|
||||||
name: "Charts",
|
|
||||||
href: "apps/charts",
|
|
||||||
expectedSelector: "div.HelmCharts input",
|
|
||||||
expectedText: ""
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "Releases",
|
|
||||||
href: "apps/releases",
|
|
||||||
expectedSelector: "h5.title",
|
|
||||||
expectedText: "Releases"
|
|
||||||
}]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
drawer: "Access Control",
|
|
||||||
drawerId: "users",
|
|
||||||
pages: [{
|
|
||||||
name: "Service Accounts",
|
|
||||||
href: "service-accounts",
|
|
||||||
expectedSelector: "h5.title",
|
|
||||||
expectedText: "Service Accounts"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "Role Bindings",
|
|
||||||
href: "role-bindings",
|
|
||||||
expectedSelector: "h5.title",
|
|
||||||
expectedText: "Role Bindings"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "Roles",
|
|
||||||
href: "roles",
|
|
||||||
expectedSelector: "h5.title",
|
|
||||||
expectedText: "Roles"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "Pod Security Policies",
|
|
||||||
href: "pod-security-policies",
|
|
||||||
expectedSelector: "h5.title",
|
|
||||||
expectedText: "Pod Security Policies"
|
|
||||||
}]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
drawer: "Custom Resources",
|
|
||||||
drawerId: "custom-resources",
|
|
||||||
pages: [{
|
|
||||||
name: "Definitions",
|
|
||||||
href: "crd/definitions",
|
|
||||||
expectedSelector: "h5.title",
|
|
||||||
expectedText: "Custom Resources"
|
|
||||||
}]
|
|
||||||
}];
|
|
||||||
|
|
||||||
tests.forEach(({ drawer = "", drawerId = "", pages }) => {
|
|
||||||
if (drawer !== "") {
|
|
||||||
it(`shows ${drawer} drawer`, async () => {
|
|
||||||
expect(clusterAdded).toBe(true);
|
|
||||||
await app.client.click(`.sidebar-nav [data-test-id="${drawerId}"] span.link-text`);
|
|
||||||
await app.client.waitUntilTextExists(`a[href^="/${pages[0].href}"]`, pages[0].name);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
pages.forEach(({ name, href, expectedSelector, expectedText }) => {
|
|
||||||
it(`shows ${drawer}->${name} page`, async () => {
|
|
||||||
expect(clusterAdded).toBe(true);
|
|
||||||
await app.client.click(`a[href^="/${href}"]`);
|
|
||||||
await app.client.waitUntilTextExists(expectedSelector, expectedText);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
if (drawer !== "") {
|
|
||||||
// hide the drawer
|
|
||||||
it(`hides ${drawer} drawer`, async () => {
|
|
||||||
expect(clusterAdded).toBe(true);
|
|
||||||
await app.client.click(`.sidebar-nav [data-test-id="${drawerId}"] span.link-text`);
|
|
||||||
await expect(app.client.waitUntilTextExists(`a[href^="/${pages[0].href}"]`, pages[0].name, 100)).rejects.toThrow();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("viewing pod logs", () => {
|
|
||||||
beforeEach(appStartAddCluster, 40000);
|
|
||||||
|
|
||||||
afterEach(async () => {
|
|
||||||
if (app && app.isRunning()) {
|
|
||||||
return util.tearDown(app);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
it(`shows a logs for a pod`, async () => {
|
|
||||||
expect(clusterAdded).toBe(true);
|
|
||||||
// Go to Pods page
|
|
||||||
await app.client.click(".sidebar-nav [data-test-id='workloads'] span.link-text");
|
|
||||||
await app.client.waitUntilTextExists('a[href^="/pods"]', "Pods");
|
|
||||||
await app.client.click('a[href^="/pods"]');
|
|
||||||
await app.client.waitUntilTextExists("div.TableCell", "kube-apiserver");
|
|
||||||
// Open logs tab in dock
|
|
||||||
await app.client.click(".list .TableRow:first-child");
|
|
||||||
await app.client.waitForVisible(".Drawer");
|
|
||||||
await app.client.click(".drawer-title .Menu li:nth-child(2)");
|
|
||||||
// Check if controls are available
|
|
||||||
await app.client.waitForVisible(".PodLogs .VirtualList");
|
|
||||||
await app.client.waitForVisible(".PodLogControls");
|
|
||||||
await app.client.waitForVisible(".PodLogControls .SearchInput");
|
|
||||||
await app.client.waitForVisible(".PodLogControls .SearchInput input");
|
|
||||||
// Search for semicolon
|
|
||||||
await app.client.keys(":");
|
|
||||||
await app.client.waitForVisible(".PodLogs .list span.active");
|
|
||||||
// Click through controls
|
|
||||||
await app.client.click(".PodLogControls .timestamps-icon");
|
|
||||||
await app.client.click(".PodLogControls .undo-icon");
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("cluster operations", () => {
|
|
||||||
beforeEach(appStartAddCluster, 40000);
|
|
||||||
|
|
||||||
afterEach(async () => {
|
|
||||||
if (app && app.isRunning()) {
|
|
||||||
return util.tearDown(app);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
it("shows default namespace", async () => {
|
|
||||||
expect(clusterAdded).toBe(true);
|
|
||||||
await app.client.click('a[href="/namespaces"]');
|
|
||||||
await app.client.waitUntilTextExists("div.TableCell", "default");
|
|
||||||
await app.client.waitUntilTextExists("div.TableCell", "kube-system");
|
|
||||||
});
|
|
||||||
|
|
||||||
it(`creates ${TEST_NAMESPACE} namespace`, async () => {
|
|
||||||
expect(clusterAdded).toBe(true);
|
|
||||||
await app.client.click('a[href="/namespaces"]');
|
|
||||||
await app.client.waitUntilTextExists("div.TableCell", "default");
|
|
||||||
await app.client.waitUntilTextExists("div.TableCell", "kube-system");
|
|
||||||
await app.client.click("button.add-button");
|
|
||||||
await app.client.waitUntilTextExists("div.AddNamespaceDialog", "Create Namespace");
|
|
||||||
await app.client.keys(`${TEST_NAMESPACE}\n`);
|
|
||||||
await app.client.waitForExist(`.name=${TEST_NAMESPACE}`);
|
|
||||||
});
|
|
||||||
|
|
||||||
it(`creates a pod in ${TEST_NAMESPACE} namespace`, async () => {
|
|
||||||
expect(clusterAdded).toBe(true);
|
|
||||||
await app.client.click(".sidebar-nav [data-test-id='workloads'] span.link-text");
|
|
||||||
await app.client.waitUntilTextExists('a[href^="/pods"]', "Pods");
|
|
||||||
await app.client.click('a[href^="/pods"]');
|
|
||||||
await app.client.waitUntilTextExists("div.TableCell", "kube-apiserver");
|
|
||||||
await app.client.click(".Icon.new-dock-tab");
|
|
||||||
await app.client.waitUntilTextExists("li.MenuItem.create-resource-tab", "Create resource");
|
|
||||||
await app.client.click("li.MenuItem.create-resource-tab");
|
|
||||||
await app.client.waitForVisible(".CreateResource div.ace_content");
|
|
||||||
// Write pod manifest to editor
|
|
||||||
await app.client.keys("apiVersion: v1\n");
|
|
||||||
await app.client.keys("kind: Pod\n");
|
|
||||||
await app.client.keys("metadata:\n");
|
|
||||||
await app.client.keys(" name: nginx-create-pod-test\n");
|
|
||||||
await app.client.keys(`namespace: ${TEST_NAMESPACE}\n`);
|
|
||||||
await app.client.keys(`${BACKSPACE}spec:\n`);
|
|
||||||
await app.client.keys(" containers:\n");
|
|
||||||
await app.client.keys("- name: nginx-create-pod-test\n");
|
|
||||||
await app.client.keys(" image: nginx:alpine\n");
|
|
||||||
// Create deployment
|
|
||||||
await app.client.waitForEnabled("button.Button=Create & Close");
|
|
||||||
await app.client.click("button.Button=Create & Close");
|
|
||||||
// Wait until first bits of pod appears on dashboard
|
|
||||||
await app.client.waitForExist(".name=nginx-create-pod-test");
|
|
||||||
// Open pod details
|
|
||||||
await app.client.click(".name=nginx-create-pod-test");
|
|
||||||
await app.client.waitUntilTextExists("div.drawer-title-text", "Pod: nginx-create-pod-test");
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|||||||
450
integration/__tests__/cluster-pages.tests.ts
Normal file
450
integration/__tests__/cluster-pages.tests.ts
Normal file
@ -0,0 +1,450 @@
|
|||||||
|
/*
|
||||||
|
Cluster tests are run if there is a pre-existing minikube cluster. Before running cluster tests the TEST_NAMESPACE
|
||||||
|
namespace is removed, if it exists, from the minikube cluster. Resources are created as part of the cluster tests in the
|
||||||
|
TEST_NAMESPACE namespace. This is done to minimize destructive impact of the cluster tests on an existing minikube
|
||||||
|
cluster and vice versa.
|
||||||
|
*/
|
||||||
|
import { Application } from "spectron";
|
||||||
|
import * as utils from "../helpers/utils";
|
||||||
|
import { addMinikubeCluster, minikubeReady, waitForMinikubeDashboard } from "../helpers/minikube";
|
||||||
|
import { exec } from "child_process";
|
||||||
|
import * as util from "util";
|
||||||
|
|
||||||
|
export const promiseExec = util.promisify(exec);
|
||||||
|
|
||||||
|
jest.setTimeout(60000);
|
||||||
|
|
||||||
|
// FIXME (!): improve / simplify all css-selectors + use [data-test-id="some-id"] (already used in some tests below)
|
||||||
|
describe("Lens cluster pages", () => {
|
||||||
|
const TEST_NAMESPACE = "integration-tests";
|
||||||
|
const BACKSPACE = "\uE003";
|
||||||
|
let app: Application;
|
||||||
|
const ready = minikubeReady(TEST_NAMESPACE);
|
||||||
|
|
||||||
|
utils.describeIf(ready)("test common pages", () => {
|
||||||
|
let clusterAdded = false;
|
||||||
|
const addCluster = async () => {
|
||||||
|
await utils.clickWhatsNew(app);
|
||||||
|
await addMinikubeCluster(app);
|
||||||
|
await waitForMinikubeDashboard(app);
|
||||||
|
await app.client.click('a[href="/nodes"]');
|
||||||
|
await app.client.waitUntilTextExists("div.TableCell", "Ready");
|
||||||
|
};
|
||||||
|
|
||||||
|
describe("cluster add", () => {
|
||||||
|
beforeAll(async () => app = await utils.appStart(), 20000);
|
||||||
|
|
||||||
|
afterAll(async () => {
|
||||||
|
if (app && app.isRunning()) {
|
||||||
|
return utils.tearDown(app);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
it("allows to add a cluster", async () => {
|
||||||
|
await addCluster();
|
||||||
|
clusterAdded = true;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
const appStartAddCluster = async () => {
|
||||||
|
if (clusterAdded) {
|
||||||
|
app = await utils.appStart();
|
||||||
|
await addCluster();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
describe("cluster pages", () => {
|
||||||
|
|
||||||
|
beforeAll(appStartAddCluster, 40000);
|
||||||
|
|
||||||
|
afterAll(async () => {
|
||||||
|
if (app && app.isRunning()) {
|
||||||
|
return utils.tearDown(app);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const tests: {
|
||||||
|
drawer?: string
|
||||||
|
drawerId?: string
|
||||||
|
pages: {
|
||||||
|
name: string,
|
||||||
|
href: string,
|
||||||
|
expectedSelector: string,
|
||||||
|
expectedText: string
|
||||||
|
}[]
|
||||||
|
}[] = [{
|
||||||
|
drawer: "",
|
||||||
|
drawerId: "",
|
||||||
|
pages: [{
|
||||||
|
name: "Cluster",
|
||||||
|
href: "cluster",
|
||||||
|
expectedSelector: "div.ClusterOverview div.label",
|
||||||
|
expectedText: "Master"
|
||||||
|
}]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
drawer: "",
|
||||||
|
drawerId: "",
|
||||||
|
pages: [{
|
||||||
|
name: "Nodes",
|
||||||
|
href: "nodes",
|
||||||
|
expectedSelector: "h5.title",
|
||||||
|
expectedText: "Nodes"
|
||||||
|
}]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
drawer: "Workloads",
|
||||||
|
drawerId: "workloads",
|
||||||
|
pages: [{
|
||||||
|
name: "Overview",
|
||||||
|
href: "workloads",
|
||||||
|
expectedSelector: "h5.box",
|
||||||
|
expectedText: "Overview"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Pods",
|
||||||
|
href: "pods",
|
||||||
|
expectedSelector: "h5.title",
|
||||||
|
expectedText: "Pods"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Deployments",
|
||||||
|
href: "deployments",
|
||||||
|
expectedSelector: "h5.title",
|
||||||
|
expectedText: "Deployments"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "DaemonSets",
|
||||||
|
href: "daemonsets",
|
||||||
|
expectedSelector: "h5.title",
|
||||||
|
expectedText: "Daemon Sets"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "StatefulSets",
|
||||||
|
href: "statefulsets",
|
||||||
|
expectedSelector: "h5.title",
|
||||||
|
expectedText: "Stateful Sets"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "ReplicaSets",
|
||||||
|
href: "replicasets",
|
||||||
|
expectedSelector: "h5.title",
|
||||||
|
expectedText: "Replica Sets"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Jobs",
|
||||||
|
href: "jobs",
|
||||||
|
expectedSelector: "h5.title",
|
||||||
|
expectedText: "Jobs"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "CronJobs",
|
||||||
|
href: "cronjobs",
|
||||||
|
expectedSelector: "h5.title",
|
||||||
|
expectedText: "Cron Jobs"
|
||||||
|
}]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
drawer: "Configuration",
|
||||||
|
drawerId: "config",
|
||||||
|
pages: [{
|
||||||
|
name: "ConfigMaps",
|
||||||
|
href: "configmaps",
|
||||||
|
expectedSelector: "h5.title",
|
||||||
|
expectedText: "Config Maps"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Secrets",
|
||||||
|
href: "secrets",
|
||||||
|
expectedSelector: "h5.title",
|
||||||
|
expectedText: "Secrets"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Resource Quotas",
|
||||||
|
href: "resourcequotas",
|
||||||
|
expectedSelector: "h5.title",
|
||||||
|
expectedText: "Resource Quotas"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Limit Ranges",
|
||||||
|
href: "limitranges",
|
||||||
|
expectedSelector: "h5.title",
|
||||||
|
expectedText: "Limit Ranges"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "HPA",
|
||||||
|
href: "hpa",
|
||||||
|
expectedSelector: "h5.title",
|
||||||
|
expectedText: "Horizontal Pod Autoscalers"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Pod Disruption Budgets",
|
||||||
|
href: "poddisruptionbudgets",
|
||||||
|
expectedSelector: "h5.title",
|
||||||
|
expectedText: "Pod Disruption Budgets"
|
||||||
|
}]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
drawer: "Network",
|
||||||
|
drawerId: "networks",
|
||||||
|
pages: [{
|
||||||
|
name: "Services",
|
||||||
|
href: "services",
|
||||||
|
expectedSelector: "h5.title",
|
||||||
|
expectedText: "Services"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Endpoints",
|
||||||
|
href: "endpoints",
|
||||||
|
expectedSelector: "h5.title",
|
||||||
|
expectedText: "Endpoints"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Ingresses",
|
||||||
|
href: "ingresses",
|
||||||
|
expectedSelector: "h5.title",
|
||||||
|
expectedText: "Ingresses"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Network Policies",
|
||||||
|
href: "network-policies",
|
||||||
|
expectedSelector: "h5.title",
|
||||||
|
expectedText: "Network Policies"
|
||||||
|
}]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
drawer: "Storage",
|
||||||
|
drawerId: "storage",
|
||||||
|
pages: [{
|
||||||
|
name: "Persistent Volume Claims",
|
||||||
|
href: "persistent-volume-claims",
|
||||||
|
expectedSelector: "h5.title",
|
||||||
|
expectedText: "Persistent Volume Claims"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Persistent Volumes",
|
||||||
|
href: "persistent-volumes",
|
||||||
|
expectedSelector: "h5.title",
|
||||||
|
expectedText: "Persistent Volumes"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Storage Classes",
|
||||||
|
href: "storage-classes",
|
||||||
|
expectedSelector: "h5.title",
|
||||||
|
expectedText: "Storage Classes"
|
||||||
|
}]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
drawer: "",
|
||||||
|
drawerId: "",
|
||||||
|
pages: [{
|
||||||
|
name: "Namespaces",
|
||||||
|
href: "namespaces",
|
||||||
|
expectedSelector: "h5.title",
|
||||||
|
expectedText: "Namespaces"
|
||||||
|
}]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
drawer: "",
|
||||||
|
drawerId: "",
|
||||||
|
pages: [{
|
||||||
|
name: "Events",
|
||||||
|
href: "events",
|
||||||
|
expectedSelector: "h5.title",
|
||||||
|
expectedText: "Events"
|
||||||
|
}]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
drawer: "Apps",
|
||||||
|
drawerId: "apps",
|
||||||
|
pages: [{
|
||||||
|
name: "Charts",
|
||||||
|
href: "apps/charts",
|
||||||
|
expectedSelector: "div.HelmCharts input",
|
||||||
|
expectedText: ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Releases",
|
||||||
|
href: "apps/releases",
|
||||||
|
expectedSelector: "h5.title",
|
||||||
|
expectedText: "Releases"
|
||||||
|
}]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
drawer: "Access Control",
|
||||||
|
drawerId: "users",
|
||||||
|
pages: [{
|
||||||
|
name: "Service Accounts",
|
||||||
|
href: "service-accounts",
|
||||||
|
expectedSelector: "h5.title",
|
||||||
|
expectedText: "Service Accounts"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Role Bindings",
|
||||||
|
href: "role-bindings",
|
||||||
|
expectedSelector: "h5.title",
|
||||||
|
expectedText: "Role Bindings"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Roles",
|
||||||
|
href: "roles",
|
||||||
|
expectedSelector: "h5.title",
|
||||||
|
expectedText: "Roles"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Pod Security Policies",
|
||||||
|
href: "pod-security-policies",
|
||||||
|
expectedSelector: "h5.title",
|
||||||
|
expectedText: "Pod Security Policies"
|
||||||
|
}]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
drawer: "Custom Resources",
|
||||||
|
drawerId: "custom-resources",
|
||||||
|
pages: [{
|
||||||
|
name: "Definitions",
|
||||||
|
href: "crd/definitions",
|
||||||
|
expectedSelector: "h5.title",
|
||||||
|
expectedText: "Custom Resources"
|
||||||
|
}]
|
||||||
|
}];
|
||||||
|
|
||||||
|
tests.forEach(({ drawer = "", drawerId = "", pages }) => {
|
||||||
|
if (drawer !== "") {
|
||||||
|
it(`shows ${drawer} drawer`, async () => {
|
||||||
|
expect(clusterAdded).toBe(true);
|
||||||
|
await app.client.click(`.sidebar-nav [data-test-id="${drawerId}"] span.link-text`);
|
||||||
|
await app.client.waitUntilTextExists(`a[href^="/${pages[0].href}"]`, pages[0].name);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
pages.forEach(({ name, href, expectedSelector, expectedText }) => {
|
||||||
|
it(`shows ${drawer}->${name} page`, async () => {
|
||||||
|
expect(clusterAdded).toBe(true);
|
||||||
|
await app.client.click(`a[href^="/${href}"]`);
|
||||||
|
await app.client.waitUntilTextExists(expectedSelector, expectedText);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
if (drawer !== "") {
|
||||||
|
// hide the drawer
|
||||||
|
it(`hides ${drawer} drawer`, async () => {
|
||||||
|
expect(clusterAdded).toBe(true);
|
||||||
|
await app.client.click(`.sidebar-nav [data-test-id="${drawerId}"] span.link-text`);
|
||||||
|
await expect(app.client.waitUntilTextExists(`a[href^="/${pages[0].href}"]`, pages[0].name, 100)).rejects.toThrow();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("viewing pod logs", () => {
|
||||||
|
beforeEach(appStartAddCluster, 40000);
|
||||||
|
|
||||||
|
afterEach(async () => {
|
||||||
|
if (app && app.isRunning()) {
|
||||||
|
return utils.tearDown(app);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
it(`shows a logs for a pod`, async () => {
|
||||||
|
expect(clusterAdded).toBe(true);
|
||||||
|
// Go to Pods page
|
||||||
|
await app.client.click(".sidebar-nav [data-test-id='workloads'] span.link-text");
|
||||||
|
await app.client.waitUntilTextExists('a[href^="/pods"]', "Pods");
|
||||||
|
await app.client.click('a[href^="/pods"]');
|
||||||
|
await app.client.click(".NamespaceSelect");
|
||||||
|
await app.client.keys("kube-system");
|
||||||
|
await app.client.keys("Enter");// "\uE007"
|
||||||
|
await app.client.waitUntilTextExists("div.TableCell", "kube-apiserver");
|
||||||
|
let podMenuItemEnabled = false;
|
||||||
|
|
||||||
|
// Wait until extensions are enabled on renderer
|
||||||
|
while (!podMenuItemEnabled) {
|
||||||
|
const logs = await app.client.getRenderProcessLogs();
|
||||||
|
|
||||||
|
podMenuItemEnabled = !!logs.find(entry => entry.message.includes("[EXTENSION]: enabled lens-pod-menu@"));
|
||||||
|
|
||||||
|
if (!podMenuItemEnabled) {
|
||||||
|
await new Promise(r => setTimeout(r, 1000));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
await new Promise(r => setTimeout(r, 500)); // Give some extra time to prepare extensions
|
||||||
|
// Open logs tab in dock
|
||||||
|
await app.client.click(".list .TableRow:first-child");
|
||||||
|
await app.client.waitForVisible(".Drawer");
|
||||||
|
await app.client.click(".drawer-title .Menu li:nth-child(2)");
|
||||||
|
// Check if controls are available
|
||||||
|
await app.client.waitForVisible(".LogList .VirtualList");
|
||||||
|
await app.client.waitForVisible(".LogResourceSelector");
|
||||||
|
//await app.client.waitForVisible(".LogSearch .SearchInput");
|
||||||
|
await app.client.waitForVisible(".LogSearch .SearchInput input");
|
||||||
|
// Search for semicolon
|
||||||
|
await app.client.keys(":");
|
||||||
|
await app.client.waitForVisible(".LogList .list span.active");
|
||||||
|
// Click through controls
|
||||||
|
await app.client.click(".LogControls .show-timestamps");
|
||||||
|
await app.client.click(".LogControls .show-previous");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("cluster operations", () => {
|
||||||
|
beforeEach(appStartAddCluster, 40000);
|
||||||
|
|
||||||
|
afterEach(async () => {
|
||||||
|
if (app && app.isRunning()) {
|
||||||
|
return utils.tearDown(app);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
it("shows default namespace", async () => {
|
||||||
|
expect(clusterAdded).toBe(true);
|
||||||
|
await app.client.click('a[href="/namespaces"]');
|
||||||
|
await app.client.waitUntilTextExists("div.TableCell", "default");
|
||||||
|
await app.client.waitUntilTextExists("div.TableCell", "kube-system");
|
||||||
|
});
|
||||||
|
|
||||||
|
it(`creates ${TEST_NAMESPACE} namespace`, async () => {
|
||||||
|
expect(clusterAdded).toBe(true);
|
||||||
|
await app.client.click('a[href="/namespaces"]');
|
||||||
|
await app.client.waitUntilTextExists("div.TableCell", "default");
|
||||||
|
await app.client.waitUntilTextExists("div.TableCell", "kube-system");
|
||||||
|
await app.client.click("button.add-button");
|
||||||
|
await app.client.waitUntilTextExists("div.AddNamespaceDialog", "Create Namespace");
|
||||||
|
await app.client.keys(`${TEST_NAMESPACE}\n`);
|
||||||
|
await app.client.waitForExist(`.name=${TEST_NAMESPACE}`);
|
||||||
|
});
|
||||||
|
|
||||||
|
it(`creates a pod in ${TEST_NAMESPACE} namespace`, async () => {
|
||||||
|
expect(clusterAdded).toBe(true);
|
||||||
|
await app.client.click(".sidebar-nav [data-test-id='workloads'] span.link-text");
|
||||||
|
await app.client.waitUntilTextExists('a[href^="/pods"]', "Pods");
|
||||||
|
await app.client.click('a[href^="/pods"]');
|
||||||
|
|
||||||
|
await app.client.click(".NamespaceSelect");
|
||||||
|
await app.client.keys(TEST_NAMESPACE);
|
||||||
|
await app.client.keys("Enter");// "\uE007"
|
||||||
|
await app.client.click(".Icon.new-dock-tab");
|
||||||
|
await app.client.waitUntilTextExists("li.MenuItem.create-resource-tab", "Create resource");
|
||||||
|
await app.client.click("li.MenuItem.create-resource-tab");
|
||||||
|
await app.client.waitForVisible(".CreateResource div.ace_content");
|
||||||
|
// Write pod manifest to editor
|
||||||
|
await app.client.keys("apiVersion: v1\n");
|
||||||
|
await app.client.keys("kind: Pod\n");
|
||||||
|
await app.client.keys("metadata:\n");
|
||||||
|
await app.client.keys(" name: nginx-create-pod-test\n");
|
||||||
|
await app.client.keys(`namespace: ${TEST_NAMESPACE}\n`);
|
||||||
|
await app.client.keys(`${BACKSPACE}spec:\n`);
|
||||||
|
await app.client.keys(" containers:\n");
|
||||||
|
await app.client.keys("- name: nginx-create-pod-test\n");
|
||||||
|
await app.client.keys(" image: nginx:alpine\n");
|
||||||
|
// Create deployment
|
||||||
|
await app.client.waitForEnabled("button.Button=Create & Close");
|
||||||
|
await app.client.click("button.Button=Create & Close");
|
||||||
|
// Wait until first bits of pod appears on dashboard
|
||||||
|
await app.client.waitForExist(".name=nginx-create-pod-test");
|
||||||
|
// Open pod details
|
||||||
|
await app.client.click(".name=nginx-create-pod-test");
|
||||||
|
await app.client.waitUntilTextExists("div.drawer-title-text", "Pod: nginx-create-pod-test");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
25
integration/__tests__/command-palette.tests.ts
Normal file
25
integration/__tests__/command-palette.tests.ts
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
import { Application } from "spectron";
|
||||||
|
import * as utils from "../helpers/utils";
|
||||||
|
|
||||||
|
jest.setTimeout(60000);
|
||||||
|
|
||||||
|
describe("Lens command palette", () => {
|
||||||
|
let app: Application;
|
||||||
|
|
||||||
|
describe("menu", () => {
|
||||||
|
beforeAll(async () => app = await utils.appStart(), 20000);
|
||||||
|
|
||||||
|
afterAll(async () => {
|
||||||
|
if (app?.isRunning()) {
|
||||||
|
await utils.tearDown(app);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
it("opens command dialog from menu", async () => {
|
||||||
|
await utils.clickWhatsNew(app);
|
||||||
|
await app.electron.ipcRenderer.send("test-menu-item-click", "View", "Command Palette...");
|
||||||
|
await app.client.waitUntilTextExists(".Select__option", "Preferences: Open");
|
||||||
|
await app.client.keys("Escape");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
75
integration/__tests__/workspace.tests.ts
Normal file
75
integration/__tests__/workspace.tests.ts
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
import { Application } from "spectron";
|
||||||
|
import * as utils from "../helpers/utils";
|
||||||
|
import { addMinikubeCluster, minikubeReady } from "../helpers/minikube";
|
||||||
|
import { exec } from "child_process";
|
||||||
|
import * as util from "util";
|
||||||
|
|
||||||
|
export const promiseExec = util.promisify(exec);
|
||||||
|
|
||||||
|
jest.setTimeout(60000);
|
||||||
|
|
||||||
|
describe("Lens integration tests", () => {
|
||||||
|
let app: Application;
|
||||||
|
const ready = minikubeReady("workspace-int-tests");
|
||||||
|
|
||||||
|
utils.describeIf(ready)("workspaces", () => {
|
||||||
|
beforeAll(async () => {
|
||||||
|
app = await utils.appStart();
|
||||||
|
await utils.clickWhatsNew(app);
|
||||||
|
}, 20000);
|
||||||
|
|
||||||
|
afterAll(async () => {
|
||||||
|
if (app && app.isRunning()) {
|
||||||
|
return utils.tearDown(app);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const switchToWorkspace = async (name: string) => {
|
||||||
|
await app.client.click("[data-test-id=current-workspace]");
|
||||||
|
await app.client.keys(name);
|
||||||
|
await app.client.keys("Enter");
|
||||||
|
await app.client.waitUntilTextExists("[data-test-id=current-workspace-name]", name);
|
||||||
|
};
|
||||||
|
|
||||||
|
const createWorkspace = async (name: string) => {
|
||||||
|
await app.client.click("[data-test-id=current-workspace]");
|
||||||
|
await app.client.keys("add workspace");
|
||||||
|
await app.client.keys("Enter");
|
||||||
|
await app.client.keys(name);
|
||||||
|
await app.client.keys("Enter");
|
||||||
|
await app.client.waitUntilTextExists("[data-test-id=current-workspace-name]", name);
|
||||||
|
};
|
||||||
|
|
||||||
|
it("creates new workspace", async () => {
|
||||||
|
const name = "test-workspace";
|
||||||
|
|
||||||
|
await createWorkspace(name);
|
||||||
|
await app.client.waitUntilTextExists("[data-test-id=current-workspace-name]", name);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("edits current workspaces", async () => {
|
||||||
|
await createWorkspace("to-be-edited");
|
||||||
|
await app.client.click("[data-test-id=current-workspace]");
|
||||||
|
await app.client.keys("edit current workspace");
|
||||||
|
await app.client.keys("Enter");
|
||||||
|
await app.client.keys("edited-workspace");
|
||||||
|
await app.client.keys("Enter");
|
||||||
|
await app.client.waitUntilTextExists("[data-test-id=current-workspace-name]", "edited-workspace");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("adds cluster in default workspace", async () => {
|
||||||
|
await switchToWorkspace("default");
|
||||||
|
await addMinikubeCluster(app);
|
||||||
|
await app.client.waitUntilTextExists("pre.kube-auth-out", "Authentication proxy started");
|
||||||
|
await app.client.waitForExist(`iframe[name="minikube"]`);
|
||||||
|
await app.client.waitForVisible(".ClustersMenu .ClusterIcon.active");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("adds cluster in test-workspace", async () => {
|
||||||
|
await switchToWorkspace("test-workspace");
|
||||||
|
await addMinikubeCluster(app);
|
||||||
|
await app.client.waitUntilTextExists("pre.kube-auth-out", "Authentication proxy started");
|
||||||
|
await app.client.waitForExist(`iframe[name="minikube"]`);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
59
integration/helpers/minikube.ts
Normal file
59
integration/helpers/minikube.ts
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
import { spawnSync } from "child_process";
|
||||||
|
import { Application } from "spectron";
|
||||||
|
|
||||||
|
export function minikubeReady(testNamespace: string): boolean {
|
||||||
|
// determine if minikube is running
|
||||||
|
{
|
||||||
|
const { status } = spawnSync("minikube status", { shell: true });
|
||||||
|
|
||||||
|
if (status !== 0) {
|
||||||
|
console.warn("minikube not running");
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove TEST_NAMESPACE if it already exists
|
||||||
|
{
|
||||||
|
const { status } = spawnSync(`minikube kubectl -- get namespace ${testNamespace}`, { shell: true });
|
||||||
|
|
||||||
|
if (status === 0) {
|
||||||
|
console.warn(`Removing existing ${testNamespace} namespace`);
|
||||||
|
|
||||||
|
const { status, stdout, stderr } = spawnSync(
|
||||||
|
`minikube kubectl -- delete namespace ${testNamespace}`,
|
||||||
|
{ shell: true },
|
||||||
|
);
|
||||||
|
|
||||||
|
if (status !== 0) {
|
||||||
|
console.warn(`Error removing ${testNamespace} namespace: ${stderr.toString()}`);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(stdout.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function addMinikubeCluster(app: Application) {
|
||||||
|
await app.client.click("div.add-cluster");
|
||||||
|
await app.client.waitUntilTextExists("div", "Select kubeconfig file");
|
||||||
|
await app.client.click("div.Select__control"); // show the context drop-down list
|
||||||
|
await app.client.waitUntilTextExists("div", "minikube");
|
||||||
|
|
||||||
|
if (!await app.client.$("button.primary").isEnabled()) {
|
||||||
|
await app.client.click("div.minikube"); // select minikube context
|
||||||
|
} // else the only context, which must be 'minikube', is automatically selected
|
||||||
|
await app.client.click("div.Select__control"); // hide the context drop-down list (it might be obscuring the Add cluster(s) button)
|
||||||
|
await app.client.click("button.primary"); // add minikube cluster
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function waitForMinikubeDashboard(app: Application) {
|
||||||
|
await app.client.waitUntilTextExists("pre.kube-auth-out", "Authentication proxy started");
|
||||||
|
await app.client.waitForExist(`iframe[name="minikube"]`);
|
||||||
|
await app.client.frame("minikube");
|
||||||
|
await app.client.waitUntilTextExists("span.link-text", "Cluster");
|
||||||
|
}
|
||||||
@ -1,4 +1,6 @@
|
|||||||
import { Application } from "spectron";
|
import { Application } from "spectron";
|
||||||
|
import * as util from "util";
|
||||||
|
import { exec } from "child_process";
|
||||||
|
|
||||||
const AppPaths: Partial<Record<NodeJS.Platform, string>> = {
|
const AppPaths: Partial<Record<NodeJS.Platform, string>> = {
|
||||||
"win32": "./dist/win-unpacked/Lens.exe",
|
"win32": "./dist/win-unpacked/Lens.exe",
|
||||||
@ -26,6 +28,28 @@ export function setup(): Application {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const keys = {
|
||||||
|
backspace: "\uE003"
|
||||||
|
};
|
||||||
|
|
||||||
|
export async function appStart() {
|
||||||
|
const app = setup();
|
||||||
|
|
||||||
|
await app.start();
|
||||||
|
// Wait for splash screen to be closed
|
||||||
|
while (await app.client.getWindowCount() > 1);
|
||||||
|
await app.client.windowByIndex(0);
|
||||||
|
await app.client.waitUntilWindowLoaded();
|
||||||
|
|
||||||
|
return app;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function clickWhatsNew(app: Application) {
|
||||||
|
await app.client.waitUntilTextExists("h1", "What's new?");
|
||||||
|
await app.client.click("button.primary");
|
||||||
|
await app.client.waitUntilTextExists("h1", "Welcome");
|
||||||
|
}
|
||||||
|
|
||||||
type AsyncPidGetter = () => Promise<number>;
|
type AsyncPidGetter = () => Promise<number>;
|
||||||
|
|
||||||
export async function tearDown(app: Application) {
|
export async function tearDown(app: Application) {
|
||||||
@ -39,3 +63,26 @@ export async function tearDown(app: Application) {
|
|||||||
console.error(e);
|
console.error(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const promiseExec = util.promisify(exec);
|
||||||
|
|
||||||
|
type HelmRepository = {
|
||||||
|
name: string;
|
||||||
|
url: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export async function listHelmRepositories(retries = 0): Promise<HelmRepository[]>{
|
||||||
|
if (retries < 5) {
|
||||||
|
try {
|
||||||
|
const { stdout: reposJson } = await promiseExec("helm repo list -o json");
|
||||||
|
|
||||||
|
return JSON.parse(reposJson);
|
||||||
|
} catch {
|
||||||
|
await new Promise(r => setTimeout(r, 2000)); // if no repositories, wait for Lens adding bitnami repository
|
||||||
|
|
||||||
|
return await listHelmRepositories((retries + 1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|||||||
@ -34,7 +34,7 @@ nav:
|
|||||||
- Main Extension: extensions/guides/main-extension.md
|
- Main Extension: extensions/guides/main-extension.md
|
||||||
- Renderer Extension: extensions/guides/renderer-extension.md
|
- Renderer Extension: extensions/guides/renderer-extension.md
|
||||||
- Stores: extensions/guides/stores.md
|
- Stores: extensions/guides/stores.md
|
||||||
- Working with mobx: extensions/guides/working-with-mobx.md
|
- Working with MobX: extensions/guides/working-with-mobx.md
|
||||||
- Testing and Publishing:
|
- Testing and Publishing:
|
||||||
- Testing Extensions: extensions/testing-and-publishing/testing.md
|
- Testing Extensions: extensions/testing-and-publishing/testing.md
|
||||||
- Publishing Extensions: extensions/testing-and-publishing/publishing.md
|
- Publishing Extensions: extensions/testing-and-publishing/publishing.md
|
||||||
@ -81,6 +81,8 @@ markdown_extensions:
|
|||||||
- toc:
|
- toc:
|
||||||
permalink: "#"
|
permalink: "#"
|
||||||
toc_depth: 3
|
toc_depth: 3
|
||||||
|
- admonition: {}
|
||||||
|
- pymdownx.details: {}
|
||||||
|
|
||||||
extra:
|
extra:
|
||||||
generator: false
|
generator: false
|
||||||
|
|||||||
43
package.json
43
package.json
@ -2,7 +2,7 @@
|
|||||||
"name": "kontena-lens",
|
"name": "kontena-lens",
|
||||||
"productName": "Lens",
|
"productName": "Lens",
|
||||||
"description": "Lens - The Kubernetes IDE",
|
"description": "Lens - The Kubernetes IDE",
|
||||||
"version": "4.1.0-alpha.0",
|
"version": "4.2.0-alpha.0",
|
||||||
"main": "static/build/main.js",
|
"main": "static/build/main.js",
|
||||||
"copyright": "© 2020, Mirantis, Inc.",
|
"copyright": "© 2020, Mirantis, Inc.",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
@ -16,7 +16,7 @@
|
|||||||
"dev-run": "nodemon --watch static/build/main.js --exec \"electron --inspect .\"",
|
"dev-run": "nodemon --watch static/build/main.js --exec \"electron --inspect .\"",
|
||||||
"dev:main": "yarn run compile:main --watch",
|
"dev:main": "yarn run compile:main --watch",
|
||||||
"dev:renderer": "yarn run webpack-dev-server --config webpack.renderer.ts",
|
"dev:renderer": "yarn run webpack-dev-server --config webpack.renderer.ts",
|
||||||
"dev:extension-types": "yarn run compile:extension-types --watch",
|
"dev:extension-types": "yarn run compile:extension-types --watch --progress",
|
||||||
"compile": "env NODE_ENV=production concurrently yarn:compile:*",
|
"compile": "env NODE_ENV=production concurrently yarn:compile:*",
|
||||||
"compile:main": "yarn run webpack --config webpack.main.ts",
|
"compile:main": "yarn run webpack --config webpack.main.ts",
|
||||||
"compile:renderer": "yarn run webpack --config webpack.renderer.ts",
|
"compile:renderer": "yarn run webpack --config webpack.renderer.ts",
|
||||||
@ -26,7 +26,7 @@
|
|||||||
"build:mac": "yarn run compile && electron-builder --mac --dir -c.productName=Lens",
|
"build:mac": "yarn run compile && electron-builder --mac --dir -c.productName=Lens",
|
||||||
"build:win": "yarn run compile && electron-builder --win --dir -c.productName=Lens",
|
"build:win": "yarn run compile && electron-builder --win --dir -c.productName=Lens",
|
||||||
"test": "jest --env=jsdom src $@",
|
"test": "jest --env=jsdom src $@",
|
||||||
"integration": "jest --coverage integration $@",
|
"integration": "jest --runInBand integration",
|
||||||
"dist": "yarn run compile && electron-builder --publish onTag",
|
"dist": "yarn run compile && electron-builder --publish onTag",
|
||||||
"dist:win": "yarn run compile && electron-builder --publish onTag --x64 --ia32",
|
"dist:win": "yarn run compile && electron-builder --publish onTag --x64 --ia32",
|
||||||
"dist:dir": "yarn run dist --dir -c.compression=store -c.mac.identity=null",
|
"dist:dir": "yarn run dist --dir -c.compression=store -c.mac.identity=null",
|
||||||
@ -42,7 +42,7 @@
|
|||||||
"typedocs-extensions-api": "yarn run typedoc --ignoreCompilerErrors --readme docs/extensions/typedoc-readme.md.tpl --name @k8slens/extensions --out docs/extensions/api --mode library --excludePrivate --hideBreadcrumbs --includes src/ src/extensions/extension-api.ts"
|
"typedocs-extensions-api": "yarn run typedoc --ignoreCompilerErrors --readme docs/extensions/typedoc-readme.md.tpl --name @k8slens/extensions --out docs/extensions/api --mode library --excludePrivate --hideBreadcrumbs --includes src/ src/extensions/extension-api.ts"
|
||||||
},
|
},
|
||||||
"config": {
|
"config": {
|
||||||
"bundledKubectlVersion": "1.17.15",
|
"bundledKubectlVersion": "1.18.15",
|
||||||
"bundledHelmVersion": "3.4.2"
|
"bundledHelmVersion": "3.4.2"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
@ -103,7 +103,10 @@
|
|||||||
],
|
],
|
||||||
"linux": {
|
"linux": {
|
||||||
"category": "Network",
|
"category": "Network",
|
||||||
|
"artifactName": "${productName}-${version}.${arch}.${ext}",
|
||||||
"target": [
|
"target": [
|
||||||
|
"deb",
|
||||||
|
"rpm",
|
||||||
"snap",
|
"snap",
|
||||||
"AppImage"
|
"AppImage"
|
||||||
],
|
],
|
||||||
@ -154,7 +157,12 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"nsis": {
|
"nsis": {
|
||||||
"include": "build/installer.nsh"
|
"include": "build/installer.nsh",
|
||||||
|
"oneClick": false,
|
||||||
|
"allowToChangeInstallationDirectory": true
|
||||||
|
},
|
||||||
|
"snap": {
|
||||||
|
"confinement": "classic"
|
||||||
},
|
},
|
||||||
"publish": [
|
"publish": [
|
||||||
{
|
{
|
||||||
@ -162,10 +170,7 @@
|
|||||||
"repo": "lens",
|
"repo": "lens",
|
||||||
"owner": "lensapp"
|
"owner": "lensapp"
|
||||||
}
|
}
|
||||||
],
|
]
|
||||||
"snap": {
|
|
||||||
"confinement": "classic"
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"lens": {
|
"lens": {
|
||||||
"extensions": [
|
"extensions": [
|
||||||
@ -174,7 +179,8 @@
|
|||||||
"node-menu",
|
"node-menu",
|
||||||
"metrics-cluster-feature",
|
"metrics-cluster-feature",
|
||||||
"license-menu-item",
|
"license-menu-item",
|
||||||
"kube-object-event-status"
|
"kube-object-event-status",
|
||||||
|
"survey"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@ -183,6 +189,7 @@
|
|||||||
"@kubernetes/client-node": "^0.12.0",
|
"@kubernetes/client-node": "^0.12.0",
|
||||||
"array-move": "^3.0.0",
|
"array-move": "^3.0.0",
|
||||||
"await-lock": "^2.1.0",
|
"await-lock": "^2.1.0",
|
||||||
|
"byline": "^5.0.0",
|
||||||
"chalk": "^4.1.0",
|
"chalk": "^4.1.0",
|
||||||
"chokidar": "^3.4.3",
|
"chokidar": "^3.4.3",
|
||||||
"command-exists": "1.2.9",
|
"command-exists": "1.2.9",
|
||||||
@ -200,7 +207,7 @@
|
|||||||
"jsonpath": "^1.0.2",
|
"jsonpath": "^1.0.2",
|
||||||
"lodash": "^4.17.15",
|
"lodash": "^4.17.15",
|
||||||
"mac-ca": "^1.0.4",
|
"mac-ca": "^1.0.4",
|
||||||
"marked": "^1.1.0",
|
"marked": "^1.2.7",
|
||||||
"md5-file": "^5.0.0",
|
"md5-file": "^5.0.0",
|
||||||
"mobx": "^5.15.7",
|
"mobx": "^5.15.7",
|
||||||
"mobx-observable-history": "^1.0.3",
|
"mobx-observable-history": "^1.0.3",
|
||||||
@ -215,11 +222,12 @@
|
|||||||
"react": "^17.0.1",
|
"react": "^17.0.1",
|
||||||
"react-dom": "^17.0.1",
|
"react-dom": "^17.0.1",
|
||||||
"react-router": "^5.2.0",
|
"react-router": "^5.2.0",
|
||||||
|
"readable-stream": "^3.6.0",
|
||||||
"request": "^2.88.2",
|
"request": "^2.88.2",
|
||||||
"request-promise-native": "^1.0.8",
|
"request-promise-native": "^1.0.8",
|
||||||
"semver": "^7.3.2",
|
"semver": "^7.3.2",
|
||||||
"serializr": "^2.0.3",
|
"serializr": "^2.0.3",
|
||||||
"shell-env": "^3.0.0",
|
"shell-env": "^3.0.1",
|
||||||
"spdy": "^4.0.2",
|
"spdy": "^4.0.2",
|
||||||
"tar": "^6.0.5",
|
"tar": "^6.0.5",
|
||||||
"tcp-port-used": "^1.0.1",
|
"tcp-port-used": "^1.0.1",
|
||||||
@ -236,6 +244,7 @@
|
|||||||
"@pmmmwh/react-refresh-webpack-plugin": "^0.4.3",
|
"@pmmmwh/react-refresh-webpack-plugin": "^0.4.3",
|
||||||
"@testing-library/jest-dom": "^5.11.5",
|
"@testing-library/jest-dom": "^5.11.5",
|
||||||
"@testing-library/react": "^11.1.0",
|
"@testing-library/react": "^11.1.0",
|
||||||
|
"@types/byline": "^4.2.32",
|
||||||
"@types/chart.js": "^2.9.21",
|
"@types/chart.js": "^2.9.21",
|
||||||
"@types/circular-dependency-plugin": "^5.0.1",
|
"@types/circular-dependency-plugin": "^5.0.1",
|
||||||
"@types/color": "^3.0.1",
|
"@types/color": "^3.0.1",
|
||||||
@ -244,7 +253,7 @@
|
|||||||
"@types/electron-devtools-installer": "^2.2.0",
|
"@types/electron-devtools-installer": "^2.2.0",
|
||||||
"@types/electron-window-state": "^2.0.34",
|
"@types/electron-window-state": "^2.0.34",
|
||||||
"@types/fs-extra": "^9.0.1",
|
"@types/fs-extra": "^9.0.1",
|
||||||
"@types/hapi": "^18.0.3",
|
"@types/hapi": "^18.0.5",
|
||||||
"@types/hoist-non-react-statics": "^3.3.1",
|
"@types/hoist-non-react-statics": "^3.3.1",
|
||||||
"@types/html-webpack-plugin": "^3.2.3",
|
"@types/html-webpack-plugin": "^3.2.3",
|
||||||
"@types/http-proxy": "^1.17.4",
|
"@types/http-proxy": "^1.17.4",
|
||||||
@ -268,6 +277,7 @@
|
|||||||
"@types/react-router-dom": "^5.1.6",
|
"@types/react-router-dom": "^5.1.6",
|
||||||
"@types/react-select": "^3.0.13",
|
"@types/react-select": "^3.0.13",
|
||||||
"@types/react-window": "^1.8.2",
|
"@types/react-window": "^1.8.2",
|
||||||
|
"@types/readable-stream": "^2.3.9",
|
||||||
"@types/request": "^2.48.5",
|
"@types/request": "^2.48.5",
|
||||||
"@types/request-promise-native": "^1.0.17",
|
"@types/request-promise-native": "^1.0.17",
|
||||||
"@types/semver": "^7.2.0",
|
"@types/semver": "^7.2.0",
|
||||||
@ -285,7 +295,7 @@
|
|||||||
"@types/webpack-dev-server": "^3.11.1",
|
"@types/webpack-dev-server": "^3.11.1",
|
||||||
"@types/webpack-env": "^1.15.2",
|
"@types/webpack-env": "^1.15.2",
|
||||||
"@types/webpack-node-externals": "^1.7.1",
|
"@types/webpack-node-externals": "^1.7.1",
|
||||||
"@typescript-eslint/eslint-plugin": "^4.12.0",
|
"@typescript-eslint/eslint-plugin": "^4.14.2",
|
||||||
"@typescript-eslint/parser": "^4.0.0",
|
"@typescript-eslint/parser": "^4.0.0",
|
||||||
"ace-builds": "^1.4.11",
|
"ace-builds": "^1.4.11",
|
||||||
"ansi_up": "^4.0.4",
|
"ansi_up": "^4.0.4",
|
||||||
@ -313,7 +323,7 @@
|
|||||||
"jest-canvas-mock": "^2.3.0",
|
"jest-canvas-mock": "^2.3.0",
|
||||||
"jest-fetch-mock": "^3.0.3",
|
"jest-fetch-mock": "^3.0.3",
|
||||||
"jest-mock-extended": "^1.0.10",
|
"jest-mock-extended": "^1.0.10",
|
||||||
"make-plural": "^6.2.1",
|
"make-plural": "^6.2.2",
|
||||||
"mini-css-extract-plugin": "^0.9.0",
|
"mini-css-extract-plugin": "^0.9.0",
|
||||||
"moment": "^2.26.0",
|
"moment": "^2.26.0",
|
||||||
"node-loader": "^0.6.0",
|
"node-loader": "^0.6.0",
|
||||||
@ -328,6 +338,7 @@
|
|||||||
"react-refresh": "^0.9.0",
|
"react-refresh": "^0.9.0",
|
||||||
"react-router-dom": "^5.2.0",
|
"react-router-dom": "^5.2.0",
|
||||||
"react-select": "^3.1.0",
|
"react-select": "^3.1.0",
|
||||||
|
"react-select-event": "^5.1.0",
|
||||||
"react-window": "^1.8.5",
|
"react-window": "^1.8.5",
|
||||||
"sass-loader": "^8.0.2",
|
"sass-loader": "^8.0.2",
|
||||||
"sharp": "^0.26.1",
|
"sharp": "^0.26.1",
|
||||||
@ -348,7 +359,7 @@
|
|||||||
"webpack-dev-server": "^3.11.0",
|
"webpack-dev-server": "^3.11.0",
|
||||||
"webpack-node-externals": "^1.7.2",
|
"webpack-node-externals": "^1.7.2",
|
||||||
"what-input": "^5.2.10",
|
"what-input": "^5.2.10",
|
||||||
"xterm": "^4.6.0",
|
"xterm": "^4.10.0",
|
||||||
"xterm-addon-fit": "^0.4.0"
|
"xterm-addon-fit": "^0.4.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import fs from "fs";
|
|||||||
import mockFs from "mock-fs";
|
import mockFs from "mock-fs";
|
||||||
import yaml from "js-yaml";
|
import yaml from "js-yaml";
|
||||||
import { Cluster } from "../../main/cluster";
|
import { Cluster } from "../../main/cluster";
|
||||||
import { ClusterStore } from "../cluster-store";
|
import { ClusterStore, getClusterIdFromHost } from "../cluster-store";
|
||||||
import { workspaceStore } from "../workspace-store";
|
import { workspaceStore } from "../workspace-store";
|
||||||
|
|
||||||
const testDataIcon = fs.readFileSync("test-data/cluster-store-migration-icon.png");
|
const testDataIcon = fs.readFileSync("test-data/cluster-store-migration-icon.png");
|
||||||
@ -541,3 +541,27 @@ describe("pre 3.6.0-beta.1 config with an existing cluster", () => {
|
|||||||
expect(icon.startsWith("data:;base64,")).toBe(true);
|
expect(icon.startsWith("data:;base64,")).toBe(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("getClusterIdFromHost", () => {
|
||||||
|
const clusterFakeId = "fe540901-0bd6-4f6c-b472-bce1559d7c4a";
|
||||||
|
|
||||||
|
it("should return undefined for non cluster frame hosts", () => {
|
||||||
|
expect(getClusterIdFromHost("localhost:45345")).toBeUndefined();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should return ClusterId for cluster frame hosts", () => {
|
||||||
|
expect(getClusterIdFromHost(`${clusterFakeId}.localhost:59110`)).toBe(clusterFakeId);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should return ClusterId for cluster frame hosts with additional subdomains", () => {
|
||||||
|
expect(getClusterIdFromHost(`abc.${clusterFakeId}.localhost:59110`)).toBe(clusterFakeId);
|
||||||
|
expect(getClusterIdFromHost(`abc.def.${clusterFakeId}.localhost:59110`)).toBe(clusterFakeId);
|
||||||
|
expect(getClusterIdFromHost(`abc.def.ghi.${clusterFakeId}.localhost:59110`)).toBe(clusterFakeId);
|
||||||
|
expect(getClusterIdFromHost(`abc.def.ghi.jkl.${clusterFakeId}.localhost:59110`)).toBe(clusterFakeId);
|
||||||
|
expect(getClusterIdFromHost(`abc.def.ghi.jkl.mno.${clusterFakeId}.localhost:59110`)).toBe(clusterFakeId);
|
||||||
|
expect(getClusterIdFromHost(`abc.def.ghi.jkl.mno.pqr.${clusterFakeId}.localhost:59110`)).toBe(clusterFakeId);
|
||||||
|
expect(getClusterIdFromHost(`abc.def.ghi.jkl.mno.pqr.stu.${clusterFakeId}.localhost:59110`)).toBe(clusterFakeId);
|
||||||
|
expect(getClusterIdFromHost(`abc.def.ghi.jkl.mno.pqr.stu.vwx.${clusterFakeId}.localhost:59110`)).toBe(clusterFakeId);
|
||||||
|
expect(getClusterIdFromHost(`abc.def.ghi.jkl.mno.pqr.stu.vwx.yz.${clusterFakeId}.localhost:59110`)).toBe(clusterFakeId);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|||||||
@ -36,6 +36,13 @@ describe("workspace store tests", () => {
|
|||||||
expect(ws.getById(WorkspaceStore.defaultId)).not.toBe(null);
|
expect(ws.getById(WorkspaceStore.defaultId)).not.toBe(null);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("default workspace should be enabled", () => {
|
||||||
|
const ws = WorkspaceStore.getInstance<WorkspaceStore>();
|
||||||
|
|
||||||
|
expect(ws.workspaces.size).toBe(1);
|
||||||
|
expect(ws.getById(WorkspaceStore.defaultId).enabled).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
it("cannot remove the default workspace", () => {
|
it("cannot remove the default workspace", () => {
|
||||||
const ws = WorkspaceStore.getInstance<WorkspaceStore>();
|
const ws = WorkspaceStore.getInstance<WorkspaceStore>();
|
||||||
|
|
||||||
|
|||||||
@ -354,10 +354,11 @@ export class ClusterStore extends BaseStore<ClusterStoreModel> {
|
|||||||
|
|
||||||
export const clusterStore = ClusterStore.getInstance<ClusterStore>();
|
export const clusterStore = ClusterStore.getInstance<ClusterStore>();
|
||||||
|
|
||||||
export function getClusterIdFromHost(hostname: string): ClusterId {
|
export function getClusterIdFromHost(host: string): ClusterId | undefined {
|
||||||
const subDomains = hostname.split(":")[0].split(".");
|
// e.g host == "%clusterId.localhost:45345"
|
||||||
|
const subDomains = host.split(":")[0].split(".");
|
||||||
|
|
||||||
return subDomains.slice(-2)[0]; // e.g host == "%clusterId.localhost:45345"
|
return subDomains.slice(-2, -1)[0]; // ClusterId or undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getClusterFrameUrl(clusterId: ClusterId) {
|
export function getClusterFrameUrl(clusterId: ClusterId) {
|
||||||
@ -365,7 +366,7 @@ export function getClusterFrameUrl(clusterId: ClusterId) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function getHostedClusterId() {
|
export function getHostedClusterId() {
|
||||||
return getClusterIdFromHost(location.hostname);
|
return getClusterIdFromHost(location.host);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getHostedCluster(): Cluster {
|
export function getHostedCluster(): Cluster {
|
||||||
|
|||||||
126
src/common/ipc/__tests__/type-enforced-ipc.test.ts
Normal file
126
src/common/ipc/__tests__/type-enforced-ipc.test.ts
Normal file
@ -0,0 +1,126 @@
|
|||||||
|
import { EventEmitter } from "events";
|
||||||
|
import { onCorrect, onceCorrect } from "../type-enforced-ipc";
|
||||||
|
|
||||||
|
describe("type enforced ipc tests", () => {
|
||||||
|
describe("onCorrect tests", () => {
|
||||||
|
it("should call the handler if the args are valid", () => {
|
||||||
|
let called = false;
|
||||||
|
const source = new EventEmitter();
|
||||||
|
const listener = () => called = true;
|
||||||
|
const verifier = (args: unknown[]): args is [] => true;
|
||||||
|
const channel = "foobar";
|
||||||
|
|
||||||
|
onCorrect({ source, listener, verifier, channel });
|
||||||
|
|
||||||
|
source.emit(channel);
|
||||||
|
expect(called).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should not call the handler if the args are not valid", () => {
|
||||||
|
let called = false;
|
||||||
|
const source = new EventEmitter();
|
||||||
|
const listener = () => called = true;
|
||||||
|
const verifier = (args: unknown[]): args is [] => false;
|
||||||
|
const channel = "foobar";
|
||||||
|
|
||||||
|
onCorrect({ source, listener, verifier, channel });
|
||||||
|
|
||||||
|
source.emit(channel);
|
||||||
|
expect(called).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should call the handler twice if the args are valid on two emits", () => {
|
||||||
|
let called = 0;
|
||||||
|
const source = new EventEmitter();
|
||||||
|
const listener = () => called += 1;
|
||||||
|
const verifier = (args: unknown[]): args is [] => true;
|
||||||
|
const channel = "foobar";
|
||||||
|
|
||||||
|
onCorrect({ source, listener, verifier, channel });
|
||||||
|
|
||||||
|
source.emit(channel);
|
||||||
|
source.emit(channel);
|
||||||
|
expect(called).toBe(2);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should call the handler twice if the args are [valid, invalid, valid]", () => {
|
||||||
|
let called = 0;
|
||||||
|
const source = new EventEmitter();
|
||||||
|
const listener = () => called += 1;
|
||||||
|
const results = [true, false, true];
|
||||||
|
const verifier = (args: unknown[]): args is [] => results.pop();
|
||||||
|
const channel = "foobar";
|
||||||
|
|
||||||
|
onCorrect({ source, listener, verifier, channel });
|
||||||
|
|
||||||
|
source.emit(channel);
|
||||||
|
source.emit(channel);
|
||||||
|
source.emit(channel);
|
||||||
|
expect(called).toBe(2);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("onceCorrect tests", () => {
|
||||||
|
it("should call the handler if the args are valid", () => {
|
||||||
|
let called = false;
|
||||||
|
const source = new EventEmitter();
|
||||||
|
const listener = () => called = true;
|
||||||
|
const verifier = (args: unknown[]): args is [] => true;
|
||||||
|
const channel = "foobar";
|
||||||
|
|
||||||
|
onceCorrect({ source, listener, verifier, channel });
|
||||||
|
|
||||||
|
source.emit(channel);
|
||||||
|
expect(called).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should not call the handler if the args are not valid", () => {
|
||||||
|
let called = false;
|
||||||
|
const source = new EventEmitter();
|
||||||
|
const listener = () => called = true;
|
||||||
|
const verifier = (args: unknown[]): args is [] => false;
|
||||||
|
const channel = "foobar";
|
||||||
|
|
||||||
|
onceCorrect({ source, listener, verifier, channel });
|
||||||
|
|
||||||
|
source.emit(channel);
|
||||||
|
expect(called).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should call the handler only once even if args are valid multiple times", () => {
|
||||||
|
let called = 0;
|
||||||
|
const source = new EventEmitter();
|
||||||
|
const listener = () => called += 1;
|
||||||
|
const verifier = (args: unknown[]): args is [] => true;
|
||||||
|
const channel = "foobar";
|
||||||
|
|
||||||
|
onceCorrect({ source, listener, verifier, channel });
|
||||||
|
|
||||||
|
source.emit(channel);
|
||||||
|
source.emit(channel);
|
||||||
|
expect(called).toBe(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should call the handler on only the first valid set of args", () => {
|
||||||
|
let called = "";
|
||||||
|
let verifierCalled = 0;
|
||||||
|
const source = new EventEmitter();
|
||||||
|
const listener = (info: any, arg: string) => called = arg;
|
||||||
|
const verifier = (args: unknown[]): args is [string] => (++verifierCalled) % 3 === 0;
|
||||||
|
const channel = "foobar";
|
||||||
|
|
||||||
|
onceCorrect({ source, listener, verifier, channel });
|
||||||
|
|
||||||
|
source.emit(channel, {}, "a");
|
||||||
|
source.emit(channel, {}, "b");
|
||||||
|
source.emit(channel, {}, "c");
|
||||||
|
source.emit(channel, {}, "d");
|
||||||
|
source.emit(channel, {}, "e");
|
||||||
|
source.emit(channel, {}, "f");
|
||||||
|
source.emit(channel, {}, "g");
|
||||||
|
source.emit(channel, {}, "h");
|
||||||
|
source.emit(channel, {}, "i");
|
||||||
|
expect(called).toBe("c");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
3
src/common/ipc/index.ts
Normal file
3
src/common/ipc/index.ts
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
export * from "./ipc";
|
||||||
|
export * from "./update-available";
|
||||||
|
export * from "./type-enforced-ipc";
|
||||||
@ -3,10 +3,13 @@
|
|||||||
// https://www.electronjs.org/docs/api/ipc-renderer
|
// https://www.electronjs.org/docs/api/ipc-renderer
|
||||||
|
|
||||||
import { ipcMain, ipcRenderer, webContents, remote } from "electron";
|
import { ipcMain, ipcRenderer, webContents, remote } from "electron";
|
||||||
import logger from "../main/logger";
|
import { toJS } from "mobx";
|
||||||
import { ClusterFrameInfo, clusterFrameMap } from "./cluster-frames";
|
import logger from "../../main/logger";
|
||||||
|
import { ClusterFrameInfo, clusterFrameMap } from "../cluster-frames";
|
||||||
|
|
||||||
export function handleRequest(channel: string, listener: (...args: any[]) => any) {
|
const subFramesChannel = "ipc:get-sub-frames";
|
||||||
|
|
||||||
|
export function handleRequest(channel: string, listener: (event: Electron.IpcMainInvokeEvent, ...args: any[]) => any) {
|
||||||
ipcMain.handle(channel, listener);
|
ipcMain.handle(channel, listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -14,38 +17,39 @@ export async function requestMain(channel: string, ...args: any[]) {
|
|||||||
return ipcRenderer.invoke(channel, ...args);
|
return ipcRenderer.invoke(channel, ...args);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getSubFrames(): Promise<ClusterFrameInfo[]> {
|
function getSubFrames(): ClusterFrameInfo[] {
|
||||||
const subFrames: ClusterFrameInfo[] = [];
|
return toJS(Array.from(clusterFrameMap.values()), { recurseEverything: true });
|
||||||
|
|
||||||
clusterFrameMap.forEach(frameInfo => {
|
|
||||||
subFrames.push(frameInfo);
|
|
||||||
});
|
|
||||||
|
|
||||||
return subFrames;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function broadcastMessage(channel: string, ...args: any[]) {
|
export async function broadcastMessage(channel: string, ...args: any[]) {
|
||||||
const views = (webContents || remote?.webContents)?.getAllWebContents();
|
const views = (webContents || remote?.webContents)?.getAllWebContents();
|
||||||
|
|
||||||
if (!views) return;
|
if (!views) return;
|
||||||
|
|
||||||
views.forEach(webContent => {
|
|
||||||
const type = webContent.getType();
|
|
||||||
|
|
||||||
logger.silly(`[IPC]: broadcasting "${channel}" to ${type}=${webContent.id}`, { args });
|
|
||||||
webContent.send(channel, ...args);
|
|
||||||
getSubFrames().then((frames) => {
|
|
||||||
frames.map((frameInfo) => {
|
|
||||||
webContent.sendToFrame([frameInfo.processId, frameInfo.frameId], channel, ...args);
|
|
||||||
});
|
|
||||||
}).catch((e) => e);
|
|
||||||
});
|
|
||||||
|
|
||||||
if (ipcRenderer) {
|
if (ipcRenderer) {
|
||||||
ipcRenderer.send(channel, ...args);
|
ipcRenderer.send(channel, ...args);
|
||||||
} else {
|
} else {
|
||||||
ipcMain.emit(channel, ...args);
|
ipcMain.emit(channel, ...args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (const view of views) {
|
||||||
|
const type = view.getType();
|
||||||
|
|
||||||
|
logger.silly(`[IPC]: broadcasting "${channel}" to ${type}=${view.id}`, { args });
|
||||||
|
view.send(channel, ...args);
|
||||||
|
|
||||||
|
try {
|
||||||
|
const subFrames: ClusterFrameInfo[] = ipcRenderer
|
||||||
|
? await requestMain(subFramesChannel)
|
||||||
|
: getSubFrames();
|
||||||
|
|
||||||
|
for (const frameInfo of subFrames) {
|
||||||
|
view.sendToFrame([frameInfo.processId, frameInfo.frameId], channel, ...args);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
logger.error("[IPC]: failed to send IPC message", { error });
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function subscribeToBroadcast(channel: string, listener: (...args: any[]) => any) {
|
export function subscribeToBroadcast(channel: string, listener: (...args: any[]) => any) {
|
||||||
@ -73,3 +77,9 @@ export function unsubscribeAllFromBroadcast(channel: string) {
|
|||||||
ipcMain.removeAllListeners(channel);
|
ipcMain.removeAllListeners(channel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function bindBroadcastHandlers() {
|
||||||
|
handleRequest(subFramesChannel, () => {
|
||||||
|
return getSubFrames();
|
||||||
|
});
|
||||||
|
}
|
||||||
71
src/common/ipc/type-enforced-ipc.ts
Normal file
71
src/common/ipc/type-enforced-ipc.ts
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
import { EventEmitter } from "events";
|
||||||
|
import logger from "../../main/logger";
|
||||||
|
|
||||||
|
export type HandlerEvent<EM extends EventEmitter> = Parameters<Parameters<EM["on"]>[1]>[0];
|
||||||
|
export type ListVerifier<T extends any[]> = (args: unknown[]) => args is T;
|
||||||
|
export type Rest<T> = T extends [any, ...infer R] ? R : [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a listener to `source` that waits for the first IPC message with the correct
|
||||||
|
* argument data is sent.
|
||||||
|
* @param channel The channel to be listened on
|
||||||
|
* @param listener The function for the channel to be called if the args of the correct type
|
||||||
|
* @param verifier The function to be called to verify that the args are the correct type
|
||||||
|
*/
|
||||||
|
export function onceCorrect<
|
||||||
|
EM extends EventEmitter,
|
||||||
|
L extends (event: HandlerEvent<EM>, ...args: any[]) => any
|
||||||
|
>({
|
||||||
|
source,
|
||||||
|
channel,
|
||||||
|
listener,
|
||||||
|
verifier,
|
||||||
|
}: {
|
||||||
|
source: EM,
|
||||||
|
channel: string | symbol,
|
||||||
|
listener: L,
|
||||||
|
verifier: ListVerifier<Rest<Parameters<L>>>,
|
||||||
|
}): void {
|
||||||
|
function handler(event: HandlerEvent<EM>, ...args: unknown[]): void {
|
||||||
|
if (verifier(args)) {
|
||||||
|
source.removeListener(channel, handler); // remove immediately
|
||||||
|
|
||||||
|
(async () => (listener(event, ...args)))() // might return a promise, or throw, or reject
|
||||||
|
.catch((error: any) => logger.error("[IPC]: channel once handler threw error", { channel, error }));
|
||||||
|
} else {
|
||||||
|
logger.error("[IPC]: channel was emitted with invalid data", { channel, args });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
source.on(channel, handler);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a listener to `source` that checks to verify the arguments before calling the handler.
|
||||||
|
* @param channel The channel to be listened on
|
||||||
|
* @param listener The function for the channel to be called if the args of the correct type
|
||||||
|
* @param verifier The function to be called to verify that the args are the correct type
|
||||||
|
*/
|
||||||
|
export function onCorrect<
|
||||||
|
EM extends EventEmitter,
|
||||||
|
L extends (event: HandlerEvent<EM>, ...args: any[]) => any
|
||||||
|
>({
|
||||||
|
source,
|
||||||
|
channel,
|
||||||
|
listener,
|
||||||
|
verifier,
|
||||||
|
}: {
|
||||||
|
source: EM,
|
||||||
|
channel: string | symbol,
|
||||||
|
listener: L,
|
||||||
|
verifier: ListVerifier<Rest<Parameters<L>>>,
|
||||||
|
}): void {
|
||||||
|
source.on(channel, (event, ...args: unknown[]) => {
|
||||||
|
if (verifier(args)) {
|
||||||
|
(async () => (listener(event, ...args)))() // might return a promise, or throw, or reject
|
||||||
|
.catch(error => logger.error("[IPC]: channel on handler threw error", { channel, error }));
|
||||||
|
} else {
|
||||||
|
logger.error("[IPC]: channel was emitted with invalid data", { channel, args });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
48
src/common/ipc/update-available/index.ts
Normal file
48
src/common/ipc/update-available/index.ts
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
import { UpdateInfo } from "electron-updater";
|
||||||
|
|
||||||
|
export const UpdateAvailableChannel = "update-available";
|
||||||
|
export const AutoUpdateLogPrefix = "[UPDATE-CHECKER]";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* [<back-channel>, <update-info>]
|
||||||
|
*/
|
||||||
|
export type UpdateAvailableFromMain = [string, UpdateInfo];
|
||||||
|
|
||||||
|
export function areArgsUpdateAvailableFromMain(args: unknown[]): args is UpdateAvailableFromMain {
|
||||||
|
if (args.length !== 2) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof args[0] !== "string") {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof args[1] !== "object" || args[1] === null) {
|
||||||
|
// TODO: improve this checking
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type BackchannelArg = {
|
||||||
|
doUpdate: false;
|
||||||
|
} | {
|
||||||
|
doUpdate: true;
|
||||||
|
now: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type UpdateAvailableToBackchannel = [BackchannelArg];
|
||||||
|
|
||||||
|
export function areArgsUpdateAvailableToBackchannel(args: unknown[]): args is UpdateAvailableToBackchannel {
|
||||||
|
if (args.length !== 1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof args[0] !== "object" || args[0] === null) {
|
||||||
|
// TODO: improve this checking
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
@ -1,42 +1,44 @@
|
|||||||
import { getHostedCluster } from "./cluster-store";
|
import { getHostedCluster } from "./cluster-store";
|
||||||
|
|
||||||
export type KubeResource =
|
export type KubeResource =
|
||||||
"namespaces" | "nodes" | "events" | "resourcequotas" | "services" |
|
"namespaces" | "nodes" | "events" | "resourcequotas" | "services" | "limitranges" |
|
||||||
"secrets" | "configmaps" | "ingresses" | "networkpolicies" | "persistentvolumeclaims" | "persistentvolumes" | "storageclasses" |
|
"secrets" | "configmaps" | "ingresses" | "networkpolicies" | "persistentvolumeclaims" | "persistentvolumes" | "storageclasses" |
|
||||||
"pods" | "daemonsets" | "deployments" | "statefulsets" | "replicasets" | "jobs" | "cronjobs" |
|
"pods" | "daemonsets" | "deployments" | "statefulsets" | "replicasets" | "jobs" | "cronjobs" |
|
||||||
"endpoints" | "customresourcedefinitions" | "horizontalpodautoscalers" | "podsecuritypolicies" | "poddisruptionbudgets";
|
"endpoints" | "customresourcedefinitions" | "horizontalpodautoscalers" | "podsecuritypolicies" | "poddisruptionbudgets";
|
||||||
|
|
||||||
export interface KubeApiResource {
|
export interface KubeApiResource {
|
||||||
resource: KubeResource; // valid resource name
|
kind: string; // resource type (e.g. "Namespace")
|
||||||
|
apiName: KubeResource; // valid api resource name (e.g. "namespaces")
|
||||||
group?: string; // api-group
|
group?: string; // api-group
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: auto-populate all resources dynamically (see: kubectl api-resources -o=wide -v=7)
|
// TODO: auto-populate all resources dynamically (see: kubectl api-resources -o=wide -v=7)
|
||||||
export const apiResources: KubeApiResource[] = [
|
export const apiResources: KubeApiResource[] = [
|
||||||
{ resource: "configmaps" },
|
{ kind: "ConfigMap", apiName: "configmaps" },
|
||||||
{ resource: "cronjobs", group: "batch" },
|
{ kind: "CronJob", apiName: "cronjobs", group: "batch" },
|
||||||
{ resource: "customresourcedefinitions", group: "apiextensions.k8s.io" },
|
{ kind: "CustomResourceDefinition", apiName: "customresourcedefinitions", group: "apiextensions.k8s.io" },
|
||||||
{ resource: "daemonsets", group: "apps" },
|
{ kind: "DaemonSet", apiName: "daemonsets", group: "apps" },
|
||||||
{ resource: "deployments", group: "apps" },
|
{ kind: "Deployment", apiName: "deployments", group: "apps" },
|
||||||
{ resource: "endpoints" },
|
{ kind: "Endpoint", apiName: "endpoints" },
|
||||||
{ resource: "events" },
|
{ kind: "Event", apiName: "events" },
|
||||||
{ resource: "horizontalpodautoscalers" },
|
{ kind: "HorizontalPodAutoscaler", apiName: "horizontalpodautoscalers" },
|
||||||
{ resource: "ingresses", group: "networking.k8s.io" },
|
{ kind: "Ingress", apiName: "ingresses", group: "networking.k8s.io" },
|
||||||
{ resource: "jobs", group: "batch" },
|
{ kind: "Job", apiName: "jobs", group: "batch" },
|
||||||
{ resource: "namespaces" },
|
{ kind: "Namespace", apiName: "namespaces" },
|
||||||
{ resource: "networkpolicies", group: "networking.k8s.io" },
|
{ kind: "LimitRange", apiName: "limitranges" },
|
||||||
{ resource: "nodes" },
|
{ kind: "NetworkPolicy", apiName: "networkpolicies", group: "networking.k8s.io" },
|
||||||
{ resource: "persistentvolumes" },
|
{ kind: "Node", apiName: "nodes" },
|
||||||
{ resource: "persistentvolumeclaims" },
|
{ kind: "PersistentVolume", apiName: "persistentvolumes" },
|
||||||
{ resource: "pods" },
|
{ kind: "PersistentVolumeClaim", apiName: "persistentvolumeclaims" },
|
||||||
{ resource: "poddisruptionbudgets" },
|
{ kind: "Pod", apiName: "pods" },
|
||||||
{ resource: "podsecuritypolicies" },
|
{ kind: "PodDisruptionBudget", apiName: "poddisruptionbudgets" },
|
||||||
{ resource: "resourcequotas" },
|
{ kind: "PodSecurityPolicy", apiName: "podsecuritypolicies" },
|
||||||
{ resource: "replicasets", group: "apps" },
|
{ kind: "ResourceQuota", apiName: "resourcequotas" },
|
||||||
{ resource: "secrets" },
|
{ kind: "ReplicaSet", apiName: "replicasets", group: "apps" },
|
||||||
{ resource: "services" },
|
{ kind: "Secret", apiName: "secrets" },
|
||||||
{ resource: "statefulsets", group: "apps" },
|
{ kind: "Service", apiName: "services" },
|
||||||
{ resource: "storageclasses", group: "storage.k8s.io" },
|
{ kind: "StatefulSet", apiName: "statefulsets", group: "apps" },
|
||||||
|
{ kind: "StorageClass", apiName: "storageclasses", group: "storage.k8s.io" },
|
||||||
];
|
];
|
||||||
|
|
||||||
export function isAllowedResource(resources: KubeResource | KubeResource[]) {
|
export function isAllowedResource(resources: KubeResource | KubeResource[]) {
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
import { action, computed, observable } from "mobx";
|
import { action, computed, observable,reaction } from "mobx";
|
||||||
|
import { dockStore } from "../renderer/components/dock/dock.store";
|
||||||
import { autobind } from "../renderer/utils";
|
import { autobind } from "../renderer/utils";
|
||||||
|
|
||||||
export class SearchStore {
|
export class SearchStore {
|
||||||
@ -6,6 +7,12 @@ export class SearchStore {
|
|||||||
@observable occurrences: number[] = []; // Array with line numbers, eg [0, 0, 10, 21, 21, 40...]
|
@observable occurrences: number[] = []; // Array with line numbers, eg [0, 0, 10, 21, 21, 40...]
|
||||||
@observable activeOverlayIndex = -1; // Index withing the occurences array. Showing where is activeOverlay currently located
|
@observable activeOverlayIndex = -1; // Index withing the occurences array. Showing where is activeOverlay currently located
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
reaction(() => dockStore.selectedTabId, () => {
|
||||||
|
searchStore.reset();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets default activeOverlayIndex
|
* Sets default activeOverlayIndex
|
||||||
* @param text An array of any textual data (logs, for example)
|
* @param text An array of any textual data (logs, for example)
|
||||||
|
|||||||
@ -28,6 +28,7 @@ export interface UserPreferences {
|
|||||||
downloadBinariesPath?: string;
|
downloadBinariesPath?: string;
|
||||||
kubectlBinariesPath?: string;
|
kubectlBinariesPath?: string;
|
||||||
openAtLogin?: boolean;
|
openAtLogin?: boolean;
|
||||||
|
hiddenTableColumns?: Record<string, string[]>
|
||||||
}
|
}
|
||||||
|
|
||||||
export class UserStore extends BaseStore<UserStoreModel> {
|
export class UserStore extends BaseStore<UserStoreModel> {
|
||||||
@ -54,6 +55,7 @@ export class UserStore extends BaseStore<UserStoreModel> {
|
|||||||
downloadMirror: "default",
|
downloadMirror: "default",
|
||||||
downloadKubectlBinaries: true, // Download kubectl binaries matching cluster version
|
downloadKubectlBinaries: true, // Download kubectl binaries matching cluster version
|
||||||
openAtLogin: false,
|
openAtLogin: false,
|
||||||
|
hiddenTableColumns: {},
|
||||||
};
|
};
|
||||||
|
|
||||||
protected async handleOnLoad() {
|
protected async handleOnLoad() {
|
||||||
@ -82,6 +84,15 @@ export class UserStore extends BaseStore<UserStoreModel> {
|
|||||||
return semver.gt(getAppVersion(), this.lastSeenAppVersion);
|
return semver.gt(getAppVersion(), this.lastSeenAppVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@action
|
||||||
|
setHiddenTableColumns(tableId: string, names: Set<string> | string[]) {
|
||||||
|
this.preferences.hiddenTableColumns[tableId] = Array.from(names);
|
||||||
|
}
|
||||||
|
|
||||||
|
getHiddenTableColumns(tableId: string): Set<string> {
|
||||||
|
return new Set(this.preferences.hiddenTableColumns[tableId]);
|
||||||
|
}
|
||||||
|
|
||||||
@action
|
@action
|
||||||
resetKubeConfigPath() {
|
resetKubeConfigPath() {
|
||||||
this.kubeConfigPath = kubeConfigDefaultPath;
|
this.kubeConfigPath = kubeConfigDefaultPath;
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
import requestPromise from "request-promise-native";
|
||||||
import packageInfo from "../../../package.json";
|
import packageInfo from "../../../package.json";
|
||||||
|
|
||||||
export function getAppVersion(): string {
|
export function getAppVersion(): string {
|
||||||
@ -11,3 +12,13 @@ export function getBundledKubectlVersion(): string {
|
|||||||
export function getBundledExtensions(): string[] {
|
export function getBundledExtensions(): string[] {
|
||||||
return packageInfo.lens?.extensions || [];
|
return packageInfo.lens?.extensions || [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function getAppVersionFromProxyServer(proxyPort: number): Promise<string> {
|
||||||
|
const response = await requestPromise({
|
||||||
|
method: "GET",
|
||||||
|
uri: `http://localhost:${proxyPort}/version`,
|
||||||
|
resolveWithFullResponse: true
|
||||||
|
});
|
||||||
|
|
||||||
|
return JSON.parse(response.body).version;
|
||||||
|
}
|
||||||
|
|||||||
8
src/common/utils/delay.ts
Normal file
8
src/common/utils/delay.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
/**
|
||||||
|
* Return a promise that will be resolved after at least `timeout` ms have
|
||||||
|
* passed
|
||||||
|
* @param timeout The number of milliseconds before resolving
|
||||||
|
*/
|
||||||
|
export function delay(timeout = 1000): Promise<void> {
|
||||||
|
return new Promise(resolve => setTimeout(resolve, timeout));
|
||||||
|
}
|
||||||
@ -7,6 +7,7 @@ export * from "./autobind";
|
|||||||
export * from "./base64";
|
export * from "./base64";
|
||||||
export * from "./camelCase";
|
export * from "./camelCase";
|
||||||
export * from "./cloneJson";
|
export * from "./cloneJson";
|
||||||
|
export * from "./delay";
|
||||||
export * from "./debouncePromise";
|
export * from "./debouncePromise";
|
||||||
export * from "./defineGlobal";
|
export * from "./defineGlobal";
|
||||||
export * from "./getRandId";
|
export * from "./getRandId";
|
||||||
@ -17,3 +18,4 @@ export * from "./openExternal";
|
|||||||
export * from "./downloadFile";
|
export * from "./downloadFile";
|
||||||
export * from "./escapeRegExp";
|
export * from "./escapeRegExp";
|
||||||
export * from "./tar";
|
export * from "./tar";
|
||||||
|
export * from "./delay";
|
||||||
|
|||||||
@ -58,14 +58,7 @@ export class Workspace implements WorkspaceModel, WorkspaceState {
|
|||||||
* @observable
|
* @observable
|
||||||
*/
|
*/
|
||||||
@observable ownerRef?: string;
|
@observable ownerRef?: string;
|
||||||
/**
|
|
||||||
* Is workspace enabled
|
|
||||||
*
|
|
||||||
* Workspaces that don't have ownerRef will be enabled by default. Workspaces with ownerRef need to explicitly enable a workspace.
|
|
||||||
*
|
|
||||||
* @observable
|
|
||||||
*/
|
|
||||||
@observable enabled: boolean;
|
|
||||||
/**
|
/**
|
||||||
* Last active cluster id
|
* Last active cluster id
|
||||||
*
|
*
|
||||||
@ -73,6 +66,9 @@ export class Workspace implements WorkspaceModel, WorkspaceState {
|
|||||||
*/
|
*/
|
||||||
@observable lastActiveClusterId?: ClusterId;
|
@observable lastActiveClusterId?: ClusterId;
|
||||||
|
|
||||||
|
|
||||||
|
@observable private _enabled: boolean;
|
||||||
|
|
||||||
constructor(data: WorkspaceModel) {
|
constructor(data: WorkspaceModel) {
|
||||||
Object.assign(this, data);
|
Object.assign(this, data);
|
||||||
|
|
||||||
@ -83,6 +79,21 @@ export class Workspace implements WorkspaceModel, WorkspaceState {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is workspace enabled
|
||||||
|
*
|
||||||
|
* Workspaces that don't have ownerRef will be enabled by default. Workspaces with ownerRef need to explicitly enable a workspace.
|
||||||
|
*
|
||||||
|
* @observable
|
||||||
|
*/
|
||||||
|
get enabled(): boolean {
|
||||||
|
return !this.isManaged || this._enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
set enabled(enabled: boolean) {
|
||||||
|
this._enabled = enabled;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is workspace managed by an extension
|
* Is workspace managed by an extension
|
||||||
*/
|
*/
|
||||||
@ -134,10 +145,18 @@ export class WorkspaceStore extends BaseStore<WorkspaceStoreModel> {
|
|||||||
static readonly defaultId: WorkspaceId = "default";
|
static readonly defaultId: WorkspaceId = "default";
|
||||||
private static stateRequestChannel = "workspace:states";
|
private static stateRequestChannel = "workspace:states";
|
||||||
|
|
||||||
|
@observable currentWorkspaceId = WorkspaceStore.defaultId;
|
||||||
|
@observable workspaces = observable.map<WorkspaceId, Workspace>();
|
||||||
|
|
||||||
private constructor() {
|
private constructor() {
|
||||||
super({
|
super({
|
||||||
configName: "lens-workspace-store",
|
configName: "lens-workspace-store",
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.workspaces.set(WorkspaceStore.defaultId, new Workspace({
|
||||||
|
id: WorkspaceStore.defaultId,
|
||||||
|
name: "default"
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
async load() {
|
async load() {
|
||||||
@ -186,15 +205,6 @@ export class WorkspaceStore extends BaseStore<WorkspaceStoreModel> {
|
|||||||
ipcRenderer.removeAllListeners("workspace:state");
|
ipcRenderer.removeAllListeners("workspace:state");
|
||||||
}
|
}
|
||||||
|
|
||||||
@observable currentWorkspaceId = WorkspaceStore.defaultId;
|
|
||||||
|
|
||||||
@observable workspaces = observable.map<WorkspaceId, Workspace>({
|
|
||||||
[WorkspaceStore.defaultId]: new Workspace({
|
|
||||||
id: WorkspaceStore.defaultId,
|
|
||||||
name: "default"
|
|
||||||
})
|
|
||||||
});
|
|
||||||
|
|
||||||
@computed get currentWorkspace(): Workspace {
|
@computed get currentWorkspace(): Workspace {
|
||||||
return this.getById(this.currentWorkspaceId);
|
return this.getById(this.currentWorkspaceId);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,6 +2,7 @@ import type { AppPreferenceRegistration, ClusterFeatureRegistration, ClusterPage
|
|||||||
import type { Cluster } from "../main/cluster";
|
import type { Cluster } from "../main/cluster";
|
||||||
import { LensExtension } from "./lens-extension";
|
import { LensExtension } from "./lens-extension";
|
||||||
import { getExtensionPageUrl } from "./registries/page-registry";
|
import { getExtensionPageUrl } from "./registries/page-registry";
|
||||||
|
import { CommandRegistration } from "./registries/command-registry";
|
||||||
|
|
||||||
export class LensRendererExtension extends LensExtension {
|
export class LensRendererExtension extends LensExtension {
|
||||||
globalPages: PageRegistration[] = [];
|
globalPages: PageRegistration[] = [];
|
||||||
@ -14,6 +15,7 @@ export class LensRendererExtension extends LensExtension {
|
|||||||
statusBarItems: StatusBarRegistration[] = [];
|
statusBarItems: StatusBarRegistration[] = [];
|
||||||
kubeObjectDetailItems: KubeObjectDetailRegistration[] = [];
|
kubeObjectDetailItems: KubeObjectDetailRegistration[] = [];
|
||||||
kubeObjectMenuItems: KubeObjectMenuRegistration[] = [];
|
kubeObjectMenuItems: KubeObjectMenuRegistration[] = [];
|
||||||
|
commands: CommandRegistration[] = [];
|
||||||
|
|
||||||
async navigate<P extends object>(pageId?: string, params?: P) {
|
async navigate<P extends object>(pageId?: string, params?: P) {
|
||||||
const { navigate } = await import("../renderer/navigation");
|
const { navigate } = await import("../renderer/navigation");
|
||||||
|
|||||||
37
src/extensions/registries/command-registry.ts
Normal file
37
src/extensions/registries/command-registry.ts
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
// Extensions API -> Commands
|
||||||
|
|
||||||
|
import type { Cluster } from "../../main/cluster";
|
||||||
|
import type { Workspace } from "../../common/workspace-store";
|
||||||
|
import { BaseRegistry } from "./base-registry";
|
||||||
|
import { action } from "mobx";
|
||||||
|
import { LensExtension } from "../lens-extension";
|
||||||
|
|
||||||
|
export type CommandContext = {
|
||||||
|
cluster?: Cluster;
|
||||||
|
workspace?: Workspace;
|
||||||
|
};
|
||||||
|
|
||||||
|
export interface CommandRegistration {
|
||||||
|
id: string;
|
||||||
|
title: string;
|
||||||
|
scope: "cluster" | "global";
|
||||||
|
action: (context: CommandContext) => void;
|
||||||
|
isActive?: (context: CommandContext) => boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class CommandRegistry extends BaseRegistry<CommandRegistration> {
|
||||||
|
@action
|
||||||
|
add(items: CommandRegistration | CommandRegistration[], extension?: LensExtension) {
|
||||||
|
const itemArray = [items].flat();
|
||||||
|
|
||||||
|
const newIds = itemArray.map((item) => item.id);
|
||||||
|
const currentIds = this.getItems().map((item) => item.id);
|
||||||
|
|
||||||
|
const filteredIds = newIds.filter((id) => !currentIds.includes(id));
|
||||||
|
const filteredItems = itemArray.filter((item) => filteredIds.includes(item.id));
|
||||||
|
|
||||||
|
return super.add(filteredItems, extension);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const commandRegistry = new CommandRegistry();
|
||||||
@ -3,7 +3,18 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import { BaseRegistry } from "./base-registry";
|
import { BaseRegistry } from "./base-registry";
|
||||||
|
|
||||||
export interface StatusBarRegistration {
|
interface StatusBarComponents {
|
||||||
|
Item?: React.ComponentType;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface StatusBarRegistrationV2 {
|
||||||
|
components?: StatusBarComponents; // has to be optional for backwards compatability
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface StatusBarRegistration extends StatusBarRegistrationV2 {
|
||||||
|
/**
|
||||||
|
* @deprecated use components.Item instead
|
||||||
|
*/
|
||||||
item?: React.ReactNode;
|
item?: React.ReactNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -13,6 +13,9 @@ export * from "../../renderer/components/select";
|
|||||||
export * from "../../renderer/components/slider";
|
export * from "../../renderer/components/slider";
|
||||||
export * from "../../renderer/components/input/input";
|
export * from "../../renderer/components/input/input";
|
||||||
|
|
||||||
|
// command-overlay
|
||||||
|
export { CommandOverlay } from "../../renderer/components/command-palette";
|
||||||
|
|
||||||
// other components
|
// other components
|
||||||
export * from "../../renderer/components/icon";
|
export * from "../../renderer/components/icon";
|
||||||
export * from "../../renderer/components/tooltip";
|
export * from "../../renderer/components/tooltip";
|
||||||
@ -38,4 +41,4 @@ export * from "../../renderer/components/+events/kube-event-details";
|
|||||||
// specific exports
|
// specific exports
|
||||||
export * from "../../renderer/components/status-brick";
|
export * from "../../renderer/components/status-brick";
|
||||||
export { terminalStore, createTerminalTab } from "../../renderer/components/dock/terminal.store";
|
export { terminalStore, createTerminalTab } from "../../renderer/components/dock/terminal.store";
|
||||||
export { createPodLogsTab } from "../../renderer/components/dock/pod-logs.store";
|
export { logTabStore } from "../../renderer/components/dock/log-tab.store";
|
||||||
|
|||||||
@ -14,6 +14,7 @@ export { ConfigMap, configMapApi } from "../../renderer/api/endpoints";
|
|||||||
export { Secret, secretsApi, ISecretRef } from "../../renderer/api/endpoints";
|
export { Secret, secretsApi, ISecretRef } from "../../renderer/api/endpoints";
|
||||||
export { ReplicaSet, replicaSetApi } from "../../renderer/api/endpoints";
|
export { ReplicaSet, replicaSetApi } from "../../renderer/api/endpoints";
|
||||||
export { ResourceQuota, resourceQuotaApi } from "../../renderer/api/endpoints";
|
export { ResourceQuota, resourceQuotaApi } from "../../renderer/api/endpoints";
|
||||||
|
export { LimitRange, limitRangeApi } from "../../renderer/api/endpoints";
|
||||||
export { HorizontalPodAutoscaler, hpaApi } from "../../renderer/api/endpoints";
|
export { HorizontalPodAutoscaler, hpaApi } from "../../renderer/api/endpoints";
|
||||||
export { PodDisruptionBudget, pdbApi } from "../../renderer/api/endpoints";
|
export { PodDisruptionBudget, pdbApi } from "../../renderer/api/endpoints";
|
||||||
export { Service, serviceApi } from "../../renderer/api/endpoints";
|
export { Service, serviceApi } from "../../renderer/api/endpoints";
|
||||||
@ -46,6 +47,7 @@ export type { ConfigMapsStore } from "../../renderer/components/+config-maps/con
|
|||||||
export type { SecretsStore } from "../../renderer/components/+config-secrets/secrets.store";
|
export type { SecretsStore } from "../../renderer/components/+config-secrets/secrets.store";
|
||||||
export type { ReplicaSetStore } from "../../renderer/components/+workloads-replicasets/replicasets.store";
|
export type { ReplicaSetStore } from "../../renderer/components/+workloads-replicasets/replicasets.store";
|
||||||
export type { ResourceQuotasStore } from "../../renderer/components/+config-resource-quotas/resource-quotas.store";
|
export type { ResourceQuotasStore } from "../../renderer/components/+config-resource-quotas/resource-quotas.store";
|
||||||
|
export type { LimitRangesStore } from "../../renderer/components/+config-limit-ranges/limit-ranges.store";
|
||||||
export type { HPAStore } from "../../renderer/components/+config-autoscalers/hpa.store";
|
export type { HPAStore } from "../../renderer/components/+config-autoscalers/hpa.store";
|
||||||
export type { PodDisruptionBudgetsStore } from "../../renderer/components/+config-pod-disruption-budgets/pod-disruption-budgets.store";
|
export type { PodDisruptionBudgetsStore } from "../../renderer/components/+config-pod-disruption-budgets/pod-disruption-budgets.store";
|
||||||
export type { ServiceStore } from "../../renderer/components/+network-services/services.store";
|
export type { ServiceStore } from "../../renderer/components/+network-services/services.store";
|
||||||
|
|||||||
@ -126,6 +126,7 @@ describe("create clusters", () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
jest.spyOn(Cluster.prototype, "isClusterAdmin").mockReturnValue(Promise.resolve(true));
|
jest.spyOn(Cluster.prototype, "isClusterAdmin").mockReturnValue(Promise.resolve(true));
|
||||||
|
jest.spyOn(Cluster.prototype, "canUseWatchApi").mockReturnValue(Promise.resolve(true));
|
||||||
jest.spyOn(Cluster.prototype, "canI")
|
jest.spyOn(Cluster.prototype, "canI")
|
||||||
.mockImplementation((attr: V1ResourceAttributes): Promise<boolean> => {
|
.mockImplementation((attr: V1ResourceAttributes): Promise<boolean> => {
|
||||||
expect(attr.namespace).toBe("default");
|
expect(attr.namespace).toBe("default");
|
||||||
|
|||||||
@ -1,20 +1,96 @@
|
|||||||
import { autoUpdater } from "electron-updater";
|
import { autoUpdater, UpdateInfo } from "electron-updater";
|
||||||
import logger from "./logger";
|
import logger from "./logger";
|
||||||
|
import { isDevelopment, isTestEnv } from "../common/vars";
|
||||||
|
import { delay } from "../common/utils";
|
||||||
|
import { areArgsUpdateAvailableToBackchannel, AutoUpdateLogPrefix, broadcastMessage, onceCorrect, UpdateAvailableChannel, UpdateAvailableToBackchannel } from "../common/ipc";
|
||||||
|
import { ipcMain } from "electron";
|
||||||
|
|
||||||
export class AppUpdater {
|
let installVersion: null | string = null;
|
||||||
static readonly defaultUpdateIntervalMs = 1000 * 60 * 60 * 24; // once a day
|
|
||||||
|
|
||||||
static checkForUpdates() {
|
function handleAutoUpdateBackChannel(event: Electron.IpcMainEvent, ...[arg]: UpdateAvailableToBackchannel) {
|
||||||
return autoUpdater.checkForUpdatesAndNotify();
|
if (arg.doUpdate) {
|
||||||
}
|
if (arg.now) {
|
||||||
|
logger.info(`${AutoUpdateLogPrefix}: User chose to update now`);
|
||||||
constructor(protected updateInterval = AppUpdater.defaultUpdateIntervalMs) {
|
autoUpdater.on("update-downloaded", () => autoUpdater.quitAndInstall());
|
||||||
autoUpdater.logger = logger;
|
autoUpdater.downloadUpdate().catch(error => logger.error(`${AutoUpdateLogPrefix}: Failed to download or install update`, { error }));
|
||||||
}
|
} else {
|
||||||
|
logger.info(`${AutoUpdateLogPrefix}: User chose to update on quit`);
|
||||||
public start() {
|
autoUpdater.autoInstallOnAppQuit = true;
|
||||||
setInterval(AppUpdater.checkForUpdates, this.updateInterval);
|
autoUpdater.downloadUpdate()
|
||||||
|
.catch(error => logger.error(`${AutoUpdateLogPrefix}: Failed to download update`, { error }));
|
||||||
return AppUpdater.checkForUpdates();
|
}
|
||||||
|
} else {
|
||||||
|
logger.info(`${AutoUpdateLogPrefix}: User chose not to update`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* starts the automatic update checking
|
||||||
|
* @param interval milliseconds between interval to check on, defaults to 24h
|
||||||
|
*/
|
||||||
|
export function startUpdateChecking(interval = 1000 * 60 * 60 * 24): void {
|
||||||
|
if (isDevelopment || isTestEnv) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
autoUpdater.logger = logger;
|
||||||
|
autoUpdater.autoDownload = false;
|
||||||
|
autoUpdater.autoInstallOnAppQuit = false;
|
||||||
|
|
||||||
|
autoUpdater
|
||||||
|
.on("update-available", (args: UpdateInfo) => {
|
||||||
|
if (autoUpdater.autoInstallOnAppQuit) {
|
||||||
|
// a previous auto-update loop was completed with YES+LATER, check if same version
|
||||||
|
if (installVersion === args.version) {
|
||||||
|
// same version, don't broadcast
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This should be always set to false here because it is the reasonable
|
||||||
|
* default. Namely, if a don't auto update to a version that the user
|
||||||
|
* didn't ask for.
|
||||||
|
*/
|
||||||
|
autoUpdater.autoInstallOnAppQuit = false;
|
||||||
|
installVersion = args.version;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const backchannel = `auto-update:${args.version}`;
|
||||||
|
|
||||||
|
ipcMain.removeAllListeners(backchannel); // only one handler should be present
|
||||||
|
|
||||||
|
// make sure that the handler is in place before broadcasting (prevent race-condition)
|
||||||
|
onceCorrect({
|
||||||
|
source: ipcMain,
|
||||||
|
channel: backchannel,
|
||||||
|
listener: handleAutoUpdateBackChannel,
|
||||||
|
verifier: areArgsUpdateAvailableToBackchannel,
|
||||||
|
});
|
||||||
|
logger.info(`${AutoUpdateLogPrefix}: broadcasting update available`, { backchannel, version: args.version });
|
||||||
|
broadcastMessage(UpdateAvailableChannel, backchannel, args);
|
||||||
|
} catch (error) {
|
||||||
|
logger.error(`${AutoUpdateLogPrefix}: broadcasting failed`, { error });
|
||||||
|
installVersion = undefined;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
async function helper() {
|
||||||
|
while (true) {
|
||||||
|
await checkForUpdates();
|
||||||
|
await delay(interval);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
helper();
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function checkForUpdates(): Promise<void> {
|
||||||
|
try {
|
||||||
|
logger.info(`📡 Checking for app updates`);
|
||||||
|
|
||||||
|
await autoUpdater.checkForUpdates();
|
||||||
|
} catch (error) {
|
||||||
|
logger.error(`${AutoUpdateLogPrefix}: failed with an error`, { error: String(error) });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import "../common/cluster-ipc";
|
import "../common/cluster-ipc";
|
||||||
import type http from "http";
|
import type http from "http";
|
||||||
import { ipcMain } from "electron";
|
import { ipcMain } from "electron";
|
||||||
import { autorun } from "mobx";
|
import { autorun, reaction } from "mobx";
|
||||||
import { clusterStore, getClusterIdFromHost } from "../common/cluster-store";
|
import { clusterStore, getClusterIdFromHost } from "../common/cluster-store";
|
||||||
import { Cluster } from "./cluster";
|
import { Cluster } from "./cluster";
|
||||||
import logger from "./logger";
|
import logger from "./logger";
|
||||||
@ -12,14 +12,14 @@ export class ClusterManager extends Singleton {
|
|||||||
constructor(public readonly port: number) {
|
constructor(public readonly port: number) {
|
||||||
super();
|
super();
|
||||||
// auto-init clusters
|
// auto-init clusters
|
||||||
autorun(() => {
|
reaction(() => clusterStore.enabledClustersList, (clusters) => {
|
||||||
clusterStore.enabledClustersList.forEach(cluster => {
|
clusters.forEach((cluster) => {
|
||||||
if (!cluster.initialized) {
|
if (!cluster.initialized && !cluster.initializing) {
|
||||||
logger.info(`[CLUSTER-MANAGER]: init cluster`, cluster.getMeta());
|
logger.info(`[CLUSTER-MANAGER]: init cluster`, cluster.getMeta());
|
||||||
cluster.init(port);
|
cluster.init(port);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
}, { fireImmediately: true });
|
||||||
|
|
||||||
// auto-stop removed clusters
|
// auto-stop removed clusters
|
||||||
autorun(() => {
|
autorun(() => {
|
||||||
|
|||||||
@ -48,6 +48,7 @@ export interface ClusterState {
|
|||||||
isAdmin: boolean;
|
isAdmin: boolean;
|
||||||
allowedNamespaces: string[]
|
allowedNamespaces: string[]
|
||||||
allowedResources: string[]
|
allowedResources: string[]
|
||||||
|
isGlobalWatchEnabled: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -85,6 +86,13 @@ export class Cluster implements ClusterModel, ClusterState {
|
|||||||
whenInitialized = when(() => this.initialized);
|
whenInitialized = when(() => this.initialized);
|
||||||
whenReady = when(() => this.ready);
|
whenReady = when(() => this.ready);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is cluster object initializinng on-going
|
||||||
|
*
|
||||||
|
* @observable
|
||||||
|
*/
|
||||||
|
@observable initializing = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is cluster object initialized
|
* Is cluster object initialized
|
||||||
*
|
*
|
||||||
@ -171,6 +179,12 @@ export class Cluster implements ClusterModel, ClusterState {
|
|||||||
*/
|
*/
|
||||||
@observable isAdmin = false;
|
@observable isAdmin = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Global watch-api accessibility , e.g. "/api/v1/services?watch=1"
|
||||||
|
*
|
||||||
|
* @observable
|
||||||
|
*/
|
||||||
|
@observable isGlobalWatchEnabled = false;
|
||||||
/**
|
/**
|
||||||
* Preferences
|
* Preferences
|
||||||
*
|
*
|
||||||
@ -184,7 +198,7 @@ export class Cluster implements ClusterModel, ClusterState {
|
|||||||
*/
|
*/
|
||||||
@observable metadata: ClusterMetadata = {};
|
@observable metadata: ClusterMetadata = {};
|
||||||
/**
|
/**
|
||||||
* List of allowed namespaces
|
* List of allowed namespaces verified via K8S::SelfSubjectAccessReview api
|
||||||
*
|
*
|
||||||
* @observable
|
* @observable
|
||||||
*/
|
*/
|
||||||
@ -197,7 +211,7 @@ export class Cluster implements ClusterModel, ClusterState {
|
|||||||
*/
|
*/
|
||||||
@observable allowedResources: string[] = [];
|
@observable allowedResources: string[] = [];
|
||||||
/**
|
/**
|
||||||
* List of accessible namespaces
|
* List of accessible namespaces provided by user in the Cluster Settings
|
||||||
*
|
*
|
||||||
* @observable
|
* @observable
|
||||||
*/
|
*/
|
||||||
@ -218,7 +232,7 @@ export class Cluster implements ClusterModel, ClusterState {
|
|||||||
* @computed
|
* @computed
|
||||||
*/
|
*/
|
||||||
@computed get name() {
|
@computed get name() {
|
||||||
return this.preferences.clusterName || this.contextName;
|
return this.preferences.clusterName || this.contextName;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -279,8 +293,10 @@ export class Cluster implements ClusterModel, ClusterState {
|
|||||||
* @param port port where internal auth proxy is listening
|
* @param port port where internal auth proxy is listening
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
@action async init(port: number) {
|
@action
|
||||||
|
async init(port: number) {
|
||||||
try {
|
try {
|
||||||
|
this.initializing = true;
|
||||||
this.contextHandler = new ContextHandler(this);
|
this.contextHandler = new ContextHandler(this);
|
||||||
this.kubeconfigManager = await KubeconfigManager.create(this, this.contextHandler, port);
|
this.kubeconfigManager = await KubeconfigManager.create(this, this.contextHandler, port);
|
||||||
this.kubeProxyUrl = `http://localhost:${port}${apiKubePrefix}`;
|
this.kubeProxyUrl = `http://localhost:${port}${apiKubePrefix}`;
|
||||||
@ -295,6 +311,8 @@ export class Cluster implements ClusterModel, ClusterState {
|
|||||||
id: this.id,
|
id: this.id,
|
||||||
error: err,
|
error: err,
|
||||||
});
|
});
|
||||||
|
} finally {
|
||||||
|
this.initializing = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -331,7 +349,8 @@ export class Cluster implements ClusterModel, ClusterState {
|
|||||||
* @param force force activation
|
* @param force force activation
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
@action async activate(force = false) {
|
@action
|
||||||
|
async activate(force = false) {
|
||||||
if (this.activated && !force) {
|
if (this.activated && !force) {
|
||||||
return this.pushState();
|
return this.pushState();
|
||||||
}
|
}
|
||||||
@ -348,9 +367,7 @@ export class Cluster implements ClusterModel, ClusterState {
|
|||||||
await this.refreshConnectionStatus();
|
await this.refreshConnectionStatus();
|
||||||
|
|
||||||
if (this.accessible) {
|
if (this.accessible) {
|
||||||
await this.refreshAllowedResources();
|
await this.refreshAccessibility();
|
||||||
this.isAdmin = await this.isClusterAdmin();
|
|
||||||
this.ready = true;
|
|
||||||
this.ensureKubectl();
|
this.ensureKubectl();
|
||||||
}
|
}
|
||||||
this.activated = true;
|
this.activated = true;
|
||||||
@ -370,7 +387,8 @@ export class Cluster implements ClusterModel, ClusterState {
|
|||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
@action async reconnect() {
|
@action
|
||||||
|
async reconnect() {
|
||||||
logger.info(`[CLUSTER]: reconnect`, this.getMeta());
|
logger.info(`[CLUSTER]: reconnect`, this.getMeta());
|
||||||
this.contextHandler?.stopServer();
|
this.contextHandler?.stopServer();
|
||||||
await this.contextHandler?.ensureServer();
|
await this.contextHandler?.ensureServer();
|
||||||
@ -389,6 +407,7 @@ export class Cluster implements ClusterModel, ClusterState {
|
|||||||
this.accessible = false;
|
this.accessible = false;
|
||||||
this.ready = false;
|
this.ready = false;
|
||||||
this.activated = false;
|
this.activated = false;
|
||||||
|
this.allowedNamespaces = [];
|
||||||
this.resourceAccessStatuses.clear();
|
this.resourceAccessStatuses.clear();
|
||||||
this.pushState();
|
this.pushState();
|
||||||
}
|
}
|
||||||
@ -397,19 +416,18 @@ export class Cluster implements ClusterModel, ClusterState {
|
|||||||
* @internal
|
* @internal
|
||||||
* @param opts refresh options
|
* @param opts refresh options
|
||||||
*/
|
*/
|
||||||
@action async refresh(opts: ClusterRefreshOptions = {}) {
|
@action
|
||||||
|
async refresh(opts: ClusterRefreshOptions = {}) {
|
||||||
logger.info(`[CLUSTER]: refresh`, this.getMeta());
|
logger.info(`[CLUSTER]: refresh`, this.getMeta());
|
||||||
await this.whenInitialized;
|
await this.whenInitialized;
|
||||||
await this.refreshConnectionStatus();
|
await this.refreshConnectionStatus();
|
||||||
|
|
||||||
if (this.accessible) {
|
if (this.accessible) {
|
||||||
this.isAdmin = await this.isClusterAdmin();
|
await this.refreshAccessibility();
|
||||||
await this.refreshAllowedResources();
|
|
||||||
|
|
||||||
if (opts.refreshMetadata) {
|
if (opts.refreshMetadata) {
|
||||||
this.refreshMetadata();
|
this.refreshMetadata();
|
||||||
}
|
}
|
||||||
this.ready = true;
|
|
||||||
}
|
}
|
||||||
this.pushState();
|
this.pushState();
|
||||||
}
|
}
|
||||||
@ -417,7 +435,8 @@ export class Cluster implements ClusterModel, ClusterState {
|
|||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
@action async refreshMetadata() {
|
@action
|
||||||
|
async refreshMetadata() {
|
||||||
logger.info(`[CLUSTER]: refreshMetadata`, this.getMeta());
|
logger.info(`[CLUSTER]: refreshMetadata`, this.getMeta());
|
||||||
const metadata = await detectorRegistry.detectForCluster(this);
|
const metadata = await detectorRegistry.detectForCluster(this);
|
||||||
const existingMetadata = this.metadata;
|
const existingMetadata = this.metadata;
|
||||||
@ -428,7 +447,20 @@ export class Cluster implements ClusterModel, ClusterState {
|
|||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
@action async refreshConnectionStatus() {
|
private async refreshAccessibility(): Promise<void> {
|
||||||
|
this.isAdmin = await this.isClusterAdmin();
|
||||||
|
this.isGlobalWatchEnabled = await this.canUseWatchApi({ resource: "*" });
|
||||||
|
|
||||||
|
await this.refreshAllowedResources();
|
||||||
|
|
||||||
|
this.ready = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
|
@action
|
||||||
|
async refreshConnectionStatus() {
|
||||||
const connectionStatus = await this.getConnectionStatus();
|
const connectionStatus = await this.getConnectionStatus();
|
||||||
|
|
||||||
this.online = connectionStatus > ClusterStatus.Offline;
|
this.online = connectionStatus > ClusterStatus.Offline;
|
||||||
@ -438,7 +470,8 @@ export class Cluster implements ClusterModel, ClusterState {
|
|||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
@action async refreshAllowedResources() {
|
@action
|
||||||
|
async refreshAllowedResources() {
|
||||||
this.allowedNamespaces = await this.getAllowedNamespaces();
|
this.allowedNamespaces = await this.getAllowedNamespaces();
|
||||||
this.allowedResources = await this.getAllowedResources();
|
this.allowedResources = await this.getAllowedResources();
|
||||||
}
|
}
|
||||||
@ -561,6 +594,17 @@ export class Cluster implements ClusterModel, ClusterState {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
|
async canUseWatchApi(customizeResource: V1ResourceAttributes = {}): Promise<boolean> {
|
||||||
|
return this.canI({
|
||||||
|
verb: "watch",
|
||||||
|
resource: "*",
|
||||||
|
...customizeResource,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
toJSON(): ClusterModel {
|
toJSON(): ClusterModel {
|
||||||
const model: ClusterModel = {
|
const model: ClusterModel = {
|
||||||
id: this.id,
|
id: this.id,
|
||||||
@ -594,6 +638,7 @@ export class Cluster implements ClusterModel, ClusterState {
|
|||||||
isAdmin: this.isAdmin,
|
isAdmin: this.isAdmin,
|
||||||
allowedNamespaces: this.allowedNamespaces,
|
allowedNamespaces: this.allowedNamespaces,
|
||||||
allowedResources: this.allowedResources,
|
allowedResources: this.allowedResources,
|
||||||
|
isGlobalWatchEnabled: this.isGlobalWatchEnabled,
|
||||||
};
|
};
|
||||||
|
|
||||||
return toJS(state, {
|
return toJS(state, {
|
||||||
@ -665,7 +710,7 @@ export class Cluster implements ClusterModel, ClusterState {
|
|||||||
for (const namespace of this.allowedNamespaces.slice(0, 10)) {
|
for (const namespace of this.allowedNamespaces.slice(0, 10)) {
|
||||||
if (!this.resourceAccessStatuses.get(apiResource)) {
|
if (!this.resourceAccessStatuses.get(apiResource)) {
|
||||||
const result = await this.canI({
|
const result = await this.canI({
|
||||||
resource: apiResource.resource,
|
resource: apiResource.apiName,
|
||||||
group: apiResource.group,
|
group: apiResource.group,
|
||||||
verb: "list",
|
verb: "list",
|
||||||
namespace
|
namespace
|
||||||
@ -680,9 +725,19 @@ export class Cluster implements ClusterModel, ClusterState {
|
|||||||
|
|
||||||
return apiResources
|
return apiResources
|
||||||
.filter((resource) => this.resourceAccessStatuses.get(resource))
|
.filter((resource) => this.resourceAccessStatuses.get(resource))
|
||||||
.map(apiResource => apiResource.resource);
|
.map(apiResource => apiResource.apiName);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isAllowedResource(kind: string): boolean {
|
||||||
|
const apiResource = apiResources.find(resource => resource.kind === kind || resource.apiName === kind);
|
||||||
|
|
||||||
|
if (apiResource) {
|
||||||
|
return this.allowedResources.includes(apiResource.apiName);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true; // allowed by default for other resources
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,9 +1,12 @@
|
|||||||
|
import logger from "./logger";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Installs Electron developer tools in the development build.
|
* Installs Electron developer tools in the development build.
|
||||||
* The dependency is not bundled to the production build.
|
* The dependency is not bundled to the production build.
|
||||||
*/
|
*/
|
||||||
export const installDeveloperTools = async () => {
|
export const installDeveloperTools = async () => {
|
||||||
if (process.env.NODE_ENV === "development") {
|
if (process.env.NODE_ENV === "development") {
|
||||||
|
logger.info("🤓 Installing developer tools");
|
||||||
const { default: devToolsInstaller, REACT_DEVELOPER_TOOLS } = await import("electron-devtools-installer");
|
const { default: devToolsInstaller, REACT_DEVELOPER_TOOLS } = await import("electron-devtools-installer");
|
||||||
|
|
||||||
return devToolsInstaller([REACT_DEVELOPER_TOOLS]);
|
return devToolsInstaller([REACT_DEVELOPER_TOOLS]);
|
||||||
|
|||||||
108
src/main/helm/__mocks__/helm-chart-manager.ts
Normal file
108
src/main/helm/__mocks__/helm-chart-manager.ts
Normal file
@ -0,0 +1,108 @@
|
|||||||
|
import { HelmRepo, HelmRepoManager } from "../helm-repo-manager";
|
||||||
|
|
||||||
|
export class HelmChartManager {
|
||||||
|
private cache: any = {};
|
||||||
|
private repo: HelmRepo;
|
||||||
|
|
||||||
|
constructor(repo: HelmRepo){
|
||||||
|
this.cache = HelmRepoManager.cache;
|
||||||
|
this.repo = repo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async charts(): Promise<any> {
|
||||||
|
switch (this.repo.name) {
|
||||||
|
case "stable":
|
||||||
|
return Promise.resolve({
|
||||||
|
"apm-server": [
|
||||||
|
{
|
||||||
|
apiVersion: "3.0.0",
|
||||||
|
name: "apm-server",
|
||||||
|
version: "2.1.7",
|
||||||
|
repo: "stable",
|
||||||
|
digest: "test"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
apiVersion: "3.0.0",
|
||||||
|
name: "apm-server",
|
||||||
|
version: "2.1.6",
|
||||||
|
repo: "stable",
|
||||||
|
digest: "test"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"redis": [
|
||||||
|
{
|
||||||
|
apiVersion: "3.0.0",
|
||||||
|
name: "apm-server",
|
||||||
|
version: "1.0.0",
|
||||||
|
repo: "stable",
|
||||||
|
digest: "test"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
apiVersion: "3.0.0",
|
||||||
|
name: "apm-server",
|
||||||
|
version: "0.0.9",
|
||||||
|
repo: "stable",
|
||||||
|
digest: "test"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
case "experiment":
|
||||||
|
return Promise.resolve({
|
||||||
|
"fairwind": [
|
||||||
|
{
|
||||||
|
apiVersion: "3.0.0",
|
||||||
|
name: "fairwind",
|
||||||
|
version: "0.0.1",
|
||||||
|
repo: "experiment",
|
||||||
|
digest: "test"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
apiVersion: "3.0.0",
|
||||||
|
name: "fairwind",
|
||||||
|
version: "0.0.2",
|
||||||
|
repo: "experiment",
|
||||||
|
digest: "test",
|
||||||
|
deprecated: true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
case "bitnami":
|
||||||
|
return Promise.resolve({
|
||||||
|
"hotdog": [
|
||||||
|
{
|
||||||
|
apiVersion: "3.0.0",
|
||||||
|
name: "hotdog",
|
||||||
|
version: "1.0.1",
|
||||||
|
repo: "bitnami",
|
||||||
|
digest: "test"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
apiVersion: "3.0.0",
|
||||||
|
name: "hotdog",
|
||||||
|
version: "1.0.2",
|
||||||
|
repo: "bitnami",
|
||||||
|
digest: "test",
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"pretzel": [
|
||||||
|
{
|
||||||
|
apiVersion: "3.0.0",
|
||||||
|
name: "pretzel",
|
||||||
|
version: "1.0",
|
||||||
|
repo: "bitnami",
|
||||||
|
digest: "test",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
apiVersion: "3.0.0",
|
||||||
|
name: "pretzel",
|
||||||
|
version: "1.0.1",
|
||||||
|
repo: "bitnami",
|
||||||
|
digest: "test"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
default:
|
||||||
|
return Promise.resolve({});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
104
src/main/helm/__tests__/helm-service.test.ts
Normal file
104
src/main/helm/__tests__/helm-service.test.ts
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
import { helmService } from "../helm-service";
|
||||||
|
import { repoManager } from "../helm-repo-manager";
|
||||||
|
|
||||||
|
jest.spyOn(repoManager, "init").mockImplementation();
|
||||||
|
|
||||||
|
jest.mock("../helm-chart-manager");
|
||||||
|
|
||||||
|
describe("Helm Service tests", () => {
|
||||||
|
test("list charts without deprecated ones", async () => {
|
||||||
|
jest.spyOn(repoManager, "repositories").mockImplementation(async () => {
|
||||||
|
return [
|
||||||
|
{ name: "stable", url: "stableurl" },
|
||||||
|
{ name: "experiment", url: "experimenturl" }
|
||||||
|
];
|
||||||
|
});
|
||||||
|
|
||||||
|
const charts = await helmService.listCharts();
|
||||||
|
|
||||||
|
expect(charts).toEqual({
|
||||||
|
stable: {
|
||||||
|
"apm-server": [
|
||||||
|
{
|
||||||
|
apiVersion: "3.0.0",
|
||||||
|
name: "apm-server",
|
||||||
|
version: "2.1.7",
|
||||||
|
repo: "stable",
|
||||||
|
digest: "test"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
apiVersion: "3.0.0",
|
||||||
|
name: "apm-server",
|
||||||
|
version: "2.1.6",
|
||||||
|
repo: "stable",
|
||||||
|
digest: "test"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"redis": [
|
||||||
|
{
|
||||||
|
apiVersion: "3.0.0",
|
||||||
|
name: "apm-server",
|
||||||
|
version: "1.0.0",
|
||||||
|
repo: "stable",
|
||||||
|
digest: "test"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
apiVersion: "3.0.0",
|
||||||
|
name: "apm-server",
|
||||||
|
version: "0.0.9",
|
||||||
|
repo: "stable",
|
||||||
|
digest: "test"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
experiment: {}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
test("list charts sorted by version in descending order", async () => {
|
||||||
|
jest.spyOn(repoManager, "repositories").mockImplementation(async () => {
|
||||||
|
return [
|
||||||
|
{ name: "bitnami", url: "bitnamiurl" }
|
||||||
|
];
|
||||||
|
});
|
||||||
|
|
||||||
|
const charts = await helmService.listCharts();
|
||||||
|
|
||||||
|
expect(charts).toEqual({
|
||||||
|
bitnami: {
|
||||||
|
"hotdog": [
|
||||||
|
{
|
||||||
|
apiVersion: "3.0.0",
|
||||||
|
name: "hotdog",
|
||||||
|
version: "1.0.2",
|
||||||
|
repo: "bitnami",
|
||||||
|
digest: "test",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
apiVersion: "3.0.0",
|
||||||
|
name: "hotdog",
|
||||||
|
version: "1.0.1",
|
||||||
|
repo: "bitnami",
|
||||||
|
digest: "test"
|
||||||
|
},
|
||||||
|
],
|
||||||
|
"pretzel": [
|
||||||
|
{
|
||||||
|
apiVersion: "3.0.0",
|
||||||
|
name: "pretzel",
|
||||||
|
version: "1.0.1",
|
||||||
|
repo: "bitnami",
|
||||||
|
digest: "test",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
apiVersion: "3.0.0",
|
||||||
|
name: "pretzel",
|
||||||
|
version: "1.0",
|
||||||
|
repo: "bitnami",
|
||||||
|
digest: "test"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
@ -4,9 +4,10 @@ import { HelmRepo, HelmRepoManager } from "./helm-repo-manager";
|
|||||||
import logger from "../logger";
|
import logger from "../logger";
|
||||||
import { promiseExec } from "../promise-exec";
|
import { promiseExec } from "../promise-exec";
|
||||||
import { helmCli } from "./helm-cli";
|
import { helmCli } from "./helm-cli";
|
||||||
|
import type { RepoHelmChartList } from "../../renderer/api/endpoints/helm-charts.api";
|
||||||
|
|
||||||
type CachedYaml = {
|
type CachedYaml = {
|
||||||
entries: any; // todo: types
|
entries: RepoHelmChartList
|
||||||
};
|
};
|
||||||
|
|
||||||
export class HelmChartManager {
|
export class HelmChartManager {
|
||||||
@ -24,15 +25,15 @@ export class HelmChartManager {
|
|||||||
return charts[name];
|
return charts[name];
|
||||||
}
|
}
|
||||||
|
|
||||||
public async charts(): Promise<any> {
|
public async charts(): Promise<RepoHelmChartList> {
|
||||||
try {
|
try {
|
||||||
const cachedYaml = await this.cachedYaml();
|
const cachedYaml = await this.cachedYaml();
|
||||||
|
|
||||||
return cachedYaml["entries"];
|
return cachedYaml["entries"];
|
||||||
} catch(error) {
|
} catch(error) {
|
||||||
logger.error(error);
|
logger.error("HELM-CHART-MANAGER]: failed to list charts", { error });
|
||||||
|
|
||||||
return [];
|
return {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,8 +1,10 @@
|
|||||||
|
import semver from "semver";
|
||||||
import { Cluster } from "../cluster";
|
import { Cluster } from "../cluster";
|
||||||
import logger from "../logger";
|
import logger from "../logger";
|
||||||
import { repoManager } from "./helm-repo-manager";
|
import { repoManager } from "./helm-repo-manager";
|
||||||
import { HelmChartManager } from "./helm-chart-manager";
|
import { HelmChartManager } from "./helm-chart-manager";
|
||||||
import { releaseManager } from "./helm-release-manager";
|
import { releaseManager } from "./helm-release-manager";
|
||||||
|
import { HelmChartList, RepoHelmChartList } from "../../renderer/api/endpoints/helm-charts.api";
|
||||||
|
|
||||||
class HelmService {
|
class HelmService {
|
||||||
public async installChart(cluster: Cluster, data: { chart: string; values: {}; name: string; namespace: string; version: string }) {
|
public async installChart(cluster: Cluster, data: { chart: string; values: {}; name: string; namespace: string; version: string }) {
|
||||||
@ -10,7 +12,7 @@ class HelmService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async listCharts() {
|
public async listCharts() {
|
||||||
const charts: any = {};
|
const charts: HelmChartList = {};
|
||||||
|
|
||||||
await repoManager.init();
|
await repoManager.init();
|
||||||
const repositories = await repoManager.repositories();
|
const repositories = await repoManager.repositories();
|
||||||
@ -18,14 +20,10 @@ class HelmService {
|
|||||||
for (const repo of repositories) {
|
for (const repo of repositories) {
|
||||||
charts[repo.name] = {};
|
charts[repo.name] = {};
|
||||||
const manager = new HelmChartManager(repo);
|
const manager = new HelmChartManager(repo);
|
||||||
let entries = await manager.charts();
|
const sortedCharts = this.sortChartsByVersion(await manager.charts());
|
||||||
|
const enabledCharts = this.excludeDeprecatedChartGroups(sortedCharts);
|
||||||
|
|
||||||
entries = this.excludeDeprecated(entries);
|
charts[repo.name] = enabledCharts;
|
||||||
|
|
||||||
for (const key in entries) {
|
|
||||||
entries[key] = entries[key][0];
|
|
||||||
}
|
|
||||||
charts[repo.name] = entries;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return charts;
|
return charts;
|
||||||
@ -96,20 +94,30 @@ class HelmService {
|
|||||||
return { message: output };
|
return { message: output };
|
||||||
}
|
}
|
||||||
|
|
||||||
protected excludeDeprecated(entries: any) {
|
private excludeDeprecatedChartGroups(chartGroups: RepoHelmChartList) {
|
||||||
for (const key in entries) {
|
const groups = new Map(Object.entries(chartGroups));
|
||||||
entries[key] = entries[key].filter((entry: any) => {
|
|
||||||
if (Array.isArray(entry)) {
|
|
||||||
return entry[0]["deprecated"] != true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return entry["deprecated"] != true;
|
for (const [chartName, charts] of groups) {
|
||||||
|
if (charts[0].deprecated) {
|
||||||
|
groups.delete(chartName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Object.fromEntries(groups);
|
||||||
|
}
|
||||||
|
|
||||||
|
private sortChartsByVersion(chartGroups: RepoHelmChartList) {
|
||||||
|
for (const key in chartGroups) {
|
||||||
|
chartGroups[key] = chartGroups[key].sort((first, second) => {
|
||||||
|
const firstVersion = semver.coerce(first.version || 0);
|
||||||
|
const secondVersion = semver.coerce(second.version || 0);
|
||||||
|
|
||||||
|
return semver.compare(secondVersion, firstVersion);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return entries;
|
return chartGroups;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const helmService = new HelmService();
|
export const helmService = new HelmService();
|
||||||
|
|||||||
@ -4,13 +4,12 @@ import "../common/system-ca";
|
|||||||
import "../common/prometheus-providers";
|
import "../common/prometheus-providers";
|
||||||
import * as Mobx from "mobx";
|
import * as Mobx from "mobx";
|
||||||
import * as LensExtensions from "../extensions/core-api";
|
import * as LensExtensions from "../extensions/core-api";
|
||||||
import { app, dialog, powerMonitor } from "electron";
|
import { app, autoUpdater, dialog, powerMonitor } from "electron";
|
||||||
import { appName } from "../common/vars";
|
import { appName } from "../common/vars";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
import { LensProxy } from "./lens-proxy";
|
import { LensProxy } from "./lens-proxy";
|
||||||
import { WindowManager } from "./window-manager";
|
import { WindowManager } from "./window-manager";
|
||||||
import { ClusterManager } from "./cluster-manager";
|
import { ClusterManager } from "./cluster-manager";
|
||||||
import { AppUpdater } from "./app-updater";
|
|
||||||
import { shellSync } from "./shell-sync";
|
import { shellSync } from "./shell-sync";
|
||||||
import { getFreePort } from "./port";
|
import { getFreePort } from "./port";
|
||||||
import { mangleProxyEnv } from "./proxy-env";
|
import { mangleProxyEnv } from "./proxy-env";
|
||||||
@ -26,6 +25,9 @@ import { InstalledExtension, extensionDiscovery } from "../extensions/extension-
|
|||||||
import type { LensExtensionId } from "../extensions/lens-extension";
|
import type { LensExtensionId } from "../extensions/lens-extension";
|
||||||
import { installDeveloperTools } from "./developer-tools";
|
import { installDeveloperTools } from "./developer-tools";
|
||||||
import { filesystemProvisionerStore } from "./extension-filesystem";
|
import { filesystemProvisionerStore } from "./extension-filesystem";
|
||||||
|
import { getAppVersion, getAppVersionFromProxyServer } from "../common/utils";
|
||||||
|
import { bindBroadcastHandlers } from "../common/ipc";
|
||||||
|
import { startUpdateChecking } from "./app-updater";
|
||||||
|
|
||||||
const workingDir = path.join(app.getPath("appData"), appName);
|
const workingDir = path.join(app.getPath("appData"), appName);
|
||||||
let proxyPort: number;
|
let proxyPort: number;
|
||||||
@ -61,20 +63,20 @@ if (process.env.LENS_DISABLE_GPU) {
|
|||||||
|
|
||||||
app.on("ready", async () => {
|
app.on("ready", async () => {
|
||||||
logger.info(`🚀 Starting Lens from "${workingDir}"`);
|
logger.info(`🚀 Starting Lens from "${workingDir}"`);
|
||||||
|
logger.info("🐚 Syncing shell environment");
|
||||||
await shellSync();
|
await shellSync();
|
||||||
|
|
||||||
|
bindBroadcastHandlers();
|
||||||
|
|
||||||
powerMonitor.on("shutdown", () => {
|
powerMonitor.on("shutdown", () => {
|
||||||
app.exit();
|
app.exit();
|
||||||
});
|
});
|
||||||
|
|
||||||
const updater = new AppUpdater();
|
|
||||||
|
|
||||||
updater.start();
|
|
||||||
|
|
||||||
registerFileProtocol("static", __static);
|
registerFileProtocol("static", __static);
|
||||||
|
|
||||||
await installDeveloperTools();
|
await installDeveloperTools();
|
||||||
|
|
||||||
|
logger.info("💾 Loading stores");
|
||||||
// preload
|
// preload
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
userStore.load(),
|
userStore.load(),
|
||||||
@ -86,6 +88,7 @@ app.on("ready", async () => {
|
|||||||
|
|
||||||
// find free port
|
// find free port
|
||||||
try {
|
try {
|
||||||
|
logger.info("🔑 Getting free port for LensProxy server");
|
||||||
proxyPort = await getFreePort();
|
proxyPort = await getFreePort();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error(error);
|
logger.error(error);
|
||||||
@ -98,6 +101,7 @@ app.on("ready", async () => {
|
|||||||
|
|
||||||
// run proxy
|
// run proxy
|
||||||
try {
|
try {
|
||||||
|
logger.info("🔌 Starting LensProxy");
|
||||||
// eslint-disable-next-line unused-imports/no-unused-vars-ts
|
// eslint-disable-next-line unused-imports/no-unused-vars-ts
|
||||||
proxyServer = LensProxy.create(proxyPort, clusterManager);
|
proxyServer = LensProxy.create(proxyPort, clusterManager);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -106,9 +110,27 @@ app.on("ready", async () => {
|
|||||||
app.exit();
|
app.exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// test proxy connection
|
||||||
|
try {
|
||||||
|
logger.info("🔎 Testing LensProxy connection ...");
|
||||||
|
const versionFromProxy = await getAppVersionFromProxyServer(proxyPort);
|
||||||
|
|
||||||
|
if (getAppVersion() !== versionFromProxy) {
|
||||||
|
logger.error(`Proxy server responded with invalid response`);
|
||||||
|
}
|
||||||
|
logger.info("⚡ LensProxy connection OK");
|
||||||
|
} catch (error) {
|
||||||
|
logger.error("Checking proxy server connection failed", error);
|
||||||
|
}
|
||||||
|
|
||||||
extensionLoader.init();
|
extensionLoader.init();
|
||||||
extensionDiscovery.init();
|
extensionDiscovery.init();
|
||||||
|
|
||||||
|
logger.info("🖥️ Starting WindowManager");
|
||||||
windowManager = WindowManager.getInstance<WindowManager>(proxyPort);
|
windowManager = WindowManager.getInstance<WindowManager>(proxyPort);
|
||||||
|
windowManager.whenLoaded.then(() => startUpdateChecking());
|
||||||
|
|
||||||
|
logger.info("🧩 Initializing extensions");
|
||||||
|
|
||||||
// call after windowManager to see splash earlier
|
// call after windowManager to see splash earlier
|
||||||
try {
|
try {
|
||||||
@ -145,14 +167,25 @@ app.on("activate", (event, hasVisibleWindows) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This variable should is used so that `autoUpdater.installAndQuit()` works
|
||||||
|
*/
|
||||||
|
let blockQuit = true;
|
||||||
|
|
||||||
|
autoUpdater.on("before-quit-for-update", () => blockQuit = false);
|
||||||
|
|
||||||
// Quit app on Cmd+Q (MacOS)
|
// Quit app on Cmd+Q (MacOS)
|
||||||
app.on("will-quit", (event) => {
|
app.on("will-quit", (event) => {
|
||||||
logger.info("APP:QUIT");
|
logger.info("APP:QUIT");
|
||||||
appEventBus.emit({name: "app", action: "close"});
|
appEventBus.emit({name: "app", action: "close"});
|
||||||
event.preventDefault(); // prevent app's default shutdown (e.g. required for telemetry, etc.)
|
|
||||||
clusterManager?.stop(); // close cluster connections
|
clusterManager?.stop(); // close cluster connections
|
||||||
|
|
||||||
return; // skip exit to make tray work, to quit go to app's global menu or tray's menu
|
if (blockQuit) {
|
||||||
|
event.preventDefault(); // prevent app's default shutdown (e.g. required for telemetry, etc.)
|
||||||
|
|
||||||
|
return; // skip exit to make tray work, to quit go to app's global menu or tray's menu
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Extensions-api runtime exports
|
// Extensions-api runtime exports
|
||||||
|
|||||||
@ -23,10 +23,10 @@ const kubectlMap: Map<string, string> = new Map([
|
|||||||
["1.14", "1.14.10"],
|
["1.14", "1.14.10"],
|
||||||
["1.15", "1.15.11"],
|
["1.15", "1.15.11"],
|
||||||
["1.16", "1.16.15"],
|
["1.16", "1.16.15"],
|
||||||
["1.17", bundledVersion],
|
["1.17", "1.17.17"],
|
||||||
["1.18", "1.18.14"],
|
["1.18", bundledVersion],
|
||||||
["1.19", "1.19.5"],
|
["1.19", "1.19.7"],
|
||||||
["1.20", "1.20.0"]
|
["1.20", "1.20.2"]
|
||||||
]);
|
]);
|
||||||
const packageMirrors: Map<string, string> = new Map([
|
const packageMirrors: Map<string, string> = new Map([
|
||||||
["default", "https://storage.googleapis.com/kubernetes-release/release"],
|
["default", "https://storage.googleapis.com/kubernetes-release/release"],
|
||||||
|
|||||||
@ -29,7 +29,7 @@ export class LensProxy {
|
|||||||
|
|
||||||
listen(port = this.port): this {
|
listen(port = this.port): this {
|
||||||
this.proxyServer = this.buildCustomProxy().listen(port);
|
this.proxyServer = this.buildCustomProxy().listen(port);
|
||||||
logger.info(`LensProxy server has started at ${this.origin}`);
|
logger.info(`[LENS-PROXY]: Proxy server has started at ${this.origin}`);
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -194,7 +194,8 @@ export class LensProxy {
|
|||||||
|
|
||||||
if (proxyTarget) {
|
if (proxyTarget) {
|
||||||
// allow to fetch apis in "clusterId.localhost:port" from "localhost:port"
|
// allow to fetch apis in "clusterId.localhost:port" from "localhost:port"
|
||||||
res.setHeader("Access-Control-Allow-Origin", this.origin);
|
// this should be safe because we have already validated cluster uuid
|
||||||
|
res.setHeader("Access-Control-Allow-Origin", "*");
|
||||||
|
|
||||||
return proxy.web(req, res, proxyTarget);
|
return proxy.web(req, res, proxyTarget);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,6 +10,7 @@ import { extensionsURL } from "../renderer/components/+extensions/extensions.rou
|
|||||||
import { menuRegistry } from "../extensions/registries/menu-registry";
|
import { menuRegistry } from "../extensions/registries/menu-registry";
|
||||||
import logger from "./logger";
|
import logger from "./logger";
|
||||||
import { exitApp } from "./exit-app";
|
import { exitApp } from "./exit-app";
|
||||||
|
import { broadcastMessage } from "../common/ipc";
|
||||||
|
|
||||||
export type MenuTopId = "mac" | "file" | "edit" | "view" | "help";
|
export type MenuTopId = "mac" | "file" | "edit" | "view" | "help";
|
||||||
|
|
||||||
@ -173,6 +174,14 @@ export function buildMenu(windowManager: WindowManager) {
|
|||||||
const viewMenu: MenuItemConstructorOptions = {
|
const viewMenu: MenuItemConstructorOptions = {
|
||||||
label: "View",
|
label: "View",
|
||||||
submenu: [
|
submenu: [
|
||||||
|
{
|
||||||
|
label: "Command Palette...",
|
||||||
|
accelerator: "Shift+CmdOrCtrl+P",
|
||||||
|
click() {
|
||||||
|
broadcastMessage("command-palette:open");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ type: "separator" },
|
||||||
{
|
{
|
||||||
label: "Back",
|
label: "Back",
|
||||||
accelerator: "CmdOrCtrl+[",
|
accelerator: "CmdOrCtrl+[",
|
||||||
|
|||||||
@ -5,7 +5,7 @@ import path from "path";
|
|||||||
import { readFile } from "fs-extra";
|
import { readFile } from "fs-extra";
|
||||||
import { Cluster } from "./cluster";
|
import { Cluster } from "./cluster";
|
||||||
import { apiPrefix, appName, publicPath, isDevelopment, webpackDevServerPort } from "../common/vars";
|
import { apiPrefix, appName, publicPath, isDevelopment, webpackDevServerPort } from "../common/vars";
|
||||||
import { helmRoute, kubeconfigRoute, metricsRoute, portForwardRoute, resourceApplierRoute, watchRoute } from "./routes";
|
import { helmRoute, kubeconfigRoute, metricsRoute, portForwardRoute, resourceApplierRoute, versionRoute } from "./routes";
|
||||||
import logger from "./logger";
|
import logger from "./logger";
|
||||||
|
|
||||||
export interface RouterRequestOpts {
|
export interface RouterRequestOpts {
|
||||||
@ -143,11 +143,9 @@ export class Router {
|
|||||||
this.handleStaticFile(params.path, response, req);
|
this.handleStaticFile(params.path, response, req);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.router.add({ method: "get", path: "/version"}, versionRoute.getVersion.bind(versionRoute));
|
||||||
this.router.add({ method: "get", path: `${apiPrefix}/kubeconfig/service-account/{namespace}/{account}` }, kubeconfigRoute.routeServiceAccountRoute.bind(kubeconfigRoute));
|
this.router.add({ method: "get", path: `${apiPrefix}/kubeconfig/service-account/{namespace}/{account}` }, kubeconfigRoute.routeServiceAccountRoute.bind(kubeconfigRoute));
|
||||||
|
|
||||||
// Watch API
|
|
||||||
this.router.add({ method: "get", path: `${apiPrefix}/watch` }, watchRoute.routeWatch.bind(watchRoute));
|
|
||||||
|
|
||||||
// Metrics API
|
// Metrics API
|
||||||
this.router.add({ method: "post", path: `${apiPrefix}/metrics` }, metricsRoute.routeMetrics.bind(metricsRoute));
|
this.router.add({ method: "post", path: `${apiPrefix}/metrics` }, metricsRoute.routeMetrics.bind(metricsRoute));
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
export * from "./kubeconfig-route";
|
export * from "./kubeconfig-route";
|
||||||
export * from "./metrics-route";
|
export * from "./metrics-route";
|
||||||
export * from "./port-forward-route";
|
export * from "./port-forward-route";
|
||||||
export * from "./watch-route";
|
|
||||||
export * from "./helm-route";
|
export * from "./helm-route";
|
||||||
export * from "./resource-applier-route";
|
export * from "./resource-applier-route";
|
||||||
|
export * from "./version-route";
|
||||||
|
|||||||
13
src/main/routes/version-route.ts
Normal file
13
src/main/routes/version-route.ts
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
import { LensApiRequest } from "../router";
|
||||||
|
import { LensApi } from "../lens-api";
|
||||||
|
import { getAppVersion } from "../../common/utils";
|
||||||
|
|
||||||
|
class VersionRoute extends LensApi {
|
||||||
|
public async getVersion(request: LensApiRequest) {
|
||||||
|
const { response } = request;
|
||||||
|
|
||||||
|
this.respondJson(response, { version: getAppVersion()}, 200);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const versionRoute = new VersionRoute();
|
||||||
@ -1,115 +0,0 @@
|
|||||||
import { LensApiRequest } from "../router";
|
|
||||||
import { LensApi } from "../lens-api";
|
|
||||||
import { Watch, KubeConfig } from "@kubernetes/client-node";
|
|
||||||
import { ServerResponse } from "http";
|
|
||||||
import { Request } from "request";
|
|
||||||
import logger from "../logger";
|
|
||||||
|
|
||||||
class ApiWatcher {
|
|
||||||
private apiUrl: string;
|
|
||||||
private response: ServerResponse;
|
|
||||||
private watchRequest: Request;
|
|
||||||
private watch: Watch;
|
|
||||||
private processor: NodeJS.Timeout;
|
|
||||||
private eventBuffer: any[] = [];
|
|
||||||
|
|
||||||
constructor(apiUrl: string, kubeConfig: KubeConfig, response: ServerResponse) {
|
|
||||||
this.apiUrl = apiUrl;
|
|
||||||
this.watch = new Watch(kubeConfig);
|
|
||||||
this.response = response;
|
|
||||||
}
|
|
||||||
|
|
||||||
public async start() {
|
|
||||||
if (this.processor) {
|
|
||||||
clearInterval(this.processor);
|
|
||||||
}
|
|
||||||
this.processor = setInterval(() => {
|
|
||||||
const events = this.eventBuffer.splice(0);
|
|
||||||
|
|
||||||
events.map(event => this.sendEvent(event));
|
|
||||||
this.response.flushHeaders();
|
|
||||||
}, 50);
|
|
||||||
this.watchRequest = await this.watch.watch(this.apiUrl, {}, this.watchHandler.bind(this), this.doneHandler.bind(this));
|
|
||||||
}
|
|
||||||
|
|
||||||
public stop() {
|
|
||||||
if (!this.watchRequest) { return; }
|
|
||||||
|
|
||||||
if (this.processor) {
|
|
||||||
clearInterval(this.processor);
|
|
||||||
}
|
|
||||||
logger.debug(`Stopping watcher for api: ${this.apiUrl}`);
|
|
||||||
|
|
||||||
try {
|
|
||||||
this.watchRequest.abort();
|
|
||||||
this.sendEvent({
|
|
||||||
type: "STREAM_END",
|
|
||||||
url: this.apiUrl,
|
|
||||||
status: 410,
|
|
||||||
});
|
|
||||||
logger.debug("watch aborted");
|
|
||||||
} catch (error) {
|
|
||||||
logger.error(`Watch abort errored:${error}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private watchHandler(phase: string, obj: any) {
|
|
||||||
this.eventBuffer.push({
|
|
||||||
type: phase,
|
|
||||||
object: obj
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private doneHandler(error: Error) {
|
|
||||||
if (error) logger.warn(`watch ended: ${error.toString()}`);
|
|
||||||
this.watchRequest.abort();
|
|
||||||
}
|
|
||||||
|
|
||||||
private sendEvent(evt: any) {
|
|
||||||
// convert to "text/event-stream" format
|
|
||||||
this.response.write(`data: ${JSON.stringify(evt)}\n\n`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class WatchRoute extends LensApi {
|
|
||||||
|
|
||||||
public async routeWatch(request: LensApiRequest) {
|
|
||||||
const { response, cluster} = request;
|
|
||||||
const apis: string[] = request.query.getAll("api");
|
|
||||||
const watchers: ApiWatcher[] = [];
|
|
||||||
|
|
||||||
if (!apis.length) {
|
|
||||||
this.respondJson(response, {
|
|
||||||
message: "Empty request. Query params 'api' are not provided.",
|
|
||||||
example: "?api=/api/v1/pods&api=/api/v1/nodes",
|
|
||||||
}, 400);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
response.setHeader("Content-Type", "text/event-stream");
|
|
||||||
response.setHeader("Cache-Control", "no-cache");
|
|
||||||
response.setHeader("Connection", "keep-alive");
|
|
||||||
logger.debug(`watch using kubeconfig:${JSON.stringify(cluster.getProxyKubeconfig(), null, 2)}`);
|
|
||||||
|
|
||||||
apis.forEach(apiUrl => {
|
|
||||||
const watcher = new ApiWatcher(apiUrl, cluster.getProxyKubeconfig(), response);
|
|
||||||
|
|
||||||
watcher.start();
|
|
||||||
watchers.push(watcher);
|
|
||||||
});
|
|
||||||
|
|
||||||
request.raw.req.on("close", () => {
|
|
||||||
logger.debug("Watch request closed");
|
|
||||||
watchers.map(watcher => watcher.stop());
|
|
||||||
});
|
|
||||||
|
|
||||||
request.raw.req.on("end", () => {
|
|
||||||
logger.debug("Watch request ended");
|
|
||||||
watchers.map(watcher => watcher.stop());
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export const watchRoute = new WatchRoute();
|
|
||||||
@ -108,7 +108,7 @@ export class ShellSession extends EventEmitter {
|
|||||||
|
|
||||||
if(isWindows) {
|
if(isWindows) {
|
||||||
env["SystemRoot"] = process.env.SystemRoot;
|
env["SystemRoot"] = process.env.SystemRoot;
|
||||||
env["PTYSHELL"] = "powershell.exe";
|
env["PTYSHELL"] = process.env.SHELL || "powershell.exe";
|
||||||
env["PATH"] = pathStr;
|
env["PATH"] = pathStr;
|
||||||
} else if(typeof(process.env.SHELL) != "undefined") {
|
} else if(typeof(process.env.SHELL) != "undefined") {
|
||||||
env["PTYSHELL"] = process.env.SHELL;
|
env["PTYSHELL"] = process.env.SHELL;
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
import path from "path";
|
import path from "path";
|
||||||
import packageInfo from "../../package.json";
|
import packageInfo from "../../package.json";
|
||||||
import { dialog, Menu, NativeImage, Tray } from "electron";
|
import { Menu, NativeImage, Tray } from "electron";
|
||||||
import { autorun } from "mobx";
|
import { autorun } from "mobx";
|
||||||
import { showAbout } from "./menu";
|
import { showAbout } from "./menu";
|
||||||
import { AppUpdater } from "./app-updater";
|
import { checkForUpdates } from "./app-updater";
|
||||||
import { WindowManager } from "./window-manager";
|
import { WindowManager } from "./window-manager";
|
||||||
import { clusterStore } from "../common/cluster-store";
|
import { clusterStore } from "../common/cluster-store";
|
||||||
import { workspaceStore } from "../common/workspace-store";
|
import { workspaceStore } from "../common/workspace-store";
|
||||||
@ -62,16 +62,6 @@ function buildTray(icon: string | NativeImage, menu: Menu, windowManager: Window
|
|||||||
|
|
||||||
function createTrayMenu(windowManager: WindowManager): Menu {
|
function createTrayMenu(windowManager: WindowManager): Menu {
|
||||||
return Menu.buildFromTemplate([
|
return Menu.buildFromTemplate([
|
||||||
{
|
|
||||||
label: "About Lens",
|
|
||||||
async click() {
|
|
||||||
// note: argument[1] (browserWindow) not available when app is not focused / hidden
|
|
||||||
const browserWindow = await windowManager.ensureMainWindow();
|
|
||||||
|
|
||||||
showAbout(browserWindow);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{ type: "separator" },
|
|
||||||
{
|
{
|
||||||
label: "Open Lens",
|
label: "Open Lens",
|
||||||
async click() {
|
async click() {
|
||||||
@ -112,16 +102,17 @@ function createTrayMenu(windowManager: WindowManager): Menu {
|
|||||||
{
|
{
|
||||||
label: "Check for updates",
|
label: "Check for updates",
|
||||||
async click() {
|
async click() {
|
||||||
const result = await AppUpdater.checkForUpdates();
|
await checkForUpdates();
|
||||||
|
await windowManager.ensureMainWindow();
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "About Lens",
|
||||||
|
async click() {
|
||||||
|
// note: argument[1] (browserWindow) not available when app is not focused / hidden
|
||||||
|
const browserWindow = await windowManager.ensureMainWindow();
|
||||||
|
|
||||||
if (!result) {
|
showAbout(browserWindow);
|
||||||
const browserWindow = await windowManager.ensureMainWindow();
|
|
||||||
|
|
||||||
dialog.showMessageBoxSync(browserWindow, {
|
|
||||||
message: "No updates available",
|
|
||||||
type: "info",
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{ type: "separator" },
|
{ type: "separator" },
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import type { ClusterId } from "../common/cluster-store";
|
import type { ClusterId } from "../common/cluster-store";
|
||||||
import { observable } from "mobx";
|
import { observable, when } from "mobx";
|
||||||
import { app, BrowserWindow, dialog, shell, webContents } from "electron";
|
import { app, BrowserWindow, dialog, shell, webContents } from "electron";
|
||||||
import windowStateKeeper from "electron-window-state";
|
import windowStateKeeper from "electron-window-state";
|
||||||
import { appEventBus } from "../common/event-bus";
|
import { appEventBus } from "../common/event-bus";
|
||||||
@ -8,6 +8,7 @@ import { initMenu } from "./menu";
|
|||||||
import { initTray } from "./tray";
|
import { initTray } from "./tray";
|
||||||
import { Singleton } from "../common/utils";
|
import { Singleton } from "../common/utils";
|
||||||
import { ClusterFrameInfo, clusterFrameMap } from "../common/cluster-frames";
|
import { ClusterFrameInfo, clusterFrameMap } from "../common/cluster-frames";
|
||||||
|
import logger from "./logger";
|
||||||
|
|
||||||
export class WindowManager extends Singleton {
|
export class WindowManager extends Singleton {
|
||||||
protected mainWindow: BrowserWindow;
|
protected mainWindow: BrowserWindow;
|
||||||
@ -15,6 +16,9 @@ export class WindowManager extends Singleton {
|
|||||||
protected windowState: windowStateKeeper.State;
|
protected windowState: windowStateKeeper.State;
|
||||||
protected disposers: Record<string, Function> = {};
|
protected disposers: Record<string, Function> = {};
|
||||||
|
|
||||||
|
@observable mainViewInitiallyLoaded = false;
|
||||||
|
whenLoaded = when(() => this.mainViewInitiallyLoaded);
|
||||||
|
|
||||||
@observable activeClusterId: ClusterId;
|
@observable activeClusterId: ClusterId;
|
||||||
|
|
||||||
constructor(protected proxyPort: number) {
|
constructor(protected proxyPort: number) {
|
||||||
@ -81,16 +85,26 @@ export class WindowManager extends Singleton {
|
|||||||
this.splashWindow = null;
|
this.splashWindow = null;
|
||||||
app.dock?.hide(); // hide icon in dock (mac-os)
|
app.dock?.hide(); // hide icon in dock (mac-os)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.mainWindow.webContents.on("did-fail-load", (_event, code, desc) => {
|
||||||
|
logger.error(`[WINDOW-MANAGER]: Failed to load Main window`, { code, desc });
|
||||||
|
});
|
||||||
|
|
||||||
|
this.mainWindow.webContents.on("did-finish-load", () => {
|
||||||
|
logger.info("[WINDOW-MANAGER]: Main window loaded");
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (showSplash) await this.showSplash();
|
if (showSplash) await this.showSplash();
|
||||||
|
logger.info(`[WINDOW-MANAGER]: Loading Main window from url: ${this.mainUrl} ...`);
|
||||||
await this.mainWindow.loadURL(this.mainUrl);
|
await this.mainWindow.loadURL(this.mainUrl);
|
||||||
this.mainWindow.show();
|
this.mainWindow.show();
|
||||||
this.splashWindow?.close();
|
this.splashWindow?.close();
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
appEventBus.emit({ name: "app", action: "start" });
|
appEventBus.emit({ name: "app", action: "start" });
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
this.mainViewInitiallyLoaded = true;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
dialog.showErrorBox("ERROR!", err.toString());
|
dialog.showErrorBox("ERROR!", err.toString());
|
||||||
}
|
}
|
||||||
|
|||||||
40
src/renderer/api/__tests__/api-manager.test.ts
Normal file
40
src/renderer/api/__tests__/api-manager.test.ts
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
import { ingressStore } from "../../components/+network-ingresses/ingress.store";
|
||||||
|
import { apiManager } from "../api-manager";
|
||||||
|
import { KubeApi } from "../kube-api";
|
||||||
|
|
||||||
|
class TestApi extends KubeApi {
|
||||||
|
|
||||||
|
protected async checkPreferredVersion() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
describe("ApiManager", () => {
|
||||||
|
describe("registerApi", () => {
|
||||||
|
it("re-register store if apiBase changed", async () => {
|
||||||
|
const apiBase = "apis/v1/foo";
|
||||||
|
const fallbackApiBase = "/apis/extensions/v1beta1/foo";
|
||||||
|
const kubeApi = new TestApi({
|
||||||
|
apiBase,
|
||||||
|
fallbackApiBases: [fallbackApiBase],
|
||||||
|
checkPreferredVersion: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
apiManager.registerApi(apiBase, kubeApi);
|
||||||
|
|
||||||
|
// Define to use test api for ingress store
|
||||||
|
Object.defineProperty(ingressStore, "api", { value: kubeApi });
|
||||||
|
apiManager.registerStore(ingressStore, [kubeApi]);
|
||||||
|
|
||||||
|
// Test that store is returned with original apiBase
|
||||||
|
expect(apiManager.getStore(kubeApi)).toBe(ingressStore);
|
||||||
|
|
||||||
|
// Change apiBase similar as checkPreferredVersion does
|
||||||
|
Object.defineProperty(kubeApi, "apiBase", { value: fallbackApiBase });
|
||||||
|
apiManager.registerApi(fallbackApiBase, kubeApi);
|
||||||
|
|
||||||
|
// Test that store is returned with new apiBase
|
||||||
|
expect(apiManager.getStore(kubeApi)).toBe(ingressStore);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
@ -2,16 +2,16 @@ import type { KubeObjectStore } from "../kube-object.store";
|
|||||||
|
|
||||||
import { action, observable } from "mobx";
|
import { action, observable } from "mobx";
|
||||||
import { autobind } from "../utils";
|
import { autobind } from "../utils";
|
||||||
import { KubeApi } from "./kube-api";
|
import { KubeApi, parseKubeApi } from "./kube-api";
|
||||||
|
|
||||||
@autobind()
|
@autobind()
|
||||||
export class ApiManager {
|
export class ApiManager {
|
||||||
private apis = observable.map<string, KubeApi>();
|
private apis = observable.map<string, KubeApi>();
|
||||||
private stores = observable.map<KubeApi, KubeObjectStore>();
|
private stores = observable.map<string, KubeObjectStore>();
|
||||||
|
|
||||||
getApi(pathOrCallback: string | ((api: KubeApi) => boolean)) {
|
getApi(pathOrCallback: string | ((api: KubeApi) => boolean)) {
|
||||||
if (typeof pathOrCallback === "string") {
|
if (typeof pathOrCallback === "string") {
|
||||||
return this.apis.get(pathOrCallback) || this.apis.get(KubeApi.parseApi(pathOrCallback).apiBase);
|
return this.apis.get(pathOrCallback) || this.apis.get(parseKubeApi(pathOrCallback).apiBase);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Array.from(this.apis.values()).find(pathOrCallback ?? (() => true));
|
return Array.from(this.apis.values()).find(pathOrCallback ?? (() => true));
|
||||||
@ -23,6 +23,12 @@ export class ApiManager {
|
|||||||
|
|
||||||
registerApi(apiBase: string, api: KubeApi) {
|
registerApi(apiBase: string, api: KubeApi) {
|
||||||
if (!this.apis.has(apiBase)) {
|
if (!this.apis.has(apiBase)) {
|
||||||
|
this.stores.forEach((store) => {
|
||||||
|
if(store.api === api) {
|
||||||
|
this.stores.set(apiBase, store);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
this.apis.set(apiBase, api);
|
this.apis.set(apiBase, api);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -46,12 +52,12 @@ export class ApiManager {
|
|||||||
@action
|
@action
|
||||||
registerStore(store: KubeObjectStore, apis: KubeApi[] = [store.api]) {
|
registerStore(store: KubeObjectStore, apis: KubeApi[] = [store.api]) {
|
||||||
apis.forEach(api => {
|
apis.forEach(api => {
|
||||||
this.stores.set(api, store);
|
this.stores.set(api.apiBase, store);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
getStore<S extends KubeObjectStore>(api: string | KubeApi): S {
|
getStore<S extends KubeObjectStore>(api: string | KubeApi): S {
|
||||||
return this.stores.get(this.resolveApi(api)) as S;
|
return this.stores.get(this.resolveApi(api)?.apiBase) as S;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -28,7 +28,7 @@ export class KubeEvent extends KubeObject {
|
|||||||
firstTimestamp: string;
|
firstTimestamp: string;
|
||||||
lastTimestamp: string;
|
lastTimestamp: string;
|
||||||
count: number;
|
count: number;
|
||||||
type: string;
|
type: "Normal" | "Warning" | string;
|
||||||
eventTime: null;
|
eventTime: null;
|
||||||
reportingComponent: string;
|
reportingComponent: string;
|
||||||
reportingInstance: string;
|
reportingInstance: string;
|
||||||
|
|||||||
@ -3,11 +3,8 @@ import { apiBase } from "../index";
|
|||||||
import { stringify } from "querystring";
|
import { stringify } from "querystring";
|
||||||
import { autobind } from "../../utils";
|
import { autobind } from "../../utils";
|
||||||
|
|
||||||
interface IHelmChartList {
|
export type RepoHelmChartList = Record<string, HelmChart[]>;
|
||||||
[repo: string]: {
|
export type HelmChartList = Record<string, RepoHelmChartList>;
|
||||||
[name: string]: HelmChart;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface IHelmChartDetails {
|
export interface IHelmChartDetails {
|
||||||
readme: string;
|
readme: string;
|
||||||
@ -22,12 +19,12 @@ const endpoint = compile(`/v2/charts/:repo?/:name?`) as (params?: {
|
|||||||
export const helmChartsApi = {
|
export const helmChartsApi = {
|
||||||
list() {
|
list() {
|
||||||
return apiBase
|
return apiBase
|
||||||
.get<IHelmChartList>(endpoint())
|
.get<HelmChartList>(endpoint())
|
||||||
.then(data => {
|
.then(data => {
|
||||||
return Object
|
return Object
|
||||||
.values(data)
|
.values(data)
|
||||||
.reduce((allCharts, repoCharts) => allCharts.concat(Object.values(repoCharts)), [])
|
.reduce((allCharts, repoCharts) => allCharts.concat(Object.values(repoCharts)), [])
|
||||||
.map(HelmChart.create);
|
.map(([chart]) => HelmChart.create(chart));
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -86,7 +83,7 @@ export class HelmChart {
|
|||||||
tillerVersion?: string;
|
tillerVersion?: string;
|
||||||
|
|
||||||
getId() {
|
getId() {
|
||||||
return this.digest;
|
return `${this.apiVersion}/${this.name}@${this.getAppVersion()}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
getName() {
|
getName() {
|
||||||
|
|||||||
@ -57,6 +57,7 @@ export interface IReleaseRevision {
|
|||||||
updated: string;
|
updated: string;
|
||||||
status: string;
|
status: string;
|
||||||
chart: string;
|
chart: string;
|
||||||
|
app_version: string;
|
||||||
description: string;
|
description: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -197,10 +198,9 @@ export class HelmRelease implements ItemObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getUpdated(humanize = true, compact = true) {
|
getUpdated(humanize = true, compact = true) {
|
||||||
const now = new Date().getTime();
|
|
||||||
const updated = this.updated.replace(/\s\w*$/, ""); // 2019-11-26 10:58:09 +0300 MSK -> 2019-11-26 10:58:09 +0300 to pass into Date()
|
const updated = this.updated.replace(/\s\w*$/, ""); // 2019-11-26 10:58:09 +0300 MSK -> 2019-11-26 10:58:09 +0300 to pass into Date()
|
||||||
const updatedDate = new Date(updated).getTime();
|
const updatedDate = new Date(updated).getTime();
|
||||||
const diff = now - updatedDate;
|
const diff = Date.now() - updatedDate;
|
||||||
|
|
||||||
if (humanize) {
|
if (humanize) {
|
||||||
return formatDuration(diff, compact);
|
return formatDuration(diff, compact);
|
||||||
|
|||||||
@ -14,6 +14,7 @@ export * from "./events.api";
|
|||||||
export * from "./hpa.api";
|
export * from "./hpa.api";
|
||||||
export * from "./ingress.api";
|
export * from "./ingress.api";
|
||||||
export * from "./job.api";
|
export * from "./job.api";
|
||||||
|
export * from "./limit-range.api";
|
||||||
export * from "./namespaces.api";
|
export * from "./namespaces.api";
|
||||||
export * from "./network-policy.api";
|
export * from "./network-policy.api";
|
||||||
export * from "./nodes.api";
|
export * from "./nodes.api";
|
||||||
|
|||||||
57
src/renderer/api/endpoints/limit-range.api.ts
Normal file
57
src/renderer/api/endpoints/limit-range.api.ts
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
import { KubeObject } from "../kube-object";
|
||||||
|
import { KubeApi } from "../kube-api";
|
||||||
|
import { autobind } from "../../utils";
|
||||||
|
|
||||||
|
export enum LimitType {
|
||||||
|
CONTAINER = "Container",
|
||||||
|
POD = "Pod",
|
||||||
|
PVC = "PersistentVolumeClaim",
|
||||||
|
}
|
||||||
|
|
||||||
|
export enum Resource {
|
||||||
|
MEMORY = "memory",
|
||||||
|
CPU = "cpu",
|
||||||
|
STORAGE = "storage",
|
||||||
|
EPHEMERAL_STORAGE = "ephemeral-storage",
|
||||||
|
}
|
||||||
|
|
||||||
|
export enum LimitPart {
|
||||||
|
MAX = "max",
|
||||||
|
MIN = "min",
|
||||||
|
DEFAULT = "default",
|
||||||
|
DEFAULT_REQUEST = "defaultRequest",
|
||||||
|
MAX_LIMIT_REQUEST_RATIO = "maxLimitRequestRatio",
|
||||||
|
}
|
||||||
|
|
||||||
|
type LimitRangeParts = Partial<Record<LimitPart, Record<string, string>>>;
|
||||||
|
|
||||||
|
export interface LimitRangeItem extends LimitRangeParts {
|
||||||
|
type: string
|
||||||
|
}
|
||||||
|
|
||||||
|
@autobind()
|
||||||
|
export class LimitRange extends KubeObject {
|
||||||
|
static kind = "LimitRange";
|
||||||
|
static namespaced = true;
|
||||||
|
static apiBase = "/api/v1/limitranges";
|
||||||
|
|
||||||
|
spec: {
|
||||||
|
limits: LimitRangeItem[];
|
||||||
|
};
|
||||||
|
|
||||||
|
getContainerLimits() {
|
||||||
|
return this.spec.limits.filter(limit => limit.type === LimitType.CONTAINER);
|
||||||
|
}
|
||||||
|
|
||||||
|
getPodLimits() {
|
||||||
|
return this.spec.limits.filter(limit => limit.type === LimitType.POD);
|
||||||
|
}
|
||||||
|
|
||||||
|
getPVCLimits() {
|
||||||
|
return this.spec.limits.filter(limit => limit.type === LimitType.PVC);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const limitRangeApi = new KubeApi({
|
||||||
|
objectConstructor: LimitRange,
|
||||||
|
});
|
||||||
@ -63,10 +63,16 @@ export class PersistentVolume extends KubeObject {
|
|||||||
return this.status.phase || "-";
|
return this.status.phase || "-";
|
||||||
}
|
}
|
||||||
|
|
||||||
getClaimRefName() {
|
getStorageClass(): string {
|
||||||
const { claimRef } = this.spec;
|
return this.spec.storageClassName;
|
||||||
|
}
|
||||||
|
|
||||||
return claimRef ? claimRef.name : "";
|
getClaimRefName(): string {
|
||||||
|
return this.spec.claimRef?.name ?? "";
|
||||||
|
}
|
||||||
|
|
||||||
|
getStorageClassName() {
|
||||||
|
return this.spec.storageClassName || "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -104,6 +104,9 @@ export interface IPodContainer {
|
|||||||
configMapRef?: {
|
configMapRef?: {
|
||||||
name: string;
|
name: string;
|
||||||
};
|
};
|
||||||
|
secretRef?: {
|
||||||
|
name: string;
|
||||||
|
}
|
||||||
}[];
|
}[];
|
||||||
volumeMounts?: {
|
volumeMounts?: {
|
||||||
name: string;
|
name: string;
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
import { stringify } from "querystring";
|
import { stringify } from "querystring";
|
||||||
import { EventEmitter } from "../../common/event-emitter";
|
import { EventEmitter } from "../../common/event-emitter";
|
||||||
import { cancelableFetch } from "../utils/cancelableFetch";
|
import { cancelableFetch } from "../utils/cancelableFetch";
|
||||||
|
import { randomBytes } from "crypto";
|
||||||
export interface JsonApiData {
|
export interface JsonApiData {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,6 +55,34 @@ export class JsonApi<D = JsonApiData, P extends JsonApiParams = JsonApiParams> {
|
|||||||
return this.request<T>(path, params, { ...reqInit, method: "get" });
|
return this.request<T>(path, params, { ...reqInit, method: "get" });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getResponse(path: string, params?: P, init: RequestInit = {}): Promise<Response> {
|
||||||
|
const reqPath = `${this.config.apiBase}${path}`;
|
||||||
|
const subdomain = randomBytes(2).toString("hex");
|
||||||
|
let reqUrl = `http://${subdomain}.${window.location.host}${reqPath}`; // hack around browser connection limits (chromium allows 6 per domain)
|
||||||
|
const reqInit: RequestInit = { ...init };
|
||||||
|
const { query } = params || {} as P;
|
||||||
|
|
||||||
|
if (!reqInit.method) {
|
||||||
|
reqInit.method = "get";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (query) {
|
||||||
|
const queryString = stringify(query);
|
||||||
|
|
||||||
|
reqUrl += (reqUrl.includes("?") ? "&" : "?") + queryString;
|
||||||
|
}
|
||||||
|
|
||||||
|
const infoLog: JsonApiLog = {
|
||||||
|
method: reqInit.method.toUpperCase(),
|
||||||
|
reqUrl: reqPath,
|
||||||
|
reqInit,
|
||||||
|
};
|
||||||
|
|
||||||
|
this.writeLog({ ...infoLog });
|
||||||
|
|
||||||
|
return fetch(reqUrl, reqInit);
|
||||||
|
}
|
||||||
|
|
||||||
post<T = D>(path: string, params?: P, reqInit: RequestInit = {}) {
|
post<T = D>(path: string, params?: P, reqInit: RequestInit = {}) {
|
||||||
return this.request<T>(path, params, { ...reqInit, method: "post" });
|
return this.request<T>(path, params, { ...reqInit, method: "post" });
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,8 +8,10 @@ import { apiManager } from "./api-manager";
|
|||||||
import { apiKube } from "./index";
|
import { apiKube } from "./index";
|
||||||
import { createKubeApiURL, parseKubeApi } from "./kube-api-parse";
|
import { createKubeApiURL, parseKubeApi } from "./kube-api-parse";
|
||||||
import { KubeJsonApi, KubeJsonApiData, KubeJsonApiDataList } from "./kube-json-api";
|
import { KubeJsonApi, KubeJsonApiData, KubeJsonApiDataList } from "./kube-json-api";
|
||||||
import { IKubeObjectConstructor, KubeObject } from "./kube-object";
|
import { IKubeObjectConstructor, KubeObject, KubeStatus } from "./kube-object";
|
||||||
import { kubeWatchApi } from "./kube-watch-api";
|
import byline from "byline";
|
||||||
|
import { IKubeWatchEvent } from "./kube-watch-api";
|
||||||
|
import { ReadableWebToNodeStream } from "../utils/readableStream";
|
||||||
|
|
||||||
export interface IKubeApiOptions<T extends KubeObject> {
|
export interface IKubeApiOptions<T extends KubeObject> {
|
||||||
/**
|
/**
|
||||||
@ -91,15 +93,15 @@ export function ensureObjectSelfLink(api: KubeApi, object: KubeJsonApiData) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type KubeApiWatchCallback = (data: IKubeWatchEvent, error: any) => void;
|
||||||
|
|
||||||
|
export type KubeApiWatchOptions = {
|
||||||
|
namespace: string;
|
||||||
|
callback?: KubeApiWatchCallback;
|
||||||
|
abortController?: AbortController
|
||||||
|
};
|
||||||
|
|
||||||
export class KubeApi<T extends KubeObject = any> {
|
export class KubeApi<T extends KubeObject = any> {
|
||||||
static parseApi = parseKubeApi;
|
|
||||||
|
|
||||||
static watchAll(...apis: KubeApi[]) {
|
|
||||||
const disposers = apis.map(api => api.watch());
|
|
||||||
|
|
||||||
return () => disposers.forEach(unwatch => unwatch());
|
|
||||||
}
|
|
||||||
|
|
||||||
readonly kind: string;
|
readonly kind: string;
|
||||||
readonly apiBase: string;
|
readonly apiBase: string;
|
||||||
readonly apiPrefix: string;
|
readonly apiPrefix: string;
|
||||||
@ -112,6 +114,7 @@ export class KubeApi<T extends KubeObject = any> {
|
|||||||
public objectConstructor: IKubeObjectConstructor<T>;
|
public objectConstructor: IKubeObjectConstructor<T>;
|
||||||
protected request: KubeJsonApi;
|
protected request: KubeJsonApi;
|
||||||
protected resourceVersions = new Map<string, string>();
|
protected resourceVersions = new Map<string, string>();
|
||||||
|
protected watchDisposer: () => void;
|
||||||
|
|
||||||
constructor(protected options: IKubeApiOptions<T>) {
|
constructor(protected options: IKubeApiOptions<T>) {
|
||||||
const {
|
const {
|
||||||
@ -124,7 +127,7 @@ export class KubeApi<T extends KubeObject = any> {
|
|||||||
if (!options.apiBase) {
|
if (!options.apiBase) {
|
||||||
options.apiBase = objectConstructor.apiBase;
|
options.apiBase = objectConstructor.apiBase;
|
||||||
}
|
}
|
||||||
const { apiBase, apiPrefix, apiGroup, apiVersion, resource } = KubeApi.parseApi(options.apiBase);
|
const { apiBase, apiPrefix, apiGroup, apiVersion, resource } = parseKubeApi(options.apiBase);
|
||||||
|
|
||||||
this.kind = kind;
|
this.kind = kind;
|
||||||
this.isNamespaced = isNamespaced;
|
this.isNamespaced = isNamespaced;
|
||||||
@ -157,7 +160,7 @@ export class KubeApi<T extends KubeObject = any> {
|
|||||||
|
|
||||||
for (const apiUrl of apiBases) {
|
for (const apiUrl of apiBases) {
|
||||||
// Split e.g. "/apis/extensions/v1beta1/ingresses" to parts
|
// Split e.g. "/apis/extensions/v1beta1/ingresses" to parts
|
||||||
const { apiPrefix, apiGroup, apiVersionWithGroup, resource } = KubeApi.parseApi(apiUrl);
|
const { apiPrefix, apiGroup, apiVersionWithGroup, resource } = parseKubeApi(apiUrl);
|
||||||
|
|
||||||
// Request available resources
|
// Request available resources
|
||||||
try {
|
try {
|
||||||
@ -269,6 +272,7 @@ export class KubeApi<T extends KubeObject = any> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected parseResponse(data: KubeJsonApiData | KubeJsonApiData[] | KubeJsonApiDataList, namespace?: string): any {
|
protected parseResponse(data: KubeJsonApiData | KubeJsonApiData[] | KubeJsonApiDataList, namespace?: string): any {
|
||||||
|
if (!data) return;
|
||||||
const KubeObjectConstructor = this.objectConstructor;
|
const KubeObjectConstructor = this.objectConstructor;
|
||||||
|
|
||||||
if (KubeObject.isJsonApiData(data)) {
|
if (KubeObject.isJsonApiData(data)) {
|
||||||
@ -365,8 +369,98 @@ export class KubeApi<T extends KubeObject = any> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
watch(): () => void {
|
watch(opts: KubeApiWatchOptions = { namespace: "" }): () => void {
|
||||||
return kubeWatchApi.subscribe(this);
|
if (!opts.abortController) {
|
||||||
|
opts.abortController = new AbortController();
|
||||||
|
}
|
||||||
|
let errorReceived = false;
|
||||||
|
let timedRetry: NodeJS.Timeout;
|
||||||
|
const { abortController, namespace, callback } = opts;
|
||||||
|
|
||||||
|
abortController.signal.addEventListener("abort", () => {
|
||||||
|
clearTimeout(timedRetry);
|
||||||
|
});
|
||||||
|
|
||||||
|
const watchUrl = this.getWatchUrl(namespace);
|
||||||
|
const responsePromise = this.request.getResponse(watchUrl, null, {
|
||||||
|
signal: abortController.signal
|
||||||
|
});
|
||||||
|
|
||||||
|
responsePromise.then((response) => {
|
||||||
|
if (!response.ok && !abortController.signal.aborted) {
|
||||||
|
callback?.(null, response);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const nodeStream = new ReadableWebToNodeStream(response.body);
|
||||||
|
|
||||||
|
["end", "close", "error"].forEach((eventName) => {
|
||||||
|
nodeStream.on(eventName, () => {
|
||||||
|
if (errorReceived) return; // kubernetes errors should be handled in a callback
|
||||||
|
|
||||||
|
clearTimeout(timedRetry);
|
||||||
|
timedRetry = setTimeout(() => { // we did not get any kubernetes errors so let's retry
|
||||||
|
if (abortController.signal.aborted) return;
|
||||||
|
|
||||||
|
this.watch({...opts, namespace, callback});
|
||||||
|
}, 1000);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
const stream = byline(nodeStream);
|
||||||
|
|
||||||
|
stream.on("data", (line) => {
|
||||||
|
try {
|
||||||
|
const event: IKubeWatchEvent = JSON.parse(line);
|
||||||
|
|
||||||
|
if (event.type === "ERROR" && event.object.kind === "Status") {
|
||||||
|
errorReceived = true;
|
||||||
|
callback(null, new KubeStatus(event.object as any));
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.modifyWatchEvent(event);
|
||||||
|
|
||||||
|
if (callback) {
|
||||||
|
callback(event, null);
|
||||||
|
}
|
||||||
|
} catch (ignore) {
|
||||||
|
// ignore parse errors
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}, (error) => {
|
||||||
|
if (error instanceof DOMException) return; // AbortController rejects, we can ignore it
|
||||||
|
|
||||||
|
callback?.(null, error);
|
||||||
|
}).catch((error) => {
|
||||||
|
callback?.(null, error);
|
||||||
|
});
|
||||||
|
|
||||||
|
const disposer = () => {
|
||||||
|
abortController.abort();
|
||||||
|
};
|
||||||
|
|
||||||
|
return disposer;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected modifyWatchEvent(event: IKubeWatchEvent) {
|
||||||
|
|
||||||
|
switch (event.type) {
|
||||||
|
case "ADDED":
|
||||||
|
case "DELETED":
|
||||||
|
|
||||||
|
case "MODIFIED": {
|
||||||
|
ensureObjectSelfLink(this, event.object);
|
||||||
|
|
||||||
|
const { namespace, resourceVersion } = event.object.metadata;
|
||||||
|
|
||||||
|
this.setResourceVersion(namespace, resourceVersion);
|
||||||
|
this.setResourceVersion("", resourceVersion);
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -21,7 +21,7 @@ export interface KubeJsonApiData extends JsonApiData {
|
|||||||
resourceVersion: string;
|
resourceVersion: string;
|
||||||
continue?: string;
|
continue?: string;
|
||||||
finalizers?: string[];
|
finalizers?: string[];
|
||||||
selfLink: string;
|
selfLink?: string;
|
||||||
labels?: {
|
labels?: {
|
||||||
[label: string]: string;
|
[label: string]: string;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -40,6 +40,29 @@ export interface IKubeObjectMetadata {
|
|||||||
}[];
|
}[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface IKubeStatus {
|
||||||
|
kind: string;
|
||||||
|
apiVersion: string;
|
||||||
|
code: number;
|
||||||
|
message?: string;
|
||||||
|
reason?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class KubeStatus {
|
||||||
|
public readonly kind = "Status";
|
||||||
|
public readonly apiVersion: string;
|
||||||
|
public readonly code: number;
|
||||||
|
public readonly message: string;
|
||||||
|
public readonly reason: string;
|
||||||
|
|
||||||
|
constructor(data: IKubeStatus) {
|
||||||
|
this.apiVersion = data.apiVersion;
|
||||||
|
this.code = data.code;
|
||||||
|
this.message = data.message || "";
|
||||||
|
this.reason = data.reason || "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export type IKubeMetaField = keyof IKubeObjectMetadata;
|
export type IKubeMetaField = keyof IKubeObjectMetadata;
|
||||||
|
|
||||||
@autobind()
|
@autobind()
|
||||||
@ -99,12 +122,15 @@ export class KubeObject implements ItemObject {
|
|||||||
return this.metadata.namespace || undefined;
|
return this.metadata.namespace || undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo: refactor with named arguments
|
getTimeDiffFromNow(): number {
|
||||||
getAge(humanize = true, compact = true, fromNow = false) {
|
return Date.now() - new Date(this.metadata.creationTimestamp).getTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
getAge(humanize = true, compact = true, fromNow = false): string | number {
|
||||||
if (fromNow) {
|
if (fromNow) {
|
||||||
return moment(this.metadata.creationTimestamp).fromNow();
|
return moment(this.metadata.creationTimestamp).fromNow(); // "string", getTimeDiffFromNow() cannot be used
|
||||||
}
|
}
|
||||||
const diff = new Date().getTime() - new Date(this.metadata.creationTimestamp).getTime();
|
const diff = this.getTimeDiffFromNow();
|
||||||
|
|
||||||
if (humanize) {
|
if (humanize) {
|
||||||
return formatDuration(diff, compact);
|
return formatDuration(diff, compact);
|
||||||
|
|||||||
@ -1,183 +1,131 @@
|
|||||||
// Kubernetes watch-api consumer
|
// Kubernetes watch-api client
|
||||||
|
// API: https://developer.mozilla.org/en-US/docs/Web/API/Streams_API/Using_readable_streams
|
||||||
|
|
||||||
import { computed, observable, reaction } from "mobx";
|
|
||||||
import { stringify } from "querystring";
|
|
||||||
import { autobind, EventEmitter } from "../utils";
|
|
||||||
import { KubeJsonApiData } from "./kube-json-api";
|
|
||||||
import type { KubeObjectStore } from "../kube-object.store";
|
import type { KubeObjectStore } from "../kube-object.store";
|
||||||
import { ensureObjectSelfLink, KubeApi } from "./kube-api";
|
import type { ClusterContext } from "../components/context";
|
||||||
import { apiManager } from "./api-manager";
|
|
||||||
import { apiPrefix, isDevelopment } from "../../common/vars";
|
|
||||||
import { getHostedCluster } from "../../common/cluster-store";
|
|
||||||
|
|
||||||
export interface IKubeWatchEvent<T = any> {
|
import plimit from "p-limit";
|
||||||
type: "ADDED" | "MODIFIED" | "DELETED";
|
import { comparer, IReactionDisposer, observable, reaction, when } from "mobx";
|
||||||
|
import { autobind, noop } from "../utils";
|
||||||
|
import { KubeApi } from "./kube-api";
|
||||||
|
import { KubeJsonApiData } from "./kube-json-api";
|
||||||
|
import { isDebugging, isProduction } from "../../common/vars";
|
||||||
|
|
||||||
|
export interface IKubeWatchEvent<T = KubeJsonApiData> {
|
||||||
|
type: "ADDED" | "MODIFIED" | "DELETED" | "ERROR";
|
||||||
object?: T;
|
object?: T;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IKubeWatchRouteEvent {
|
export interface IKubeWatchSubscribeStoreOptions {
|
||||||
type: "STREAM_END";
|
namespaces?: string[]; // default: all accessible namespaces
|
||||||
url: string;
|
preload?: boolean; // preload store items, default: true
|
||||||
status: number;
|
waitUntilLoaded?: boolean; // subscribe only after loading all stores, default: true
|
||||||
|
loadOnce?: boolean; // check store.isLoaded to skip loading if done already, default: false
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IKubeWatchRouteQuery {
|
export interface IKubeWatchLog {
|
||||||
api: string | string[];
|
message: string | string[] | Error;
|
||||||
|
meta?: object;
|
||||||
|
cssStyle?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@autobind()
|
@autobind()
|
||||||
export class KubeWatchApi {
|
export class KubeWatchApi {
|
||||||
protected evtSource: EventSource;
|
@observable context: ClusterContext = null;
|
||||||
protected onData = new EventEmitter<[IKubeWatchEvent]>();
|
|
||||||
protected subscribers = observable.map<KubeApi, number>();
|
|
||||||
protected reconnectTimeoutMs = 5000;
|
|
||||||
protected maxReconnectsOnError = 10;
|
|
||||||
protected reconnectAttempts = this.maxReconnectsOnError;
|
|
||||||
|
|
||||||
constructor() {
|
contextReady = when(() => Boolean(this.context));
|
||||||
reaction(() => this.activeApis, () => this.connect(), {
|
|
||||||
fireImmediately: true,
|
isAllowedApi(api: KubeApi): boolean {
|
||||||
delay: 500,
|
return Boolean(this.context?.cluster.isAllowedResource(api.kind));
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@computed get activeApis() {
|
preloadStores(stores: KubeObjectStore[], opts: { namespaces?: string[], loadOnce?: boolean } = {}) {
|
||||||
return Array.from(this.subscribers.keys());
|
const limitRequests = plimit(1); // load stores one by one to allow quick skipping when fast clicking btw pages
|
||||||
}
|
const preloading: Promise<any>[] = [];
|
||||||
|
|
||||||
getSubscribersCount(api: KubeApi) {
|
for (const store of stores) {
|
||||||
return this.subscribers.get(api) || 0;
|
preloading.push(limitRequests(async () => {
|
||||||
}
|
if (store.isLoaded && opts.loadOnce) return; // skip
|
||||||
|
|
||||||
subscribe(...apis: KubeApi[]) {
|
return store.loadAll({ namespaces: opts.namespaces });
|
||||||
apis.forEach(api => {
|
}));
|
||||||
this.subscribers.set(api, this.getSubscribersCount(api) + 1);
|
}
|
||||||
});
|
|
||||||
|
|
||||||
return () => apis.forEach(api => {
|
|
||||||
const count = this.getSubscribersCount(api) - 1;
|
|
||||||
|
|
||||||
if (count <= 0) this.subscribers.delete(api);
|
|
||||||
else this.subscribers.set(api, count);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
protected getQuery(): Partial<IKubeWatchRouteQuery> {
|
|
||||||
const { isAdmin, allowedNamespaces } = getHostedCluster();
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
api: this.activeApis.map(api => {
|
loading: Promise.allSettled(preloading),
|
||||||
if (isAdmin) return api.getWatchUrl();
|
cancelLoading: () => limitRequests.clearQueue(),
|
||||||
|
|
||||||
return allowedNamespaces.map(namespace => api.getWatchUrl(namespace));
|
|
||||||
}).flat()
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo: maybe switch to websocket to avoid often reconnects
|
subscribeStores(stores: KubeObjectStore[], opts: IKubeWatchSubscribeStoreOptions = {}): () => void {
|
||||||
@autobind()
|
const { preload = true, waitUntilLoaded = true, loadOnce = false, } = opts;
|
||||||
protected connect() {
|
const subscribingNamespaces = opts.namespaces ?? this.context?.allNamespaces ?? [];
|
||||||
if (this.evtSource) this.disconnect(); // close previous connection
|
const unsubscribeList: Function[] = [];
|
||||||
|
let isUnsubscribed = false;
|
||||||
|
|
||||||
if (!this.activeApis.length) {
|
const load = (namespaces = subscribingNamespaces) => this.preloadStores(stores, { namespaces, loadOnce });
|
||||||
|
let preloading = preload && load();
|
||||||
|
let cancelReloading: IReactionDisposer = noop;
|
||||||
|
|
||||||
|
const subscribe = () => {
|
||||||
|
if (isUnsubscribed) return;
|
||||||
|
|
||||||
|
stores.forEach((store) => {
|
||||||
|
unsubscribeList.push(store.subscribe());
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
if (preloading) {
|
||||||
|
if (waitUntilLoaded) {
|
||||||
|
preloading.loading.then(subscribe, error => {
|
||||||
|
this.log({
|
||||||
|
message: new Error("Loading stores has failed"),
|
||||||
|
meta: { stores, error, options: opts },
|
||||||
|
});
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
subscribe();
|
||||||
|
}
|
||||||
|
|
||||||
|
// reload stores only for context namespaces change
|
||||||
|
cancelReloading = reaction(() => this.context?.contextNamespaces, namespaces => {
|
||||||
|
preloading?.cancelLoading();
|
||||||
|
unsubscribeList.forEach(unsubscribe => unsubscribe());
|
||||||
|
unsubscribeList.length = 0;
|
||||||
|
preloading = load(namespaces);
|
||||||
|
preloading.loading.then(subscribe);
|
||||||
|
}, {
|
||||||
|
equals: comparer.shallow,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// unsubscribe
|
||||||
|
return () => {
|
||||||
|
if (isUnsubscribed) return;
|
||||||
|
isUnsubscribed = true;
|
||||||
|
cancelReloading();
|
||||||
|
preloading?.cancelLoading();
|
||||||
|
unsubscribeList.forEach(unsubscribe => unsubscribe());
|
||||||
|
unsubscribeList.length = 0;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
protected log({ message, cssStyle = "", meta = {} }: IKubeWatchLog) {
|
||||||
|
if (isProduction && !isDebugging) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const query = this.getQuery();
|
|
||||||
const apiUrl = `${apiPrefix}/watch?${stringify(query)}`;
|
|
||||||
|
|
||||||
this.evtSource = new EventSource(apiUrl);
|
const logInfo = [`%c[KUBE-WATCH-API]:`, `font-weight: bold; ${cssStyle}`, message].flat().map(String);
|
||||||
this.evtSource.onmessage = this.onMessage;
|
const logMeta = {
|
||||||
this.evtSource.onerror = this.onError;
|
time: new Date().toLocaleString(),
|
||||||
this.writeLog("CONNECTING", query.api);
|
...meta,
|
||||||
}
|
|
||||||
|
|
||||||
reconnect() {
|
|
||||||
if (!this.evtSource || this.evtSource.readyState !== EventSource.OPEN) {
|
|
||||||
this.reconnectAttempts = this.maxReconnectsOnError;
|
|
||||||
this.connect();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected disconnect() {
|
|
||||||
if (!this.evtSource) return;
|
|
||||||
this.evtSource.close();
|
|
||||||
this.evtSource.onmessage = null;
|
|
||||||
this.evtSource = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected onMessage(evt: MessageEvent) {
|
|
||||||
if (!evt.data) return;
|
|
||||||
const data = JSON.parse(evt.data);
|
|
||||||
|
|
||||||
if ((data as IKubeWatchEvent).object) {
|
|
||||||
this.onData.emit(data);
|
|
||||||
} else {
|
|
||||||
this.onRouteEvent(data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected async onRouteEvent(event: IKubeWatchRouteEvent) {
|
|
||||||
if (event.type === "STREAM_END") {
|
|
||||||
this.disconnect();
|
|
||||||
const { apiBase, namespace } = KubeApi.parseApi(event.url);
|
|
||||||
const api = apiManager.getApi(apiBase);
|
|
||||||
|
|
||||||
if (api) {
|
|
||||||
try {
|
|
||||||
await api.refreshResourceVersion({ namespace });
|
|
||||||
this.reconnect();
|
|
||||||
} catch (error) {
|
|
||||||
console.error("failed to refresh resource version", error);
|
|
||||||
|
|
||||||
if (this.subscribers.size > 0) {
|
|
||||||
setTimeout(() => {
|
|
||||||
this.onRouteEvent(event);
|
|
||||||
}, 1000);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected onError(evt: MessageEvent) {
|
|
||||||
const { reconnectAttempts: attemptsRemain, reconnectTimeoutMs } = this;
|
|
||||||
|
|
||||||
if (evt.eventPhase === EventSource.CLOSED) {
|
|
||||||
if (attemptsRemain > 0) {
|
|
||||||
this.reconnectAttempts--;
|
|
||||||
setTimeout(() => this.connect(), reconnectTimeoutMs);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected writeLog(...data: any[]) {
|
|
||||||
if (isDevelopment) {
|
|
||||||
console.log("%cKUBE-WATCH-API:", `font-weight: bold`, ...data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
addListener(store: KubeObjectStore, callback: (evt: IKubeWatchEvent) => void) {
|
|
||||||
const listener = (evt: IKubeWatchEvent<KubeJsonApiData>) => {
|
|
||||||
const { namespace, resourceVersion } = evt.object.metadata;
|
|
||||||
const api = apiManager.getApiByKind(evt.object.kind, evt.object.apiVersion);
|
|
||||||
|
|
||||||
api.setResourceVersion(namespace, resourceVersion);
|
|
||||||
api.setResourceVersion("", resourceVersion);
|
|
||||||
|
|
||||||
ensureObjectSelfLink(api, evt.object);
|
|
||||||
|
|
||||||
if (store == apiManager.getStore(api)) {
|
|
||||||
callback(evt);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
this.onData.addListener(listener);
|
if (message instanceof Error) {
|
||||||
|
console.error(...logInfo, logMeta);
|
||||||
return () => this.onData.removeListener(listener);
|
} else {
|
||||||
}
|
console.info(...logInfo, logMeta);
|
||||||
|
}
|
||||||
reset() {
|
|
||||||
this.subscribers.clear();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import get from "lodash/get";
|
import get from "lodash/get";
|
||||||
import { KubeObject } from "./kube-object";
|
import { KubeObject } from "./kube-object";
|
||||||
|
|
||||||
interface IToleration {
|
export interface IToleration {
|
||||||
key?: string;
|
key?: string;
|
||||||
operator?: string;
|
operator?: string;
|
||||||
effect?: string;
|
effect?: string;
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user