Modern Docker Management, Designed for Everyone
Go composecontainer-managementcontainersdockerdocker-composedocker-managementgoself-hostedsveltekittypescriptweb-ui
fix: honor SSH usernames in Git repository URLs
Kyle Mendell837fe10c92dd
diff --git a/backend/pkg/gitutil/git.go b/backend/pkg/gitutil/git.goindex 71b937fe0..6e5715a47 100644--- a/backend/pkg/gitutil/git.go+++ b/backend/pkg/gitutil/git.go@@ -118,8 +118,8 @@ type AuthConfig struct {SSHHostKeyVerification string // strict, accept_new, skip}-// getAuth returns the appropriate transport.AuthMethod-func (c *Client) getAuth(config AuthConfig) (transport.AuthMethod, error) {+// getAuthInternal returns the appropriate transport.AuthMethod.+func (c *Client) getAuthInternal(url string, config AuthConfig) (transport.AuthMethod, error) {switch config.AuthType {case "http":if config.Token != "" {@@ -131,7 +131,15 @@ func (c *Client) getAuth(config AuthConfig) (transport.AuthMethod, error) {return nil, nilcase "ssh":if config.SSHKey != "" {- publicKeys, err := ssh.NewPublicKeys("git", []byte(config.SSHKey), "")+ endpoint, err := transport.NewEndpoint(url)+ if err != nil {+ return nil, errors.WrapIf(err, "failed to parse SSH repository URL")+ }+ username := endpoint.User+ if username == "" {+ username = "git"+ }+ publicKeys, err := ssh.NewPublicKeys(username, []byte(config.SSHKey), "")if err != nil {return nil, errors.WrapIf(err, "failed to create ssh auth")}@@ -319,13 +327,13 @@ func (c *Client) Clone(ctx context.Context, url, branch string, auth AuthConfig)return "", errors.WrapIf(err, "failed to create temp dir")}- authMethod, err := c.getAuth(auth)+ url, err = normalizeURL(url)if err != nil {_ = os.RemoveAll(tmpDir)return "", err}- url, err = normalizeURL(url)+ authMethod, err := c.getAuthInternal(url, auth)if err != nil {_ = os.RemoveAll(tmpDir)return "", err@@ -448,12 +456,12 @@ func (c *Client) ProbeRemote(ctx context.Context, url string, auth AuthConfig) e}func (c *Client) listRemoteReferences(ctx context.Context, url string, auth AuthConfig) ([]*plumbing.Reference, error) {- authMethod, err := c.getAuth(auth)+ url, err := normalizeURL(url)if err != nil {return nil, err}- url, err = normalizeURL(url)+ authMethod, err := c.getAuthInternal(url, auth)if err != nil {return nil, err}diff --git a/backend/pkg/projects/pull_policy_test.go b/backend/pkg/projects/pull_policy_test.goindex 60a2d2865..c048da687 100644--- a/backend/pkg/projects/pull_policy_test.go+++ b/backend/pkg/projects/pull_policy_test.go@@ -25,11 +25,9 @@ func TestResolveServiceImagePullMode(t *testing.T) {expected: ImagePullStep{Mode: ImagePullModeAlways},},{- // bare "refresh" is not a spec value; compose-go resolves it to- // missing, and compose v5.5.0 `up` follows that- name: "bare refresh policy behaves as missing",+ name: "bare refresh policy has a zero refresh window",service: composetypes.ServiceConfig{PullPolicy: composetypes.PullPolicyRefresh},- expected: ImagePullStep{Mode: ImagePullModeIfMissing},+ expected: ImagePullStep{Mode: ImagePullModeRefresh, RefreshAfter: 0},},{name: "daily policy is a 24h refresh window",