Skip to content

Commit

Permalink
Add handling of "local-registry"
Browse files Browse the repository at this point in the history
Signed-off-by: C0D3 M4513R <[email protected]>
  • Loading branch information
C0D3-M4513R committed Jun 11, 2024
1 parent d8116fe commit 8e68e50
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions syft/pkg/cataloger/rust/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/go-git/go-git/v5/storage/memory"
"io"
"net/http"
"os"
"strings"
)

Expand Down Expand Up @@ -55,6 +56,13 @@ var RegistryConfig = make(map[string]RepositoryConfig)
const RepositoryConfigName = "config.json"

func (i *SourceId) GetConfig() (*RepositoryConfig, error) {
if i.kind == SourceKindLocalRegistry {
return &RepositoryConfig{
Download: i.url,
API: "",
AuthRequired: false,
}, nil
}
if repoConfig, ok := RegistryConfig[i.url]; ok {
return &repoConfig, nil
}
Expand All @@ -74,6 +82,11 @@ func (i *SourceId) GetConfig() (*RepositoryConfig, error) {
func (i *SourceId) GetPath(path string) ([]byte, error) {
var content []byte
switch i.kind {
case SourceKindLocalRegistry:
if path == RepositoryConfigName {
return nil, nil
}
return os.ReadFile(fmt.Sprintf("%s/index/%s", i.url, path))
case SourceKindSparse:
var resp, err = http.Get(fmt.Sprintf("%s/%s", i.url, path))
if err != nil {
Expand Down

0 comments on commit 8e68e50

Please sign in to comment.