(dbApp database.WorkspaceApp, agent database.WorkspaceAgent, ownerName string, workspace database.Workspace, appHostname string)
| 219 | } |
| 220 | |
| 221 | func dbAppToProto(dbApp database.WorkspaceApp, agent database.WorkspaceAgent, ownerName string, workspace database.Workspace, appHostname string) (*agentproto.WorkspaceApp, error) { |
| 222 | sharingLevelRaw, ok := agentproto.WorkspaceApp_SharingLevel_value[strings.ToUpper(string(dbApp.SharingLevel))] |
| 223 | if !ok { |
| 224 | return nil, xerrors.Errorf("unknown app sharing level: %q", dbApp.SharingLevel) |
| 225 | } |
| 226 | |
| 227 | healthRaw, ok := agentproto.WorkspaceApp_Health_value[strings.ToUpper(string(dbApp.Health))] |
| 228 | if !ok { |
| 229 | return nil, xerrors.Errorf("unknown app health: %q", dbApp.SharingLevel) |
| 230 | } |
| 231 | |
| 232 | // SubdomainName should be empty if AppHostname is not configured |
| 233 | subdomainName := "" |
| 234 | if appHostname != "" { |
| 235 | subdomainName = db2sdk.AppSubdomain(dbApp, agent.Name, workspace.Name, ownerName) |
| 236 | } |
| 237 | |
| 238 | return &agentproto.WorkspaceApp{ |
| 239 | Id: dbApp.ID[:], |
| 240 | Url: dbApp.Url.String, |
| 241 | External: dbApp.External, |
| 242 | Slug: dbApp.Slug, |
| 243 | DisplayName: dbApp.DisplayName, |
| 244 | Command: dbApp.Command.String, |
| 245 | Icon: dbApp.Icon, |
| 246 | Subdomain: dbApp.Subdomain, |
| 247 | SubdomainName: subdomainName, |
| 248 | SharingLevel: agentproto.WorkspaceApp_SharingLevel(sharingLevelRaw), |
| 249 | Healthcheck: &agentproto.WorkspaceApp_Healthcheck{ |
| 250 | Url: dbApp.HealthcheckUrl, |
| 251 | Interval: durationpb.New(time.Duration(dbApp.HealthcheckInterval) * time.Second), |
| 252 | Threshold: dbApp.HealthcheckThreshold, |
| 253 | }, |
| 254 | Health: agentproto.WorkspaceApp_Health(healthRaw), |
| 255 | Hidden: dbApp.Hidden, |
| 256 | }, nil |
| 257 | } |
| 258 | |
| 259 | func dbAgentDevcontainersToProto(devcontainers []database.WorkspaceAgentDevcontainer) []*agentproto.WorkspaceAgentDevcontainer { |
| 260 | ret := make([]*agentproto.WorkspaceAgentDevcontainer, len(devcontainers)) |
no test coverage detected