oc-deploy/src/tool/kubectl.go

42 lines
813 B
Go
Raw Normal View History

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