-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Export command for winget settings. #2719
Changes from 3 commits
a0a9173
34d6e3c
1f31a7b
9497bf2
d552d45
aa36a86
0b7e4d4
c831d83
47d1ba3
b140188
2e68669
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,33 @@ namespace AppInstaller::CLI::Workflow | |
using namespace AppInstaller::Settings; | ||
using namespace AppInstaller::Utility; | ||
|
||
namespace | ||
{ | ||
struct AdminSettings | ||
{ | ||
AdminSettings() | ||
{ | ||
root["adminSettings"] = Json::ValueType::objectValue; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For DSC... not entirely. The admin settings resource will take a hashtable with something really similar to value of the adminSettings. We just needed a way to expose it without reading registry keys. Also, because reasons (mostly testing and not having to special case powershell) I'm adding the path of the local user settings file to But yes, I'm going to add a new schema. |
||
} | ||
|
||
void Add(AdminSetting setting) | ||
{ | ||
auto str = std::string{ Settings::AdminSettingToString(setting) }; | ||
root["adminSettings"][str] = Settings::IsAdminSettingEnabled(setting); | ||
} | ||
|
||
std::string ToJsonString() const | ||
{ | ||
Json::StreamWriterBuilder writerBuilder; | ||
writerBuilder.settings_["indentation"] = ""; | ||
return Json::writeString(writerBuilder, root); | ||
} | ||
|
||
private: | ||
Json::Value root{ Json::ValueType::objectValue }; | ||
}; | ||
} | ||
|
||
void EnableAdminSetting(Execution::Context& context) | ||
{ | ||
std::string_view adminSettingString = context.Args.GetArg(Execution::Args::Type::AdminSettingEnable); | ||
|
@@ -99,4 +126,22 @@ namespace AppInstaller::CLI::Workflow | |
ShellExecuteW(nullptr, nullptr, L"notepad", filePathUTF16.c_str(), nullptr, SW_SHOW); | ||
} | ||
} | ||
|
||
void ExportAdminSettings(Execution::Context& context) | ||
{ | ||
AdminSetting settings[] = | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This would be better if there were a |
||
{ | ||
AdminSetting::LocalManifestFiles, | ||
AdminSetting::BypassCertificatePinningForMicrosoftStore | ||
}; | ||
|
||
AdminSettings adminSettings; | ||
|
||
for (auto& setting : settings) | ||
{ | ||
adminSettings.Add(setting); | ||
} | ||
|
||
context.Reporter.Info() << adminSettings.ToJsonString() << std::endl; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just curious is there a particular reason to require admin for export? Exporting seems harmless to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no real reason. Removing.