diff --git a/offline/oc_1.0.yml b/offline/oc_1.0.yml index 1915e15..5167362 100644 --- a/offline/oc_1.0.yml +++ b/offline/oc_1.0.yml @@ -6,10 +6,10 @@ version: 1.0 tools: - name: kubectl url: https://dl.k8s.io/release/%s/bin/linux/amd64/kubectl - version: v1.30.3 + version: v1.31.0 - name: helm url: https://get.helm.sh/helm-%s-linux-amd64.tar.gz - version: v3.15.4 + version: v3.16.0 # helm install my-release / opencloud: diff --git a/src/README.md b/src/README.md index 68ab878..eef348d 100644 --- a/src/README.md +++ b/src/README.md @@ -77,4 +77,9 @@ Test generate _.coverage.html_ file to view the coverage of test. ## To Publish -Cf : ../publish \ No newline at end of file +Cf : ../publish + +## Divers + +* Latest version for _kubectl_: https://dl.k8s.io/release/stable.txt +* Release for _helm_: https://github.com/helm/helm/releases diff --git a/src/cmd/args.go b/src/cmd/args.go index 4f04f09..8f879bd 100644 --- a/src/cmd/args.go +++ b/src/cmd/args.go @@ -24,9 +24,9 @@ func cobraInstallCmd() *cobra.Command { Long: `deploy Charts`, Args: cobra.MaximumNArgs(0), RunE: func(cmd *cobra.Command, args []string) error { - return InstallCmd(context, version, modules) + return InstallCmd(context, "v"+version, modules) }, - Example: "oc-deploy install --version 1.0 --context ex1", + Example: "oc-deploy install --version 0.1.0 --context ex1", } } @@ -51,9 +51,9 @@ func cobraGenerateCmd() *cobra.Command{ Long: "Value", Args: cobra.MaximumNArgs(0), RunE: func(cmd *cobra.Command, args []string) error { - return GenerateCmd(context, version) + return GenerateCmd(context, "v"+version) }, - Example: "oc-deploy generate --version 1.0 --context ex1", + Example: "oc-deploy generate --version 0.1.0 --context ex1", } } diff --git a/src/occonst/variables.go b/src/occonst/variables.go index b9a5b5c..44c451e 100644 --- a/src/occonst/variables.go +++ b/src/occonst/variables.go @@ -1,6 +1,18 @@ package occonst -var ONLINE_URL = "https://cloud.o-forge.io" -var ONLINE_VERSION = "core/oc-deploy" +import ( + "os" +) -var OFFLINE_DIR = "../../offline" +var OCDEPLOY_ONLINE_URL = getenv("OCDEPLOY_ONLINE_URL", "https://cloud.o-forge.io") +var OCDEPLOY_ONLINE_REPO = getenv("OCDEPLOY_ONLINE_REPO", "core/oc-version") + +var OCDEPLOY_OFFLINE_DIR = getenv("OCDEPLOY_OFFLINE_DIR", "../../offline") + +func getenv(key string, defaut string) string { + value := os.Getenv(key) + if len(value) == 0 { + return defaut + } + return value +} diff --git a/src/versionOc/offline.go b/src/versionOc/offline.go index 1695822..3a48bd4 100644 --- a/src/versionOc/offline.go +++ b/src/versionOc/offline.go @@ -29,7 +29,7 @@ func GetFromOffline(version string) (string, string, error) { } ficversion := fmt.Sprintf("oc_%s.yml", version2) - src := filepath.Join(occonst.OFFLINE_DIR, ficversion) + src := filepath.Join(occonst.OCDEPLOY_OFFLINE_DIR, ficversion) if _, err := os.Stat(src); err != nil { log.Log().Debug().Msg(err.Error()) return "", "", errors.New("Version non disponible") @@ -47,7 +47,7 @@ func GetFromOffline(version string) (string, string, error) { // readLatestFile : Lit le numéro de la version dans le fichier lastest.yml func readLatestFromOffline() (string, error) { - src := filepath.Join(occonst.OFFLINE_DIR, "latest.yml") + src := filepath.Join(occonst.OCDEPLOY_OFFLINE_DIR, "latest.yml") fin, err := os.Open(src) if err != nil { diff --git a/src/versionOc/offline_test.go b/src/versionOc/offline_test.go index 85a84ec..7112010 100644 --- a/src/versionOc/offline_test.go +++ b/src/versionOc/offline_test.go @@ -18,10 +18,10 @@ func TestGetOffline(t *testing.T) { func TestGetLatest(t *testing.T) { - occonst.OFFLINE_DIR = filepath.Join(TEST_SRC_DIR, "offline") + occonst.OCDEPLOY_OFFLINE_DIR = filepath.Join(TEST_SRC_DIR, "offline") version, _, err := GetFromOffline("latest") assert.Nilf(t, err, "error message %s", err) assert.Equal(t, "99.1", version, "TestGetFromFile error") -} \ No newline at end of file +} diff --git a/src/versionOc/online.go b/src/versionOc/online.go index e23acf1..3dc361f 100644 --- a/src/versionOc/online.go +++ b/src/versionOc/online.go @@ -46,8 +46,8 @@ type ocJsonStruct struct { func readLatestFromOnline() (string, error) { url := fmt.Sprintf("%s/api/v1/repos/%s/releases/latest", - occonst.ONLINE_URL, - occonst.ONLINE_VERSION) + occonst.OCDEPLOY_ONLINE_URL, + occonst.OCDEPLOY_ONLINE_REPO) res, err := http.Get(url) if err != nil { @@ -72,8 +72,8 @@ func readLatestFromOnline() (string, error) { func getFileVersion(version string) (string, error) { url := fmt.Sprintf("%s/%s/releases/download/%s/oc.json", - occonst.ONLINE_URL, - occonst.ONLINE_VERSION, + occonst.OCDEPLOY_ONLINE_URL, + occonst.OCDEPLOY_ONLINE_REPO, version) res, err := http.Get(url) diff --git a/src/versionOc/online_test.go b/src/versionOc/online_test.go index b7458a8..6fc2b38 100644 --- a/src/versionOc/online_test.go +++ b/src/versionOc/online_test.go @@ -18,8 +18,8 @@ func TestGetOnline(t *testing.T) { version := "99.1" url := fmt.Sprintf("%s/%s/releases/download/%s/oc.json", - occonst.ONLINE_URL, - occonst.ONLINE_VERSION, + occonst.OCDEPLOY_ONLINE_URL, + occonst.OCDEPLOY_ONLINE_REPO, version) httpmock.RegisterResponder("GET", url, @@ -37,16 +37,16 @@ func TestGetOnlineLatest(t *testing.T) { // version := "99.1" url := fmt.Sprintf("%s/api/v1/repos/%s/releases/latest", - occonst.ONLINE_URL, - occonst.ONLINE_VERSION) + occonst.OCDEPLOY_ONLINE_URL, + occonst.OCDEPLOY_ONLINE_REPO) httpmock.RegisterResponder("GET", url, httpmock.NewStringResponder(200, `{"name": "99.0", "id": 2}`)) version := "99.0" url2 := fmt.Sprintf("%s/%s/releases/download/%s/oc.json", - occonst.ONLINE_URL, - occonst.ONLINE_VERSION, + occonst.OCDEPLOY_ONLINE_URL, + occonst.OCDEPLOY_ONLINE_REPO, version) httpmock.RegisterResponder("GET", url2,