computeBuildKind performs the actual detection without any caching. Exposed for tests. Gathers runtime/global inputs and delegates the pure branching logic to classifyBuild so that logic can be unit-tested without mutating process-wide provider registries.
()
| 106 | // branching logic to classifyBuild so that logic can be unit-tested without |
| 107 | // mutating process-wide provider registries. |
| 108 | func computeBuildKind() string { |
| 109 | info, ok := debug.ReadBuildInfo() |
| 110 | mainPath := "" |
| 111 | if ok { |
| 112 | mainPath = info.Main.Path |
| 113 | } |
| 114 | |
| 115 | credProviders := credential.Providers() |
| 116 | creds := make([]any, len(credProviders)) |
| 117 | for i, p := range credProviders { |
| 118 | creds[i] = p |
| 119 | } |
| 120 | |
| 121 | var tp any |
| 122 | if p := exttransport.GetProvider(); p != nil { |
| 123 | tp = p |
| 124 | } |
| 125 | var fp any |
| 126 | if p := fileio.GetProvider(); p != nil { |
| 127 | fp = p |
| 128 | } |
| 129 | return classifyBuild(mainPath, ok, creds, tp, fp) |
| 130 | } |
| 131 | |
| 132 | // classifyBuild is the pure classification logic used by computeBuildKind. |
| 133 | // Callers supply concrete values so every branch is reachable from tests |