-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Converge Container Start/Stop/Run/Create into CLI model #14240
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
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
6d8ba57
First cut at start/stop/run/create
dkbennett 2bfd4d1
Add command to the arg string
dkbennett 01ae2e5
Update tests
dkbennett 6c52f79
Fix signal to be an int
dkbennett 42b6f5d
adjust clang formatting for more readability on commands
dkbennett 0650dee
Actually fix formatting in Create
dkbennett 572d6b3
Add NO_LIMIT macro to avoid hardcoding -1, update tests, change throw…
dkbennett dd57e14
Update validation to validate all arg values in case of multiple
dkbennett da11187
Copilot adjustments
dkbennett 3b306a8
Fix formatting
dkbennett 4666dda
PR feedback and remove --all
dkbennett ae31aac
Merge branch 'feature/wsl-for-apps' into user/dkbennett/converge2
dkbennett f9dc17a
feedback update
dkbennett 050fc12
Merge feature/wsl-for-apps
dkbennett 04d562b
Copilot review adjustments
dkbennett 2a4ebbc
Merge and fix validation
dkbennett a8dab21
Fix missed error condition in argument conversion for out of range, a…
dkbennett File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| /*++ | ||
|
|
||
| Copyright (c) Microsoft. All rights reserved. | ||
|
|
||
| Module Name: | ||
|
|
||
| ArgumentValidation.cpp | ||
|
|
||
| Abstract: | ||
|
|
||
| Implementation of the Argument Validation. | ||
|
|
||
| --*/ | ||
| #include "Argument.h" | ||
| #include "ArgumentTypes.h" | ||
| #include "ArgumentValidation.h" | ||
| #include "ContainerModel.h" | ||
| #include "Exceptions.h" | ||
| #include <algorithm> | ||
| #include <charconv> | ||
|
|
||
| using namespace wsl::windows::common; | ||
|
|
||
| namespace wsl::windows::wslc { | ||
| // Common argument validation that occurs across multiple commands. | ||
| void Argument::Validate(const ArgMap& execArgs) const | ||
| { | ||
| switch (m_argType) | ||
| { | ||
| case ArgType::Signal: | ||
| validation::ValidateIntegerFromString<ULONG>(execArgs.GetAll<ArgType::Signal>(), m_name); | ||
| break; | ||
|
|
||
| case ArgType::Time: | ||
| validation::ValidateIntegerFromString<LONGLONG>(execArgs.GetAll<ArgType::Time>(), m_name); | ||
| break; | ||
|
|
||
| default: | ||
| break; | ||
| } | ||
| } | ||
| } // namespace wsl::windows::wslc | ||
|
|
||
| namespace wsl::windows::wslc::validation { | ||
|
|
||
| template <typename T> | ||
| void ValidateIntegerFromString(const std::vector<std::wstring>& values, const std::wstring& argName) | ||
| { | ||
| for (const auto& value : values) | ||
| { | ||
| std::ignore = GetIntegerFromString<T>(value, argName); | ||
| } | ||
| } | ||
|
|
||
| template <typename T> | ||
| T GetIntegerFromString(const std::wstring& value, const std::wstring& argName) | ||
| { | ||
| std::string narrowValue = string::WideToMultiByte(value); | ||
|
|
||
| T convertedValue{}; | ||
| auto result = std::from_chars(narrowValue.c_str(), narrowValue.c_str() + narrowValue.size(), convertedValue); | ||
| if (result.ec != std::errc()) | ||
| { | ||
| throw ArgumentException(L"Invalid " + argName + L" argument value: " + value); | ||
| } | ||
|
|
||
| return convertedValue; | ||
| } | ||
|
|
||
| } // namespace wsl::windows::wslc::validation |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| /*++ | ||
|
|
||
| Copyright (c) Microsoft. All rights reserved. | ||
|
|
||
| Module Name: | ||
|
|
||
| ArgumentValidation.h | ||
|
|
||
| Abstract: | ||
|
|
||
| Declaration of Argument Validation functions. | ||
|
|
||
| --*/ | ||
| #pragma once | ||
| #include "ArgumentTypes.h" | ||
| #include "Exceptions.h" | ||
|
|
||
| using namespace wsl::windows::wslc; | ||
| using namespace wsl::windows::wslc::argument; | ||
|
|
||
| namespace wsl::windows::wslc::validation { | ||
|
|
||
| template <typename T> | ||
| void ValidateIntegerFromString(const std::vector<std::wstring>& values, const std::wstring& argName); | ||
|
|
||
| template <typename T> | ||
| T GetIntegerFromString(const std::wstring& value, const std::wstring& argName = {}); | ||
|
|
||
| } // namespace wsl::windows::wslc::validation |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.