From 5d843fa62819ee336ef5ca3cf6e6b0081d458132 Mon Sep 17 00:00:00 2001 From: Simon Emms Date: Thu, 5 Jan 2023 15:25:09 +0000 Subject: [PATCH] [licensor]: deprecate the licensor This makes all licences unlimited users. This component will be removed in future. --- .../licensor/ee/pkg/licensor/licensor.go | 7 ++-- .../licensor/ee/pkg/licensor/licensor_test.go | 32 +++++++++++++++---- components/licensor/main.go | 2 ++ 3 files changed, 30 insertions(+), 11 deletions(-) diff --git a/components/licensor/ee/pkg/licensor/licensor.go b/components/licensor/ee/pkg/licensor/licensor.go index 8df72f447d864e..ed2bcb8e7ae5dd 100644 --- a/components/licensor/ee/pkg/licensor/licensor.go +++ b/components/licensor/ee/pkg/licensor/licensor.go @@ -67,8 +67,7 @@ type licensePayload struct { type LicenseLevel int const ( - // LevelTeam is the default license level, - // which is the free tier + // This exists for historical reasons - it is now the same as LevelEnterprise LevelTeam LicenseLevel = 0 // LevelEnterprise enables enterprise features, @@ -140,7 +139,7 @@ func (lvl LicenseLevel) allowance() allowance { // Fallback license is used when the instance exceeds the number of licenses - it allows limited access var fallbackLicense = LicensePayload{ ID: "fallback-license", - Level: LevelTeam, + Level: LevelEnterprise, Seats: 0, // Domain, ValidUntil are free for all } @@ -149,7 +148,7 @@ var fallbackLicense = LicensePayload{ var defaultLicense = LicensePayload{ ID: "default-license", Level: LevelEnterprise, - Seats: 10, + Seats: 0, // Domain, ValidUntil are free for all } diff --git a/components/licensor/ee/pkg/licensor/licensor_test.go b/components/licensor/ee/pkg/licensor/licensor_test.go index ca17a65fb26dd6..c1a6e47e32f4f7 100644 --- a/components/licensor/ee/pkg/licensor/licensor_test.go +++ b/components/licensor/ee/pkg/licensor/licensor_test.go @@ -157,7 +157,7 @@ func TestSeats(t *testing.T) { {"Gitpod: invalid license", 50, 50, false, false, true, LicenseTypeGitpod, false}, {"Gitpod: within default license seats", 0, 7, true, true, false, LicenseTypeGitpod, false}, {"Gitpod: within default license seats (edge)", 0, 10, true, true, false, LicenseTypeGitpod, false}, - {"Gitpod: beyond default license seats", 0, 11, false, true, false, LicenseTypeGitpod, false}, + {"Gitpod: beyond default license seats", 0, 11, true, true, false, LicenseTypeGitpod, false}, // correctly missing the default license tests as Replicated always has a license {"Replicated: unlimited seats", 0, 1000, true, false, false, LicenseTypeReplicated, false}, @@ -165,15 +165,15 @@ func TestSeats(t *testing.T) { {"Replicated: within limited seats (edge)", 50, 50, true, false, false, LicenseTypeReplicated, false}, {"Replicated: beyond limited seats", 50, 150, false, false, false, LicenseTypeReplicated, false}, {"Replicated: beyond limited seats (edge)", 50, 51, false, false, false, LicenseTypeReplicated, false}, - {"Replicated: invalid license", 50, 50, false, false, true, LicenseTypeReplicated, false}, - {"Replicated: beyond default license seats", 0, 11, false, true, false, LicenseTypeReplicated, false}, + {"Replicated: invalid license", 50, 50, true, false, true, LicenseTypeReplicated, false}, + {"Replicated: beyond default license seats", 0, 11, true, true, false, LicenseTypeReplicated, false}, {"Replicated: unlimited seats", 0, 1000, true, false, false, LicenseTypeReplicated, true}, {"Replicated: within limited seats", 50, 40, true, false, false, LicenseTypeReplicated, true}, {"Replicated: within limited seats (edge)", 50, 50, true, false, false, LicenseTypeReplicated, true}, {"Replicated: beyond limited seats", 50, 150, false, false, false, LicenseTypeReplicated, true}, {"Replicated: beyond limited seats (edge)", 50, 51, false, false, false, LicenseTypeReplicated, true}, - {"Replicated: invalid license", 50, 50, false, false, true, LicenseTypeReplicated, true}, + {"Replicated: invalid license", 50, 50, true, false, true, LicenseTypeReplicated, true}, {"Replicated: beyond default license seats", 0, 11, false, true, false, LicenseTypeReplicated, true}, {"Replicated: invalid license within default seats", 50, 5, true, false, true, LicenseTypeReplicated, false}, } @@ -238,7 +238,13 @@ func TestFeatures(t *testing.T) { FeaturePrebuild, }, LicenseTypeGitpod, seats, nil}, - {"Gitpod (over seats): no license", true, LicenseLevel(0), []Feature{FeatureAdminDashboard}, LicenseTypeGitpod, 11, nil}, + {"Gitpod (over seats): no license", true, LicenseLevel(0), []Feature{ + FeatureAdminDashboard, + FeatureSetTimeout, + FeatureWorkspaceSharing, + FeatureSnapshot, + FeaturePrebuild, + }, LicenseTypeGitpod, 11, nil}, {"Gitpod (over seats): invalid license level", false, LicenseLevel(666), []Feature{}, LicenseTypeGitpod, seats + 1, nil}, {"Gitpod (over seats): enterprise license", false, LevelEnterprise, []Feature{}, LicenseTypeGitpod, seats + 1, nil}, @@ -272,8 +278,20 @@ func TestFeatures(t *testing.T) { FeaturePrebuild, }, LicenseTypeReplicated, seats + 1, &replicatedPaid}, - {"Replicated (over seats - fallback): invalid license level", false, LicenseLevel(666), []Feature{FeatureAdminDashboard}, LicenseTypeReplicated, seats + 1, &replicatedCommunity}, - {"Replicated (over seats - fallback): enterprise license", false, LevelEnterprise, []Feature{FeatureAdminDashboard}, LicenseTypeReplicated, seats + 1, &replicatedCommunity}, + {"Replicated (over seats - fallback): invalid license level", false, LicenseLevel(666), []Feature{ + FeatureAdminDashboard, + FeatureSetTimeout, + FeatureWorkspaceSharing, + FeatureSnapshot, + FeaturePrebuild, + }, LicenseTypeReplicated, seats + 1, &replicatedCommunity}, + {"Replicated (over seats - fallback): enterprise license", false, LevelEnterprise, []Feature{ + FeatureAdminDashboard, + FeatureSetTimeout, + FeatureWorkspaceSharing, + FeatureSnapshot, + FeaturePrebuild, + }, LicenseTypeReplicated, seats + 1, &replicatedCommunity}, } for _, test := range tests { diff --git a/components/licensor/main.go b/components/licensor/main.go index 3de2e09479f39d..3cdf5b32f8f556 100644 --- a/components/licensor/main.go +++ b/components/licensor/main.go @@ -2,6 +2,8 @@ // Licensed under the GNU Affero General Public License (AGPL). // See License.AGPL.txt in the project root for license information. +// @deprecated + package main import "github.com/gitpod-io/gitpod/licensor/ee/cmd"