Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(app): show git image registry domains #636

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions cmd/revproxy/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,13 @@ type metricsConfig struct {
}

type revProxyConfig struct {
RenkuBaseURL *url.URL `mapstructure:"renku_base_url"`
AllowOrigin []string `mapstructure:"allow_origin"`
ExternalGitlabURL *url.URL `mapstructure:"external_gitlab_url"`
RenkuServices renkuServicesConfig `mapstructure:",squash"`
Metrics metricsConfig `mapstructure:",squash"`
Port int
RenkuBaseURL *url.URL `mapstructure:"renku_base_url"`
AllowOrigin []string `mapstructure:"allow_origin"`
ExternalGitlabURL *url.URL `mapstructure:"external_gitlab_url"`
DefaultImageRegistryHost string `mapstructure:"default_image_registry_host"`
RenkuServices renkuServicesConfig `mapstructure:",squash"`
Metrics metricsConfig `mapstructure:",squash"`
Port int
}

func parseStringAsURL() mapstructure.DecodeHookFuncType {
Expand Down
6 changes: 6 additions & 0 deletions cmd/revproxy/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ func setupServer(config revProxyConfig) *echo.Echo {
return c.JSON(http.StatusOK, map[string]string{"status": "ok"})
})

// Config endpoints
configAPI := e.Group("/api/config")
configAPI.GET("/imageRegistries", func(c echo.Context) error {
return c.JSON(http.StatusOK, map[string]string{"default": config.DefaultImageRegistryHost})
})

return e
}

Expand Down
20 changes: 16 additions & 4 deletions cmd/revproxy/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,11 @@ func setupTestAuthServer(ID string, responseHeaders map[string]string, responseS
return srv, url
}

func setupTestRevproxy(upstreamServerURL *url.URL, authURL *url.URL, externalGitlabURL *url.URL) (*echo.Echo, *url.URL) {
func setupTestRevproxy(upstreamServerURL *url.URL, authURL *url.URL, externalGitlabURL *url.URL, defaultImageRegsitryHost string) (*echo.Echo, *url.URL) {
config := revProxyConfig{
RenkuBaseURL: upstreamServerURL,
ExternalGitlabURL: externalGitlabURL,
DefaultImageRegistryHost: defaultImageRegsitryHost,
Port: 8080,
RenkuServices: renkuServicesConfig{
Notebooks: upstreamServerURL,
Expand Down Expand Up @@ -124,7 +125,8 @@ func ParametrizedRouteTest(scenario TestCase) func(*testing.T) {
gitlab, gitlabURL = setupTestUpstream("gitlab", requestTracker)
defer gitlab.Close()
}
proxy, proxyURL := setupTestRevproxy(upstreamURL, authURL, gitlabURL)
imageRegistryHost := "registry.dev.renku.ch"
proxy, proxyURL := setupTestRevproxy(upstreamURL, authURL, gitlabURL, imageRegistryHost)
defer upstream.Close()
defer proxy.Close()
defer auth.Close()
Expand Down Expand Up @@ -155,10 +157,10 @@ func ParametrizedRouteTest(scenario TestCase) func(*testing.T) {
for hdrKey, hdrValue := range scenario.Expected.ResponseHeaders {
assert.Equal(t, hdrValue, res.Header.Get(hdrKey))
}
if scenario.Expected.Path != "" {
if scenario.Expected.Path != "" && len(reqs) > 0 {
assert.Equal(t, scenario.Expected.Path, reqs[len(reqs)-1].URL.EscapedPath())
}
if len(scenario.QueryParams) > 0 {
if len(scenario.QueryParams) > 0 && len(reqs) > 0 {
assert.Equal(t, reqURLQuery.Encode(), reqs[len(reqs)-1].URL.RawQuery)
}
}
Expand Down Expand Up @@ -334,6 +336,16 @@ func TestInternalSvcRoutes(t *testing.T) {
ExternalGitlab: false,
Expected: TestResults{Path: "/gitlab/api/v4/projects/some.username%2Ftest-project", VisitedServerIDs: []string{"auth", "upstream"}},
},
{
Path: "/api/config/gitRepositories",
ExternalGitlab: false,
Expected: TestResults{Path: "/api/config/gitRepositories"},
},
{
Path: "/api/config/gitRepositories",
ExternalGitlab: false,
Expected: TestResults{Path: "/api/config/gitRepositories"},
},
}
for _, testCase := range testCases {
// Test names show up poorly in vscode if the name contains "/"
Expand Down
2 changes: 2 additions & 0 deletions helm-chart/renku-gateway/templates/deployment-revproxy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ spec:
value: {{ .Values.core.hostname | default (printf "http://%s-core" .Release.Name ) | quote }}
- name: REVPROXY_RENKU_SERVICES_AUTH
value: {{ printf "http://%s-gateway-auth" .Release.Name }}
- name: REVPROXY_DEFAULT_IMAGE_REGISTRY_HOST
value: {{ .Values.global.gitlab.registryDomain | quote }}
- name: REVPROXY_PORT
value: "8080"
- name: REVPROXY_METRICS_ENABLED
Expand Down
2 changes: 2 additions & 0 deletions helm-chart/renku-gateway/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ global:
## Must contain a leading slash, use "/" for root path.
gitlab:
urlPrefix: /gitlab
## The domain of the gitlab image registry (i.e. registry.dev.renku.ch)
registryDomain:
gateway:
## Client secret of the renku client application registered in keycloak.
## Should be set to a proper value (i.e. by using openssl rand -hex 32) for production.
Expand Down