Skip to content
This repository has been archived by the owner on Jun 5, 2024. It is now read-only.

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 <[email protected]>
@dungdm93 dungdm93 force-pushed the handle-unsupported-schema branch from 9ef824b to aef1f64 Compare March 18, 2024 09:50
@dungdm93
Copy link
Author

cc @jonjohnsonjr, @tuananh

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

Successfully merging this pull request may close these issues.

1 participant