Skip to content

Commit 06f7dfa

Browse files
authored
fix: fix build command by listing the argv (#40)
* fix: fix build commad by listing the argv * fix: update argument list for image-create shell out
1 parent ea6517a commit 06f7dfa

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

internal/config/image.go

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package config
22

33
import (
4-
"fmt"
54
"strings"
65
)
76

@@ -16,37 +15,40 @@ type Image struct {
1615
}
1716

1817
func (i *Image) Args() []string {
19-
args := []string{}
18+
var args []string
2019

2120
if i.Name != "" {
22-
args = append(args, fmt.Sprintf(`--name "%s"`, i.Name))
21+
args = append(args, "--name", i.Name)
2322
}
2423

2524
if i.DisplayName != "" {
26-
args = append(args, fmt.Sprintf(`--display-name "%s"`, i.DisplayName))
25+
args = append(args, "--display-name", i.DisplayName)
2726
}
27+
2828
if i.Description != "" {
29-
args = append(args, fmt.Sprintf(`--description "%s"`, i.Description))
29+
args = append(args, "--description", i.Description)
3030
}
31+
3132
if i.UseLatestAgentVersion {
3233
args = append(args, "--use-latest-agent-version")
3334
}
35+
3436
if i.EnableDynamicAppCatalog {
3537
args = append(args, "--enable-dynamic-app-catalog")
3638
}
39+
3740
if i.DryRun {
3841
args = append(args, "--dry-run")
3942
}
4043

4144
if len(i.Tags) > 0 {
42-
tagString := []string{"--tags"}
45+
args = append(args, "--tags")
4346
for _, tag := range i.Tags {
4447
parts := strings.SplitSeq(tag, ":")
4548
for part := range parts {
46-
tagString = append(tagString, fmt.Sprintf(`"%s"`, part))
49+
args = append(args, part)
4750
}
4851
}
49-
args = append(args, strings.Join(tagString, " "))
5052
}
5153

5254
return args

internal/service/image_build_service_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ func TestImageBuild(t *testing.T) {
2626
Description: "test3",
2727
EnableDynamicAppCatalog: true,
2828
UseLatestAgentVersion: true,
29-
Tags: []string{"k1", "v1"},
29+
Tags: []string{"k1", "v1", "k2", "built with appstreamfile"},
3030
DryRun: true,
3131
}
3232

3333
i.BuildImage(image)
3434

35-
expectedCommand := strings.TrimSpace(`image-assistant create-image --name "test" --display-name "test2" --description "test3" --use-latest-agent-version --enable-dynamic-app-catalog --dry-run --tags "k1" "v1"`)
35+
expectedCommand := strings.TrimSpace(`image-assistant create-image --name test --display-name test2 --description test3 --use-latest-agent-version --enable-dynamic-app-catalog --dry-run --tags k1 v1 k2 built with appstreamfile`)
3636
actual := strings.TrimSpace(fmt.Sprintf("%s %s", fc.LastCommand, strings.Join(fc.LastArgs, " ")))
3737

3838
if expectedCommand != actual {

0 commit comments

Comments
 (0)