Consolidate build URL helpers into helpers/url with auth flag
What does this MR do?
Consolidates the git auth URL helper logic from common/build_url_helper.go into a new, reusable helpers/url/gitauth.go package, and removes dead code from the helpers/url package.
Key changes:
-
New
helpers/urlpackage (GitAuthHelper): IntroducesGitAuthHelper,GitAuthConfig, andGitAuthServerConfigtypes. The helper is constructed with anauthenticated boolflag, replacing the previous two-struct approach (authenticatedURLHelper/unauthenticatedURLHelper). Auth mode is now a single constructor parameter rather than a runtime interface switch. -
Removes
common/build_url_helper.go: TheurlHelperConfig,authenticatedURLHelper,unauthenticatedURLHelper, and related helpers are deleted.Build.urlHelpernow holds a*url_helpers.GitAuthHelperdirectly. -
Simplifies
Build.withUrlHelper(): Variables are resolved once up front, theGitAuthConfigis populated with the newServersub-struct (Host,SSHHost,SSHPort), and the feature flagGitURLsWithoutTokensis passed as theauthenticatedargument toNewGitAuthHelper(inverted:!ffOn). -
Removes dead code from
helpers/url:ScrubSecrets(scrub_secrets.go) and theSecretsCleanupHook(log/secrets_cleanup.go) along with their tests are deleted, as they were unused. -
Refactored tests: Once the new
GitAuthHelperwas proven to work against the originalcommonpackage tests (see pipeline below),TestGetRemoteURLandTestGetInsteadOfsincommon/build_test.gowere slimmed down to avoid duplicating the coverage that now lives inhelpers/url/gitauth_test.go. The new dedicated unit tests cover both authenticated and unauthenticated modes, SSH URL handling, submodule force-HTTPS rewrites, custom SSH ports/hosts, and fallback behaviour.
Motivation: The scripts-to-steps migration needs to reuse the git auth URL helper outside of the common package. Moving it to helpers/url makes it importable without creating a circular dependency.
What's the best way to test this MR?
- The new
GitAuthHelperwas first validated against the original unmodifiedcommonpackage tests to confirm behavioural parity: Pipeline 2358860522. - Once that was confirmed, the
commonpackage tests were refactored to remove duplication with the newhelpers/url/gitauth_test.gotests. - The full test suite now passes with the refactored tests in place.
What are the relevant issue numbers?
Closes #39285
Edited by Arran Walker