66 "context"
77 "fmt"
88 "path"
9+ "runtime"
910 "strings"
1011
1112 "dagger/protoc-gen-go-grpc/internal/dagger"
@@ -17,29 +18,43 @@ type ProtocGenGoGRPC struct {
1718}
1819
1920func New (
20- // Custom image to use to run protoc.
21- // +optional
22- // renovate image: datasource=docker depName=golang versioning=docker
23- // +default="golang:1.24.5-bookworm"
21+ ctx context.Context ,
22+ // Custom image to use to run protoc.
23+ // +optional
24+ // renovate image: datasource=docker depName=golang versioning=docker
25+ // +default="golang:1.24.5-bookworm"
2426 goImage string ,
25- // +optional
26- // renovate: datasource=github-tags depName=protocolbuffers/protobuf versioning="regex:^v?(?<major>\\d+)\\.(?<minor>\\d+)$"
27- // +default="v30.2 "
27+ // +optional
28+ // renovate: datasource=github-tags depName=protocolbuffers/protobuf versioning="regex:^v?(?<major>\\d+)\\.(?<minor>\\d+)$"
29+ // +default="v32.1 "
2830 protobufVersion string ,
29- // +optional
30- // renovate: datasource=go depName=google.golang.org/protobuf/cmd/protoc-gen-go versioning=semver
31- // +default="v1.36.6"
31+ // +optional
32+ // renovate: datasource=go depName=google.golang.org/protobuf/cmd/protoc-gen-go versioning=semver
33+ // +default="v1.36.6"
3234 protocGenGoVersion string ,
33- // +optional
34- // renovate: datasource=go depName=google.golang.org/grpc/cmd/protoc-gen-go-grpc versioning=semver
35- // +default="v1.5.1"
35+ // +optional
36+ // renovate: datasource=go depName=google.golang.org/grpc/cmd/protoc-gen-go-grpc versioning=semver
37+ // +default="v1.5.1"
3638 protocGenGoGRPCVersion string ,
37- ) * ProtocGenGoGRPC {
38- protobufRelURL := fmt .Sprintf ("https://github.com/protocolbuffers/protobuf/releases/download/%v/protoc-%v-linux-x86_64.zip" ,
39- protobufVersion , strings .TrimPrefix (protobufVersion , "v" ))
40-
39+ ) (* ProtocGenGoGRPC , error ) {
40+ architecturesMap := map [string ]string {
41+ "arm64" : "aarch_64" ,
42+ "amd64" : "x86_64" ,
43+ "ppc" : "ppcle_64" ,
44+ "s390x" : "s390_64" ,
45+ }
4146 protobuf := dag .Container ().
42- From (goImage ).
47+ From (goImage )
48+
49+ architecture := runtime .GOARCH
50+ if remappedArchitecture , ok := architecturesMap [architecture ]; ok {
51+ architecture = remappedArchitecture
52+ }
53+
54+ protobufRelURL := fmt .Sprintf ("https://github.com/protocolbuffers/protobuf/releases/download/%v/protoc-%v-linux-%v.zip" ,
55+ protobufVersion , strings .TrimPrefix (protobufVersion , "v" ), architecture )
56+
57+ protobuf = protobuf .
4358 WithExec ([]string {"apt" , "update" }).
4459 WithExec ([]string {"apt" , "install" , "-y" , "unzip" }).
4560 WithExec ([]string {"curl" , "-LO" , protobufRelURL }).
@@ -54,7 +69,7 @@ func New(
5469
5570 return & ProtocGenGoGRPC {
5671 Ctr : protobuf ,
57- }
72+ }, nil
5873}
5974
6075// Container get the current container
0 commit comments