Skip to content

Commit 6f7798c

Browse files
author
Simon Emms
committed
[installer]: add all combinations of images to the mirror function
1 parent 19e2ea8 commit 6f7798c

File tree

1 file changed

+113
-1
lines changed

1 file changed

+113
-1
lines changed

install/installer/cmd/mirror_list.go

Lines changed: 113 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
"github.com/gitpod-io/gitpod/installer/pkg/common"
1616
configv1 "github.com/gitpod-io/gitpod/installer/pkg/config/v1"
1717
"github.com/spf13/cobra"
18+
"k8s.io/utils/pointer"
1819
)
1920

2021
type mirrorListRepo struct {
@@ -85,6 +86,117 @@ func init() {
8586
mirrorListCmd.Flags().StringVarP(&mirrorListOpts.ConfigFN, "config", "c", os.Getenv("GITPOD_INSTALLER_CONFIG"), "path to the config file")
8687
}
8788

89+
func renderAllKubernetesObject(cfgVersion string, cfg *configv1.Config) ([]string, error) {
90+
fns := []func() ([]string, error){
91+
func() ([]string, error) {
92+
// Render for in-cluster dependencies
93+
return renderKubernetesObjects(cfgVersion, cfg)
94+
},
95+
func() ([]string, error) {
96+
// Render for external depedencies - AWS
97+
cfg.Database = configv1.Database{
98+
InCluster: pointer.Bool(false),
99+
External: &configv1.DatabaseExternal{
100+
Certificate: configv1.ObjectRef{
101+
Kind: configv1.ObjectRefSecret,
102+
Name: "value",
103+
},
104+
},
105+
}
106+
cfg.ContainerRegistry = configv1.ContainerRegistry{
107+
InCluster: pointer.Bool(false),
108+
External: &configv1.ContainerRegistryExternal{
109+
URL: "some-url",
110+
Certificate: configv1.ObjectRef{
111+
Kind: configv1.ObjectRefSecret,
112+
Name: "value",
113+
},
114+
},
115+
S3Storage: &configv1.S3Storage{
116+
Bucket: "some-bucket",
117+
Certificate: configv1.ObjectRef{
118+
Kind: configv1.ObjectRefSecret,
119+
Name: "value",
120+
},
121+
},
122+
}
123+
cfg.ObjectStorage = configv1.ObjectStorage{
124+
InCluster: pointer.Bool(false),
125+
S3: &configv1.ObjectStorageS3{
126+
Endpoint: "endpoint",
127+
Credentials: configv1.ObjectRef{
128+
Kind: configv1.ObjectRefSecret,
129+
Name: "value",
130+
},
131+
},
132+
}
133+
return renderKubernetesObjects(cfgVersion, cfg)
134+
},
135+
func() ([]string, error) {
136+
// Render for external depedencies - Azure
137+
cfg.Database.CloudSQL = nil
138+
cfg.ContainerRegistry = configv1.ContainerRegistry{
139+
InCluster: pointer.Bool(false),
140+
External: &configv1.ContainerRegistryExternal{
141+
URL: "some-url",
142+
Certificate: configv1.ObjectRef{
143+
Kind: configv1.ObjectRefSecret,
144+
Name: "value",
145+
},
146+
},
147+
}
148+
cfg.ObjectStorage = configv1.ObjectStorage{
149+
InCluster: pointer.Bool(false),
150+
Azure: &configv1.ObjectStorageAzure{
151+
Credentials: configv1.ObjectRef{
152+
Kind: configv1.ObjectRefSecret,
153+
Name: "value",
154+
},
155+
},
156+
}
157+
158+
return renderKubernetesObjects(cfgVersion, cfg)
159+
},
160+
func() ([]string, error) {
161+
// Render for external depedencies - GCP
162+
cfg.Database = configv1.Database{
163+
InCluster: pointer.Bool(false),
164+
CloudSQL: &configv1.DatabaseCloudSQL{
165+
Instance: "value",
166+
ServiceAccount: configv1.ObjectRef{
167+
Kind: configv1.ObjectRefSecret,
168+
Name: "value",
169+
},
170+
},
171+
}
172+
cfg.ObjectStorage = configv1.ObjectStorage{
173+
InCluster: pointer.Bool(false),
174+
CloudStorage: &configv1.ObjectStorageCloudStorage{
175+
Project: "project",
176+
ServiceAccount: configv1.ObjectRef{
177+
Kind: configv1.ObjectRefSecret,
178+
Name: "value",
179+
},
180+
},
181+
}
182+
183+
return renderKubernetesObjects(cfgVersion, cfg)
184+
},
185+
}
186+
187+
var k8s []string
188+
for _, fn := range fns {
189+
data, err := fn()
190+
if err != nil {
191+
return nil, err
192+
}
193+
194+
k8s = append(k8s, data...)
195+
}
196+
197+
return k8s, nil
198+
}
199+
88200
func generateMirrorList(cfgVersion string, cfg *configv1.Config) ([]mirrorListRepo, error) {
89201
// Throw error if set to the default Gitpod repository
90202
if cfg.Repository == common.GitpodContainerRegistry {
@@ -97,7 +209,7 @@ func generateMirrorList(cfgVersion string, cfg *configv1.Config) ([]mirrorListRe
97209
// Use the default Gitpod registry to pull from
98210
cfg.Repository = common.GitpodContainerRegistry
99211

100-
k8s, err := renderKubernetesObjects(cfgVersion, cfg)
212+
k8s, err := renderAllKubernetesObject(cfgVersion, cfg)
101213
if err != nil {
102214
return nil, err
103215
}

0 commit comments

Comments
 (0)