oc-deploy/src/tool/kubectl.go

42 lines
821 B
Go
Raw Normal View History

2024-09-02 09:09:46 +02:00
package tool
import (
"fmt"
"os"
"path/filepath"
log "oc-deploy/log_wrapper"
"oc-deploy/utils"
"oc-deploy/kubectl"
)
type KubecltInstallData struct {
obj ToolData
}
func (this KubecltInstallData) Get() (ToolData) {
return this.obj
}
func (this KubecltInstallData) Download() (error) {
bin_dir := this.obj.Bin
bin := filepath.Join(bin_dir, this.obj.Name)
url := fmt.Sprintf(this.obj.Url, this.obj.Version)
log.Log().Debug().Msg(fmt.Sprintf("Téléchargement : %s, %s", bin, url))
os.MkdirAll(bin_dir, os.ModePerm)
err := utils.DownloadFromUrl(bin, url, 0777)
if err != nil {return err}
os.Chmod(bin, 0755)
return nil
}
///////////////
func (this KubecltInstallData) Version(path string) (string, error) {
return kubectl.Version(path)
}