Skip to content

Commit

Permalink
Do not make any assumption on the file name when parsing
Browse files Browse the repository at this point in the history
The parser should act generically, and be able to parse
any file it is provided, regardless of name and file extension.

Signed-off-by: Armel Soro <asoro@redhat.com>
  • Loading branch information
rm3l committed Oct 24, 2023
1 parent 3d5e045 commit fd5fccb
Showing 1 changed file with 0 additions and 15 deletions.
15 changes: 0 additions & 15 deletions pkg/devfile/parser/context/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@
package parser

import (
"fmt"
"net/url"
"os"
"path/filepath"
"strings"

"github.com/devfile/library/v2/pkg/testingutil/filesystem"
"github.com/devfile/library/v2/pkg/util"
Expand Down Expand Up @@ -96,17 +92,6 @@ func (d *DevfileCtx) populateDevfile() (err error) {

// Populate fills the DevfileCtx struct with relevant context info
func (d *DevfileCtx) Populate() (err error) {
if !strings.HasSuffix(d.relPath, ".yaml") {
if _, err := os.Stat(filepath.Join(d.relPath, "devfile.yaml")); os.IsNotExist(err) {
if _, err := os.Stat(filepath.Join(d.relPath, ".devfile.yaml")); os.IsNotExist(err) {
return fmt.Errorf("the provided path is not a valid yaml filepath, and devfile.yaml or .devfile.yaml not found in the provided path : %s", d.relPath)
} else {
d.relPath = filepath.Join(d.relPath, ".devfile.yaml")
}
} else {
d.relPath = filepath.Join(d.relPath, "devfile.yaml")
}
}
if err := d.SetAbsPath(); err != nil {
return err
}
Expand Down

0 comments on commit fd5fccb

Please sign in to comment.