From e7ba6a803d32ee215661b4186aca5471fb8eb99c Mon Sep 17 00:00:00 2001 From: Mihail Stoykov Date: Tue, 2 Apr 2024 11:40:30 +0300 Subject: [PATCH 1/2] Deprecate magic resolving of cdnjs and github "URLs" Part of #1408 --- loader/cdnjs.go | 8 +++++--- loader/github.go | 9 +++++++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/loader/cdnjs.go b/loader/cdnjs.go index f58719c7a50d..b9a785dea16c 100644 --- a/loader/cdnjs.go +++ b/loader/cdnjs.go @@ -17,7 +17,7 @@ type cdnjsEnvelope struct { } } -func cdnjs(logger logrus.FieldLogger, path string, parts []string) (string, error) { +func cdnjs(logger logrus.FieldLogger, specifier string, parts []string) (string, error) { name := parts[0] version := parts[1] filename := parts[2] @@ -56,7 +56,7 @@ func cdnjs(logger logrus.FieldLogger, path string, parts []string) (string, erro if len(ver.Files) == 0 { return "", fmt.Errorf("cdnjs: no files for version %s of %s, this is a problem with the library or cdnjs not k6", - version, path) + version, specifier) } backupFilename = ver.Files[0] for _, file := range ver.Files { @@ -70,5 +70,7 @@ func cdnjs(logger logrus.FieldLogger, path string, parts []string) (string, erro } } - return "https://cdnjs.cloudflare.com/ajax/libs/" + name + "/" + version + "/" + filename, nil + realURL := "https://cdnjs.cloudflare.com/ajax/libs/" + name + "/" + version + "/" + filename + logger.Warnf(magicURLsDeprecationWarning, specifier, "cdnjs", realURL) + return realURL, nil } diff --git a/loader/github.go b/loader/github.go index 028d8c773b6a..296160191085 100644 --- a/loader/github.go +++ b/loader/github.go @@ -2,9 +2,14 @@ package loader import "github.com/sirupsen/logrus" -func github(_ logrus.FieldLogger, _ string, parts []string) (string, error) { +func github(logger logrus.FieldLogger, specifier string, parts []string) (string, error) { username := parts[0] repo := parts[1] filepath := parts[2] - return "https://raw.githubusercontent.com/" + username + "/" + repo + "/master/" + filepath, nil + realURL := "https://raw.githubusercontent.com/" + username + "/" + repo + "/master/" + filepath + logger.Warnf(magicURLsDeprecationWarning, specifier, "github", realURL) + return realURL, nil } + +const magicURLsDeprecationWarning = "Specifier %q was resolved to use a none conventional %s loader. " + + "That loader is deprecated and will be removed in v0.53.0. Please use the real URL %q instead." From 7b23ce9df029bd82d581ea058a37bdfa7422f55d Mon Sep 17 00:00:00 2001 From: Mihail Stoykov <312246+mstoykov@users.noreply.github.com> Date: Tue, 2 Apr 2024 12:37:57 +0300 Subject: [PATCH 2/2] Update loader/github.go Co-authored-by: Oleg Bespalov --- loader/github.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/loader/github.go b/loader/github.go index 296160191085..897d10de3d3a 100644 --- a/loader/github.go +++ b/loader/github.go @@ -11,5 +11,5 @@ func github(logger logrus.FieldLogger, specifier string, parts []string) (string return realURL, nil } -const magicURLsDeprecationWarning = "Specifier %q was resolved to use a none conventional %s loader. " + +const magicURLsDeprecationWarning = "Specifier %q resolved to use a non-conventional %s loader. " + "That loader is deprecated and will be removed in v0.53.0. Please use the real URL %q instead."