Commit 2d58dd5a authored by Oren Shomron's avatar Oren Shomron
Browse files

Add target separator migration


Signed-off-by: default avatarOren Shomron <shomron@gmail.com>
parent 98b36185
......@@ -16,6 +16,8 @@
package app
import (
"strings"
"github.com/blang/semver"
"github.com/ghodss/yaml"
"github.com/pkg/errors"
......@@ -220,7 +222,14 @@ func migrateSchema010To020(src *Spec010) (*Spec020, error) {
dst.Environments = EnvironmentConfigs020{}
for k, v := range src.Environments {
targets := make([]string, len(v.Targets))
copy(targets, v.Targets)
for i, t := range v.Targets {
// Target separators changed from "/" to "." in 0.2.0
if t == "/" {
targets[i] = t
} else {
targets[i] = strings.Replace(t, "/", ".", -1)
}
}
dst.Environments[k] = &EnvironmentConfig020{
Name: v.Name,
......
......@@ -73,7 +73,7 @@ func Test_migrateSchema010To020(t *testing.T) {
Server: "https://localhost:6443",
Namespace: "default-namespace",
},
Targets: []string{"target1", "target2"},
Targets: []string{"/", "foo/bar/baz", "simple"},
},
},
Libraries: LibraryConfigs010{
......@@ -145,7 +145,7 @@ func Test_migrateSchema010To020(t *testing.T) {
Server: "https://localhost:6443",
Namespace: "default-namespace",
},
Targets: []string{"target1", "target2"},
Targets: []string{"/", "foo.bar.baz", "simple"},
Libraries: LibraryConfigs020{},
},
},
......@@ -217,7 +217,7 @@ func Test_migrateSchema020To030(t *testing.T) {
Server: "https://localhost:6443",
Namespace: "default-namespace",
},
Targets: []string{"target1", "target2"},
Targets: []string{"/", "foo.bar.baz", "simple"},
Libraries: LibraryConfigs020{
"nginx": &LibraryConfig020{
Name: "nginx",
......@@ -295,7 +295,7 @@ func Test_migrateSchema020To030(t *testing.T) {
Server: "https://localhost:6443",
Namespace: "default-namespace",
},
Targets: []string{"target1", "target2"},
Targets: []string{"/", "foo.bar.baz", "simple"},
Libraries: LibraryConfigs030{
"incubator/nginx": &LibraryConfig030{
Name: "nginx",
......@@ -379,7 +379,7 @@ func Test_Migrator_Load(t *testing.T) {
Server: "https://localhost:6443",
Namespace: "default-namespace",
},
Targets: []string{"target1", "target2"},
Targets: []string{"/", "foo.bar.baz", "simple"},
Libraries: LibraryConfigs030{
"incubator/nginx": &LibraryConfig030{
Name: "nginx",
......@@ -457,7 +457,7 @@ func Test_Migrator_Load(t *testing.T) {
Server: "https://localhost:6443",
Namespace: "default-namespace",
},
Targets: []string{"target1", "target2"},
Targets: []string{"/", "foo.bar.baz", "simple"},
Libraries: LibraryConfigs030{},
},
},
......
......@@ -18,8 +18,9 @@ environments:
k8sVersion: v1.10.3
path: default-path
targets:
- target1
- target2
- /
- foo/bar/baz
- simple
keywords:
- ksonnet
- kubernetes
......
......@@ -27,8 +27,9 @@ environments:
version: 1.2.3
path: default-path
targets:
- target1
- target2
- /
- foo.bar.baz
- simple
keywords:
- ksonnet
- kubernetes
......
......@@ -27,8 +27,9 @@ environments:
version: 1.2.3
path: default-path
targets:
- target1
- target2
- /
- foo.bar.baz
- simple
keywords:
- ksonnet
- kubernetes
......
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