#Why is Container().File() trying to marshal my file

1 messages · Page 1 of 1 (latest)

lilac shard
#

I am writting a dagger function in go that returns a *File that retrieves a JSON file from a rest API and then calls json.Indent to make it easier to read. The function then writes the file to the dagger container/cache using os.OpenFile and Write. I then call the following line which causes the function to fail:

daggerFile := dag.Container().
File(scanResultsFile)

When I run the function with dagger call function-name I get the following error:

marshal: json: error calling MarshalJSON for type *dagger.File: input: container.file resolve: empty reference. How do I get it to not marshal the data? My plan is to chain it to export or potentially content.

If I am misunderstanding how to perform these types of actions please le tme know a better way.

lilac shard
#

I was able to work with one of my coworkers who provided guidance. I now create the file in an alpine:latest container using WithNewFile. The problem is resolved!