vars: generate docs for cli and module
This commit is contained in:
@@ -120,6 +120,7 @@ nav:
|
|||||||
- reference/cli/show.md
|
- reference/cli/show.md
|
||||||
- reference/cli/ssh.md
|
- reference/cli/ssh.md
|
||||||
- reference/cli/state.md
|
- reference/cli/state.md
|
||||||
|
- reference/cli/vars.md
|
||||||
- reference/cli/vms.md
|
- reference/cli/vms.md
|
||||||
- Clan Core:
|
- Clan Core:
|
||||||
- reference/clan-core/index.md
|
- reference/clan-core/index.md
|
||||||
@@ -130,6 +131,7 @@ nav:
|
|||||||
- reference/clan-core/state.md
|
- reference/clan-core/state.md
|
||||||
- reference/clan-core/deployment.md
|
- reference/clan-core/deployment.md
|
||||||
- reference/clan-core/networking.md
|
- reference/clan-core/networking.md
|
||||||
|
- reference/clan-core/vars.md
|
||||||
- Nix API:
|
- Nix API:
|
||||||
- buildClan: reference/nix-api/buildclan.md
|
- buildClan: reference/nix-api/buildclan.md
|
||||||
- Inventory: reference/nix-api/inventory.md
|
- Inventory: reference/nix-api/inventory.md
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ in
|
|||||||
# ./secret/vm.nix
|
# ./secret/vm.nix
|
||||||
];
|
];
|
||||||
options.clan.core.vars = lib.mkOption {
|
options.clan.core.vars = lib.mkOption {
|
||||||
visible = false;
|
|
||||||
description = ''
|
description = ''
|
||||||
Generated Variables
|
Generated Variables
|
||||||
|
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ in
|
|||||||
'';
|
'';
|
||||||
readOnly = true;
|
readOnly = true;
|
||||||
default = generator.config._module.args.name;
|
default = generator.config._module.args.name;
|
||||||
|
defaultText = "Name of the generator";
|
||||||
};
|
};
|
||||||
|
|
||||||
dependencies = lib.mkOption {
|
dependencies = lib.mkOption {
|
||||||
@@ -91,7 +92,10 @@ in
|
|||||||
# lists are not allowed as of now due to potential ordering issues
|
# lists are not allowed as of now due to potential ordering issues
|
||||||
]);
|
]);
|
||||||
in
|
in
|
||||||
data;
|
data
|
||||||
|
// {
|
||||||
|
description = "JSON compatible data structure";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
# the invalidationHash is the validation interface to the outside world
|
# the invalidationHash is the validation interface to the outside world
|
||||||
invalidationHash = lib.mkOption {
|
invalidationHash = lib.mkOption {
|
||||||
@@ -108,6 +112,7 @@ in
|
|||||||
null
|
null
|
||||||
else
|
else
|
||||||
hashString "sha256" (toJSON generator.config.invalidationData);
|
hashString "sha256" (toJSON generator.config.invalidationData);
|
||||||
|
defaultText = "Hash of the invalidation data";
|
||||||
};
|
};
|
||||||
files = lib.mkOption {
|
files = lib.mkOption {
|
||||||
description = ''
|
description = ''
|
||||||
@@ -145,6 +150,7 @@ in
|
|||||||
'';
|
'';
|
||||||
readOnly = true;
|
readOnly = true;
|
||||||
default = file.config._module.args.name;
|
default = file.config._module.args.name;
|
||||||
|
defaultText = "Name of the file";
|
||||||
};
|
};
|
||||||
generatorName = lib.mkOption {
|
generatorName = lib.mkOption {
|
||||||
type = lib.types.str;
|
type = lib.types.str;
|
||||||
@@ -153,6 +159,7 @@ in
|
|||||||
'';
|
'';
|
||||||
readOnly = true;
|
readOnly = true;
|
||||||
default = generator.config._module.args.name;
|
default = generator.config._module.args.name;
|
||||||
|
defaultText = "Name of the generator that generates this file";
|
||||||
};
|
};
|
||||||
share = lib.mkOption {
|
share = lib.mkOption {
|
||||||
type = lib.types.bool;
|
type = lib.types.bool;
|
||||||
@@ -164,6 +171,7 @@ in
|
|||||||
readOnly = true;
|
readOnly = true;
|
||||||
internal = true;
|
internal = true;
|
||||||
default = generator.config.share;
|
default = generator.config.share;
|
||||||
|
defaultText = "Mirror of the share flag of the generator";
|
||||||
};
|
};
|
||||||
deploy = lib.mkOption {
|
deploy = lib.mkOption {
|
||||||
description = ''
|
description = ''
|
||||||
@@ -229,6 +237,7 @@ in
|
|||||||
'';
|
'';
|
||||||
type = str;
|
type = str;
|
||||||
default = prompt.config._module.args.name;
|
default = prompt.config._module.args.name;
|
||||||
|
defaultText = "Name of the prompt";
|
||||||
};
|
};
|
||||||
createFile = lib.mkOption {
|
createFile = lib.mkOption {
|
||||||
description = ''
|
description = ''
|
||||||
@@ -252,6 +261,7 @@ in
|
|||||||
type = str;
|
type = str;
|
||||||
example = "SSH private key";
|
example = "SSH private key";
|
||||||
default = prompt.config._module.args.name;
|
default = prompt.config._module.args.name;
|
||||||
|
defaultText = "Name of the prompt";
|
||||||
};
|
};
|
||||||
type = lib.mkOption {
|
type = lib.mkOption {
|
||||||
description = ''
|
description = ''
|
||||||
@@ -301,7 +311,6 @@ in
|
|||||||
type = lib.types.str;
|
type = lib.types.str;
|
||||||
readOnly = true;
|
readOnly = true;
|
||||||
internal = true;
|
internal = true;
|
||||||
visible = false;
|
|
||||||
};
|
};
|
||||||
share = lib.mkOption {
|
share = lib.mkOption {
|
||||||
description = ''
|
description = ''
|
||||||
|
|||||||
@@ -293,11 +293,11 @@ For more detailed information, visit: {help_hyperlink("secrets", "https://docs.c
|
|||||||
# like facts but with vars instead of facts
|
# like facts but with vars instead of facts
|
||||||
parser_vars = subparsers.add_parser(
|
parser_vars = subparsers.add_parser(
|
||||||
"vars",
|
"vars",
|
||||||
help="WIP: Manage vars",
|
help="Manage vars",
|
||||||
description="WIP: Manage vars",
|
description="Manage vars",
|
||||||
epilog=(
|
epilog=(
|
||||||
f"""
|
f"""
|
||||||
This subcommand provides an interface to vars of clan machines.
|
This subcommand provides an interface to `vars` of clan machines.
|
||||||
Vars are variables that a service can generate.
|
Vars are variables that a service can generate.
|
||||||
There are public and secret vars.
|
There are public and secret vars.
|
||||||
Public vars can be referenced by other machines directly.
|
Public vars can be referenced by other machines directly.
|
||||||
|
|||||||
@@ -137,7 +137,6 @@ class Machine:
|
|||||||
module = importlib.import_module(self.public_facts_module)
|
module = importlib.import_module(self.public_facts_module)
|
||||||
return module.FactStore(machine=self)
|
return module.FactStore(machine=self)
|
||||||
|
|
||||||
# WIP: Vars module is not ready yet.
|
|
||||||
@property
|
@property
|
||||||
def secret_vars_module(self) -> str:
|
def secret_vars_module(self) -> str:
|
||||||
return self.deployment["vars"]["secretModule"]
|
return self.deployment["vars"]["secretModule"]
|
||||||
|
|||||||
@@ -487,7 +487,7 @@ def generate_command(args: argparse.Namespace) -> None:
|
|||||||
machines = get_all_machines(args.flake, args.option)
|
machines = get_all_machines(args.flake, args.option)
|
||||||
else:
|
else:
|
||||||
machines = get_selected_machines(args.flake, args.option, args.machines)
|
machines = get_selected_machines(args.flake, args.option, args.machines)
|
||||||
generate_vars(machines, args.service, args.regenerate, args.fix)
|
generate_vars(machines, args.generator, args.regenerate, args.fix)
|
||||||
|
|
||||||
|
|
||||||
def register_generate_parser(parser: argparse.ArgumentParser) -> None:
|
def register_generate_parser(parser: argparse.ArgumentParser) -> None:
|
||||||
@@ -501,15 +501,17 @@ def register_generate_parser(parser: argparse.ArgumentParser) -> None:
|
|||||||
add_dynamic_completer(machines_parser, complete_machines)
|
add_dynamic_completer(machines_parser, complete_machines)
|
||||||
|
|
||||||
service_parser = parser.add_argument(
|
service_parser = parser.add_argument(
|
||||||
"--service",
|
"--generator",
|
||||||
|
"-g",
|
||||||
type=str,
|
type=str,
|
||||||
help="service to generate facts for, if empty, generate facts for every service",
|
help="execute only the specified generator. If unset, execute all generators",
|
||||||
default=None,
|
default=None,
|
||||||
)
|
)
|
||||||
add_dynamic_completer(service_parser, complete_services_for_machine)
|
add_dynamic_completer(service_parser, complete_services_for_machine)
|
||||||
|
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--regenerate",
|
"--regenerate",
|
||||||
|
"-r",
|
||||||
action=argparse.BooleanOptionalAction,
|
action=argparse.BooleanOptionalAction,
|
||||||
help="whether to regenerate facts for the specified machine",
|
help="whether to regenerate facts for the specified machine",
|
||||||
default=None,
|
default=None,
|
||||||
|
|||||||
Reference in New Issue
Block a user