Skip to content

Commit

Permalink
Update to latest devfile-lifecycle version, license compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
feloy committed Jul 3, 2023
1 parent 4a7b298 commit a9bd13e
Show file tree
Hide file tree
Showing 16 changed files with 37 additions and 1,360 deletions.
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ require (
github.com/devfile/registry-support/index/generator v0.0.0-20230322155332-33914affc83b
github.com/devfile/registry-support/registry-library v0.0.0-20221201200738-19293ac0b8ab
github.com/fatih/color v1.14.1
github.com/feloy/devfile-lifecycle v0.0.0-20230703133341-1c1589018778
github.com/frapposelli/wwhrd v0.4.0
github.com/fsnotify/fsnotify v1.6.0
github.com/ghodss/yaml v1.0.0
Expand Down Expand Up @@ -75,7 +76,6 @@ require (
github.com/ActiveState/termtest/xpty v0.6.0 // indirect
github.com/ActiveState/vt10x v1.3.1 // indirect
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect
github.com/Heiko-san/mermaidgen v0.0.0-20190623222458-ec72afae378b // indirect
github.com/MakeNowJust/heredoc v0.0.0-20170808103936-bb23615498cd // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/Netflix/go-expect v0.0.0-20220104043353-73e0943537d2 // indirect
Expand Down Expand Up @@ -109,7 +109,6 @@ require (
github.com/evanphx/json-patch v4.12.0+incompatible // indirect
github.com/evanphx/json-patch/v5 v5.6.0 // indirect
github.com/exponent-io/jsonpath v0.0.0-20151013193312-d6023ce2651d // indirect
github.com/feloy/devfile-lifecycle v0.0.0-20230515183001-11d088157da2 // indirect
github.com/go-errors/errors v1.0.1 // indirect
github.com/go-git/gcfg v1.5.0 // indirect
github.com/go-git/go-billy/v5 v5.4.1 // indirect
Expand Down
8 changes: 4 additions & 4 deletions go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/apiserver-impl/devstate/chart.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ func (o *DevfileState) GetFlowChart() (string, error) {
if err != nil {
return "", errors.New("error building graph")
}
return g.ToFlowchart().String(), nil
return g.ToFlowchart(), nil
}
18 changes: 8 additions & 10 deletions pkg/apiserver-impl/devstate/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,15 @@ func (o *DevfileState) MoveCommand(previousGroup, newGroup string, previousIndex

// Deleting from the end as deleting from the beginning seems buggy
for i := len(commands) - 1; i >= 0; i-- {
o.Devfile.Data.DeleteCommand(commands[i].Id)
err = o.Devfile.Data.DeleteCommand(commands[i].Id)
if err != nil {
return DevfileContent{}, err
}
}

for _, group := range []string{"build", "run", "test", "debug", "deploy", ""} {
err := o.Devfile.Data.AddCommands(commandsByGroup[group])
if err != nil {
fmt.Printf("%s\n", err)
return DevfileContent{}, err
}
}
Expand Down Expand Up @@ -144,20 +146,17 @@ func subMoveCommand(commands []v1alpha2.Command, previousGroup, newGroup string,
}

func (o *DevfileState) SetDefaultCommand(commandName string, group string) (DevfileContent, error) {
fmt.Printf("change default for group %q\n", group)
commands, err := o.Devfile.Data.GetCommands(common.DevfileOptions{})
if err != nil {
return DevfileContent{}, err
}

for _, command := range commands {
for i, command := range commands {
if GetGroup(command) == group {
isDefault := command.Id == commandName
fmt.Printf("setting default = %v for command %q\n", isDefault, command.Id)
SetDefault(&command, isDefault)
SetDefault(&commands[i], isDefault)
err = o.Devfile.Data.UpdateCommand(command)
if err != nil {
fmt.Printf("%s\n", err)
return DevfileContent{}, err
}
}
Expand All @@ -171,12 +170,11 @@ func (o *DevfileState) UnsetDefaultCommand(commandName string) (DevfileContent,
return DevfileContent{}, err
}

for _, command := range commands {
for i, command := range commands {
if command.Id == commandName {
SetDefault(&command, false)
SetDefault(&commands[i], false)
err = o.Devfile.Data.UpdateCommand(command)
if err != nil {
fmt.Printf("%s\n", err)
return DevfileContent{}, err
}
break
Expand Down
5 changes: 4 additions & 1 deletion pkg/apiserver-impl/devstate/events_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ schemaVersion: 2.2.0
name: "set postStart event when preStart is already set",
state: func(t *testing.T) DevfileState {
state := NewDevfileState()
state.UpdateEvents("preStart", []string{"command1"})
_, err := state.UpdateEvents("preStart", []string{"command1"})
if err != nil {
t.Fatal(err)
}
return state
},
args: args{
Expand Down
Loading

0 comments on commit a9bd13e

Please sign in to comment.