Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/dappmanager/src/api/routes/packageManifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ export const packageManifest = wrapHandler<Params>(async (req, res) => {
"links",
"repository",
"bugs",
"license"
"license",
"notifications"
]);

res.status(200).send(filteredManifest);
Expand Down
14 changes: 10 additions & 4 deletions packages/installer/src/dappnodeInstaller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import {
PackageRequest,
SetupWizard,
GrafanaDashboard,
PrometheusTarget
PrometheusTarget,
GatusConfig
} from "@dappnode/types";
import { DappGetState, DappgetOptions, dappGet } from "./dappGet/index.js";
import { validateDappnodeCompose, validateManifestSchema } from "@dappnode/schemas";
Expand Down Expand Up @@ -72,7 +73,8 @@ export class DappnodeInstaller extends DappnodeRepository {
disclaimer: pkgRelease.disclaimer,
gettingStarted: pkgRelease.gettingStarted,
grafanaDashboards: pkgRelease.grafanaDashboards,
prometheusTargets: pkgRelease.prometheusTargets
prometheusTargets: pkgRelease.prometheusTargets,
notifications: pkgRelease.notifications
});

// set compose to custom dappnode compose in release
Expand Down Expand Up @@ -107,7 +109,8 @@ export class DappnodeInstaller extends DappnodeRepository {
disclaimer: pkgRelease.disclaimer,
gettingStarted: pkgRelease.gettingStarted,
grafanaDashboards: pkgRelease.grafanaDashboards,
prometheusTargets: pkgRelease.prometheusTargets
prometheusTargets: pkgRelease.prometheusTargets,
notifications: pkgRelease.notifications
});
});

Expand Down Expand Up @@ -151,20 +154,23 @@ export class DappnodeInstaller extends DappnodeRepository {
disclaimer,
gettingStarted,
prometheusTargets,
grafanaDashboards
grafanaDashboards,
notifications
}: {
manifest: Manifest;
SetupWizard?: SetupWizard;
disclaimer?: string;
gettingStarted?: string;
prometheusTargets?: PrometheusTarget[];
grafanaDashboards?: GrafanaDashboard[];
notifications?: GatusConfig;
}): Manifest {
if (SetupWizard) manifest.setupWizard = SetupWizard;
if (disclaimer) manifest.disclaimer = { message: disclaimer };
if (gettingStarted) manifest.gettingStarted = gettingStarted;
if (prometheusTargets) manifest.prometheusTargets = prometheusTargets;
if (grafanaDashboards && grafanaDashboards.length > 0) manifest.grafanaDashboards = grafanaDashboards;
if (notifications) manifest.notifications = notifications;

return manifest;
}
Expand Down
4 changes: 3 additions & 1 deletion packages/installer/test/unit/release/findEntries.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ describe("validateTarImage", () => {
"host-grafana-dashboard.json",
"prometheus-targets.json",
"setup-wizard.json",
"signature.json"
"signature.json",
"notifications.yaml"
].map((name) => ({
name,
path: `Qm-root/${name}`,
Expand All @@ -70,6 +71,7 @@ describe("validateTarImage", () => {
disclaimer: "disclaimer.md",
gettingStarted: "getting-started.md",
prometheusTargets: "prometheus-targets.json",
notifications: "notifications.yaml",
grafanaDashboards: ["docker-grafana-dashboard.json", "host-grafana-dashboard.json"]
};

Expand Down
4 changes: 2 additions & 2 deletions packages/toolkit/src/repository/repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ export class DappnodeRepository extends ApmRepository {
private async pinAddNoThrow(hash: any): Promise<void> {
try {
await this.ipfs.pin.add(hash);

} catch (e) {
// Do not spam the terminal
// console.error(`Error pinning ${hash}`, e);
Expand Down Expand Up @@ -205,7 +204,8 @@ export class DappnodeRepository extends ApmRepository {
disclaimer: await this.getPkgAsset(releaseFilesToDownload.disclaimer, ipfsEntries),
gettingStarted: await this.getPkgAsset(releaseFilesToDownload.gettingStarted, ipfsEntries),
prometheusTargets: await this.getPkgAsset(releaseFilesToDownload.prometheusTargets, ipfsEntries),
grafanaDashboards: await this.getPkgAsset(releaseFilesToDownload.grafanaDashboards, ipfsEntries)
grafanaDashboards: await this.getPkgAsset(releaseFilesToDownload.grafanaDashboards, ipfsEntries),
notifications: await this.getPkgAsset(releaseFilesToDownload.notifications, ipfsEntries)
};
}

Expand Down
1 change: 1 addition & 0 deletions packages/types/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export * from "./releaseFiles.js";
export * from "./errors.js";
export * from "./routes.js";
export * from "./subscriptions.js";
export * from "./notifications.js";

// utils
export * from "./utils/index.js";
4 changes: 4 additions & 0 deletions packages/types/src/manifest.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { GatusConfig } from "./notifications.js";
import { SetupSchema, SetupTarget, SetupUiJson, SetupWizard } from "./setupWizard.js";

export interface Manifest {
Expand Down Expand Up @@ -98,6 +99,9 @@ export interface Manifest {

// setupWizard for compacted manifests in core packages
setupWizard?: SetupWizard;

// notifications
notifications?: GatusConfig;
}

export interface UpstreamItem {
Expand Down
47 changes: 47 additions & 0 deletions packages/types/src/notifications.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
export interface Notification {
title: string;
body: string;
dnpName: string;
timestamp: string;
category: string;
seen: boolean;
callToAction?: {
title: string;
url: string;
};
}

export interface GatusConfig {
endpoints: Endpoint[];
}

export interface Endpoint {
name: string;
enabled: boolean;
url: string;
method: string;
conditions: string[];
interval: string; // e.g., "1m"
group: string;
alerts: Alert[];
definition: {
// dappnode specific
title: string;
description: string;
};
metric?: {
// dappnode specific
min: number;
max: number;
unit: string; // e.g ºC
};
}

interface Alert {
type: string;
"failure-threshold": number;
"success-threshold": number;
"send-on-resolved": boolean;
description: string;
enabled: boolean;
}
2 changes: 2 additions & 0 deletions packages/types/src/pkg.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Compose } from "./compose.js";
import { Manifest, PrometheusTarget, GrafanaDashboard } from "./manifest.js";
import { GatusConfig } from "./notifications.js";
import { SetupWizard } from "./setupWizard.js";

/**
Expand Down Expand Up @@ -97,6 +98,7 @@ export type DirectoryFiles = {
gettingStarted?: string;
prometheusTargets?: PrometheusTarget[];
grafanaDashboards?: GrafanaDashboard[];
notifications?: GatusConfig;
};

export interface FileConfig {
Expand Down
10 changes: 9 additions & 1 deletion packages/types/src/releaseFiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,13 @@ export const releaseFiles = Object.freeze({
maxSize: 10e6, // ~ 10MB
required: false as const,
multiple: true as const
}),
notifications: Object.freeze({
regex: /^.*notifications\.yaml$/,
format: FileFormat.YAML,
maxSize: 10e3,
required: false as const,
multiple: false as const
})
} as const);

Expand All @@ -95,5 +102,6 @@ export const releaseFilesToDownload = {
disclaimer: releaseFiles.disclaimer,
gettingStarted: releaseFiles.gettingStarted,
prometheusTargets: releaseFiles.prometheusTargets,
grafanaDashboards: releaseFiles.grafanaDashboards
grafanaDashboards: releaseFiles.grafanaDashboards,
notifications: releaseFiles.notifications
};
Loading