Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarthik Nayak <knayak@gitlab.com>2022-09-29 10:34:55 +0300
committerJohn Cai <jcai@gitlab.com>2022-11-02 21:40:46 +0300
commit7769f643229158ffd83e2bd0a903d6b93ddac121 (patch)
treedd8647a32d6a9a68f4f59e736bbe0a3283961082
parentc34800b226f9a23b8236b4adc1c2f3e59565a272 (diff)
remote: Use `GetURLAndResolveConfig()`
In `updateRemoteMirror()` use `GetURLAndResolveConfig()` to get the configPair and modified URL to avoid DNS rebinding. Unfortunately, because of the structure of the code, the `git.Cmd` is not exposed on this level, which means the added code is not testable.
-rw-r--r--internal/gitaly/service/remote/update_remote_mirror.go17
1 files changed, 15 insertions, 2 deletions
diff --git a/internal/gitaly/service/remote/update_remote_mirror.go b/internal/gitaly/service/remote/update_remote_mirror.go
index 63cad5be2..eff0189fc 100644
--- a/internal/gitaly/service/remote/update_remote_mirror.go
+++ b/internal/gitaly/service/remote/update_remote_mirror.go
@@ -71,10 +71,23 @@ func (s *server) updateRemoteMirror(stream gitalypb.RemoteService_UpdateRemoteMi
}
remoteName := "inmemory-" + remoteSuffix
- remoteConfig := []git.ConfigPair{
- {Key: fmt.Sprintf("remote.%s.url", remoteName), Value: remote.GetUrl()},
+ var remoteConfig []git.ConfigPair
+ remoteURL := remote.GetUrl()
+
+ if resolvedAddress := remote.GetResolvedAddress(); resolvedAddress != "" {
+ modifiedURL, resolveConfig, err := git.GetURLAndResolveConfig(remoteURL, resolvedAddress)
+ if err != nil {
+ return fmt.Errorf("couldn't get curloptResolve config: %w", err)
+ }
+
+ remoteURL = modifiedURL
+ remoteConfig = append(remoteConfig, resolveConfig...)
}
+ remoteConfig = append(remoteConfig, git.ConfigPair{
+ Key: fmt.Sprintf("remote.%s.url", remoteName), Value: remoteURL,
+ })
+
if authHeader := remote.GetHttpAuthorizationHeader(); authHeader != "" {
remoteConfig = append(remoteConfig, git.ConfigPair{
Key: fmt.Sprintf("http.%s.extraHeader", remote.GetUrl()),