diff --git a/yaml/converter/gitlab/convert.go b/yaml/converter/gitlab/convert.go index 3070f90..608979f 100644 --- a/yaml/converter/gitlab/convert.go +++ b/yaml/converter/gitlab/convert.go @@ -2,11 +2,12 @@ package gitlab import ( "bytes" + "strings" droneyaml "github.com/drone/drone-yaml/yaml" + "github.com/drone/drone-yaml/yaml/compiler/image" "github.com/drone/drone-yaml/yaml/pretty" - "github.com/gosimple/slug" "gopkg.in/yaml.v2" ) @@ -78,7 +79,7 @@ func Convert(b []byte) ([]byte, error) { Entrypoint: step.Entrypoint, } if step.Name == "" { - step.Name = slug.Make(step.Image) + step.Name = serviceSlug(step.Image) } pipeline.Services = append(pipeline.Services, step) } @@ -93,3 +94,9 @@ func Convert(b []byte) ([]byte, error) { pretty.Print(buf, manifest) return buf.Bytes(), nil } + +func serviceSlug(s string) string { + s = image.Trim(s) + s = strings.Replace(s, "/", "__", -1) + return s +} diff --git a/yaml/converter/gitlab/testdata/example1.yml.golden b/yaml/converter/gitlab/testdata/example1.yml.golden index 4308b81..c99f1a5 100644 --- a/yaml/converter/gitlab/testdata/example1.yml.golden +++ b/yaml/converter/gitlab/testdata/example1.yml.golden @@ -14,7 +14,7 @@ steps: - bundle exec rake spec services: -- name: postgres-9-3 +- name: postgres image: postgres:9.3 ...