mirror of
https://github.com/coder/coder.git
synced 2025-07-06 15:41:45 +00:00
`agentsdk` depends on `agent/proto` because it needs to get the version to dial. Therefore, the conversion routines need to live in `agentsdk` so that we can convert to and from the Manifest. I briefly considered refactoring the agent to only reference `proto.Manifest`, but decided against it because we might have multiple protocol versions in the future, its useful to have a protocol-independent data structure.
25 lines
635 B
Go
25 lines
635 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"
|
|
"github.com/coder/coder/v2/codersdk/agentsdk"
|
|
)
|
|
|
|
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 agentsdk.ProtoFromServiceBanner(cfg.ServiceBanner), nil
|
|
}
|