Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Ijaz Ahmad
ksonnet
Commits
54eeeb7c
Commit
54eeeb7c
authored
Mar 05, 2018
by
bryanl
Browse files
save k8s version in 0.1.0 app
Signed-off-by:
bryanl
<
bryanliles@gmail.com
>
parent
c2996a9b
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
23 additions
and
19 deletions
+23
-19
metadata/app/app.go
metadata/app/app.go
+9
-5
metadata/app/app001.go
metadata/app/app001.go
+4
-2
metadata/app/app001_test.go
metadata/app/app001_test.go
+2
-8
metadata/app/app010.go
metadata/app/app010.go
+4
-1
metadata/app/app010_test.go
metadata/app/app010_test.go
+4
-3
No files found.
metadata/app/app.go
View file @
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
}
metadata/app/app001.go
View file @
54eeeb7c
...
...
@@ -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
{
...
...
metadata/app/app001_test.go
View file @
54eeeb7c
...
...
@@ -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
()
{
...
...
metadata/app/app010.go
View file @
54eeeb7c
...
...
@@ -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
()
}
...
...
metadata/app/app010_test.go
View file @
54eeeb7c
...
...
@@ -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
()
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment