drop the unused hawser stacks-dir column and layout
This commit is contained in:
10 files changed
+2
-7528
No files matched your search
@@ -1 +0,0 @@
|
||||
ALTER TABLE "environments" ADD COLUMN "hawser_stacks_dir" text;
|
||||
File diff suppressed because it is too large.
Load diff
@@ -106,13 +106,6 @@
|
||||
"when": 1787468505425,
|
||||
"tag": "0014_backup_tls_and_container_icons",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 15,
|
||||
"version": "7",
|
||||
"when": 1787600000000,
|
||||
"tag": "0015_hawser_stacks_dir",
|
||||
"breakpoints": true
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
ALTER TABLE `environments` ADD `hawser_stacks_dir` text;
|
||||
File diff suppressed because it is too large.
Load diff
@@ -106,13 +106,6 @@
|
||||
"when": 1787468495122,
|
||||
"tag": "0014_backup_tls_and_container_icons",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 15,
|
||||
"version": "6",
|
||||
"when": 1787600000000,
|
||||
"tag": "0015_hawser_stacks_dir",
|
||||
"breakpoints": true
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -44,7 +44,6 @@ export const environments = sqliteTable('environments', {
|
||||
hawserAgentName: text('hawser_agent_name'),
|
||||
hawserVersion: text('hawser_version'),
|
||||
hawserCapabilities: text('hawser_capabilities'), // JSON array: ["compose", "exec", "metrics"]
|
||||
hawserStacksDir: text('hawser_stacks_dir'), // Remote STACKS_DIR reported by agent
|
||||
createdAt: text('created_at').default(sql`CURRENT_TIMESTAMP`),
|
||||
updatedAt: text('updated_at').default(sql`CURRENT_TIMESTAMP`)
|
||||
});
|
||||
|
||||
@@ -47,7 +47,6 @@ export const environments = pgTable('environments', {
|
||||
hawserAgentName: text('hawser_agent_name'),
|
||||
hawserVersion: text('hawser_version'),
|
||||
hawserCapabilities: text('hawser_capabilities'), // JSON array: ["compose", "exec", "metrics"]
|
||||
hawserStacksDir: text('hawser_stacks_dir'), // Remote STACKS_DIR reported by agent
|
||||
createdAt: timestamp('created_at', { mode: 'string' }).defaultNow(),
|
||||
updatedAt: timestamp('updated_at', { mode: 'string' }).defaultNow()
|
||||
});
|
||||
|
||||
@@ -1,72 +0,0 @@
|
||||
import { join, relative, resolve } from 'node:path';
|
||||
import { isPathUnderRoot } from './path-utils';
|
||||
|
||||
function remapPathBetweenStackDirs(fromDir: string, toDir: string, path: string): string {
|
||||
const fromResolved = resolve(fromDir);
|
||||
const toResolved = resolve(toDir);
|
||||
const resolved = resolve(path);
|
||||
if (isPathUnderRoot(resolved, fromResolved)) {
|
||||
return join(toResolved, relative(fromResolved, resolved));
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
function remapPathsBetweenStackDirs(fromDir: string, toDir: string, paths: string[]): string[] {
|
||||
return paths.map((p) => remapPathBetweenStackDirs(fromDir, toDir, p));
|
||||
}
|
||||
|
||||
function remapComposeContentsBetweenStackDirs(
|
||||
fromDir: string,
|
||||
toDir: string,
|
||||
contents: Record<string, string>
|
||||
): Record<string, string> {
|
||||
const remapped: Record<string, string> = {};
|
||||
for (const [path, content] of Object.entries(contents)) {
|
||||
remapped[remapPathBetweenStackDirs(fromDir, toDir, path)] = content;
|
||||
}
|
||||
return remapped;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remap absolute paths from Dockhand's Hawser staging dir to the remote host stack dir.
|
||||
*/
|
||||
export function remapPathsFromStagingToRemote(
|
||||
stagingStackDir: string,
|
||||
remoteStackDir: string,
|
||||
paths: string[]
|
||||
): string[] {
|
||||
return remapPathsBetweenStackDirs(stagingStackDir, remoteStackDir, paths);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remap absolute paths from the Hawser remote stack dir back to Dockhand staging.
|
||||
*/
|
||||
export function remapPathsFromRemoteToStaging(
|
||||
stagingStackDir: string,
|
||||
remoteStackDir: string,
|
||||
paths: string[]
|
||||
): string[] {
|
||||
return remapPathsBetweenStackDirs(remoteStackDir, stagingStackDir, paths);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remap composeContents keys from staging paths to remote display paths.
|
||||
*/
|
||||
export function remapComposeContentsFromStagingToRemote(
|
||||
stagingStackDir: string,
|
||||
remoteStackDir: string,
|
||||
contents: Record<string, string>
|
||||
): Record<string, string> {
|
||||
return remapComposeContentsBetweenStackDirs(stagingStackDir, remoteStackDir, contents);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remap composeContents keys from remote display paths back to staging paths.
|
||||
*/
|
||||
export function remapComposeContentsFromRemoteToStaging(
|
||||
stagingStackDir: string,
|
||||
remoteStackDir: string,
|
||||
contents: Record<string, string>
|
||||
): Record<string, string> {
|
||||
return remapComposeContentsBetweenStackDirs(remoteStackDir, stagingStackDir, contents);
|
||||
}
|
||||
@@ -1,95 +0,0 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import { describe, it } from 'node:test';
|
||||
import { join } from 'node:path';
|
||||
import {
|
||||
remapComposeContentsFromRemoteToStaging,
|
||||
remapComposeContentsFromStagingToRemote,
|
||||
remapPathsFromRemoteToStaging,
|
||||
remapPathsFromStagingToRemote
|
||||
} from '../src/lib/server/stacks-display-paths';
|
||||
|
||||
describe('remapPathsFromStagingToRemote', () => {
|
||||
it('remaps compose paths from Dockhand staging to Hawser STACKS_DIR', () => {
|
||||
const staging = '/opt/docker/data/dockhand/stacks/nexz447/linkleaner';
|
||||
const remote = '/opt/docker/stacks/linkleaner';
|
||||
const paths = [
|
||||
join(staging, 'compose.yaml'),
|
||||
join(staging, 'compose.override.yaml')
|
||||
];
|
||||
|
||||
const remapped = remapPathsFromStagingToRemote(staging, remote, paths);
|
||||
|
||||
assert.deepEqual(remapped, [
|
||||
join(remote, 'compose.yaml'),
|
||||
join(remote, 'compose.override.yaml')
|
||||
]);
|
||||
});
|
||||
|
||||
it('leaves paths outside the staging dir unchanged', () => {
|
||||
const staging = '/data/stacks/prod/myapp';
|
||||
const remote = '/opt/stacks/myapp';
|
||||
const external = '/srv/custom/myapp/compose.yaml';
|
||||
|
||||
const remapped = remapPathsFromStagingToRemote(staging, remote, [external]);
|
||||
|
||||
assert.deepEqual(remapped, [external]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('remapPathsFromRemoteToStaging', () => {
|
||||
it('remaps compose paths from Hawser STACKS_DIR back to Dockhand staging', () => {
|
||||
const staging = '/opt/docker/data/dockhand/stacks/nexz447/linkleaner';
|
||||
const remote = '/opt/docker/stacks/linkleaner';
|
||||
const paths = [
|
||||
join(remote, 'compose.yaml'),
|
||||
join(remote, 'compose.override.yaml')
|
||||
];
|
||||
|
||||
const remapped = remapPathsFromRemoteToStaging(staging, remote, paths);
|
||||
|
||||
assert.deepEqual(remapped, [
|
||||
join(staging, 'compose.yaml'),
|
||||
join(staging, 'compose.override.yaml')
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('remapComposeContentsFromStagingToRemote', () => {
|
||||
it('remaps composeContents keys to remote display paths', () => {
|
||||
const staging = '/opt/docker/data/dockhand/stacks/prod/linkleaner';
|
||||
const remote = '/opt/docker/stacks/linkleaner';
|
||||
const contents = {
|
||||
[join(staging, 'compose.yaml')]: 'services:\n app:\n image: app',
|
||||
[join(staging, 'compose.override.yaml')]: 'services:\n app:\n ports:\n - 8080:80'
|
||||
};
|
||||
|
||||
const remapped = remapComposeContentsFromStagingToRemote(staging, remote, contents);
|
||||
|
||||
assert.equal(remapped[join(remote, 'compose.yaml')], contents[join(staging, 'compose.yaml')]);
|
||||
assert.equal(
|
||||
remapped[join(remote, 'compose.override.yaml')],
|
||||
contents[join(staging, 'compose.override.yaml')]
|
||||
);
|
||||
assert.equal(Object.keys(remapped).length, 2);
|
||||
});
|
||||
});
|
||||
|
||||
describe('remapComposeContentsFromRemoteToStaging', () => {
|
||||
it('remaps composeContents keys back to staging paths', () => {
|
||||
const staging = '/opt/docker/data/dockhand/stacks/prod/linkleaner';
|
||||
const remote = '/opt/docker/stacks/linkleaner';
|
||||
const contents = {
|
||||
[join(remote, 'compose.yaml')]: 'services:\n app:\n image: app',
|
||||
[join(remote, 'compose.override.yaml')]: 'services:\n app:\n ports:\n - 8080:80'
|
||||
};
|
||||
|
||||
const remapped = remapComposeContentsFromRemoteToStaging(staging, remote, contents);
|
||||
|
||||
assert.equal(remapped[join(staging, 'compose.yaml')], contents[join(remote, 'compose.yaml')]);
|
||||
assert.equal(
|
||||
remapped[join(staging, 'compose.override.yaml')],
|
||||
contents[join(remote, 'compose.override.yaml')]
|
||||
);
|
||||
assert.equal(Object.keys(remapped).length, 2);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user