diff --git a/CHANGELOG.md b/CHANGELOG.md index b782b1e3..97ae6d74 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Documentation structure ### Fixed - Vault nilpointer if `SKIP_VAULT_SETUP` is set +- Fix broken `gitlab.com` detection due to CloudFlare checking ## v0.1.5 - 2020-06-12 ### Added diff --git a/pkg/git/gitlab/gitlab.go b/pkg/git/gitlab/gitlab.go index 4b81e5f6..45647a0e 100644 --- a/pkg/git/gitlab/gitlab.go +++ b/pkg/git/gitlab/gitlab.go @@ -2,10 +2,8 @@ package gitlab import ( "fmt" - "net/http" "net/url" "strings" - "time" "github.com/projectsyn/lieutenant-operator/pkg/git/helpers" "github.com/projectsyn/lieutenant-operator/pkg/git/manager" @@ -225,30 +223,11 @@ func (g *Gitlab) FullURL() *url.URL { return sshURL } -// IsType determines if the given url can be handled by this concrete implementation. -// This is done by a simple http query to the login page of gitlab. If any errors occur anywhere -// it will return false. +// TODO: this will be deprecated in favour of a fixed type definition in the +// CRD. As there's currently only the GitLab implementation this is a workaround +// for the brittle detection. func (g *Gitlab) IsType(URL *url.URL) (bool, error) { - httpClient := &http.Client{ - Timeout: 10 * time.Second, - } - - gitlabURL := URL.Scheme + "://" + URL.Host + "/users/sign_in'" - - resp, err := httpClient.Get(gitlabURL) - if err != nil { - return false, err - } - - if resp.StatusCode == http.StatusNotFound { - return false, nil - } - - if resp.StatusCode != http.StatusOK { - return false, fmt.Errorf("status code was %d", resp.StatusCode) - } - return true, nil } diff --git a/pkg/git/gitlab/gitlab_test.go b/pkg/git/gitlab/gitlab_test.go index d0f1721b..9a5e0d3b 100644 --- a/pkg/git/gitlab/gitlab_test.go +++ b/pkg/git/gitlab/gitlab_test.go @@ -73,36 +73,6 @@ func TestGitlab_Read(t *testing.T) { } } -func TestGitlab_IsType(t *testing.T) { - tests := []struct { - name string - want bool - httpServer *httptest.Server - }{ - { - name: "is gitlab", - want: true, - httpServer: testGetHTTPServer(http.StatusOK, []byte("")), - }, - { - name: "is not Gitlab", - want: false, - httpServer: testGetHTTPServer(http.StatusNotFound, []byte("")), - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - defer tt.httpServer.Close() - g := &Gitlab{} - serverURL, _ := url.Parse(tt.httpServer.URL) - if got, _ := g.IsType(serverURL); got != tt.want { - t.Errorf("IsType() = %v, want %v", got, tt.want) - } - }) - } - -} - func testGetCreateServer() *httptest.Server { mux := http.NewServeMux()