Skip to content

Commit 39e4a68

Browse files
nroeskecesmarvin
authored andcommitted
Merge branch 'release/v3.3.0' into main
2 parents 740e6f6 + d095381 commit 39e4a68

File tree

11 files changed

+335
-83
lines changed

11 files changed

+335
-83
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

88
## [Unreleased]
99

10+
## [v3.3.0] - 2025-01-27
11+
### Added
12+
- [#128] Proxy support for dogu, container and helm registry.
13+
- If configured via `.setup.env.proxy` the setup creates a secret `ces-proxy` with the fully url and uses this proxy to query the dogu registry.
14+
Other components e.g. component-operator uses the url from the secret too if available.
15+
In general if you use this proxy configuration you should also set the proxy for the dogus via the global config in the setup json.
16+
See [setup json documentation](https://docs.cloudogu.com/en/docs/system-components/ces-setup/operations/setup-json/#section-config_globalproxy).
17+
1018
## [v3.2.2] - 2024-12-19
1119
### Fixed
1220
- [#101] Fix CVE-2024-45337

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ RUN make compile-generic
3030
FROM gcr.io/distroless/static:nonroot
3131
LABEL maintainer="[email protected]" \
3232
NAME="k8s-ces-setup" \
33-
VERSION="3.2.2"
33+
VERSION="3.3.0"
3434

3535
WORKDIR /
3636

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Set these to the desired values
22
ARTIFACT_ID=k8s-ces-setup
3-
VERSION=3.2.2
3+
VERSION=3.3.0
44

55
GOTAG?=1.23.2
66
MAKEFILES_VERSION=9.3.2

app/setup/executor.go

Lines changed: 50 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ import (
99
k8sreg "github.com/cloudogu/k8s-registry-lib/repository"
1010
remotedogudescriptor "github.com/cloudogu/remote-dogu-descriptor-lib/repository"
1111
"maps"
12+
"net/url"
13+
"os"
1214
"slices"
15+
"strconv"
1316
"strings"
1417

1518
"github.com/cloudogu/cesapp-lib/core"
@@ -59,7 +62,12 @@ func NewExecutor(clusterConfig *rest.Config, k8sClient kubernetes.Interface, set
5962
Password: setupCtx.DoguRegistryConfiguration.Password,
6063
}
6164

62-
doguRepository, err := remotedogudescriptor.NewRemoteDoguDescriptorRepository(getRemoteConfig(setupCtx.DoguRegistryConfiguration.Endpoint, setupCtx.DoguRegistryConfiguration.URLSchema), credentials)
65+
config, err := getRemoteConfig(setupCtx.DoguRegistryConfiguration.Endpoint, setupCtx.DoguRegistryConfiguration.URLSchema)
66+
if err != nil {
67+
return nil, err
68+
}
69+
70+
doguRepository, err := remotedogudescriptor.NewRemoteDoguDescriptorRepository(config, credentials)
6371
if err != nil {
6472
return nil, fmt.Errorf("failed to create new remote dogu repository: %w", err)
6573
}
@@ -72,18 +80,55 @@ func NewExecutor(clusterConfig *rest.Config, k8sClient kubernetes.Interface, set
7280
}, nil
7381
}
7482

75-
func getRemoteConfig(endpoint string, urlSchema string) *core.Remote {
83+
func getRemoteConfig(endpoint string, urlSchema string) (*core.Remote, error) {
7684
endpoint = strings.TrimSuffix(endpoint, "/")
7785
if urlSchema == "default" {
7886
endpoint = strings.TrimSuffix(endpoint, "dogus")
7987
endpoint = strings.TrimSuffix(endpoint, "/")
8088
}
8189

90+
proxyURL, b := os.LookupEnv("PROXY_URL")
91+
92+
proxySettings := core.ProxySettings{}
93+
if b && len(proxyURL) > 0 {
94+
var err error
95+
if proxySettings, err = configureProxySettings(proxyURL); err != nil {
96+
return nil, err
97+
}
98+
}
99+
82100
return &core.Remote{
83-
Endpoint: endpoint,
84-
URLSchema: urlSchema,
85-
CacheDir: "/tmp",
101+
Endpoint: endpoint,
102+
URLSchema: urlSchema,
103+
CacheDir: "/tmp",
104+
ProxySettings: proxySettings,
105+
}, nil
106+
}
107+
108+
func configureProxySettings(proxyURL string) (core.ProxySettings, error) {
109+
parsedURL, err := url.Parse(proxyURL)
110+
if err != nil {
111+
return core.ProxySettings{}, fmt.Errorf("invalid proxy url: %w", err)
112+
}
113+
114+
proxySettings := core.ProxySettings{}
115+
proxySettings.Enabled = true
116+
if parsedURL.User != nil {
117+
proxySettings.Username = parsedURL.User.Username()
118+
if password, set := parsedURL.User.Password(); set {
119+
proxySettings.Password = password
120+
}
86121
}
122+
123+
proxySettings.Server = parsedURL.Hostname()
124+
125+
port, err := strconv.Atoi(parsedURL.Port())
126+
if err != nil {
127+
return core.ProxySettings{}, fmt.Errorf("invalid port %s: %w", parsedURL.Port(), err)
128+
}
129+
proxySettings.Port = port
130+
131+
return proxySettings, nil
87132
}
88133

89134
// RegisterSetupSteps adds a new step to the setup

app/setup/executor_test.go

Lines changed: 70 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -332,44 +332,93 @@ func Test_getRemoteConfig(t *testing.T) {
332332
urlSchema string
333333
}
334334
tests := []struct {
335-
name string
336-
args args
337-
want *core.Remote
335+
name string
336+
args args
337+
want *core.Remote
338+
wantErr assert.ErrorAssertionFunc
339+
setEnv func(t *testing.T)
338340
}{
339341
{
340-
name: "test default url schema",
341-
args: args{endpoint: "https://example.com/", urlSchema: "default"},
342-
want: &core.Remote{Endpoint: "https://example.com", URLSchema: "default", CacheDir: "/tmp"},
342+
name: "test default url schema",
343+
args: args{endpoint: "https://example.com/", urlSchema: "default"},
344+
want: &core.Remote{Endpoint: "https://example.com", URLSchema: "default", CacheDir: "/tmp"},
345+
wantErr: assert.NoError,
343346
},
344347
{
345-
name: "test default url schema with 'dogus' suffix",
346-
args: args{endpoint: "https://example.com/dogus", urlSchema: "default"},
347-
want: &core.Remote{Endpoint: "https://example.com", URLSchema: "default", CacheDir: "/tmp"},
348+
name: "test default url schema with 'dogus' suffix",
349+
args: args{endpoint: "https://example.com/dogus", urlSchema: "default"},
350+
want: &core.Remote{Endpoint: "https://example.com", URLSchema: "default", CacheDir: "/tmp"},
351+
wantErr: assert.NoError,
348352
},
349353
{
350-
name: "test default url schema with 'dogus/' suffix",
351-
args: args{endpoint: "https://example.com/dogus/", urlSchema: "default"},
352-
want: &core.Remote{Endpoint: "https://example.com", URLSchema: "default", CacheDir: "/tmp"},
354+
name: "test default url schema with 'dogus/' suffix",
355+
args: args{endpoint: "https://example.com/dogus/", urlSchema: "default"},
356+
want: &core.Remote{Endpoint: "https://example.com", URLSchema: "default", CacheDir: "/tmp"},
357+
wantErr: assert.NoError,
353358
},
354359
{
355-
name: "test non-default url schema",
356-
args: args{endpoint: "https://example.com/", urlSchema: "index"},
357-
want: &core.Remote{Endpoint: "https://example.com", URLSchema: "index", CacheDir: "/tmp"},
360+
name: "test non-default url schema",
361+
args: args{endpoint: "https://example.com/", urlSchema: "index"},
362+
want: &core.Remote{Endpoint: "https://example.com", URLSchema: "index", CacheDir: "/tmp"},
363+
wantErr: assert.NoError,
358364
},
359365
{
360-
name: "test non-default url schema with 'dogus' suffix",
361-
args: args{endpoint: "https://example.com/dogus", urlSchema: "index"},
362-
want: &core.Remote{Endpoint: "https://example.com/dogus", URLSchema: "index", CacheDir: "/tmp"},
366+
name: "test non-default url schema with 'dogus' suffix",
367+
args: args{endpoint: "https://example.com/dogus", urlSchema: "index"},
368+
want: &core.Remote{Endpoint: "https://example.com/dogus", URLSchema: "index", CacheDir: "/tmp"},
369+
wantErr: assert.NoError,
363370
},
364371
{
365-
name: "test non-default url schema with 'dogus/' suffix",
372+
name: "test non-default url schema with 'dogus/' suffix",
373+
args: args{endpoint: "https://example.com/dogus/", urlSchema: "index"},
374+
want: &core.Remote{Endpoint: "https://example.com/dogus", URLSchema: "index", CacheDir: "/tmp"},
375+
wantErr: assert.NoError,
376+
},
377+
{
378+
name: "test with proxy",
366379
args: args{endpoint: "https://example.com/dogus/", urlSchema: "index"},
367-
want: &core.Remote{Endpoint: "https://example.com/dogus", URLSchema: "index", CacheDir: "/tmp"},
380+
want: &core.Remote{Endpoint: "https://example.com/dogus", URLSchema: "index", CacheDir: "/tmp", ProxySettings: core.ProxySettings{
381+
Enabled: true,
382+
Server: "host",
383+
Port: 3128,
384+
Username: "user",
385+
Password: "password",
386+
}},
387+
wantErr: assert.NoError,
388+
setEnv: func(t *testing.T) {
389+
t.Setenv("PROXY_URL", "https://user:password@host:3128")
390+
},
391+
},
392+
{
393+
name: "test proxy invalid url",
394+
args: args{endpoint: "https://example.com/dogus/", urlSchema: "index"},
395+
want: nil,
396+
wantErr: assert.Error,
397+
setEnv: func(t *testing.T) {
398+
t.Setenv("PROXY_URL", "://f")
399+
},
400+
},
401+
{
402+
name: "test proxy invalid port",
403+
args: args{endpoint: "https://example.com/dogus/", urlSchema: "index"},
404+
want: nil,
405+
wantErr: assert.Error,
406+
setEnv: func(t *testing.T) {
407+
t.Setenv("PROXY_URL", "https://user:password@host:invalid")
408+
},
368409
},
369410
}
370411
for _, tt := range tests {
371412
t.Run(tt.name, func(t *testing.T) {
372-
assert.Equalf(t, tt.want, getRemoteConfig(tt.args.endpoint, tt.args.urlSchema), "getRemoteConfig(%v, %v)", tt.args.endpoint, tt.args.urlSchema)
413+
if tt.setEnv != nil {
414+
tt.setEnv(t)
415+
}
416+
417+
config, err := getRemoteConfig(tt.args.endpoint, tt.args.urlSchema)
418+
419+
tt.wantErr(t, err)
420+
421+
assert.Equalf(t, tt.want, config, "getRemoteConfig(%v, %v)", tt.args.endpoint, tt.args.urlSchema)
373422
})
374423
}
375424
}

0 commit comments

Comments
 (0)