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

remove file name addition to URL #77

Merged
merged 1 commit into from
Apr 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
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
13 changes: 1 addition & 12 deletions pkg/devfile/parser/context/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"fmt"
"net/url"
"os"
"path"
"path/filepath"
"strings"

Expand Down Expand Up @@ -104,20 +103,10 @@ func (d *DevfileCtx) Populate() (err error) {

// PopulateFromURL fills the DevfileCtx struct with relevant context info
func (d *DevfileCtx) PopulateFromURL() (err error) {
u, err := url.ParseRequestURI(d.url)
_, err = url.ParseRequestURI(d.url)
if err != nil {
return err
}
if !strings.HasSuffix(d.url, ".yaml") {
u.Path = path.Join(u.Path, "devfile.yaml")
if _, err = util.DownloadFileInMemory(u.String()); err != nil {
u.Path = path.Join(path.Dir(u.Path), ".devfile.yaml")
if _, err = util.DownloadFileInMemory(u.String()); err != nil {
return fmt.Errorf("the provided url is not a valid yaml filepath, and devfile.yaml or .devfile.yaml not found in the provided path : %s", d.url)
}
}
d.url = u.String()
}
if d.uriMap == nil {
d.uriMap = make(map[string]bool)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/devfile/parser/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2390,7 +2390,7 @@ func Test_parseParentAndPlugin_RecursivelyReference_withMultipleURI(t *testing.T
defer testServer3.Close()
t.Run("it should error out if URI is recursively referenced with multiple references", func(t *testing.T) {
err := parseParentAndPlugin(devFileObj)
expectedErr := fmt.Sprintf("URI %v%v/devfile.yaml is recursively referenced", httpPrefix, uri1)
expectedErr := fmt.Sprintf("URI %v%v is recursively referenced", httpPrefix, uri1)
// Unexpected error
if err == nil || !reflect.DeepEqual(expectedErr, err.Error()) {
t.Errorf("Test_parseParentAndPlugin_RecursivelyReference_withMultipleURI() unexpected error = %v", err)
Expand Down