Skip to content

Add more options to applications module #32

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed

Conversation

adamchol
Copy link
Contributor

@adamchol adamchol commented Mar 6, 2025

This PR adds those options to applications module:

  • ignoreDifferences
  • managedNamespaceMetadata inside the syncPolicy
  • createNamespace inside the syncPolicy.syncOptions

This changes were made mainly to match some values originally generated by an operator (especially the createNamespace sync option which doesn't really make sense in normal cases). Seems like it's working fine with all the types. I didn't have time to write any tests for those options though and I'm not sure if this code fits well, so I'm open for any comments and I can do some cleanup later.

adamchol added 2 commits March 4, 2025 15:00
- add managedNamespaceMetadata option in syncPolicy
- add syncOption "CreateNamespace=true"
Copy link
Owner

@arnarg arnarg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really appreciate the contribution and I like the addition of ignoreDifferences!

One thought, maybe it would be better to introduce it as an attrsOf instead of listOf that is then changed to a list in the Application (effectively applications.<name>.ignoreDifferences.<kind>, since kind is the only required option). This would allow you to influence an ignoreDifferences rule from different modules, which you can't easily do when it's just a list.

Regarding the addition of createNamespace in syncOptions, I knew this feature existed in ArgoCD but I decided to instead have nixidy support generating an actual Namespace manifest with applications.<name>.createNamespace because (and correct me if I'm wrong) ArgoCD doesn't clean up the namespace it creates with the CreateNamespace=true feature when the application is deleted. Is there any other benefits from having ArgoCD handle this?

I'm concerned with that it might be confusing having both.

Finally, since these are 2 kind of unrelated changes, could you split this into 2 PRs instead?

Comment on lines +328 to +335
config = {
"group" = mkOverride 1002 null;
"jqPathExpressions" = mkOverride 1002 null;
"jsonPointers" = mkOverride 1002 null;
"managedFieldsManagers" = mkOverride 1002 null;
"name" = mkOverride 1002 null;
"namespace" = mkOverride 1002 null;
};
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While the fromCRD generator sets defaults like this, I don't do it anywhere in the nixidy codebase. Could you instead set the default = null; in each respective mkOption instead?

});
inherit (app) ignoreDifferences;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A minor nitpick, could you merge this with inherit (app) project; at the top of spec.

@arnarg
Copy link
Owner

arnarg commented Mar 28, 2025

Hey @adamchol, are you still interested in introducing these changes. I'm interested in the ignoreDifferences change with the comment I made previously.

I could implement it myself but I want you to have the credit if it matters to you :)

@adamchol
Copy link
Contributor Author

I am interested, sorry I couldn't find the time.

Should be done today or tomorrow.

@arnarg
Copy link
Owner

arnarg commented Mar 28, 2025

I am interested, sorry I couldn't find the time.

Should be done today or tomorrow.

No worries! Just checking :)

@arnarg
Copy link
Owner

arnarg commented May 9, 2025

@adamchol I'm closing this since we pulled the ignoreDifferences into another pull request. I'd like to still discuss the use of CreateNamespace in ArgoCD application over the current "actually creating a Namespace manifest as part of the application" if it's actually better that way, please open an issue or another pull request if you feel like that would be beneficial.

@arnarg arnarg closed this May 9, 2025
@adamchol
Copy link
Contributor Author

adamchol commented May 9, 2025

Hi! Actually, now I think there is no need for CreateNamespace since we can do it as part of application module as you described. I might open a PR/issue for managedNamespaceMetadata in the future thought, I'll check if it'd be useful for us and overall.

@arnarg
Copy link
Owner

arnarg commented May 9, 2025

I have used this technique to add a label to a namespace created by createNamespace = true;: https://github.com/arnarg/cluster/blob/main/modules/tailscale-operator/default.nix#L82

Do you feel like abstracting this to a managedNamespaceMetadata would be needed? I'm genuinely asking, I want to learn about how others use nixidy and need more opinions other than just my own :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants