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