Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd5955e3

Browse files
committed
chore: move proto to sdk conversion to agentsdk
1 parent6fcd156 commitd5955e3

File tree

8 files changed

+423
-174
lines changed

8 files changed

+423
-174
lines changed

‎agent/agent.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -677,7 +677,7 @@ func (a *agent) fetchServiceBannerLoop(ctx context.Context, aAPI proto.DRPCAgent
677677
a.logger.Error(ctx,"failed to update service banner",slog.Error(err))
678678
returnerr
679679
}
680-
serviceBanner:=proto.SDKServiceBannerFromProto(sbp)
680+
serviceBanner:=agentsdk.ServiceBannerFromProto(sbp)
681681
a.serviceBanner.Store(&serviceBanner)
682682
}
683683
}
@@ -710,7 +710,7 @@ func (a *agent) run(ctx context.Context) error {
710710
iferr!=nil {
711711
returnxerrors.Errorf("fetch service banner: %w",err)
712712
}
713-
serviceBanner:=proto.SDKServiceBannerFromProto(sbp)
713+
serviceBanner:=agentsdk.ServiceBannerFromProto(sbp)
714714
a.serviceBanner.Store(&serviceBanner)
715715

716716
manifest,err:=a.client.Manifest(ctx)

‎agent/agenttest/client.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ func (f *FakeAgentAPI) GetServiceBanner(context.Context, *agentproto.GetServiceB
277277
iferr!=nil {
278278
returnnil,err
279279
}
280-
returnagentproto.ServiceBannerFromSDK(sb),nil
280+
returnagentsdk.ProtoFromServiceBanner(sb),nil
281281
}
282282

283283
func (*FakeAgentAPI)UpdateStats(context.Context,*agentproto.UpdateStatsRequest) (*agentproto.UpdateStatsResponse,error) {

‎agent/proto/convert.go‎

Lines changed: 0 additions & 122 deletions
This file was deleted.

‎coderd/agentapi/servicebanner.go‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88

99
"github.com/coder/coder/v2/agent/proto"
1010
"github.com/coder/coder/v2/coderd/appearance"
11+
"github.com/coder/coder/v2/codersdk/agentsdk"
1112
)
1213

1314
typeServiceBannerAPIstruct {
@@ -19,5 +20,5 @@ func (a *ServiceBannerAPI) GetServiceBanner(ctx context.Context, _ *proto.GetSer
1920
iferr!=nil {
2021
returnnil,xerrors.Errorf("fetch appearance: %w",err)
2122
}
22-
returnproto.ServiceBannerFromSDK(cfg.ServiceBanner),nil
23+
returnagentsdk.ProtoFromServiceBanner(cfg.ServiceBanner),nil
2324
}

‎coderd/workspaceagents.go‎

Lines changed: 3 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -179,60 +179,16 @@ func (api *API) workspaceAgentManifest(rw http.ResponseWriter, r *http.Request)
179179
})
180180
return
181181
}
182-
183-
apps,err:=agentproto.SDKAppsFromProto(manifest.Apps)
184-
iferr!=nil {
185-
httpapi.Write(ctx,rw,http.StatusInternalServerError, codersdk.Response{
186-
Message:"Internal error converting workspace agent apps.",
187-
Detail:err.Error(),
188-
})
189-
return
190-
}
191-
192-
scripts,err:=agentproto.SDKAgentScriptsFromProto(manifest.Scripts)
193-
iferr!=nil {
194-
httpapi.Write(ctx,rw,http.StatusInternalServerError, codersdk.Response{
195-
Message:"Internal error converting workspace agent scripts.",
196-
Detail:err.Error(),
197-
})
198-
return
199-
}
200-
201-
agentID,err:=uuid.FromBytes(manifest.AgentId)
182+
sdkManifest,err:=agentsdk.ManifestFromProto(manifest)
202183
iferr!=nil {
203184
httpapi.Write(ctx,rw,http.StatusInternalServerError, codersdk.Response{
204-
Message:"Internal error converting workspace agent ID.",
205-
Detail:err.Error(),
206-
})
207-
return
208-
}
209-
workspaceID,err:=uuid.FromBytes(manifest.WorkspaceId)
210-
iferr!=nil {
211-
httpapi.Write(ctx,rw,http.StatusInternalServerError, codersdk.Response{
212-
Message:"Internal error converting workspace ID.",
185+
Message:"Internal error converting manifest.",
213186
Detail:err.Error(),
214187
})
215188
return
216189
}
217190

218-
httpapi.Write(ctx,rw,http.StatusOK, agentsdk.Manifest{
219-
AgentID:agentID,
220-
AgentName:manifest.AgentName,
221-
OwnerName:manifest.OwnerUsername,
222-
WorkspaceID:workspaceID,
223-
WorkspaceName:manifest.WorkspaceName,
224-
Apps:apps,
225-
Scripts:scripts,
226-
DERPMap:tailnet.DERPMapFromProto(manifest.DerpMap),
227-
DERPForceWebSockets:manifest.DerpForceWebsockets,
228-
GitAuthConfigs:int(manifest.GitAuthConfigs),
229-
EnvironmentVariables:manifest.EnvironmentVariables,
230-
Directory:manifest.Directory,
231-
VSCodePortProxyURI:manifest.VsCodePortProxyUri,
232-
MOTDFile:manifest.MotdPath,
233-
DisableDirectConnections:manifest.DisableDirectConnections,
234-
Metadata:agentproto.SDKAgentMetadataDescriptionsFromProto(manifest.Metadata),
235-
})
191+
httpapi.Write(ctx,rw,http.StatusOK,sdkManifest)
236192
}
237193

238194
constAgentAPIVersionREST="1.0"

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp