Recognize devfile.yml and .devfile.yml as Devfiles (#7130)

This commit is contained in:
Armel Soro
2023-12-01 12:10:19 +01:00
committed by GitHub
parent 15f663f12a
commit 0f2103e7d7
70 changed files with 1152 additions and 418 deletions

View File

@@ -24,7 +24,7 @@ func (o *DevfileState) GetContent() (DevfileContent, error) {
if err != nil {
return DevfileContent{}, errors.New("error writing file")
}
result, err := o.FS.ReadFile("/devfile.yaml")
result, err := o.FS.ReadFile(o.Devfile.Ctx.GetAbsPath())
if err != nil {
return DevfileContent{}, errors.New("error reading file")
}

View File

@@ -9,6 +9,7 @@ import (
"github.com/devfile/library/v2/pkg/devfile/parser"
context "github.com/devfile/library/v2/pkg/devfile/parser/context"
"github.com/devfile/library/v2/pkg/testingutil/filesystem"
. "github.com/redhat-developer/odo/pkg/apiserver-gen/go"
"k8s.io/utils/pointer"
@@ -42,7 +43,7 @@ func (o *DevfileState) SetDevfileContent(content string) (DevfileContent, error)
return DevfileContent{}, fmt.Errorf("error parsing devfile YAML: %w", err)
}
o.Devfile = devfile
o.Devfile.Ctx = context.FakeContext(o.FS, "/devfile.yaml")
o.Devfile.Ctx = context.FakeContext(o.FS, o.Devfile.Ctx.GetAbsPath())
return o.GetContent()
}

View File

@@ -8,8 +8,8 @@ import (
"github.com/redhat-developer/odo/pkg/util"
)
// possibleDevfileNames contains possivle devfile name that should be checked in the context dir.
var possibleDevfileNames = [...]string{"devfile.yaml", ".devfile.yaml"}
// possibleDevfileNames contains possible devfile name that should be checked in the context dir.
var possibleDevfileNames = [...]string{"devfile.yaml", ".devfile.yaml", "devfile.yml", ".devfile.yml"}
// DevfileFilenamesProvider checks if the context dir contains devfile with possible names from possibleDevfileNames variable,
// else it returns "devfile.yaml" as default value.