From a5cf93c7588e30ffabeaefb29267eb10e585dea5 Mon Sep 17 00:00:00 2001 From: Jonas Juselius Date: Thu, 10 Oct 2024 20:50:50 +0200 Subject: [PATCH] wip: add openfga app with direct helm render --- .gitignore | 6 ++-- apps/default.nix | 1 + apps/openfga.nix | 70 +++++++++++++++++++++++++++++++++++++++++++++ modules/default.nix | 2 +- 4 files changed, 75 insertions(+), 4 deletions(-) create mode 100644 apps/openfga.nix diff --git a/.gitignore b/.gitignore index 2432e9ce..098d7691 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ -_manifest.yaml -_resources.yaml *.tgz -_build/ +_*/ .direnv/ .pre-commit-config.yaml +_manifest.yaml +_resources.yaml diff --git a/apps/default.nix b/apps/default.nix index 1b6428bf..3acac358 100644 --- a/apps/default.nix +++ b/apps/default.nix @@ -2,6 +2,7 @@ { imports = [ ./atlantis.nix + ./openfga.nix ]; config = { diff --git a/apps/openfga.nix b/apps/openfga.nix new file mode 100644 index 00000000..1240c260 --- /dev/null +++ b/apps/openfga.nix @@ -0,0 +1,70 @@ +{ lib, config, charts, ... }: +let + cfg = config.services.openfga; + + namespace = "openfga"; + env = "prod"; + project = "aux"; + cluster = "https://kubernetes.default.svc"; + + values = lib.attrsets.recursiveUpdate {} cfg.values; +in + { + options.services.openfga = { + enable = lib.mkOption { + type = lib.types.bool; + default = true; + description = "Enable"; + }; + autoSync = lib.mkOption { + type = lib.types.bool; + default = true; + description = "Auto sync"; + }; + prune = lib.mkOption { + type = lib.types.bool; + default = false; + description = "Prune"; + }; + values = lib.mkOption { + type = lib.types.attrsOf lib.types.anything; + default = {}; + }; + }; + + config = lib.mkIf cfg.enable { + applications.openfga = { + inherit namespace; + inherit project; + + name = "${env}-openfga"; + destination.server = cluster; + + helm.releases.openfga = { + inherit values; + chart = lib.helm.downloadHelmChart { + repo = "https://openfga.github.io/helm-charts"; + chart = "openfga"; + version = "0.2.12"; + chartHash = "sha256-7yLcw9/oNPvCePrtTJwKAG88t0Ym5Dl/S83Gz+gQdDU="; + }; + }; + + annotations = { + "argocd.argoproj.io/compare-options" = "ServerSideDiff=true"; + }; + + syncPolicy = { + syncOptions = { + applyOutOfSyncOnly = true; + }; + autoSync = lib.mkIf cfg.autoSync { + prune = cfg.prune; + selfHeal = false; + }; + }; + + resources = {}; + }; + }; + } diff --git a/modules/default.nix b/modules/default.nix index ca1c709e..029d8022 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -7,7 +7,7 @@ target = { repository = "https://gitlab.com/oveanbox/manifests.git"; branch = "main"; - rootPath = "_build"; + rootPath = "_manifests"; }; resourceImports = [