107 lines
3.0 KiB
Nix
107 lines
3.0 KiB
Nix
{ lib, config, ... }:
|
|
let
|
|
cfg = config.services.atlantis;
|
|
in
|
|
{
|
|
options.services.atlantis = {
|
|
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";
|
|
};
|
|
};
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
applications.atlantis.resources = {
|
|
applicationSets = {
|
|
atlantis.spec = {
|
|
goTemplate = true;
|
|
generators = [
|
|
{
|
|
list = {
|
|
elements = [
|
|
{
|
|
env = "prod";
|
|
namespace = "atlantis";
|
|
project = "atlantis";
|
|
cluster = "https://kubernetes.default.svc";
|
|
hostname = "atlantis.srv.oceanbox.io";
|
|
revision = "main";
|
|
autoSync = cfg.autoSync;
|
|
prune = cfg.prune;
|
|
}
|
|
{
|
|
env = "staging";
|
|
namespace = "atlantis";
|
|
project = "atlantis";
|
|
cluster = "https://staging-vcluster.staging-vcluster";
|
|
hostname = "atlantis.beta.oceanbox.io";
|
|
revision = "main";
|
|
autoSync = cfg.autoSync;
|
|
prune = cfg.prune;
|
|
}
|
|
];
|
|
};
|
|
}
|
|
];
|
|
template = {
|
|
metadata = {
|
|
name = "{{ .env }}-atlantis";
|
|
annotations = {
|
|
"argocd.argoproj.io/compare-options" = "ServerSideDiff=true";
|
|
};
|
|
};
|
|
spec = {
|
|
destination = {
|
|
namespace = "{{`{{.namespace}}`}}";
|
|
server = "{{ .cluster }}";
|
|
};
|
|
project = "{{`{{.project}}`}}";
|
|
sources = [
|
|
{
|
|
repoURL = "https://gitlab.com/oceanbox/manifests.git";
|
|
targetRevision = "{{`{{.revision}}`}}";
|
|
path = "kustomizations/atlantis";
|
|
plugin = {
|
|
name = "kustomize-helm-with-rewrite";
|
|
parameters = [
|
|
{
|
|
name = "env";
|
|
string = "{{ .env }}";
|
|
}
|
|
{
|
|
name = "hostname";
|
|
string = "{{ .hostname }}";
|
|
}
|
|
];
|
|
};
|
|
}
|
|
];
|
|
syncPolicy = {
|
|
syncOptions = [
|
|
"CreateNamespace=true"
|
|
"ApplyOutOfSyncOnly=true"
|
|
];
|
|
automated = lib.mkIf cfg.autoSync {
|
|
prune = cfg.prune;
|
|
selfHeal = false;
|
|
};
|
|
};
|
|
};
|
|
};
|
|
};
|
|
};
|
|
};
|
|
};
|
|
}
|