lint
This commit is contained in:
parent
26404e5892
commit
11a4d5cc90
@ -26,9 +26,12 @@ type chartsRepoData struct {
|
|||||||
Charts []ChartRepoData `yaml:"opencloud"`
|
Charts []ChartRepoData `yaml:"opencloud"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func FromConfigFile(filename string) ([]ChartRepoData) {
|
func FromConfigFile(filename string) ([]ChartRepoData, error) {
|
||||||
yamlFile, _ := os.ReadFile(filename)
|
yamlFile, _ := os.ReadFile(filename)
|
||||||
var data chartsRepoData
|
var data chartsRepoData
|
||||||
yaml.Unmarshal(yamlFile, &data)
|
err := yaml.Unmarshal(yamlFile, &data)
|
||||||
return data.Charts
|
if err != nil {
|
||||||
|
return data.Charts, err
|
||||||
|
}
|
||||||
|
return data.Charts, nil
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ func TestReadConfChart(t *testing.T){
|
|||||||
|
|
||||||
assert.FileExists(t, src, "FromConfigFile error")
|
assert.FileExists(t, src, "FromConfigFile error")
|
||||||
|
|
||||||
data := FromConfigFile(src)
|
data, _ := FromConfigFile(src)
|
||||||
assert.Equal(t, data[0].Name, "bitnami", "FromConfigFile error")
|
assert.Equal(t, data[0].Name, "bitnami", "FromConfigFile error")
|
||||||
assert.Equal(t, data[0].Repository, "https://charts.bitnami.com/bitnami", "FromConfigFile error")
|
assert.Equal(t, data[0].Repository, "https://charts.bitnami.com/bitnami", "FromConfigFile error")
|
||||||
|
|
||||||
|
@ -8,7 +8,6 @@ import (
|
|||||||
type GenerateClass struct {
|
type GenerateClass struct {
|
||||||
Version string
|
Version string
|
||||||
Workspace string
|
Workspace string
|
||||||
url string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this GenerateClass) New() (string, error) {
|
func (this GenerateClass) New() (string, error) {
|
||||||
|
@ -76,7 +76,10 @@ func (this HelmChart) Install() (string, error) {
|
|||||||
|
|
||||||
var objmap installOutput
|
var objmap installOutput
|
||||||
|
|
||||||
json.Unmarshal(stdout, &objmap)
|
err = json.Unmarshal(stdout, &objmap)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
res := objmap.Info.Status
|
res := objmap.Info.Status
|
||||||
|
|
||||||
|
@ -52,8 +52,15 @@ func (this *InstallClass) NewInstall() (string, error) {
|
|||||||
// Lecture du fichier de conf
|
// Lecture du fichier de conf
|
||||||
// this.versionFile = dst
|
// this.versionFile = dst
|
||||||
|
|
||||||
this.tools = tool.FromConfigFile(dst)
|
var err error
|
||||||
this.charts = chart.FromConfigFile(dst)
|
this.tools, err = tool.FromConfigFile(dst)
|
||||||
|
if err != nil {
|
||||||
|
return dst, err
|
||||||
|
}
|
||||||
|
this.charts, _ = chart.FromConfigFile(dst)
|
||||||
|
if err != nil {
|
||||||
|
return dst, err
|
||||||
|
}
|
||||||
|
|
||||||
return dst, nil
|
return dst, nil
|
||||||
}
|
}
|
||||||
|
@ -27,8 +27,14 @@ func (this *InstallClass) NewUninstall() (string, error) {
|
|||||||
this.Version = version
|
this.Version = version
|
||||||
|
|
||||||
// Lecture du fichier de conf
|
// Lecture du fichier de conf
|
||||||
this.tools = tool.FromConfigFile(dst)
|
this.tools, err = tool.FromConfigFile(dst)
|
||||||
this.charts = chart.FromConfigFile(dst)
|
if err != nil {
|
||||||
|
return dst, err
|
||||||
|
}
|
||||||
|
this.charts, _ = chart.FromConfigFile(dst)
|
||||||
|
if err != nil {
|
||||||
|
return dst, err
|
||||||
|
}
|
||||||
|
|
||||||
return dst, nil
|
return dst, nil
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,10 @@ func (this KubeContext) GetContext() (string, string, string, error) {
|
|||||||
|
|
||||||
var objmap kubeConfig
|
var objmap kubeConfig
|
||||||
|
|
||||||
json.Unmarshal(stdout, &objmap)
|
err := json.Unmarshal(stdout, &objmap)
|
||||||
|
if err != nil {
|
||||||
|
return "", "", "", err
|
||||||
|
}
|
||||||
currentContext := objmap.CurrentContext
|
currentContext := objmap.CurrentContext
|
||||||
|
|
||||||
currentCluster := ""
|
currentCluster := ""
|
||||||
|
@ -9,9 +9,12 @@ type toolsData struct {
|
|||||||
Tools []ToolData `yaml:"tools"`
|
Tools []ToolData `yaml:"tools"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func FromConfigFile(filename string) ([]ToolData) {
|
func FromConfigFile(filename string) ([]ToolData, error) {
|
||||||
yamlFile, _ := os.ReadFile(filename)
|
yamlFile, _ := os.ReadFile(filename)
|
||||||
var data toolsData
|
var data toolsData
|
||||||
yaml.Unmarshal(yamlFile, &data)
|
err := yaml.Unmarshal(yamlFile, &data)
|
||||||
return data.Tools
|
if err != nil {
|
||||||
|
return data.Tools, nil
|
||||||
|
}
|
||||||
|
return data.Tools, nil
|
||||||
}
|
}
|
||||||
|
@ -36,14 +36,16 @@ func (this HelmInstallData) Download() (error) {
|
|||||||
|
|
||||||
r, _ := os.Open(tmp_file)
|
r, _ := os.Open(tmp_file)
|
||||||
err1 := utils.ExtractTarGz(bin_dir, r)
|
err1 := utils.ExtractTarGz(bin_dir, r)
|
||||||
|
if err1 != nil {return err1}
|
||||||
|
|
||||||
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)
|
errChmod := os.Chmod(bin_file, 0755)
|
||||||
|
if errChmod != nil {return errChmod}
|
||||||
|
|
||||||
return err1
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////
|
///////////////
|
||||||
|
@ -4,7 +4,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"errors"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -73,7 +72,7 @@ func factory(data ToolData) (Forme, error) {
|
|||||||
case "helm":
|
case "helm":
|
||||||
f = HelmInstallData{obj: data, tmp: "/tmp"}
|
f = HelmInstallData{obj: data, tmp: "/tmp"}
|
||||||
default:
|
default:
|
||||||
return f, errors.New(fmt.Sprintf("Outil Inconnu : %s", data.Name))
|
return f, fmt.Errorf("Outil Inconnu : %s", data.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
return f, nil
|
return f, nil
|
||||||
|
@ -43,7 +43,7 @@ func ExtractTarGz(dest string, gzipStream io.Reader) error {
|
|||||||
|
|
||||||
tarReader := tar.NewReader(uncompressedStream)
|
tarReader := tar.NewReader(uncompressedStream)
|
||||||
|
|
||||||
for true {
|
for {
|
||||||
header, err := tarReader.Next()
|
header, err := tarReader.Next()
|
||||||
|
|
||||||
if err == io.EOF {
|
if err == io.EOF {
|
||||||
|
@ -5,7 +5,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"errors"
|
"errors"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"gopkg.in/yaml.v2"
|
"gopkg.in/yaml.v2"
|
||||||
log "oc-deploy/log_wrapper"
|
log "oc-deploy/log_wrapper"
|
||||||
)
|
)
|
||||||
@ -21,7 +21,7 @@ func GetFromFile(fileversion string) (string, error) {
|
|||||||
}
|
}
|
||||||
defer fin.Close()
|
defer fin.Close()
|
||||||
|
|
||||||
byteValue, err := ioutil.ReadAll(fin)
|
byteValue, err := io.ReadAll(fin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
@ -64,7 +64,7 @@ func readLatestFile() (string, error) {
|
|||||||
}
|
}
|
||||||
defer fin.Close()
|
defer fin.Close()
|
||||||
|
|
||||||
byteValue, err := ioutil.ReadAll(fin)
|
byteValue, err := io.ReadAll(fin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user