microsoft/openvmm

Public

mirrored from https://github.com/microsoft/openvmmAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
release/2411-fork

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

flowey/flowey_hvlite/src/pipelines_shared/cfg_common_params.rs

100lines · modecode

1// Copyright (c) Microsoft Corporation.
2// Licensed under the MIT License.
3
4//! Shared logic to set cfg_common params across various backends
5
6use flowey::node::prelude::*;
7use flowey::pipeline::prelude::*;
8
9#[derive(Clone, Default, clap::Args)]
10#[clap(next_help_heading = "Local Only")]
11pub struct LocalRunArgs {
12 /// Emit verbose output when possible
13 #[clap(long)]
14 verbose: bool,
15
16 /// Run builds with --locked
17 #[clap(long)]
18 locked: bool,
19
20 /// Automatically install all required dependencies
21 #[clap(long)]
22 auto_install_deps: bool,
23
24 /// Don't prompt user when running certain interactive commands.
25 #[clap(long)]
26 non_interactive: bool,
27
28 /// (WSL2 only) Force the use of `mono` to download nuget packages.
29 #[clap(long)]
30 force_nuget_mono: bool,
31
32 /// Claim that nuget is using an external auth mechanism.
33 ///
34 /// This will skip the check to make sure Azure Credential Provider is
35 /// installed.
36 #[clap(long)]
37 external_nuget_auth: bool,
38}
39
40pub type FulfillCommonRequestsParamsResolver =
41 Box<dyn for<'a> Fn(&mut PipelineJobCtx<'a>) -> flowey_lib_hvlite::_jobs::cfg_common::Params>;
42
43fn get_params_local(
44 local_run_args: Option<LocalRunArgs>,
45) -> anyhow::Result<FulfillCommonRequestsParamsResolver> {
46 Ok(Box::new(move |_ctx| {
47 let LocalRunArgs {
48 verbose,
49 locked,
50 auto_install_deps,
51 non_interactive,
52 force_nuget_mono,
53 external_nuget_auth,
54 } = local_run_args.clone().unwrap_or_default();
55
56 flowey_lib_hvlite::_jobs::cfg_common::Params {
57 local_only: Some(flowey_lib_hvlite::_jobs::cfg_common::LocalOnlyParams {
58 interactive: !non_interactive,
59 auto_install: auto_install_deps,
60 force_nuget_mono,
61 external_nuget_auth,
62 ignore_rust_version: true,
63 }),
64 verbose: ReadVar::from_static(verbose),
65 locked,
66 deny_warnings: false,
67 }
68 }))
69}
70
71fn get_params_cloud(
72 pipeline: &mut Pipeline,
73) -> anyhow::Result<FulfillCommonRequestsParamsResolver> {
74 let param_verbose = pipeline.new_parameter_bool("Run with verbose output", Some(false));
75
76 Ok(Box::new(move |ctx: &mut PipelineJobCtx<'_>| {
77 flowey_lib_hvlite::_jobs::cfg_common::Params {
78 local_only: None,
79 verbose: ctx.use_parameter(param_verbose.clone()),
80 locked: true,
81 deny_warnings: true,
82 }
83 }))
84}
85
86pub fn get_cfg_common_params(
87 pipeline: &mut Pipeline,
88 backend_hint: PipelineBackendHint,
89 local_run_args: Option<LocalRunArgs>,
90) -> anyhow::Result<FulfillCommonRequestsParamsResolver> {
91 match backend_hint {
92 PipelineBackendHint::Local => get_params_local(local_run_args),
93 PipelineBackendHint::Ado | PipelineBackendHint::Github => {
94 if local_run_args.is_some() {
95 anyhow::bail!("cannot set local only params when emitting as non-local pipeline")
96 }
97 get_params_cloud(pipeline)
98 }
99 }
100}
101