Skip to content

Commit 5e10a51

Browse files
committed
Add a preview flag
1 parent 122b73c commit 5e10a51

3 files changed

Lines changed: 19 additions & 1 deletion

File tree

crates/uv-preview/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ bitflags::bitflags! {
2626
const WORKSPACE_DIR = 1 << 14;
2727
const WORKSPACE_LIST = 1 << 15;
2828
const SBOM_EXPORT = 1 << 16;
29+
const AUTH_HELPER = 1 << 17;
2930
}
3031
}
3132

@@ -52,6 +53,7 @@ impl PreviewFeatures {
5253
Self::WORKSPACE_DIR => "workspace-dir",
5354
Self::WORKSPACE_LIST => "workspace-list",
5455
Self::SBOM_EXPORT => "sbom-export",
56+
Self::AUTH_HELPER => "auth-helper",
5557
_ => panic!("`flag_as_str` can only be used for exactly one feature flag"),
5658
}
5759
}
@@ -106,6 +108,7 @@ impl FromStr for PreviewFeatures {
106108
"workspace-dir" => Self::WORKSPACE_DIR,
107109
"workspace-list" => Self::WORKSPACE_LIST,
108110
"sbom-export" => Self::SBOM_EXPORT,
111+
"auth-helper" => Self::AUTH_HELPER,
109112
_ => {
110113
warn_user_once!("Unknown preview feature: `{part}`");
111114
continue;

crates/uv/src/commands/auth/helper.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ use tracing::debug;
88

99
use uv_auth::{AuthBackend, Credentials, PyxTokenStore};
1010
use uv_client::BaseClientBuilder;
11-
use uv_preview::Preview;
11+
use uv_preview::{Preview, PreviewFeatures};
1212
use uv_redacted::DisplaySafeUrl;
13+
use uv_warnings::warn_user;
1314

1415
use crate::{commands::ExitStatus, printer::Printer, settings::NetworkSettings};
1516

@@ -126,6 +127,13 @@ pub(crate) async fn helper(
126127
network_settings: &NetworkSettings,
127128
printer: Printer,
128129
) -> Result<ExitStatus> {
130+
if !preview.is_enabled(PreviewFeatures::AUTH_HELPER) {
131+
warn_user!(
132+
"The `uv auth helper` command is experimental and may change without warning. Pass `--preview-features {}` to disable this warning",
133+
PreviewFeatures::AUTH_HELPER
134+
);
135+
}
136+
129137
let request = BazelCredentialRequest::from_stdin()?;
130138

131139
// TODO: make this logic generic over the protocol by providing `request.uri` from a

crates/uv/tests/it/auth.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1955,6 +1955,7 @@ fn bazel_helper_basic_auth() {
19551955
{"headers":{"Authorization":["Basic dGVzdHVzZXI6dGVzdHBhc3M="]}}
19561956
19571957
----- stderr -----
1958+
warning: The `uv auth helper` command is experimental and may change without warning. Pass `--preview-features auth-helper` to disable this warning
19581959
"#
19591960
);
19601961
}
@@ -1988,6 +1989,7 @@ fn bazel_helper_token() {
19881989
{"headers":{"Authorization":["Basic X190b2tlbl9fOm15dG9rZW4xMjM="]}}
19891990
19901991
----- stderr -----
1992+
warning: The `uv auth helper` command is experimental and may change without warning. Pass `--preview-features auth-helper` to disable this warning
19911993
"#
19921994
);
19931995
}
@@ -2007,6 +2009,7 @@ fn bazel_helper_no_credentials() {
20072009
{"headers":{}}
20082010
20092011
----- stderr -----
2012+
warning: The `uv auth helper` command is experimental and may change without warning. Pass `--preview-features auth-helper` to disable this warning
20102013
"#
20112014
);
20122015
}
@@ -2026,6 +2029,7 @@ fn bazel_helper_invalid_json() {
20262029
----- stdout -----
20272030
20282031
----- stderr -----
2032+
warning: The `uv auth helper` command is experimental and may change without warning. Pass `--preview-features auth-helper` to disable this warning
20292033
error: Failed to parse credential request as JSON
20302034
Caused by: expected ident at line 1 column 2
20312035
"
@@ -2047,6 +2051,7 @@ fn bazel_helper_invalid_uri() {
20472051
----- stdout -----
20482052
20492053
----- stderr -----
2054+
warning: The `uv auth helper` command is experimental and may change without warning. Pass `--preview-features auth-helper` to disable this warning
20502055
error: Failed to parse credential request as JSON
20512056
Caused by: relative URL without a base: "not a url" at line 1 column 18
20522057
"#
@@ -2083,6 +2088,7 @@ fn bazel_helper_username_in_uri() {
20832088
{"headers":{"Authorization":["Basic c3BlY2lmaWN1c2VyOnNwZWNpZmljcGFzcw=="]}}
20842089
20852090
----- stderr -----
2091+
warning: The `uv auth helper` command is experimental and may change without warning. Pass `--preview-features auth-helper` to disable this warning
20862092
"#
20872093
);
20882094
}
@@ -2117,6 +2123,7 @@ fn bazel_helper_unknown_username_in_uri() {
21172123
{"headers":{}}
21182124
21192125
----- stderr -----
2126+
warning: The `uv auth helper` command is experimental and may change without warning. Pass `--preview-features auth-helper` to disable this warning
21202127
"#
21212128
);
21222129
}

0 commit comments

Comments
 (0)