Skip to content

Fix GetDeployment function when Devfile SchemaVersion is less than 2.1.0 #161

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

Merged
Merged
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
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update comment to say less than 2.0.1

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