Skip to content

Commit

Permalink
stub for zfs apply config
Browse files Browse the repository at this point in the history
  • Loading branch information
mpyne1 committed Jan 23, 2025
1 parent 7878419 commit 149914e
Showing 2 changed files with 18 additions and 10 deletions.
24 changes: 18 additions & 6 deletions houston-common-lib/lib/managers/easysetup/manager.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Result, ResultAsync } from "neverthrow";
import { EasySetupConfig, EasySetupResult } from "./types";
import { okAsync, Result, ResultAsync } from "neverthrow";
import { EasySetupConfig } from "./types";
import { ParsingError, ProcessError, SambaConfParser, SambaManagerNet } from "@/index";
import * as defaultConfigs from "@/defaultconfigs";

export interface IEasySetupConfigurator {

applyConfig(config: EasySetupConfig): ResultAsync<EasySetupResult, ProcessError>;
applyConfig(config: EasySetupConfig): ResultAsync<void, ProcessError>;
}

export class EasySetupConfigurator implements IEasySetupConfigurator {
@@ -15,12 +15,24 @@ export class EasySetupConfigurator implements IEasySetupConfigurator {
this.sambaManager = new SambaManagerNet();
}

applyConfig(config: EasySetupConfig): ResultAsync<EasySetupResult, ProcessError> {
applyConfig(config: EasySetupConfig): ResultAsync<void, ProcessError> {

return this.applyZFSConfig(config)satisfies
.andThen(() => this.applySambaConfig(config));
}

private applyZFSConfig(config: EasySetupConfig) {
return okAsync({});
}

private applySambaConfig(config: EasySetupConfig) {
const globalSambaUpdateResult = this.sambaManager.editGlobal(config.sambaConfig.global);
const shareSamabaResults = config.sambaConfig.shares.map(share => this.sambaManager.addShare(share));

return ResultAsync.combine([globalSambaUpdateResult, ...shareSamabaResults])
.map(() => ({}))
return ResultAsync.combine([
globalSambaUpdateResult,
...shareSamabaResults
]).map(() => { });
}

static loadConfig(easyConfigName: keyof typeof defaultConfigs): Result<EasySetupConfig, ParsingError> {
4 changes: 0 additions & 4 deletions houston-common-lib/lib/managers/easysetup/types.ts
Original file line number Diff line number Diff line change
@@ -3,7 +3,3 @@ import { SambaConfig } from "../samba/types";
export type EasySetupConfig = {
sambaConfig: SambaConfig
};

export type EasySetupResult = {

}

0 comments on commit 149914e

Please sign in to comment.