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
......@@ -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)
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 {
......@@ -75,6 +79,6 @@ func app010LibPath(root string) string {
}
// StubUpdateLibData always returns no error.
func StubUpdateLibData(fs afero.Fs, k8sSpecFlag string, libPath string, useVersionPath bool) error {
return nil
func StubUpdateLibData(fs afero.Fs, k8sSpecFlag string, libPath string, useVersionPath bool) (string, error) {
return "v1.8.7", nil
}
......@@ -72,7 +72,8 @@ func (a *App001) AddEnvironment(name, k8sSpecFlag string, spec *EnvironmentSpec)
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.
......@@ -234,7 +235,8 @@ func (a *App001) convertEnvironment(envName string, dryRun bool) error {
}
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 {
......
......@@ -2,7 +2,6 @@ package app
import (
"bytes"
"io/ioutil"
"os"
"path/filepath"
"testing"
......@@ -124,11 +123,6 @@ func TestApp001_Upgrade_dryrun(t *testing.T) {
err = app.Upgrade(true)
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) {
func withApp001Fs(t *testing.T, appName string, fn func(fs afero.Fs)) {
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")
stageFile(t, fs, "swagger.json", path)
return nil
return "v1.8.7", nil
}
defer func() {
......
......@@ -92,10 +92,13 @@ func (a *App010) AddEnvironment(name, k8sSpecFlag string, spec *EnvironmentSpec)
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
}
a.spec.Environments[name].KubernetesVersion = ver
return a.save()
}
......
......@@ -113,8 +113,9 @@ func TestApp010_AddEnvironment(t *testing.T) {
require.NoError(t, err)
require.Len(t, envs, envLen+1)
_, err = app.Environment("us-west/qa")
env, err := app.Environment("us-west/qa")
require.NoError(t, err)
require.Equal(t, "v1.8.7", env.KubernetesVersion)
})
}
......@@ -139,8 +140,8 @@ func TestApp010_RemoveEnvironment(t *testing.T) {
func withApp010Fs(t *testing.T, appName string, fn func(fs afero.Fs)) {
ogLibUpdater := LibUpdater
LibUpdater = func(fs afero.Fs, k8sSpecFlag string, libPath string, useVersionPath bool) error {
return nil
LibUpdater = func(fs afero.Fs, k8sSpecFlag string, libPath string, useVersionPath bool) (string, error) {
return "v1.8.7", nil
}
defer func() {
......
Markdown is supported
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