Skip to content

Commit

Permalink
fixed the problem of incorrect number of generated stages for resourc…
Browse files Browse the repository at this point in the history
…e in the box
  • Loading branch information
zc2638 committed Jan 10, 2024
1 parent a41009e commit c6eb25f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ packages = `go list ./... | grep -v github.com/zc2638/ink/test`
build-%:
@CGO_ENABLED=0 go build -ldflags="-s -w" -installsuffix cgo -o _output/$* ./cmd/$*

docker-build-%: build-%
docker-build-%:
@docker build -t zc2638/$* -f docker/$*.dockerfile .

docker-tag-%:
Expand Down
16 changes: 14 additions & 2 deletions core/service/build/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,15 +154,27 @@ func (s *srv) Create(ctx context.Context, namespace, name string, settings map[s
return 0, err
}

workflowNames := make([]string, 0, len(box.Resources))
for _, v := range box.Resources {
if v.Kind != v1.KindWorkflow {
continue
}
workflowNames = append(workflowNames, v.Name)
}
if len(workflowNames) == 0 {
return 0, errors.New("workflow resource not found")
}

err = db.Transaction(func(tx *gorm.DB) error {
if err := tx.Create(&buildS).Error; err != nil {
return err
}

for k, v := range box.Resources {
for k, v := range workflowNames {

sd := &storageV1.Workflow{
Namespace: box.Namespace,
Name: v.Name,
Name: v,
}
if err := tx.Where(sd).First(sd).Error; err != nil {
return err
Expand Down

0 comments on commit c6eb25f

Please sign in to comment.