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

update devfile/library v1.2.0 #5130

Merged
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
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ require (
github.com/Netflix/go-expect v0.0.0-20201125194554-85d881c3777e
github.com/Xuanwo/go-locale v1.0.0
github.com/blang/semver v3.5.1+incompatible
github.com/devfile/api/v2 v2.1.0
github.com/devfile/library v1.1.1-0.20210910214722-7c5ff63711ec
github.com/devfile/api/v2 v2.0.0-20210917193329-089a48011460
github.com/devfile/library v1.2.0
github.com/devfile/registry-support/index/generator v0.0.0-20210916150157-08b31e03fdf0
github.com/devfile/registry-support/registry-library v0.0.0-20210928163805-b0916a4f1aca
github.com/fatih/color v1.10.0
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -246,10 +246,14 @@ github.com/deislabs/oras v0.8.1/go.mod h1:Mx0rMSbBNaNfY9hjpccEnxkOqJL6KGjtxNHPLC
github.com/denisenkom/go-mssqldb v0.0.0-20190515213511-eb9f6a1743f3/go.mod h1:zAg7JM8CkOJ43xKXIj7eRO9kmWm/TW578qo+oDO6tuM=
github.com/denverdino/aliyungo v0.0.0-20190125010748-a747050bb1ba/go.mod h1:dV8lFg6daOBZbT6/BDGIz6Y3WFGn8juu6G+CQ6LHtl0=
github.com/devfile/api/v2 v2.0.0-20210910153124-da620cd1a7a1/go.mod h1:kLX/nW93gigOHXK3NLeJL2fSS/sgEe+OHu8bo3aoOi4=
github.com/devfile/api/v2 v2.0.0-20210917193329-089a48011460 h1:cmd+3poyUwevcWchYdvE02YT1nQU4SJpA5/wrdLrpWE=
github.com/devfile/api/v2 v2.0.0-20210917193329-089a48011460/go.mod h1:kLX/nW93gigOHXK3NLeJL2fSS/sgEe+OHu8bo3aoOi4=
github.com/devfile/api/v2 v2.1.0 h1:hodMaQpa9onnx8uG5NBxIuzBjC7AUkLTGCcuvZyED7g=
github.com/devfile/api/v2 v2.1.0/go.mod h1:Cot4snybn3qhIh48oIFi9McocnIx7zY5fFbjfrIpPvg=
github.com/devfile/library v1.1.1-0.20210910214722-7c5ff63711ec h1:UtJiFJfnC7fhup2MbGOzt6DCKMFKJTw47aHHETLfcZA=
github.com/devfile/library v1.1.1-0.20210910214722-7c5ff63711ec/go.mod h1:svPWwWb+BP15SXCHl0dyOeE4Sohrjl5a2BaOzc/riLc=
github.com/devfile/library v1.2.0 h1:OT1Irwg5EZhlCpsAFkjIzd3bqyzbLG0JmFPMHeE1e7M=
github.com/devfile/library v1.2.0/go.mod h1:gyiQS+ZImnM4/d+wFUl3gJmIozOSXMenl0WX8cx4zu4=
github.com/devfile/registry-support/index/generator v0.0.0-20210916150157-08b31e03fdf0 h1:F2OkuW0ASrSz5d06tJxWfweUNYTnsOCyiGTEORisokE=
github.com/devfile/registry-support/index/generator v0.0.0-20210916150157-08b31e03fdf0/go.mod h1:bLGagbW2SFn7jo5+kUPlCMehIGqWkRtLKc5O0OyJMJM=
github.com/devfile/registry-support/registry-library v0.0.0-20210928163805-b0916a4f1aca h1:MioKDSUEwwYCGEjGioWYO1vodYAutS+ESkZBGCPtx/U=
Expand Down
5 changes: 3 additions & 2 deletions pkg/devfile/adapters/common/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
devfilev1 "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2"
"github.com/devfile/library/pkg/devfile/parser/data"
parsercommon "github.com/devfile/library/pkg/devfile/parser/data/v2/common"
"github.com/openshift/odo/pkg/util"
"github.com/pkg/errors"
"k8s.io/klog"
)
Expand All @@ -34,7 +35,7 @@ func New(devfile devfilev1.Command, knowCommands map[string]devfilev1.Command, e
return nil, fmt.Errorf("composite command %q has command %v not found in devfile", cmd, devfile)
}
}
if composite.Parallel {
if util.SafeGetBool(composite.Parallel) {
return newParallelCompositeCommand(components...), nil
}
return newCompositeCommand(components...), nil
Expand Down Expand Up @@ -69,7 +70,7 @@ func getCommandFromDevfile(data data.DevfileData, groupType devfilev1.CommandGro
for _, command := range commands {
cmdGroup := parsercommon.GetGroup(command)
if cmdGroup != nil && cmdGroup.Kind == groupType {
if cmdGroup.IsDefault {
if util.SafeGetBool(cmdGroup.IsDefault) {
return command, nil
} else if reflect.DeepEqual(onlyCommand, devfilev1.Command{}) {
// return the only remaining command for the group if there is no default command
Expand Down
54 changes: 27 additions & 27 deletions pkg/devfile/adapters/common/command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func TestGetCommand(t *testing.T) {
Exec: &devfilev1.ExecCommand{
LabeledCommand: devfilev1.LabeledCommand{
BaseCommand: devfilev1.BaseCommand{
Group: &devfilev1.CommandGroup{Kind: runGroup, IsDefault: true},
Group: &devfilev1.CommandGroup{Kind: runGroup, IsDefault: util.GetBoolPtr(true)},
},
},
CommandLine: commands[0],
Expand Down Expand Up @@ -138,7 +138,7 @@ func TestGetCommand(t *testing.T) {
Exec: &devfilev1.ExecCommand{
LabeledCommand: devfilev1.LabeledCommand{
BaseCommand: devfilev1.BaseCommand{
Group: &devfilev1.CommandGroup{Kind: buildGroup, IsDefault: false},
Group: &devfilev1.CommandGroup{Kind: buildGroup, IsDefault: util.GetBoolPtr(false)},
},
},
CommandLine: commands[0],
Expand Down Expand Up @@ -168,7 +168,7 @@ func TestGetCommand(t *testing.T) {
Composite: &devfilev1.CompositeCommand{
LabeledCommand: devfilev1.LabeledCommand{
BaseCommand: devfilev1.BaseCommand{
Group: &devfilev1.CommandGroup{Kind: buildGroup, IsDefault: true},
Group: &devfilev1.CommandGroup{Kind: buildGroup, IsDefault: util.GetBoolPtr(true)},
},
},
Commands: []string{"build", "run"},
Expand Down Expand Up @@ -284,7 +284,7 @@ func TestGetCommandFromDevfile(t *testing.T) {
Exec: &devfilev1.ExecCommand{
LabeledCommand: devfilev1.LabeledCommand{
BaseCommand: devfilev1.BaseCommand{
Group: &devfilev1.CommandGroup{Kind: runGroup, IsDefault: true},
Group: &devfilev1.CommandGroup{Kind: runGroup, IsDefault: util.GetBoolPtr(true)},
},
},
CommandLine: commands[0],
Expand Down Expand Up @@ -364,7 +364,7 @@ func TestGetCommandFromDevfile(t *testing.T) {
Composite: &devfilev1.CompositeCommand{
LabeledCommand: devfilev1.LabeledCommand{
BaseCommand: devfilev1.BaseCommand{
Group: &devfilev1.CommandGroup{Kind: buildGroup, IsDefault: true},
Group: &devfilev1.CommandGroup{Kind: buildGroup, IsDefault: util.GetBoolPtr(true)},
},
},
Commands: []string{"build1", "run"},
Expand All @@ -385,7 +385,7 @@ func TestGetCommandFromDevfile(t *testing.T) {
Exec: &devfilev1.ExecCommand{
LabeledCommand: devfilev1.LabeledCommand{
BaseCommand: devfilev1.BaseCommand{
Group: &devfilev1.CommandGroup{Kind: buildGroup, IsDefault: false},
Group: &devfilev1.CommandGroup{Kind: buildGroup, IsDefault: util.GetBoolPtr(false)},
},
},
CommandLine: commands[0],
Expand Down Expand Up @@ -415,7 +415,7 @@ func TestGetCommandFromDevfile(t *testing.T) {
Composite: &devfilev1.CompositeCommand{
LabeledCommand: devfilev1.LabeledCommand{
BaseCommand: devfilev1.BaseCommand{
Group: &devfilev1.CommandGroup{Kind: buildGroup, IsDefault: true},
Group: &devfilev1.CommandGroup{Kind: buildGroup, IsDefault: util.GetBoolPtr(true)},
},
},
Commands: []string{"build", "run"},
Expand All @@ -428,7 +428,7 @@ func TestGetCommandFromDevfile(t *testing.T) {
Composite: &devfilev1.CompositeCommand{
LabeledCommand: devfilev1.LabeledCommand{
BaseCommand: devfilev1.BaseCommand{
Group: &devfilev1.CommandGroup{Kind: buildGroup, IsDefault: false},
Group: &devfilev1.CommandGroup{Kind: buildGroup, IsDefault: util.GetBoolPtr(false)},
},
},
Commands: []string{"build", "run"},
Expand Down Expand Up @@ -606,7 +606,7 @@ func TestGetCommandFromFlag(t *testing.T) {
Exec: &devfilev1.ExecCommand{
LabeledCommand: devfilev1.LabeledCommand{
BaseCommand: devfilev1.BaseCommand{
Group: &devfilev1.CommandGroup{Kind: runGroup, IsDefault: true},
Group: &devfilev1.CommandGroup{Kind: runGroup, IsDefault: util.GetBoolPtr(true)},
},
},
CommandLine: commands[0],
Expand All @@ -620,7 +620,7 @@ func TestGetCommandFromFlag(t *testing.T) {
Exec: &devfilev1.ExecCommand{
LabeledCommand: devfilev1.LabeledCommand{
BaseCommand: devfilev1.BaseCommand{
Group: &devfilev1.CommandGroup{Kind: runGroup, IsDefault: true},
Group: &devfilev1.CommandGroup{Kind: runGroup, IsDefault: util.GetBoolPtr(true)},
},
},
CommandLine: commands[0],
Expand Down Expand Up @@ -698,7 +698,7 @@ func TestGetCommandFromFlag(t *testing.T) {
Exec: &devfilev1.ExecCommand{
LabeledCommand: devfilev1.LabeledCommand{
BaseCommand: devfilev1.BaseCommand{
Group: &devfilev1.CommandGroup{Kind: buildGroup, IsDefault: false},
Group: &devfilev1.CommandGroup{Kind: buildGroup, IsDefault: util.GetBoolPtr(false)},
},
},
CommandLine: commands[0],
Expand Down Expand Up @@ -728,7 +728,7 @@ func TestGetCommandFromFlag(t *testing.T) {
Composite: &devfilev1.CompositeCommand{
LabeledCommand: devfilev1.LabeledCommand{
BaseCommand: devfilev1.BaseCommand{
Group: &devfilev1.CommandGroup{Kind: buildGroup, IsDefault: true},
Group: &devfilev1.CommandGroup{Kind: buildGroup, IsDefault: util.GetBoolPtr(true)},
},
},
Commands: []string{"build", "run"},
Expand All @@ -741,7 +741,7 @@ func TestGetCommandFromFlag(t *testing.T) {
Composite: &devfilev1.CompositeCommand{
LabeledCommand: devfilev1.LabeledCommand{
BaseCommand: devfilev1.BaseCommand{
Group: &devfilev1.CommandGroup{Kind: buildGroup, IsDefault: false},
Group: &devfilev1.CommandGroup{Kind: buildGroup, IsDefault: util.GetBoolPtr(false)},
},
},
Commands: []string{"build", "run"},
Expand Down Expand Up @@ -824,7 +824,7 @@ func TestGetBuildCommand(t *testing.T) {
Exec: &devfilev1.ExecCommand{
LabeledCommand: devfilev1.LabeledCommand{
BaseCommand: devfilev1.BaseCommand{
Group: &devfilev1.CommandGroup{Kind: buildGroup, IsDefault: true},
Group: &devfilev1.CommandGroup{Kind: buildGroup, IsDefault: util.GetBoolPtr(true)},
},
},
CommandLine: command,
Expand All @@ -839,7 +839,7 @@ func TestGetBuildCommand(t *testing.T) {
Exec: &devfilev1.ExecCommand{
LabeledCommand: devfilev1.LabeledCommand{
BaseCommand: devfilev1.BaseCommand{
Group: &devfilev1.CommandGroup{Kind: buildGroup, IsDefault: true},
Group: &devfilev1.CommandGroup{Kind: buildGroup, IsDefault: util.GetBoolPtr(true)},
},
},
CommandLine: command,
Expand Down Expand Up @@ -984,7 +984,7 @@ func TestGetDebugCommand(t *testing.T) {
LabeledCommand: devfilev1.LabeledCommand{
BaseCommand: devfilev1.BaseCommand{
Group: &devfilev1.CommandGroup{
IsDefault: true,
IsDefault: util.GetBoolPtr(true),
Kind: devfilev1.DebugCommandGroupKind,
},
},
Expand All @@ -1009,7 +1009,7 @@ func TestGetDebugCommand(t *testing.T) {
LabeledCommand: devfilev1.LabeledCommand{
BaseCommand: devfilev1.BaseCommand{
Group: &devfilev1.CommandGroup{
IsDefault: false,
IsDefault: util.GetBoolPtr(false),
Kind: devfilev1.DebugCommandGroupKind,
},
},
Expand All @@ -1033,7 +1033,7 @@ func TestGetDebugCommand(t *testing.T) {
LabeledCommand: devfilev1.LabeledCommand{
BaseCommand: devfilev1.BaseCommand{
Group: &devfilev1.CommandGroup{
IsDefault: true,
IsDefault: util.GetBoolPtr(true),
Kind: devfilev1.BuildCommandGroupKind,
},
},
Expand Down Expand Up @@ -1109,7 +1109,7 @@ func TestGetTestCommand(t *testing.T) {
LabeledCommand: devfilev1.LabeledCommand{
BaseCommand: devfilev1.BaseCommand{
Group: &devfilev1.CommandGroup{
IsDefault: true,
IsDefault: util.GetBoolPtr(true),
Kind: devfilev1.TestCommandGroupKind,
},
},
Expand All @@ -1134,7 +1134,7 @@ func TestGetTestCommand(t *testing.T) {
LabeledCommand: devfilev1.LabeledCommand{
BaseCommand: devfilev1.BaseCommand{
Group: &devfilev1.CommandGroup{
IsDefault: false,
IsDefault: util.GetBoolPtr(false),
Kind: devfilev1.TestCommandGroupKind,
},
},
Expand All @@ -1158,7 +1158,7 @@ func TestGetTestCommand(t *testing.T) {
LabeledCommand: devfilev1.LabeledCommand{
BaseCommand: devfilev1.BaseCommand{
Group: &devfilev1.CommandGroup{
IsDefault: true,
IsDefault: util.GetBoolPtr(true),
Kind: devfilev1.BuildCommandGroupKind,
},
},
Expand Down Expand Up @@ -1233,7 +1233,7 @@ func TestGetRunCommand(t *testing.T) {
Exec: &devfilev1.ExecCommand{
LabeledCommand: devfilev1.LabeledCommand{
BaseCommand: devfilev1.BaseCommand{
Group: &devfilev1.CommandGroup{Kind: runGroup, IsDefault: true},
Group: &devfilev1.CommandGroup{Kind: runGroup, IsDefault: util.GetBoolPtr(true)},
},
},
CommandLine: command,
Expand Down Expand Up @@ -1351,7 +1351,7 @@ func TestValidateAndGetDebugDevfileCommands(t *testing.T) {
LabeledCommand: devfilev1.LabeledCommand{
BaseCommand: devfilev1.BaseCommand{
Group: &devfilev1.CommandGroup{
IsDefault: true,
IsDefault: util.GetBoolPtr(true),
Kind: devfilev1.DebugCommandGroupKind,
},
},
Expand All @@ -1369,7 +1369,7 @@ func TestValidateAndGetDebugDevfileCommands(t *testing.T) {
LabeledCommand: devfilev1.LabeledCommand{
BaseCommand: devfilev1.BaseCommand{
Group: &devfilev1.CommandGroup{
IsDefault: false,
IsDefault: util.GetBoolPtr(false),
Kind: devfilev1.DebugCommandGroupKind,
},
},
Expand Down Expand Up @@ -1465,7 +1465,7 @@ func TestValidateAndGetPushDevfileCommands(t *testing.T) {
BaseCommand: devfilev1.BaseCommand{
Group: &devfilev1.CommandGroup{
Kind: runGroup,
IsDefault: true,
IsDefault: util.GetBoolPtr(true),
},
},
},
Expand Down Expand Up @@ -1641,7 +1641,7 @@ func TestValidateAndGetTestDevfileCommands(t *testing.T) {
LabeledCommand: devfilev1.LabeledCommand{
BaseCommand: devfilev1.BaseCommand{
Group: &devfilev1.CommandGroup{
IsDefault: true,
IsDefault: util.GetBoolPtr(true),
Kind: devfilev1.TestCommandGroupKind,
},
},
Expand All @@ -1659,7 +1659,7 @@ func TestValidateAndGetTestDevfileCommands(t *testing.T) {
LabeledCommand: devfilev1.LabeledCommand{
BaseCommand: devfilev1.BaseCommand{
Group: &devfilev1.CommandGroup{
IsDefault: false,
IsDefault: util.GetBoolPtr(false),
Kind: devfilev1.TestCommandGroupKind,
},
},
Expand Down
3 changes: 2 additions & 1 deletion pkg/devfile/adapters/common/generic.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/devfile/library/pkg/devfile/parser/data/v2/common"
"github.com/openshift/odo/pkg/log"
"github.com/openshift/odo/pkg/machineoutput"
"github.com/openshift/odo/pkg/util"
"github.com/pkg/errors"
"k8s.io/klog"
)
Expand Down Expand Up @@ -145,7 +146,7 @@ func (a GenericAdapter) ExecDevfile(commandsMap PushCommandsMap, componentExists
}
}

restart := IsRestartRequired(command.Exec.HotReloadCapable, params.RunModeChanged)
restart := IsRestartRequired(util.SafeGetBool(command.Exec.HotReloadCapable), params.RunModeChanged)

// if we need to restart, issue supervisor command to stop all running commands first
// we do not need to restart Hot reload capable commands
Expand Down
Loading