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

Method ToProtoApp

agent/agentcontainers/subagent.go:67–127  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

65}
66
67func (app SubAgentApp) ToProtoApp() (*agentproto.CreateSubAgentRequest_App, error) {
68 proto := agentproto.CreateSubAgentRequest_App{
69 Slug: app.Slug,
70 External: &app.External,
71 Hidden: &app.Hidden,
72 Order: &app.Order,
73 Subdomain: &app.Subdomain,
74 }
75
76 if app.Command != "" {
77 proto.Command = &app.Command
78 }
79 if app.DisplayName != "" {
80 proto.DisplayName = &app.DisplayName
81 }
82 if app.Group != "" {
83 proto.Group = &app.Group
84 }
85 if app.Icon != "" {
86 proto.Icon = &app.Icon
87 }
88 if app.URL != "" {
89 proto.Url = &app.URL
90 }
91
92 if app.HealthCheck.URL != "" {
93 proto.Healthcheck = &agentproto.CreateSubAgentRequest_App_Healthcheck{
94 Interval: app.HealthCheck.Interval,
95 Threshold: app.HealthCheck.Threshold,
96 Url: app.HealthCheck.URL,
97 }
98 }
99
100 if app.OpenIn != "" {
101 switch app.OpenIn {
102 case codersdk.WorkspaceAppOpenInSlimWindow:
103 proto.OpenIn = agentproto.CreateSubAgentRequest_App_SLIM_WINDOW.Enum()
104 case codersdk.WorkspaceAppOpenInTab:
105 proto.OpenIn = agentproto.CreateSubAgentRequest_App_TAB.Enum()
106 default:
107 return nil, xerrors.Errorf("unexpected codersdk.WorkspaceAppOpenIn: %#v", app.OpenIn)
108 }
109 }
110
111 if app.Share != "" {
112 switch app.Share {
113 case codersdk.WorkspaceAppSharingLevelAuthenticated:
114 proto.Share = agentproto.CreateSubAgentRequest_App_AUTHENTICATED.Enum()
115 case codersdk.WorkspaceAppSharingLevelOwner:
116 proto.Share = agentproto.CreateSubAgentRequest_App_OWNER.Enum()
117 case codersdk.WorkspaceAppSharingLevelPublic:
118 proto.Share = agentproto.CreateSubAgentRequest_App_PUBLIC.Enum()
119 case codersdk.WorkspaceAppSharingLevelOrganization:
120 proto.Share = agentproto.CreateSubAgentRequest_App_ORGANIZATION.Enum()
121 default:
122 return nil, xerrors.Errorf("unexpected codersdk.WorkspaceAppSharingLevel: %#v", app.Share)
123 }
124 }

Callers 1

CreateMethod · 0.80

Calls 2

EnumMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected