#How to use `Directory.export()`

1 messages · Page 1 of 1 (latest)

finite crater
#

I'm using dagger to create a generated OpenAPI client for different languages using a OpenAPI spec I export from my backend build. See https://github.com/Fristi/project-mycelium-v2/blob/main/.dagger/src/index.ts#L88

When I call Directory.export and specify a directory I don't see it show up on my host file system. Even when I supply an absolute path. I've read somewhere that this export is being done on runtime docker container, so that would explain it.

Ideally I would like to use this on my ci target aswell where first the client is generated and then all the other build steps are executed afterwards. Tried this, but also there the same problem. the directory was not found

GitHub

The mycelium project is a plant monitoring system that automatically monitors environmental conditions in households and gardens using IoT edge devices. - Fristi/project-mycelium-v2

azure ice
#

Directory.export does indeed export to the runtime container. You need to use export in the call to Dagger, e.g. for a function build that returns a Directory: dagger call build export --path .

finite crater
#

create-client rust edge-client-backend | export ./edge-client-backend

I see, yes I did that .. so it would involve me to run two GHA steps to do it .. first export and then run ci

azure ice
ancient spindle
# finite crater I'm using dagger to create a generated OpenAPI client for different languages us...

hey Mark! If I understand correctly your pipeline, in order for the ci step to use whatever createClient generates, you shouldn't have to export it to the host. You could do something like:

 const client = await this.createClient();
// do whatever you need with the client here.
 await Promise.all([
    this.buildPeripheral(arch),
    this.testCentral(),
    this.buildBackend(),
    this.testBackend(),
    this.buildApp()
]);
finite crater
ancient spindle
#

that way you can have everything within a single call

#

since IIUC, you're exporting things to the host and then re-importing them in the ci which shouldn't be necessary

finite crater
# ancient spindle that way you can have everything within a single call

Yea I tried that before

    await this.createClient("rust", "edge-client-backend").export("edge-client-backend"); // after executing this, there is no directory `edge-client-backend` being exported.. so the next step fails

    await Promise.all([
      this.buildPeripheral(arch),
      this.testCentral(),
      this.buildBackend(),
      this.buildApp()
    ]);

#

You also pass the reference Directory to the methods like testCentral which requires this edge-client-backend

#

But the setup I have now would reflect the real DX situation now, edge-client-backend is not checked in and should be generated manually by the dev by calling dagger -c ...

ancient spindle
ancient spindle
#

FWIW I've just tried this and indeed doesn't seem to work because indeed /edge-client-backend doesn't exist:

dagger -m github.com/Fristi/project-mycelium-v2 call test-central

ancient spindle
#

hey @finite crater going through my list of unresolved issues and this came up. Mostly checking if there's anything else I can help with here 🙏

stark gyro
#

Hi. Reading through the threads and this one in particular. Exports are note very friendly at the moment : the API is exposed to sdk's but is worthless since it exports only to runtime containers. So it needs to be used on the dagger prompt in our shell directly but : a Directory object in dagger represents exactly which files are there and which are not. But on export it copies stuff without removing files that were not present in the exported directory. So it actually does a merge. Is there a way to leverage dagger properly for generated stuff ? Where files / directories could disappear ?