Files
coder/coderd/agentapi/servicebanner.go
Spike Curtis 207328ca50 feat: use appearance.Fetcher in agentapi (#11770)
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.
2024-01-29 21:22:50 +04:00

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
}