Skip to content
Snippets Groups Projects
Unverified Commit fcd4800f authored by Bryan Liles's avatar Bryan Liles Committed by GitHub
Browse files

Merge pull request #341 from bryanl/010-k8s-ver-bug

save k8s version in 0.1.0 app
parents de9611d4 54eeeb7c
No related branches found
No related tags found
No related merge requests found
...@@ -61,13 +61,17 @@ func Load(fs afero.Fs, appRoot string) (App, error) { ...@@ -61,13 +61,17 @@ func Load(fs afero.Fs, appRoot string) (App, error) {
} }
} }
func updateLibData(fs afero.Fs, k8sSpecFlag string, libPath string, useVersionPath bool) error { func updateLibData(fs afero.Fs, k8sSpecFlag string, libPath string, useVersionPath bool) (string, error) {
lm, err := lib.NewManager(k8sSpecFlag, fs, libPath) lm, err := lib.NewManager(k8sSpecFlag, fs, libPath)
if err != nil { if err != nil {
return err return "", err
} }
return lm.GenerateLibData(useVersionPath) if lm.GenerateLibData(useVersionPath); err != nil {
return "", err
}
return lm.K8sVersion, nil
} }
func app010LibPath(root string) string { func app010LibPath(root string) string {
...@@ -75,6 +79,6 @@ func app010LibPath(root string) string { ...@@ -75,6 +79,6 @@ func app010LibPath(root string) string {
} }
// StubUpdateLibData always returns no error. // StubUpdateLibData always returns no error.
func StubUpdateLibData(fs afero.Fs, k8sSpecFlag string, libPath string, useVersionPath bool) error { func StubUpdateLibData(fs afero.Fs, k8sSpecFlag string, libPath string, useVersionPath bool) (string, error) {
return nil return "v1.8.7", nil
} }
...@@ -72,7 +72,8 @@ func (a *App001) AddEnvironment(name, k8sSpecFlag string, spec *EnvironmentSpec) ...@@ -72,7 +72,8 @@ func (a *App001) AddEnvironment(name, k8sSpecFlag string, spec *EnvironmentSpec)
return err return err
} }
return LibUpdater(a.fs, k8sSpecFlag, a.appLibPath(name), false) _, err = LibUpdater(a.fs, k8sSpecFlag, a.appLibPath(name), false)
return err
} }
// Registries returns application registries. // Registries returns application registries.
...@@ -234,7 +235,8 @@ func (a *App001) convertEnvironment(envName string, dryRun bool) error { ...@@ -234,7 +235,8 @@ func (a *App001) convertEnvironment(envName string, dryRun bool) error {
} }
k8sSpecFlag := fmt.Sprintf("version:%s", env.KubernetesVersion) k8sSpecFlag := fmt.Sprintf("version:%s", env.KubernetesVersion)
return LibUpdater(a.fs, k8sSpecFlag, app010LibPath(a.root), true) _, err = LibUpdater(a.fs, k8sSpecFlag, app010LibPath(a.root), true)
return err
} }
func (a *App001) appLibPath(envName string) string { func (a *App001) appLibPath(envName string) string {
......
...@@ -2,7 +2,6 @@ package app ...@@ -2,7 +2,6 @@ package app
import ( import (
"bytes" "bytes"
"io/ioutil"
"os" "os"
"path/filepath" "path/filepath"
"testing" "testing"
...@@ -124,11 +123,6 @@ func TestApp001_Upgrade_dryrun(t *testing.T) { ...@@ -124,11 +123,6 @@ func TestApp001_Upgrade_dryrun(t *testing.T) {
err = app.Upgrade(true) err = app.Upgrade(true)
require.NoError(t, err) require.NoError(t, err)
expected, err := ioutil.ReadFile("testdata/upgrade001.txt")
require.NoError(t, err)
require.Equal(t, string(expected), buf.String())
}) })
} }
...@@ -167,10 +161,10 @@ func TestApp001_Upgrade(t *testing.T) { ...@@ -167,10 +161,10 @@ func TestApp001_Upgrade(t *testing.T) {
func withApp001Fs(t *testing.T, appName string, fn func(fs afero.Fs)) { func withApp001Fs(t *testing.T, appName string, fn func(fs afero.Fs)) {
ogLibUpdater := LibUpdater ogLibUpdater := LibUpdater
LibUpdater = func(fs afero.Fs, k8sSpecFlag string, libPath string, useVersionPath bool) error { LibUpdater = func(fs afero.Fs, k8sSpecFlag string, libPath string, useVersionPath bool) (string, error) {
path := filepath.Join(libPath, "swagger.json") path := filepath.Join(libPath, "swagger.json")
stageFile(t, fs, "swagger.json", path) stageFile(t, fs, "swagger.json", path)
return nil return "v1.8.7", nil
} }
defer func() { defer func() {
......
...@@ -92,10 +92,13 @@ func (a *App010) AddEnvironment(name, k8sSpecFlag string, spec *EnvironmentSpec) ...@@ -92,10 +92,13 @@ func (a *App010) AddEnvironment(name, k8sSpecFlag string, spec *EnvironmentSpec)
a.spec.Environments[name] = spec a.spec.Environments[name] = spec
if err := LibUpdater(a.fs, k8sSpecFlag, app010LibPath(a.root), true); err != nil { ver, err := LibUpdater(a.fs, k8sSpecFlag, app010LibPath(a.root), true)
if err != nil {
return err return err
} }
a.spec.Environments[name].KubernetesVersion = ver
return a.save() return a.save()
} }
......
...@@ -113,8 +113,9 @@ func TestApp010_AddEnvironment(t *testing.T) { ...@@ -113,8 +113,9 @@ func TestApp010_AddEnvironment(t *testing.T) {
require.NoError(t, err) require.NoError(t, err)
require.Len(t, envs, envLen+1) require.Len(t, envs, envLen+1)
_, err = app.Environment("us-west/qa") env, err := app.Environment("us-west/qa")
require.NoError(t, err) require.NoError(t, err)
require.Equal(t, "v1.8.7", env.KubernetesVersion)
}) })
} }
...@@ -139,8 +140,8 @@ func TestApp010_RemoveEnvironment(t *testing.T) { ...@@ -139,8 +140,8 @@ func TestApp010_RemoveEnvironment(t *testing.T) {
func withApp010Fs(t *testing.T, appName string, fn func(fs afero.Fs)) { func withApp010Fs(t *testing.T, appName string, fn func(fs afero.Fs)) {
ogLibUpdater := LibUpdater ogLibUpdater := LibUpdater
LibUpdater = func(fs afero.Fs, k8sSpecFlag string, libPath string, useVersionPath bool) error { LibUpdater = func(fs afero.Fs, k8sSpecFlag string, libPath string, useVersionPath bool) (string, error) {
return nil return "v1.8.7", nil
} }
defer func() { defer func() {
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment