| 120 | } |
| 121 | |
| 122 | func getManifest(repoName string) (map[string]interface{}, error) { |
| 123 | if !strings.HasPrefix(repoName, "github.com/") { |
| 124 | return nil, errors.New("Repo other than github.com is not supported for now") |
| 125 | } |
| 126 | |
| 127 | repoName = strings.TrimRight(repoName, "/") |
| 128 | manifestURL := "http://raw." + repoName + "/master/.kite.json" |
| 129 | |
| 130 | res, err := http.Get(manifestURL) |
| 131 | if err != nil { |
| 132 | return nil, err |
| 133 | } |
| 134 | defer res.Body.Close() |
| 135 | |
| 136 | if res.StatusCode == 404 { |
| 137 | return nil, errors.New("Package is not found on the server.") |
| 138 | } |
| 139 | |
| 140 | if res.StatusCode != 200 { |
| 141 | return nil, fmt.Errorf("Unexpected response from server: %d", res.StatusCode) |
| 142 | } |
| 143 | |
| 144 | body, err := ioutil.ReadAll(res.Body) |
| 145 | if err != nil { |
| 146 | return nil, fmt.Errorf("cannot read response: %s", err.Error()) |
| 147 | } |
| 148 | |
| 149 | manifest := make(map[string]interface{}) |
| 150 | err = json.Unmarshal(body, &manifest) |
| 151 | if err != nil { |
| 152 | return nil, fmt.Errorf("invalid manifest file: %s", err.Error()) |
| 153 | } |
| 154 | |
| 155 | return manifest, nil |
| 156 | } |
| 157 | |
| 158 | func getBinaryURL(manifest map[string]interface{}) (string, error) { |
| 159 | platforms, ok := manifest["platforms"].(map[string]interface{}) |