Skip to content

Commit a4cbe33

Browse files
committed
Merge branch 'main' into feature/github-oauth
2 parents aab1ecf + 68ac092 commit a4cbe33

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

src/knative.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@ export class Knative {
117117
kind: "Service",
118118
metadata: {
119119
name: service.name,
120-
namespace: namespace,
121120
labels: {
122121
"app.kubernetes.io/managed-by": "deploycat",
123122
},

src/lib/config.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import { z } from "zod";
22
import fs from "fs/promises";
33
import merge from "deepmerge";
4+
import { isServer } from "solid-js/web";
45

5-
const configPath = `${process.cwd()}/config.json`;
6+
const configPath = process.cwd?.() && `${process.cwd()}/config.json`;
67

78
const schemaConfig = z.object({
89
database: z.object({
@@ -20,7 +21,7 @@ const schemaConfig = z.object({
2021
}),
2122
});
2223

23-
const parseEnv = ({ prefix = "", envs = process.env } = {}) => {
24+
const parseEnv = ({ prefix = "", envs = process.env ?? {} } = {}) => {
2425
const parsed = {} as any;
2526
Object.entries(envs).forEach(([key, value]) => {
2627
const seq = (obj: any, arr: Array<string>, v: string | undefined) => {
@@ -36,10 +37,11 @@ const parseEnv = ({ prefix = "", envs = process.env } = {}) => {
3637
const keyArr = key.split("_").map((e) => e.toLocaleLowerCase());
3738
seq(parsed, keyArr, value);
3839
});
39-
return prefix !== "" ? parsed?.[prefix] : parsed;
40+
return prefix !== "" ? parsed?.[prefix] ?? {} : parsed;
4041
};
4142

4243
const parseJSON = async () => {
44+
if (!configPath) return {};
4345
try {
4446
return JSON.parse((await fs.readFile(configPath)).toString());
4547
} catch (e) {
@@ -54,4 +56,4 @@ const getConfig = async () => {
5456
return config;
5557
};
5658

57-
export const config = schemaConfig.parse(await getConfig());
59+
export const config = isServer ? schemaConfig.parse(await getConfig()) : {};

src/lib/prometheus.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ import { getUser } from "./server";
33
import { knative } from "~/k8s";
44
import { config } from "./config";
55

6-
const baseUrl = `${config.prometheus.url}/api/v1`;
7-
86
export const rangeQuery = async ({
97
query,
108
start,
@@ -16,6 +14,7 @@ export const rangeQuery = async ({
1614
end: Date;
1715
step: number;
1816
}) => {
17+
const baseUrl = `${config.prometheus.url}/api/v1`;
1918
const url = new URL(`${baseUrl}/query_range`);
2019
url.search = new URLSearchParams({
2120
query,

0 commit comments

Comments
 (0)