wip: getting there, slowly
This commit is contained in:
+2
-2
@@ -7,7 +7,7 @@ in
|
||||
|
||||
options.apps = with lib; {
|
||||
env = mkOption {
|
||||
type = types.string;
|
||||
type = types.str;
|
||||
default = "prod";
|
||||
description = "Enable";
|
||||
};
|
||||
@@ -42,7 +42,7 @@ in
|
||||
target = {
|
||||
repository = "https://gitlab.com/oveanbox/manifests.git";
|
||||
branch = "main";
|
||||
rootPath = "_manifests";
|
||||
rootPath = "_manifests/${config.apps.env}";
|
||||
};
|
||||
|
||||
resourceImports = [
|
||||
|
||||
+20
-10
@@ -1,4 +1,4 @@
|
||||
{ pkgs }:
|
||||
{ pkgs, kube }:
|
||||
{
|
||||
appOptions = opts: with pkgs.lib; {
|
||||
enable = mkOption {
|
||||
@@ -25,20 +25,26 @@
|
||||
description = "Enable server-side diffing";
|
||||
};
|
||||
|
||||
name = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
default = null;
|
||||
description = "Application name";
|
||||
};
|
||||
|
||||
namespace = mkOption {
|
||||
type = types.string;
|
||||
type = types.nullOr types.str;
|
||||
default = null;
|
||||
description = "Namespace";
|
||||
};
|
||||
|
||||
project = mkOption {
|
||||
type = types.string;
|
||||
type = types.str;
|
||||
default = "default";
|
||||
description = "Project";
|
||||
};
|
||||
|
||||
cluster = mkOption {
|
||||
type = types.string;
|
||||
type = types.str;
|
||||
default = "https://kubernetes.default.svc";
|
||||
description = "Cluster";
|
||||
};
|
||||
@@ -54,6 +60,11 @@
|
||||
with pkgs.lib;
|
||||
let
|
||||
app = conf // {
|
||||
name = if builtins.isNull cfg.name then "${cfg.env}-${name}" else cfg.name;
|
||||
project = cfg.project;
|
||||
|
||||
destination.server = cfg.cluster;
|
||||
|
||||
createNamespace = true;
|
||||
|
||||
compareOptions = {
|
||||
@@ -70,14 +81,13 @@
|
||||
selfHeal = false;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
} // (if builtins.isNull cfg.namespace then {} else { namespace = cfg.namespace; });
|
||||
in mkIf cfg.enable { applications.${name} = app; };
|
||||
|
||||
appValues = with pkgs.lib; vs: values:
|
||||
appValues = with pkgs.lib; { env, base, extraValues}:
|
||||
attrsets.mergeAttrsList (lists.flatten [
|
||||
(lib.kube.fromYAML (builtins.readFile "${vs}/values.yaml"))
|
||||
(lib.kube.fromYAML (builtins.readFile "${vs}/values-${env}.yaml"))
|
||||
[ values ]
|
||||
(kube.fromYAML (builtins.readFile "${base}/values.yaml"))
|
||||
(kube.fromYAML (builtins.readFile "${base}/values-${env}.yaml"))
|
||||
[ extraValues ]
|
||||
]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user