Skip to content

Commit 247f07b

Browse files
author
Simon Emms
committed
[installer]: extract the minio incluster helm config into it's own package
1 parent cb7e182 commit 247f07b

File tree

2 files changed

+39
-24
lines changed

2 files changed

+39
-24
lines changed

installer/pkg/components/minio/helm.go

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,38 +2,22 @@
22
// Licensed under the GNU Affero General Public License (AGPL).
33
// See License-AGPL.txt in the project root for license information.
44

5+
// Minio is used for both incluster deployments and as a facade for non-GCP storage providers
6+
57
package minio
68

79
import (
8-
"fmt"
910
"github.com/gitpod-io/gitpod/installer/pkg/common"
10-
"github.com/gitpod-io/gitpod/installer/pkg/helm"
11-
"github.com/gitpod-io/gitpod/installer/third_party/charts"
12-
"helm.sh/helm/v3/pkg/cli/values"
11+
"github.com/gitpod-io/gitpod/installer/pkg/components/minio/incluster"
1312
"k8s.io/utils/pointer"
1413
)
1514

1615
var Helm = common.CompositeHelmFunc(
17-
helm.ImportTemplate(charts.Minio(), helm.TemplateConfig{}, func(cfg *common.RenderContext) (*common.HelmConfig, error) {
18-
accessKey := cfg.Values.StorageAccessKey
19-
if accessKey == "" {
20-
return nil, fmt.Errorf("unknown value: storage access key")
21-
}
22-
secretKey := cfg.Values.StorageSecretKey
23-
if secretKey == "" {
24-
return nil, fmt.Errorf("unknown value: storage secret key")
16+
func(cfg *common.RenderContext) ([]string, error) {
17+
if pointer.BoolDeref(cfg.Config.ObjectStorage.InCluster, false) {
18+
return incluster.Helm(ServiceAPIPort, ServiceConsolePort)(cfg)
2519
}
2620

27-
return &common.HelmConfig{
28-
Enabled: pointer.BoolDeref(cfg.Config.ObjectStorage.InCluster, false),
29-
Values: &values.Options{
30-
Values: []string{
31-
helm.KeyValue("minio.auth.rootUser", accessKey),
32-
helm.KeyValue("minio.auth.rootPassword", secretKey),
33-
helm.KeyValue("service.ports.api", fmt.Sprintf("%d", ServiceAPIPort)),
34-
helm.KeyValue("service.ports.console", fmt.Sprintf("%d", ServiceConsolePort)),
35-
},
36-
},
37-
}, nil
38-
}),
21+
return nil, nil
22+
},
3923
)
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Copyright (c) 2021 Gitpod GmbH. All rights reserved.
2+
// Licensed under the GNU Affero General Public License (AGPL).
3+
// See License-AGPL.txt in the project root for license information.
4+
5+
package incluster
6+
7+
import (
8+
"fmt"
9+
"github.com/gitpod-io/gitpod/installer/pkg/common"
10+
"github.com/gitpod-io/gitpod/installer/pkg/helm"
11+
"github.com/gitpod-io/gitpod/installer/third_party/charts"
12+
"helm.sh/helm/v3/pkg/cli/values"
13+
)
14+
15+
var Helm = func(apiPort int32, consolePort int32) common.HelmFunc {
16+
return common.CompositeHelmFunc(
17+
helm.ImportTemplate(charts.Minio(), helm.TemplateConfig{}, func(cfg *common.RenderContext) (*common.HelmConfig, error) {
18+
return &common.HelmConfig{
19+
Enabled: true,
20+
Values: &values.Options{
21+
Values: []string{
22+
helm.KeyValue("minio.auth.rootUser", cfg.Values.StorageAccessKey),
23+
helm.KeyValue("minio.auth.rootPassword", cfg.Values.StorageSecretKey),
24+
helm.KeyValue("minio.service.ports.api", fmt.Sprintf("%d", apiPort)),
25+
helm.KeyValue("minio.service.ports.console", fmt.Sprintf("%d", consolePort)),
26+
},
27+
},
28+
}, nil
29+
}),
30+
)
31+
}

0 commit comments

Comments
 (0)