Skip to content

Commit

Permalink
Fix GetDeployment function when Devfile SchemaVersion is less than 2.1.0
Browse files Browse the repository at this point in the history
Signed-off-by: Parthvi Vala <[email protected]>
  • Loading branch information
valaparthvi committed Jan 14, 2023
1 parent 4d107dd commit 2d58ec4
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions pkg/devfile/generator/generators.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ package generator

import (
"fmt"
"github.com/devfile/api/v2/pkg/attributes"
"github.com/devfile/library/v2/pkg/devfile/parser/data"

v1 "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2"
"github.com/devfile/library/v2/pkg/devfile/parser"
Expand Down Expand Up @@ -185,10 +187,14 @@ func GetDeployment(devfileObj parser.DevfileObj, deployParams DeploymentParams)
Containers: deployParams.Containers,
Volumes: deployParams.Volumes,
}

globalAttributes, err := devfileObj.Data.GetAttributes()
if err != nil {
return nil, err
var globalAttributes attributes.Attributes
// attributes is not supported in versions less than 2.0.0, so we skip it
if devfileObj.Data.GetSchemaVersion() > string(data.APISchemaVersion200) {
var err error
globalAttributes, err = devfileObj.Data.GetAttributes()
if err != nil {
return nil, err
}
}
components, err := devfileObj.Data.GetDevfileContainerComponents(common.DevfileOptions{})
if err != nil {
Expand Down

0 comments on commit 2d58ec4

Please sign in to comment.