EnsureIndex returns a stable index derived from the auth file name or credential identity.
()
| 376 | |
| 377 | // EnsureIndex returns a stable index derived from the auth file name or credential identity. |
| 378 | func (a *Auth) EnsureIndex() string { |
| 379 | if a == nil { |
| 380 | return "" |
| 381 | } |
| 382 | if existingIndex := strings.TrimSpace(a.Index); existingIndex != "" { |
| 383 | a.Index = existingIndex |
| 384 | a.indexAssigned = true |
| 385 | return existingIndex |
| 386 | } |
| 387 | |
| 388 | seed := a.indexSeed() |
| 389 | if seed == "" { |
| 390 | return "" |
| 391 | } |
| 392 | |
| 393 | idx := stableAuthIndex(seed) |
| 394 | a.Index = idx |
| 395 | a.indexAssigned = true |
| 396 | return idx |
| 397 | } |
| 398 | |
| 399 | // Clone duplicates a model state including nested error details. |
| 400 | func (m *ModelState) Clone() *ModelState { |