mirror of
https://github.com/coder/coder.git
synced 2025-07-03 16:13:58 +00:00
This PR updates the Agent API to use the appearance.Fetcher, which is set by entitlement code in Enterprise coderd. This brings the agentapi into compliance with the Enterprise feature.
24 lines
583 B
Go
24 lines
583 B
Go
package agentapi
|
|
|
|
import (
|
|
"context"
|
|
"sync/atomic"
|
|
|
|
"golang.org/x/xerrors"
|
|
|
|
"github.com/coder/coder/v2/agent/proto"
|
|
"github.com/coder/coder/v2/coderd/appearance"
|
|
)
|
|
|
|
type ServiceBannerAPI struct {
|
|
appearanceFetcher *atomic.Pointer[appearance.Fetcher]
|
|
}
|
|
|
|
func (a *ServiceBannerAPI) GetServiceBanner(ctx context.Context, _ *proto.GetServiceBannerRequest) (*proto.ServiceBanner, error) {
|
|
cfg, err := (*a.appearanceFetcher.Load()).Fetch(ctx)
|
|
if err != nil {
|
|
return nil, xerrors.Errorf("fetch appearance: %w", err)
|
|
}
|
|
return proto.ServiceBannerFromSDK(cfg.ServiceBanner), nil
|
|
}
|