MCPcopy Index your code
hub / github.com/coder/coder / ManifestFromProto

Function ManifestFromProto

codersdk/agentsdk/convert.go:22–71  ·  view source on GitHub ↗

ManifestFromProto converts the proto manifest to the SDK Manifest. Secrets are intentionally NOT included on the returned Manifest: keeping them off of the SDK type makes it impossible for any code path that only holds a *Manifest to leak secret values via logging, JSON encoding, fmt verbs, or debug

(manifest *proto.Manifest)

Source from the content-addressed store, hash-verified

20// path that only holds a *Manifest to leak secret values via
21// logging, JSON encoding, fmt verbs, or debug endpoints.
22func ManifestFromProto(manifest *proto.Manifest) (Manifest, error) {
23 parentID := uuid.Nil
24 if pid := manifest.GetParentId(); pid != nil {
25 var err error
26 parentID, err = uuid.FromBytes(pid)
27 if err != nil {
28 return Manifest{}, xerrors.Errorf("error converting workspace agent parent ID: %w", err)
29 }
30 }
31 apps, err := AppsFromProto(manifest.Apps)
32 if err != nil {
33 return Manifest{}, xerrors.Errorf("error converting workspace agent apps: %w", err)
34 }
35 scripts, err := AgentScriptsFromProto(manifest.Scripts)
36 if err != nil {
37 return Manifest{}, xerrors.Errorf("error converting workspace agent scripts: %w", err)
38 }
39 agentID, err := uuid.FromBytes(manifest.AgentId)
40 if err != nil {
41 return Manifest{}, xerrors.Errorf("error converting workspace agent ID: %w", err)
42 }
43 workspaceID, err := uuid.FromBytes(manifest.WorkspaceId)
44 if err != nil {
45 return Manifest{}, xerrors.Errorf("error converting workspace ID: %w", err)
46 }
47 devcontainers, err := DevcontainersFromProto(manifest.Devcontainers)
48 if err != nil {
49 return Manifest{}, xerrors.Errorf("error converting workspace agent devcontainers: %w", err)
50 }
51 return Manifest{
52 ParentID: parentID,
53 AgentID: agentID,
54 AgentName: manifest.AgentName,
55 OwnerName: manifest.OwnerUsername,
56 WorkspaceID: workspaceID,
57 WorkspaceName: manifest.WorkspaceName,
58 Apps: apps,
59 Scripts: scripts,
60 DERPMap: tailnet.DERPMapFromProto(manifest.DerpMap),
61 DERPForceWebSockets: manifest.DerpForceWebsockets,
62 GitAuthConfigs: int(manifest.GitAuthConfigs),
63 EnvironmentVariables: manifest.EnvironmentVariables,
64 Directory: manifest.Directory,
65 VSCodePortProxyURI: manifest.VsCodePortProxyUri,
66 MOTDFile: manifest.MotdPath,
67 DisableDirectConnections: manifest.DisableDirectConnections,
68 Metadata: MetadataDescriptionsFromProto(manifest.Metadata),
69 Devcontainers: devcontainers,
70 }, nil
71}
72
73// ProtoFromManifest converts the SDK Manifest to the proto manifest.
74// It does not populate the proto's Secrets field because the SDK

Callers 3

requireGetManifestFunction · 0.92
TestManifestFunction · 0.92
handleManifestMethod · 0.92

Calls 7

DERPMapFromProtoFunction · 0.92
AppsFromProtoFunction · 0.85
AgentScriptsFromProtoFunction · 0.85
DevcontainersFromProtoFunction · 0.85
GetParentIdMethod · 0.80
ErrorfMethod · 0.45

Tested by 2

requireGetManifestFunction · 0.74
TestManifestFunction · 0.74