Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
gitpod-io
GitHub Repository: gitpod-io/gitpod
Path: blob/main/install/installer/pkg/components/database/objects.go
2501 views
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 database
6
7
import (
8
"github.com/gitpod-io/gitpod/installer/pkg/common"
9
"github.com/gitpod-io/gitpod/installer/pkg/components/database/cloudsql"
10
"github.com/gitpod-io/gitpod/installer/pkg/components/database/external"
11
"github.com/gitpod-io/gitpod/installer/pkg/components/database/incluster"
12
"k8s.io/apimachinery/pkg/runtime"
13
"k8s.io/utils/pointer"
14
)
15
16
func cloudSqlEnabled(cfg *common.RenderContext) bool {
17
return !pointer.BoolDeref(cfg.Config.Database.InCluster, false) && cfg.Config.Database.CloudSQL != nil
18
}
19
20
func externalEnabled(cfg *common.RenderContext) bool {
21
return !pointer.BoolDeref(cfg.Config.Database.InCluster, false) && cfg.Config.Database.External != nil
22
}
23
24
func inClusterEnabled(cfg *common.RenderContext) bool {
25
return pointer.BoolDeref(cfg.Config.Database.InCluster, false)
26
}
27
28
var Objects = common.CompositeRenderFunc(
29
common.CompositeRenderFunc(func(cfg *common.RenderContext) ([]runtime.Object, error) {
30
if inClusterEnabled(cfg) {
31
return incluster.Objects(cfg)
32
}
33
if cloudSqlEnabled(cfg) {
34
return cloudsql.Objects(cfg)
35
}
36
if externalEnabled(cfg) {
37
return external.Objects(cfg)
38
}
39
return nil, nil
40
}),
41
)
42
43
var Helm = common.CompositeHelmFunc(
44
common.CompositeHelmFunc(func(cfg *common.RenderContext) ([]string, error) {
45
if inClusterEnabled(cfg) {
46
return incluster.Helm(cfg)
47
}
48
49
return nil, nil
50
}),
51
)
52
53