-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
115 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Implementation of the license manager for unlocking enterprise features | ||
package licensemanager | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/go-logr/logr" | ||
"github.com/l7mp/stunner-gateway-operator/internal/event" | ||
licensecfg "github.com/l7mp/stunner/pkg/config/license" | ||
) | ||
|
||
var licenseManagerConstructor = NewStubManager | ||
|
||
// Manager is a global license manager that encapsulates the license management logics | ||
type Manager interface { | ||
// Start runs the license manager. | ||
Start(context.Context) error | ||
// Validate checks whether a client is entitled to use a feature. | ||
Validate(feature licensecfg.Feature) bool | ||
// SubscriptionType returns the current subscription type (e.g., free, member, enterprise). | ||
SubscriptionType() string | ||
// SetOperatorChannel sets up the operator channel where the manager can send rendering | ||
SetOperatorChannel(c chan event.Event) | ||
// LastError returns the last license manager error. | ||
LastError() error | ||
} | ||
|
||
type Config struct { | ||
CustomerKey string | ||
LicenseManagerClient any | ||
Logger logr.Logger | ||
} | ||
|
||
func NewManager(config Config) Manager { | ||
return licenseManagerConstructor(config) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package licensemanager | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/l7mp/stunner-gateway-operator/internal/event" | ||
licensecfg "github.com/l7mp/stunner/pkg/config/license" | ||
) | ||
|
||
// license manager stub | ||
type stubMgr struct{} | ||
|
||
func NewStubManager(_ Config) Manager { return &stubMgr{} } | ||
|
||
func (_ *stubMgr) Start(_ context.Context) error { return nil } | ||
func (_ *stubMgr) Validate(_ licensecfg.Feature) bool { return true } | ||
func (_ *stubMgr) SubscriptionType() string { return "free" } | ||
func (_ *stubMgr) LastError() error { return nil } | ||
func (_ *stubMgr) SetOperatorChannel(_ chan event.Event) {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters