Skip to content

Commit

Permalink
fixed v0 / v1 yaml for harness ci
Browse files Browse the repository at this point in the history
  • Loading branch information
aman-harness committed Mar 29, 2023
1 parent 97895b9 commit e290f06
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 92 deletions.
21 changes: 17 additions & 4 deletions builder/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,26 @@ package builder
import (
"io/fs"

"github.com/drone/go-convert/convert/harness/downgrader"
spec "github.com/drone/spec/dist/go"
"github.com/ghodss/yaml"
"github.com/wings-software/autogen-go/utils"
)

// Builder builds a pipeline configuration.
type Builder struct {
vendor Vendor
vendor Vendor
version string
}

// New creates a new pipeline builder.
func New(vendor string) *Builder {
func New(vendor, version string) *Builder {
if version == "" {
version = "v1"
}
return &Builder{
vendor: NewVendor(vendor),
vendor: NewVendor(vendor),
version: version,
}
}

Expand Down Expand Up @@ -51,5 +57,12 @@ func (b *Builder) Build(fsys fs.FS) ([]byte, error) {
// never prevent yaml generation.
}

return yaml.Marshal(pipeline)
yml, err := yaml.Marshal(pipeline)
if (b.version == "v1") || (b.version == "default") {
return yml, err
} else {
d := downgrader.New()
v0Yaml, err := d.Downgrade(yml)
return v0Yaml, err
}
}
17 changes: 0 additions & 17 deletions builder/rules/drone.go

This file was deleted.

67 changes: 0 additions & 67 deletions builder/rules/drone/rule_drone.go

This file was deleted.

2 changes: 1 addition & 1 deletion builder/vendor.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ func NewVendor(vendor string) Vendor {
case "harness":
return rules.NewHarness()
default:
return rules.NewDrone()
return rules.NewHarness()
}
}
9 changes: 7 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
module github.com/wings-software/autogen-go

go 1.18
go 1.19

require (
github.com/drone/spec v0.0.0-20230203155728-6f5b316cad3e
github.com/drone/spec v0.0.0-20230328162846-c2bc4a6d62ab
github.com/ghodss/yaml v1.0.0
)

Expand All @@ -13,7 +13,12 @@ require (
github.com/coreos/go-semver v0.3.0 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/drone/drone-go v1.7.1 // indirect
github.com/drone/go-convert v0.0.0-20230329091825-a238380a6b0e // indirect
github.com/google/subcommands v1.2.0 // indirect
github.com/gotidy/ptr v1.4.0 // indirect
github.com/kr/text v0.2.0 // indirect
golang.org/x/text v0.7.0 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
14 changes: 14 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,34 @@ github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4
github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
github.com/drone/drone-go v1.7.1 h1:ZX+3Rs8YHUSUQ5mkuMLmm1zr1ttiiE2YGNxF3AnyDKw=
github.com/drone/drone-go v1.7.1/go.mod h1:fxCf9jAnXDZV1yDr0ckTuWd1intvcQwfJmTRpTZ1mXg=
github.com/drone/go-convert v0.0.0-20230329091825-a238380a6b0e h1:ybfe4Po+BUQjm2BpIZjEpng9fXBYgPvAehNe2edC0lY=
github.com/drone/go-convert v0.0.0-20230329091825-a238380a6b0e/go.mod h1:HamZvO81G2K1g9FeRVliWaN0vEV4AMSfMsINzI2ZbS4=
github.com/drone/spec v0.0.0-20230203155728-6f5b316cad3e h1:9IrlHM84CSV6ui+PnxWRTslm8VJiyvpyd8tIsUVCSKE=
github.com/drone/spec v0.0.0-20230203155728-6f5b316cad3e/go.mod h1:lhM5nV3zKzXnHD2WPLQ2KoJ/65hr3vr0KaiKod2T3W8=
github.com/drone/spec v0.0.0-20230316030012-8fb992844a55 h1:3JssRUXnMnGVSXUni4mkln4TGzvHMgcN4lpviuH35dY=
github.com/drone/spec v0.0.0-20230316030012-8fb992844a55/go.mod h1:pdaL6nOipGF/5L6jAu1DwAeLzmZdaU3+UIvQ1MUIZ9Y=
github.com/drone/spec v0.0.0-20230328162846-c2bc4a6d62ab h1:SCRvpZOFAS/kFo6q0c+oeH+ID0OBDPLpDAx4uHYQwYo=
github.com/drone/spec v0.0.0-20230328162846-c2bc4a6d62ab/go.mod h1:pdaL6nOipGF/5L6jAu1DwAeLzmZdaU3+UIvQ1MUIZ9Y=
github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/subcommands v1.2.0 h1:vWQspBTo2nEqTUFita5/KeEWlUL8kQObDFbub/EN9oE=
github.com/google/subcommands v1.2.0/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk=
github.com/gotidy/ptr v1.4.0 h1:7++suUs+HNHMnyz6/AW3SE+4EnBhupPSQTSI7QNijVc=
github.com/gotidy/ptr v1.4.0/go.mod h1:MjRBG6/IETiiZGWI8LrRtISXEji+8b/jigmj2q0mEyM=
github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI=
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo=
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func main() {

// builds the pipeline configuration based on
// the contents of the virtual filesystem.
builder := builder.New("harness")
builder := builder.New("harness", "v1")
out, err := builder.Build(chroot)
if err != nil {
log.Fatalln(err)
Expand Down

0 comments on commit e290f06

Please sign in to comment.