diff --git a/modules/programs/k9s.nix b/modules/programs/k9s.nix
index 41b694bf..42c25ac4 100644
--- a/modules/programs/k9s.nix
+++ b/modules/programs/k9s.nix
@@ -33,6 +33,8 @@ in
"skin"
]
)
+ (lib.mkRenamedOptionModule [ "programs" "k9s" "hotkey" ] [ "programs" "k9s" "hotKeys" ])
+ (lib.mkRenamedOptionModule [ "programs" "k9s" "plugin" ] [ "programs" "k9s" "plugins" ])
];
options.programs.k9s = {
@@ -86,14 +88,14 @@ in
for supported values.
'';
example = literalExpression ''
- alias = {
+ {
# Use pp as an alias for Pod
pp = "v1/pods";
- };
+ }
'';
};
- hotkey = mkOption {
+ hotKeys = mkOption {
type = yamlFormat.type;
default = { };
description = ''
@@ -102,20 +104,17 @@ in
for supported values.
'';
example = literalExpression ''
- hotkey = {
- # Make sure this is camel case
- hotKey = {
- shift-0 = {
- shortCut = "Shift-0";
- description = "Viewing pods";
- command = "pods";
- };
+ {
+ shift-0 = {
+ shortCut = "Shift-0";
+ description = "Viewing pods";
+ command = "pods";
};
- };
+ }
'';
};
- plugin = mkOption {
+ plugins = mkOption {
type = yamlFormat.type;
default = { };
description = ''
@@ -124,7 +123,7 @@ in
for supported values.
'';
example = literalExpression ''
- plugin = {
+ {
# Defines a plugin to provide a `ctrl-l` shortcut to
# tail the logs while in pod view.
fred = {
@@ -143,7 +142,7 @@ in
"$CLUSTER"
];
};
- };
+ }
'';
};
@@ -157,21 +156,19 @@ in
See for supported values.
'';
example = literalExpression ''
- k9s = {
- views = {
- "v1/pods" = {
- columns = [
- "AGE"
- "NAMESPACE"
- "NAME"
- "IP"
- "NODE"
- "STATUS"
- "READY"
- ];
- };
+ {
+ "v1/pods" = {
+ columns = [
+ "AGE"
+ "NAMESPACE"
+ "NAME"
+ "IP"
+ "NODE"
+ "STATUS"
+ "READY"
+ ];
};
- };
+ }
'';
};
};
@@ -206,6 +203,16 @@ in
in
mkIf cfg.enable {
home.packages = lib.mkIf (cfg.package != null) [ cfg.package ];
+ warnings =
+ (lib.optional (cfg.aliases ? alias)
+ "Nested 'alias' key in programs.k9s.aliases is deprecated, move the contents directly under programs.k9s.aliases"
+ )
+ ++ (lib.optional (cfg.plugins ? plugin)
+ "Nested 'plugin' key in programs.k9s.plugins is deprecated, move the contents directly under programs.k9s.plugins"
+ )
+ ++ (lib.optional (cfg.views ? k9s.views)
+ "Nested 'k9s.views' structure in programs.k9s.views is deprecated, move the contents directly under programs.k9s.views"
+ );
xdg.configFile = mkIf enableXdgConfig (
{
@@ -214,19 +221,19 @@ in
};
"k9s/aliases.yaml" = mkIf (cfg.aliases != { }) {
- source = yamlFormat.generate "k9s-aliases" cfg.aliases;
+ source = yamlFormat.generate "k9s-aliases" { inherit (cfg) aliases; };
};
- "k9s/hotkeys.yaml" = mkIf (cfg.hotkey != { }) {
- source = yamlFormat.generate "k9s-hotkey" cfg.hotkey;
+ "k9s/hotkeys.yaml" = mkIf (cfg.hotKeys != { }) {
+ source = yamlFormat.generate "k9s-hotkeys" { inherit (cfg) hotKeys; };
};
- "k9s/plugins.yaml" = mkIf (cfg.plugin != { }) {
- source = yamlFormat.generate "k9s-plugin" cfg.plugin;
+ "k9s/plugins.yaml" = mkIf (cfg.plugins != { }) {
+ source = yamlFormat.generate "k9s-plugins" { inherit (cfg) plugins; };
};
"k9s/views.yaml" = mkIf (cfg.views != { }) {
- source = yamlFormat.generate "k9s-views" cfg.views;
+ source = yamlFormat.generate "k9s-views" { inherit (cfg) views; };
};
}
// skinFiles
@@ -239,19 +246,19 @@ in
};
"Library/Application Support/k9s/aliases.yaml" = mkIf (cfg.aliases != { }) {
- source = yamlFormat.generate "k9s-aliases" cfg.aliases;
+ source = yamlFormat.generate "k9s-aliases" { inherit (cfg) aliases; };
};
- "Library/Application Support/k9s/hotkeys.yaml" = mkIf (cfg.hotkey != { }) {
- source = yamlFormat.generate "k9s-hotkey" cfg.hotkey;
+ "Library/Application Support/k9s/hotkeys.yaml" = mkIf (cfg.hotKeys != { }) {
+ source = yamlFormat.generate "k9s-hotkeys" { inherit (cfg) hotKeys; };
};
- "Library/Application Support/k9s/plugins.yaml" = mkIf (cfg.plugin != { }) {
- source = yamlFormat.generate "k9s-plugin" cfg.plugin;
+ "Library/Application Support/k9s/plugins.yaml" = mkIf (cfg.plugins != { }) {
+ source = yamlFormat.generate "k9s-plugins" { inherit (cfg) plugins; };
};
"Library/Application Support/k9s/views.yaml" = mkIf (cfg.views != { }) {
- source = yamlFormat.generate "k9s-views" cfg.views;
+ source = yamlFormat.generate "k9s-views" { inherit (cfg) views; };
};
}
// skinFiles
diff --git a/tests/modules/programs/k9s/deprecated-options.nix b/tests/modules/programs/k9s/deprecated-options.nix
index 390ab331..1d19ac2e 100644
--- a/tests/modules/programs/k9s/deprecated-options.nix
+++ b/tests/modules/programs/k9s/deprecated-options.nix
@@ -16,11 +16,60 @@
};
};
};
+ hotkey = {
+ shift-0 = {
+ shortCut = "Shift-0";
+ description = "Viewing pods";
+ command = "pods";
+ };
+ };
+ plugin = {
+ fred = {
+ shortCut = "Ctrl-L";
+ description = "Pod logs";
+ scopes = [ "po" ];
+ command = "kubectl";
+ background = false;
+ args = [
+ "logs"
+ "-f"
+ "$NAME"
+ "-n"
+ "$NAMESPACE"
+ "--context"
+ "$CLUSTER"
+ ];
+ };
+ };
+ views = {
+ k9s.views = {
+ "v1/services" = {
+ columns = [
+ "NAME"
+ "TYPE"
+ ];
+ };
+ };
+ "v1/pods" = {
+ columns = [
+ "AGE"
+ "NAMESPACE"
+ "NAME"
+ "IP"
+ "NODE"
+ "STATUS"
+ "READY"
+ ];
+ };
+ };
};
test.asserts.warnings.enable = true;
test.asserts.warnings.expected = [
+ "The option `programs.k9s.plugin' defined in ${lib.showFiles options.programs.k9s.plugin.files} has been renamed to `programs.k9s.plugins'."
+ "The option `programs.k9s.hotkey' defined in ${lib.showFiles options.programs.k9s.hotkey.files} has been renamed to `programs.k9s.hotKeys'."
"The option `programs.k9s.skin' defined in ${lib.showFiles options.programs.k9s.skin.files} has been renamed to `programs.k9s.skins.skin'."
+ "Nested 'k9s.views' structure in programs.k9s.views is deprecated, move the contents directly under programs.k9s.views"
];
nmt.script = ''
assertFileExists home-files/.config/k9s/skins/skin.yaml
diff --git a/tests/modules/programs/k9s/example-aliases-expected.yaml b/tests/modules/programs/k9s/example-aliases-expected.yaml
index c2939252..f9eccce9 100644
--- a/tests/modules/programs/k9s/example-aliases-expected.yaml
+++ b/tests/modules/programs/k9s/example-aliases-expected.yaml
@@ -1,2 +1,2 @@
-alias:
+aliases:
pp: v1/pods
diff --git a/tests/modules/programs/k9s/example-hotkey-expected.yaml b/tests/modules/programs/k9s/example-hotkeys-expected.yaml
similarity index 90%
rename from tests/modules/programs/k9s/example-hotkey-expected.yaml
rename to tests/modules/programs/k9s/example-hotkeys-expected.yaml
index cae3005d..aaf633bc 100644
--- a/tests/modules/programs/k9s/example-hotkey-expected.yaml
+++ b/tests/modules/programs/k9s/example-hotkeys-expected.yaml
@@ -1,4 +1,4 @@
-hotKey:
+hotKeys:
shift-0:
command: pods
description: Viewing pods
diff --git a/tests/modules/programs/k9s/example-plugin-expected.yaml b/tests/modules/programs/k9s/example-plugins-expected.yaml
similarity index 96%
rename from tests/modules/programs/k9s/example-plugin-expected.yaml
rename to tests/modules/programs/k9s/example-plugins-expected.yaml
index e6eb2a6c..38c959c0 100644
--- a/tests/modules/programs/k9s/example-plugin-expected.yaml
+++ b/tests/modules/programs/k9s/example-plugins-expected.yaml
@@ -1,4 +1,4 @@
-plugin:
+plugins:
fred:
args:
- logs
diff --git a/tests/modules/programs/k9s/example-settings.nix b/tests/modules/programs/k9s/example-settings.nix
index cd3e36e3..09fe7b58 100644
--- a/tests/modules/programs/k9s/example-settings.nix
+++ b/tests/modules/programs/k9s/example-settings.nix
@@ -21,13 +21,11 @@
ui.skin = "default";
};
};
- hotkey = {
- hotKey = {
- shift-0 = {
- shortCut = "Shift-0";
- description = "Viewing pods";
- command = "pods";
- };
+ hotKeys = {
+ shift-0 = {
+ shortCut = "Shift-0";
+ description = "Viewing pods";
+ command = "pods";
};
};
skins = {
@@ -60,45 +58,37 @@
};
};
aliases = {
- alias = {
- pp = "v1/pods";
- };
+ pp = "v1/pods";
};
- plugin = {
- plugin = {
- fred = {
- shortCut = "Ctrl-L";
- description = "Pod logs";
- scopes = [ "po" ];
- command = "kubectl";
- background = false;
- args = [
- "logs"
- "-f"
- "$NAME"
- "-n"
- "$NAMESPACE"
- "--context"
- "$CLUSTER"
- ];
- };
+ plugins = {
+ fred = {
+ shortCut = "Ctrl-L";
+ description = "Pod logs";
+ scopes = [ "po" ];
+ command = "kubectl";
+ background = false;
+ args = [
+ "logs"
+ "-f"
+ "$NAME"
+ "-n"
+ "$NAMESPACE"
+ "--context"
+ "$CLUSTER"
+ ];
};
};
views = {
- k9s = {
- views = {
- "v1/pods" = {
- columns = [
- "AGE"
- "NAMESPACE"
- "NAME"
- "IP"
- "NODE"
- "STATUS"
- "READY"
- ];
- };
- };
+ "v1/pods" = {
+ columns = [
+ "AGE"
+ "NAMESPACE"
+ "NAME"
+ "IP"
+ "NODE"
+ "STATUS"
+ "READY"
+ ];
};
};
};
@@ -124,18 +114,16 @@
assertFileContent \
"home-files/${configDir}/skins/alt-skin.yaml" \
${./example-skin-expected-alt.yaml}
- assertFileExists "home-files/${configDir}/hotkeys.yaml"
assertFileContent \
"home-files/${configDir}/hotkeys.yaml" \
- ${./example-hotkey-expected.yaml}
+ ${./example-hotkeys-expected.yaml}
assertFileExists "home-files/${configDir}/aliases.yaml"
assertFileContent \
"home-files/${configDir}/aliases.yaml" \
${./example-aliases-expected.yaml}
- assertFileExists "home-files/${configDir}/plugins.yaml"
assertFileContent \
"home-files/${configDir}/plugins.yaml" \
- ${./example-plugin-expected.yaml}
+ ${./example-plugins-expected.yaml}
assertFileExists "home-files/${configDir}/views.yaml"
assertFileContent \
"home-files/${configDir}/views.yaml" \
diff --git a/tests/modules/programs/k9s/example-views-expected.yaml b/tests/modules/programs/k9s/example-views-expected.yaml
index f76bb07d..eece162c 100644
--- a/tests/modules/programs/k9s/example-views-expected.yaml
+++ b/tests/modules/programs/k9s/example-views-expected.yaml
@@ -1,11 +1,10 @@
-k9s:
- views:
- v1/pods:
- columns:
- - AGE
- - NAMESPACE
- - NAME
- - IP
- - NODE
- - STATUS
- - READY
+views:
+ v1/pods:
+ columns:
+ - AGE
+ - NAMESPACE
+ - NAME
+ - IP
+ - NODE
+ - STATUS
+ - READY