mirror of
https://github.com/portainer/portainer.git
synced 2025-07-19 05:19:39 +02:00
feat(oci): oci helm support [r8s-361] (#787)
This commit is contained in:
parent
b6a6ce9aaf
commit
2697d6c5d7
80 changed files with 4264 additions and 812 deletions
57
pkg/liboras/github_listrepo_client.go
Normal file
57
pkg/liboras/github_listrepo_client.go
Normal file
|
@ -0,0 +1,57 @@
|
|||
package liboras
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
portainer "github.com/portainer/portainer/api"
|
||||
"github.com/portainer/portainer/api/http/proxy/factory/github"
|
||||
"github.com/rs/zerolog/log"
|
||||
)
|
||||
|
||||
// GithubListRepoClient implements RepositoryListClient specifically for GitHub registries
|
||||
// This client handles the GitHub Packages API's unique repository listing implementation
|
||||
type GithubListRepoClient struct {
|
||||
registry *portainer.Registry
|
||||
client *github.Client
|
||||
}
|
||||
|
||||
// NewGithubListRepoClient creates a new GitHub repository listing client
|
||||
func NewGithubListRepoClient(registry *portainer.Registry) *GithubListRepoClient {
|
||||
// Prefer the management configuration credentials when available
|
||||
token := registry.Password
|
||||
if registry.ManagementConfiguration != nil && registry.ManagementConfiguration.Password != "" {
|
||||
token = registry.ManagementConfiguration.Password
|
||||
}
|
||||
|
||||
client := github.NewClient(token)
|
||||
|
||||
return &GithubListRepoClient{
|
||||
registry: registry,
|
||||
client: client,
|
||||
}
|
||||
}
|
||||
|
||||
// ListRepositories fetches repositories from a GitHub registry using the GitHub Packages API
|
||||
func (c *GithubListRepoClient) ListRepositories(ctx context.Context) ([]string, error) {
|
||||
repositories, err := c.client.GetContainerPackages(
|
||||
ctx,
|
||||
c.registry.Github.UseOrganisation,
|
||||
c.registry.Github.OrganisationName,
|
||||
)
|
||||
if err != nil {
|
||||
log.Error().
|
||||
Str("registry_name", c.registry.Name).
|
||||
Err(err).
|
||||
Msg("Failed to list GitHub repositories")
|
||||
return nil, fmt.Errorf("failed to list GitHub repositories: %w", err)
|
||||
}
|
||||
|
||||
log.Debug().
|
||||
Bool("use_organisation", c.registry.Github.UseOrganisation).
|
||||
Str("organisation_name", c.registry.Github.OrganisationName).
|
||||
Int("repository_count", len(repositories)).
|
||||
Msg("Successfully listed GitHub repositories")
|
||||
|
||||
return repositories, nil
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue