From 6f4988b3b076598a937b4a126ccd61bed917b59b Mon Sep 17 00:00:00 2001 From: Armel Soro Date: Thu, 25 May 2023 18:02:20 +0200 Subject: [PATCH] Bump Devfile library to latest commit [1] This fixes the issue with parsing child Devfiles referencing parents via URIs (GitHub blob, raw or any hosted URL). See [2] for more context. [1] https://github.com/devfile/library/commit/04a8b3fc66c0ca7a33d03190f3a026a3d9e6a940 [2] https://github.com/devfile/api/issues/1119 --- go.mod | 2 +- go.sum | 4 ++-- .../devfile/library/v2/pkg/devfile/parser/parse.go | 10 +++++----- vendor/github.com/devfile/library/v2/pkg/git/git.go | 4 ++-- vendor/github.com/devfile/library/v2/pkg/git/mock.go | 7 +++---- vendor/modules.txt | 2 +- 6 files changed, 14 insertions(+), 15 deletions(-) diff --git a/go.mod b/go.mod index fd50524204f..468d66f4a2e 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/Xuanwo/go-locale v1.1.0 github.com/blang/semver v3.5.1+incompatible github.com/devfile/api/v2 v2.2.1-alpha.0.20230413012049-a6c32fca0dbd - github.com/devfile/library/v2 v2.2.1-0.20230515084048-f041d798707c + github.com/devfile/library/v2 v2.2.1-0.20230524160049-04a8b3fc66c0 github.com/devfile/registry-support/index/generator v0.0.0-20230322155332-33914affc83b github.com/devfile/registry-support/registry-library v0.0.0-20221201200738-19293ac0b8ab github.com/fatih/color v1.14.1 diff --git a/go.sum b/go.sum index 5f6aff908c1..a79dad5e61a 100644 --- a/go.sum +++ b/go.sum @@ -374,8 +374,8 @@ github.com/devfile/api/v2 v2.2.1-alpha.0.20230413012049-a6c32fca0dbd/go.mod h1:q github.com/devfile/library v1.2.1-0.20211104222135-49d635cb492f/go.mod h1:uFZZdTuRqA68FVe/JoJHP92CgINyQkyWnM2Qyiim+50= github.com/devfile/library v1.2.1-0.20220308191614-f0f7e11b17de/go.mod h1:GSPfJaBg0+bBjBHbwBE5aerJLH6tWGQu2q2rHYd9czM= github.com/devfile/library/v2 v2.0.1/go.mod h1:paJ0PARAVy0br13VpBEQ4fO3rZVDxWtooQ29+23PNBk= -github.com/devfile/library/v2 v2.2.1-0.20230515084048-f041d798707c h1:WXsJ/mP865odQ6yxP9MKULBg6N6lPmoBzMZ/Ur2y/5I= -github.com/devfile/library/v2 v2.2.1-0.20230515084048-f041d798707c/go.mod h1:7oEhkC6GW6OKmAP8HbxbaQ+nFbnACQuU7anYhJroltQ= +github.com/devfile/library/v2 v2.2.1-0.20230524160049-04a8b3fc66c0 h1:cZPTQyQqZD6zTbrNhS5MU1j/tE+kyDIOgYqeBCu+2to= +github.com/devfile/library/v2 v2.2.1-0.20230524160049-04a8b3fc66c0/go.mod h1:7oEhkC6GW6OKmAP8HbxbaQ+nFbnACQuU7anYhJroltQ= github.com/devfile/registry-support/index/generator v0.0.0-20220222194908-7a90a4214f3e/go.mod h1:iRPBxs+ZjfLEduVXpCCIOzdD2588Zv9OCs/CcXMcCCY= github.com/devfile/registry-support/index/generator v0.0.0-20220527155645-8328a8a883be/go.mod h1:1fyDJL+fPHtcrYA6yjSVWeLmXmjCNth0d5Rq1rvtryc= github.com/devfile/registry-support/index/generator v0.0.0-20221018203505-df96d34d4273/go.mod h1:ZJnaSLjTKCvGJhWmYgQoQ1O3g78qBe4Va6ZugLmi4dE= diff --git a/vendor/github.com/devfile/library/v2/pkg/devfile/parser/parse.go b/vendor/github.com/devfile/library/v2/pkg/devfile/parser/parse.go index 6f25a3ab476..0d1810c1eea 100644 --- a/vendor/github.com/devfile/library/v2/pkg/devfile/parser/parse.go +++ b/vendor/github.com/devfile/library/v2/pkg/devfile/parser/parse.go @@ -50,12 +50,12 @@ import ( var downloadGitRepoResources = func(url string, destDir string, httpTimeout *int, token string) error { var returnedErr error - gitUrl, err := git.NewGitUrlWithURL(url) - if err != nil { - return err - } + if util.IsGitProviderRepo(url) { + gitUrl, err := git.NewGitUrlWithURL(url) + if err != nil { + return err + } - if gitUrl.IsGitProviderRepo() { if !gitUrl.IsFile || gitUrl.Revision == "" || !strings.Contains(gitUrl.Path, OutputDevfileYamlPath) { return fmt.Errorf("error getting devfile from url: failed to retrieve %s", url) } diff --git a/vendor/github.com/devfile/library/v2/pkg/git/git.go b/vendor/github.com/devfile/library/v2/pkg/git/git.go index 94c7680ea42..bbd69547a33 100644 --- a/vendor/github.com/devfile/library/v2/pkg/git/git.go +++ b/vendor/github.com/devfile/library/v2/pkg/git/git.go @@ -139,13 +139,13 @@ func (g *GitUrl) CloneGitRepo(destDir string) error { } if g.Revision != "" { - _, err := execute(destDir, "git", "switch", "--detach", "origin/"+g.Revision) + _, err := execute(destDir, "git", "checkout", g.Revision) if err != nil { err = os.RemoveAll(destDir) if err != nil { return err } - return fmt.Errorf("failed to switch repo to revision. repo dir: %v, revision: %v", destDir, g.Revision) + return fmt.Errorf("failed to switch repo to revision. repo dir: %v, revision: %v, error: %v", destDir, g.Revision, err) } } diff --git a/vendor/github.com/devfile/library/v2/pkg/git/mock.go b/vendor/github.com/devfile/library/v2/pkg/git/mock.go index 458ab36945b..b75cbbcf1dd 100644 --- a/vendor/github.com/devfile/library/v2/pkg/git/mock.go +++ b/vendor/github.com/devfile/library/v2/pkg/git/mock.go @@ -20,7 +20,6 @@ import ( "net/url" "os" "path/filepath" - "strings" ) type MockGitUrl struct { @@ -70,8 +69,8 @@ var mockExecute = func(baseDir string, cmd CommandType, args ...string) ([]byte, return []byte(""), nil } - if len(args) > 0 && args[0] == "switch" { - revision := strings.TrimPrefix(args[2], "origin/") + if len(args) > 0 && args[0] == "checkout" { + revision := args[1] if revision != "invalid-revision" { resourceFile, err := os.OpenFile(filepath.Clean(baseDir)+"/resource.file", os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0600) if err != nil { @@ -122,7 +121,7 @@ func (m *MockGitUrl) CloneGitRepo(destDir string) error { } if m.Revision != "" { - _, err := mockExecute(destDir, "git", "switch", "--detach", "origin/"+m.Revision) + _, err := mockExecute(destDir, "git", "checkout", m.Revision) if err != nil { return fmt.Errorf("failed to switch repo to revision. repo dir: %v, revision: %v", destDir, m.Revision) } diff --git a/vendor/modules.txt b/vendor/modules.txt index 27b5a8d80b5..fcf60c7153d 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -146,7 +146,7 @@ github.com/devfile/api/v2/pkg/utils/overriding github.com/devfile/api/v2/pkg/utils/unions github.com/devfile/api/v2/pkg/validation github.com/devfile/api/v2/pkg/validation/variables -# github.com/devfile/library/v2 v2.2.1-0.20230515084048-f041d798707c +# github.com/devfile/library/v2 v2.2.1-0.20230524160049-04a8b3fc66c0 ## explicit; go 1.18 github.com/devfile/library/v2/pkg/devfile github.com/devfile/library/v2/pkg/devfile/generator