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

Method Run

kitectl/command/install.go:45–120  ·  view source on GitHub ↗
(args []string)

Source from the content-addressed store, hash-verified

43}
44
45func (c *Install) Run(args []string) int {
46 if len(args) != 1 {
47 c.Ui.Error("You should give a URL. Example: github.com/cenkalti/math.kite")
48 return 1
49 }
50
51 repoName := args[0]
52
53 // Download manifest
54 c.Ui.Output("Downloading manifest file...")
55 manifest, err := getManifest(repoName)
56 if err != nil {
57 c.Ui.Error(err.Error())
58 return 1
59 }
60
61 version, err := getVersion(manifest)
62 if err != nil {
63 c.Ui.Error(err.Error())
64 return 1
65 }
66
67 c.Ui.Output(fmt.Sprintf("Found version: %s\n", version))
68
69 binaryURL, err := getBinaryURL(manifest)
70 if err != nil {
71 c.Ui.Error(err.Error())
72 return 1
73 }
74
75 // Make download request to the kite binary
76 fmt.Println("Downloading kite...")
77 targz, err := http.Get(binaryURL)
78 if err != nil {
79 c.Ui.Error(err.Error())
80 return 1
81 }
82 defer targz.Body.Close()
83
84 // Extract gzip
85 gz, err := gzip.NewReader(targz.Body)
86 if err != nil {
87 c.Ui.Error(err.Error())
88 return 1
89 }
90 defer gz.Close()
91
92 // Extract tar
93 tempKitePath, err := ioutil.TempDir("", "kite-install-")
94 if err != nil {
95 c.Ui.Error(err.Error())
96 return 1
97 }
98 defer os.RemoveAll(tempKitePath)
99
100 err = extractTar(gz, tempKitePath)
101 if err != nil {
102 c.Ui.Error(err.Error())

Callers

nothing calls this directly

Calls 9

getManifestFunction · 0.85
getVersionFunction · 0.85
getBinaryURLFunction · 0.85
extractTarFunction · 0.85
validatePackageFunction · 0.85
installKiteFunction · 0.85
ErrorMethod · 0.65
GetMethod · 0.65
CloseMethod · 0.45

Tested by

no test coverage detected