Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions libs/config/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ std::unordered_map<std::string, std::string> CalculateTags(
{
std::unordered_map<std::string, std::string> valid_tags;

for (const auto& [fst, snd] : tags)
{
if (IsEmptyOrWhitespace(fst) == false && IsEmptyOrWhitespace(snd) == false)
{
valid_tags[fst] = snd;
}
}

const char* container_name = std::getenv(ConfigConstants::EnvVarContainer);
const char* process_name = std::getenv(ConfigConstants::EnvVarProcess);

Expand All @@ -41,14 +49,6 @@ std::unordered_map<std::string, std::string> CalculateTags(
}
}

for (const auto& [fst, snd] : tags)
{
if (IsEmptyOrWhitespace(fst) == false && IsEmptyOrWhitespace(snd) == false)
{
valid_tags[fst] = snd;
}
}

return valid_tags;
}

Expand Down
6 changes: 3 additions & 3 deletions libs/config/test_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,12 +190,12 @@ TEST_F(ConfigTest, MergingTags)
EXPECT_EQ(config.GetExtraTags().at("env"), "test");
}

// Override environment variables with explicit tags
// Override common tags with explicit env tags
{
containerGuard.setValue("test-container");
containerGuard.setValue("override-container");
processGuard.unsetValue();

std::unordered_map<std::string, std::string> tags = {{"nf.container", "override-container"}};
std::unordered_map<std::string, std::string> tags = {{"nf.container", "test-container"}};

Config config(writerConfig, tags);

Expand Down