diff --git a/modules/programs/k9s.nix b/modules/programs/k9s.nix
index 78dbe71ca..43de8f79c 100644
--- a/modules/programs/k9s.nix
+++ b/modules/programs/k9s.nix
@@ -20,10 +20,8 @@ in {
type = yamlFormat.type;
default = { };
description = ''
- Configuration written to
- {file}`$XDG_CONFIG_HOME/k9s/config.yml`. See
-
- for supported values.
+ Configuration written to {file}`$XDG_CONFIG_HOME/k9s/config.yml`. See
+ for supported values.
'';
example = literalExpression ''
k9s = {
@@ -36,10 +34,8 @@ in {
type = yamlFormat.type;
default = { };
description = ''
- Skin written to
- {file}`$XDG_CONFIG_HOME/k9s/skin.yml`. See
-
- for supported values.
+ Skin written to {file}`$XDG_CONFIG_HOME/k9s/skin.yml`. See
+ for supported values.
'';
example = literalExpression ''
k9s = {
@@ -50,14 +46,27 @@ in {
'';
};
+ aliases = mkOption {
+ type = yamlFormat.type;
+ default = { };
+ description = ''
+ Aliases written to {file}`$XDG_CONFIG_HOME/k9s/aliases.yml`. See
+ for supported values.
+ '';
+ example = literalExpression ''
+ alias = {
+ # Use pp as an alias for Pod
+ pp = "v1/pods";
+ };
+ '';
+ };
+
hotkey = mkOption {
type = yamlFormat.type;
default = { };
description = ''
- hotkeys written to
- {file}`$XDG_CONFIG_HOME/k9s/hotkey.yml`. See
-
- for supported values.
+ Hotkeys written to {file}`$XDG_CONFIG_HOME/k9s/hotkey.yml`. See
+ for supported values.
'';
example = literalExpression ''
hotkey = {
@@ -72,6 +81,63 @@ in {
};
'';
};
+
+ plugin = mkOption {
+ type = yamlFormat.type;
+ default = { };
+ description = ''
+ Plugins written to {file}`$XDG_CONFIG_HOME/k9s/plugin.yml`. See
+ for supported values.
+ '';
+ example = literalExpression ''
+ plugin = {
+ # Defines a plugin to provide a `ctrl-l` shortcut to
+ # tail the logs while in pod view.
+ fred = {
+ shortCut = "Ctrl-L";
+ description = "Pod logs";
+ scopes = [ "po" ];
+ command = "kubectl";
+ background = false;
+ args = [
+ "logs"
+ "-f"
+ "$NAME"
+ "-n"
+ "$NAMESPACE"
+ "--context"
+ "$CLUSTER"
+ ];
+ };
+ };
+ '';
+ };
+
+ views = mkOption {
+ type = yamlFormat.type;
+ default = { };
+ description = ''
+ Resource column views written to {file}`$XDG_CONFIG_HOME/k9s/views.yml`.
+ See for supported values.
+ '';
+ example = literalExpression ''
+ k9s = {
+ views = {
+ "v1/pods" = {
+ columns = [
+ "AGE"
+ "NAMESPACE"
+ "NAME"
+ "IP"
+ "NODE"
+ "STATUS"
+ "READY"
+ ];
+ };
+ };
+ };
+ '';
+ };
};
config = mkIf cfg.enable {
@@ -85,8 +151,20 @@ in {
source = yamlFormat.generate "k9s-skin" cfg.skin;
};
+ xdg.configFile."k9s/aliases.yml" = mkIf (cfg.aliases != { }) {
+ source = yamlFormat.generate "k9s-aliases" cfg.aliases;
+ };
+
xdg.configFile."k9s/hotkey.yml" = mkIf (cfg.hotkey != { }) {
source = yamlFormat.generate "k9s-hotkey" cfg.hotkey;
};
+
+ xdg.configFile."k9s/plugin.yml" = mkIf (cfg.plugin != { }) {
+ source = yamlFormat.generate "k9s-plugin" cfg.plugin;
+ };
+
+ xdg.configFile."k9s/views.yml" = mkIf (cfg.views != { }) {
+ source = yamlFormat.generate "k9s-views" cfg.views;
+ };
};
}
diff --git a/tests/modules/programs/k9s/example-aliases-expected.yml b/tests/modules/programs/k9s/example-aliases-expected.yml
new file mode 100644
index 000000000..c2939252d
--- /dev/null
+++ b/tests/modules/programs/k9s/example-aliases-expected.yml
@@ -0,0 +1,2 @@
+alias:
+ pp: v1/pods
diff --git a/tests/modules/programs/k9s/example-plugin-expected.yml b/tests/modules/programs/k9s/example-plugin-expected.yml
new file mode 100644
index 000000000..e6eb2a6c6
--- /dev/null
+++ b/tests/modules/programs/k9s/example-plugin-expected.yml
@@ -0,0 +1,16 @@
+plugin:
+ fred:
+ args:
+ - logs
+ - -f
+ - $NAME
+ - -n
+ - $NAMESPACE
+ - --context
+ - $CLUSTER
+ background: false
+ command: kubectl
+ description: Pod logs
+ scopes:
+ - po
+ shortCut: Ctrl-L
diff --git a/tests/modules/programs/k9s/example-settings.nix b/tests/modules/programs/k9s/example-settings.nix
index 0100aa93c..3c935aa6f 100644
--- a/tests/modules/programs/k9s/example-settings.nix
+++ b/tests/modules/programs/k9s/example-settings.nix
@@ -35,6 +35,29 @@
};
};
};
+ aliases = { alias = { 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" ];
+ };
+ };
+ };
+ views = {
+ k9s = {
+ views = {
+ "v1/pods" = {
+ columns = [ "AGE" "NAMESPACE" "NAME" "IP" "NODE" "STATUS" "READY" ];
+ };
+ };
+ };
+ };
};
nmt.script = ''
@@ -43,12 +66,24 @@
home-files/.config/k9s/config.yml \
${./example-config-expected.yml}
assertFileExists home-files/.config/k9s/skin.yml
- assertFileExists home-files/.config/k9s/hotkey.yml
assertFileContent \
home-files/.config/k9s/skin.yml \
${./example-skin-expected.yml}
+ assertFileExists home-files/.config/k9s/hotkey.yml
assertFileContent \
home-files/.config/k9s/hotkey.yml \
${./example-hotkey-expected.yml}
+ assertFileExists home-files/.config/k9s/aliases.yml
+ assertFileContent \
+ home-files/.config/k9s/aliases.yml \
+ ${./example-aliases-expected.yml}
+ assertFileExists home-files/.config/k9s/plugin.yml
+ assertFileContent \
+ home-files/.config/k9s/plugin.yml \
+ ${./example-plugin-expected.yml}
+ assertFileExists home-files/.config/k9s/views.yml
+ assertFileContent \
+ home-files/.config/k9s/views.yml \
+ ${./example-views-expected.yml}
'';
}
diff --git a/tests/modules/programs/k9s/example-views-expected.yml b/tests/modules/programs/k9s/example-views-expected.yml
new file mode 100644
index 000000000..f76bb07d1
--- /dev/null
+++ b/tests/modules/programs/k9s/example-views-expected.yml
@@ -0,0 +1,11 @@
+k9s:
+ views:
+ v1/pods:
+ columns:
+ - AGE
+ - NAMESPACE
+ - NAME
+ - IP
+ - NODE
+ - STATUS
+ - READY