Skip to content

Commit 3ffedc1

Browse files
author
Simon Emms
committed
[installer]: allow Installer to specify licensor type
Defaults to "legacy" and allows "replicated". This is defined by the secret
1 parent e55ba3e commit 3ffedc1

File tree

6 files changed

+39
-5
lines changed

6 files changed

+39
-5
lines changed

components/installer/pkg/components/server/configmap.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@ func configmap(ctx *common.RenderContext) ([]runtime.Object, error) {
2121
}
2222

2323
license := ""
24+
licenseTypeFile := ""
2425
if ctx.Config.License != nil {
25-
license = licenseFilePath
26+
license = fmt.Sprintf("%s/license", licensePath)
27+
licenseTypeFile = fmt.Sprintf("%s/licensor", licensePath) // If not set, will use "legacy"
2628
}
2729

2830
// todo(sje): all these values are configurable
@@ -32,6 +34,7 @@ func configmap(ctx *common.RenderContext) ([]runtime.Object, error) {
3234
InstallationShortname: ctx.Namespace, // todo(sje): is this needed?
3335
Stage: "production", // todo(sje): is this needed?
3436
LicenseFile: license,
37+
LicenseTypeFile: licenseTypeFile,
3538
WorkspaceHeartbeat: WorkspaceHeartbeat{
3639
IntervalSeconds: 60,
3740
TimeoutSeconds: 300,

components/installer/pkg/components/server/constants.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const (
1313
ContainerPort = 3000
1414
ContainerPortName = "http"
1515
authProviderFilePath = "/gitpod/auth-providers"
16-
licenseFilePath = "/gitpod/license"
16+
licensePath = "/gitpod/license"
1717
PrometheusPort = 9500
1818
PrometheusPortName = "metrics"
1919
InstallationAdminPort = common.ServerInstallationAdminPort

components/installer/pkg/components/server/deployment.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ func deployment(ctx *common.RenderContext) ([]runtime.Object, error) {
5151

5252
volumeMounts = append(volumeMounts, corev1.VolumeMount{
5353
Name: "gitpod-license-key",
54-
MountPath: licenseFilePath,
55-
SubPath: "license",
54+
MountPath: licensePath,
5655
ReadOnly: true,
5756
})
5857
}

components/installer/pkg/components/server/types.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ type ConfigSerialized struct {
1717
DevBranch string `json:"devBranch"`
1818
InsecureNoDomain bool `json:"insecureNoDomain"`
1919
License string `json:"license"`
20+
LicenseType string `json:"licenseType"`
2021
LicenseFile string `json:"licenseFile"`
22+
LicenseTypeFile string `json:"licenseTypeFile"`
2123
DefinitelyGpDisabled bool `json:"definitelyGpDisabled"`
2224
EnableLocalApp bool `json:"enableLocalApp"`
2325
BuiltinAuthProvidersConfigured bool `json:"builtinAuthProvidersConfigured"`

components/installer/pkg/config/v1/config.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,13 @@ type Workspace struct {
227227
Templates *WorkspaceTemplates `json:"templates,omitempty"`
228228
}
229229

230+
type LicensorType string
231+
232+
const (
233+
LicensorTypeLegacy LicensorType = "legacy"
234+
LicensorTypeReplicated LicensorType = "replicated"
235+
)
236+
230237
type FSShiftMethod string
231238

232239
const (

components/installer/pkg/config/v1/validation.go

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ var FSShiftMethodList = map[FSShiftMethod]struct{}{
4141
FSShiftShiftFS: {},
4242
}
4343

44+
var LicensorTypeList = map[LicensorType]struct{}{
45+
LicensorTypeLegacy: {},
46+
LicensorTypeReplicated: {},
47+
}
48+
4449
// LoadValidationFuncs load custom validation functions for this version of the config API
4550
func (v version) LoadValidationFuncs(validate *validator.Validate) error {
4651
funcs := map[string]validator.Func{
@@ -115,7 +120,25 @@ func (v version) ClusterValidation(rcfg interface{}) cluster.ValidationChecks {
115120

116121
if cfg.License != nil {
117122
secretName := cfg.License.Name
118-
res = append(res, cluster.CheckSecret(secretName, cluster.CheckSecretRequiredData("license")))
123+
licensorKey := "type"
124+
res = append(res, cluster.CheckSecret(secretName, cluster.CheckSecretRequiredData("license"), cluster.CheckSecretRecommendedData(licensorKey), cluster.CheckSecretRule(func(s *corev1.Secret) ([]cluster.ValidationError, error) {
125+
errors := make([]cluster.ValidationError, 0)
126+
127+
licensor := LicensorType(s.Data[licensorKey])
128+
if licensor != "" {
129+
// This field is optional, so blank is valid
130+
_, ok := LicensorTypeList[licensor]
131+
132+
if !ok {
133+
errors = append(errors, cluster.ValidationError{
134+
Message: fmt.Sprintf("Secret '%s' has invalid license type '%s'", secretName, licensor),
135+
Type: cluster.ValidationStatusError,
136+
})
137+
}
138+
}
139+
140+
return errors, nil
141+
})))
119142
}
120143

121144
if len(cfg.AuthProviders) > 0 {

0 commit comments

Comments
 (0)