Skip to content

Commit

Permalink
fix: requested changes
Browse files Browse the repository at this point in the history
Signed-off-by: Soumil Paranjpay <soumil.paranjpay@gmail.com>
  • Loading branch information
Soumil-07 committed Dec 13, 2023
1 parent 7af198a commit ef4a44c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ $(GOX):

.PHONY: build-cross
build-cross: $(GOX) clean $(SRC) $(ASSETS) $(WEB_ASSETS)
CGO_ENABLED=0 $(GOX) -parallel=3 -output="$(DISTDIR)/{{.OS}}-{{.Arch}}/$(BINNAME)" -osarch='$(TARGETS)' -ldflags '$(LDFLAGS)' .
CGO_ENABLED=1 $(GOX) -parallel=3 -output="$(DISTDIR)/{{.OS}}-{{.Arch}}/$(BINNAME)" -osarch='$(TARGETS)' -ldflags '$(LDFLAGS)' .

.PHONY: dist
dist: clean build-cross ## Build distribution
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ require (
github.com/phayes/freeport v0.0.0-20180830031419-95f893ade6f2
github.com/pkg/errors v0.9.1
github.com/qri-io/starlib v0.5.0
github.com/second-state/WasmEdge-go v0.13.0
github.com/sirupsen/logrus v1.9.0
github.com/spf13/cast v1.4.1
github.com/spf13/cobra v1.6.1
Expand Down Expand Up @@ -185,7 +186,6 @@ require (
github.com/robfig/cron v1.2.0 // indirect
github.com/russross/blackfriday v1.6.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/second-state/WasmEdge-go v0.13.0 // indirect
github.com/sergi/go-diff v1.2.0 // indirect
github.com/spf13/afero v1.8.0 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
Expand Down
12 changes: 8 additions & 4 deletions transformer/external/wasmtransformer.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"encoding/binary"
"encoding/json"
"fmt"
"path/filepath"
"sort"
"strings"

Expand Down Expand Up @@ -58,7 +59,7 @@ func (t *WASM) Init(tc transformertypes.Transformer, env *environment.Environmen
t.Env = env
t.WASMConfig = &WASMYamlConfig{}
if err := common.GetObjFromInterface(t.Config.Spec.Config, t.WASMConfig); err != nil {
return fmt.Errorf("unable to load config for Transformer %+v into %T . Error: %q", t.Config.Spec.Config, t.WASMConfig, err)
return fmt.Errorf("unable to load config for Transformer %+v into %T . Error: %w", t.Config.Spec.Config, t.WASMConfig, err)
}

return nil
Expand Down Expand Up @@ -99,7 +100,7 @@ func (t *WASM) DirectoryDetect(dir string) (map[string][]transformertypes.Artifa
memData[len(dir)] = 0
directoryDetectOutput, dderr := vm.Execute("directoryDetect", dirPointer)
if dderr != nil {
err = fmt.Errorf("failed to execute directoryDetect in the wasm module. Error : %s", dderr.Error())
err = fmt.Errorf("failed to execute directoryDetect in the wasm module. Error : %w", dderr)
return nil, err
}
directoryDetectOutputPointer := directoryDetectOutput[0].(int32)
Expand Down Expand Up @@ -203,7 +204,10 @@ func (t *WASM) Transform(newArtifacts []transformertypes.Artifact, alreadySeenAr
}
logrus.Debug(string(memData))
var output transformertypes.TransformOutput
json.Unmarshal(memData, &output)
err = json.Unmarshal(memData, &output)
if err != nil {
return nil, nil, fmt.Errorf("failed to unmarshal transformer output: %w", err)
}
pathMappings = append(pathMappings, output.PathMappings...)
createdArtifacts = append(createdArtifacts, output.CreatedArtifacts...)
return pathMappings, createdArtifacts, err
Expand All @@ -221,7 +225,7 @@ func (t *WASM) initVm(preopens []string) (*wasmedge.VM, error) {
preopens,
)

err := vm.LoadWasmFile(t.WASMConfig.WASMModule)
err := vm.LoadWasmFile(filepath.Join(t.Env.GetEnvironmentContext(), t.WASMConfig.WASMModule))
if err != nil {
return nil, err
}
Expand Down

0 comments on commit ef4a44c

Please sign in to comment.