Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cbuild] Fix setup list layers arguments #278

Merged
merged 1 commit into from
Jul 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 2 additions & 18 deletions pkg/builder/csolution/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,20 +125,6 @@ func (b CSolutionBuilder) installMissingPacks() (err error) {
func (b CSolutionBuilder) generateBuildFiles() (err error) {
args := b.formulateArgs([]string{"convert"})

cbuildSetFile := b.getCbuildSetFilePath()

var selectedContexts []string
if len(b.Options.Contexts) != 0 {
selectedContexts = append(selectedContexts, b.Options.Contexts...)
}

_, err = os.Stat(cbuildSetFile)

// Read contexts to be processed from cbuild-set file
if b.Options.UseContextSet && err == nil {
selectedContexts, _ = b.getSelectedContexts(cbuildSetFile)
}

// when using "cbuild setup *.csolution.yml -S" with no existing cbuild-set file
// Select first target-type and the first build-type for first listed project
if b.Setup && b.Options.UseContextSet && (len(b.Options.Contexts) == 0) && errors.Is(err, os.ErrNotExist) {
Expand Down Expand Up @@ -189,11 +175,9 @@ func (b CSolutionBuilder) generateBuildFiles() (err error) {
log.Debug("error code received: " + errCodeStr)

if exitError.ExitCode() == 2 {
args = []string{"list", "layers", b.InputFile, "--load=all", "--update-idx", "--quiet"}
for _, context := range selectedContexts {
args = append(args, "--context="+context)
}
args = []string{"list", "layers", b.InputFile, "--context-set", "--load=all", "--update-idx", "--quiet"}
_, listCmdErr := b.runCSolution(args, false)
log.Debug("csolution command: csolution " + strings.Join(args, " "))
if listCmdErr != nil {
err = listCmdErr
} else {
Expand Down
7 changes: 7 additions & 0 deletions pkg/builder/csolution/builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,13 @@ func TestBuild(t *testing.T) {
},
}

t.Run("test setup", func(t *testing.T) {
b.Setup = true
err := b.Build()
assert.Error(err)
b.Setup = false
})

t.Run("test build csolution without context", func(t *testing.T) {
err := b.Build()
assert.Error(err)
Expand Down