Refactor Template Step to use App and AppSource Updates#1829
Conversation
|
|
||
| public void StageFiles(string[] filesToStage) | ||
| public void UnstageFiles(string[] filesToRemove) |
| namespace Calamari.ArgoCD.Conventions.UpdateImageTag; | ||
|
|
||
| public record FileUpdateResult(HashSet<string> UpdatedImages, List<FilePathContent> PatchedFileContent); No newline at end of file | ||
| public record FileUpdateResult(bool hasChanges, HashSet<string> UpdatedImages, List<FilePathContent> PatchedFileContent, string[]? FilesRemoved = null); No newline at end of file |
There was a problem hiding this comment.
The HasChanges flag should be computed right?
There was a problem hiding this comment.
🤔 Prior to this, if there were UpdatedImages - then we determined that a change was made and should be commited.
Except that doesn't work for templating step (which will never results in changed images) - but maybe we could just say "if either of the files-changed list is non-empty)... which would make this much cleaner.
| namespace Calamari.ArgoCD.Conventions.UpdateImageTag; | ||
|
|
||
| public record FileUpdateResult(HashSet<string> UpdatedImages, List<FilePathContent> PatchedFileContent); No newline at end of file | ||
| public record FileUpdateResult(bool hasChanges, HashSet<string> UpdatedImages, List<FilePathContent> PatchedFileContent, string[]? FilesRemoved = null); No newline at end of file |
There was a problem hiding this comment.
Also should we be sharing FileUpdateResult ? UpdatedImages will never be populated for the manifest step etc.
There was a problem hiding this comment.
It was really useful to find a common type so that we could use for both steps :/ Maybe I can find a nicer solution 👍
There was a problem hiding this comment.
So turns out - the UpdatedImages ends up in Octopus, to be added to an event in AMplitude - and defaults to "0" if the UpdatedImages Variable is not populated.
source/Calamari/ArgoCD/Conventions/ManifestTemplating/CopyTemplatesSourceUpdater.cs
Outdated
Show resolved
Hide resolved
| log.Info($"Removing files recursively from {outputDirectory}"); | ||
| //TODO(tmm): Knowing we're in a git repository is a bit of a smell :( | ||
| var gitDir = Path.Combine(cleansedSubPath, ".git"); | ||
| // var gitDir = Path.Combine(cleansedSubPath, ".git"); |
| namespace Calamari.ArgoCD.Conventions.UpdateImageTag; | ||
|
|
||
| public record FileUpdateResult(bool hasChanges, HashSet<string> UpdatedImages, List<FilePathContent> PatchedFileContent, string[]? FilesRemoved = null); No newline at end of file | ||
| public record FileUpdateResult(HashSet<string> UpdatedImages, List<FilePathContent> PatchedFileContent, string[]? FilesRemoved = null) |
There was a problem hiding this comment.
Might as well make FilesRemoved non-nullable
There was a problem hiding this comment.
Maybe create static factory methods to aid creating this record for image-tag vs. manifest use
There was a problem hiding this comment.
going to avoid the factory method for now - being explicit in the "no files removed" is not a bad thin to have.
The field was nullable to minimise the files changed - but its probably sensible to make it explicit.
| { | ||
| var fileTreeEntry = repo.Branches[branchName.Value].Tip[filename]; | ||
| //filename will always be posix-compliant | ||
| var fileTreeEntry = repo.Branches[branchName.Value].Tip[filename.Replace(Path.DirectorySeparatorChar, '/')]; |
There was a problem hiding this comment.
Do you know if this filename also needs to be stripped of the leading "./"?
There was a problem hiding this comment.
I think, the way we're using it in the tests - the answer is "no" - but that's luck.
The reason we have a problem in production code is when the argo app's path is "./" :(

This splits up the UpdateArgoCDApplicationManifestsInstallConvention into 2 extra classes:
This should be reviewed when prior refactoring is merged (is built atop).