diff --git a/cmd/relayproxy/config/retriever.go b/cmd/relayproxy/config/retriever.go
index a5dac21be1b..ad57f3527fb 100644
--- a/cmd/relayproxy/config/retriever.go
+++ b/cmd/relayproxy/config/retriever.go
@@ -34,9 +34,6 @@ func (c *RetrieverConf) IsValid() error {
if c.Kind == GitHubRetriever && c.RepositorySlug == "" {
return fmt.Errorf("invalid retriever: no \"repositorySlug\" property found for kind \"%s\"", c.Kind)
}
- if c.Kind == GitlabRetriever && c.URL == "" {
- return fmt.Errorf("invalid retriever: no \"URL\" property found for kind \"%s\"", c.Kind)
- }
if c.Kind == GitlabRetriever && c.RepositorySlug == "" {
return fmt.Errorf("invalid retriever: no \"repositorySlug\" property found for kind \"%s\"", c.Kind)
}
diff --git a/cmd/relayproxy/config/retriever_test.go b/cmd/relayproxy/config/retriever_test.go
index 8e120f9d732..2cb785f0c35 100644
--- a/cmd/relayproxy/config/retriever_test.go
+++ b/cmd/relayproxy/config/retriever_test.go
@@ -37,14 +37,6 @@ func TestRetrieverConf_IsValid(t *testing.T) {
wantErr: true,
errValue: "invalid retriever: no \"repositorySlug\" property found for kind \"github\"",
},
- {
- name: "kind GitlabRetriever without URL slug",
- fields: config.RetrieverConf{
- Kind: "gitlab",
- },
- wantErr: true,
- errValue: "invalid retriever: no \"URL\" property found for kind \"gitlab\"",
- },
{
name: "kind GitlabRetriever, with URL but without path",
fields: config.RetrieverConf{
diff --git a/retriever/gitlabretriever/retriever.go b/retriever/gitlabretriever/retriever.go
index 49fd64b87ad..61d82d2dcd5 100644
--- a/retriever/gitlabretriever/retriever.go
+++ b/retriever/gitlabretriever/retriever.go
@@ -5,6 +5,7 @@ import (
"fmt"
"net/http"
"net/url"
+ "strings"
"time"
httpretriever "github.com/thomaspoignant/go-feature-flag/retriever/httpretriever"
@@ -52,22 +53,17 @@ func (r *Retriever) Retrieve(ctx context.Context) ([]byte, error) {
r.BaseURL = "https://gitlab.com"
}
- parsedURL, err := url.Parse(r.BaseURL)
- if err != nil {
- return nil, fmt.Errorf("impossible to parse the param baseUrl %s", err)
- }
- parsedURL.Path, err = url.JoinPath(
- parsedURL.Path,
- "api/v4/projects",
+ path := strings.Join([]string{
+ r.BaseURL, "api/v4/projects",
url.QueryEscape(r.RepositorySlug),
"repository/files",
- url.QueryEscape(r.FilePath),
- )
+ url.QueryEscape(r.FilePath), "raw"}, "/")
+
+ parsedURL, err := url.Parse(path)
if err != nil {
- return nil, fmt.Errorf("impossible to parse the param baseUrl %s", err)
+ return nil, fmt.Errorf("impossible to parse the url %s", err)
}
- // add branch as
rawQuery := parsedURL.Query()
rawQuery.Set("ref", branch)
parsedURL.RawQuery = rawQuery.Encode()
diff --git a/website/docs/relay_proxy/configure_relay_proxy.md b/website/docs/relay_proxy/configure_relay_proxy.md
index e8dce721502..2300bfcea08 100644
--- a/website/docs/relay_proxy/configure_relay_proxy.md
+++ b/website/docs/relay_proxy/configure_relay_proxy.md
@@ -75,15 +75,15 @@ In this section we will present all the available retriever configuration availa
### GitLab
-| Field name | Type | Default | Description |
-|------------------|--------|----------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
-| `kind` | string | **none** | **(mandatory)** Value should be **`gitlab`**.
_This field is mandatory and describe which retriever you are using._ |
-| `repositorySlug` | string | **none** | **(mandatory)** The repository slug of the GitHub repository where your file is located _(ex: `thomaspoignant/go-feature-flag`)_. |
-| `path` | string | **none** | **(mandatory)** Path to the file inside the repository _(ex: `config/flag/my-flags.yaml`)_. |
-| `baseUrl` | string | `https://gitlab.com` | The base URL of your Gitlab instance. |
-| `branch` | string | `main` | The branch we should check in the repository. |
-| `token` | string | **none** | Github token is used to access a private repository, you need the repo permission ([how to create a GitHub token](https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/creating-a-personal-access-token)). |
-| `timeout` | string | `10000` | Timeout in millisecond used when calling GitHub. |
+| Field name | Type | Default | Description |
+|------------------|--------|----------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
+| `kind` | string | **none** | **(mandatory)** Value should be **`gitlab`**.
_This field is mandatory and describe which retriever you are using._ |
+| `repositorySlug` | string | **none** | **(mandatory)** The repository slug of the Gitlab repository where your file is located _(ex: `thomaspoignant/go-feature-flag`)_. |
+| `path` | string | **none** | **(mandatory)** Path to the file inside the repository _(ex: `config/flag/my-flags.yaml`)_. |
+| `baseUrl` | string | `https://gitlab.com` | The base URL of your Gitlab instance. |
+| `branch` | string | `main` | The branch we should check in the repository. |
+| `token` | string | **none** | Gitlab personal access token used to access a private repository ([Create a personal access token](https://docs.gitlab.com/ee/user/profile/personal_access_tokens.html#create-a-personal-access-token)). |
+| `timeout` | string | `10000` | Timeout in millisecond used when calling Gitlab. |
### File