Skip to content

Commit 7104c3b

Browse files
Merge pull request #182 from drone/fix_enum
fix enum types in go-convert
2 parents 2228eb8 + a93a128 commit 7104c3b

File tree

7 files changed

+29
-25
lines changed

7 files changed

+29
-25
lines changed

convert/circle/util.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -233,35 +233,35 @@ func convertPlatform(job *circle.Job, config *circle.Config) *harness.Platform {
233233
}
234234
if executor.Windows != nil {
235235
return &harness.Platform{
236-
Os: harness.OSWindows,
237-
Arch: harness.ArchAmd64,
236+
Os: harness.OSWindows.String(),
237+
Arch: harness.ArchAmd64.String(),
238238
}
239239
}
240240
if executor.Machine != nil {
241241
if strings.Contains(executor.Machine.Image, "win") ||
242242
strings.Contains(executor.ResourceClass, "win") {
243243
return &harness.Platform{
244-
Os: harness.OSWindows,
245-
Arch: harness.ArchAmd64,
244+
Os: harness.OSWindows.String(),
245+
Arch: harness.ArchAmd64.String(),
246246
}
247247
}
248248
if strings.Contains(executor.Machine.Image, "arm") ||
249249
strings.Contains(executor.ResourceClass, "arm") {
250250
return &harness.Platform{
251-
Os: harness.OSLinux,
252-
Arch: harness.ArchArm64,
251+
Os: harness.OSLinux.String(),
252+
Arch: harness.ArchArm64.String(),
253253
}
254254
}
255255
}
256256
if executor.Macos != nil {
257257
return &harness.Platform{
258-
Os: harness.OSMacos,
259-
Arch: harness.ArchArm64,
258+
Os: harness.OSMacos.String(),
259+
Arch: harness.ArchArm64.String(),
260260
}
261261
}
262262
return &harness.Platform{
263-
Os: harness.OSLinux,
264-
Arch: harness.ArchAmd64,
263+
Os: harness.OSLinux.String(),
264+
Arch: harness.ArchAmd64.String(),
265265
}
266266
}
267267

convert/cloudbuild/convert.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,8 @@ func (d *Converter) convert(src *cloudbuild.Config) ([]byte, error) {
137137
Cache: nil, // No Google equivalent
138138
Envs: nil,
139139
Platform: &harness.Platform{
140-
Os: harness.OSLinux,
141-
Arch: harness.ArchAmd64,
140+
Os: harness.OSLinux.String(),
141+
Arch: harness.ArchAmd64.String(),
142142
},
143143
Runtime: d.convertRuntime(src),
144144
Steps: d.convertSteps(src),

convert/drone/convert.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -686,17 +686,17 @@ func convertPlatform(src v1.Platform) *v2.Platform {
686686
dst := new(v2.Platform)
687687
switch src.OS {
688688
case "windows", "win", "win32":
689-
dst.Os = v2.OSWindows
689+
dst.Os = v2.OSWindows.String()
690690
case "darwin", "macos", "mac":
691-
dst.Os = v2.OSDarwin
691+
dst.Os = v2.OSDarwin.String()
692692
default:
693-
dst.Os = v2.OSLinux
693+
dst.Os = v2.OSLinux.String()
694694
}
695695
switch src.Arch {
696696
case "arm", "arm64":
697-
dst.Arch = v2.ArchArm64
697+
dst.Arch = v2.ArchArm64.String()
698698
default:
699-
dst.Arch = v2.ArchAmd64
699+
dst.Arch = v2.ArchAmd64.String()
700700
}
701701
return dst
702702
}

convert/github/convert.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -309,13 +309,13 @@ func convertRunsOn(src string) *harness.Platform {
309309
dst := new(harness.Platform)
310310
switch {
311311
case strings.Contains(src, "windows"), strings.Contains(src, "win"):
312-
dst.Os = harness.OSWindows
312+
dst.Os = harness.OSWindows.String()
313313
case strings.Contains(src, "darwin"), strings.Contains(src, "macos"), strings.Contains(src, "mac"):
314-
dst.Os = harness.OSDarwin
314+
dst.Os = harness.OSDarwin.String()
315315
default:
316-
dst.Os = harness.OSLinux
316+
dst.Os = harness.OSLinux.String()
317317
}
318-
dst.Arch = harness.ArchAmd64 // we assume amd64 for now
318+
dst.Arch = harness.ArchAmd64.String() // we assume amd64 for now
319319
return dst
320320
}
321321

convert/harness/downgrader/downgrade.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,7 @@ func convertPlatform(platform *v1.Platform, runtime *v0.Runtime) *v0.Platform {
714714
var os, arch string
715715

716716
// convert the OS name
717-
switch platform.Os.String() {
717+
switch platform.Os {
718718
case "linux":
719719
os = "Linux"
720720
case "windows":
@@ -726,7 +726,7 @@ func convertPlatform(platform *v1.Platform, runtime *v0.Runtime) *v0.Platform {
726726
}
727727

728728
// convert the Arch name
729-
switch platform.Arch.String() {
729+
switch platform.Arch {
730730
case "amd64":
731731
arch = "Amd64"
732732
case "arm", "arm64":

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ require (
77
github.com/bmatcuk/doublestar v1.3.4
88
github.com/buildkite/yaml v2.1.0+incompatible
99
github.com/docker/go-units v0.4.0
10-
github.com/drone/spec v0.0.0-20230911203429-f7f1b5e9aa40
10+
github.com/drone/spec v0.0.0-20230919004456-7455b8913ff5
1111
github.com/ghodss/yaml v1.0.0
1212
github.com/google/go-cmp v0.5.9
1313
github.com/google/subcommands v1.2.0
1414
github.com/gotidy/ptr v1.4.0
15-
golang.org/x/text v0.7.0
15+
golang.org/x/text v0.13.0
1616
gopkg.in/yaml.v3 v3.0.1
1717
)
1818

go.sum

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ github.com/docker/go-units v0.4.0 h1:3uh0PgVws3nIA0Q+MwDC8yjEPf9zjRfZZWXZYDct3Tw
88
github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
99
github.com/drone/spec v0.0.0-20230911203429-f7f1b5e9aa40 h1:XTADVN1LXkDk+TJc0WQr3ohWu94/NSP4FoIo50gwxIw=
1010
github.com/drone/spec v0.0.0-20230911203429-f7f1b5e9aa40/go.mod h1:pdaL6nOipGF/5L6jAu1DwAeLzmZdaU3+UIvQ1MUIZ9Y=
11+
github.com/drone/spec v0.0.0-20230919004456-7455b8913ff5 h1:NgAseJNQpJE3XtgJUPu4x7x5fcBjqZ3oKHDJfwBYdWk=
12+
github.com/drone/spec v0.0.0-20230919004456-7455b8913ff5/go.mod h1:KyQZA9qwuscbbM7yTrtZg25Wammoc5GKwaRem8kDA5k=
1113
github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk=
1214
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
1315
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
@@ -18,6 +20,8 @@ github.com/gotidy/ptr v1.4.0 h1:7++suUs+HNHMnyz6/AW3SE+4EnBhupPSQTSI7QNijVc=
1820
github.com/gotidy/ptr v1.4.0/go.mod h1:MjRBG6/IETiiZGWI8LrRtISXEji+8b/jigmj2q0mEyM=
1921
golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo=
2022
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
23+
golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=
24+
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
2125
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
2226
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
2327
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=

0 commit comments

Comments
 (0)