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

handle unsupported schema correctly #225

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

dungdm93
Copy link

@dungdm93 dungdm93 commented Mar 18, 2024

I try to create Docker image with this apko.yaml config:

contents:
  repositories:
    - https://packages.wolfi.dev/os
    - http://172.18.0.2:8081/repository/apk
  keyring:
    - https://packages.wolfi.dev/os/wolfi-signing.rsa.pub
    - http://172.18.0.2:8081/repository/apk/melange.rsa.pub
  packages:
    ....

And got weird error message:

2024/03/18 14:32:13 INFO Building images for 1 architectures: [amd64]
Error: initializing apk: failed to initialize apk keyring: failed to read apk key: open http://172.18.0.2:8081/repository/apk/melange.rsa.pub: no such file or directory
2024/03/18 14:32:14 INFO error during command execution: initializing apk: failed to initialize apk keyring: failed to read apk key: open http://172.18.0.2:8081/repository/apk/melange.rsa.pub: no such file or directory

This is because this code tread all non-https URL as file:

if strings.HasPrefix(element, "https://") {
asURL, err = url.Parse(element)
} else {
// Attempt to parse non-https elements into URI's so they are translated into
// file:// URLs allowing them to parse into a url.URL{}
asURL, err = url.Parse(string(uri.New(element)))
}
if err != nil {
return fmt.Errorf("failed to parse key as URI: %w", err)
}

and this line is never reached:

default:
return fmt.Errorf("scheme %s not supported", asURL.Scheme)

@dungdm93 dungdm93 force-pushed the handle-unsupported-schema branch 3 times, most recently from ff303f2 to 9ef824b Compare March 18, 2024 09:13
Signed-off-by: Đặng Minh Dũng <dungdm93@live.com>
@dungdm93
Copy link
Author

cc @jonjohnsonjr, @tuananh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant