(auth *coreauth.Auth)
| 383 | } |
| 384 | |
| 385 | func (h *Host) buildHostAuthFileEntry(auth *coreauth.Auth) *pluginapi.HostAuthFileEntry { |
| 386 | if auth == nil { |
| 387 | return nil |
| 388 | } |
| 389 | auth.EnsureIndex() |
| 390 | runtimeOnly := isRuntimeOnlyAuth(auth) |
| 391 | if runtimeOnly && (auth.Disabled || auth.Status == coreauth.StatusDisabled) { |
| 392 | return nil |
| 393 | } |
| 394 | path := strings.TrimSpace(authAttribute(auth, "path")) |
| 395 | if path == "" && !runtimeOnly { |
| 396 | return nil |
| 397 | } |
| 398 | name := strings.TrimSpace(auth.FileName) |
| 399 | if name == "" { |
| 400 | name = auth.ID |
| 401 | } |
| 402 | entry := &pluginapi.HostAuthFileEntry{ |
| 403 | ID: auth.ID, |
| 404 | AuthIndex: auth.Index, |
| 405 | Name: name, |
| 406 | Type: strings.TrimSpace(auth.Provider), |
| 407 | Provider: strings.TrimSpace(auth.Provider), |
| 408 | Label: auth.Label, |
| 409 | Status: string(auth.Status), |
| 410 | StatusMessage: auth.StatusMessage, |
| 411 | Disabled: auth.Disabled, |
| 412 | Unavailable: auth.Unavailable, |
| 413 | RuntimeOnly: runtimeOnly, |
| 414 | Source: "memory", |
| 415 | Success: auth.Success, |
| 416 | Failed: auth.Failed, |
| 417 | RecentRequests: hostRecentRequests(auth), |
| 418 | } |
| 419 | if email := authEmail(auth); email != "" { |
| 420 | entry.Email = email |
| 421 | } |
| 422 | if projectID := authProjectID(auth); projectID != "" { |
| 423 | entry.ProjectID = projectID |
| 424 | } |
| 425 | if accountType, account := auth.AccountInfo(); accountType != "" || account != "" { |
| 426 | entry.AccountType = accountType |
| 427 | entry.Account = account |
| 428 | } |
| 429 | if !auth.CreatedAt.IsZero() { |
| 430 | entry.CreatedAt = auth.CreatedAt |
| 431 | } |
| 432 | if !auth.UpdatedAt.IsZero() { |
| 433 | entry.ModTime = auth.UpdatedAt |
| 434 | entry.UpdatedAt = auth.UpdatedAt |
| 435 | } |
| 436 | if !auth.LastRefreshedAt.IsZero() { |
| 437 | entry.LastRefresh = auth.LastRefreshedAt |
| 438 | } |
| 439 | if !auth.NextRetryAfter.IsZero() { |
| 440 | entry.NextRetryAfter = auth.NextRetryAfter |
| 441 | } |
| 442 | if path != "" { |
no test coverage detected