From 8d6c51da5fb87c63fbf2a4cafc64e70003059a27 Mon Sep 17 00:00:00 2001 From: David O'Sullivan Date: Tue, 9 Dec 2025 11:30:36 +0000 Subject: [PATCH 1/3] workaround bellsoft req issue --- resources/bellsoft-liberica/metadata.go | 10 +++++++++- resources/in/artifact.go | 10 +++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/resources/bellsoft-liberica/metadata.go b/resources/bellsoft-liberica/metadata.go index 090889b..2e7baf9 100644 --- a/resources/bellsoft-liberica/metadata.go +++ b/resources/bellsoft-liberica/metadata.go @@ -17,6 +17,7 @@ package bellsoft import ( + "crypto/tls" "encoding/json" "fmt" "net/http" @@ -53,7 +54,14 @@ func (m *metadata) load() error { resp, err := http.DefaultClient.Do(req) if err != nil || resp.StatusCode != 200 { - return fmt.Errorf("unable to get %s\n%w", u, err) + tr := &http.Transport{ + TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, + } + client := &http.Client{Transport: tr} + resp, err = client.Do(req) + if err != nil { + return fmt.Errorf("unable to get %s\n%w", u, err) + } } defer resp.Body.Close() diff --git a/resources/in/artifact.go b/resources/in/artifact.go index f00679b..695403a 100644 --- a/resources/in/artifact.go +++ b/resources/in/artifact.go @@ -18,6 +18,7 @@ package in import ( "crypto/sha256" + "crypto/tls" "fmt" "io" "net/http" @@ -54,7 +55,14 @@ func (a Artifact) Download(mods ...RequestModifierFunc) (string, error) { resp, err := http.DefaultClient.Do(req) if err != nil { - return "", fmt.Errorf("unable to get %s\n%w", a.URI, err) + tr := &http.Transport{ + TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, + } + client := &http.Client{Transport: tr} + resp, err = client.Do(req) + if err != nil { + return "", fmt.Errorf("unable to get %s\n%w", req.RequestURI, err) + } } defer resp.Body.Close() From 2976e414a8bb23cc875d751d248ce17d8a0eaf85 Mon Sep 17 00:00:00 2001 From: David O'Sullivan Date: Fri, 19 Dec 2025 11:27:04 +0000 Subject: [PATCH 2/3] artifactory error detail --- resources/artifactory/search.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/artifactory/search.go b/resources/artifactory/search.go index b66201f..1e995b1 100644 --- a/resources/artifactory/search.go +++ b/resources/artifactory/search.go @@ -56,7 +56,7 @@ func (s *search) execute() error { defer resp.Body.Close() if resp.StatusCode != 200 { - return fmt.Errorf("unable to download %s", uri) + return fmt.Errorf("unable to download %s, code: %d, body: %s", uri, resp.StatusCode, resp.Body) } b := struct { From 605523003fd49c802ec9d3ce416e2fc483e23fe4 Mon Sep 17 00:00:00 2001 From: David O'Sullivan Date: Fri, 19 Dec 2025 11:56:46 +0000 Subject: [PATCH 3/3] artifactory error detail --- resources/artifactory/artifactory.go | 16 +++++++++++++++- resources/artifactory/search.go | 13 +++++++++---- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/resources/artifactory/artifactory.go b/resources/artifactory/artifactory.go index 4dc1799..40d03e8 100644 --- a/resources/artifactory/artifactory.go +++ b/resources/artifactory/artifactory.go @@ -17,6 +17,7 @@ package artifactory import ( + "net/http" "path" "resources/check" "resources/in" @@ -34,6 +35,8 @@ type source struct { GroupId string `json:"group_id"` Repository string `json:"repository"` URI string `json:"uri"` + User string `json:"user"` + Pass string `json:"pass"` } func (a Artifactory) Check() (check.Result, error) { @@ -43,6 +46,8 @@ func (a Artifactory) Check() (check.Result, error) { artifactId: a.Source.ArtifactId, repository: a.Source.Repository, artifactPattern: a.Source.ArtifactPattern, + user: a.Source.User, + pass: a.Source.Pass, } if err := s.execute(); err != nil { @@ -65,6 +70,8 @@ func (a Artifactory) In(destination string) (in.Result, error) { artifactId: a.Source.ArtifactId, repository: a.Source.Repository, artifactPattern: a.Source.ArtifactPattern, + user: a.Source.User, + pass: a.Source.Pass, } if err := s.execute(); err != nil { @@ -78,7 +85,7 @@ func (a Artifactory) In(destination string) (in.Result, error) { Version: a.Version, URI: uri, Destination: destination, - }.Download() + }.Download(a.addNameAndPassword) if err != nil { return in.Result{}, err } @@ -95,3 +102,10 @@ func (a Artifactory) In(destination string) (in.Result, error) { func (a Artifactory) name(uri string) string { return path.Base(uri) } + +func (a Artifactory) addNameAndPassword(req *http.Request) *http.Request { + if a.Source.User != "" && a.Source.Pass != "" { + req.SetBasicAuth(a.Source.User, a.Source.Pass) + } + return req +} \ No newline at end of file diff --git a/resources/artifactory/search.go b/resources/artifactory/search.go index 1e995b1..3e87a25 100644 --- a/resources/artifactory/search.go +++ b/resources/artifactory/search.go @@ -23,6 +23,7 @@ import ( "reflect" "regexp" "resources/internal" + "strings" ) var pattern = internal.Pattern{Regexp: regexp.MustCompile("^.+/([\\d]+)\\.([\\d]+)\\.([\\d]+)[.-]?(.*)/[^/]+$")} @@ -33,8 +34,9 @@ type search struct { artifactId string repository string artifactPattern internal.Pattern - versions map[internal.Version]string + user string + pass string } func (s *search) execute() error { @@ -47,6 +49,9 @@ func (s *search) execute() error { if err != nil { return err } + if s.user != "" && s.pass != "" { + req.SetBasicAuth(s.user, s.pass) + } req.Header.Set("X-Result-Detail", "info") resp, err := http.DefaultClient.Do(req) @@ -56,7 +61,7 @@ func (s *search) execute() error { defer resp.Body.Close() if resp.StatusCode != 200 { - return fmt.Errorf("unable to download %s, code: %d, body: %s", uri, resp.StatusCode, resp.Body) + return fmt.Errorf("unable to download %s, code: %d", uri, resp.StatusCode) } b := struct { @@ -76,8 +81,8 @@ func (s *search) execute() error { if reflect.DeepEqual(s.artifactPattern, internal.Pattern{}) || s.artifactPattern.MatchString(r.Path) { if err := pattern.IfMatches(r.Path, func(g []string) error { ref := fmt.Sprintf("%s.%s.%s", g[1], g[2], g[3]) - if g[4] != "" { - ref = fmt.Sprintf("%s-%s", ref, g[4]) + if g[4] != "" && strings.Contains(g[4], "_") { + ref = fmt.Sprintf("%s-%s", ref, strings.TrimPrefix(g[4], "_")) } s.versions[internal.Version{Ref: ref}] = r.URI