diff --git a/internal/extensions/extension.go b/internal/extensions/extension.go index 102f81d..c7afee5 100644 --- a/internal/extensions/extension.go +++ b/internal/extensions/extension.go @@ -18,16 +18,12 @@ type Extension struct { } func newExtensionFromRegistry(globalStore *global.GlobalStore, registryExtension *registryExtension) (*Extension, error) { - os := runtime.GOOS - arch := runtime.GOARCH - return &Extension{ - os: os, - arch: arch, + os: runtime.GOOS, + arch: runtime.GOARCH, globalStore: globalStore, remote: registryExtension, }, nil - } func (e *Extension) Ensure(ctx context.Context) error { diff --git a/internal/extensions/extensions.go b/internal/extensions/extensions.go index 74fd1e7..e77d1f9 100644 --- a/internal/extensions/extensions.go +++ b/internal/extensions/extensions.go @@ -31,9 +31,7 @@ func (e *ExtensionsManager) GetAll(ctx context.Context) ([]Extension, error) { // Install will ensure that all known extensions are installed and ready for use func (e *ExtensionsManager) Install(ctx context.Context) error { registry := getRegistryPath(e.globalStore) - index := newRegistryIndex(registry) - extensions, err := index.getExtensions(ctx) if err != nil { return fmt.Errorf("failed to install extensions, could not get extensions from index: %w", err) diff --git a/internal/extensions/registry_index.go b/internal/extensions/registry_index.go index e87b9b4..e5db77a 100644 --- a/internal/extensions/registry_index.go +++ b/internal/extensions/registry_index.go @@ -9,9 +9,25 @@ import ( "path" ) -type registryIndex struct { - registryPath string -} +type ( + registryIndex struct { + registryPath string + } + + registryExtensionDownloadLink struct { + Architecture string `json:"architecture"` + Os string `json:"os"` + Url string `json:"url"` + Checksum string `json:"checksum"` + } + + registryExtension struct { + Name string `json:"name"` + Description string `json:"description"` + Version string `json:"version"` + DownloadUrls []registryExtensionDownloadLink `json:"downloadUrls"` + } +) func newRegistryIndex(registryPath string) *registryIndex { return ®istryIndex{ @@ -35,7 +51,7 @@ func (r *registryIndex) getExtensions(ctx context.Context) ([]registryExtension, extensionContent, err := os.ReadFile(extensionPath) if err != nil { - log.Printf("failed to get extension: %s, skipping extension", err.Error()) + log.Printf("failed to get extension: %s, skipping extension, the extension might be invalid at: %s, please contact your admin", err.Error(), extensionPath) continue } @@ -53,17 +69,3 @@ func (r *registryIndex) getExtensions(ctx context.Context) ([]registryExtension, func (r *registryIndex) getIndexPath() string { return path.Join(r.registryPath, "index") } - -type registryExtensionDownloadLink struct { - Architecture string `json:"architecture"` - Os string `json:"os"` - Url string `json:"url"` - Checksum string `json:"checksum"` -} - -type registryExtension struct { - Name string `json:"name"` - Description string `json:"description"` - Version string `json:"version"` - DownloadUrls []registryExtensionDownloadLink `json:"downloadUrls"` -}