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

Deprecate magic resolving of cdnjs and github "URLs" #3671

Merged
merged 3 commits into from
Apr 2, 2024
Merged
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: 12 additions & 1 deletion loader/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,10 @@ func Load(
data, err := fsext.ReadFile(filesystems[scheme], pathOnFs)

if err == nil {
if moduleSpecifier.Opaque != "" {
loaderName, _, _ := pickLoader(moduleSpecifier.Opaque)
logger.Warnf(magicURLsDeprecationWarning, originalModuleSpecifier, loaderName)
}
return &SourceData{URL: moduleSpecifier, Data: data}, nil
}
if !errors.Is(err, fs.ErrNotExist) {
Expand Down Expand Up @@ -203,13 +207,20 @@ func Load(
return result, nil
}

const (
magicURLsDeprecationWarning = "Specifier %q resolved to use a non-conventional %[2]q loader. " +
"The used %[2]q loader is deprecated and will be removed in k6 v0.53.0."
magicURLsDeprecationWarningExtended = magicURLsDeprecationWarning + " Please use the real URL %q instead."
)

func resolveUsingLoaders(logger logrus.FieldLogger, name string) (*url.URL, error) {
_, loader, loaderArgs := pickLoader(name)
loaderName, loader, loaderArgs := pickLoader(name)
if loader != nil {
urlString, err := loader(logger, name, loaderArgs)
if err != nil {
return nil, err
}
logger.Warnf(magicURLsDeprecationWarningExtended, name, loaderName, urlString)
return url.Parse(urlString)
}

Expand Down
Loading