Compare commits

...

5 Commits

Author SHA1 Message Date
Aarnav Tale a7e4f3e4d2 chore: v0.5.1 2025-02-28 12:21:00 -05:00
Aarnav Tale 40ddb69bc9 fix: resolve latest tags being set 2025-02-28 12:19:14 -05:00
Aarnav Tale 6aa6e77611 chore: fix globalThis typings 2025-02-28 12:17:58 -05:00
Aarnav Tale c5c2f8a93b fix: use context for k8s config 2025-02-28 11:29:31 -05:00
Aarnav Tale acd042b4de fix: define globals correctly 2025-02-28 11:29:11 -05:00
6 changed files with 21 additions and 19 deletions
+1 -1
View File
@@ -33,7 +33,7 @@ jobs:
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=raw,value=latest,enable=false
- name: Build and push Docker image
uses: docker/build-push-action@v5
+5
View File
@@ -1,3 +1,8 @@
### 0.5.1 (February 28, 2025)
- Fixed an issue that caused the entire server to crash on start
- Fixed the published semver tags from Docker
- Fixed the Kubernetes integration not reading the config
### 0.5 (February 27, 2025)
- Completely redesigned the UI from the ground up for accessibility and performance.
- Switched to a config-file setup (this introduces breaking changes, see [config.example.yaml](/config.example.yaml) for the new format).
+2 -2
View File
@@ -58,10 +58,10 @@ export default class KubernetesIntegration extends Integration<T> {
);
// Some very ugly nesting but it's necessary
if (process.env.HEADSCALE_INTEGRATION_UNSTRICT === 'true') {
if (this.context.validate_manifest === false) {
log.warn('INTG', 'Skipping strict Pod status check');
} else {
const pod = process.env.POD_NAME;
const pod = this.context.pod_name;
if (!pod) {
log.error('INTG', 'Missing POD_NAME variable');
return false;
+6 -9
View File
@@ -1,4 +1,5 @@
import { constants, access, readFile } from 'node:fs/promises';
import { env } from 'node:process';
import { type } from 'arktype';
import dotenv from 'dotenv';
import { parseDocument } from 'yaml';
@@ -7,7 +8,7 @@ import log, { hpServer_loadLogger } from '~server/utils/log';
import mutex from '~server/utils/mutex';
import { HeadplaneConfig, coalesceConfig, validateConfig } from './parser';
declare global {
declare namespace globalThis {
let __cookie_context: {
cookie_secret: string;
cookie_secure: boolean;
@@ -63,9 +64,9 @@ export async function hp_loadConfig() {
let path = HEADPLANE_DEFAULT_CONFIG_PATH;
const envs = rootEnvs({
HEADPLANE_DEBUG_LOG: process.env.HEADPLANE_DEBUG_LOG,
HEADPLANE_CONFIG_PATH: process.env.HEADPLANE_CONFIG_PATH,
HEADPLANE_LOAD_ENV_OVERRIDES: process.env.HEADPLANE_LOAD_ENV_OVERRIDES,
HEADPLANE_DEBUG_LOG: env.HEADPLANE_DEBUG_LOG,
HEADPLANE_CONFIG_PATH: env.HEADPLANE_CONFIG_PATH,
HEADPLANE_LOAD_ENV_OVERRIDES: env.HEADPLANE_LOAD_ENV_OVERRIDES,
});
if (envs instanceof type.errors) {
@@ -79,7 +80,6 @@ export async function hp_loadConfig() {
// Load our debug based logger before ANYTHING
hpServer_loadLogger(envs.HEADPLANE_DEBUG_LOG);
if (envs.HEADPLANE_CONFIG_PATH) {
path = envs.HEADPLANE_CONFIG_PATH;
}
@@ -117,20 +117,17 @@ export async function hp_loadConfig() {
testOidc(config.oidc);
}
// @ts-expect-error: If we remove globalThis we get a runtime error
globalThis.__cookie_context = {
cookie_secret: config.server.cookie_secret,
cookie_secure: config.server.cookie_secure,
};
// @ts-expect-error: If we remove globalThis we get a runtime error
globalThis.__hs_context = {
url: config.headscale.url,
config_path: config.headscale.config_path,
config_strict: config.headscale.config_strict,
};
// @ts-expect-error: If we remove globalThis we get a runtime error
globalThis.__integration_context = config.integration;
runtimeConfig = config;
@@ -190,7 +187,7 @@ function coalesceEnv(config: HeadplaneConfig) {
const rootKeys: string[] = rootEnvs.props.map((prop) => prop.key);
// Typescript is still insanely stupid at nullish filtering
const vars = Object.entries(process.env).filter(([key, value]) => {
const vars = Object.entries(env).filter(([key, value]) => {
if (!value) {
return false;
}
+1
View File
@@ -37,6 +37,7 @@ const dockerConfig = type({
const kubernetesConfig = type({
enabled: stringToBool,
pod_name: 'string',
validate_manifest: stringToBool,
});
+6 -7
View File
@@ -9,20 +9,19 @@ import mime from 'mime/lite';
import appContext from '~server/context/app';
import { loadDevtools, stacksafeTry } from '~server/dev/hot-server';
import prodBuild from '~server/prod-handler';
import { hp_loadConfig } from './context/loader';
declare global {
// Prefix is a build-time constant
const __hp_prefix: string;
}
const devtools = import.meta.env.DEV ? await loadDevtools() : undefined;
const prodHandler = import.meta.env.PROD ? await prodBuild() : undefined;
const buildPath = process.env.BUILD_PATH ?? './build';
const baseDir = resolve(join(buildPath, 'client'));
export const listener: RequestListener = async (req, res) => {
await hp_loadConfig();
const devtools = import.meta.env.DEV ? await loadDevtools() : undefined;
const prodHandler = import.meta.env.PROD ? await prodBuild() : undefined;
const baseDir = resolve(join('./build', 'client'));
const url = new URL(`http://${req.headers.host}${req.url}`);
// build:strip