Skip to content

[licensor] cleanup duplicate license types #9880

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions components/licensor/ee/pkg/licensor/gitpod.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func NewGitpodEvaluator(key []byte, domain string) (res *Evaluator) {
return &Evaluator{
lic: defaultLicense,
allowFallback: true,
plan: CommunityLicense,
plan: LicenseTypeCommunity,
}
}

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

return &Evaluator{
lic: lic.LicensePayload,
allowFallback: false, // Gitpod licenses cannot fallback - assume these are always paid-for
plan: ProfessionalLicense, // This essentially means "paid" license
allowFallback: false, // Gitpod licenses cannot fallback - assume these are always paid-for
plan: LicenseTypePaid, // This essentially means "paid" license
}
}
6 changes: 4 additions & 2 deletions components/licensor/ee/pkg/licensor/licensor.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ const (
type LicenseSubscriptionLevel string

const (
CommunityLicense LicenseSubscriptionLevel = "community"
ProfessionalLicense LicenseSubscriptionLevel = "prod"
LicenseTypeCommunity LicenseSubscriptionLevel = "community"
LicenseTypePaid LicenseSubscriptionLevel = "prod"
LicenseTypeTrial LicenseSubscriptionLevel = "trial"
LicenseTypeDevelopment LicenseSubscriptionLevel = "dev"
)

// LicenseData has type specific info about the license
Expand Down
6 changes: 3 additions & 3 deletions components/licensor/ee/pkg/licensor/licensor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func (test *licenseTest) Run(t *testing.T) {
payload, err := json.Marshal(replicatedLicensePayload{
LicenseType: func() LicenseSubscriptionLevel {
if test.ReplicatedLicenseType == nil {
return ReplicatedLicenseTypePaid
return LicenseTypePaid
}
return *test.ReplicatedLicenseType
}(),
Expand Down Expand Up @@ -210,8 +210,8 @@ func TestSeats(t *testing.T) {
}

func TestFeatures(t *testing.T) {
replicatedCommunity := ReplicatedLicenseTypeCommunity
replicatedPaid := ReplicatedLicenseTypePaid
replicatedCommunity := LicenseTypeCommunity
replicatedPaid := LicenseTypePaid

tests := []struct {
Name string
Expand Down
12 changes: 2 additions & 10 deletions components/licensor/ee/pkg/licensor/replicated.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,6 @@ type replicatedFields struct {
Value interface{} `json:"value"` // This is of type "fieldType"
}

// variable names are what Replicated calls them in the vendor portal
const (
ReplicatedLicenseTypeCommunity LicenseSubscriptionLevel = "community"
ReplicatedLicenseTypeDevelopment LicenseSubscriptionLevel = "dev"
ReplicatedLicenseTypePaid LicenseSubscriptionLevel = "prod"
ReplicatedLicenseTypeTrial LicenseSubscriptionLevel = "trial"
)

// replicatedLicensePayload exists to convert the JSON structure to a LicensePayload
type replicatedLicensePayload struct {
LicenseID string `json:"license_id"`
Expand Down Expand Up @@ -95,7 +87,7 @@ func defaultReplicatedLicense() *Evaluator {
return &Evaluator{
lic: defaultLicense,
allowFallback: true,
plan: ReplicatedLicenseTypeCommunity,
plan: LicenseTypeCommunity,
}
}

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

return &Evaluator{
lic: lic,
allowFallback: replicatedPayload.LicenseType == ReplicatedLicenseTypeCommunity, // Only community licenses are allowed to fallback
allowFallback: replicatedPayload.LicenseType == LicenseTypeCommunity, // Only community licenses are allowed to fallback
plan: replicatedPayload.LicenseType,
}
}
Expand Down
10 changes: 4 additions & 6 deletions components/licensor/typescript/ee/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,10 @@ export interface LicensePayload {
}

export enum LicenseSubscriptionLevel {
ReplicatedLicenseTypeCommunity = "community",
ReplicatedLicenseTypeDevelopment = "dev",
ReplicatedLicenseTypePaid = "prod",
ReplicatedLicenseTypeTrial = "trial",
CommunityLicense = "community",
ProfessionalLicense = "prod",
LicenseTypeCommunity = "community",
LicenseTypePaid = "prod",
LicenseTypeTrial = "trial",
LicenseTypeDevelopment = "dev",
}
export enum LicenseType {
LicenseTypeGitpod = "gitpod",
Expand Down