Skip to content

Commit

Permalink
Merge branch 'release/v2.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
mms-gianni committed Mar 25, 2024
2 parents 91cbc25 + df625d0 commit caa80d8
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 5 deletions.
7 changes: 6 additions & 1 deletion client/src/layouts/default/Default.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ kuberoStore.kubero.socket = socket;
type Message = {
action: string,
pipelineName: string,
text?: string,
pipelineName?: string,
phaseName?: string,
appName?: string,
data?: any
Expand All @@ -51,6 +52,10 @@ socket.on('updatedPipelines', (message: Message) => {
triggerToast('success', 'Pipeline '+message.action, text);
});
socket.on('updatedKuberoSettings', (message: Message) => {
triggerToast('success', 'Kubero System', message.text ?? '');
});
function triggerToast(icon: SweetAlertIcon, title: string, text: string) {
Swal.fire({
toast: true,
Expand Down
4 changes: 3 additions & 1 deletion server/src/configure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,9 @@ export const configure = async (app: Express, server: Server) => {

const settings = new Settings({
kubectl: kubero.kubectl,
config: kubero.config
config: kubero.config,
audit: audit,
io: sockets,
});
app.locals.settings = settings;
}
27 changes: 26 additions & 1 deletion server/src/modules/settings.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,30 @@
import { Kubectl } from './kubectl';
import { IKuberoConfig} from '../types';
import { IKuberoConfig, IMessage} from '../types';
import { KuberoConfig } from './config';
import YAML from 'yaml'
import { readFileSync, writeFileSync } from 'fs';
import { join } from 'path';
import { Audit } from './audit';

export interface SettingsOptions {
kubectl: Kubectl;
config: IKuberoConfig;
audit: Audit;
io: any;
}

export class Settings {
private kubectl: Kubectl;
private runningConfig: IKuberoConfig
private audit: Audit;
private _io: any;
constructor(
options: SettingsOptions
) {
this.kubectl = options.kubectl
this.runningConfig = options.config
this.audit = options.audit
this._io = options.io
}

public async getSettings(): Promise<any> {
Expand Down Expand Up @@ -84,6 +91,24 @@ export class Settings {
this.kubectl.updateKuberoSecret(namespace, config.secrets)
this.setEnv(config.secrets)

this.audit?.log({
user: 'kubero',
severity: 'normal',
action: 'update',
namespace: '',
phase: '',
app: '',
pipeline: '',
resource: 'system',
message: 'kubero settings updated',
});
const message = {
'action': 'updated',
'text': 'Kubero settings updated',
'data': {}
} as IMessage;
this._io.emit('updatedKuberoSettings', message);


return kuberoes
}
Expand Down
5 changes: 3 additions & 2 deletions server/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -388,9 +388,10 @@ export interface ILoglines {

export interface IMessage {
action: string,
text?: string,
appName?: string,
pipelineName: string,
phaseName: string,
pipelineName?: string,
phaseName?: string,
data?: any
}

Expand Down

0 comments on commit caa80d8

Please sign in to comment.