Skip to content
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

Add workload config command #39888

Merged
merged 9 commits into from
Apr 4, 2024

Conversation

dsplaisted
Copy link
Member

  • Add dotnet workload config command to set the workload update mode
  • Fix displaying the workload version in dotnet --info and dotnet workload --version when in workload set mode but no workload set is installed
  • Add some initial workload set MSI installation tests

Here's the how the new dotnet workload config command works:

  • dotnet workload config --update-mode - Prints the current workload update mode
  • dotnet workload config --update-mode workload-set - Switches to workload set update mode
  • dotnet workload config --update-mode manifests - Switches to loose manifest update mode

Here's the command-line help:

C:\Users\User>dotnet workload config --help
Description:
  Modify or display workload configuration values.
  To display a value, specify the corresponding command-line option without providing a value.  For example: "dotnet
  workload config --update-mode"

Usage:
  dotnet workload config [options]

Options:
  --update-mode <manifests|workload-set>  Controls whether updates should look for workload sets or the latest version
                                          of each individual manifest.
  -?, -h, --help                          Show command line help.

This replaces the previous syntax, which was dotnet workload update --mode workloadset and dotnet workload update --mode loosemanifest. Note that the previous option was hidden from command-line help, where currently the dotnet workload config command is not hidden.

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Workloads untriaged Request triage from a team member labels Mar 29, 2024
@dsplaisted dsplaisted requested review from baronfel, Forgind and a team March 29, 2024 13:22
@baronfel
Copy link
Member

For these kinds of config-lookup commands there are generally two patterns:

  • NPM-style, where you have a syntax like npm config <get/set/delete/list> <key>[=optional value if the subcommand requires it]
    • Rust's cargo also uses this format
  • Git style, where you have git config <key> [value], where the presence of value signals a write instead of a read

I think using one of these forms would be easier for users to understand, because they would have experience in that form from other tools. This form would also scale to a more general dotnet config command in the future, where workload-specific config items would become something like workload.update-mode instead of just update-mode, for example.

To me, we should use one of these forms and use CliArguments to model these inputs. The CliArguments can use the same validation as currently described but make it easier to detect if the argument was even provided (can be controlled via Arity) and the values can be validated once the settings key is known using a validator in much the same way that you have already implemented.

In teams chat today, @marcpopMSFT mentioned that rollback and download link printing could be moved to this config command - I could see that, but I could also see versions like:

  • a read-only settings key with a name like package-links or rollback-file
  • a version of dotnet workload --info that accepted a flag to print these out, instead of update

I don't see as clear of an answer for that question.

@MiYanni
Copy link
Member

MiYanni commented Apr 1, 2024

@baronfel Correct me if I'm wrong, but doesn't the dotnet CLI have its own style of command structure? Like, a general command format that most of the commands use. I know we don't have rules/regulations against the command format. But I think your comment makes sense in the context of a brand new dotnet config command, where that command would have its own design identity.

In the context of just adding a small set of options for dotnet workload, I recommended we keep it feeling like the style of the rest of the dotnet workload commands. I think that'll make the most sense for this PR. And if we want to eventually make a dotnet config generalized command, we can add the ability to update the workload configuration there and eventually deprecate this usage in dotnet workload.

@baronfel
Copy link
Member

baronfel commented Apr 3, 2024

We talked today and we're going to keep the existing format in this PR, keeping a more broad treatment of the CLI grammar of a config command for a larger, centralized config effort.

{
_workloadInstaller.UpdateInstallMode(_sdkFeatureBand, false);
}
else if (string.IsNullOrEmpty(_updateMode))
Copy link
Member

Choose a reason for hiding this comment

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

The _hasUpdateMode check doesn't eliminate this possibility?

Copy link
Member Author

Choose a reason for hiding this comment

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

No, _hasUpdateMode specifies whether the --update-mode option was specified, but it's possible to specify the option without it's optional argument value, which we use to print the current value.

{
_workloadInstaller.UpdateInstallMode(_sdkFeatureBand, true);
}
else if (_updateMode == WorkloadConfigCommandParser.UpdateMode_Manifests)
Copy link
Member

Choose a reason for hiding this comment

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

.Equals for strings, no?

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed (also with invariant ignore case)

{
// dotnet workload config --update-mode workload-set

public static readonly string UpdateMode_WorkloadSet = "workload-set";
Copy link
Member

Choose a reason for hiding this comment

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

nit: typing - is hard. workloadset?

Also, I thought we were trying to not include "workload set" terminology? Not that I have a better proposal in this case...

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm pretty sure the guidance I got from @baronfel was to use dashes to separate words. I think that's the style we're going with in the CLI.

@@ -159,11 +159,6 @@ public void RefreshWorkloadManifests()
return _workloadSet?.Version!;
}

if (InstallStateContents.FromPath(Path.Combine(WorkloadInstallType.GetInstallStateFolder(_sdkVersionBand, _sdkRootPath), "default.json")).UseWorkloadSets == true)
Copy link
Member

Choose a reason for hiding this comment

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

We'd want this to change to echo the version for the current SDK, per our discussion this morning.

Copy link
Member Author

Choose a reason for hiding this comment

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

I've filed an issue to track the further changes needed: #40005

Comment on lines 23 to 24
bool _hasUpdateMode;
string? _updateMode;
Copy link
Member

Choose a reason for hiding this comment

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

nit private

Copy link
Member Author

Choose a reason for hiding this comment

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

private would be redundant here. I know it's inconsistent here and probably is throughout our codebase. Do we have a convention we are trying to follow for whether we should include private or not?

Copy link
Member

Choose a reason for hiding this comment

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

I generally prefer including it...not technically an answer, but it's my preference :)

Copy link
Member

Choose a reason for hiding this comment

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

I'm pretty sure explicit access modifiers for fields are the convention in the dotnet org. I'm surprised we don't have that enabled in our editorconfig.

IWorkloadResolverFactory? workloadResolverFactory = null
) : base(parseResult, CommonOptions.HiddenVerbosityOption, reporter)
{
// TODO: Is it possible to check the order of the options? This would allow us to print the values out in the same order they are specified on the command line
Copy link
Member

Choose a reason for hiding this comment

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

You can only get the list of tokens via the Tokens property. The list should be in the order in which they are read. But, that doesn't have a relationship with the CliArguments in any way, unfortunately. You'd have to make custom logic to figure that out.

@dsplaisted dsplaisted disabled auto-merge April 4, 2024 11:32
@dsplaisted dsplaisted merged commit ef92a8a into dotnet:release/8.0.3xx Apr 4, 2024
13 of 16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Workloads untriaged Request triage from a team member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants