| 819 | // |
| 820 | |
| 821 | static std::string common_docker_get_token(const std::string & repo) { |
| 822 | std::string url = "https://auth.docker.io/token?service=registry.docker.io&scope=repository:" + repo + ":pull"; |
| 823 | |
| 824 | common_remote_params params; |
| 825 | auto res = common_remote_get_content(url, params); |
| 826 | |
| 827 | if (res.first != 200) { |
| 828 | throw std::runtime_error("Failed to get Docker registry token, HTTP code: " + std::to_string(res.first)); |
| 829 | } |
| 830 | |
| 831 | std::string response_str(res.second.begin(), res.second.end()); |
| 832 | nlohmann::ordered_json response = nlohmann::ordered_json::parse(response_str); |
| 833 | |
| 834 | if (!response.contains("token")) { |
| 835 | throw std::runtime_error("Docker registry token response missing 'token' field"); |
| 836 | } |
| 837 | |
| 838 | return response["token"].get<std::string>(); |
| 839 | } |
| 840 | |
| 841 | std::string common_docker_resolve_model(const std::string & docker) { |
| 842 | // Parse ai/smollm2:135M-Q4_0 |
no test coverage detected