Skip to content

Commit

Permalink
fix: acl parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
LucaRickli committed Nov 23, 2024
1 parent 13fbfdb commit 91a9e0a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/lib/api/headscale.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export interface V1Policy {
*/
Hosts: { [x: string]: string };
acls: {
action: 'accept';
action: string;
proto?: string;
src: string[];
dst: string[];
Expand Down Expand Up @@ -690,7 +690,7 @@ export class Acl {
} catch (err) {
return {
...response,
data: undefined,
data: new Acl({}),
error: err
};
}
Expand Down
15 changes: 13 additions & 2 deletions src/routes/(app)/+page.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Acl, formatApiErrors, Headscale, Machine, Route, User } from '$lib/api/index.js';
import { Acl, ApiError, formatApiErrors, Headscale, Machine, Route, User } from '$lib/api/index.js';

export async function load({ data, fetch }) {
const headscale = new Headscale({ fetch });
Expand All @@ -16,6 +16,17 @@ export async function load({ data, fetch }) {
users: users.data,
routes: routes.data,
machines: machines.data,
errors: formatApiErrors([machines.error, routes.error, users.error, acl.error])
errors: (
formatApiErrors([
machines.error,
routes.error,
users.error,
acl.error instanceof ApiError ? acl.error : undefined
]) as unknown[]
).concat(
acl.error !== null && typeof acl.error !== 'undefined' && !(acl.error instanceof ApiError)
? [acl.error]
: []
)
};
}

0 comments on commit 91a9e0a

Please sign in to comment.