Commit Graph

37 Commits

Author SHA1 Message Date
Jörg Thalheim
16fefb27bb add temp_dir fixture 2024-10-01 20:54:19 +02:00
DavHau
0324f4d4b8 vars/sops: improve shared secrets, switching backend
When a second machine checks for a shared secret, now the exists() call returns negative and only when updating the secrets for that machine, the machine is added to the sops receivers.

Also throw proper errors when the user switches backends without cleaning the files first.
2024-09-20 15:06:54 +02:00
DavHau
501ade7de7 vars: implement migration
Migrating generated files from the facts subsystem to the vars subsystem is now possible.

HowTo:
1. declare `clan.core.vars.generators.<generator>.migrateFact = my_service` where `my_service` refers to a service from `clan.core.facts.services`
2. run `clan vers generate your_machine` or `clan machines update your_machine`

Vars will only be migrated for a generator if:
1. The facts service specified via `migrateFact` does exist
2. None of the vars to generate exist yet
3. All public var names exist in the public facts store
4. All secret var names exist in the secret fact store

If the migration is deemed possible, the generator script will not be executed. Instead the files from the public or secret facts store are read and stored into the corresponding vars store
2024-09-19 17:57:03 +02:00
DavHau
89d39186ee vars/generate: improve output when vars are updated
fixes #2076

- print old and new value if possible
- also inform the user if something hasn't changed
2024-09-18 16:57:01 +02:00
DavHau
1c56ef5725 vars: allow setting a default for values 2024-09-17 21:11:38 +02:00
DavHau
cf47c1d51a vars: generate proper commit messages
fixes #2126
2024-09-17 20:22:18 +02:00
DavHau
067d287398 vars/list: display '<not set>' also for secrets 2024-09-12 17:24:29 +02:00
a-kenji
4d2ad709ad vars: use correct paths for value accesses
Use correct paths for value accesses of vars under:

- `per-machine`
- `shared`
2024-09-11 19:02:43 +02:00
DavHau
6fafafa064 vars/password-store: use standard paths; fix share flag 2024-09-09 21:20:03 +02:00
DavHau
b3dd36bdb6 vars: improve generator pipeline
Compute the whole closure of to-be-executed generators upfront before executing anything

Properly compute closures for the 4 different scenarios:

1. full_closure: run all generators for a selected machine in topological order
2. all_missing_closure: run just the missing generators including their dependents
3. requested_closure: run only a selected list of generators including their missing dependencies and their dependents
4. minimal_closure: Run just enough to ensure that the list of selected generators are in a consistent state. Don't execute anything if nothing is missing.
2024-09-06 21:32:17 +02:00
Qubasa
2b5cdd66f9 clan-cli: Make run_vm_in_thread fail fast. Fix generate_flake to support machine_id 2024-09-06 18:53:02 +02:00
DavHau
f161c7ca58 vars: improve generator execution pipeline
- ensure all dependents are re-generated as well
- refactor: separate out computation of generator update closure
2024-09-06 14:30:49 +02:00
DavHau
1254b80a52 vars: add api endpoint set_prompts 2024-09-04 18:06:11 +02:00
DavHau
112982a7fb vars: add get_prompts api endpoint
vars: add test for api endpoint get_prompts
2024-09-04 17:36:50 +02:00
DavHau
bd554ca392 vars: new option prompts.<name>.createFile 2024-09-04 15:48:10 +02:00
Jörg Thalheim
15ff74f7c2 enable ASYNC, DTZ, YTT and EM lints 2024-09-02 14:07:06 +02:00
Jörg Thalheim
e9a266001c enable comprehensions linting rules 2024-09-02 13:35:52 +02:00
Jörg Thalheim
f3a2b4d80e fix all typing error in tests 2024-09-02 12:23:13 +02:00
DavHau
2ec3abb24c vars: improve check command and add tests 2024-09-01 16:45:09 +02:00
DavHau
8ad90aa44f vars: fix listing vars + add test 2024-09-01 16:10:25 +02:00
Qubasa
6c4d7494f6 clan-cli: Fix some type errors in tests 2024-08-21 15:48:43 +02:00
Qubasa
b2530f0b19 clan-app: Fix nix run .#clan-app 2024-08-21 13:52:25 +02:00
DavHau
b2646aa0fe tests: improve testing framework for impure vm tests
Also fix computet sops secret paths for vars
2024-08-04 13:40:12 +07:00
DavHau
d3542cf1c8 vars: simplify tests 2024-08-03 15:47:35 +07:00
DavHau
8086f70b79 clan-cli/tests: improve test helpers for VMs 2024-08-03 15:26:53 +07:00
DavHau
cc9c828598 vars: introduce share flag 2024-08-03 15:26:53 +07:00
DavHau
9996f5596c vars/sops: store secrets in /sops/vars 2024-07-24 18:42:50 +07:00
DavHau
5bd20fcf2c vars: add support for password-store 2024-07-23 14:54:18 +07:00
DavHau
9ff076aec1 vars: implement prompts 2024-07-22 20:40:12 +07:00
DavHau
117843021e vars: implement dependencies 2024-07-17 16:42:16 +07:00
DavHau
d700f651b4 vars: add test for multiple machines 2024-07-16 18:35:13 +07:00
Johannes Kirschbauer
b324e1a4f4 Fix some type issues 2024-07-11 17:05:57 +02:00
DavHau
9988fb744c vars: implement sops.defaultGroups 2024-07-11 18:39:29 +07:00
DavHau
75b969b1ad clan-cli: improve runtime dependency management
Many dependencies of clan-cli  are currently dynamically loaded via nix-shell on each execution.
This is nice, as it reduces the initial closure size of clan, but the overhead introduced by nix-shell piles up quickly, as some commands shell out many times during their lifetime. For example, when adding a secret git is called 10+ times.

This reduces the time of a test which adds a secret from around 50 seconds to 15 seconds.

- add run_cmd() as an alternative to nix_shell()
- introduce the concept of static dependencies which do not need to go through nix-shell
- static dependencies are defined at build time and included into the wrapper for clan-cli
- add package: clan-cli-full which statically ships all required dependencies

TODO: deprecate nix_shell() in favor of run_cmd()
2024-07-11 15:34:41 +07:00
DavHau
d21926db47 vars: implement secret generation 2024-07-11 11:37:17 +07:00
DavHau
e7908c2af5 clan-cli: simplify cli helper 2024-07-10 18:14:06 +07:00
DavHau
3447a98bee vars: implement generating public variables via in_repo 2024-07-09 14:26:56 +07:00