Giter Site home page Giter Site logo

Comments (4)

paralin avatar paralin commented on June 2, 2024

I can expose it like this:

// FSConfigWithSysFSMount extends FSConfig to expose the existing WithSysFSMount function.
// https://github.com/tetratelabs/wazero/issues/2076
type FSConfigWithSysFSMount interface {
	WithSysFSMount(fs wazero_sys.FS, guestPath string) wazero.FSConfig
}

var writableFS wazero_sys.FS
fsConf.(FSConfigWithSysFSMount).WithSysFSMount(writableFS, "/")

But this is a runtime type assertion and can't be enforced at compile time, ideally FSConfigWithSysFSMount would be exposed by wazero and type-asserted that fsConfig conforms to that exported interface.

from wazero.

evacchi avatar evacchi commented on June 2, 2024

Admittedly, I think this may not be easy to find, but you should be able to write the following:

import (
	"github.com/tetratelabs/wazero"
	"github.com/tetratelabs/wazero/experimental/sysfs"
)

func main() {
	var sys.FS = ...
	config := wazero.NewFSConfig()
	config.(sysfs.FSConfig).WithSysFSMount(myFs, guestPath)
	...
}

e.g. see

func ExampleAdaptFS() {
m := fstest.MapFS{
"a/b.txt": &fstest.MapFile{Mode: 0o666},
".": &fstest.MapFile{Mode: 0o777 | fs.ModeDir},
}
root := &sysfs.AdaptFS{FS: m}
moduleConfig = wazero.NewModuleConfig().
WithFSConfig(wazero.NewFSConfig().(sysfs.FSConfig).WithSysFSMount(root, "/"))
}

from wazero.

paralin avatar paralin commented on June 2, 2024

Could that just be added to the main FSConfig or perhaps add a NewFSConfig to sysfs which returns sysfs.FSConfig and have the type assertion in wazero? That way we can trust that the type assertion won't panic (covered by wazero tests)

from wazero.

evacchi avatar evacchi commented on June 2, 2024

Eventually, they will. They are not yet because this API has not been tested extensively by our users so far. So, please do play with it and let us know what other roadblocks you encounter :)

from wazero.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.