Skip to content

Commit 9831cf7

Browse files
Use slug.Make
1 parent ef12b1d commit 9831cf7

File tree

3 files changed

+8
-17
lines changed

3 files changed

+8
-17
lines changed

go.mod

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ require (
2828

2929
require (
3030
github.com/concourse/concourse v1.6.1-0.20240109225805-4c9be50ffbcb
31+
github.com/gosimple/slug v1.15.0
3132
github.com/sirupsen/logrus v1.9.3
3233
gopkg.in/yaml.v3 v3.0.1
3334
)
@@ -39,6 +40,7 @@ require (
3940
github.com/charlievieth/fs v0.0.3 // indirect
4041
github.com/davecgh/go-spew v1.1.1 // indirect
4142
github.com/google/go-cmp v0.7.0 // indirect
43+
github.com/gosimple/unidecode v1.0.1 // indirect
4244
github.com/hashicorp/go-multierror v1.1.1 // indirect
4345
github.com/inconshreveable/mousetrap v1.1.0 // indirect
4446
github.com/jessevdk/go-flags v1.6.1 // indirect

go.sum

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ github.com/gookit/color v1.5.4 h1:FZmqs7XOyGgCAxmWyPslpiok1k05wmY3SJTytgvYFs0=
4040
github.com/gookit/color v1.5.4/go.mod h1:pZJOeOS8DM43rXbp4AZo1n9zCU2qjpcRko0b6/QJi9w=
4141
github.com/gorhill/cronexpr v0.0.0-20180427100037-88b0669f7d75 h1:f0n1xnMSmBLzVfsMMvriDyA75NB/oBgILX2GcHXIQzY=
4242
github.com/gorhill/cronexpr v0.0.0-20180427100037-88b0669f7d75/go.mod h1:g2644b03hfBX9Ov0ZBDgXXens4rxSxmqFBbhvKv2yVA=
43+
github.com/gosimple/slug v1.15.0 h1:wRZHsRrRcs6b0XnxMUBM6WK1U1Vg5B0R7VkIf1Xzobo=
44+
github.com/gosimple/slug v1.15.0/go.mod h1:UiRaFH+GEilHstLUmcBgWcI42viBN7mAb818JrYOeFQ=
45+
github.com/gosimple/unidecode v1.0.1 h1:hZzFTMMqSswvf0LBJZCZgThIZrpDHFXux9KeGmn6T/o=
46+
github.com/gosimple/unidecode v1.0.1/go.mod h1:CP0Cr1Y1kogOtx0bJblKzsVWrqYaqfNOnHzpgWw4Awc=
4347
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
4448
github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I=
4549
github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=

renderers/actions/run.go

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@ package actions
22

33
import (
44
"fmt"
5+
"github.com/gosimple/slug"
56
"github.com/springernature/halfpipe/manifest"
67
"strings"
78
)
89

910
func (a *Actions) runSteps(task manifest.Run) (steps Steps) {
1011
run := Step{
1112
Name: task.GetName(),
12-
ID: normaliseForID(task.GetName()),
13+
ID: slug.Make(task.GetName()),
1314
Env: Env(task.Vars),
1415
}
1516

@@ -42,19 +43,3 @@ func (a *Actions) runSteps(task manifest.Run) (steps Steps) {
4243
}
4344
return steps
4445
}
45-
46-
func normaliseForID(name string) string {
47-
r := strings.NewReplacer(
48-
" ", "-",
49-
"_", "-",
50-
",", "-",
51-
".", "-",
52-
"/", "-",
53-
"\\", "-",
54-
"\"", "-",
55-
"(", "-",
56-
")", "-",
57-
)
58-
before, _ := strings.CutSuffix(strings.ReplaceAll(r.Replace(strings.ToLower(name)), "--", "-"), "-")
59-
return before
60-
}

0 commit comments

Comments
 (0)