mirror of
https://github.com/coder/coder.git
synced 2025-07-08 11:39:50 +00:00
Move prebuilds code to enterprise top-level package, refactor into agpl pointers
Signed-off-by: Danny Kopping <danny@coder.com>
This commit is contained in:
@ -4,7 +4,6 @@ import (
|
||||
"context"
|
||||
"crypto/ed25519"
|
||||
"fmt"
|
||||
"github.com/coder/coder/v2/coderd/prebuilds"
|
||||
"math"
|
||||
"net/http"
|
||||
"net/url"
|
||||
@ -19,6 +18,7 @@ import (
|
||||
"github.com/coder/coder/v2/coderd/entitlements"
|
||||
"github.com/coder/coder/v2/coderd/idpsync"
|
||||
agplportsharing "github.com/coder/coder/v2/coderd/portsharing"
|
||||
agplprebuilds "github.com/coder/coder/v2/coderd/prebuilds"
|
||||
"github.com/coder/coder/v2/coderd/rbac/policy"
|
||||
"github.com/coder/coder/v2/enterprise/coderd/enidpsync"
|
||||
"github.com/coder/coder/v2/enterprise/coderd/portsharing"
|
||||
@ -44,6 +44,7 @@ import (
|
||||
"github.com/coder/coder/v2/codersdk"
|
||||
"github.com/coder/coder/v2/enterprise/coderd/dbauthz"
|
||||
"github.com/coder/coder/v2/enterprise/coderd/license"
|
||||
"github.com/coder/coder/v2/enterprise/coderd/prebuilds"
|
||||
"github.com/coder/coder/v2/enterprise/coderd/proxyhealth"
|
||||
"github.com/coder/coder/v2/enterprise/coderd/schedule"
|
||||
"github.com/coder/coder/v2/enterprise/dbcrypt"
|
||||
@ -583,6 +584,7 @@ func New(ctx context.Context, options *Options) (_ *API, err error) {
|
||||
go api.runEntitlementsLoop(ctx)
|
||||
|
||||
if api.AGPL.Experiments.Enabled(codersdk.ExperimentWorkspacePrebuilds) {
|
||||
// TODO: future enhancement, start this up without restarting coderd when entitlement is updated.
|
||||
if !api.Entitlements.Enabled(codersdk.FeatureWorkspacePrebuilds) {
|
||||
options.Logger.Warn(ctx, "prebuilds experiment enabled but not entitled to use")
|
||||
} else {
|
||||
@ -883,6 +885,14 @@ func (api *API) updateEntitlements(ctx context.Context) error {
|
||||
api.AGPL.PortSharer.Store(&ps)
|
||||
}
|
||||
|
||||
if initial, changed, enabled := featureChanged(codersdk.FeatureWorkspacePrebuilds); shouldUpdate(initial, changed, enabled) {
|
||||
c := agplprebuilds.DefaultClaimer
|
||||
if enabled {
|
||||
c = prebuilds.EnterpriseClaimer{}
|
||||
}
|
||||
api.AGPL.PrebuildsClaimer.Store(&c)
|
||||
}
|
||||
|
||||
// External token encryption is soft-enforced
|
||||
featureExternalTokenEncryption := reloadedEntitlements.Features[codersdk.FeatureExternalTokenEncryption]
|
||||
featureExternalTokenEncryption.Enabled = len(api.ExternalTokenEncryption) > 0
|
||||
|
Reference in New Issue
Block a user