Path: blob/main/install/installer/pkg/components/database/objects.go
2501 views
// Copyright (c) 2021 Gitpod GmbH. All rights reserved.1// Licensed under the GNU Affero General Public License (AGPL).2// See License.AGPL.txt in the project root for license information.34package database56import (7"github.com/gitpod-io/gitpod/installer/pkg/common"8"github.com/gitpod-io/gitpod/installer/pkg/components/database/cloudsql"9"github.com/gitpod-io/gitpod/installer/pkg/components/database/external"10"github.com/gitpod-io/gitpod/installer/pkg/components/database/incluster"11"k8s.io/apimachinery/pkg/runtime"12"k8s.io/utils/pointer"13)1415func cloudSqlEnabled(cfg *common.RenderContext) bool {16return !pointer.BoolDeref(cfg.Config.Database.InCluster, false) && cfg.Config.Database.CloudSQL != nil17}1819func externalEnabled(cfg *common.RenderContext) bool {20return !pointer.BoolDeref(cfg.Config.Database.InCluster, false) && cfg.Config.Database.External != nil21}2223func inClusterEnabled(cfg *common.RenderContext) bool {24return pointer.BoolDeref(cfg.Config.Database.InCluster, false)25}2627var Objects = common.CompositeRenderFunc(28common.CompositeRenderFunc(func(cfg *common.RenderContext) ([]runtime.Object, error) {29if inClusterEnabled(cfg) {30return incluster.Objects(cfg)31}32if cloudSqlEnabled(cfg) {33return cloudsql.Objects(cfg)34}35if externalEnabled(cfg) {36return external.Objects(cfg)37}38return nil, nil39}),40)4142var Helm = common.CompositeHelmFunc(43common.CompositeHelmFunc(func(cfg *common.RenderContext) ([]string, error) {44if inClusterEnabled(cfg) {45return incluster.Helm(cfg)46}4748return nil, nil49}),50)515253