| 123 | |
| 124 | |
| 125 | Try<string> getRegistryScheme(const string& registry) |
| 126 | { |
| 127 | Result<int> port = getRegistryPort(registry); |
| 128 | if (port.isError()) { |
| 129 | return Error("Failed to get registry port: " + port.error()); |
| 130 | } else if (port.isSome()) { |
| 131 | if (port.get() == 443) { |
| 132 | return "https"; |
| 133 | } |
| 134 | |
| 135 | if (port.get() == 80) { |
| 136 | return "http"; |
| 137 | } |
| 138 | |
| 139 | // NOTE: For a local registry, it's typically a http server. |
| 140 | const string host = getRegistryHost(registry); |
| 141 | if (host == "localhost" || host == "127.0.0.1") { |
| 142 | return "http"; |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | return "https"; |
| 147 | } |
| 148 | |
| 149 | |
| 150 | string getRegistryHost(const string& registry) |
no test coverage detected