Skip to content

Commit

Permalink
registry: fix specific version not parsed
Browse files Browse the repository at this point in the history
  • Loading branch information
ImSingee committed Jan 4, 2024
1 parent 9f0c015 commit c7aef71
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
6 changes: 6 additions & 0 deletions internal/extension-registry/get.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package extregistry

import (
"log/slog"
"net/http"
"net/url"
"os"
Expand All @@ -13,16 +14,21 @@ import (

// GetAppVersion will get the app and version from registry
func GetAppVersion(app string, version string) (*App, *Version, error) {
slog.Debug("GetAppVersion", "app", app, "version", version)
a, err := GetApp(app)
if err != nil {
return nil, nil, ee.Wrapf(err, "cannot get app %s from registry", app)
}
slog.Debug("GetApp", "app", app, "parsed", a)

if realVersion := a.Tags[version]; realVersion != "" {
slog.Debug("map tag version", "previous", version, "to", realVersion)

version = realVersion
}

v, err := a.parseVersion(version)
slog.Debug("parse version", "version", version, "parsed", v)
if err != nil {
if ee.Is(err, ErrVersionNotExist) {
v := &Version{
Expand Down
4 changes: 4 additions & 0 deletions internal/extension-registry/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package extregistry

import (
"fmt"
"log/slog"

"github.com/ImSingee/go-ex/ee"
"github.com/ImSingee/go-ex/pp"
Expand All @@ -14,6 +15,7 @@ import (
)

func (a *App) installUnknownVersionTo(version string, dst string) error {
slog.Debug("app installUnknownVersionTo", "version", version, "dst", dst)
o := &installer.InstallOptions{
Version: version,
To: dst,
Expand All @@ -33,10 +35,12 @@ func (a *App) installUnknownVersionTo(version string, dst string) error {
}

func (v *Version) InstallUnknownVersionTo(dst string) error {
slog.Debug("version installUnknownVersionTo", "dst", dst)
return v.App.installUnknownVersionTo(v.Version, dst)
}

func (v *Version) InstallTo(dst string) error {
slog.Debug("version InstallTo", "version", v, "dst", dst)
o := &installer.InstallOptions{
Version: v.Version,
To: dst,
Expand Down
9 changes: 9 additions & 0 deletions internal/extension-registry/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package extregistry

import (
"fmt"
"log/slog"
"strings"

"github.com/ImSingee/go-ex/ee"
Expand All @@ -10,6 +11,8 @@ import (
)

func parseApp(name string, in eroptions.AnyOptions) (*App, error) {
slog.Debug("parseApp", "in", in)

a := &App{
Name: name,
}
Expand Down Expand Up @@ -48,6 +51,8 @@ func parseApp(name string, in eroptions.AnyOptions) (*App, error) {
parsedVersions := make(map[string]eroptions.AnyOptions, len(versions))

for version, v := range versions {
slog.Debug("parseVersion", "in", v)

v, ok := v.(map[string]any)
if !ok {
parsedVersions[version] = eroptions.AsAnyOptions(map[string]any{
Expand All @@ -57,6 +62,8 @@ func parseApp(name string, in eroptions.AnyOptions) (*App, error) {
parsedVersions[version] = eroptions.AsAnyOptions(v)
}
}

a.Versions = parsedVersions
}

installOptions := eroptions.AnyOptions{}
Expand All @@ -67,6 +74,8 @@ func parseApp(name string, in eroptions.AnyOptions) (*App, error) {
}
a.InstallOptions = installOptions

slog.Debug("parseApp", "parsed", a)

return a, nil
}

Expand Down

0 comments on commit c7aef71

Please sign in to comment.