diff --git a/libmamba/include/mamba/api/configuration.hpp b/libmamba/include/mamba/api/configuration.hpp index e21fb2a20f..861fdf9c77 100644 --- a/libmamba/include/mamba/api/configuration.hpp +++ b/libmamba/include/mamba/api/configuration.hpp @@ -8,6 +8,8 @@ #define MAMBA_API_CONFIGURATION_HPP #include +#include +#include #include @@ -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 dump_names = {} + ); + } #endif // MAMBA_CONFIG_HPP diff --git a/libmamba/src/api/config.cpp b/libmamba/src/api/config.cpp index 1cecb2e81e..f7b2f98f35 100644 --- a/libmamba/src/api/config.cpp +++ b/libmamba/src/api/config.cpp @@ -31,7 +31,7 @@ namespace mamba auto specs = config.at("specs").value>(); 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(); } @@ -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(); } diff --git a/libmamba/src/api/configuration.cpp b/libmamba/src/api/configuration.cpp index affefbf432..e8931a96f6 100644 --- a/libmamba/src/api/configuration.cpp +++ b/libmamba/src/api/configuration.cpp @@ -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); } @@ -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 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))); + std::cout << dump_text << std::endl; + } } diff --git a/micromamba/tests/test_config.py b/micromamba/tests/test_config.py index 205c70b8d3..38649f652b 100644 --- a/micromamba/tests/test_config.py +++ b/micromamba/tests/test_config.py @@ -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" )