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
9 changes: 9 additions & 0 deletions libmamba/include/mamba/api/configuration.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#define MAMBA_API_CONFIGURATION_HPP

#include <functional>
#include <string>
#include <vector>

#include <yaml-cpp/yaml.h>

Expand Down Expand Up @@ -961,6 +963,13 @@ namespace mamba
}

void use_conda_root_prefix(Configuration& config, bool force = false);

void print_dump(
const Configuration& config,
int dump_opts = MAMBA_SHOW_CONFIG_VALUES,
std::vector<std::string> dump_names = {}
);

}

#endif // MAMBA_CONFIG_HPP
4 changes: 2 additions & 2 deletions libmamba/src/api/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace mamba
auto specs = config.at("specs").value<std::vector<std::string>>();
int dump_opts = MAMBA_SHOW_CONFIG_DESCS | show_long_desc | show_group;

std::cout << config.dump(dump_opts, specs) << std::endl;
print_dump(config, dump_opts, specs);

config.operation_teardown();
}
Expand Down Expand Up @@ -64,7 +64,7 @@ namespace mamba
int dump_opts = MAMBA_SHOW_CONFIG_VALUES | show_sources | show_desc | show_long_desc
| show_group | show_all_rcs | show_all;

std::cout << config.dump(dump_opts, specs) << std::endl;
print_dump(config, dump_opts, specs);

config.operation_teardown();
}
Expand Down
10 changes: 9 additions & 1 deletion libmamba/src/api/configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2288,7 +2288,7 @@ namespace mamba
{
int dump_opts = MAMBA_SHOW_CONFIG_VALUES | MAMBA_SHOW_CONFIG_SRCS
| MAMBA_SHOW_ALL_CONFIGS;
std::cout << this->dump(dump_opts) << std::endl;
print_dump(*this, dump_opts);
exit(0);
}

Expand Down Expand Up @@ -2771,4 +2771,12 @@ namespace mamba
return dump_yaml(opts, names, get_grouped_config());
}
}

void print_dump(const Configuration& config, int dump_opts, std::vector<std::string> dump_names)
{
// Note: this function is intended to get more complex with incoming changes and need to be
// isolated in preparation for these changes.
const std::string dump_text = hide_secrets(config.dump(dump_opts, std::move(dump_names)));

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 not calling hide_secrets inside the Congifuration::dump method instead? This would allow to continue using operator<< instead of requiring a new free function.

@Klaim Klaim Apr 7, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

We could do that, although I was anticipating the need for a new function because of that pr that needs the fix from this pr.

But I can add it only in that pr if you prefer.

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.

Ah ok, then no need to change anything, let's merge!

std::cout << dump_text << std::endl;
}
}
9 changes: 3 additions & 6 deletions micromamba/tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -816,11 +816,8 @@ def test_envsubst_windows_problem(self, monkeypatch, rc_file):
monkeypatch.setenv("CONDA_CHANNEL_UPLOAD_USER", "uuuuuuuuu", True)
monkeypatch.setenv("CONDA_CHANNEL_UPLOAD_PASSWORD", "pppppppppppppppppppp", True)
out = self._roundtrip(rc_file, condarc)
# Note that the password is a secret and will be hidden in the output
assert out["channel_alias"] == "https://xxxxxxxxxxxxxxxxxxxx.com/t/*****/get"
assert (
out["channel_alias"]
== "https://xxxxxxxxxxxxxxxxxxxx.com/t/kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk/get"
)
assert (
out["custom_channels"]["yyyyyyyyyyyy"]
== "https://uuuuuuuuu:pppppppppppppppppppp@xxxxxxxxxxxxxxx.com"
out["custom_channels"]["yyyyyyyyyyyy"] == "https://uuuuuuuuu:*****@xxxxxxxxxxxxxxx.com"
)
Loading