53 lines
985 B
Go
53 lines
985 B
Go
package tool
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
|
|
// log "oc-deploy/log_wrapper"
|
|
"oc-deploy/utils"
|
|
"oc-deploy/helm"
|
|
)
|
|
|
|
type HelmInstallData struct {
|
|
obj ToolData
|
|
tmp string
|
|
}
|
|
|
|
func (this HelmInstallData) Get() (ToolData) {
|
|
return this.obj
|
|
}
|
|
|
|
func (this HelmInstallData) Download() (error) {
|
|
|
|
bin_dir := this.obj.Bin
|
|
err2 := os.MkdirAll(bin_dir, os.ModePerm)
|
|
if err2 != nil {
|
|
fmt.Println(err2)
|
|
return err2
|
|
}
|
|
|
|
tmp_file := fmt.Sprintf("%s/oc-deploy-%s", this.tmp, this.obj.Name)
|
|
url := fmt.Sprintf(this.obj.Url, this.obj.Version)
|
|
|
|
err := utils.DownloadFromUrl(tmp_file, url, 0777)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
r, _ := os.Open(tmp_file)
|
|
err1 := utils.ExtractTarGz(bin_dir, r)
|
|
|
|
os.Remove(tmp_file)
|
|
|
|
bin_file := fmt.Sprintf("%s/%s", bin_dir, this.obj.Name)
|
|
|
|
os.Chmod(bin_file, 0755)
|
|
|
|
return err1
|
|
}
|
|
|
|
///////////////
|
|
func (this HelmInstallData) Version(path string) (string, error) {
|
|
return helm.Version(path)
|
|
} |