Skip to content

Commit ddea418

Browse files
authored
Merge pull request #141 from fluxcd/revert-136
reverting pr #136
2 parents 04eef97 + 2e98cf1 commit ddea418

File tree

3 files changed

+0
-99
lines changed

3 files changed

+0
-99
lines changed

gitlab/auth.go

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ limitations under the License.
1717
package gitlab
1818

1919
import (
20-
"net/url"
21-
2220
"github.com/fluxcd/go-git-providers/gitprovider"
2321
gogitlab "github.com/xanzy/go-gitlab"
2422
)
@@ -39,21 +37,6 @@ func NewClient(token string, tokenType string, optFns ...gitprovider.ClientOptio
3937
return nil, err
4038
}
4139

42-
// Ensure that the URL includes a scheme when using a custom domain.
43-
if opts.Domain != nil && *opts.Domain != "" {
44-
d, err := url.Parse(*opts.Domain)
45-
if err != nil {
46-
return nil, err
47-
}
48-
if d.Scheme != "http" && d.Scheme != "https" {
49-
u := url.URL{
50-
Scheme: "https",
51-
Host: *opts.Domain,
52-
}
53-
*opts.Domain = u.String()
54-
}
55-
}
56-
5740
// Create a *http.Client using the transport chain
5841
httpClient, err := gitprovider.BuildClientFromTransportChain(opts.GetTransportChain())
5942
if err != nil {

gitlab/auth_test.go

Lines changed: 0 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import (
2020
"testing"
2121

2222
"github.com/fluxcd/go-git-providers/gitprovider"
23-
gogitlab "github.com/xanzy/go-gitlab"
2423
)
2524

2625
func TestSupportedDomain(t *testing.T) {
@@ -40,31 +39,16 @@ func TestSupportedDomain(t *testing.T) {
4039
opts: gitprovider.WithDomain("my-gitlab.dev.com"),
4140
want: "https://my-gitlab.dev.com",
4241
},
43-
{
44-
name: "custom domain without protocol with port",
45-
opts: gitprovider.WithDomain("my-gitlab.dev.com:1234"),
46-
want: "https://my-gitlab.dev.com:1234",
47-
},
4842
{
4943
name: "custom domain with https protocol",
5044
opts: gitprovider.WithDomain("https://my-gitlab.dev.com"),
5145
want: "https://my-gitlab.dev.com",
5246
},
53-
{
54-
name: "custom domain with https protocol with port",
55-
opts: gitprovider.WithDomain("https://my-gitlab.dev.com:1234"),
56-
want: "https://my-gitlab.dev.com:1234",
57-
},
5847
{
5948
name: "custom domain with http protocol",
6049
opts: gitprovider.WithDomain("http://my-gitlab.dev.com"),
6150
want: "http://my-gitlab.dev.com",
6251
},
63-
{
64-
name: "custom domain with http protocol with port",
65-
opts: gitprovider.WithDomain("http://my-gitlab.dev.com:1234"),
66-
want: "http://my-gitlab.dev.com:1234",
67-
},
6852
}
6953
for _, tt := range tests {
7054
t.Run(tt.name, func(t *testing.T) {
@@ -77,61 +61,6 @@ func TestSupportedDomain(t *testing.T) {
7761
}
7862
}
7963

80-
func TestBaseURL(t *testing.T) {
81-
tests := []struct {
82-
name string
83-
opts gitprovider.ClientOption
84-
expected string
85-
}{
86-
{
87-
name: "gitlab.com domain",
88-
opts: gitprovider.WithDomain("gitlab.com"),
89-
expected: "https://gitlab.com/api/v4/",
90-
},
91-
{
92-
name: "custom domain without protocol",
93-
opts: gitprovider.WithDomain("my-gitlab.dev.com"),
94-
expected: "https://my-gitlab.dev.com/api/v4/",
95-
},
96-
{
97-
name: "custom domain without protocol with port",
98-
opts: gitprovider.WithDomain("my-gitlab.dev.com:1234"),
99-
expected: "https://my-gitlab.dev.com:1234/api/v4/",
100-
},
101-
{
102-
name: "custom domain with https protocol",
103-
opts: gitprovider.WithDomain("https://my-gitlab.dev.com"),
104-
expected: "https://my-gitlab.dev.com/api/v4/",
105-
},
106-
{
107-
name: "custom domain with https protocol with port",
108-
opts: gitprovider.WithDomain("https://my-gitlab.dev.com:1234"),
109-
expected: "https://my-gitlab.dev.com:1234/api/v4/",
110-
},
111-
{
112-
name: "custom domain with http protocol",
113-
opts: gitprovider.WithDomain("http://my-gitlab.dev.com"),
114-
expected: "http://my-gitlab.dev.com/api/v4/",
115-
},
116-
{
117-
name: "custom domain with http protocol with port",
118-
opts: gitprovider.WithDomain("http://my-gitlab.dev.com:1234"),
119-
expected: "http://my-gitlab.dev.com:1234/api/v4/",
120-
},
121-
}
122-
for _, tt := range tests {
123-
t.Run(tt.name, func(t *testing.T) {
124-
c1, _ := NewClient("token", "oauth2", tt.opts)
125-
gc1 := c1.Raw().(*gogitlab.Client)
126-
assertEqual(t, tt.expected, gc1.BaseURL().String())
127-
128-
c2, _ := NewClient("token", "pat", tt.opts)
129-
gc2 := c2.Raw().(*gogitlab.Client)
130-
assertEqual(t, tt.expected, gc2.BaseURL().String())
131-
})
132-
}
133-
}
134-
13564
func assertEqual(t *testing.T, a interface{}, b interface{}) {
13665
if a != b {
13766
t.Fatalf("%s != %s", a, b)

gitlab/util.go

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"errors"
55
"fmt"
66
"net/http"
7-
"net/url"
87
"strings"
98

109
"github.com/fluxcd/go-git-providers/gitprovider"
@@ -193,16 +192,6 @@ func validateOrganizationRef(ref gitprovider.OrganizationRef, expectedDomain str
193192
func validateIdentityFields(ref gitprovider.IdentityRef, expectedDomain string) error {
194193
// Make sure the expected domain is used
195194

196-
// For custom domains ensure the expected domain only includes host
197-
// and port information but not the scheme.
198-
if expectedDomain != DefaultDomain {
199-
d, err := url.Parse(expectedDomain)
200-
if err != nil {
201-
return err
202-
}
203-
expectedDomain = d.Host
204-
}
205-
206195
if ref.GetDomain() != expectedDomain {
207196
return fmt.Errorf("domain %q not supported by this client: %w", ref.GetDomain(), gitprovider.ErrDomainUnsupported)
208197
}

0 commit comments

Comments
 (0)