mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Merge branch 'master' into lens_restructure
# Conflicts: # Makefile # dashboard/yarn.lock # package.json # yarn.lock
This commit is contained in:
commit
e8624c845a
@ -44,7 +44,6 @@ jobs:
|
||||
WIN_CSC_KEY_PASSWORD: $(WIN_CSC_KEY_PASSWORD)
|
||||
GH_TOKEN: $(GH_TOKEN)
|
||||
- job: macOS
|
||||
condition: "and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/'))"
|
||||
pool:
|
||||
vmImage: macOS-10.14
|
||||
strategy:
|
||||
@ -73,7 +72,10 @@ jobs:
|
||||
displayName: Install dependencies
|
||||
- script: make test
|
||||
displayName: Run tests
|
||||
- script: make integration-mac
|
||||
displayName: Run integration tests
|
||||
- script: make build
|
||||
condition: "and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/'))"
|
||||
displayName: Build
|
||||
env:
|
||||
APPLEID: $(APPLEID)
|
||||
@ -115,6 +117,15 @@ jobs:
|
||||
displayName: Install dependencies
|
||||
- script: make test
|
||||
displayName: Run tests
|
||||
- bash: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install libgconf-2-4 conntrack -y
|
||||
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
|
||||
sudo install minikube-linux-amd64 /usr/local/bin/minikube
|
||||
sudo minikube start --driver=none
|
||||
displayName: Install integration test dependencies
|
||||
- script: xvfb-run --auto-servernum --server-args='-screen 0, 1600x900x24' make integration-linux
|
||||
displayName: Run integration tests
|
||||
- bash: |
|
||||
sudo chown root:root /
|
||||
sudo apt-get update && sudo apt-get install -y snapd
|
||||
|
||||
@ -160,7 +160,7 @@ export class ShellSession extends EventEmitter {
|
||||
}
|
||||
|
||||
protected exit(code = 1000) {
|
||||
this.websocket.close(code)
|
||||
if (this.websocket.readyState == this.websocket.OPEN) this.websocket.close(code)
|
||||
this.emit('exit')
|
||||
}
|
||||
|
||||
@ -180,12 +180,25 @@ export class ShellSession extends EventEmitter {
|
||||
|
||||
protected exitProcessOnWebsocketClose() {
|
||||
this.websocket.on("close", () => {
|
||||
if (this.shellProcess) {
|
||||
this.shellProcess.kill();
|
||||
}
|
||||
this.killShellProcess()
|
||||
})
|
||||
}
|
||||
|
||||
protected killShellProcess(){
|
||||
if(this.running) {
|
||||
// On Windows we need to kill the shell process by pid, since Lens won't respond after a while if using `this.shellProcess.kill()`
|
||||
if (process.platform == "win32") {
|
||||
try {
|
||||
process.kill(this.shellProcess.pid)
|
||||
} catch(e) {
|
||||
return
|
||||
}
|
||||
} else {
|
||||
this.shellProcess.kill()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected sendResponse(msg: string) {
|
||||
this.websocket.send("1" + Buffer.from(msg).toString("base64"))
|
||||
}
|
||||
|
||||
@ -26,7 +26,10 @@ export class WindowManager {
|
||||
center: true,
|
||||
frame: false,
|
||||
resizable: false,
|
||||
show: false
|
||||
show: false,
|
||||
webPreferences: {
|
||||
nodeIntegration: true
|
||||
}
|
||||
})
|
||||
if (showSplash) {
|
||||
this.splashWindow.loadFile(path.join(__static, "/splash.html"))
|
||||
|
||||
@ -11,6 +11,7 @@
|
||||
label="Choose config:"
|
||||
>
|
||||
<b-form-select
|
||||
id="kubecontext-select"
|
||||
v-model="kubecontext"
|
||||
:options="contextNames"
|
||||
@change="onSelect($event)"
|
||||
|
||||
@ -8,8 +8,8 @@
|
||||
<div>
|
||||
<b-row align-h="center" class="banner">
|
||||
<b-col sm="8">
|
||||
<h1 v-if="user && clusters.length === 0" class="display-4 text-center">
|
||||
Welcome, {{ greetingName }}!
|
||||
<h1 v-if="clusters.length === 0" class="display-4 text-center">
|
||||
Welcome!
|
||||
</h1>
|
||||
<p v-if="clusters.length === 0" class="text-center">
|
||||
Get started by associating one or more clusters to Lens.
|
||||
@ -35,12 +35,6 @@ export default {
|
||||
},
|
||||
clusters: function() {
|
||||
return this.$store.getters.clusters;
|
||||
},
|
||||
user: function() {
|
||||
return this.$store.getters.user;
|
||||
},
|
||||
greetingName: function() {
|
||||
return (this.user['first-name'] && this.user['first-name'] !== "") ? this.user['first-name'] : this.user.username
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -199,21 +199,4 @@ export class HelmRelease implements ItemObject {
|
||||
const chartVersion = versions.find(chartVersion => chartVersion.version === version);
|
||||
return chartVersion ? chartVersion.repo : "";
|
||||
}
|
||||
|
||||
getLastVersion(): string | null {
|
||||
const chartName = this.getChart();
|
||||
const versions = helmChartStore.versions.get(chartName);
|
||||
if (!versions) {
|
||||
return null; // checking new version state
|
||||
}
|
||||
if (versions.length) {
|
||||
return versions[0].version; // versions already sorted when loaded, the first is latest
|
||||
}
|
||||
return this.getVersion();
|
||||
}
|
||||
|
||||
hasNewVersion() {
|
||||
const lastVersion = this.getLastVersion();
|
||||
return lastVersion && lastVersion !== this.getVersion();
|
||||
}
|
||||
}
|
||||
|
||||
@ -19,7 +19,6 @@ import { AceEditor } from "../ace-editor";
|
||||
import { Button } from "../button";
|
||||
import { releaseStore } from "./release.store";
|
||||
import { Notifications } from "../notifications";
|
||||
import { Icon } from "../icon";
|
||||
import { createUpgradeChartTab } from "../dock/upgrade-chart.store";
|
||||
import { getDetailsUrl } from "../../navigation";
|
||||
import { _i18n } from "../../i18n";
|
||||
@ -190,14 +189,12 @@ export class ReleaseDetails extends Component<Props> {
|
||||
<DrawerItem name={<Trans>Chart</Trans>} className="chart">
|
||||
<div className="flex gaps align-center">
|
||||
<span>{release.getChart()}</span>
|
||||
{release.hasNewVersion() && (
|
||||
<Button
|
||||
primary
|
||||
label={_i18n._(t`Upgrade`)}
|
||||
className="box right upgrade"
|
||||
onClick={this.upgradeVersion}
|
||||
/>
|
||||
)}
|
||||
<Button
|
||||
primary
|
||||
label={_i18n._(t`Upgrade`)}
|
||||
className="box right upgrade"
|
||||
onClick={this.upgradeVersion}
|
||||
/>
|
||||
</div>
|
||||
</DrawerItem>
|
||||
<DrawerItem name={<Trans>Updated</Trans>}>
|
||||
@ -211,12 +208,6 @@ export class ReleaseDetails extends Component<Props> {
|
||||
<span>
|
||||
{release.getVersion()}
|
||||
</span>
|
||||
{!release.getLastVersion() && (
|
||||
<Icon svg="spinner" small/>
|
||||
)}
|
||||
{release.hasNewVersion() && (
|
||||
<span><Trans>New version available:</Trans> <b>{release.getLastVersion()}</b></span>
|
||||
)}
|
||||
</div>
|
||||
</DrawerItem>
|
||||
<DrawerItem name={<Trans>Status</Trans>} className="status" labelsOnly>
|
||||
|
||||
@ -37,7 +37,6 @@ export class HelmReleaseMenu extends React.Component<Props> {
|
||||
const { release, toolbar } = this.props;
|
||||
if (!release) return;
|
||||
const hasRollback = release && release.getRevision() > 1;
|
||||
const hasNewVersion = release.hasNewVersion();
|
||||
return (
|
||||
<>
|
||||
{hasRollback && (
|
||||
@ -46,12 +45,6 @@ export class HelmReleaseMenu extends React.Component<Props> {
|
||||
<span className="title"><Trans>Rollback</Trans></span>
|
||||
</MenuItem>
|
||||
)}
|
||||
{hasNewVersion && (
|
||||
<MenuItem onClick={this.upgrade}>
|
||||
<Icon material="build" interactive={toolbar} title={_i18n._(t`Upgrade`)}/>
|
||||
<span className="title"><Trans>Upgrade</Trans></span>
|
||||
</MenuItem>
|
||||
)}
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
@ -5,9 +5,7 @@ import kebabCase from "lodash/kebabCase";
|
||||
import { observer } from "mobx-react";
|
||||
import { Trans } from "@lingui/macro";
|
||||
import { RouteComponentProps } from "react-router";
|
||||
import { autobind, interval } from "../../utils";
|
||||
import { releaseStore } from "./release.store";
|
||||
import { helmChartStore } from "../+apps-helm-charts/helm-chart.store";
|
||||
import { IReleaseRouteParams, releaseURL } from "./release.route";
|
||||
import { HelmRelease } from "../../api/endpoints/helm-releases.api";
|
||||
import { ReleaseDetails } from "./release-details";
|
||||
@ -15,9 +13,7 @@ import { ReleaseRollbackDialog } from "./release-rollback-dialog";
|
||||
import { navigation } from "../../navigation";
|
||||
import { ItemListLayout } from "../item-object-list/item-list-layout";
|
||||
import { HelmReleaseMenu } from "./release-menu";
|
||||
import { Icon } from "../icon";
|
||||
import { secretsStore } from "../+config-secrets/secrets.store";
|
||||
import { when } from "mobx";
|
||||
|
||||
enum sortBy {
|
||||
name = "name",
|
||||
@ -33,31 +29,16 @@ interface Props extends RouteComponentProps<IReleaseRouteParams> {
|
||||
|
||||
@observer
|
||||
export class HelmReleases extends Component<Props> {
|
||||
private versionsWatcher = interval(3600, this.checkVersions);
|
||||
|
||||
componentDidMount() {
|
||||
// Watch for secrets associated with releases and react to their changes
|
||||
releaseStore.watch();
|
||||
this.versionsWatcher.start();
|
||||
when(() => releaseStore.isLoaded, this.checkVersions);
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
releaseStore.unwatch();
|
||||
this.versionsWatcher.stop();
|
||||
}
|
||||
|
||||
// Check all available versions every 1 hour for installed releases.
|
||||
// This required to show "upgrade" icon in the list and upgrade button in the details view.
|
||||
@autobind()
|
||||
checkVersions() {
|
||||
const charts = releaseStore.items.map(release => release.getChart());
|
||||
return charts.reduce((promise, chartName) => {
|
||||
const loadVersions = () => helmChartStore.getVersions(chartName, true);
|
||||
return promise.then(loadVersions, loadVersions);
|
||||
}, Promise.resolve({}))
|
||||
};
|
||||
|
||||
get selectedRelease() {
|
||||
const { match: { params: { name, namespace } } } = this.props;
|
||||
return releaseStore.items.find(release => {
|
||||
@ -130,7 +111,6 @@ export class HelmReleases extends Component<Props> {
|
||||
]}
|
||||
renderTableContents={(release: HelmRelease) => {
|
||||
const version = release.getVersion();
|
||||
const lastVersion = release.getLastVersion();
|
||||
return [
|
||||
release.getName(),
|
||||
release.getNs(),
|
||||
@ -138,20 +118,6 @@ export class HelmReleases extends Component<Props> {
|
||||
release.getRevision(),
|
||||
<>
|
||||
{version}
|
||||
{!lastVersion && (
|
||||
<Icon
|
||||
small svg="spinner"
|
||||
className="checking-update"
|
||||
tooltip={<Trans>Checking update</Trans>}
|
||||
/>
|
||||
)}
|
||||
{release.hasNewVersion() && (
|
||||
<Icon
|
||||
material="new_releases"
|
||||
className="new-version"
|
||||
tooltip={<Trans>New version: {lastVersion}</Trans>}
|
||||
/>
|
||||
)}
|
||||
</>,
|
||||
release.appVersion,
|
||||
{ title: release.getStatus(), className: kebabCase(release.getStatus()) },
|
||||
|
||||
34
spec/integration/helpers/utils.ts
Normal file
34
spec/integration/helpers/utils.ts
Normal file
@ -0,0 +1,34 @@
|
||||
import { Application } from "spectron";
|
||||
|
||||
let appPath = ""
|
||||
switch(process.platform) {
|
||||
case "win32":
|
||||
appPath = "./dist/win-unpacked/Lens.exe"
|
||||
break
|
||||
case "linux":
|
||||
appPath = "./dist/linux-unpacked/kontena-lens"
|
||||
break
|
||||
case "darwin":
|
||||
appPath = "./dist/mac/LensDev.app/Contents/MacOS/LensDev"
|
||||
break
|
||||
}
|
||||
|
||||
export function setup() {
|
||||
return new Application({
|
||||
// path to electron app
|
||||
args: [],
|
||||
path: appPath,
|
||||
startTimeout: 30000,
|
||||
waitTimeout: 30000,
|
||||
})
|
||||
}
|
||||
|
||||
export async function tearDown(app: Application) {
|
||||
const pid = app.mainProcess.pid
|
||||
await app.stop()
|
||||
try {
|
||||
process.kill(pid, 0);
|
||||
} catch(e) {
|
||||
return
|
||||
}
|
||||
}
|
||||
56
spec/integration/specs/app_spec.ts
Normal file
56
spec/integration/specs/app_spec.ts
Normal file
@ -0,0 +1,56 @@
|
||||
import { Application } from "spectron"
|
||||
import * as util from "../helpers/utils"
|
||||
import { spawnSync } from "child_process"
|
||||
import { stat } from "fs"
|
||||
|
||||
jest.setTimeout(20000)
|
||||
|
||||
describe("app start", () => {
|
||||
let app: Application
|
||||
const clickWhatsNew = async (app: Application) => {
|
||||
await app.client.waitUntilTextExists("h1", "What's new")
|
||||
await app.client.click("button.btn-primary")
|
||||
await app.client.waitUntilTextExists("h1", "Welcome")
|
||||
}
|
||||
|
||||
beforeEach(async () => {
|
||||
app = util.setup()
|
||||
await app.start()
|
||||
const windowCount = await app.client.getWindowCount()
|
||||
await app.client.windowByIndex(windowCount - 1)
|
||||
await app.client.waitUntilWindowLoaded()
|
||||
}, 20000)
|
||||
|
||||
it('shows "whats new"', async () => {
|
||||
await clickWhatsNew(app)
|
||||
})
|
||||
|
||||
it('allows to add a cluster', async () => {
|
||||
const status = spawnSync("minikube status", {shell: true})
|
||||
if (status.status !== 0) {
|
||||
console.warn("minikube not running, skipping test")
|
||||
return
|
||||
}
|
||||
await clickWhatsNew(app)
|
||||
await app.client.click("a#add-cluster")
|
||||
await app.client.waitUntilTextExists("legend", "Choose config:")
|
||||
await app.client.selectByVisibleText("select#kubecontext-select", "minikube (new)")
|
||||
await app.client.click("button.btn-primary")
|
||||
await app.client.waitUntilTextExists("pre.auth-output", "Authentication proxy started")
|
||||
let windowCount = await app.client.getWindowCount()
|
||||
// wait for webview to appear on window count
|
||||
while (windowCount == 1) {
|
||||
windowCount = await app.client.getWindowCount()
|
||||
}
|
||||
await app.client.windowByIndex(windowCount - 1)
|
||||
await app.client.waitUntilTextExists("span.link-text", "Cluster")
|
||||
await app.client.click('a[href="/nodes"]')
|
||||
await app.client.waitUntilTextExists("div.TableCell", "minikube")
|
||||
})
|
||||
|
||||
afterEach(async () => {
|
||||
if (app && app.isRunning()) {
|
||||
return util.tearDown(app)
|
||||
}
|
||||
})
|
||||
})
|
||||
Loading…
Reference in New Issue
Block a user