-
Notifications
You must be signed in to change notification settings - Fork 0
/
license_check.go
40 lines (36 loc) · 1.26 KB
/
license_check.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Copyright 2017 The Cockroach Authors.
//
// Licensed as a CockroachDB Enterprise file under the Cockroach Community
// License (the "License"); you may not use this file except in compliance with
// the License. You may obtain a copy of the License at
//
// https://github.com/cockroachdb/cockroach/blob/master/LICENSE
package utilccl
import (
"github.com/cockroachdb/cockroach/pkg/settings"
"github.com/pkg/errors"
)
// EnterpriseEnabled is temporary, until #14114 is implemented.
var EnterpriseEnabled = func() *settings.BoolSetting {
name := "enterprise.enabled"
s := settings.RegisterBoolSetting(name, "set to true to enable Enterprise features", false)
settings.Hide(name)
return s
}()
// CheckEnterpriseEnabled returns a non-nil error if the requested enterprise
// feature is not enabled, including information or a link explaining how to
// enable it.
func CheckEnterpriseEnabled(feature string) error {
if EnterpriseEnabled.Get() {
return nil
}
// TODO(dt): link to some stable URL that then redirects to a helpful page
// that explains what to do here.
link := "https://cockroachlabs.com/pricing"
return errors.Errorf(
"use of %s requires an enterprise license. "+
"see %s for details on how to enable enterprise features",
feature,
link,
)
}