Skip to content

Commit

Permalink
Maint. Leaving some notes
Browse files Browse the repository at this point in the history
Signed-off-by: Julius Liu <[email protected]>
  • Loading branch information
juliusl committed Apr 18, 2022
1 parent a543fb1 commit 06bcda5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
13 changes: 7 additions & 6 deletions registry/extension/extension.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,23 +57,24 @@ type InitExtensionNamespace func(ctx c.Context, storageDriver driver.StorageDriv

var extensions map[string]InitExtensionNamespace

func EnumerateRegistered() []v2.RouteDescriptor {
descs := make([]v2.RouteDescriptor, 0)
func EnumerateRegistered(ctx context.Context) (repositoryRoutes []v2.RouteDescriptor, registryRoutes []v2.RouteDescriptor) {
for _, ext := range extensions {
namespace, err := ext(context.TODO(), nil, nil)
// TODO: It's probably okay to pass a nil storage driver, but should probably figure out where the extension config is stored and pass that here
namespace, err := ext(ctx, nil, nil)
if err != nil {
registryScoped := namespace.GetRegistryRoutes()
for _, regScoped := range registryScoped {
descs = append(descs, regScoped.Descriptor)
registryRoutes = append(registryRoutes, regScoped.Descriptor)
}

repositoryScoped := namespace.GetRepositoryRoutes()
for _, repScoped := range repositoryScoped {
descs = append(descs, repScoped.Descriptor)
repositoryRoutes = append(repositoryRoutes, repScoped.Descriptor)
}
}
}
return descs

return repositoryRoutes, registryRoutes
}

// Register is used to register an InitExtensionNamespace for
Expand Down
7 changes: 4 additions & 3 deletions registry/extension/oci/discover.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@ func (th *extensionHandler) getExtensions(w http.ResponseWriter, r *http.Request

w.Header().Set("Content-Type", "application/json")

registered := extension.EnumerateRegistered()
// TODO: currently this is only handling repository_routes
repository_routes, _ := extension.EnumerateRegistered(r.Context())

extensions := make([]ociExtension, len(registered))
for _, e := range registered {
extensions := make([]ociExtension, len(repository_routes))
for _, e := range repository_routes {
extensions = append(extensions, ociExtension{Name: e.Name, Description: e.Description, Url: e.Path})
}

Expand Down
1 change: 0 additions & 1 deletion registry/extension/oci/oci.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ type distributionOptions struct {

// newOciNamespace creates a new extension namespace with the name "oci"
func newOciNamespace(ctx context.Context, storageDriver driver.StorageDriver, options configuration.ExtensionConfig) (extension.Namespace, error) {

optionsYaml, err := yaml.Marshal(options)
if err != nil {
return nil, err
Expand Down

0 comments on commit 06bcda5

Please sign in to comment.