Skip to content

Commit

Permalink
fix: review comments, wording etc.
Browse files Browse the repository at this point in the history
Signed-off-by: Kasper J. Hermansen <[email protected]>
  • Loading branch information
kjuulh committed Jun 13, 2024
1 parent 4328218 commit 5866709
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 26 deletions.
8 changes: 2 additions & 6 deletions internal/extensions/extension.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 0 additions & 2 deletions internal/extensions/extensions.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
38 changes: 20 additions & 18 deletions internal/extensions/registry_index.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 &registryIndex{
Expand All @@ -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
}

Expand All @@ -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"`
}

0 comments on commit 5866709

Please sign in to comment.