Skip to content

Commit 0ab2a8d

Browse files
nandajavarmaroboquat
authored andcommitted
[licensor] cleanup duplicate license types
1 parent b02e548 commit 0ab2a8d

File tree

5 files changed

+16
-24
lines changed

5 files changed

+16
-24
lines changed

components/licensor/ee/pkg/licensor/gitpod.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ func NewGitpodEvaluator(key []byte, domain string) (res *Evaluator) {
2121
return &Evaluator{
2222
lic: defaultLicense,
2323
allowFallback: true,
24-
plan: CommunityLicense,
24+
plan: LicenseTypeCommunity,
2525
}
2626
}
2727

@@ -64,7 +64,7 @@ func NewGitpodEvaluator(key []byte, domain string) (res *Evaluator) {
6464

6565
return &Evaluator{
6666
lic: lic.LicensePayload,
67-
allowFallback: false, // Gitpod licenses cannot fallback - assume these are always paid-for
68-
plan: ProfessionalLicense, // This essentially means "paid" license
67+
allowFallback: false, // Gitpod licenses cannot fallback - assume these are always paid-for
68+
plan: LicenseTypePaid, // This essentially means "paid" license
6969
}
7070
}

components/licensor/ee/pkg/licensor/licensor.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,10 @@ const (
2929
type LicenseSubscriptionLevel string
3030

3131
const (
32-
CommunityLicense LicenseSubscriptionLevel = "community"
33-
ProfessionalLicense LicenseSubscriptionLevel = "prod"
32+
LicenseTypeCommunity LicenseSubscriptionLevel = "community"
33+
LicenseTypePaid LicenseSubscriptionLevel = "prod"
34+
LicenseTypeTrial LicenseSubscriptionLevel = "trial"
35+
LicenseTypeDevelopment LicenseSubscriptionLevel = "dev"
3436
)
3537

3638
// LicenseData has type specific info about the license

components/licensor/ee/pkg/licensor/licensor_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ func (test *licenseTest) Run(t *testing.T) {
7979
payload, err := json.Marshal(replicatedLicensePayload{
8080
LicenseType: func() LicenseSubscriptionLevel {
8181
if test.ReplicatedLicenseType == nil {
82-
return ReplicatedLicenseTypePaid
82+
return LicenseTypePaid
8383
}
8484
return *test.ReplicatedLicenseType
8585
}(),
@@ -210,8 +210,8 @@ func TestSeats(t *testing.T) {
210210
}
211211

212212
func TestFeatures(t *testing.T) {
213-
replicatedCommunity := ReplicatedLicenseTypeCommunity
214-
replicatedPaid := ReplicatedLicenseTypePaid
213+
replicatedCommunity := LicenseTypeCommunity
214+
replicatedPaid := LicenseTypePaid
215215

216216
tests := []struct {
217217
Name string

components/licensor/ee/pkg/licensor/replicated.go

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,6 @@ type replicatedFields struct {
2323
Value interface{} `json:"value"` // This is of type "fieldType"
2424
}
2525

26-
// variable names are what Replicated calls them in the vendor portal
27-
const (
28-
ReplicatedLicenseTypeCommunity LicenseSubscriptionLevel = "community"
29-
ReplicatedLicenseTypeDevelopment LicenseSubscriptionLevel = "dev"
30-
ReplicatedLicenseTypePaid LicenseSubscriptionLevel = "prod"
31-
ReplicatedLicenseTypeTrial LicenseSubscriptionLevel = "trial"
32-
)
33-
3426
// replicatedLicensePayload exists to convert the JSON structure to a LicensePayload
3527
type replicatedLicensePayload struct {
3628
LicenseID string `json:"license_id"`
@@ -95,7 +87,7 @@ func defaultReplicatedLicense() *Evaluator {
9587
return &Evaluator{
9688
lic: defaultLicense,
9789
allowFallback: true,
98-
plan: ReplicatedLicenseTypeCommunity,
90+
plan: LicenseTypeCommunity,
9991
}
10092
}
10193

@@ -143,7 +135,7 @@ func newReplicatedEvaluator(client *http.Client, domain string) (res *Evaluator)
143135

144136
return &Evaluator{
145137
lic: lic,
146-
allowFallback: replicatedPayload.LicenseType == ReplicatedLicenseTypeCommunity, // Only community licenses are allowed to fallback
138+
allowFallback: replicatedPayload.LicenseType == LicenseTypeCommunity, // Only community licenses are allowed to fallback
147139
plan: replicatedPayload.LicenseType,
148140
}
149141
}

components/licensor/typescript/ee/src/api.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,10 @@ export interface LicensePayload {
3232
}
3333

3434
export enum LicenseSubscriptionLevel {
35-
ReplicatedLicenseTypeCommunity = "community",
36-
ReplicatedLicenseTypeDevelopment = "dev",
37-
ReplicatedLicenseTypePaid = "prod",
38-
ReplicatedLicenseTypeTrial = "trial",
39-
CommunityLicense = "community",
40-
ProfessionalLicense = "prod",
35+
LicenseTypeCommunity = "community",
36+
LicenseTypePaid = "prod",
37+
LicenseTypeTrial = "trial",
38+
LicenseTypeDevelopment = "dev",
4139
}
4240
export enum LicenseType {
4341
LicenseTypeGitpod = "gitpod",

0 commit comments

Comments
 (0)