Skip to content

Commit c8f6c26

Browse files
authored
Merge pull request #154 from maysunfaisal/update-utils-1
Change func param signature to avoid unneccessary Ctx
2 parents 63790be + b5c3f6a commit c8f6c26

3 files changed

Lines changed: 9 additions & 8 deletions

File tree

pkg/devfile/parser/parse_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3988,7 +3988,7 @@ func Test_parseFromRegistry(t *testing.T) {
39883988
ImportReferenceUnion: v1.ImportReferenceUnion{
39893989
Id: registryId,
39903990
},
3991-
Version: "2.1.0",
3991+
Version: "2.1.1",
39923992
RegistryUrl: stagingRegistry,
39933993
},
39943994
},

pkg/devfile/parser/utils.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,18 @@ import (
2020
"reflect"
2121

2222
devfilev1 "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2"
23+
"github.com/devfile/library/v2/pkg/devfile/parser/data"
2324
"github.com/devfile/library/v2/pkg/devfile/parser/data/v2/common"
2425
)
2526

2627
// GetDeployComponents gets the default deploy command associated components
27-
func GetDeployComponents(devfileObj DevfileObj) (map[string]string, error) {
28+
func GetDeployComponents(devfileData data.DevfileData) (map[string]string, error) {
2829
deployCommandFilter := common.DevfileOptions{
2930
CommandOptions: common.CommandOptions{
3031
CommandGroupKind: devfilev1.DeployCommandGroupKind,
3132
},
3233
}
33-
deployCommands, err := devfileObj.Data.GetCommands(deployCommandFilter)
34+
deployCommands, err := devfileData.GetCommands(deployCommandFilter)
3435
if err != nil {
3536
return nil, err
3637
}
@@ -57,7 +58,7 @@ func GetDeployComponents(devfileObj DevfileObj) (map[string]string, error) {
5758
CommandType: devfilev1.ApplyCommandType,
5859
},
5960
}
60-
applyCommands, err := devfileObj.Data.GetCommands(applyCommandFilter)
61+
applyCommands, err := devfileData.GetCommands(applyCommandFilter)
6162
if err != nil {
6263
return nil, err
6364
}
@@ -77,14 +78,14 @@ func GetDeployComponents(devfileObj DevfileObj) (map[string]string, error) {
7778
}
7879

7980
// GetImageBuildComponent gets the image build component from the deploy associated components
80-
func GetImageBuildComponent(devfileObj DevfileObj, deployAssociatedComponents map[string]string) (devfilev1.Component, error) {
81+
func GetImageBuildComponent(devfileData data.DevfileData, deployAssociatedComponents map[string]string) (devfilev1.Component, error) {
8182
imageComponentFilter := common.DevfileOptions{
8283
ComponentOptions: common.ComponentOptions{
8384
ComponentType: devfilev1.ImageComponentType,
8485
},
8586
}
8687

87-
imageComponents, err := devfileObj.Data.GetComponents(imageComponentFilter)
88+
imageComponents, err := devfileData.GetComponents(imageComponentFilter)
8889
if err != nil {
8990
return devfilev1.Component{}, err
9091
}

pkg/devfile/parser/utils_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ func TestGetDeployComponents(t *testing.T) {
196196
Data: mockDevfileData,
197197
}
198198

199-
componentMap, err := GetDeployComponents(devObj)
199+
componentMap, err := GetDeployComponents(devObj.Data)
200200
// Unexpected error
201201
if (err != nil) != (tt.wantErr != nil) {
202202
t.Errorf("TestGetDeployComponents() error: %v, wantErr %v", err, tt.wantErr)
@@ -372,7 +372,7 @@ func TestGetImageBuildComponent(t *testing.T) {
372372
Data: mockDevfileData,
373373
}
374374

375-
component, err := GetImageBuildComponent(devObj, tt.deployAssociatedComponents)
375+
component, err := GetImageBuildComponent(devObj.Data, tt.deployAssociatedComponents)
376376
// Unexpected error
377377
if (err != nil) != (tt.wantErr != nil) {
378378
t.Errorf("TestGetImageBuildComponent() error: %v, wantErr %v", err, tt.wantErr)

0 commit comments

Comments
 (0)