mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-11-20 03:52:24 -05:00
license messages (#118)
* license: tell the user whether file couldn't be found or there was another error * license: print correct info for community license
This commit is contained in:
parent
0952435e25
commit
c41018ed32
1 changed files with 9 additions and 1 deletions
|
|
@ -10,6 +10,8 @@ package license
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
|
"io/fs"
|
||||||
|
|
||||||
"github.com/edgelesssys/constellation/internal/cloud/cloudprovider"
|
"github.com/edgelesssys/constellation/internal/cloud/cloudprovider"
|
||||||
"github.com/edgelesssys/constellation/internal/config"
|
"github.com/edgelesssys/constellation/internal/config"
|
||||||
|
|
@ -34,9 +36,12 @@ func NewChecker(quotaChecker QuotaChecker, fileHandler file.Handler) *Checker {
|
||||||
// If no license file is found, community license is assumed.
|
// If no license file is found, community license is assumed.
|
||||||
func (c *Checker) CheckLicense(ctx context.Context, provider cloudprovider.Provider, providerCfg config.ProviderConfig, printer func(string, ...any)) error {
|
func (c *Checker) CheckLicense(ctx context.Context, provider cloudprovider.Provider, providerCfg config.ProviderConfig, printer func(string, ...any)) error {
|
||||||
licenseID, err := FromFile(c.fileHandler, constants.LicenseFilename)
|
licenseID, err := FromFile(c.fileHandler, constants.LicenseFilename)
|
||||||
if err != nil {
|
if errors.Is(err, fs.ErrNotExist) {
|
||||||
printer("Unable to find license file. Assuming community license.\n")
|
printer("Unable to find license file. Assuming community license.\n")
|
||||||
licenseID = CommunityLicense
|
licenseID = CommunityLicense
|
||||||
|
} else if err != nil {
|
||||||
|
printer("Error: %v\nContinuing with community license.\n", err)
|
||||||
|
licenseID = CommunityLicense
|
||||||
} else {
|
} else {
|
||||||
printer("Constellation license found!\n")
|
printer("Constellation license found!\n")
|
||||||
}
|
}
|
||||||
|
|
@ -57,6 +62,9 @@ func (c *Checker) CheckLicense(ctx context.Context, provider cloudprovider.Provi
|
||||||
if err != nil {
|
if err != nil {
|
||||||
printer("Unable to contact license server.\n")
|
printer("Unable to contact license server.\n")
|
||||||
printer("Please keep your vCPU quota in mind.\n")
|
printer("Please keep your vCPU quota in mind.\n")
|
||||||
|
} else if licenseID == CommunityLicense {
|
||||||
|
printer("You can use Constellation to create services for internal consumption.\n")
|
||||||
|
printer("For details, see https://docs.edgeless.systems/constellation/overview/license\n")
|
||||||
} else {
|
} else {
|
||||||
printer("Please keep your vCPU quota (%d) in mind.\n", quotaResp.Quota)
|
printer("Please keep your vCPU quota (%d) in mind.\n", quotaResp.Quota)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue