Skip to content

Commit

Permalink
don't attempt to discover keys for file path repos (#1326)
Browse files Browse the repository at this point in the history
Signed-off-by: Jason Hall <jason@chainguard.dev>
  • Loading branch information
imjasonh authored Oct 1, 2024
1 parent c615b40 commit b485c09
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
11 changes: 10 additions & 1 deletion pkg/apk/apk/implementation.go
Original file line number Diff line number Diff line change
Expand Up @@ -824,7 +824,16 @@ func DiscoverKeys(ctx context.Context, client *http.Client, auth auth.Authentica
ctx, span := otel.Tracer("go-apk").Start(ctx, "DiscoverKeys")
defer span.End()

discoveryRequest, err := http.NewRequestWithContext(ctx, http.MethodGet, fmt.Sprintf("%s/%s", strings.TrimSuffix(repository, "/"), "apk-configuration"), nil)
if !strings.HasPrefix(repository, "https://") && !strings.HasPrefix(repository, "http://") {
// Ignore non-remote repositories.
return nil, nil
}
asURL, err := url.Parse(strings.TrimSuffix(repository, "/") + "/apk-configuration")
if err != nil {
return nil, fmt.Errorf("failed to parse repository URL: %w", err)
}

discoveryRequest, err := http.NewRequestWithContext(ctx, http.MethodGet, asURL.String(), nil)
if err != nil {
return nil, err
}
Expand Down
6 changes: 1 addition & 5 deletions pkg/apk/apk/implementation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,7 @@ func TestInitDB_ChainguardDiscovery(t *testing.T) {
apk, err := New(WithFS(src), WithIgnoreMknodErrors(ignoreMknodErrors))
require.NoError(t, err)

// This is a staging group that was set up to host public images published
// by https://github.com/chainguard-dev/terraform-provider-apko presubmit.
// TODO(mattmoor): Once we push this out to production, we should switch to
// using apk.cgr.dev/chainguard or apk.cgr.dev/extra-packages.
err = apk.InitDB(context.Background(), "https://apk.chainreg.biz/tf-apko.pub")
err = apk.InitDB(context.Background(), "https://apk.cgr.dev/chainguard")
require.NoError(t, err)
// check all of the contents
for _, d := range initDirectories {
Expand Down

0 comments on commit b485c09

Please sign in to comment.