diff --git a/modules/applications/default.nix b/modules/applications/default.nix index fbbac96..62e53e6 100644 --- a/modules/applications/default.nix +++ b/modules/applications/default.nix @@ -86,7 +86,7 @@ in { }; namespace = mkOption { type = types.str; - default = name; + default = config.name; description = "Namespace to deploy application into (defaults to name)."; }; createNamespace = mkOption { @@ -255,7 +255,7 @@ in { output = { path = mkOption { type = types.str; - default = name; + default = config.name; description = '' Name of the folder that contains all rendered resources for the application. Relative to the root of the repository. ''; diff --git a/modules/nixidy.nix b/modules/nixidy.nix index 8d80dd9..7f1606d 100644 --- a/modules/nixidy.nix +++ b/modules/nixidy.nix @@ -189,7 +189,7 @@ in { lib.attrsets.mapAttrs ( n: app: { metadata = { - name = n; + inherit (app) name; annotations = if app.annotations != {} then app.annotations diff --git a/tests/default.nix b/tests/default.nix index 27ce5c7..604fd50 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -8,6 +8,7 @@ ./compare-options.nix ./create-namespace.nix ./yamls.nix + ./override-name.nix ./helm/no-values.nix ./helm/with-values.nix ./helm/transformer.nix diff --git a/tests/override-name.nix b/tests/override-name.nix new file mode 100644 index 0000000..1cbe145 --- /dev/null +++ b/tests/override-name.nix @@ -0,0 +1,37 @@ +{config, ...}: let + apps = config.applications; +in { + applications.test1 = { + name = "test1override"; + }; + + test = { + name = "application name override"; + description = "Check that application name override works as expected."; + assertions = [ + { + description = "Output path should use override name."; + + expression = apps.test1.output.path; + + expected = "test1override"; + } + + { + description = "Namespace without override should use override name."; + + expression = apps.test1.namespace; + + expected = "test1override"; + } + + { + description = "Generated Argo CD applicaiton should use override name."; + + expression = apps.apps.resources.applications.test1.metadata.name; + + expected = "test1override"; + } + ]; + }; +}