Gestion des versions
This commit is contained in:
parent
5d4de618dd
commit
dfa9fe3f1e
@ -24,7 +24,7 @@ func cobraInstallCmd() *cobra.Command {
|
||||
Long: `deploy Charts`,
|
||||
Args: cobra.MaximumNArgs(0),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
return InstallCmd(context, "v"+version, modules)
|
||||
return InstallCmd(context, version, modules)
|
||||
},
|
||||
Example: "oc-deploy install --version 0.1.0 --context ex1",
|
||||
}
|
||||
@ -51,7 +51,7 @@ func cobraGenerateCmd() *cobra.Command{
|
||||
Long: "Value",
|
||||
Args: cobra.MaximumNArgs(0),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
return GenerateCmd(context, "v"+version)
|
||||
return GenerateCmd(context, version)
|
||||
},
|
||||
Example: "oc-deploy generate --version 0.1.0 --context ex1",
|
||||
}
|
||||
|
@ -75,10 +75,6 @@ func (this *InstallClass) SetCommands() {
|
||||
this.commandKubectl.New()
|
||||
}
|
||||
|
||||
// func (this *InstallClass) SetCommandsMock(mock helm.HelmCommandInterface) {
|
||||
// this.commandHelm = mock
|
||||
// }
|
||||
|
||||
func (this *InstallClass) getToolBin(name string) (string, error) {
|
||||
for key, value := range this.toolsBin {
|
||||
if key == name {
|
||||
@ -132,7 +128,7 @@ func (this *InstallClass) extractVersion() (string, error) {
|
||||
}
|
||||
this.Version = version
|
||||
} else {
|
||||
log.Log().Debug().Msg("Téléchargement du fichier de version")
|
||||
log.Log().Debug().Msg("Téléchargement du fichier de version "+ this.Version)
|
||||
version, fileversion, err := versionOc.GetFromOnline(this.Version)
|
||||
if err != nil {
|
||||
return "", err
|
||||
|
@ -36,6 +36,7 @@ func GetFromOnline(version string) (string, string, error) {
|
||||
type releaseStruct struct {
|
||||
Id int `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Message string `json:"message"`
|
||||
}
|
||||
|
||||
type ocJsonStruct struct {
|
||||
@ -49,6 +50,7 @@ func readLatestFromOnline() (string, error) {
|
||||
occonst.OCDEPLOY_ONLINE_URL,
|
||||
occonst.OCDEPLOY_ONLINE_REPO)
|
||||
|
||||
log.Log().Debug().Msg(url)
|
||||
res, err := http.Get(url)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@ -64,6 +66,10 @@ func readLatestFromOnline() (string, error) {
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if len(data.Message) > 0 {
|
||||
log.Log().Debug().Msg(data.Message)
|
||||
return "", fmt.Errorf("Dernière version introuvable")
|
||||
}
|
||||
|
||||
return data.Name, err
|
||||
}
|
||||
|
@ -26,5 +26,5 @@ func GetFromFile(fileversion string) (string, error) {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return objmap.Version, nil
|
||||
return "v" + objmap.Version, nil
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ func TestGetFromFile(t *testing.T) {
|
||||
version, err := GetFromFile(ocyaml)
|
||||
|
||||
assert.Nilf(t, err, "error message %s", ocyaml)
|
||||
assert.Equal(t, "99.0", version, "TestGetFromFile error")
|
||||
assert.Equal(t, "v99.0", version, "TestGetFromFile error")
|
||||
}
|
||||
|
||||
func TestGetFromFileErr(t *testing.T) {
|
||||
|
Loading…
Reference in New Issue
Block a user