Skip to content

Commit ec1fa74

Browse files
remove obsolete command fixup from compose generation (#1396)
1 parent 5f1b395 commit ec1fa74

File tree

2 files changed

+0
-97
lines changed

2 files changed

+0
-97
lines changed

src/pkg/migrate/migrate.go

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
"slices"
1010
"strings"
1111

12-
"al.essio.dev/pkg/shellescape"
1312
"github.com/DefangLabs/defang/src/pkg/cli/client"
1413
"github.com/DefangLabs/defang/src/pkg/cli/compose"
1514
"github.com/DefangLabs/defang/src/pkg/surveyor"
@@ -233,50 +232,6 @@ func cleanupComposeFile(in string) (string, error) {
233232
})
234233
}
235234
}
236-
237-
// railpack generates images with `Entrypoint: "bash -c"`, and
238-
// compose-go normalizes string commands into arrays, for example:
239-
// `command: npm start` -> `command: [ "npm", "start" ]`. As a
240-
// result, the command which ultimately gets run is
241-
// `bash -c npm start`. When this gets run, `bash` will ignore
242-
// `start` and `npm` will get run in a subprocess--only printing
243-
// the help text. As it is common for users to type their service
244-
// command as a string, this cleanup step will help ensure the
245-
// command is run as intended by replacing `command: npm start`
246-
// with `command: [ "npm start" ]`.
247-
if kk.Value == "command" {
248-
if vk.Kind == yaml.ScalarNode {
249-
cmd := vk.Value
250-
vk.Value = ""
251-
vk.Kind = yaml.SequenceNode
252-
vk.Tag = "!!seq"
253-
vk.Content = []*yaml.Node{
254-
{
255-
Tag: "!!str",
256-
Kind: yaml.ScalarNode,
257-
Value: cmd,
258-
},
259-
}
260-
}
261-
// We will do the same for
262-
// `command: ["npm", "start"]`, which will also get transformed
263-
// to `command: [ "npm start" ]`.
264-
if vk.Kind == yaml.SequenceNode && len(vk.Content) > 1 {
265-
var parts []string
266-
for _, c := range vk.Content {
267-
parts = append(parts, c.Value)
268-
}
269-
cmd := shellescape.QuoteCommand(parts)
270-
// combine content nodes into one
271-
vk.Content = []*yaml.Node{
272-
{
273-
Tag: "!!str",
274-
Kind: yaml.ScalarNode,
275-
Value: cmd,
276-
},
277-
}
278-
}
279-
}
280235
}
281236
}
282237
}

src/pkg/migrate/migrate_test.go

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -469,58 +469,6 @@ services:
469469
db:
470470
image: postgres:latest # EOL comment
471471
x-defang-postgres: "true"
472-
`,
473-
expectingError: false,
474-
},
475-
{
476-
name: "string command",
477-
input: `
478-
services:
479-
web:
480-
build: .
481-
command: npm start
482-
`,
483-
expected: `services:
484-
web:
485-
build: .
486-
command:
487-
- npm start
488-
`,
489-
expectingError: false,
490-
},
491-
{
492-
name: "array command",
493-
input: `
494-
services:
495-
web:
496-
build: .
497-
command:
498-
- npm
499-
- start
500-
`,
501-
expected: `services:
502-
web:
503-
build: .
504-
command:
505-
- npm start
506-
`,
507-
expectingError: false,
508-
},
509-
{
510-
name: "array command with multiple words",
511-
input: `
512-
services:
513-
web:
514-
build: .
515-
command:
516-
- echo
517-
- hello world
518-
`,
519-
expected: `services:
520-
web:
521-
build: .
522-
command:
523-
- echo 'hello world'
524472
`,
525473
expectingError: false,
526474
},

0 commit comments

Comments
 (0)