Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into auto-updater
Browse files Browse the repository at this point in the history
  • Loading branch information
devcatalin committed Sep 28, 2023
2 parents 390288e + 553ada1 commit bda33cd
Show file tree
Hide file tree
Showing 63 changed files with 1,852 additions and 415 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
docs/* @jfermi

* @devcatalin @topliceanurazvan @mortada-codes @olensmar
* @devcatalin @topliceanurazvan @olensmar
2 changes: 2 additions & 0 deletions .github/workflows/monokle-build-nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ jobs:
CSC_KEY_PASSWORD: ${{ secrets.MONOKLE_MACOS_CERTS_PASSWORD }}
APPLE_ID: ${{ secrets.APPLE_ID }}
APPLE_ID_PASSWORD: ${{ secrets.APPLE_ID_PASSWORD }}
APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.APPLE_APP_SPECIFIC_PASSWORD }}
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
USE_HARD_LINKS: false

- name: Create release and upload artifacts
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/monokle-publish-downloads.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ jobs:
CSC_KEY_PASSWORD: ${{ secrets.MONOKLE_MACOS_CERTS_PASSWORD }}
APPLE_ID: ${{ secrets.APPLE_ID }}
APPLE_ID_PASSWORD: ${{ secrets.APPLE_ID_PASSWORD }}
APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.APPLE_APP_SPECIFIC_PASSWORD }}
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
USE_HARD_LINKS: false

# Check Binary Size
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/monokle-publish-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ jobs:
CSC_KEY_PASSWORD: ${{ secrets.MONOKLE_MACOS_CERTS_PASSWORD }}
APPLE_ID: ${{ secrets.APPLE_ID }}
APPLE_ID_PASSWORD: ${{ secrets.APPLE_ID_PASSWORD }}
APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.APPLE_APP_SPECIFIC_PASSWORD }}
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
USE_HARD_LINKS: false

# Check Binary Size
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/monokle-publish-updater.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ jobs:
CSC_KEY_PASSWORD: ${{ secrets.MONOKLE_MACOS_CERTS_PASSWORD }}
APPLE_ID: ${{ secrets.APPLE_ID }}
APPLE_ID_PASSWORD: ${{ secrets.APPLE_ID_PASSWORD }}
APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.APPLE_APP_SPECIFIC_PASSWORD }}
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
USE_HARD_LINKS: false

# Check Binary Size
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/monokle-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ jobs:
CSC_KEY_PASSWORD: ${{ secrets.MONOKLE_MACOS_CERTS_PASSWORD }}
APPLE_ID: ${{ secrets.APPLE_ID }}
APPLE_ID_PASSWORD: ${{ secrets.APPLE_ID_PASSWORD }}
APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.APPLE_APP_SPECIFIC_PASSWORD }}
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
USE_HARD_LINKS: false

# Check Binary Size
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

## [2.4.0](https://github.com/kubeshop/monokle/compare/v2.4.1-nightly-2023-09-28.0...v2.4.0) (2023-09-28)


### Features

* compare clusters in quick cluster mode ([c9c0a12](https://github.com/kubeshop/monokle/commit/c9c0a12cb21eb65d99aa315082ff1501ef692b07))

### [2.3.3](https://github.com/kubeshop/monokle/compare/v2.3.3-nightly-2023-07-26.0...v2.3.3) (2023-07-26)


Expand Down
2 changes: 1 addition & 1 deletion electron/app/autoUpdater.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {AppImageUpdater, MacUpdater, NsisUpdater} from 'electron-updater';
import {GenericServerOptions} from 'electron-updater/node_modules/builder-util-runtime';

import {GenericServerOptions} from 'builder-util-runtime';
import {join} from 'path';

const isDev = process.env.NODE_ENV === 'development';
Expand Down
1 change: 1 addition & 0 deletions electron/app/ipc/ipcListeners.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import {
selectFileDialog,
} from '../commands';
import {ProjectNameChange, StorePropagation} from '../models';
import '../services/cloud/ipc';
import '../services/cluster/ipc';
import {downloadPlugin, updatePlugin} from '../services/pluginService';
import {
Expand Down
7 changes: 1 addition & 6 deletions electron/app/ipc/ipcMainRedux.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const createDispatchForWindow = (window: BrowserWindow) => {

export const dispatchToFocusedWindow = (action: AnyAction) => {
const focusedWebContents = webContents.getFocusedWebContents();
focusedWebContents.send('redux-dispatch', action);
focusedWebContents?.send('redux-dispatch', action);
};

export const fetchStoreState = (contents: WebContents) => {
Expand All @@ -51,11 +51,6 @@ export const fetchStoreState = (contents: WebContents) => {
);
};

export const fetchFocusedWindowStoreState = () => {
const focusedWebContents = webContents.getFocusedWebContents();
return fetchStoreState(focusedWebContents);
};

export const subscribeToStoreStateChanges = (
contents: WebContents,
propertiesToPick: string[],
Expand Down
22 changes: 22 additions & 0 deletions electron/app/services/cloud/authenticator.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import {app} from 'electron';

import {join} from 'path';

import {Authenticator, StorageHandlerAuth, createDefaultMonokleAuthenticator} from '@monokle/synchronizer';

let authenticator: Authenticator | undefined;

const initAuthenticator = async (cloudStorageDir: string) => {
const newAuthenticator = createDefaultMonokleAuthenticator(new StorageHandlerAuth(cloudStorageDir));
authenticator = newAuthenticator;
return newAuthenticator;
};

export const getAuthenticator = async () => {
const userDataDir = app.getPath('userData');
const cloudStorageDir = join(userDataDir, 'cloud');
if (!authenticator) {
await initAuthenticator(cloudStorageDir);
}
return authenticator;
};
11 changes: 11 additions & 0 deletions electron/app/services/cloud/ipc.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import {handleIpc} from '../../utils/ipc';
import {cloudLogin, cloudLogout} from './login';
import {getPolicy} from './policy';
import {getInfo} from './project';
import {getSerializedUser} from './user';

handleIpc('cloud:login', cloudLogin);
handleIpc('cloud:logout', cloudLogout);
handleIpc('cloud:getUser', getSerializedUser);
handleIpc('cloud:getPolicy', getPolicy);
handleIpc('cloud:getInfo', getInfo);
28 changes: 28 additions & 0 deletions electron/app/services/cloud/login.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import {shell} from 'electron';

import {CloudLoginResponse} from '@shared/models/cloud';

import {getAuthenticator} from './authenticator';
import {serializeUser} from './user';

export const cloudLogin = async (): Promise<CloudLoginResponse> => {
const authenticator = await getAuthenticator();
if (!authenticator) {
throw new Error('Something went wrong with the authenticator');
}
const loginResponse = await authenticator.login('device code');
if (!loginResponse.handle) {
throw new Error('Something went wrong with the login response');
}
shell.openExternal(loginResponse.handle.verification_uri_complete);
const user = await loginResponse.onDone;
if (!user) {
throw new Error('Login to Cloud has failed. Please try again later.');
}
return {user: serializeUser(user)};
};

export const cloudLogout = async (): Promise<void> => {
const authenticator = await getAuthenticator();
await authenticator?.logout();
};
23 changes: 23 additions & 0 deletions electron/app/services/cloud/policy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import log from 'loglevel';

import {getSynchronizer} from './synchronizer';
import {getUser} from './user';

export const getPolicy = async (repoPath: string) => {
const synchronizer = await getSynchronizer();
const user = await getUser();
if (!user?.token || !synchronizer) {
return null;
}

try {
const policy = await synchronizer.getPolicy(repoPath, true, user.token);
return policy;
} catch (e: any) {
if (e instanceof Error) {
log.warn(e.message);
}
log.warn('Failed to synchronize policy');
}
return null;
};
26 changes: 26 additions & 0 deletions electron/app/services/cloud/project.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import {CloudPolicyInfo, CloudProjectInfo} from '@shared/models/cloud';

import {getSynchronizer} from './synchronizer';
import {getUser} from './user';

export const getInfo = async (
repoPath: string
): Promise<{projectInfo: CloudProjectInfo; policyInfo: CloudPolicyInfo} | null> => {
const synchronizer = await getSynchronizer();
const user = await getUser();
if (!user?.token || !synchronizer) {
return null;
}

try {
const project = await synchronizer?.getProjectInfo(repoPath, user.token, true);
return project
? {
projectInfo: {...project, link: synchronizer.generateDeepLinkProject(project.slug)},
policyInfo: {link: synchronizer.generateDeepLinkProjectPolicy(project.slug)},
}
: null;
} catch {
return null;
}
};
22 changes: 22 additions & 0 deletions electron/app/services/cloud/synchronizer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import {app} from 'electron';

import {join} from 'path';

import {StorageHandlerPolicy, Synchronizer, createDefaultMonokleSynchronizer} from '@monokle/synchronizer';

let synchronizer: Synchronizer | undefined;

const initSynchronizer = async (cloudStorageDir: string) => {
const newSynchronizer = createDefaultMonokleSynchronizer(new StorageHandlerPolicy(cloudStorageDir));
synchronizer = newSynchronizer;
return newSynchronizer;
};

export const getSynchronizer = async () => {
const userDataDir = app.getPath('userData');
const cloudStorageDir = join(userDataDir, 'cloud');
if (!synchronizer) {
await initSynchronizer(cloudStorageDir);
}
return synchronizer;
};
45 changes: 45 additions & 0 deletions electron/app/services/cloud/user.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import log from 'loglevel';

import {User} from '@monokle/synchronizer';
import {CloudUser} from '@shared/models/cloud';

import {getAuthenticator} from './authenticator';

export const getUser = async (): Promise<User | undefined> => {
const authenticator = await getAuthenticator();
if (!authenticator) {
return undefined;
}
try {
const user = await authenticator.getUser();
if (!user.isAuthenticated) {
return undefined;
}
return user;
} catch (e: any) {
log.warn(e.message);
return undefined;
}
};

export const getSerializedUser = async (): Promise<CloudUser | undefined> => {
const user = await getUser();
if (!user) {
return undefined;
}
try {
const serializedUser = serializeUser(user);
return serializedUser;
} catch {
return undefined;
}
};

export const serializeUser = (user: User): CloudUser => {
if (!user.email) {
throw new Error('User not found');
}
return {
email: user.email,
};
};
4 changes: 3 additions & 1 deletion notarization/afterSignHook.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,12 @@ module.exports = async function (params) {

try {
await electron_notarize.notarize({
tool: 'notarytool',
teamId: process.env.APPLE_TEAM_ID,
appBundleId: appId,
appPath: appPath,
appleId: process.env.APPLE_ID,
appleIdPassword: process.env.APPLE_ID_PASSWORD,
appleIdPassword: process.env.APPLE_APP_SPECIFIC_PASSWORD,
});
} catch (error) {
log.error(error);
Expand Down
Loading

0 comments on commit bda33cd

Please sign in to comment.