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

Change func param signature to avoid unneccessary Ctx #154

Merged
merged 2 commits into from
Nov 15, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
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