Skip to content

Commit

Permalink
Merge pull request #74 from grafana/73-support-for-manual-version-num…
Browse files Browse the repository at this point in the history
…ber-configuration

Support for manual version number configuration
  • Loading branch information
szkiba authored Sep 23, 2024
2 parents e979432 + bb4b79e commit dcfbf35
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion cmd/legacy.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func legacyConvert(ctx context.Context) error {

legacyPatch(ext)

repo, tags, err := loadRepository(ctx, ext.Module)
repo, tags, err := loadRepository(ctx, ext)
if err != nil {
return err
}
Expand Down
19 changes: 13 additions & 6 deletions cmd/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,9 @@ func load(ctx context.Context, in io.Reader, loose bool, lint bool) (k6registry.
registry[idx].Categories = append(registry[idx].Categories, k6registry.CategoryMisc)
}

if ext.Repo != nil {
continue
}
ext := ext

repo, tags, err := loadRepository(ctx, ext.Module)
repo, tags, err := loadRepository(ctx, &ext)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -105,8 +103,13 @@ func load(ctx context.Context, in io.Reader, loose bool, lint bool) (k6registry.
return registry, nil
}

func loadRepository(ctx context.Context, module string) (*k6registry.Repository, []string, error) {
slog.Debug("Loading repository", "module", module)
func loadRepository(ctx context.Context, ext *k6registry.Extension) (*k6registry.Repository, []string, error) {
if ext.Versions != nil {
return ext.Repo, ext.Versions, nil
}

module := ext.Module

if strings.HasPrefix(module, k6Module) || strings.HasPrefix(module, ghModulePrefix) {
repo, tags, err := loadGitHub(ctx, module)
if err != nil {
Expand Down Expand Up @@ -150,6 +153,8 @@ func filterVersions(tags []string) []string {
}

func loadGitHub(ctx context.Context, module string) (*k6registry.Repository, []string, error) {
slog.Debug("Loading GitHub repository", "module", module)

client, err := contextGitHubClient(ctx)
if err != nil {
return nil, nil, err
Expand Down Expand Up @@ -217,6 +222,8 @@ func loadGitHub(ctx context.Context, module string) (*k6registry.Repository, []s
}

func loadGitLab(ctx context.Context, module string) (*k6registry.Repository, []string, error) {
slog.Debug("Loading GitLab repository", "module", module)

client, err := gitlab.NewClient("")
if err != nil {
return nil, nil, err
Expand Down

0 comments on commit dcfbf35

Please sign in to comment.