Skip to content

Commit

Permalink
Couple changes
Browse files Browse the repository at this point in the history
Signed-off-by: Jimmy Moore <[email protected]>
  • Loading branch information
jimmyaxod committed Sep 19, 2023
1 parent 845afa7 commit 7ad49d2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 22 deletions.
33 changes: 16 additions & 17 deletions extension/generator/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ package generator

import (
"bytes"
"encoding/hex"

"github.com/loopholelabs/scale/extension"
"github.com/loopholelabs/scale/extension/generator/golang"
Expand Down Expand Up @@ -57,28 +56,28 @@ type Options struct {
}

func GenerateGuestLocal(options *Options) (*GuestLocalPackage, error) {
hash, err := options.Extension.Hash()
if err != nil {
return nil, err
}
hashString := hex.EncodeToString(hash)
// hash, err := options.Extension.Hash()
// if err != nil {
// return nil, err
// }
// hashString := hex.EncodeToString(hash)

golangTypes, err := golang.GenerateTypes(options.Extension, options.GolangPackageName)
if err != nil {
return nil, err
}

golangGuest, err := golang.GenerateGuest(options.Extension, hashString, options.GolangPackageName)
golangGuest, err := golang.GenerateGuest(options.Extension, options.GolangPackageName, options.GolangPackageVersion)
if err != nil {
return nil, err
}

golangInterfaces, err := golang.GenerateInterfaces(options.Extension, hashString, options.GolangPackageName)
golangInterfaces, err := golang.GenerateInterfaces(options.Extension, options.GolangPackageName, options.GolangPackageVersion)
if err != nil {
return nil, err
}

modfile, err := golang.GenerateModfile(options.GolangPackageImportPath)
modfile, err := golang.GenerateModfile(options.GolangPackageName)
if err != nil {
return nil, err
}
Expand All @@ -96,28 +95,28 @@ func GenerateGuestLocal(options *Options) (*GuestLocalPackage, error) {
}

func GenerateHostLocal(options *Options) (*HostLocalPackage, error) {
hash, err := options.Extension.Hash()
if err != nil {
return nil, err
}
hashString := hex.EncodeToString(hash)
//hash, err := options.Extension.Hash()
//if err != nil {
// return nil, err
//}
//hashString := hex.EncodeToString(hash)

golangTypes, err := golang.GenerateTypes(options.Extension, options.GolangPackageName)
if err != nil {
return nil, err
}

golangHost, err := golang.GenerateHost(options.Extension, hashString, options.GolangPackageName)
golangHost, err := golang.GenerateHost(options.Extension, options.GolangPackageName, options.GolangPackageVersion)
if err != nil {
return nil, err
}

golangInterfaces, err := golang.GenerateInterfaces(options.Extension, hashString, options.GolangPackageName)
golangInterfaces, err := golang.GenerateInterfaces(options.Extension, options.GolangPackageName, options.GolangPackageVersion)
if err != nil {
return nil, err
}

modfile, err := golang.GenerateModfile(options.GolangPackageImportPath)
modfile, err := golang.GenerateModfile(options.GolangPackageName)
if err != nil {
return nil, err
}
Expand Down
10 changes: 5 additions & 5 deletions storage/extension.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,8 @@ func (s *ExtensionStorage) extensionSearch(name string, tag string, org string)

// GenerateExtension generates the extension files and writes them to
// the given path.
func GenerateExtension(sig *extension.Schema, name string, tag string, org string, directory string) error {
encoded, err := sig.Encode()
func GenerateExtension(ext *extension.Schema, name string, tag string, org string, directory string) error {
encoded, err := ext.Encode()
if err != nil {
return err
}
Expand All @@ -303,9 +303,9 @@ func GenerateExtension(sig *extension.Schema, name string, tag string, org strin
}

guestPackage, err := generator.GenerateGuestLocal(&generator.Options{
Extension: sig,
Extension: ext,
GolangPackageImportPath: "extension",
GolangPackageName: "extension",
GolangPackageName: ext.Name,
GolangPackageVersion: "v0.1.0",
})
if err != nil {
Expand All @@ -320,7 +320,7 @@ func GenerateExtension(sig *extension.Schema, name string, tag string, org strin
}

hostPackage, err := generator.GenerateHostLocal(&generator.Options{
Extension: sig,
Extension: ext,
})
if err != nil {
return err
Expand Down

0 comments on commit 7ad49d2

Please sign in to comment.