Skip to content

Add track option for Additional Env Files#955

Merged
mbecker20 merged 1 commit into
moghtech:2.0.0from
ChanningHe:additional-env-files-track-option
Nov 11, 2025
Merged

Add track option for Additional Env Files#955
mbecker20 merged 1 commit into
moghtech:2.0.0from
ChanningHe:additional-env-files-track-option

Conversation

@ChanningHe
Copy link
Copy Markdown
Contributor

Problem

When using Additional Env Files with Stack resources, Komodo always attempts to read and validate these files. This causes issues when files don't exist in the repository until deployment time (e.g., files decrypted by SOPS to /dev/shm/ during Pre Deploy).

The UI would throw errors trying to read non-existent files, and potentially interfere with git operations.

Solution

Added an optional track field to AdditionalEnvFile configuration:

  • When track: true (default): Komodo manages the file
  • When track: false: File is only passed to docker compose via --env-file, no UI management

Notes

I'm not very familiar with Rust, and this codebase has significant complexity. If there are any issues, potential breakages, or better approaches to solve this problem, please let me know - feedback and suggestions are very welcome!

Testing

  • ✅ Backward compatibility: Old string format configs load correctly
  • ✅ New format: Track option works as expected in UI
  • ✅ Untracked files: Not included in all_file_paths() or all_file_dependencies()
  • ✅ Docker compose: All files (tracked + untracked) passed via --env-file

@mbecker20
Copy link
Copy Markdown
Member

Good idea, is it possible for you to rebase the changes onto 2.0.0 branch?

Comment thread client/core/rs/src/entities/stack.rs Outdated
/// Check if this file should be tracked by Komodo
pub fn tracked(&self) -> bool {
self.track
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This method isn't needed

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed

Comment thread client/core/rs/src/entities/stack.rs Outdated
/// Get the file path
pub fn path(&self) -> &str {
&self.path
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

not needed

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed

Comment thread client/core/rs/src/entities/stack.rs Outdated
.map(|f| f.path())
}

pub fn all_file_paths(&self) -> Vec<String> {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

rename to all_tracked_file_paths

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed

Comment thread bin/periphery/src/compose/mod.rs Outdated
write!(res, " --env-file {file}").with_context(|| {
format!("Failed to write --env-file arg for {file}")
})?;
write!(res, " --env-file {}", file.path())?;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

why change?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I mistakenly removed the error context while refactoring the function signature. I've restored the .with_context() calls.
Thanks for catching this!

@ChanningHe ChanningHe force-pushed the additional-env-files-track-option branch from 9b86506 to 07a69ce Compare November 3, 2025 23:58
@ChanningHe ChanningHe changed the base branch from main to 2.0.0 November 3, 2025 23:58
@ChanningHe ChanningHe force-pushed the additional-env-files-track-option branch from 07a69ce to e44828a Compare November 4, 2025 00:03
@ChanningHe
Copy link
Copy Markdown
Contributor Author

Rebased onto 2.0.0 (base branch updated).

Copy link
Copy Markdown
Member

@mbecker20 mbecker20 left a comment

Choose a reason for hiding this comment

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

LGTM thanks for the contribution

@mbecker20 mbecker20 merged commit 3c8ef0a into moghtech:2.0.0 Nov 11, 2025
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