MCPcopy Index your code
hub / github.com/koding/kite / getManifest

Function getManifest

kitectl/command/install.go:122–156  ·  view source on GitHub ↗
(repoName string)

Source from the content-addressed store, hash-verified

120}
121
122func 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
158func getBinaryURL(manifest map[string]interface{}) (string, error) {
159 platforms, ok := manifest["platforms"].(map[string]interface{})

Callers 1

RunMethod · 0.85

Calls 4

UnmarshalMethod · 0.80
GetMethod · 0.65
ErrorMethod · 0.65
CloseMethod · 0.45

Tested by

no test coverage detected