[add] grundlegende "init"-Funktionalität
This commit is contained in:
parent
5d06f119cd
commit
d0723239c0
|
|
@ -110,7 +110,17 @@ namespace _mimir.conf
|
|||
"kind": {
|
||||
"type": "string",
|
||||
"enum": ["none"]
|
||||
}
|
||||
},
|
||||
"data": {
|
||||
"nullable": true,
|
||||
"type": "object",
|
||||
"properties": {
|
||||
},
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
],
|
||||
"default": {}
|
||||
},
|
||||
},
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
|
|
@ -138,7 +148,7 @@ namespace _mimir.conf
|
|||
"required": [
|
||||
"passphrase"
|
||||
]
|
||||
}
|
||||
},
|
||||
},
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
|
|
|
|||
|
|
@ -23,6 +23,12 @@ namespace _mimir.transfer
|
|||
/**
|
||||
*/
|
||||
export type type_logic = {
|
||||
init : (
|
||||
(
|
||||
)
|
||||
=>
|
||||
Array<string>
|
||||
);
|
||||
execute : (
|
||||
(
|
||||
name : string,
|
||||
|
|
|
|||
|
|
@ -62,6 +62,72 @@ namespace _mimir.transfer.borg
|
|||
};
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
function get_passphrase(
|
||||
parameters : type_parameters
|
||||
) : (null | string)
|
||||
{
|
||||
switch (parameters.encryption.kind)
|
||||
{
|
||||
case "none":
|
||||
{
|
||||
return null;
|
||||
break;
|
||||
}
|
||||
case "repokey":
|
||||
{
|
||||
return parameters.encryption.data.passphrase;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
throw (new Error("unhandled encryption kind"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
export function init(
|
||||
parameters : type_parameters,
|
||||
) : Array<string>
|
||||
{
|
||||
const result : Array<string> = [];
|
||||
result.push(
|
||||
_mimir.helpers.borg.init(
|
||||
parameters.repository,
|
||||
{
|
||||
"encryption": ((encryption : type_encryption) => {
|
||||
switch (encryption.kind)
|
||||
{
|
||||
case "none":
|
||||
{
|
||||
return "none";
|
||||
break;
|
||||
}
|
||||
case "repokey":
|
||||
{
|
||||
return "repokey";
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
throw (new Error("unhandled encryption kind"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}) (parameters.encryption),
|
||||
"passphrase": get_passphrase(parameters),
|
||||
}
|
||||
)
|
||||
);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
export function execute(
|
||||
|
|
@ -84,13 +150,7 @@ namespace _mimir.transfer.borg
|
|||
),
|
||||
[directory],
|
||||
{
|
||||
"passphrase": (
|
||||
(parameters.encryption.kind === "repokey")
|
||||
?
|
||||
parameters.encryption.data.passphrase
|
||||
:
|
||||
null
|
||||
),
|
||||
"passphrase": get_passphrase(parameters),
|
||||
"compression": parameters.compression,
|
||||
}
|
||||
)
|
||||
|
|
@ -116,6 +176,7 @@ namespace _mimir.transfer.borg
|
|||
) : _mimir.transfer.type_logic
|
||||
{
|
||||
return {
|
||||
"init": () => init(parameters),
|
||||
"execute": (name, stamp, directory) => execute(parameters, name, stamp, directory),
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -73,6 +73,10 @@ namespace _mimir.transfer.local
|
|||
) : _mimir.transfer.type_logic
|
||||
{
|
||||
return {
|
||||
/**
|
||||
* @todo?
|
||||
*/
|
||||
"init": () => [],
|
||||
"execute": (name, stamp, directory) => execute(parameters, name, stamp, directory),
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -168,10 +168,27 @@ namespace _mimir
|
|||
}
|
||||
case "init":
|
||||
{
|
||||
/**
|
||||
* @todo implement
|
||||
*/
|
||||
return Promise.reject(new Error("not implemented"));
|
||||
const conf : _mimir.conf.type_conf = await _mimir.conf.get(args["conf_path"]);
|
||||
|
||||
let commands : Array<string> = [];
|
||||
const commands_add : ((command : string) => void) = (command) => {
|
||||
commands.push(command);
|
||||
};
|
||||
const commands_apply : (() => void) = () => {
|
||||
process.stdout.write(commands.join("\n") + "\n");
|
||||
};
|
||||
|
||||
// transfer
|
||||
{
|
||||
const target_logic : _mimir.transfer.type_logic = _mimir.transfer.get_logic(conf.target);
|
||||
commands = commands.concat(
|
||||
target_logic.init(
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
commands_apply();
|
||||
|
||||
break;
|
||||
}
|
||||
case "run":
|
||||
|
|
|
|||
Loading…
Reference in a new issue