lint
This commit is contained in:
parent
9cf954776f
commit
26404e5892
@ -19,7 +19,7 @@ type ChartData struct {
|
||||
type ChartRepoData struct {
|
||||
Name string `yaml:"name"`
|
||||
Repository string `yaml:"repository"`
|
||||
Charts []ChartData `yaml:"charts"`
|
||||
Charts []ChartData `yaml:"charts"`
|
||||
}
|
||||
|
||||
type chartsRepoData struct {
|
||||
|
@ -1,8 +1,8 @@
|
||||
package chart
|
||||
|
||||
import (
|
||||
"os"
|
||||
"testing"
|
||||
"os"
|
||||
"testing"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
@ -10,14 +10,14 @@ var TEST_DEST_DIR = "../wrk_chart"
|
||||
var TEST_SRC_DIR = filepath.Join("../../test", "chart")
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
folderPath := TEST_DEST_DIR
|
||||
folderPath := TEST_DEST_DIR
|
||||
|
||||
os.RemoveAll(folderPath)
|
||||
os.MkdirAll(folderPath, os.ModePerm)
|
||||
os.RemoveAll(folderPath)
|
||||
os.MkdirAll(folderPath, os.ModePerm)
|
||||
|
||||
// call flag.Parse() here if TestMain uses flags
|
||||
exitCode := m.Run()
|
||||
// call flag.Parse() here if TestMain uses flags
|
||||
exitCode := m.Run()
|
||||
|
||||
os.RemoveAll(folderPath)
|
||||
os.Exit(exitCode)
|
||||
os.RemoveAll(folderPath)
|
||||
os.Exit(exitCode)
|
||||
}
|
@ -21,23 +21,23 @@ type kubeConfig struct {
|
||||
}
|
||||
|
||||
type kubeConfigContexts struct {
|
||||
Name string `json:"name"`
|
||||
Context kubeConfigContext `json:"context"`
|
||||
Name string `json:"name"`
|
||||
Context kubeConfigContext `json:"context"`
|
||||
}
|
||||
|
||||
type kubeConfigContext struct {
|
||||
Cluster string `json:"cluster"`
|
||||
User string `json:"user"`
|
||||
Namespace string `json:"namespace"`
|
||||
Cluster string `json:"cluster"`
|
||||
User string `json:"user"`
|
||||
Namespace string `json:"namespace"`
|
||||
}
|
||||
|
||||
type kubeConfigCluster struct {
|
||||
Server string `json:"server"`
|
||||
Server string `json:"server"`
|
||||
}
|
||||
|
||||
type kubeConfigClusters struct {
|
||||
Name string `json:"name"`
|
||||
Cluster kubeConfigCluster `json:"cluster"`
|
||||
Name string `json:"name"`
|
||||
Cluster kubeConfigCluster `json:"cluster"`
|
||||
}
|
||||
|
||||
func (this KubeContext) GetCurrentContext() (string, error) {
|
||||
@ -72,37 +72,37 @@ func (this KubeContext) GetContext() (string, string, string, error) {
|
||||
}
|
||||
}
|
||||
|
||||
currentServer := ""
|
||||
for _, v := range objmap.Clusters {
|
||||
if v.Name == currentCluster {
|
||||
currentServer = v.Cluster.Server
|
||||
}
|
||||
}
|
||||
currentServer := ""
|
||||
for _, v := range objmap.Clusters {
|
||||
if v.Name == currentCluster {
|
||||
currentServer = v.Cluster.Server
|
||||
}
|
||||
}
|
||||
|
||||
return currentContext, currentNamespace, currentServer, nil
|
||||
}
|
||||
|
||||
func (this KubeContext) UseContext(newContext string) (error) {
|
||||
|
||||
cmd := exec.Command(this.Bin, "config", "use-context", newContext)
|
||||
stdout, err := cmd.CombinedOutput()
|
||||
cmd := exec.Command(this.Bin, "config", "use-context", newContext)
|
||||
stdout, err := cmd.CombinedOutput()
|
||||
|
||||
if err != nil {
|
||||
if err != nil {
|
||||
log.Log().Debug().Msg(string(stdout))
|
||||
return errors.New(string(stdout))
|
||||
}
|
||||
return errors.New(string(stdout))
|
||||
}
|
||||
|
||||
return nil
|
||||
return nil
|
||||
}
|
||||
|
||||
func (this KubeContext) Check() (error) {
|
||||
|
||||
cmd := exec.Command(this.Bin, "cluster-info")
|
||||
stdout, err := cmd.CombinedOutput()
|
||||
cmd := exec.Command(this.Bin, "cluster-info")
|
||||
stdout, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
log.Log().Debug().Msg(string(stdout))
|
||||
return errors.New("Kube non disponible")
|
||||
}
|
||||
|
||||
return nil
|
||||
return nil
|
||||
}
|
||||
|
@ -4,50 +4,49 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
// log "oc-deploy/log_wrapper"
|
||||
"oc-deploy/utils"
|
||||
"oc-deploy/helm"
|
||||
)
|
||||
|
||||
type HelmInstallData struct {
|
||||
obj ToolData
|
||||
tmp string
|
||||
obj ToolData
|
||||
tmp string
|
||||
}
|
||||
|
||||
func (this HelmInstallData) Get() (ToolData) {
|
||||
return this.obj
|
||||
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
|
||||
}
|
||||
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)
|
||||
url := fmt.Sprintf(this.obj.Url, this.obj.Version)
|
||||
|
||||
err := utils.DownloadFromUrl(tmp_file, url, 0777)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err := utils.DownloadFromUrl(tmp_file, url, 0777)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
r, _ := os.Open(tmp_file)
|
||||
err1 := utils.ExtractTarGz(bin_dir, r)
|
||||
r, _ := os.Open(tmp_file)
|
||||
err1 := utils.ExtractTarGz(bin_dir, r)
|
||||
|
||||
os.Remove(tmp_file)
|
||||
os.Remove(tmp_file)
|
||||
|
||||
bin_file := fmt.Sprintf("%s/%s", bin_dir, this.obj.Name)
|
||||
bin_file := fmt.Sprintf("%s/%s", bin_dir, this.obj.Name)
|
||||
|
||||
os.Chmod(bin_file, 0755)
|
||||
os.Chmod(bin_file, 0755)
|
||||
|
||||
return err1
|
||||
return err1
|
||||
}
|
||||
|
||||
///////////////
|
||||
func (this HelmInstallData) Version(path string) (string, error) {
|
||||
return helm.Version(path)
|
||||
return helm.Version(path)
|
||||
}
|
@ -11,31 +11,31 @@ import (
|
||||
)
|
||||
|
||||
type KubecltInstallData struct {
|
||||
obj ToolData
|
||||
obj ToolData
|
||||
}
|
||||
|
||||
func (this KubecltInstallData) Get() (ToolData) {
|
||||
return this.obj
|
||||
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)
|
||||
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)
|
||||
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}
|
||||
err := utils.DownloadFromUrl(bin, url, 0777)
|
||||
if err != nil {return err}
|
||||
|
||||
os.Chmod(bin, 0755)
|
||||
|
||||
return nil
|
||||
return nil
|
||||
}
|
||||
|
||||
///////////////
|
||||
func (this KubecltInstallData) Version(path string) (string, error) {
|
||||
return kubectl.Version(path)
|
||||
return kubectl.Version(path)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user