validatePackage does some checks on kite bundle and returns the bundle path.
(tempKitePath, repoName string)
| 239 | |
| 240 | // validatePackage does some checks on kite bundle and returns the bundle path. |
| 241 | func validatePackage(tempKitePath, repoName string) (bundlePath string, err error) { |
| 242 | dirs, err := ioutil.ReadDir(tempKitePath) |
| 243 | if err != nil { |
| 244 | return "", err |
| 245 | } |
| 246 | |
| 247 | if len(dirs) != 1 { |
| 248 | return "", errors.New("Invalid package: Package must contain only one directory.") |
| 249 | } |
| 250 | |
| 251 | bundlePath = filepath.Join(tempKitePath, dirs[0].Name()) |
| 252 | |
| 253 | parts := strings.Split(repoName, "/") |
| 254 | if len(parts) == 0 { |
| 255 | return "", errors.New("invalid repo URL") |
| 256 | } |
| 257 | |
| 258 | kiteName := strings.TrimSuffix(parts[len(parts)-1], ".kite") |
| 259 | |
| 260 | _, err = os.Stat(filepath.Join(bundlePath, "bin", kiteName)) |
| 261 | return bundlePath, err |
| 262 | } |
| 263 | |
| 264 | // installKite moves the .kite bundle into ~/kd/kites. |
| 265 | func installKite(bundlePath, repoName, version string) error { |