Skip to content

Commit

Permalink
Merge pull request #154 from maysunfaisal/update-utils-1
Browse files Browse the repository at this point in the history
Change func param signature to avoid unneccessary Ctx
  • Loading branch information
maysunfaisal authored Nov 15, 2022
2 parents 63790be + b5c3f6a commit c8f6c26
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion pkg/devfile/parser/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3988,7 +3988,7 @@ func Test_parseFromRegistry(t *testing.T) {
ImportReferenceUnion: v1.ImportReferenceUnion{
Id: registryId,
},
Version: "2.1.0",
Version: "2.1.1",
RegistryUrl: stagingRegistry,
},
},
Expand Down
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 c8f6c26

Please sign in to comment.