mirror of
https://github.com/edgelesssys/constellation.git
synced 2024-10-01 01:36:09 -04: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
@ -10,6 +10,8 @@ package license
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"io/fs"
|
||||
|
||||
"github.com/edgelesssys/constellation/internal/cloud/cloudprovider"
|
||||
"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.
|
||||
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)
|
||||
if err != nil {
|
||||
if errors.Is(err, fs.ErrNotExist) {
|
||||
printer("Unable to find license file. Assuming community license.\n")
|
||||
licenseID = CommunityLicense
|
||||
} else if err != nil {
|
||||
printer("Error: %v\nContinuing with community license.\n", err)
|
||||
licenseID = CommunityLicense
|
||||
} else {
|
||||
printer("Constellation license found!\n")
|
||||
}
|
||||
@ -57,6 +62,9 @@ func (c *Checker) CheckLicense(ctx context.Context, provider cloudprovider.Provi
|
||||
if err != nil {
|
||||
printer("Unable to contact license server.\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 {
|
||||
printer("Please keep your vCPU quota (%d) in mind.\n", quotaResp.Quota)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user