Skip to content

Commit 8875afc

Browse files
committed
cleanup: pr suggestions
1 parent 6e12b9c commit 8875afc

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

modules/hashi-snapshots.nix

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
cfg = config.services.hashi-snapshots;
99

1010
inherit (lib) boolToString listToAttrs mkEnableOption mkIf mkMerge mkOption nameValuePair toUpper;
11-
inherit (lib.types) addCheck attrs bool enum int str submodule;
11+
inherit (lib.types) attrs bool enum int ints nonEmptyStr str submodule;
1212

1313
snapshotJobConfig = submodule {
1414
options = {
@@ -21,7 +21,7 @@
2121
};
2222

2323
backupCount = mkOption {
24-
type = addCheck int (x: x >= 0);
24+
type = ints.unsigned;
2525
default = null;
2626
description = ''
2727
The number of snapshots to keep. A sensible value matched to the onCalendar
@@ -47,7 +47,7 @@
4747
};
4848

4949
backupSuffix = mkOption {
50-
type = addCheck str (x: x != "");
50+
type = nonEmptyStr;
5151
default = null;
5252
description = ''
5353
Sets the saved snapshot filename with a descriptive suffix prior to the file
@@ -100,7 +100,7 @@
100100
};
101101

102102
interval = mkOption {
103-
type = addCheck str (x: x != "");
103+
type = nonEmptyStr;
104104
default = null;
105105
description = ''
106106
The default onCalendar systemd timer string to trigger snapshot backups.
@@ -114,7 +114,7 @@
114114
};
115115

116116
randomizedDelaySec = mkOption {
117-
type = addCheck int (x: x >= 0);
117+
type = ints.unsigned;
118118
default = 0;
119119
description = ''
120120
A randomization period to be added to each systemd timer to avoid
@@ -251,11 +251,11 @@
251251
snapshotCmd = ''nomad operator snapshot save "$SNAP_NAME"'';
252252
envPrep = ''
253253
set +x
254-
NOMAD_TOKEN="$(< ${hashiTokens.nomad-snapshot})"
254+
NOMAD_TOKEN=$(< ${hashiTokens.nomad-snapshot})
255255
export NOMAD_TOKEN
256256
set -x
257257
258-
STATUS="$(nomad agent-info --json)"
258+
STATUS=$(nomad agent-info --json)
259259
'';
260260
roleCmd = ''jq -e '(.stats.nomad.leader // "false") == "true"' <<< "$STATUS"'';
261261
};
@@ -268,11 +268,11 @@
268268
snapshotCmd = ''vault operator raft snapshot save "$SNAP_NAME"'';
269269
envPrep = ''
270270
set +x
271-
VAULT_TOKEN="$(< ${hashiTokens.vault})"
271+
VAULT_TOKEN=$(< ${hashiTokens.vault})
272272
export VAULT_TOKEN
273273
set -x
274274
275-
STATUS="$(vault status)"
275+
STATUS=$(vault status)
276276
277277
if jq -e '.storage_type != "raft"' <<< "$STATUS"; then
278278
echo "Vault storage backend is not raft."

0 commit comments

Comments
 (0)