mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Merge remote-tracking branch 'origin/master' into extension_install_1277
# Conflicts: # src/common/utils/index.ts
This commit is contained in:
commit
de93812ee3
@ -1,5 +1,8 @@
|
||||
module.exports = {
|
||||
ignorePatterns: ["src/extensions/npm/extensions/dist/**/*"],
|
||||
ignorePatterns: [
|
||||
"**/node_modules/**/*",
|
||||
"**/dist/**/*",
|
||||
],
|
||||
overrides: [
|
||||
{
|
||||
files: [
|
||||
|
||||
132
CODE_OF_CONDUCT.md
Normal file
132
CODE_OF_CONDUCT.md
Normal file
@ -0,0 +1,132 @@
|
||||
# Contributor Covenant Code of Conduct
|
||||
|
||||
## Our Pledge
|
||||
|
||||
We as members, contributors, and leaders pledge to make participation in our
|
||||
community a harassment-free experience for everyone, regardless of age, body
|
||||
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
||||
identity and expression, level of experience, education, socio-economic status,
|
||||
nationality, personal appearance, race, religion, or sexual identity
|
||||
and orientation.
|
||||
|
||||
We pledge to act and interact in ways that contribute to an open, welcoming,
|
||||
diverse, inclusive, and healthy community.
|
||||
|
||||
## Our Standards
|
||||
|
||||
Examples of behavior that contributes to a positive environment for our
|
||||
community include:
|
||||
|
||||
* Demonstrating empathy and kindness toward other people
|
||||
* Being respectful of differing opinions, viewpoints, and experiences
|
||||
* Giving and gracefully accepting constructive feedback
|
||||
* Accepting responsibility and apologizing to those affected by our mistakes,
|
||||
and learning from the experience
|
||||
* Focusing on what is best not just for us as individuals, but for the
|
||||
overall community
|
||||
|
||||
Examples of unacceptable behavior include:
|
||||
|
||||
* The use of sexualized language or imagery, and sexual attention or
|
||||
advances of any kind
|
||||
* Trolling, insulting or derogatory comments, and personal or political attacks
|
||||
* Public or private harassment
|
||||
* Publishing others' private information, such as a physical or email
|
||||
address, without their explicit permission
|
||||
* Other conduct which could reasonably be considered inappropriate in a
|
||||
professional setting
|
||||
|
||||
## Enforcement Responsibilities
|
||||
|
||||
Community leaders are responsible for clarifying and enforcing our standards of
|
||||
acceptable behavior and will take appropriate and fair corrective action in
|
||||
response to any behavior that they deem inappropriate, threatening, offensive,
|
||||
or harmful.
|
||||
|
||||
Community leaders have the right and responsibility to remove, edit, or reject
|
||||
comments, commits, code, wiki edits, issues, and other contributions that are
|
||||
not aligned to this Code of Conduct, and will communicate reasons for moderation
|
||||
decisions when appropriate.
|
||||
|
||||
## Scope
|
||||
|
||||
This Code of Conduct applies within all community spaces, and also applies when
|
||||
an individual is officially representing the community in public spaces.
|
||||
Examples of representing our community include using an official e-mail address,
|
||||
posting via an official social media account, or acting as an appointed
|
||||
representative at an online or offline event.
|
||||
|
||||
## Enforcement
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||
reported to the community leaders responsible for enforcement at
|
||||
info@k8slens.dev.
|
||||
All complaints will be reviewed and investigated promptly and fairly.
|
||||
|
||||
All community leaders are obligated to respect the privacy and security of the
|
||||
reporter of any incident.
|
||||
|
||||
## Enforcement Guidelines
|
||||
|
||||
Community leaders will follow these Community Impact Guidelines in determining
|
||||
the consequences for any action they deem in violation of this Code of Conduct:
|
||||
|
||||
### 1. Correction
|
||||
|
||||
**Community Impact**: Use of inappropriate language or other behavior deemed
|
||||
unprofessional or unwelcome in the community.
|
||||
|
||||
**Consequence**: A private, written warning from community leaders, providing
|
||||
clarity around the nature of the violation and an explanation of why the
|
||||
behavior was inappropriate. A public apology may be requested.
|
||||
|
||||
### 2. Warning
|
||||
|
||||
**Community Impact**: A violation through a single incident or series
|
||||
of actions.
|
||||
|
||||
**Consequence**: A warning with consequences for continued behavior. No
|
||||
interaction with the people involved, including unsolicited interaction with
|
||||
those enforcing the Code of Conduct, for a specified period of time. This
|
||||
includes avoiding interactions in community spaces as well as external channels
|
||||
like social media. Violating these terms may lead to a temporary or
|
||||
permanent ban.
|
||||
|
||||
### 3. Temporary Ban
|
||||
|
||||
**Community Impact**: A serious violation of community standards, including
|
||||
sustained inappropriate behavior.
|
||||
|
||||
**Consequence**: A temporary ban from any sort of interaction or public
|
||||
communication with the community for a specified period of time. No public or
|
||||
private interaction with the people involved, including unsolicited interaction
|
||||
with those enforcing the Code of Conduct, is allowed during this period.
|
||||
Violating these terms may lead to a permanent ban.
|
||||
|
||||
### 4. Permanent Ban
|
||||
|
||||
**Community Impact**: Demonstrating a pattern of violation of community
|
||||
standards, including sustained inappropriate behavior, harassment of an
|
||||
individual, or aggression toward or disparagement of classes of individuals.
|
||||
|
||||
**Consequence**: A permanent ban from any sort of public interaction within
|
||||
the community.
|
||||
|
||||
## Attribution
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
||||
version 2.0, available at
|
||||
[https://www.contributor-covenant.org/version/2/0/code_of_conduct.html][v2.0].
|
||||
|
||||
Community Impact Guidelines were inspired by
|
||||
[Mozilla's code of conduct enforcement ladder][Mozilla CoC].
|
||||
|
||||
For answers to common questions about this code of conduct, see the FAQ at
|
||||
[https://www.contributor-covenant.org/faq][FAQ]. Translations are available
|
||||
at [https://www.contributor-covenant.org/translations][translations].
|
||||
|
||||
[homepage]: https://www.contributor-covenant.org
|
||||
[v2.0]: https://www.contributor-covenant.org/version/2/0/code_of_conduct.html
|
||||
[Mozilla CoC]: https://github.com/mozilla/diversity
|
||||
[FAQ]: https://www.contributor-covenant.org/faq
|
||||
[translations]: https://www.contributor-covenant.org/translations
|
||||
3
CONTRIBUTING.md
Normal file
3
CONTRIBUTING.md
Normal file
@ -0,0 +1,3 @@
|
||||
# Contributing to Lens
|
||||
|
||||
See [Contributing to Lens](https://docs.k8slens.dev/latest/contributing/) documentation.
|
||||
4
Makefile
4
Makefile
@ -99,6 +99,10 @@ publish-npm: build-npm
|
||||
npm config set '//registry.npmjs.org/:_authToken' "${NPM_TOKEN}"
|
||||
cd src/extensions/npm/extensions && npm publish --access=public
|
||||
|
||||
.PHONY: docs
|
||||
docs:
|
||||
yarn mkdocs-serve-local
|
||||
|
||||
.PHONY: clean-extensions
|
||||
clean-extensions:
|
||||
ifeq "$(DETECTED_OS)" "Windows"
|
||||
|
||||
45
README.md
45
README.md
@ -1,7 +1,7 @@
|
||||
# Lens | The Kubernetes IDE
|
||||
|
||||
[](https://dev.azure.com/lensapp/lensapp/_build/latest?definitionId=1&branchName=master)
|
||||
[](https://github.com/lensapp/lens/releases)
|
||||
[](https://github.com/lensapp/lens/releases?label=Downloads)
|
||||
[](https://join.slack.com/t/k8slens/shared_invite/enQtOTc5NjAyNjYyOTk4LWU1NDQ0ZGFkOWJkNTRhYTc2YjVmZDdkM2FkNGM5MjhiYTRhMDU2NDQ1MzIyMDA4ZGZlNmExOTc0N2JmY2M3ZGI)
|
||||
|
||||
World’s most popular Kubernetes IDE provides a simplified, consistent entry point for developers, testers, integrators, and DevOps, to ship code faster at scale. Lens is the only IDE you’ll ever need to take control of your Kubernetes clusters. It is a standalone application for MacOS, Windows and Linux operating systems. Lens is an open source project and free!
|
||||
@ -25,49 +25,12 @@ World’s most popular Kubernetes IDE provides a simplified, consistent entry po
|
||||
|
||||
## Installation
|
||||
|
||||
Download a pre-built package from the [releases](https://github.com/lensapp/lens/releases) page. Lens can be also installed via [snapcraft](https://snapcraft.io/kontena-lens) (Linux only).
|
||||
|
||||
Alternatively on Mac:
|
||||
```
|
||||
brew cask install lens
|
||||
```
|
||||
See [Getting Started](https://docs.k8slens.dev/latest/getting-started/) page.
|
||||
|
||||
## Development
|
||||
|
||||
> Prerequisites: Nodejs v12, make, yarn
|
||||
|
||||
* `make dev` - builds and starts the app
|
||||
* `make test` - run tests
|
||||
|
||||
## Development (advanced)
|
||||
|
||||
Allows for faster separate re-runs of some of the more involved processes:
|
||||
|
||||
1. `yarn dev:main` compiles electron's main process app part
|
||||
1. `yarn dev:renderer` compiles electron's renderer app part
|
||||
1. `yarn dev:extension-types` compile declaration types for `@k8slens/extensions`
|
||||
1. `yarn dev-run` runs app in dev-mode and auto-restart when main process file has changed
|
||||
|
||||
## Development (documentation)
|
||||
|
||||
Run a local instance of `mkdocs serve` in a docker container for developing the Lens Documentation.
|
||||
|
||||
> Prerequisites: docker, yarn
|
||||
|
||||
* `yarn mkdocs-serve-local` - local build and serve of mkdocs with auto update enabled
|
||||
|
||||
Go to [localhost:8000](http://127.0.0.1:8000)
|
||||
|
||||
## Developer's ~~RTFM~~ recommended list:
|
||||
|
||||
- [TypeScript](https://www.typescriptlang.org/docs/home.html) (front-end/back-end)
|
||||
- [ReactJS](https://reactjs.org/docs/getting-started.html) (front-end, ui)
|
||||
- [MobX](https://mobx.js.org/) (app-state-management, back-end/front-end)
|
||||
- [ElectronJS](https://www.electronjs.org/docs) (chrome/node)
|
||||
- [NodeJS](https://nodejs.org/dist/latest-v12.x/docs/api/) (api docs)
|
||||
|
||||
|
||||
See [Development](https://docs.k8slens.dev/latest/contributing/development/) page.
|
||||
|
||||
## Contributing
|
||||
|
||||
Bug reports and pull requests are welcome on GitHub at https://github.com/lensapp/lens.
|
||||
See [Contributing](https://docs.k8slens.dev/latest/contributing/) page.
|
||||
|
||||
@ -1,3 +1,40 @@
|
||||
# Development
|
||||
|
||||
TBD
|
||||
Thank you for taking the time to make a contribution to Lens. The following document is a set of guidelines and instructions for contributing to Lens.
|
||||
|
||||
When contributing to this repository, please consider first discussing the change you wish to make by opening an issue.
|
||||
|
||||
## Recommended Reading:
|
||||
|
||||
- [TypeScript](https://www.typescriptlang.org/docs/home.html) (front-end/back-end)
|
||||
- [ReactJS](https://reactjs.org/docs/getting-started.html) (front-end, ui)
|
||||
- [MobX](https://mobx.js.org/) (app-state-management, back-end/front-end)
|
||||
- [ElectronJS](https://www.electronjs.org/docs) (chrome/node)
|
||||
- [NodeJS](https://nodejs.org/dist/latest-v12.x/docs/api/) (api docs)
|
||||
|
||||
## Local Development Environment
|
||||
|
||||
> Prerequisites: Nodejs v12, make, yarn
|
||||
|
||||
* `make dev` - builds and starts the app
|
||||
* `make clean` - cleanup local environment build artifacts
|
||||
|
||||
|
||||
## Github Workflow
|
||||
|
||||
We Use [Github Flow](https://guides.github.com/introduction/flow/index.html), so all code changes are tracked via Pull Requests.
|
||||
A detailed guide on the recommended workflow can be found below:
|
||||
|
||||
* [Github Workflow](./github_workflow.md)
|
||||
|
||||
## Code Testing
|
||||
|
||||
All submitted PRs go through a set of tests and reviews. You can run most of these tests *before* a PR is submitted.
|
||||
In fact, we recommend it, because it will save on many possible review iterations and automated tests.
|
||||
The testing guidelines can be found here:
|
||||
|
||||
* [Contributor's Guide to Testing](./testing.md)
|
||||
|
||||
## License
|
||||
|
||||
By contributing, you agree that your contributions will be licensed as described in [LICENSE](https://github.com/lensapp/lens/blob/master/LICENSE).
|
||||
|
||||
@ -20,3 +20,14 @@ When you create a new pull request, we expect some requirements to be met.
|
||||
* When updating documentation, add `Update Documentation:` before the title. E.g. `Update Documentation: Getting Started`
|
||||
* If your Pull Request closes an issue, you must write `Closes #ISSUE_NUMBER` where the ISSUE_NUMBER is the number in the end of the link url or the relevent issue. This will link your pull request to the issue, and when it is merged, the issue will close.
|
||||
* For each pull request made, we run tests to check if there are any broken links, the markdown formatting is valid, and the linter is passing.
|
||||
|
||||
|
||||
## Testing Documentation Site Locally
|
||||
|
||||
Run a local instance of `mkdocs` in a docker container for developing the Lens Documentation.
|
||||
|
||||
> Prerequisites: docker, yarn
|
||||
|
||||
* `make docs` - local build and serve of mkdocs with auto update enabled
|
||||
|
||||
Go to [localhost:8000](http://127.0.0.1:8000).
|
||||
|
||||
148
docs/contributing/github_workflow.md
Normal file
148
docs/contributing/github_workflow.md
Normal file
@ -0,0 +1,148 @@
|
||||
# Github Workflow
|
||||
|
||||
<!-- TOC -->
|
||||
- [Fork The Project](#fork-the-project)
|
||||
- [Adding the Forked Remote](#adding-the-forked-remote)
|
||||
- [Create & Rebase Your Feature Branch](#create--rebase-your-feature-branch)
|
||||
- [Commit & Push](#commit--push)
|
||||
- [Open a Pull Request](#open-a-pull-request)
|
||||
- [Get a code review](#get-a-code-review)
|
||||
- [Squash commits](#squash-commits)
|
||||
- [Push Your Final Changes](#push-your-final-changes)
|
||||
|
||||
<!-- /TOC -->
|
||||
This guide assumes you have already cloned the upstream repo to your system via git clone.
|
||||
|
||||
## Fork The Project
|
||||
|
||||
1. Go to [http://github.com/lensapp/lens](http://github.com/lensapp/lens)
|
||||
2. On the top, right-hand side, click on "fork" and select your username for the fork destination.
|
||||
|
||||
## Adding the Forked Remote
|
||||
|
||||
```
|
||||
export GITHUB_USER={ your github's username }
|
||||
|
||||
cd $WORKDIR/lens
|
||||
git remote add $GITHUB_USER git@github.com:${GITHUB_USER}/lens.git
|
||||
|
||||
# Prevent push to Upstream
|
||||
git remote set-url --push origin no_push
|
||||
|
||||
# Set your fork remote as a default push target
|
||||
git push --set-upstream $GITHUB_USER master
|
||||
```
|
||||
|
||||
Your remotes should look something like this:
|
||||
|
||||
```
|
||||
➜ git remote -v
|
||||
origin https://github.com/lensapp/lens (fetch)
|
||||
origin no_push (push)
|
||||
my_fork git@github.com:{ github_username }/lens.git (fetch)
|
||||
my_fork git@github.com:{ github_username }/lens.git (push)
|
||||
```
|
||||
|
||||
## Create & Rebase Your Feature Branch
|
||||
|
||||
Create a feature branch:
|
||||
|
||||
```
|
||||
git branch -b my_feature_branch
|
||||
```
|
||||
|
||||
Rebase your branch:
|
||||
|
||||
```
|
||||
git fetch origin
|
||||
|
||||
git rebase origin/master
|
||||
Current branch my_feature_branch is up to date.
|
||||
```
|
||||
|
||||
Please don't use `git pull` instead of the above `fetch / rebase`. `git pull` does a merge, which leaves merge commits. These make the commit history messy and violate the principle that commits ought to be individually understandable and useful.
|
||||
|
||||
## Commit & Push
|
||||
|
||||
Commit and sign your changes:
|
||||
|
||||
```
|
||||
git commit -m "my commit title" --signoff
|
||||
```
|
||||
|
||||
You can go back and edit/build/test some more, then `commit --amend` in a few cycles.
|
||||
|
||||
When ready, push your changes to your fork's repository:
|
||||
|
||||
```
|
||||
git push --set-upstream my_fork my_feature_branch
|
||||
```
|
||||
|
||||
## Open a Pull Request
|
||||
|
||||
See [Github Docs](https://docs.github.com/en/free-pro-team@latest/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request-from-a-fork).
|
||||
|
||||
### Get a code review
|
||||
|
||||
Once your pull request has been opened it will be assigned to one or more reviewers, and will go through a series of smoke tests.
|
||||
|
||||
Commit changes made in response to review comments should be added to the same branch on your fork.
|
||||
|
||||
Very small PRs are easy to review. Very large PRs are very difficult to review.
|
||||
|
||||
### Squashing Commits
|
||||
Commits on your branch should represent meaningful milestones or units of work.
|
||||
Small commits that contain typo fixes, rebases, review feedbacks, etc should be squashed.
|
||||
|
||||
To do that, it's best to perform an [interactive rebase](https://git-scm.com/book/en/v2/Git-Tools-Rewriting-History):
|
||||
|
||||
#### Example
|
||||
If you PR has 3 commits, count backwards from your last commit using `HEAD~3`:
|
||||
```
|
||||
git rebase -i HEAD~3
|
||||
```
|
||||
Output would be similar to this:
|
||||
```
|
||||
pick f7f3f6d Changed some code
|
||||
pick 310154e fixed some typos
|
||||
pick a5f4a0d made some review changes
|
||||
|
||||
# Rebase 710f0f8..a5f4a0d onto 710f0f8
|
||||
#
|
||||
# Commands:
|
||||
# p, pick <commit> = use commit
|
||||
# r, reword <commit> = use commit, but edit the commit message
|
||||
# e, edit <commit> = use commit, but stop for amending
|
||||
# s, squash <commit> = use commit, but meld into previous commit
|
||||
# f, fixup <commit> = like "squash", but discard this commit's log message
|
||||
# x, exec <command> = run command (the rest of the line) using shell
|
||||
# b, break = stop here (continue rebase later with 'git rebase --continue')
|
||||
# d, drop <commit> = remove commit
|
||||
# l, label <label> = label current HEAD with a name
|
||||
# t, reset <label> = reset HEAD to a label
|
||||
# m, merge [-C <commit> | -c <commit>] <label> [# <oneline>]
|
||||
# . create a merge commit using the original merge commit's
|
||||
# . message (or the oneline, if no original merge commit was
|
||||
# . specified). Use -c <commit> to reword the commit message.
|
||||
#
|
||||
# These lines can be re-ordered; they are executed from top to bottom.
|
||||
#
|
||||
# However, if you remove everything, the rebase will be aborted.
|
||||
#
|
||||
# Note that empty commits are commented out
|
||||
```
|
||||
Use a command line text editor to change the word `pick` to `fixup` for the commits you want to squash, then save your changes and continue the rebase:
|
||||
|
||||
Per the output above, you can see that:
|
||||
```
|
||||
fixup <commit> = like "squash", but discard this commit's log message
|
||||
```
|
||||
Which means that when rebased, the commit message "fixed some typos" will be removed, and squashed with the parent commit.
|
||||
|
||||
### Push Your Final Changes
|
||||
|
||||
Once done, you can push the final commits to your branch:
|
||||
```
|
||||
git push --force
|
||||
```
|
||||
You can run multiple iteration of `rebase`/`push -f`, if needed.
|
||||
45
docs/contributing/testing.md
Normal file
45
docs/contributing/testing.md
Normal file
@ -0,0 +1,45 @@
|
||||
## Testing Your Code
|
||||
|
||||
Lens uses github actions to run automated tests on any PR, before merging.
|
||||
However, a PR will not be reviewed before all tests are green, so to save time and prevent your PR from going stale, it is best to test it before submitting the PR.
|
||||
|
||||
### Run Local Verifications
|
||||
|
||||
Please run the following style and formatting commands and fix/check-in any changes:
|
||||
|
||||
#### 1. Linting
|
||||
|
||||
We use [ESLing](https://eslint.org/) for style verification.
|
||||
In the repository's root directory, simply run:
|
||||
|
||||
```
|
||||
make lint
|
||||
```
|
||||
|
||||
#### 3. Pre-submit Flight Checks
|
||||
|
||||
In the repository root directory, make sure that:
|
||||
|
||||
* `make build` runs successfully.
|
||||
* `make test` runs successfully.
|
||||
* `make integration` runs successfully (some tests require minikube running).
|
||||
|
||||
Please note that this last test is prone to "flakiness", so it might fail on occasion. If it fails constantly, take a deeper look at your code to find the source of the problem.
|
||||
|
||||
If you find that all tests passed, you may open a pull request upstream.
|
||||
|
||||
### Opening A Pull Request
|
||||
|
||||
#### Draft Mode
|
||||
|
||||
You may open a pull request in [draft mode](https://github.blog/2019-02-14-introducing-draft-pull-requests).
|
||||
All automated tests will still run against the PR, but the PR will not be assigned for review.
|
||||
Once a PR is ready for review, transition it from Draft mode, and code owners will be notified.
|
||||
|
||||
#### Pre-Requisites for PR Merge
|
||||
|
||||
In order for a PR to be merged, the following conditions should exist:
|
||||
1. The PR has passed all the automated tests (style, build & conformance tests).
|
||||
2. PR commits have been signed with the `--signoff` option.
|
||||
3. PR was reviewed and approved by a code owner.
|
||||
4. PR is rebased against upstream's master branch.
|
||||
13
docs/support/README.md
Normal file
13
docs/support/README.md
Normal file
@ -0,0 +1,13 @@
|
||||
# Welcome to Lens support
|
||||
Here you will find different ways of getting support for Lens.
|
||||
|
||||
## Community Slack Channel
|
||||
We have an active and growing community! Ask a question, see what's being discussed, get insights to up and coming features, help others, join the conversation on our community slack <a href="https://join.slack.com/t/k8slens/shared_invite/enQtOTc5NjAyNjYyOTk4LWU1NDQ0ZGFkOWJkNTRhYTc2YjVmZDdkM2FkNGM5MjhiYTRhMDU2NDQ1MzIyMDA4ZGZlNmExOTc0N2JmY2M3ZGI" target="_blank">here</a>
|
||||
|
||||
## Open Source Github Repository
|
||||
Search feature requests, submit an idea, review existing issues, or open a new one at our Github repository <a href="https://github.com/lensapp/lens/issues" target="_blank">here</a>
|
||||
|
||||
## Enterprise Support
|
||||
If you are interested in paid support options designed for enterprises to cover Lens usage at scale please see the following links:
|
||||
|
||||
- <a href="https://www.mirantis.com/support/enterprise-support-services" target="_blank">Mirantis</a>
|
||||
@ -11,7 +11,7 @@ export class ExamplePage extends React.Component<{ extension: LensRendererExtens
|
||||
deactivate = () => {
|
||||
const { extension } = this.props;
|
||||
extension.disable();
|
||||
}
|
||||
};
|
||||
|
||||
render() {
|
||||
const doodleStyle = {
|
||||
|
||||
@ -12,7 +12,7 @@ export default class ExampleExtension extends LensRendererExtension {
|
||||
Page: () => <ExamplePage extension={this}/>,
|
||||
}
|
||||
}
|
||||
]
|
||||
];
|
||||
|
||||
clusterPageMenus = [
|
||||
{
|
||||
@ -22,5 +22,5 @@ export default class ExampleExtension extends LensRendererExtension {
|
||||
Icon: ExampleIcon,
|
||||
}
|
||||
}
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
@ -38,5 +38,5 @@ export default class EventResourceStatusRendererExtension extends LensRendererEx
|
||||
apiVersions: ["batch/v1"],
|
||||
resolve: (cronJob: K8sApi.CronJob) => resolveStatusForCronJobs(cronJob)
|
||||
},
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
@ -9,5 +9,5 @@ export default class LicenseLensMainExtension extends LensMainExtension {
|
||||
Util.openExternal("https://k8slens.dev/licenses/eula.md");
|
||||
}
|
||||
}
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
@ -19,5 +19,5 @@ export default class ClusterMetricsFeatureExtension extends LensRendererExtensio
|
||||
},
|
||||
feature: new MetricsFeature()
|
||||
}
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
@ -25,8 +25,8 @@ export interface MetricsConfiguration {
|
||||
}
|
||||
|
||||
export class MetricsFeature extends ClusterFeature.Feature {
|
||||
name = "metrics"
|
||||
latestVersion = "v2.17.2-lens1"
|
||||
name = "metrics";
|
||||
latestVersion = "v2.17.2-lens1";
|
||||
|
||||
config: MetricsConfiguration = {
|
||||
persistence: {
|
||||
|
||||
@ -11,5 +11,5 @@ export default class NodeMenuRendererExtension extends LensRendererExtension {
|
||||
MenuItem: (props: NodeMenuProps) => <NodeMenu {...props} />
|
||||
}
|
||||
}
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
@ -19,5 +19,5 @@ export default class PodMenuRendererExtension extends LensRendererExtension {
|
||||
MenuItem: (props: PodLogsMenuProps) => <PodLogsMenu {...props} />
|
||||
}
|
||||
}
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
@ -1,13 +0,0 @@
|
||||
import { LensMainExtension } from "@k8slens/extensions";
|
||||
|
||||
export default class SupportPageMainExtension extends LensMainExtension {
|
||||
appMenus = [
|
||||
{
|
||||
parentId: "help",
|
||||
label: "Support",
|
||||
click: () => {
|
||||
this.navigate();
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
8520
extensions/support-page/package-lock.json
generated
8520
extensions/support-page/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -1,29 +0,0 @@
|
||||
{
|
||||
"name": "lens-support-page",
|
||||
"version": "0.1.0",
|
||||
"description": "Lens support page",
|
||||
"main": "dist/main.js",
|
||||
"renderer": "dist/renderer.js",
|
||||
"scripts": {
|
||||
"build": "webpack -p",
|
||||
"dev": "webpack --watch",
|
||||
"test": "jest --passWithNoTests --env=jsdom src $@"
|
||||
},
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"@k8slens/extensions": "file:../../src/extensions/npm/extensions",
|
||||
"@types/react": "^16.9.53",
|
||||
"@types/react-router": "^5.1.8",
|
||||
"@types/webpack": "^4.41.17",
|
||||
"css-loader": "^5.0.0",
|
||||
"jest": "^26.6.3",
|
||||
"mobx": "^5.15.5",
|
||||
"react": "^16.13.1",
|
||||
"sass-loader": "^10.0.4",
|
||||
"style-loader": "^2.0.0",
|
||||
"ts-loader": "^8.0.4",
|
||||
"ts-node": "^9.0.0",
|
||||
"typescript": "^4.0.3",
|
||||
"webpack": "^4.44.2"
|
||||
}
|
||||
}
|
||||
@ -1,23 +0,0 @@
|
||||
import React from "react";
|
||||
import { Component, Interface, LensRendererExtension } from "@k8slens/extensions";
|
||||
import { SupportPage } from "./src/support";
|
||||
|
||||
export default class SupportPageRendererExtension extends LensRendererExtension {
|
||||
globalPages: Interface.PageRegistration[] = [
|
||||
{
|
||||
components: {
|
||||
Page: SupportPage,
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
statusBarItems: Interface.StatusBarRegistration[] = [
|
||||
{
|
||||
item: (
|
||||
<div className="SupportPageIcon flex align-center" onClick={() => this.navigate()}>
|
||||
<Component.Icon interactive material="help" smallest/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -1,19 +0,0 @@
|
||||
.SupportPage {
|
||||
a[target=_blank] {
|
||||
text-decoration: none;
|
||||
border-bottom: 1px solid;
|
||||
|
||||
&:after {
|
||||
content: "launch";
|
||||
font: small "Material Icons";
|
||||
vertical-align: middle;
|
||||
margin-left: 2px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.SupportPageIcon {
|
||||
color: white;
|
||||
font-size: var(--font-size-small);
|
||||
padding-right: calc(var(--padding) / 2);
|
||||
}
|
||||
@ -1,29 +0,0 @@
|
||||
// TODO: support localization / figure out how to extract / consume i18n strings
|
||||
|
||||
import "./support.scss";
|
||||
import React from "react";
|
||||
import { observer } from "mobx-react";
|
||||
import { App, Component } from "@k8slens/extensions";
|
||||
|
||||
@observer
|
||||
export class SupportPage extends React.Component {
|
||||
render() {
|
||||
const { PageLayout } = Component;
|
||||
const { slackUrl, issuesTrackerUrl } = App;
|
||||
return (
|
||||
<PageLayout showOnTop className="SupportPage" header={<h2>Support</h2>}>
|
||||
<h2>Community Slack Channel</h2>
|
||||
<p>
|
||||
Ask a question, see what's being discussed, join the conversation <a href={slackUrl} target="_blank">here</a>
|
||||
</p>
|
||||
|
||||
<h2>Report an Issue</h2>
|
||||
<p>
|
||||
Review existing issues or open a new one <a href={issuesTrackerUrl} target="_blank">here</a>
|
||||
</p>
|
||||
|
||||
{/*<h2><Trans>Commercial Support</Trans></h2>*/}
|
||||
</PageLayout>
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -1,29 +0,0 @@
|
||||
{
|
||||
"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.tsx",
|
||||
"src/**/*"
|
||||
]
|
||||
}
|
||||
@ -1,75 +0,0 @@
|
||||
import path from "path";
|
||||
|
||||
const outputPath = path.resolve(__dirname, 'dist');
|
||||
|
||||
const lensExternals = {
|
||||
"@k8slens/extensions": "var global.LensExtensions",
|
||||
"react": "var global.React",
|
||||
"mobx": "var global.Mobx",
|
||||
"mobx-react": "var global.MobxReact",
|
||||
};
|
||||
|
||||
export default [
|
||||
{
|
||||
entry: './main.ts',
|
||||
context: __dirname,
|
||||
target: "electron-main",
|
||||
mode: "production",
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.tsx?$/,
|
||||
use: 'ts-loader',
|
||||
exclude: /node_modules/,
|
||||
},
|
||||
],
|
||||
},
|
||||
externals: [
|
||||
lensExternals,
|
||||
],
|
||||
resolve: {
|
||||
extensions: ['.tsx', '.ts', '.js'],
|
||||
},
|
||||
output: {
|
||||
libraryTarget: "commonjs2",
|
||||
globalObject: "this",
|
||||
filename: 'main.js',
|
||||
path: outputPath,
|
||||
},
|
||||
},
|
||||
{
|
||||
entry: './renderer.tsx',
|
||||
context: __dirname,
|
||||
target: "electron-renderer",
|
||||
mode: "production",
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.tsx?$/,
|
||||
use: 'ts-loader',
|
||||
exclude: /node_modules/,
|
||||
},
|
||||
{
|
||||
test: /\.s?css$/,
|
||||
use: [
|
||||
"style-loader",
|
||||
"css-loader",
|
||||
"sass-loader",
|
||||
]
|
||||
}
|
||||
],
|
||||
},
|
||||
externals: [
|
||||
lensExternals,
|
||||
],
|
||||
resolve: {
|
||||
extensions: ['.tsx', '.ts', '.js'],
|
||||
},
|
||||
output: {
|
||||
libraryTarget: "commonjs2",
|
||||
globalObject: "this",
|
||||
filename: 'renderer.js',
|
||||
path: outputPath,
|
||||
},
|
||||
},
|
||||
];
|
||||
@ -8,6 +8,7 @@ export default class TelemetryMainExtension extends LensMainExtension {
|
||||
console.log("telemetry main extension activated");
|
||||
tracker.start();
|
||||
tracker.reportPeriodically();
|
||||
tracker.watchExtensions();
|
||||
await telemetryPreferencesStore.loadExtension(this);
|
||||
}
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@ import { toJS } from "mobx";
|
||||
|
||||
export type TelemetryPreferencesModel = {
|
||||
enabled: boolean;
|
||||
}
|
||||
};
|
||||
|
||||
export class TelemetryPreferencesStore extends Store.ExtensionStore<TelemetryPreferencesModel> {
|
||||
enabled = true;
|
||||
|
||||
@ -3,23 +3,26 @@ import ua from "universal-analytics";
|
||||
import Analytics from "analytics-node";
|
||||
import { machineIdSync } from "node-machine-id";
|
||||
import { telemetryPreferencesStore } from "./telemetry-preferences-store";
|
||||
import { reaction, IReactionDisposer } from "mobx";
|
||||
import { comparer } from "mobx";
|
||||
|
||||
export class Tracker extends Util.Singleton {
|
||||
static readonly GA_ID = "UA-159377374-1"
|
||||
static readonly SEGMENT_KEY = "YENwswyhlOgz8P7EFKUtIZ2MfON7Yxqb"
|
||||
protected eventHandlers: Array<(ev: EventBus.AppEvent ) => void> = []
|
||||
protected started = false
|
||||
protected visitor: ua.Visitor
|
||||
protected analytics: Analytics
|
||||
static readonly GA_ID = "UA-159377374-1";
|
||||
static readonly SEGMENT_KEY = "YENwswyhlOgz8P7EFKUtIZ2MfON7Yxqb";
|
||||
protected eventHandlers: Array<(ev: EventBus.AppEvent ) => void> = [];
|
||||
protected started = false;
|
||||
protected visitor: ua.Visitor;
|
||||
protected analytics: Analytics;
|
||||
protected machineId: string = null;
|
||||
protected ip: string = null;
|
||||
protected appVersion: string;
|
||||
protected locale: string;
|
||||
protected userAgent: string;
|
||||
protected anonymousId: string;
|
||||
protected os: string
|
||||
protected os: string;
|
||||
protected disposers: IReactionDisposer[];
|
||||
|
||||
protected reportInterval: NodeJS.Timeout
|
||||
protected reportInterval: NodeJS.Timeout;
|
||||
|
||||
private constructor() {
|
||||
super();
|
||||
@ -35,6 +38,7 @@ export class Tracker extends Util.Singleton {
|
||||
this.analytics = new Analytics(Tracker.SEGMENT_KEY, { flushAt: 1 });
|
||||
this.visitor.set("dl", "https://telemetry.k8slens.dev");
|
||||
this.visitor.set("ua", this.userAgent);
|
||||
this.disposers = [];
|
||||
}
|
||||
|
||||
start() {
|
||||
@ -49,6 +53,21 @@ export class Tracker extends Util.Singleton {
|
||||
EventBus.appEventBus.addListener(handler);
|
||||
}
|
||||
|
||||
watchExtensions() {
|
||||
let previousExtensions = App.getEnabledExtensions();
|
||||
this.disposers.push(reaction(() => App.getEnabledExtensions(), (currentExtensions) => {
|
||||
const removedExtensions = previousExtensions.filter(x => !currentExtensions.includes(x));
|
||||
removedExtensions.forEach(ext => {
|
||||
this.event("extension", "disable", { extension: ext });
|
||||
});
|
||||
const newExtensions = currentExtensions.filter(x => !previousExtensions.includes(x));
|
||||
newExtensions.forEach(ext => {
|
||||
this.event("extension", "enable", { extension: ext });
|
||||
});
|
||||
previousExtensions = currentExtensions;
|
||||
}, { equals: comparer.structural }));
|
||||
}
|
||||
|
||||
reportPeriodically() {
|
||||
this.reportInterval = setInterval(() => {
|
||||
this.reportData();
|
||||
@ -66,6 +85,9 @@ export class Tracker extends Util.Singleton {
|
||||
if (this.reportInterval) {
|
||||
clearInterval(this.reportInterval);
|
||||
}
|
||||
this.disposers.forEach(disposer => {
|
||||
disposer();
|
||||
});
|
||||
}
|
||||
|
||||
protected async isTelemetryAllowed(): Promise<boolean> {
|
||||
@ -79,7 +101,8 @@ export class Tracker extends Util.Singleton {
|
||||
appVersion: App.version,
|
||||
os: this.os,
|
||||
clustersCount: clustersList.length,
|
||||
workspacesCount: Store.workspaceStore.enabledWorkspacesList.length
|
||||
workspacesCount: Store.workspaceStore.enabledWorkspacesList.length,
|
||||
extensions: App.getEnabledExtensions()
|
||||
});
|
||||
|
||||
clustersList.forEach((cluster) => {
|
||||
|
||||
@ -35,6 +35,29 @@ describe("Lens integration tests", () => {
|
||||
await app.client.waitUntilTextExists("h1", "Welcome");
|
||||
};
|
||||
|
||||
const minikubeReady = (): boolean => {
|
||||
// determine if minikube is running
|
||||
let status = spawnSync("minikube status", { shell: true });
|
||||
if (status.status !== 0) {
|
||||
console.warn("minikube not running");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Remove TEST_NAMESPACE if it already exists
|
||||
status = spawnSync(`minikube kubectl -- get namespace ${TEST_NAMESPACE}`, { shell: true });
|
||||
if (status.status === 0) {
|
||||
console.warn(`Removing existing ${TEST_NAMESPACE} namespace`);
|
||||
status = spawnSync(`minikube kubectl -- delete namespace ${TEST_NAMESPACE}`, { shell: true });
|
||||
if (status.status !== 0) {
|
||||
console.warn(`Error removing ${TEST_NAMESPACE} namespace: ${status.stderr.toString()}`);
|
||||
return false;
|
||||
}
|
||||
console.log(status.stdout.toString());
|
||||
}
|
||||
return true;
|
||||
};
|
||||
const ready = minikubeReady();
|
||||
|
||||
describe("app start", () => {
|
||||
beforeAll(appStart, 20000);
|
||||
|
||||
@ -61,7 +84,7 @@ describe("Lens integration tests", () => {
|
||||
});
|
||||
|
||||
it('ensures helm repos', async () => {
|
||||
await app.client.waitUntilTextExists("div.repos #message-stable", "stable"); // wait for the helm-cli to fetch the stable repo
|
||||
await app.client.waitUntilTextExists("div.repos #message-bitnami", "bitnami"); // wait for the helm-cli to fetch the bitnami repo
|
||||
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)
|
||||
});
|
||||
@ -73,28 +96,48 @@ describe("Lens integration tests", () => {
|
||||
});
|
||||
});
|
||||
|
||||
const minikubeReady = (): boolean => {
|
||||
// determine if minikube is running
|
||||
let status = spawnSync("minikube status", { shell: true });
|
||||
if (status.status !== 0) {
|
||||
console.warn("minikube not running");
|
||||
return false;
|
||||
}
|
||||
describeif(ready)("workspaces", () => {
|
||||
beforeAll(appStart, 20000);
|
||||
|
||||
// Remove TEST_NAMESPACE if it already exists
|
||||
status = spawnSync(`minikube kubectl -- get namespace ${TEST_NAMESPACE}`, { shell: true });
|
||||
if (status.status === 0) {
|
||||
console.warn(`Removing existing ${TEST_NAMESPACE} namespace`);
|
||||
status = spawnSync(`minikube kubectl -- delete namespace ${TEST_NAMESPACE}`, { shell: true });
|
||||
if (status.status !== 0) {
|
||||
console.warn(`Error removing ${TEST_NAMESPACE} namespace: ${status.stderr.toString()}`);
|
||||
return false;
|
||||
afterAll(async () => {
|
||||
if (app && app.isRunning()) {
|
||||
return util.tearDown(app);
|
||||
}
|
||||
console.log(status.stdout.toString());
|
||||
}
|
||||
return true;
|
||||
};
|
||||
const ready = minikubeReady();
|
||||
});
|
||||
|
||||
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.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.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");
|
||||
|
||||
@ -42,7 +42,7 @@ nav:
|
||||
- Documentation: contributing/documentation.md
|
||||
- Maintainers: contributing/maintainers.md
|
||||
- Promotion: contributing/promotion.md
|
||||
|
||||
- Support: support/README.md
|
||||
- FAQ: faq/README.md
|
||||
theme:
|
||||
name: 'material'
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
"name": "kontena-lens",
|
||||
"productName": "Lens",
|
||||
"description": "Lens - The Kubernetes IDE",
|
||||
"version": "4.0.0-beta.3",
|
||||
"version": "4.0.0-beta.4",
|
||||
"main": "static/build/main.js",
|
||||
"copyright": "© 2020, Mirantis, Inc.",
|
||||
"license": "MIT",
|
||||
@ -37,7 +37,7 @@
|
||||
"download:kubectl": "yarn run ts-node build/download_kubectl.ts",
|
||||
"download:helm": "yarn run ts-node build/download_helm.ts",
|
||||
"build:tray-icons": "yarn run ts-node build/build_tray_icon.ts",
|
||||
"lint": "yarn run eslint $@ --ext js,ts,tsx --max-warnings=0 src/ integration/ __mocks__/ build/",
|
||||
"lint": "yarn run eslint $@ --ext js,ts,tsx --max-warnings=0 src/ integration/ __mocks__/ build/ extensions/",
|
||||
"lint:fix": "yarn run lint --fix",
|
||||
"mkdocs-serve-local": "docker build -t mkdocs-serve-local:latest mkdocs/ && docker run --rm -it -p 8000:8000 -v ${PWD}:/docs mkdocs-serve-local:latest",
|
||||
"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"
|
||||
@ -194,7 +194,6 @@
|
||||
"node-menu",
|
||||
"metrics-cluster-feature",
|
||||
"license-menu-item",
|
||||
"support-page",
|
||||
"kube-object-event-status"
|
||||
]
|
||||
},
|
||||
|
||||
@ -65,6 +65,7 @@ describe("empty config", () => {
|
||||
it("sets active cluster", () => {
|
||||
clusterStore.setActive("foo");
|
||||
expect(clusterStore.active.id).toBe("foo");
|
||||
expect(workspaceStore.currentWorkspace.lastActiveClusterId).toBe("foo");
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import type { WorkspaceId } from "./workspace-store";
|
||||
import { workspaceStore } from "./workspace-store";
|
||||
import path from "path";
|
||||
import { app, ipcRenderer, remote, webFrame } from "electron";
|
||||
import { unlink } from "fs-extra";
|
||||
@ -11,9 +11,10 @@ import { appEventBus } from "./event-bus";
|
||||
import { dumpConfigYaml } from "./kube-helpers";
|
||||
import { saveToAppFiles } from "./utils/saveToAppFiles";
|
||||
import { KubeConfig } from "@kubernetes/client-node";
|
||||
import { subscribeToBroadcast, unsubscribeAllFromBroadcast } from "./ipc";
|
||||
import _ from "lodash";
|
||||
import move from "array-move";
|
||||
import { subscribeToBroadcast, unsubscribeAllFromBroadcast } from "./ipc";
|
||||
import type { WorkspaceId } from "./workspace-store";
|
||||
|
||||
export interface ClusterIconUpload {
|
||||
clusterId: string;
|
||||
@ -142,7 +143,9 @@ export class ClusterStore extends BaseStore<ClusterStoreModel> {
|
||||
|
||||
@action
|
||||
setActive(id: ClusterId) {
|
||||
this.activeCluster = this.clusters.has(id) ? id : null;
|
||||
const clusterId = this.clusters.has(id) ? id : null;
|
||||
this.activeCluster = clusterId;
|
||||
workspaceStore.setLastActiveClusterId(clusterId);
|
||||
}
|
||||
|
||||
@action
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
// Common utils (main OR renderer)
|
||||
|
||||
export const noop: any = () => { /* empty */ };
|
||||
|
||||
export * from "./app-version";
|
||||
export * from "./autobind";
|
||||
export * from "./base64";
|
||||
@ -12,4 +14,5 @@ export * from "./splitArray";
|
||||
export * from "./saveToAppFiles";
|
||||
export * from "./singleton";
|
||||
export * from "./openExternal";
|
||||
export * from "./rectify-array";
|
||||
export * from "./downloadFile";
|
||||
|
||||
8
src/common/utils/rectify-array.ts
Normal file
8
src/common/utils/rectify-array.ts
Normal file
@ -0,0 +1,8 @@
|
||||
/**
|
||||
* rectify condences the single item or array of T type, to an array.
|
||||
* @param items either one item or an array of items
|
||||
* @returns a list of items
|
||||
*/
|
||||
export function recitfy<T>(items: T | T[]): T[] {
|
||||
return Array.isArray(items) ? items : [items];
|
||||
}
|
||||
@ -5,12 +5,13 @@ import { clusterStore } from "./cluster-store";
|
||||
import { appEventBus } from "./event-bus";
|
||||
import { broadcastMessage } from "../common/ipc";
|
||||
import logger from "../main/logger";
|
||||
import type { ClusterId } from "./cluster-store";
|
||||
|
||||
export type WorkspaceId = string;
|
||||
|
||||
export interface WorkspaceStoreModel {
|
||||
workspaces: WorkspaceModel[];
|
||||
currentWorkspace?: WorkspaceId;
|
||||
workspaces: WorkspaceModel[]
|
||||
}
|
||||
|
||||
export interface WorkspaceModel {
|
||||
@ -18,6 +19,7 @@ export interface WorkspaceModel {
|
||||
name: string;
|
||||
description?: string;
|
||||
ownerRef?: string;
|
||||
lastActiveClusterId?: ClusterId;
|
||||
}
|
||||
|
||||
export interface WorkspaceState {
|
||||
@ -30,6 +32,7 @@ export class Workspace implements WorkspaceModel, WorkspaceState {
|
||||
@observable description?: string;
|
||||
@observable ownerRef?: string;
|
||||
@observable enabled: boolean;
|
||||
@observable lastActiveClusterId?: ClusterId;
|
||||
|
||||
constructor(data: WorkspaceModel) {
|
||||
Object.assign(this, data);
|
||||
@ -66,7 +69,8 @@ export class Workspace implements WorkspaceModel, WorkspaceState {
|
||||
id: this.id,
|
||||
name: this.name,
|
||||
description: this.description,
|
||||
ownerRef: this.ownerRef
|
||||
ownerRef: this.ownerRef,
|
||||
lastActiveClusterId: this.lastActiveClusterId
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -138,13 +142,12 @@ export class WorkspaceStore extends BaseStore<WorkspaceStoreModel> {
|
||||
}
|
||||
|
||||
@action
|
||||
setActive(id = WorkspaceStore.defaultId, reset = true) {
|
||||
setActive(id = WorkspaceStore.defaultId) {
|
||||
if (id === this.currentWorkspaceId) return;
|
||||
if (!this.getById(id)) {
|
||||
throw new Error(`workspace ${id} doesn't exist`);
|
||||
}
|
||||
this.currentWorkspaceId = id;
|
||||
clusterStore.activeCluster = null; // fixme: handle previously selected cluster from current workspace
|
||||
}
|
||||
|
||||
@action
|
||||
@ -184,6 +187,11 @@ export class WorkspaceStore extends BaseStore<WorkspaceStoreModel> {
|
||||
clusterStore.removeByWorkspaceId(id);
|
||||
}
|
||||
|
||||
@action
|
||||
setLastActiveClusterId(clusterId?: ClusterId, workspaceId = this.currentWorkspaceId) {
|
||||
this.getById(workspaceId).lastActiveClusterId = clusterId;
|
||||
}
|
||||
|
||||
@action
|
||||
protected fromStore({ currentWorkspace, workspaces = [] }: WorkspaceStoreModel) {
|
||||
if (currentWorkspace) {
|
||||
|
||||
@ -1,4 +1,8 @@
|
||||
import { getAppVersion } from "../../common/utils";
|
||||
import { extensionsStore } from "../extensions-store";
|
||||
|
||||
export const version = getAppVersion();
|
||||
export { isSnap, isWindows, isMac, isLinux, appName, slackUrl, issuesTrackerUrl } from "../../common/vars";
|
||||
export { isSnap, isWindows, isMac, isLinux, appName, slackUrl, issuesTrackerUrl } from "../../common/vars";
|
||||
export function getEnabledExtensions(): string[] {
|
||||
return extensionsStore.enabledExtensions;
|
||||
}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import type { LensExtensionId } from "./lens-extension";
|
||||
import type { ExtensionLoader } from "./extension-loader";
|
||||
import { BaseStore } from "../common/base-store";
|
||||
import { action, observable, reaction, toJS } from "mobx";
|
||||
import { action, computed, observable, reaction, toJS } from "mobx";
|
||||
|
||||
export interface LensExtensionsStoreModel {
|
||||
extensions: Record<LensExtensionId, LensExtensionState>;
|
||||
@ -9,6 +9,7 @@ export interface LensExtensionsStoreModel {
|
||||
|
||||
export interface LensExtensionState {
|
||||
enabled?: boolean;
|
||||
name: string;
|
||||
}
|
||||
|
||||
export class ExtensionsStore extends BaseStore<LensExtensionsStoreModel> {
|
||||
@ -18,6 +19,17 @@ export class ExtensionsStore extends BaseStore<LensExtensionsStoreModel> {
|
||||
});
|
||||
}
|
||||
|
||||
@computed
|
||||
get enabledExtensions() {
|
||||
const extensions: string[] = [];
|
||||
this.state.forEach((state, id) => {
|
||||
if (state.enabled) {
|
||||
extensions.push(state.name);
|
||||
}
|
||||
});
|
||||
return extensions;
|
||||
}
|
||||
|
||||
protected state = observable.map<LensExtensionId, LensExtensionState>();
|
||||
|
||||
protected getState(extensionLoader: ExtensionLoader) {
|
||||
@ -25,6 +37,7 @@ export class ExtensionsStore extends BaseStore<LensExtensionsStoreModel> {
|
||||
return Array.from(extensionLoader.userExtensions).reduce((state, [extId, ext]) => {
|
||||
state[extId] = {
|
||||
enabled: ext.isEnabled,
|
||||
name: ext.manifest.name,
|
||||
};
|
||||
return state;
|
||||
}, state);
|
||||
|
||||
@ -1,20 +1,21 @@
|
||||
// Base class for extensions-api registries
|
||||
import { action, observable } from "mobx";
|
||||
import { LensExtension } from "../lens-extension";
|
||||
import { recitfy } from "../../common/utils";
|
||||
|
||||
export class BaseRegistry<T = object, I extends T = T> {
|
||||
export class BaseRegistry<T> {
|
||||
private items = observable<T>([], { deep: false });
|
||||
|
||||
getItems(): I[] {
|
||||
return this.items.toJS() as I[];
|
||||
getItems(): T[] {
|
||||
return this.items.toJS();
|
||||
}
|
||||
|
||||
add(items: T | T[], ext?: LensExtension): () => void; // allow method overloading with required "ext"
|
||||
@action
|
||||
add(items: T | T[]) {
|
||||
const normalizedItems = (Array.isArray(items) ? items : [items]);
|
||||
this.items.push(...normalizedItems);
|
||||
return () => this.remove(...normalizedItems);
|
||||
const itemArray = recitfy(items);
|
||||
this.items.push(...itemArray);
|
||||
return () => this.remove(...itemArray);
|
||||
}
|
||||
|
||||
@action
|
||||
|
||||
@ -7,6 +7,7 @@ import { compile } from "path-to-regexp";
|
||||
import { BaseRegistry } from "./base-registry";
|
||||
import { LensExtension, sanitizeExtensionName } from "../lens-extension";
|
||||
import logger from "../../main/logger";
|
||||
import { recitfy } from "../../common/utils";
|
||||
|
||||
export interface PageRegistration {
|
||||
/**
|
||||
@ -55,12 +56,13 @@ export function getExtensionPageUrl<P extends object>({ extensionId, pageId = ""
|
||||
return extPageRoutePath;
|
||||
}
|
||||
|
||||
export class PageRegistry extends BaseRegistry<PageRegistration, RegisteredPage> {
|
||||
export class PageRegistry extends BaseRegistry<RegisteredPage> {
|
||||
@action
|
||||
add(items: PageRegistration[], ext: LensExtension) {
|
||||
add(items: PageRegistration | PageRegistration[], ext: LensExtension) {
|
||||
const itemArray = recitfy(items);
|
||||
let registeredPages: RegisteredPage[] = [];
|
||||
try {
|
||||
registeredPages = items.map(page => ({
|
||||
registeredPages = itemArray.map(page => ({
|
||||
...page,
|
||||
extensionId: ext.name,
|
||||
routePath: getExtensionPageUrl({ extensionId: ext.name, pageId: page.id ?? page.routePath }),
|
||||
|
||||
@ -83,7 +83,7 @@ export class HelmRepoManager extends Singleton {
|
||||
repositories: []
|
||||
}));
|
||||
if (!repositories.length) {
|
||||
await this.addRepo({ name: "stable", url: "https://kubernetes-charts.storage.googleapis.com/" });
|
||||
await this.addRepo({ name: "bitnami", url: "https://charts.bitnami.com/bitnami" });
|
||||
return await this.repositories();
|
||||
}
|
||||
return repositories.map(repo => ({
|
||||
|
||||
@ -218,6 +218,12 @@ export function buildMenu(windowManager: WindowManager) {
|
||||
shell.openExternal('https://docs.k8slens.dev/');
|
||||
},
|
||||
},
|
||||
{
|
||||
label: "Support",
|
||||
click: async () => {
|
||||
shell.openExternal('https://docs.k8slens.dev/latest/support/');
|
||||
},
|
||||
},
|
||||
...ignoreOnMac([
|
||||
{
|
||||
label: "About Lens",
|
||||
|
||||
@ -12,14 +12,22 @@ class HelmApiRoute extends LensApi {
|
||||
|
||||
public async getChart(request: LensApiRequest) {
|
||||
const { params, query, response } = request;
|
||||
const chart = await helmService.getChart(params.repo, params.chart, query.get("version"));
|
||||
this.respondJson(response, chart);
|
||||
try {
|
||||
const chart = await helmService.getChart(params.repo, params.chart, query.get("version"));
|
||||
this.respondJson(response, chart);
|
||||
} catch (error) {
|
||||
this.respondText(response, error, 422);
|
||||
}
|
||||
}
|
||||
|
||||
public async getChartValues(request: LensApiRequest) {
|
||||
const { params, query, response } = request;
|
||||
const values = await helmService.getChartValues(params.repo, params.chart, query.get("version"));
|
||||
this.respondJson(response, values);
|
||||
try {
|
||||
const values = await helmService.getChartValues(params.repo, params.chart, query.get("version"));
|
||||
this.respondJson(response, values);
|
||||
} catch (error) {
|
||||
this.respondText(response, error, 422);
|
||||
}
|
||||
}
|
||||
|
||||
public async installChart(request: LensApiRequest) {
|
||||
|
||||
@ -95,7 +95,6 @@ export function createTrayMenu(windowManager: WindowManager): Menu {
|
||||
toolTip: clusterId,
|
||||
async click() {
|
||||
workspaceStore.setActive(workspace);
|
||||
clusterStore.setActive(clusterId);
|
||||
windowManager.navigate(clusterViewURL({ params: { clusterId } }));
|
||||
}
|
||||
};
|
||||
|
||||
82
src/renderer/api/__tests__/kube-api.test.ts
Normal file
82
src/renderer/api/__tests__/kube-api.test.ts
Normal file
@ -0,0 +1,82 @@
|
||||
import { KubeApi } from "../kube-api";
|
||||
|
||||
describe("KubeApi", () => {
|
||||
it("uses url from apiBase if apiBase contains the resource", async () => {
|
||||
(fetch as any).mockResponse(async (request: any) => {
|
||||
if (request.url === "/api-kube/apis/networking.k8s.io/v1") {
|
||||
return {
|
||||
body: JSON.stringify({
|
||||
resources: [{
|
||||
name: "ingresses"
|
||||
}] as any []
|
||||
})
|
||||
};
|
||||
} else if (request.url === "/api-kube/apis/extensions/v1beta1") {
|
||||
// Even if the old API contains ingresses, KubeApi should prefer the apiBase url
|
||||
return {
|
||||
body: JSON.stringify({
|
||||
resources: [{
|
||||
name: "ingresses"
|
||||
}] as any []
|
||||
})
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
body: JSON.stringify({
|
||||
resources: [] as any []
|
||||
})
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
const apiBase = "/apis/networking.k8s.io/v1/ingresses";
|
||||
const fallbackApiBase = "/apis/extensions/v1beta1/ingresses";
|
||||
const kubeApi = new KubeApi({
|
||||
apiBase,
|
||||
fallbackApiBases: [fallbackApiBase],
|
||||
checkPreferredVersion: true,
|
||||
});
|
||||
|
||||
await kubeApi.get();
|
||||
expect(kubeApi.apiPrefix).toEqual("/apis");
|
||||
expect(kubeApi.apiGroup).toEqual("networking.k8s.io");
|
||||
});
|
||||
|
||||
it("uses url from fallbackApiBases if apiBase lacks the resource", async () => {
|
||||
(fetch as any).mockResponse(async (request: any) => {
|
||||
if (request.url === "/api-kube/apis/networking.k8s.io/v1") {
|
||||
return {
|
||||
body: JSON.stringify({
|
||||
resources: [] as any []
|
||||
})
|
||||
};
|
||||
} else if (request.url === "/api-kube/apis/extensions/v1beta1") {
|
||||
return {
|
||||
body: JSON.stringify({
|
||||
resources: [{
|
||||
name: "ingresses"
|
||||
}] as any []
|
||||
})
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
body: JSON.stringify({
|
||||
resources: [] as any []
|
||||
})
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
const apiBase = "apis/networking.k8s.io/v1/ingresses";
|
||||
const fallbackApiBase = "/apis/extensions/v1beta1/ingresses";
|
||||
const kubeApi = new KubeApi({
|
||||
apiBase,
|
||||
fallbackApiBases: [fallbackApiBase],
|
||||
checkPreferredVersion: true,
|
||||
});
|
||||
|
||||
await kubeApi.get();
|
||||
expect(kubeApi.apiPrefix).toEqual("/apis");
|
||||
expect(kubeApi.apiGroup).toEqual("extensions");
|
||||
});
|
||||
});
|
||||
@ -29,11 +29,42 @@ export interface ILoadBalancerIngress {
|
||||
hostname?: string;
|
||||
ip?: string;
|
||||
}
|
||||
|
||||
// extensions/v1beta1
|
||||
interface IExtensionsBackend {
|
||||
serviceName: string;
|
||||
servicePort: number;
|
||||
}
|
||||
|
||||
// networking.k8s.io/v1
|
||||
interface INetworkingBackend {
|
||||
service: IIngressService;
|
||||
}
|
||||
|
||||
export type IIngressBackend = IExtensionsBackend | INetworkingBackend;
|
||||
|
||||
export interface IIngressService {
|
||||
name: string;
|
||||
port: {
|
||||
name?: string;
|
||||
number?: number;
|
||||
}
|
||||
}
|
||||
|
||||
export const getBackendServiceNamePort = (backend: IIngressBackend) => {
|
||||
// .service is available with networking.k8s.io/v1, otherwise using extensions/v1beta1 interface
|
||||
const serviceName = "service" in backend ? backend.service.name : backend.serviceName;
|
||||
// Port is specified either with a number or name
|
||||
const servicePort = "service" in backend ? backend.service.port.number ?? backend.service.port.name : backend.servicePort;
|
||||
|
||||
return { serviceName, servicePort };
|
||||
};
|
||||
|
||||
@autobind()
|
||||
export class Ingress extends KubeObject {
|
||||
static kind = "Ingress";
|
||||
static namespaced = true;
|
||||
static apiBase = "/apis/extensions/v1beta1/ingresses";
|
||||
static apiBase = "/apis/networking.k8s.io/v1/ingresses";
|
||||
|
||||
spec: {
|
||||
tls: {
|
||||
@ -44,17 +75,20 @@ export class Ingress extends KubeObject {
|
||||
http: {
|
||||
paths: {
|
||||
path?: string;
|
||||
backend: {
|
||||
serviceName: string;
|
||||
servicePort: number;
|
||||
};
|
||||
backend: IIngressBackend;
|
||||
}[];
|
||||
};
|
||||
}[];
|
||||
backend?: {
|
||||
serviceName: string;
|
||||
servicePort: number;
|
||||
};
|
||||
// extensions/v1beta1
|
||||
backend?: IExtensionsBackend;
|
||||
// networking.k8s.io/v1
|
||||
defaultBackend?: INetworkingBackend & {
|
||||
resource: {
|
||||
apiGroup: string;
|
||||
kind: string;
|
||||
name: string;
|
||||
}
|
||||
}
|
||||
};
|
||||
status: {
|
||||
loadBalancer: {
|
||||
@ -75,7 +109,9 @@ export class Ingress extends KubeObject {
|
||||
const host = rule.host ? rule.host : "*";
|
||||
if (rule.http && rule.http.paths) {
|
||||
rule.http.paths.forEach(path => {
|
||||
routes.push(protocol + "://" + host + (path.path || "/") + " ⇢ " + path.backend.serviceName + ":" + path.backend.servicePort);
|
||||
const { serviceName, servicePort } = getBackendServiceNamePort(path.backend);
|
||||
|
||||
routes.push(protocol + "://" + host + (path.path || "/") + " ⇢ " + serviceName + ":" + servicePort);
|
||||
});
|
||||
}
|
||||
});
|
||||
@ -83,6 +119,17 @@ export class Ingress extends KubeObject {
|
||||
return routes;
|
||||
}
|
||||
|
||||
getServiceNamePort() {
|
||||
const { spec } = this;
|
||||
const serviceName = spec?.defaultBackend?.service.name ?? spec?.backend?.serviceName;
|
||||
const servicePort = spec?.defaultBackend?.service.port.number ?? spec?.defaultBackend?.service.port.name ?? spec?.backend?.servicePort;
|
||||
|
||||
return {
|
||||
serviceName,
|
||||
servicePort
|
||||
};
|
||||
}
|
||||
|
||||
getHosts() {
|
||||
const { spec: { rules } } = this;
|
||||
if (!rules) return [];
|
||||
@ -91,22 +138,24 @@ export class Ingress extends KubeObject {
|
||||
|
||||
getPorts() {
|
||||
const ports: number[] = [];
|
||||
const { spec: { tls, rules, backend } } = this;
|
||||
const { spec: { tls, rules, backend, defaultBackend } } = this;
|
||||
const httpPort = 80;
|
||||
const tlsPort = 443;
|
||||
|
||||
// Note: not using the port name (string)
|
||||
const servicePort = defaultBackend?.service.port.number ?? backend?.servicePort;
|
||||
|
||||
if (rules && rules.length > 0) {
|
||||
if (rules.some(rule => rule.hasOwnProperty("http"))) {
|
||||
ports.push(httpPort);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (backend && backend.servicePort) {
|
||||
ports.push(backend.servicePort);
|
||||
}
|
||||
} else if (servicePort !== undefined) {
|
||||
ports.push(Number(servicePort));
|
||||
}
|
||||
if (tls && tls.length > 0) {
|
||||
ports.push(tlsPort);
|
||||
}
|
||||
|
||||
return ports.join(", ");
|
||||
}
|
||||
|
||||
@ -121,4 +170,8 @@ export class Ingress extends KubeObject {
|
||||
|
||||
export const ingressApi = new IngressApi({
|
||||
objectConstructor: Ingress,
|
||||
});
|
||||
// Add fallback for Kubernetes <1.19
|
||||
checkPreferredVersion: true,
|
||||
fallbackApiBases: ["/apis/extensions/v1beta1/ingresses"],
|
||||
logStuff: true
|
||||
} as any);
|
||||
|
||||
@ -8,10 +8,22 @@ import { apiKube } from "./index";
|
||||
import { kubeWatchApi } from "./kube-watch-api";
|
||||
import { apiManager } from "./api-manager";
|
||||
import { createKubeApiURL, parseKubeApi } from "./kube-api-parse";
|
||||
import { apiKubePrefix, isDevelopment } from "../../common/vars";
|
||||
import { apiKubePrefix, isDevelopment, isTestEnv } from "../../common/vars";
|
||||
|
||||
export interface IKubeApiOptions<T extends KubeObject> {
|
||||
apiBase?: string; // base api-path for listing all resources, e.g. "/api/v1/pods"
|
||||
/**
|
||||
* base api-path for listing all resources, e.g. "/api/v1/pods"
|
||||
*/
|
||||
apiBase?: string;
|
||||
|
||||
/**
|
||||
* If the API uses a different API endpoint (e.g. apiBase) depending on the cluster version,
|
||||
* fallback API bases can be listed individually.
|
||||
* The first (existing) API base is used in the requests, if apiBase is not found.
|
||||
* This option only has effect if checkPreferredVersion is true.
|
||||
*/
|
||||
fallbackApiBases?: string[];
|
||||
|
||||
objectConstructor?: IKubeObjectConstructor<T>;
|
||||
request?: KubeJsonApi;
|
||||
isNamespaced?: boolean;
|
||||
@ -35,6 +47,17 @@ export interface IKubePreferredVersion {
|
||||
}
|
||||
}
|
||||
|
||||
export interface IKubeResourceList {
|
||||
resources: {
|
||||
kind: string;
|
||||
name: string;
|
||||
namespaced: boolean;
|
||||
singularName: string;
|
||||
storageVersionHash: string;
|
||||
verbs: string[];
|
||||
}[];
|
||||
}
|
||||
|
||||
export interface IKubeApiCluster {
|
||||
id: string;
|
||||
}
|
||||
@ -85,7 +108,7 @@ export class KubeApi<T extends KubeObject = any> {
|
||||
if (!options.apiBase) {
|
||||
options.apiBase = objectConstructor.apiBase;
|
||||
}
|
||||
const { apiBase, apiPrefix, apiGroup, apiVersion, apiVersionWithGroup, resource } = KubeApi.parseApi(options.apiBase);
|
||||
const { apiBase, apiPrefix, apiGroup, apiVersion, resource } = KubeApi.parseApi(options.apiBase);
|
||||
|
||||
this.kind = kind;
|
||||
this.isNamespaced = isNamespaced;
|
||||
@ -108,8 +131,73 @@ export class KubeApi<T extends KubeObject = any> {
|
||||
.join("/");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the latest API prefix/group that contains the required resource.
|
||||
* First tries options.apiBase, then urls in order from options.fallbackApiBases.
|
||||
*/
|
||||
private async getLatestApiPrefixGroup() {
|
||||
// Note that this.options.apiBase is the "full" url, whereas this.apiBase is parsed
|
||||
const apiBases = [this.options.apiBase, ...this.options.fallbackApiBases];
|
||||
|
||||
for (const apiUrl of apiBases) {
|
||||
// Split e.g. "/apis/extensions/v1beta1/ingresses" to parts
|
||||
const { apiPrefix, apiGroup, apiVersionWithGroup, resource } = KubeApi.parseApi(apiUrl);
|
||||
|
||||
// Request available resources
|
||||
try {
|
||||
const response = await this.request.get<IKubeResourceList>(`${apiPrefix}/${apiVersionWithGroup}`);
|
||||
|
||||
// If the resource is found in the group, use this apiUrl
|
||||
if (response.resources?.find(kubeResource => kubeResource.name === resource)) {
|
||||
return { apiPrefix, apiGroup };
|
||||
}
|
||||
} catch (error) {
|
||||
// Exception is ignored as we can try the next url
|
||||
console.error(error);
|
||||
}
|
||||
}
|
||||
|
||||
// Avoid throwing in tests
|
||||
if (isTestEnv) {
|
||||
return {
|
||||
apiPrefix: this.apiPrefix,
|
||||
apiGroup: this.apiGroup
|
||||
};
|
||||
}
|
||||
|
||||
throw new Error(`Can't find working API for the Kubernetes resource ${this.apiResource}`);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the apiPrefix and apiGroup to be used for fetching the preferred version.
|
||||
*/
|
||||
private async getPreferredVersionPrefixGroup() {
|
||||
if (this.options.fallbackApiBases) {
|
||||
return this.getLatestApiPrefixGroup();
|
||||
} else {
|
||||
return {
|
||||
apiPrefix: this.apiPrefix,
|
||||
apiGroup: this.apiGroup
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
protected async checkPreferredVersion() {
|
||||
if (this.options.fallbackApiBases && !this.options.checkPreferredVersion) {
|
||||
throw new Error("checkPreferredVersion must be enabled if fallbackApiBases is set in KubeApi");
|
||||
}
|
||||
|
||||
if (this.options.checkPreferredVersion && this.apiVersionPreferred === undefined) {
|
||||
const { apiPrefix, apiGroup } = await this.getPreferredVersionPrefixGroup();
|
||||
|
||||
// The apiPrefix and apiGroup might change due to fallbackApiBases, so we must override them
|
||||
Object.defineProperty(this, "apiPrefix", {
|
||||
value: apiPrefix
|
||||
});
|
||||
Object.defineProperty(this, "apiGroup", {
|
||||
value: apiGroup
|
||||
});
|
||||
|
||||
const res = await this.request.get<IKubePreferredVersion>(`${this.apiPrefix}/${this.apiGroup}`);
|
||||
Object.defineProperty(this, "apiVersionPreferred", {
|
||||
value: res?.preferredVersion?.version ?? null,
|
||||
|
||||
@ -14,6 +14,7 @@ import { KubeObjectDetailsProps } from "../kube-object";
|
||||
import { IngressCharts } from "./ingress-charts";
|
||||
import { KubeObjectMeta } from "../kube-object/kube-object-meta";
|
||||
import { kubeObjectDetailRegistry } from "../../api/kube-object-detail-registry";
|
||||
import { getBackendServiceNamePort } from "../../api/endpoints/ingress.api";
|
||||
|
||||
interface Props extends KubeObjectDetailsProps<Ingress> {
|
||||
}
|
||||
@ -48,7 +49,9 @@ export class IngressDetails extends React.Component<Props> {
|
||||
</TableHead>
|
||||
{
|
||||
rule.http.paths.map((path, index) => {
|
||||
const backend = `${path.backend.serviceName}:${path.backend.servicePort}`;
|
||||
const { serviceName, servicePort } = getBackendServiceNamePort(path.backend);
|
||||
const backend =`${serviceName}:${servicePort}`;
|
||||
|
||||
return (
|
||||
<TableRow key={index}>
|
||||
<TableCell className="path">{path.path || ""}</TableCell>
|
||||
@ -100,6 +103,9 @@ export class IngressDetails extends React.Component<Props> {
|
||||
<Trans>Network</Trans>,
|
||||
<Trans>Duration</Trans>,
|
||||
];
|
||||
|
||||
const { serviceName, servicePort } = ingress.getServiceNamePort();
|
||||
|
||||
return (
|
||||
<div className="IngressDetails">
|
||||
<ResourceMetrics
|
||||
@ -117,9 +123,9 @@ export class IngressDetails extends React.Component<Props> {
|
||||
{spec.tls.map((tls, index) => <p key={index}>{tls.secretName}</p>)}
|
||||
</DrawerItem>
|
||||
}
|
||||
{spec.backend && spec.backend.serviceName && spec.backend.servicePort &&
|
||||
{serviceName && servicePort &&
|
||||
<DrawerItem name={<Trans>Service</Trans>}>
|
||||
{spec.backend.serviceName}:{spec.backend.servicePort}
|
||||
{serviceName}:{servicePort}
|
||||
</DrawerItem>
|
||||
}
|
||||
<DrawerTitle title={<Trans>Rules</Trans>}/>
|
||||
@ -134,14 +140,14 @@ export class IngressDetails extends React.Component<Props> {
|
||||
|
||||
kubeObjectDetailRegistry.add({
|
||||
kind: "Ingress",
|
||||
apiVersions: ["extensions/v1beta1"],
|
||||
apiVersions: ["networking.k8s.io/v1", "extensions/v1beta1"],
|
||||
components: {
|
||||
Details: (props) => <IngressDetails {...props} />
|
||||
}
|
||||
});
|
||||
kubeObjectDetailRegistry.add({
|
||||
kind: "Ingress",
|
||||
apiVersions: ["extensions/v1beta1"],
|
||||
apiVersions: ["networking.k8s.io/v1", "extensions/v1beta1"],
|
||||
priority: 5,
|
||||
components: {
|
||||
Details: (props) => <KubeEventDetails {...props} />
|
||||
|
||||
@ -7,8 +7,11 @@ import { Trans } from "@lingui/macro";
|
||||
import { Menu, MenuItem, MenuProps } from "../menu";
|
||||
import { Icon } from "../icon";
|
||||
import { observable } from "mobx";
|
||||
import { workspaceStore } from "../../../common/workspace-store";
|
||||
import { WorkspaceId, workspaceStore } from "../../../common/workspace-store";
|
||||
import { cssNames } from "../../utils";
|
||||
import { navigate } from "../../navigation";
|
||||
import { clusterViewURL } from "../cluster-manager/cluster-view.route";
|
||||
import { landingURL } from "../+landing-page";
|
||||
|
||||
interface Props extends Partial<MenuProps> {
|
||||
}
|
||||
@ -17,6 +20,16 @@ interface Props extends Partial<MenuProps> {
|
||||
export class WorkspaceMenu extends React.Component<Props> {
|
||||
@observable menuVisible = false;
|
||||
|
||||
activateWorkspace = (id: WorkspaceId) => {
|
||||
const clusterId = workspaceStore.getById(id).lastActiveClusterId;
|
||||
workspaceStore.setActive(id);
|
||||
if (clusterId) {
|
||||
navigate(clusterViewURL({ params: { clusterId } }));
|
||||
} else {
|
||||
navigate(landingURL());
|
||||
}
|
||||
};
|
||||
|
||||
render() {
|
||||
const { className, ...menuProps } = this.props;
|
||||
const { enabledWorkspacesList, currentWorkspace } = workspaceStore;
|
||||
@ -38,7 +51,7 @@ export class WorkspaceMenu extends React.Component<Props> {
|
||||
key={workspaceId}
|
||||
title={description}
|
||||
active={workspaceId === currentWorkspace.id}
|
||||
onClick={() => workspaceStore.setActive(workspaceId)}
|
||||
onClick={() => this.activateWorkspace(workspaceId)}
|
||||
>
|
||||
<Icon small material="layers"/>
|
||||
<span className="workspace">{name}</span>
|
||||
|
||||
@ -13,6 +13,7 @@ import { Input } from "../input";
|
||||
import { cssNames, prevDefault } from "../../utils";
|
||||
import { Button } from "../button";
|
||||
import { isRequired, InputValidator } from "../input/input_validators";
|
||||
import { clusterStore } from "../../../common/cluster-store";
|
||||
|
||||
@observer
|
||||
export class Workspaces extends React.Component {
|
||||
@ -70,6 +71,12 @@ export class Workspaces extends React.Component {
|
||||
this.editingWorkspaces.set(id, toJS(workspace));
|
||||
};
|
||||
|
||||
activateWorkspace = (id: WorkspaceId) => {
|
||||
const clusterId = workspaceStore.getById(id).lastActiveClusterId;
|
||||
workspaceStore.setActive(id);
|
||||
clusterStore.setActive(clusterId);
|
||||
};
|
||||
|
||||
clearEditing = (id: WorkspaceId) => {
|
||||
this.editingWorkspaces.delete(id);
|
||||
};
|
||||
@ -135,7 +142,7 @@ export class Workspaces extends React.Component {
|
||||
{!isEditing && (
|
||||
<Fragment>
|
||||
<span className="name flex gaps align-center">
|
||||
<a href="#" onClick={prevDefault(() => workspaceStore.setActive(workspaceId))}>{name}</a>
|
||||
<a href="#" onClick={prevDefault(() => this.activateWorkspace(workspaceId))}>{name}</a>
|
||||
{isActive && <span> <Trans>(current)</Trans></span>}
|
||||
</span>
|
||||
<span className="description">{description}</span>
|
||||
|
||||
@ -100,7 +100,7 @@ export class App extends React.Component {
|
||||
const tabRoutes = this.getTabLayoutRoutes(menu);
|
||||
if (tabRoutes.length > 0) {
|
||||
const pageComponent = () => <TabLayout tabs={tabRoutes} />;
|
||||
return <Route key={"extension-tab-layout-route-" + index} component={pageComponent}/>;
|
||||
return <Route key={"extension-tab-layout-route-" + index} component={pageComponent} path={tabRoutes.map((tab) => tab.routePath)} />;
|
||||
} else {
|
||||
const page = clusterPageRegistry.getByPageMenuTarget(menu.target);
|
||||
if (page) {
|
||||
|
||||
@ -77,6 +77,7 @@ export class ClustersMenu extends React.Component<Props> {
|
||||
ok: () => {
|
||||
if (clusterStore.activeClusterId === cluster.id) {
|
||||
navigate(landingURL());
|
||||
clusterStore.setActive(null);
|
||||
}
|
||||
clusterStore.removeById(cluster.id);
|
||||
},
|
||||
|
||||
@ -18,11 +18,4 @@
|
||||
.xterm-viewport {
|
||||
@include custom-scrollbar;
|
||||
}
|
||||
|
||||
// fix: safari won't handle paste event for textarea with zero size block
|
||||
.xterm-helper-textarea {
|
||||
width: 10px !important;
|
||||
height: 10px !important;
|
||||
pointer-events: none;
|
||||
}
|
||||
}
|
||||
@ -98,23 +98,30 @@ export class Sidebar extends React.Component<Props> {
|
||||
}
|
||||
|
||||
renderRegisteredMenus() {
|
||||
return clusterPageMenuRegistry.getRootItems().map((menuItem) => {
|
||||
return clusterPageMenuRegistry.getRootItems().map((menuItem, index) => {
|
||||
const registeredPage = clusterPageRegistry.getByPageMenuTarget(menuItem.target);
|
||||
const tabRoutes = this.getTabLayoutRoutes(menuItem);
|
||||
let pageUrl: string;
|
||||
let routePath: string;
|
||||
let isActive = false;
|
||||
if (registeredPage) {
|
||||
const { extensionId, id: pageId } = registeredPage;
|
||||
pageUrl = getExtensionPageUrl({ extensionId, pageId, params: menuItem.target.params });
|
||||
isActive = pageUrl === navigation.location.pathname;
|
||||
}
|
||||
const tabRoutes = this.getTabLayoutRoutes(menuItem);
|
||||
if (!registeredPage && tabRoutes.length == 0) {
|
||||
routePath = registeredPage.routePath;
|
||||
isActive = isActiveRoute(registeredPage.routePath);
|
||||
} else if (tabRoutes.length > 0) {
|
||||
pageUrl = tabRoutes[0].url;
|
||||
routePath = tabRoutes[0].routePath;
|
||||
isActive = isActiveRoute(tabRoutes.map((tab) => tab.routePath));
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
return (
|
||||
<SidebarNavItem
|
||||
key={pageUrl} url={pageUrl}
|
||||
text={menuItem.title} icon={<menuItem.components.Icon/>}
|
||||
key={"registered-item-" + index}
|
||||
url={pageUrl}
|
||||
text={menuItem.title}
|
||||
icon={<menuItem.components.Icon/>}
|
||||
isActive={isActive}
|
||||
subMenus={tabRoutes}
|
||||
/>
|
||||
|
||||
@ -67,7 +67,7 @@
|
||||
"terminalForeground": "#2d2d2d",
|
||||
"terminalCursor": "#2d2d2d",
|
||||
"terminalCursorAccent": "#ffffff",
|
||||
"terminalSelection": "#bfbfbf",
|
||||
"terminalSelection": "#bfbfbf66",
|
||||
"terminalBlack": "#2d2d2d",
|
||||
"terminalRed": "#cd3734 ",
|
||||
"terminalGreen": "#18cf12",
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
// Common usage utils & helpers
|
||||
|
||||
export const noop: any = Function();
|
||||
export const isElectron = !!navigator.userAgent.match(/Electron/);
|
||||
|
||||
export * from "../../common/utils";
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
Here you can find description of changes we've built into each release. While we try our best to make each upgrade automatic and as smooth as possible, there may be some cases where you might need to do something to ensure the application works smoothly. So please read through the release highlights!
|
||||
|
||||
## 4.0.0-beta.3 (current version)
|
||||
## 4.0.0-beta.4 (current version)
|
||||
|
||||
- Extension API
|
||||
- Improved pod logs
|
||||
@ -10,6 +10,7 @@ Here you can find description of changes we've built into each release. While we
|
||||
- Tray icon
|
||||
- Add last-status information for container
|
||||
- Add LoadBalancer information to Ingress view
|
||||
- Add search by ip to Pod view
|
||||
- Move tracker to an extension
|
||||
- Add support page (as an extension)
|
||||
- Ability to restart deployment
|
||||
@ -19,6 +20,8 @@ Here you can find description of changes we've built into each release. While we
|
||||
- Add +/- buttons in scale deployment popup screen
|
||||
- Update chart details when selecting another chart
|
||||
- Use latest alpine version (3.12) for shell sessions
|
||||
- Fix errors on app quit
|
||||
- Fix kube-auth-proxy to accept only target cluster hostname
|
||||
|
||||
## 3.6.8
|
||||
- Fix cluster connection issue when opening cluster settings for disconnected clusters
|
||||
|
||||
Loading…
Reference in New Issue
Block a user