@@ -22,7 +22,7 @@ import (
22
22
"github.com/bufbuild/connect-go"
23
23
"github.com/compose-spec/compose-go/v2/loader"
24
24
"github.com/compose-spec/compose-go/v2/types"
25
- pb "github.com/defang-io/defang/src/protos/io/defang/v1"
25
+ v1 "github.com/defang-io/defang/src/protos/io/defang/v1"
26
26
"github.com/defang-io/defang/src/protos/io/defang/v1/defangv1connect"
27
27
"github.com/moby/patternmatcher"
28
28
"github.com/moby/patternmatcher/ignorefile"
@@ -80,17 +80,17 @@ func resolveEnv(k string) *string {
80
80
return & v
81
81
}
82
82
83
- func convertPlatform (platform string ) pb .Platform {
83
+ func convertPlatform (platform string ) v1 .Platform {
84
84
switch platform {
85
85
default :
86
86
logrus .Warnf ("Unsupported platform: %q (assuming linux)" , platform )
87
87
fallthrough
88
88
case "" , "linux" :
89
- return pb .Platform_LINUX_ANY
89
+ return v1 .Platform_LINUX_ANY
90
90
case "linux/amd64" :
91
- return pb .Platform_LINUX_AMD64
91
+ return v1 .Platform_LINUX_AMD64
92
92
case "linux/arm64" , "linux/arm64/v8" , "linux/arm64/v7" , "linux/arm64/v6" :
93
- return pb .Platform_LINUX_ARM64
93
+ return v1 .Platform_LINUX_ARM64
94
94
}
95
95
}
96
96
@@ -152,7 +152,7 @@ func getRemoteBuildContext(ctx context.Context, client defangv1connect.FabricCon
152
152
return uploadTarball (ctx , client , buffer , digest )
153
153
}
154
154
155
- func convertPort (port types.ServicePortConfig ) (* pb .Port , error ) {
155
+ func convertPort (port types.ServicePortConfig ) (* v1 .Port , error ) {
156
156
if port .Target < 1 || port .Target > 32767 {
157
157
return nil , fmt .Errorf ("port target must be an integer between 1 and 32767: %v" , port .Target )
158
158
}
@@ -163,7 +163,7 @@ func convertPort(port types.ServicePortConfig) (*pb.Port, error) {
163
163
return nil , fmt .Errorf ("port published must be empty or equal to target: %v" , port .Published )
164
164
}
165
165
166
- pbPort := & pb .Port {
166
+ pbPort := & v1 .Port {
167
167
// Mode string `yaml:",omitempty" json:"mode,omitempty"`
168
168
// HostIP string `mapstructure:"host_ip" yaml:"host_ip,omitempty" json:"host_ip,omitempty"`
169
169
// Published string `yaml:",omitempty" json:"published,omitempty"`
@@ -173,17 +173,17 @@ func convertPort(port types.ServicePortConfig) (*pb.Port, error) {
173
173
174
174
switch port .Protocol {
175
175
case "" :
176
- pbPort .Protocol = pb .Protocol_ANY // defaults to HTTP in CD
176
+ pbPort .Protocol = v1 .Protocol_ANY // defaults to HTTP in CD
177
177
case "tcp" :
178
- pbPort .Protocol = pb .Protocol_TCP
178
+ pbPort .Protocol = v1 .Protocol_TCP
179
179
case "udp" :
180
- pbPort .Protocol = pb .Protocol_UDP
180
+ pbPort .Protocol = v1 .Protocol_UDP
181
181
case "http" : // TODO: not per spec
182
- pbPort .Protocol = pb .Protocol_HTTP
182
+ pbPort .Protocol = v1 .Protocol_HTTP
183
183
case "http2" : // TODO: not per spec
184
- pbPort .Protocol = pb .Protocol_HTTP2
184
+ pbPort .Protocol = v1 .Protocol_HTTP2
185
185
case "grpc" : // TODO: not per spec
186
- pbPort .Protocol = pb .Protocol_GRPC
186
+ pbPort .Protocol = v1 .Protocol_GRPC
187
187
default :
188
188
return nil , fmt .Errorf ("port protocol not one of [tcp udp http http2 grpc]: %v" , port .Protocol )
189
189
}
@@ -195,26 +195,26 @@ func convertPort(port types.ServicePortConfig) (*pb.Port, error) {
195
195
logrus .Warn ("No port mode was specified; assuming 'host' (add 'mode' to silence)" )
196
196
fallthrough
197
197
case "host" :
198
- pbPort .Mode = pb .Mode_HOST
198
+ pbPort .Mode = v1 .Mode_HOST
199
199
case "ingress" :
200
200
// This code is unnecessarily complex because compose-go silently converts short syntax to ingress+tcp
201
201
if port .Published != "" {
202
202
logrus .Warn ("Published ports are not supported in ingress mode; assuming 'host' (add 'mode' to silence)" )
203
203
break
204
204
}
205
- pbPort .Mode = pb .Mode_INGRESS
206
- if pbPort .Protocol == pb .Protocol_TCP || pbPort .Protocol == pb .Protocol_UDP {
205
+ pbPort .Mode = v1 .Mode_INGRESS
206
+ if pbPort .Protocol == v1 .Protocol_TCP || pbPort .Protocol == v1 .Protocol_UDP {
207
207
logrus .Warn ("TCP ingress is not supported; assuming HTTP" )
208
- pbPort .Protocol = pb .Protocol_HTTP
208
+ pbPort .Protocol = v1 .Protocol_HTTP
209
209
}
210
210
default :
211
211
return nil , fmt .Errorf ("port mode not one of [host ingress]: %v" , port .Mode )
212
212
}
213
213
return pbPort , nil
214
214
}
215
215
216
- func convertPorts (ports []types.ServicePortConfig ) ([]* pb .Port , error ) {
217
- var pbports []* pb .Port
216
+ func convertPorts (ports []types.ServicePortConfig ) ([]* v1 .Port , error ) {
217
+ var pbports []* v1 .Port
218
218
for _ , port := range ports {
219
219
pbPort , err := convertPort (port )
220
220
if err != nil {
@@ -227,7 +227,7 @@ func convertPorts(ports []types.ServicePortConfig) ([]*pb.Port, error) {
227
227
228
228
func uploadTarball (ctx context.Context , client defangv1connect.FabricControllerClient , body * bytes.Buffer , digest string ) (string , error ) {
229
229
// Upload the tarball to the fabric controller storage; TODO: use a streaming API
230
- ureq := & pb .UploadURLRequest {Digest : digest }
230
+ ureq := & v1 .UploadURLRequest {Digest : digest }
231
231
res , err := client .CreateUploadURL (ctx , connect .NewRequest (ureq ))
232
232
if err != nil {
233
233
return "" , err
0 commit comments