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