Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .github/workflows/no-channel.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: "No channel PR"

on:
pull_request:
branches:
- 'nixos-**'
- 'nixpkgs-**'

jobs:
fail:
name: "This PR is is targeting a channel branch"
runs-on: ubuntu-latest
steps:
- run: |
cat <<EOF
The nixos-* and nixpkgs-* branches are pushed to by the channel
release script and should not be merged into directly.

Please target the equivalent release-* branch instead.
EOF
exit 1
22 changes: 20 additions & 2 deletions nixos/modules/services/cluster/k3s/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,30 @@ in
default = false;
description = "Only run the server. This option only makes sense for a server.";
};

configPath = mkOption {
type = types.nullOr types.path;
default = null;
description = "File path containing the k3s YAML config. This is useful when the config is generated (for example on boot).";
};
};

# implementation

config = mkIf cfg.enable {
assertions = [
{
assertion = cfg.role == "agent" -> cfg.serverAddr != "";
message = "serverAddr should be set if role is 'agent'";
assertion = cfg.role == "agent" -> (cfg.configPath != null || cfg.serverAddr != "");
message = "serverAddr or configPath (with 'server' key) should be set if role is 'agent'";
}
{
<<<<<<< HEAD
assertion = cfg.role == "agent" -> cfg.token != "";
message = "token should be set if role is 'agent'";
=======
assertion = cfg.role == "agent" -> cfg.configPath != null || cfg.tokenFile != null || cfg.token != "";
message = "token or tokenFile or configPath (with 'token' or 'token-file' keys) should be set if role is 'agent'";
>>>>>>> efbd199ffbb (nixos/k3s: add configPath option)
}
];

Expand All @@ -92,7 +103,14 @@ in
"${cfg.package}/bin/k3s ${cfg.role}"
] ++ (optional cfg.docker "--docker")
++ (optional cfg.disableAgent "--disable-agent")
<<<<<<< HEAD
++ (optional (cfg.role == "agent") "--server ${cfg.serverAddr} --token ${cfg.token}")
=======
++ (optional (cfg.serverAddr != "") "--server ${cfg.serverAddr}")
++ (optional (cfg.token != "") "--token ${cfg.token}")
++ (optional (cfg.tokenFile != null) "--token-file ${cfg.tokenFile}")
++ (optional (cfg.configPath != null) "--config ${cfg.configPath}")
>>>>>>> efbd199ffbb (nixos/k3s: add configPath option)
++ [ cfg.extraFlags ]
);
};
Expand Down