Skip to content

Commit

Permalink
Change func param signature to avoid unneccessary Ctx
Browse files Browse the repository at this point in the history
Signed-off-by: Maysun J Faisal <[email protected]>
  • Loading branch information
maysunfaisal committed Nov 15, 2022
1 parent 63790be commit 215469b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
11 changes: 6 additions & 5 deletions pkg/devfile/parser/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,18 @@ import (
"reflect"

devfilev1 "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2"
"github.com/devfile/library/v2/pkg/devfile/parser/data"
"github.com/devfile/library/v2/pkg/devfile/parser/data/v2/common"
)

// GetDeployComponents gets the default deploy command associated components
func GetDeployComponents(devfileObj DevfileObj) (map[string]string, error) {
func GetDeployComponents(devfileData data.DevfileData) (map[string]string, error) {
deployCommandFilter := common.DevfileOptions{
CommandOptions: common.CommandOptions{
CommandGroupKind: devfilev1.DeployCommandGroupKind,
},
}
deployCommands, err := devfileObj.Data.GetCommands(deployCommandFilter)
deployCommands, err := devfileData.GetCommands(deployCommandFilter)
if err != nil {
return nil, err
}
Expand All @@ -57,7 +58,7 @@ func GetDeployComponents(devfileObj DevfileObj) (map[string]string, error) {
CommandType: devfilev1.ApplyCommandType,
},
}
applyCommands, err := devfileObj.Data.GetCommands(applyCommandFilter)
applyCommands, err := devfileData.GetCommands(applyCommandFilter)
if err != nil {
return nil, err
}
Expand All @@ -77,14 +78,14 @@ func GetDeployComponents(devfileObj DevfileObj) (map[string]string, error) {
}

// GetImageBuildComponent gets the image build component from the deploy associated components
func GetImageBuildComponent(devfileObj DevfileObj, deployAssociatedComponents map[string]string) (devfilev1.Component, error) {
func GetImageBuildComponent(devfileData data.DevfileData, deployAssociatedComponents map[string]string) (devfilev1.Component, error) {
imageComponentFilter := common.DevfileOptions{
ComponentOptions: common.ComponentOptions{
ComponentType: devfilev1.ImageComponentType,
},
}

imageComponents, err := devfileObj.Data.GetComponents(imageComponentFilter)
imageComponents, err := devfileData.GetComponents(imageComponentFilter)
if err != nil {
return devfilev1.Component{}, err
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/devfile/parser/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ func TestGetDeployComponents(t *testing.T) {
Data: mockDevfileData,
}

componentMap, err := GetDeployComponents(devObj)
componentMap, err := GetDeployComponents(devObj.Data)
// Unexpected error
if (err != nil) != (tt.wantErr != nil) {
t.Errorf("TestGetDeployComponents() error: %v, wantErr %v", err, tt.wantErr)
Expand Down Expand Up @@ -372,7 +372,7 @@ func TestGetImageBuildComponent(t *testing.T) {
Data: mockDevfileData,
}

component, err := GetImageBuildComponent(devObj, tt.deployAssociatedComponents)
component, err := GetImageBuildComponent(devObj.Data, tt.deployAssociatedComponents)
// Unexpected error
if (err != nil) != (tt.wantErr != nil) {
t.Errorf("TestGetImageBuildComponent() error: %v, wantErr %v", err, tt.wantErr)
Expand Down

0 comments on commit 215469b

Please sign in to comment.