2022-08-25 08:06:29 -04:00
|
|
|
//go:build enterprise
|
|
|
|
|
2022-09-05 03:06:08 -04:00
|
|
|
/*
|
|
|
|
Copyright (c) Edgeless Systems GmbH
|
|
|
|
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
*/
|
|
|
|
|
2022-08-25 08:06:29 -04:00
|
|
|
package license
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
2022-09-21 07:47:57 -04:00
|
|
|
"github.com/edgelesssys/constellation/v2/internal/cloud/cloudprovider"
|
2022-08-25 08:06:29 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
type Checker struct {
|
|
|
|
quotaChecker QuotaChecker
|
|
|
|
}
|
|
|
|
|
2023-12-01 02:37:52 -05:00
|
|
|
func NewChecker(quotaChecker QuotaChecker) *Checker {
|
2022-08-25 08:06:29 -04:00
|
|
|
return &Checker{
|
|
|
|
quotaChecker: quotaChecker,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-12-01 02:37:52 -05:00
|
|
|
// CheckLicense contacts the license server to fetch quota information for the given license.
|
|
|
|
func (c *Checker) CheckLicense(ctx context.Context, provider cloudprovider.Provider, licenseID string) (QuotaCheckResponse, error) {
|
|
|
|
return c.quotaChecker.QuotaCheck(ctx, QuotaCheckRequest{
|
2022-09-08 05:02:04 -04:00
|
|
|
License: licenseID,
|
|
|
|
Action: Init,
|
2023-04-03 13:19:54 -04:00
|
|
|
Provider: provider.String(),
|
2022-08-25 08:06:29 -04:00
|
|
|
})
|
|
|
|
}
|