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

Declare credential helpers to be a stable feature. #18615

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ public class AuthAndTLSOptions extends OptionsBase {
public Duration grpcKeepaliveTimeout;

@Option(
name = "experimental_credential_helper",
name = "credential_helper",
oldName = "experimental_credential_helper",
defaultValue = "null",
allowMultiple = true,
converter = UnresolvedScopedCredentialHelperConverter.class,
Expand All @@ -160,7 +161,8 @@ public class AuthAndTLSOptions extends OptionsBase {
public List<UnresolvedScopedCredentialHelper> credentialHelpers;

@Option(
name = "experimental_credential_helper_timeout",
name = "credential_helper_timeout",
oldName = "experimental_credential_helper_timeout",
defaultValue = "10s",
converter = DurationConverter.class,
documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
Expand All @@ -172,7 +174,8 @@ public class AuthAndTLSOptions extends OptionsBase {
public Duration credentialHelperTimeout;

@Option(
name = "experimental_credential_helper_cache_duration",
name = "credential_helper_cache_duration",
oldName = "experimental_credential_helper_cache_duration",
defaultValue = "30m",
converter = DurationConverter.class,
documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
Expand All @@ -184,17 +187,26 @@ public class AuthAndTLSOptions extends OptionsBase {
+ " of this flag.")
public Duration credentialHelperCacheTimeout;

/** One of the values of the `--experimental_credential_helper` flag. */
/**
* One of the values of the `--credential_helper` flag.
*/
@AutoValue
public abstract static class UnresolvedScopedCredentialHelper {
/** Returns the scope of the credential helper (if any). */

/**
* Returns the scope of the credential helper (if any).
*/
public abstract Optional<String> getScope();

/** Returns the (unparsed) path of the credential helper. */
/**
* Returns the (unparsed) path of the credential helper.
*/
public abstract String getPath();
}

/** A {@link Converter} for the `--experimental_credential_helper` flag. */
/**
* A {@link Converter} for the `--credential_helper` flag.
*/
public static final class UnresolvedScopedCredentialHelperConverter
extends Converter.Contextless<UnresolvedScopedCredentialHelper> {
public static final UnresolvedScopedCredentialHelperConverter INSTANCE =
Expand Down
4 changes: 2 additions & 2 deletions src/test/py/bazel/bzlmod/bzlmod_credentials_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def testCredentialsFromHelper(self):
) as static_server:
_, stdout, _ = self.RunBazel([
'run',
'--experimental_credential_helper=%workspace%/credhelper',
'--credential_helper=%workspace%/credhelper',
'--registry=' + static_server.getURL(),
'--registry=https://bcr.bazel.build',
'//:main',
Expand Down Expand Up @@ -156,7 +156,7 @@ def testCredentialsFromHelperOverrideNetrc(self):
_, stdout, _ = self.RunBazel(
[
'run',
'--experimental_credential_helper=%workspace%/credhelper',
'--credential_helper=%workspace%/credhelper',
'--registry=' + static_server.getURL(),
'--registry=https://bcr.bazel.build',
'//:main',
Expand Down
12 changes: 6 additions & 6 deletions src/test/shell/bazel/remote/remote_execution_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,15 @@ function test_credential_helper_remote_cache() {

bazel build \
--remote_cache=grpc://localhost:${worker_port} \
--experimental_credential_helper="${TEST_TMPDIR}/credhelper" \
--credential_helper="${TEST_TMPDIR}/credhelper" \
//a:a >& $TEST_log || fail "Build with credentials should have succeeded"

# First build should have called helper for 4 distinct URIs.
expect_credential_helper_calls 4

bazel build \
--remote_cache=grpc://localhost:${worker_port} \
--experimental_credential_helper="${TEST_TMPDIR}/credhelper" \
--credential_helper="${TEST_TMPDIR}/credhelper" \
//a:b >& $TEST_log || fail "Build with credentials should have succeeded"

# Second build should have hit the credentials cache.
Expand All @@ -137,7 +137,7 @@ function test_credential_helper_remote_execution() {
bazel build \
--spawn_strategy=remote \
--remote_executor=grpc://localhost:${worker_port} \
--experimental_credential_helper="${TEST_TMPDIR}/credhelper" \
--credential_helper="${TEST_TMPDIR}/credhelper" \
//a:a >& $TEST_log || fail "Build with credentials should have succeeded"

# First build should have called helper for 5 distinct URIs.
Expand All @@ -146,7 +146,7 @@ function test_credential_helper_remote_execution() {
bazel build \
--spawn_strategy=remote \
--remote_executor=grpc://localhost:${worker_port} \
--experimental_credential_helper="${TEST_TMPDIR}/credhelper" \
--credential_helper="${TEST_TMPDIR}/credhelper" \
//a:b >& $TEST_log || fail "Build with credentials should have succeeded"

# Second build should have hit the credentials cache.
Expand All @@ -159,7 +159,7 @@ function test_credential_helper_clear_cache() {
bazel build \
--spawn_strategy=remote \
--remote_executor=grpc://localhost:${worker_port} \
--experimental_credential_helper="${TEST_TMPDIR}/credhelper" \
--credential_helper="${TEST_TMPDIR}/credhelper" \
//a:a >& $TEST_log || fail "Build with credentials should have succeeded"

expect_credential_helper_calls 5
Expand All @@ -169,7 +169,7 @@ function test_credential_helper_clear_cache() {
bazel build \
--spawn_strategy=remote \
--remote_executor=grpc://localhost:${worker_port} \
--experimental_credential_helper="${TEST_TMPDIR}/credhelper" \
--credential_helper="${TEST_TMPDIR}/credhelper" \
//a:b >& $TEST_log || fail "Build with credentials should have succeeded"

# Build after clean should have called helper again.
Expand Down
10 changes: 5 additions & 5 deletions src/test/shell/bazel/starlark_repository_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1801,12 +1801,12 @@ function test_auth_from_credential_helper() {
bazel build //:it \
&& fail "Expected failure when downloading repo without credential helper"

bazel build --experimental_credential_helper="${TEST_TMPDIR}/credhelper" //:it \
bazel build --credential_helper="${TEST_TMPDIR}/credhelper" //:it \
|| fail "Expected success when downloading repo with credential helper"

expect_credential_helper_calls 1

bazel build --experimental_credential_helper="${TEST_TMPDIR}/credhelper" //:it \
bazel build --credential_helper="${TEST_TMPDIR}/credhelper" //:it \
|| fail "Expected success when downloading repo with credential helper"

expect_credential_helper_calls 1 # expect credentials to have been cached
Expand All @@ -1822,7 +1822,7 @@ function test_auth_from_credential_helper_overrides_starlark() {

setup_auth baduser badpass

bazel build --experimental_credential_helper="${TEST_TMPDIR}/credhelper" //:it \
bazel build --credential_helper="${TEST_TMPDIR}/credhelper" //:it \
|| fail "Expected success when downloading repo with credential helper overriding basic auth"
}

Expand Down Expand Up @@ -2217,7 +2217,7 @@ genrule(
cmd = "cp $< $@",
)
EOF
bazel build --experimental_credential_helper="${TEST_TMPDIR}/credhelper" //:it \
bazel build --credential_helper="${TEST_TMPDIR}/credhelper" //:it \
|| fail "Expected success despite needing a file behind credential helper"
}

Expand Down Expand Up @@ -2264,7 +2264,7 @@ genrule(
cmd = "cp $< $@",
)
EOF
bazel build --experimental_credential_helper="${TEST_TMPDIR}/credhelper" //:it \
bazel build --credential_helper="${TEST_TMPDIR}/credhelper" //:it \
|| fail "Expected success despite needing a file behind credential helper"
}

Expand Down