Skip to content

Commit c4a81fa

Browse files
kt5356lionello
andauthored
DigitalOcean support (#594)
Initial DigitalOcean support! Basic up/down working. --------- Co-authored-by: Lionello Lunesu <[email protected]> Co-authored-by: Lio李歐 <[email protected]>
1 parent 76dcb49 commit c4a81fa

File tree

24 files changed

+1064
-223
lines changed

24 files changed

+1064
-223
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ The Defang CLI recognizes the following environment variables:
111111
- `DEFANG_FABRIC` - The address of the Defang Fabric to use; defaults to `fabric-prod1.defang.dev`
112112
- `DEFANG_HIDE_HINTS` - If set to `true`, hides hints in the CLI output; defaults to `false`
113113
- `DEFANG_HIDE_UPDATE` - If set to `true`, hides the update notification; defaults to `false`
114-
- `DEFANG_PROVIDER` - The name of the cloud provider to use, `auto` (default), `aws`, or `defang`
114+
- `DEFANG_PREFIX` - The prefix to use for all BYOC resources; defaults to `Defang`
115+
- `DEFANG_PROVIDER` - The name of the cloud provider to use, `auto` (default), `aws`, `digitalocean`, or `defang`
115116
- `NO_COLOR` - If set to any value, disables color output; by default, color output is enabled depending on the terminal
116117
- `TZ` - The timezone to use for log timestamps: an IANA TZ name like `UTC` or `Europe/Amsterdam`; defaults to `Local`
117118
- `XDG_STATE_HOME` - The directory to use for storing state; defaults to `~/.local/state`

pkgs/defang/cli.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ buildGoModule {
66
pname = "defang-cli";
77
version = "git";
88
src = ../../src;
9-
vendorHash = "sha256-ZV9m9uRrJyP7LjrrpsZz9LK+IJZ+1YQSLmtiin3FYl4=";
9+
vendorHash = "sha256-4+1Z498ynOullCSKPUbaByV6K7o7WooxNDL9IQsCh2s=";
1010

1111
subPackages = [ "cmd/cli" ];
1212

pkgs/npm/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ The Defang CLI recognizes the following environment variables:
3131
- `DEFANG_FABRIC` - The address of the Defang Fabric to use; defaults to `fabric-prod1.defang.dev`
3232
- `DEFANG_HIDE_HINTS` - If set to `true`, hides hints in the CLI output; defaults to `false`
3333
- `DEFANG_HIDE_UPDATE` - If set to `true`, hides the update notification; defaults to `false`
34-
- `DEFANG_PROVIDER` - The name of the cloud provider to use, `auto` (default), `aws`, or `defang`
34+
- `DEFANG_PROVIDER` - The name of the cloud provider to use, `auto` (default), `aws`, `digitalocean`, or `defang`
3535
- `NO_COLOR` - If set to any value, disables color output; by default, color output is enabled depending on the terminal
3636
- `TZ` - The timezone to use for log timestamps: an IANA TZ name like `UTC` or `Europe/Amsterdam`; defaults to `Local`
3737
- `XDG_STATE_HOME` - The directory to use for storing state; defaults to `~/.local/state`

src/cmd/cli/command/commands.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,10 @@ func Execute(ctx context.Context) error {
133133

134134
func SetupCommands(version string) {
135135
RootCmd.Version = version
136-
RootCmd.PersistentFlags().Var(&colorMode, "color", `colorize output; one of [always never]`)
136+
RootCmd.PersistentFlags().Var(&colorMode, "color", fmt.Sprintf(`colorize output; one of %v`, allColorModes))
137137
RootCmd.PersistentFlags().StringVarP(&cluster, "cluster", "s", cli.DefangFabric, "Defang cluster to connect to")
138138
RootCmd.PersistentFlags().MarkHidden("cluster")
139-
RootCmd.PersistentFlags().VarP(&provider, "provider", "P", `cloud provider to use for bring-your-own-cloud; one of [defang aws]`)
139+
RootCmd.PersistentFlags().VarP(&provider, "provider", "P", fmt.Sprintf(`bring-your-own-cloud provider; one of %v`, cliClient.AllProviders()))
140140
RootCmd.PersistentFlags().BoolVarP(&cli.DoVerbose, "verbose", "v", false, "verbose logging") // backwards compat: only used by tail
141141
RootCmd.PersistentFlags().BoolVar(&doDebug, "debug", pkg.GetenvBool("DEFANG_DEBUG"), "debug logging for troubleshooting the CLI")
142142
RootCmd.PersistentFlags().BoolVar(&cli.DoDryRun, "dry-run", false, "dry run (don't actually change anything)")
@@ -298,7 +298,7 @@ var RootCmd = &cobra.Command{
298298
if awsInEnv() {
299299
term.Warn("Using Defang playground, but AWS environment variables were detected; did you forget --provider=aws or DEFANG_PROVIDER=aws?")
300300
} else if doInEnv() {
301-
term.Warn("Using Defang playground, but DO_PAT environment variable was detected; did you forget --provider=digitalocean or DEFANG_PROVIDER=digitalocean?")
301+
term.Warn("Using Defang playground, but DIGITALOCEAN_TOKEN environment variable was detected; did you forget --provider=digitalocean or DEFANG_PROVIDER=digitalocean?")
302302
}
303303
provider = cliClient.ProviderDefang
304304
case cliClient.ProviderAWS:
@@ -307,7 +307,7 @@ var RootCmd = &cobra.Command{
307307
}
308308
case cliClient.ProviderDO:
309309
if !doInEnv() {
310-
term.Warn("DigitalOcean provider was selected, but DO_PAT environment variable is not set")
310+
term.Warn("DigitalOcean provider was selected, but DIGITALOCEAN_TOKEN environment variable is not set")
311311
}
312312
case cliClient.ProviderDefang:
313313
// Ignore any env vars when explicitly using the Defang playground provider
@@ -1007,5 +1007,5 @@ func awsInEnv() bool {
10071007
}
10081008

10091009
func doInEnv() bool {
1010-
return os.Getenv("DO_PAT") != ""
1010+
return os.Getenv("DIGITALOCEAN_ACCESS_TOKEN") != "" || os.Getenv("DIGITALOCEAN_TOKEN") != ""
10111011
}

src/go.mod

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ module github.com/DefangLabs/defang/src
22

33
go 1.21
44

5+
toolchain go1.21.10
6+
57
require (
68
github.com/AlecAivazis/survey/v2 v2.3.7
79
github.com/aws/aws-sdk-go-v2 v1.27.0
@@ -18,15 +20,16 @@ require (
1820
github.com/awslabs/goformation/v7 v7.13.1
1921
github.com/bufbuild/connect-go v1.10.0
2022
github.com/compose-spec/compose-go/v2 v2.1.4
21-
github.com/digitalocean/godo v1.111.0
23+
github.com/digitalocean/godo v1.118.0
2224
github.com/docker/docker v25.0.6+incompatible
2325
github.com/google/uuid v1.6.0
26+
github.com/gorilla/websocket v1.5.0
2427
github.com/hashicorp/go-retryablehttp v0.7.7
2528
github.com/hexops/gotextdiff v1.0.3
2629
github.com/miekg/dns v1.1.59
2730
github.com/moby/patternmatcher v0.6.0
2831
github.com/muesli/termenv v0.15.2
29-
github.com/opencontainers/image-spec v1.0.2
32+
github.com/opencontainers/image-spec v1.1.0-rc3
3033
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c
3134
github.com/ross96D/cancelreader v0.2.6
3235
github.com/sirupsen/logrus v1.9.3
@@ -35,22 +38,27 @@ require (
3538
golang.org/x/mod v0.16.0
3639
golang.org/x/oauth2 v0.19.0
3740
golang.org/x/sys v0.20.0
38-
golang.org/x/term v0.18.0
41+
golang.org/x/term v0.19.0
3942
google.golang.org/protobuf v1.33.0
4043
gopkg.in/yaml.v3 v3.0.1
4144
)
4245

4346
require (
4447
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
4548
github.com/cpuguy83/go-md2man/v2 v2.0.3 // indirect
49+
github.com/creack/pty v1.1.21 // indirect
50+
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
4651
github.com/go-viper/mapstructure/v2 v2.0.0 // indirect
52+
github.com/golang/protobuf v1.5.4 // indirect
4753
github.com/google/go-querystring v1.1.0 // indirect
4854
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
4955
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
5056
github.com/mattn/go-runewidth v0.0.14 // indirect
51-
github.com/rivo/uniseg v0.2.0 // indirect
57+
github.com/morikuni/aec v1.0.0 // indirect
58+
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
59+
github.com/rivo/uniseg v0.4.2 // indirect
5260
github.com/russross/blackfriday/v2 v2.1.0 // indirect
53-
golang.org/x/net v0.22.0 // indirect
61+
golang.org/x/net v0.24.0 // indirect
5462
gopkg.in/yaml.v2 v2.4.0 // indirect
5563
)
5664

@@ -70,7 +78,6 @@ require (
7078
github.com/aws/aws-sdk-go-v2/service/sso v1.18.7 // indirect
7179
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.21.7 // indirect
7280
github.com/containerd/log v0.1.0 // indirect
73-
github.com/creack/pty v1.1.18 // indirect
7481
github.com/distribution/reference v0.5.0 // indirect
7582
github.com/docker/go-connections v0.5.0 // indirect
7683
github.com/docker/go-units v0.5.0 // indirect
@@ -87,7 +94,6 @@ require (
8794
github.com/mattn/go-shellwords v1.0.12 // indirect
8895
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect
8996
github.com/moby/term v0.5.0 // indirect
90-
github.com/morikuni/aec v1.0.0 // indirect
9197
github.com/opencontainers/go-digest v1.0.0 // indirect
9298
github.com/pkg/errors v0.9.1 // indirect
9399
github.com/rogpeppe/go-internal v1.11.0 // indirect

src/go.sum

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,14 @@ github.com/cpuguy83/go-md2man/v2 v2.0.3 h1:qMCsGGgs+MAzDFyp9LpAe1Lqy/fY/qCovCm0q
7070
github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
7171
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
7272
github.com/creack/pty v1.1.17/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4=
73-
github.com/creack/pty v1.1.18 h1:n56/Zwd5o6whRC5PMGretI4IdRLlmBXYNjScPaBgsbY=
74-
github.com/creack/pty v1.1.18/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4=
73+
github.com/creack/pty v1.1.21 h1:1/QdRyBaHHJP61QkWMXlOIBfsgdDeeKfK8SYVUWJKf0=
74+
github.com/creack/pty v1.1.21/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4=
7575
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
76-
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
7776
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
78-
github.com/digitalocean/godo v1.111.0 h1:nBXi9LtykvQiwZjMbljrwr17HwABSBY8ZE872dm2DzI=
79-
github.com/digitalocean/godo v1.111.0/go.mod h1:R6EmmWI8CT1+fCtjWY9UCB+L5uufuZH13wk3YhxycCs=
77+
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
78+
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
79+
github.com/digitalocean/godo v1.118.0 h1:lkzGFQmACrVCp7UqH1sAi4JK/PWwlc5aaxubgorKmC4=
80+
github.com/digitalocean/godo v1.118.0/go.mod h1:Vk0vpCot2HOAJwc5WE8wljZGtJ3ZtWIc8MQ8rF38sdo=
8081
github.com/distribution/reference v0.5.0 h1:/FUIFXtfc/x2gpa5/VGfiGLuOIdYa1t65IKK2OFGvA0=
8182
github.com/distribution/reference v0.5.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E=
8283
github.com/docker/docker v25.0.6+incompatible h1:5cPwbwriIcsua2REJe8HqQV+6WlWc1byg2QSXzBxBGg=
@@ -100,8 +101,8 @@ github.com/go-viper/mapstructure/v2 v2.0.0 h1:dhn8MZ1gZ0mzeodTG3jt5Vj/o87xZKuNAp
100101
github.com/go-viper/mapstructure/v2 v2.0.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM=
101102
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
102103
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
103-
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
104-
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
104+
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
105+
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
105106
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
106107
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
107108
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
@@ -111,6 +112,8 @@ github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38 h1:yAJXTCF9TqKcTiHJAE
111112
github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
112113
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
113114
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
115+
github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc=
116+
github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
114117
github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0 h1:YBftPWNWd4WwGqtY2yeZL2ef8rHAxPBD8KFhJpmcqms=
115118
github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0/go.mod h1:YN5jB8ie0yfIUg6VvR9Kz84aCaG7AsGZnLjhHbUqwPg=
116119
github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ=
@@ -172,17 +175,19 @@ github.com/onsi/gomega v1.30.0 h1:hvMK7xYz4D3HapigLTeGdId/NcfQx1VHMJc60ew99+8=
172175
github.com/onsi/gomega v1.30.0/go.mod h1:9sxs+SwGrKI0+PWe4Fxa9tFQQBG5xSsSbMXOI8PPpoQ=
173176
github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=
174177
github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=
175-
github.com/opencontainers/image-spec v1.0.2 h1:9yCKha/T5XdGtO0q9Q9a6T5NUCsTn/DrBg0D7ufOcFM=
176-
github.com/opencontainers/image-spec v1.0.2/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0=
178+
github.com/opencontainers/image-spec v1.1.0-rc3 h1:fzg1mXZFj8YdPeNkRXMg+zb88BFV0Ys52cJydRwBkb8=
179+
github.com/opencontainers/image-spec v1.1.0-rc3/go.mod h1:X4pATf0uXsnn3g5aiGIsVnJBR4mxhKzfwmvK/B2NTm8=
177180
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ=
178181
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU=
179182
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
180183
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
181184
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
182-
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
183185
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
184-
github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
186+
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
187+
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
185188
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
189+
github.com/rivo/uniseg v0.4.2 h1:YwD0ulJSJytLpiaWua0sBDusfsCZohxjxzVTYjwxfV8=
190+
github.com/rivo/uniseg v0.4.2/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
186191
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
187192
github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M=
188193
github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA=
@@ -245,8 +250,8 @@ golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLL
245250
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
246251
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
247252
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
248-
golang.org/x/net v0.22.0 h1:9sGLhx7iRIHEiX0oAJ3MRZMUCElJgy7Br1nO+AMN3Tc=
249-
golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg=
253+
golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w=
254+
golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8=
250255
golang.org/x/oauth2 v0.19.0 h1:9+E/EZBCbTLNrbN35fHv/a/d/mOBatymz1zbtQrXpIg=
251256
golang.org/x/oauth2 v0.19.0/go.mod h1:vYi7skDa1x015PmRRYZ7+s1cWyPgrPiSYRe4rnsexc8=
252257
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
@@ -271,8 +276,8 @@ golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y=
271276
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
272277
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
273278
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
274-
golang.org/x/term v0.18.0 h1:FcHjZXDMxI8mM3nwhX9HlKop4C0YQvCVCdwYl2wOtE8=
275-
golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58=
279+
golang.org/x/term v0.19.0 h1:+ThwsDv+tYfnJFhF4L8jITxu1tdTWRTZpdsWgEgjL6Q=
280+
golang.org/x/term v0.19.0/go.mod h1:2CuTdWZ7KHSQwUzKva0cbMg6q2DMI3Mmxp+gKJbskEk=
276281
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
277282
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
278283
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=

src/pkg/cli/client/byoc/aws/byoc.go

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ import (
3636
"google.golang.org/protobuf/proto"
3737
)
3838

39+
var (
40+
// Changing this will cause issues if two clients with different versions are using the same account
41+
CdImage = pkg.Getenv("DEFANG_CD_IMAGE", "public.ecr.aws/defang-io/cd:"+byoc.CdImageTag)
42+
)
43+
3944
type ByocAws struct {
4045
*byoc.ByocBaseClient
4146

@@ -73,12 +78,12 @@ func (b *ByocAws) setUp(ctx context.Context) error {
7378
VolumesFrom: []string{
7479
cdTaskName,
7580
},
76-
WorkDir: ptr.String("/app"),
81+
WorkDir: "/app",
7782
DependsOn: map[string]types.ContainerCondition{cdTaskName: "START"},
7883
EntryPoint: []string{"node", "lib/index.js"},
7984
},
8085
{
81-
Image: byoc.CdImage,
86+
Image: CdImage,
8287
Name: cdTaskName,
8388
Essential: ptr.Bool(false),
8489
Volumes: []types.TaskVolume{
@@ -159,22 +164,21 @@ func (b *ByocAws) Deploy(ctx context.Context, req *defangv1.DeployRequest) (*def
159164
payloadString = base64.StdEncoding.EncodeToString(data)
160165
// TODO: consider making this a proper Data URL: "data:application/protobuf;base64,abcd…"
161166
} else {
162-
url, err := b.driver.CreateUploadURL(ctx, etag)
167+
payloadUrl, err := b.driver.CreateUploadURL(ctx, etag)
163168
if err != nil {
164169
return nil, err
165170
}
166171

167172
// Do an HTTP PUT to the generated URL
168-
resp, err := http.Put(ctx, url, "application/protobuf", bytes.NewReader(data))
173+
resp, err := http.Put(ctx, payloadUrl, "application/protobuf", bytes.NewReader(data))
169174
if err != nil {
170175
return nil, err
171176
}
172177
defer resp.Body.Close()
173178
if resp.StatusCode != 200 {
174179
return nil, fmt.Errorf("unexpected status code during upload: %s", resp.Status)
175180
}
176-
payloadString = http.RemoveQueryParam(url)
177-
// FIXME: this code path didn't work
181+
payloadString = http.RemoveQueryParam(payloadUrl)
178182
}
179183

180184
if b.ShouldDelegateSubdomain {
@@ -291,7 +295,7 @@ func (b *ByocAws) WhoAmI(ctx context.Context) (*defangv1.WhoAmIResponse, error)
291295
}
292296

293297
func (*ByocAws) GetVersions(context.Context) (*defangv1.Version, error) {
294-
cdVersion := byoc.CdImage[strings.LastIndex(byoc.CdImage, ":")+1:]
298+
cdVersion := CdImage[strings.LastIndex(CdImage, ":")+1:]
295299
return &defangv1.Version{Fabric: cdVersion}, nil
296300
}
297301

src/pkg/cli/client/byoc/baseclient.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ import (
1515
)
1616

1717
const (
18+
// Changing this will cause issues if two clients with different versions are using the same account
19+
CdImageTag = "public-beta"
1820
CdTaskPrefix = "defang-cd" // WARNING: renaming this practically deletes the Pulumi state
19-
DefangPrefix = "Defang" // prefix for all resources created by Defang
2021
)
2122

2223
var (
23-
// Changing this will cause issues if two clients with different versions are using the same account
24-
CdImage = pkg.Getenv("DEFANG_CD_IMAGE", "public.ecr.aws/defang-io/cd:public-beta")
24+
DefangPrefix = pkg.Getenv("DEFANG_PREFIX", "Defang") // prefix for all resources created by Defang
2525
)
2626

2727
// This function was copied from Fabric controller and slightly modified to work with BYOC
@@ -85,8 +85,7 @@ func (b *ByocBaseClient) Debug(context.Context, *defangv1.DebugRequest) (*defang
8585
}
8686

8787
func (b *ByocBaseClient) GetVersions(context.Context) (*defangv1.Version, error) {
88-
cdVersion := CdImage[strings.LastIndex(CdImage, ":")+1:]
89-
return &defangv1.Version{Fabric: cdVersion}, nil
88+
return &defangv1.Version{Fabric: CdImageTag}, nil
9089
}
9190

9291
func (b *ByocBaseClient) LoadProject(ctx context.Context) (*compose.Project, error) {

0 commit comments

Comments
 (0)