Skip to content

Commit 080e478

Browse files
craig[bot]spilchen
andcommitted
Merge #130161
130161: licenseccl: rename usage to environment r=spilchen a=spilchen This renames the usage field in the license protobuf to environment and deprecates the NonCommercial type. Epic: CRDB-39988 Informs: CRDB-40069 Release note: none Co-authored-by: Matt Spilchen <[email protected]>
2 parents 83dd266 + fcdc4ea commit 080e478

File tree

4 files changed

+20
-20
lines changed

4 files changed

+20
-20
lines changed

pkg/ccl/utilccl/license_check.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -237,15 +237,15 @@ func GetLicenseType(st *cluster.Settings) (string, error) {
237237
return license.Type.String(), nil
238238
}
239239

240-
// GetLicenseUsage returns the license usage.
241-
func GetLicenseUsage(st *cluster.Settings) (string, error) {
240+
// GetLicenseEnvironment returns the license environment.
241+
func GetLicenseEnvironment(st *cluster.Settings) (string, error) {
242242
license, err := getLicense(st)
243243
if err != nil {
244244
return "", err
245245
} else if license == nil {
246246
return "", nil
247247
}
248-
return license.Usage.String(), nil
248+
return license.Environment.String(), nil
249249
}
250250

251251
// decode attempts to read a base64 encoded License.

pkg/ccl/utilccl/license_check_test.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,10 @@ func TestGetLicenseTypePresent(t *testing.T) {
7474

7575
ctx := context.Background()
7676
for _, tc := range []struct {
77-
typ licenseccl.License_Type
78-
expectedType string
79-
usage licenseccl.License_Usage
80-
expectedUsage string
77+
typ licenseccl.License_Type
78+
expectedType string
79+
environment licenseccl.License_Environment
80+
expectedEnvironment string
8181
}{
8282
{licenseccl.License_NonCommercial, "NonCommercial", licenseccl.PreProduction, "pre-production"},
8383
{licenseccl.License_Enterprise, "Enterprise", licenseccl.Production, "production"},
@@ -91,7 +91,7 @@ func TestGetLicenseTypePresent(t *testing.T) {
9191
lic, _ := (&licenseccl.License{
9292
Type: tc.typ,
9393
ValidUntilUnixSec: 0,
94-
Usage: tc.usage,
94+
Environment: tc.environment,
9595
}).Encode()
9696
if err := setLicense(ctx, updater, lic); err != nil {
9797
t.Fatal(err)
@@ -103,21 +103,21 @@ func TestGetLicenseTypePresent(t *testing.T) {
103103
if actualType != tc.expectedType {
104104
t.Fatalf("expected license type %s, got %s", tc.expectedType, actualType)
105105
}
106-
actualUsage, err := GetLicenseUsage(st)
106+
actualEnvironment, err := GetLicenseEnvironment(st)
107107
if err != nil {
108108
t.Fatal(err)
109109
}
110-
if actualUsage != tc.expectedUsage {
111-
t.Fatalf("expected license usage %s, got %s", tc.expectedUsage, actualUsage)
110+
if actualEnvironment != tc.expectedEnvironment {
111+
t.Fatalf("expected license environment %s, got %s", tc.expectedEnvironment, actualEnvironment)
112112
}
113113
}
114114
}
115115

116-
func TestUnknownUsageEnum(t *testing.T) {
116+
func TestUnknownEnvironmentEnum(t *testing.T) {
117117
defer leaktest.AfterTest(t)()
118118

119-
// This literal was generated with an enum value of 100 for usage, to show
120-
// what happens if we add more usages later and then try to apply one to an
119+
// This literal was generated with an enum value of 100 for environment, to show
120+
// what happens if we add more environments later and then try to apply one to an
121121
// older node which does not include it.
122122
l, err := decode(`crl-0-GAIoZA`)
123123
if err != nil {
@@ -126,8 +126,8 @@ func TestUnknownUsageEnum(t *testing.T) {
126126
if expected, got := "Evaluation", l.Type.String(); got != expected {
127127
t.Fatalf("expected license type %s, got %s", expected, got)
128128
}
129-
if expected, got := "other", l.Usage.String(); got != expected {
130-
t.Fatalf("expected license usage %q, got %q", expected, got)
129+
if expected, got := "other", l.Environment.String(); got != expected {
130+
t.Fatalf("expected license environment %q, got %q", expected, got)
131131
}
132132
}
133133

pkg/ccl/utilccl/licenseccl/license.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func Decode(s string) (*License, error) {
4848
return &lic, nil
4949
}
5050

51-
func (u License_Usage) String() string {
51+
func (u License_Environment) String() string {
5252
switch u {
5353
case Unspecified:
5454
return ""

pkg/ccl/utilccl/licenseccl/license.proto

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ message License {
1717
int64 valid_until_unix_sec = 2;
1818

1919
enum Type {
20-
NonCommercial = 0;
20+
NonCommercial = 0 [deprecated = true];
2121
Enterprise = 1;
2222
Evaluation = 2;
2323
Free = 3;
@@ -28,7 +28,7 @@ message License {
2828

2929
string organization_name = 4;
3030

31-
enum Usage {
31+
enum Environment {
3232
option (gogoproto.goproto_enum_prefix) = false;
3333
option (gogoproto.goproto_enum_stringer) = false;
3434

@@ -38,7 +38,7 @@ message License {
3838
Development = 3;
3939
}
4040

41-
Usage usage = 5;
41+
Environment environment = 5;
4242

4343
// Two UUIDs uniquely identify this license and the associated organization.
4444
// They are stored as bytes to align with the server's typical usage. We

0 commit comments

Comments
 (0)