status
stringclasses
1 value
repo_name
stringclasses
31 values
repo_url
stringclasses
31 values
issue_id
int64
1
104k
title
stringlengths
4
233
body
stringlengths
0
186k
issue_url
stringlengths
38
56
pull_url
stringlengths
37
54
before_fix_sha
stringlengths
40
40
after_fix_sha
stringlengths
40
40
report_datetime
timestamp[us, tz=UTC]
language
stringclasses
5 values
commit_datetime
timestamp[us, tz=UTC]
updated_file
stringlengths
7
188
chunk_content
stringlengths
1
1.03M
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/integration/module_test.go
With(daggerExec("mod", "init", "--name=hasDaggerTypes", "--sdk=go")) logGen(ctx, t, modGen.Directory(".")) out, err := modGen. With(daggerQuery(`{hasDaggerTypes{hello{stdout}}}`)). Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"hasDaggerTypes":{"hello":{"stdout":"Hello, world!\n"}}}`, out) }) t.Run("respects existing package without creating main.go", func(t *testing.T) { t.Parallel() c, ctx := connect(t) modGen := c.Container().From(golangImage). WithMountedFile(testCLIBinPath, daggerCliFile(t, c)). WithWorkdir("/work"). WithNewFile("/work/notmain.go", dagger.ContainerWithNewFileOpts{ Contents: `package main type HasNotMainGo struct {} func (m *HasNotMainGo) Hello() string { return "Hello, world!" } `, }). With(daggerExec("mod", "init", "--name=hasNotMainGo", "--sdk=go")) logGen(ctx, t, modGen.Directory(".")) out, err := modGen. With(daggerQuery(`{hasNotMainGo{hello}}`)). Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"hasNotMainGo":{"hello":"Hello, world!"}}`, out) }) } func TestModulePythonInit(t *testing.T) {
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/integration/module_test.go
t.Run("from scratch", func(t *testing.T) { t.Parallel() c, ctx := connect(t) modGen := c.Container().From(golangImage). WithMountedFile(testCLIBinPath, daggerCliFile(t, c)). WithWorkdir("/work"). With(daggerExec("mod", "init", "--name=bare", "--sdk=python")) out, err := modGen. With(daggerQuery(`{bare{containerEcho(stringArg:"hello"){stdout}}}`)). Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"bare":{"containerEcho":{"stdout":"hello\n"}}}`, out) }) t.Run("with different root", func(t *testing.T) { t.Parallel() c, ctx := connect(t) modGen := c.Container().From(golangImage). WithMountedFile(testCLIBinPath, daggerCliFile(t, c)). WithWorkdir("/work"). With(daggerExec("mod", "init", "-m=child", "--name=bare", "--sdk=python")) out, err := modGen. With(daggerQueryAt("child", `{bare{containerEcho(stringArg:"hello"){stdout}}}`)). Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"bare":{"containerEcho":{"stdout":"hello\n"}}}`, out) }) t.Run("respects existing pyproject.toml", func(t *testing.T) { t.Parallel() c, ctx := connect(t) modGen := c.Container().From(golangImage).
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/integration/module_test.go
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)). WithWorkdir("/work"). WithNewFile("pyproject.toml", dagger.ContainerWithNewFileOpts{ Contents: `[project] name = "has-pyproject" version = "0.0.0" `, }). With(daggerExec("mod", "init", "--name=hasPyproject", "--sdk=python")) out, err := modGen. With(daggerQuery(`{hasPyproject{containerEcho(stringArg:"hello"){stdout}}}`)). Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"hasPyproject":{"containerEcho":{"stdout":"hello\n"}}}`, out) t.Run("preserves module name", func(t *testing.T) { generated, err := modGen.File("pyproject.toml").Contents(ctx) require.NoError(t, err) require.Contains(t, generated, `name = "has-pyproject"`) }) }) t.Run("respects existing main.py", func(t *testing.T) { t.Parallel() c, ctx := connect(t) modGen := c.Container().From(golangImage). WithMountedFile(testCLIBinPath, daggerCliFile(t, c)). WithWorkdir("/work"). WithNewFile("/work/src/main/__init__.py", dagger.ContainerWithNewFileOpts{ Contents: "from . import notmain\n", }). WithNewFile("/work/src/main/notmain.py", dagger.ContainerWithNewFileOpts{
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/integration/module_test.go
Contents: `from dagger import function @function def hello() -> str: return "Hello, world!" `, }). With(daggerExec("mod", "init", "--name=hasMainPy", "--sdk=python")) out, err := modGen. With(daggerQuery(`{hasMainPy{hello}}`)). Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"hasMainPy":{"hello":"Hello, world!"}}`, out) }) t.Run("uses expected field casing", func(t *testing.T) { t.Parallel() c, ctx := connect(t) modGen := c.Container().From(golangImage). WithMountedFile(testCLIBinPath, daggerCliFile(t, c)). WithWorkdir("/work"). With(daggerExec("mod", "init", "--name=hello-world", "--sdk=python")). With(sdkSource("python", `from dagger import field, function, object_type @object_type class HelloWorld: my_name: str = field(default="World") @function def message(self) -> str: return f"Hello, {self.my_name}!" `, )) out, err := modGen.
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/integration/module_test.go
With(daggerQuery(`{helloWorld(myName: "Monde"){message}}`)). Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"helloWorld":{"message":"Hello, Monde!"}}`, out) }) } func TestModuleInitLICENSE(t *testing.T) { t.Run("bootstraps Apache-2.0 LICENSE file if none found", func(t *testing.T) { t.Parallel() c, ctx := connect(t) modGen := c.Container().From(golangImage). WithMountedFile(testCLIBinPath, daggerCliFile(t, c)). WithWorkdir("/work"). With(daggerExec("mod", "init", "--name=licensed-to-ill", "--sdk=go")) content, err := modGen.File("LICENSE").Contents(ctx) require.NoError(t, err) require.Contains(t, content, "Apache License, Version 2.0") }) t.Run("creates LICENSE file in the directory specified by -m", func(t *testing.T) { t.Parallel() c, ctx := connect(t) modGen := c.Container().From(golangImage). WithMountedFile(testCLIBinPath, daggerCliFile(t, c)). WithWorkdir("/work"). With(daggerExec("mod", "init", "-m", "./mymod", "--name=licensed-to-ill", "--sdk=go")) content, err := modGen.File("mymod/LICENSE").Contents(ctx) require.NoError(t, err) require.Contains(t, content, "Apache License, Version 2.0") }) t.Run("does not bootstrap LICENSE file if it exists in the parent dir", func(t *testing.T) {
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/integration/module_test.go
t.Parallel() c, ctx := connect(t) modGen := c.Container().From(golangImage). WithMountedFile(testCLIBinPath, daggerCliFile(t, c)). WithWorkdir("/work"). WithNewFile("/work/LICENSE", dagger.ContainerWithNewFileOpts{ Contents: "doesnt matter", }). WithWorkdir("/work/sub"). With(daggerExec("mod", "init", "--name=licensed-to-ill", "--sdk=go")) _, err := modGen.File("LICENSE").Contents(ctx) require.Error(t, err) }) t.Run("bootstraps a LICENSE file when requested, even if it exists in the parent dir", func(t *testing.T) { t.Parallel() c, ctx := connect(t) modGen := c.Container().From(golangImage). WithMountedFile(testCLIBinPath, daggerCliFile(t, c)). WithWorkdir("/work"). WithNewFile("/work/LICENSE", dagger.ContainerWithNewFileOpts{ Contents: "doesnt matter", }). WithWorkdir("/work/sub"). With(daggerExec("mod", "init", "--name=licensed-to-ill", "--sdk=go", "--license=MIT")) content, err := modGen.File("LICENSE").Contents(ctx) require.NoError(t, err) require.Contains(t, content, "MIT License") }) } func TestModuleGit(t *testing.T) {
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/integration/module_test.go
t.Parallel() type testCase struct { sdk string gitGeneratedFiles []string gitIgnoredFiles []string } for _, tc := range []testCase{ { sdk: "go", gitGeneratedFiles: []string{ "/dagger.gen.go", "/querybuilder/**", }, }, { sdk: "python", gitGeneratedFiles: []string{ "/sdk/**", }, gitIgnoredFiles: []string{ "/sdk", }, }, { sdk: "typescript",
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/integration/module_test.go
gitGeneratedFiles: []string{ "/sdk/**", }, gitIgnoredFiles: []string{ "/sdk", }, }, } { tc := tc t.Run(fmt.Sprintf("module %s git", tc.sdk), func(t *testing.T) { t.Parallel() c, ctx := connect(t) modGen := goGitBase(t, c). With(daggerExec("mod", "init", "--name=bare", "--sdk="+tc.sdk)) if tc.sdk == "go" { logGen(ctx, t, modGen.Directory(".")) } out, err := modGen. With(daggerQuery(`{bare{containerEcho(stringArg:"hello"){stdout}}}`)). Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"bare":{"containerEcho":{"stdout":"hello\n"}}}`, out) t.Run("configures .gitattributes", func(t *testing.T) { ignore, err := modGen.File(".gitattributes").Contents(ctx) require.NoError(t, err) for _, fileName := range tc.gitGeneratedFiles { require.Contains(t, ignore, fmt.Sprintf("%s linguist-generated\n", fileName)) } }) if len(tc.gitIgnoredFiles) > 0 {
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/integration/module_test.go
t.Run("configures .gitignore", func(t *testing.T) { ignore, err := modGen.File(".gitignore").Contents(ctx) require.NoError(t, err) for _, fileName := range tc.gitIgnoredFiles { require.Contains(t, ignore, fileName) } }) } }) } } var goSignatures string func TestModuleGoSignatures(t *testing.T) { t.Parallel() c, ctx := connect(t) modGen := c.Container().From(golangImage). WithMountedFile(testCLIBinPath, daggerCliFile(t, c)). WithWorkdir("/work"). With(daggerExec("mod", "init", "--name=minimal", "--sdk=go")). WithNewFile("main.go", dagger.ContainerWithNewFileOpts{ Contents: goSignatures, }) logGen(ctx, t, modGen.Directory(".")) t.Run("func Hello() string", func(t *testing.T) { out, err := modGen.With(daggerQuery(`{minimal{hello}}`)).Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"minimal":{"hello":"hello"}}`, out) }) t.Run("func Echo(string) string", func(t *testing.T) { out, err := modGen.With(daggerQuery(`{minimal{echo(msg: "hello")}}`)).Stdout(ctx)
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/integration/module_test.go
require.NoError(t, err) require.JSONEq(t, `{"minimal":{"echo":"hello...hello...hello..."}}`, out) }) t.Run("func EchoPointer(*string) string", func(t *testing.T) { out, err := modGen.With(daggerQuery(`{minimal{echoPointer(msg: "hello")}}`)).Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"minimal":{"echoPointer":"hello...hello...hello..."}}`, out) }) t.Run("func EchoPointerPointer(**string) string", func(t *testing.T) { out, err := modGen.With(daggerQuery(`{minimal{echoPointerPointer(msg: "hello")}}`)).Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"minimal":{"echoPointerPointer":"hello...hello...hello..."}}`, out) }) t.Run("func EchoOptional(string) string", func(t *testing.T) { out, err := modGen.With(daggerQuery(`{minimal{echoOptional(msg: "hello")}}`)).Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"minimal":{"echoOptional":"hello...hello...hello..."}}`, out) out, err = modGen.With(daggerQuery(`{minimal{echoOptional}}`)).Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"minimal":{"echoOptional":"default...default...default..."}}`, out) }) t.Run("func EchoOptionalPointer(string) string", func(t *testing.T) { out, err := modGen.With(daggerQuery(`{minimal{echoOptionalPointer(msg: "hello")}}`)).Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"minimal":{"echoOptionalPointer":"hello...hello...hello..."}}`, out) out, err = modGen.With(daggerQuery(`{minimal{echoOptionalPointer}}`)).Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"minimal":{"echoOptionalPointer":"default...default...default..."}}`, out) }) t.Run("func EchoOptionalSlice([]string) string", func(t *testing.T) {
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/integration/module_test.go
out, err := modGen.With(daggerQuery(`{minimal{echoOptionalSlice(msg: ["hello", "there"])}}`)).Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"minimal":{"echoOptionalSlice":"hello+there...hello+there...hello+there..."}}`, out) out, err = modGen.With(daggerQuery(`{minimal{echoOptionalSlice}}`)).Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"minimal":{"echoOptionalSlice":"foobar...foobar...foobar..."}}`, out) }) t.Run("func Echoes([]string) []string", func(t *testing.T) { out, err := modGen.With(daggerQuery(`{minimal{echoes(msgs: ["hello"])}}`)).Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"minimal":{"echoes":["hello...hello...hello..."]}}`, out) }) t.Run("func EchoesVariadic(...string) string", func(t *testing.T) { out, err := modGen.With(daggerQuery(`{minimal{echoesVariadic(msgs: ["hello"])}}`)).Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"minimal":{"echoesVariadic":"hello...hello...hello..."}}`, out) }) t.Run("func HelloContext(context.Context) string", func(t *testing.T) { out, err := modGen.With(daggerQuery(`{minimal{helloContext}}`)).Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"minimal":{"helloContext":"hello context"}}`, out) }) t.Run("func EchoContext(context.Context, string) string", func(t *testing.T) { out, err := modGen.With(daggerQuery(`{minimal{echoContext(msg: "hello")}}`)).Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"minimal":{"echoContext":"ctx.hello...ctx.hello...ctx.hello..."}}`, out) }) t.Run("func HelloStringError() (string, error)", func(t *testing.T) { out, err := modGen.With(daggerQuery(`{minimal{helloStringError}}`)).Stdout(ctx) require.NoError(t, err)
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/integration/module_test.go
require.JSONEq(t, `{"minimal":{"helloStringError":"hello i worked"}}`, out) }) t.Run("func HelloVoid()", func(t *testing.T) { out, err := modGen.With(daggerQuery(`{minimal{helloVoid}}`)).Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"minimal":{"helloVoid":null}}`, out) }) t.Run("func HelloVoidError() error", func(t *testing.T) { out, err := modGen.With(daggerQuery(`{minimal{helloVoidError}}`)).Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"minimal":{"helloVoidError":null}}`, out) }) t.Run("func EchoOpts(string, string, int) error", func(t *testing.T) { out, err := modGen.With(daggerQuery(`{minimal{echoOpts(msg: "hi")}}`)).Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"minimal":{"echoOpts":"hi"}}`, out) out, err = modGen.With(daggerQuery(`{minimal{echoOpts(msg: "hi", suffix: "!", times: 2)}}`)).Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"minimal":{"echoOpts":"hi!hi!"}}`, out) }) t.Run("func EchoOptsInline(struct{string, string, int}) error", func(t *testing.T) { out, err := modGen.With(daggerQuery(`{minimal{echoOptsInline(msg: "hi")}}`)).Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"minimal":{"echoOptsInline":"hi"}}`, out) out, err = modGen.With(daggerQuery(`{minimal{echoOptsInline(msg: "hi", suffix: "!", times: 2)}}`)).Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"minimal":{"echoOptsInline":"hi!hi!"}}`, out) }) t.Run("func EchoOptsInlinePointer(*struct{string, string, int}) error", func(t *testing.T) { out, err := modGen.With(daggerQuery(`{minimal{echoOptsInlinePointer(msg: "hi")}}`)).Stdout(ctx)
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/integration/module_test.go
require.NoError(t, err) require.JSONEq(t, `{"minimal":{"echoOptsInlinePointer":"hi"}}`, out) out, err = modGen.With(daggerQuery(`{minimal{echoOptsInlinePointer(msg: "hi", suffix: "!", times: 2)}}`)).Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"minimal":{"echoOptsInlinePointer":"hi!hi!"}}`, out) }) t.Run("func EchoOptsInlineCtx(ctx, struct{string, string, int}) error", func(t *testing.T) { out, err := modGen.With(daggerQuery(`{minimal{echoOptsInlineCtx(msg: "hi")}}`)).Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"minimal":{"echoOptsInlineCtx":"hi"}}`, out) out, err = modGen.With(daggerQuery(`{minimal{echoOptsInlineCtx(msg: "hi", suffix: "!", times: 2)}}`)).Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"minimal":{"echoOptsInlineCtx":"hi!hi!"}}`, out) }) t.Run("func EchoOptsInlineTags(struct{string, string, int}) error", func(t *testing.T) { out, err := modGen.With(daggerQuery(`{minimal{echoOptsInlineTags(msg: "hi")}}`)).Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"minimal":{"echoOptsInlineTags":"hi"}}`, out) out, err = modGen.With(daggerQuery(`{minimal{echoOptsInlineTags(msg: "hi", suffix: "!", times: 2)}}`)).Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"minimal":{"echoOptsInlineTags":"hi!hi!"}}`, out) }) t.Run("func EchoOptsPragmas(string, string, int) error", func(t *testing.T) { out, err := modGen.With(daggerQuery(`{minimal{echoOptsPragmas(msg: "hi")}}`)).Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"minimal":{"echoOptsPragmas":"hi...hi...hi..."}}`, out) }) } var tsSignatures string func TestModuleTypescriptSignatures(t *testing.T) {
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/integration/module_test.go
t.Parallel() c, ctx := connect(t) modGen := c.Container().From(golangImage). WithMountedFile(testCLIBinPath, daggerCliFile(t, c)). WithWorkdir("/work"). With(daggerExec("mod", "init", "--name=minimal", "--sdk=typescript")). WithNewFile("src/index.ts", dagger.ContainerWithNewFileOpts{ Contents: tsSignatures, }) t.Run("hello(): string", func(t *testing.T) { out, err := modGen.With(daggerQuery(`{minimal{hello}}`)).Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"minimal":{"hello":"hello"}}`, out) }) t.Run("echoes(msgs: string[]): string[]", func(t *testing.T) { out, err := modGen.With(daggerQuery(`{minimal{echoes(msgs: ["hello"])}}`)).Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"minimal":{"echoes":["hello...hello...hello..."]}}`, out) }) t.Run("echoOptional(msg = 'default'): string", func(t *testing.T) { out, err := modGen.With(daggerQuery(`{minimal{echoOptional(msg: "hello")}}`)).Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"minimal":{"echoOptional":"hello...hello...hello..."}}`, out)
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/integration/module_test.go
out, err = modGen.With(daggerQuery(`{minimal{echoOptional}}`)).Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"minimal":{"echoOptional":"default...default...default..."}}`, out) }) t.Run("echoesVariadic(...msgs: string[]): string", func(t *testing.T) { out, err := modGen.With(daggerQuery(`{minimal{echoesVariadic(msgs: ["hello"])}}`)).Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"minimal":{"echoesVariadic":"hello...hello...hello..."}}`, out) }) t.Run("echo(msg: string): string", func(t *testing.T) { out, err := modGen.With(daggerQuery(`{minimal{echo(msg: "hello")}}`)).Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"minimal":{"echo":"hello...hello...hello..."}}`, out) }) t.Run("echoOptionalSlice(msg = ['foobar']): string", func(t *testing.T) { out, err := modGen.With(daggerQuery(`{minimal{echoOptionalSlice(msg: ["hello", "there"])}}`)).Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"minimal":{"echoOptionalSlice":"hello+there...hello+there...hello+there..."}}`, out) out, err = modGen.With(daggerQuery(`{minimal{echoOptionalSlice}}`)).Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"minimal":{"echoOptionalSlice":"foobar...foobar...foobar..."}}`, out) }) t.Run("helloVoid(): void", func(t *testing.T) { out, err := modGen.With(daggerQuery(`{minimal{helloVoid}}`)).Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"minimal":{"helloVoid":null}}`, out) }) t.Run("echoOpts(msg: string, suffix: string = '', times: number = 1): string", func(t *testing.T) { out, err := modGen.With(daggerQuery(`{minimal{echoOpts(msg: "hi")}}`)).Stdout(ctx) require.NoError(t, err)
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/integration/module_test.go
require.JSONEq(t, `{"minimal":{"echoOpts":"hi"}}`, out) out, err = modGen.With(daggerQuery(`{minimal{echoOpts(msg: "hi", suffix: "!", times: 2)}}`)).Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"minimal":{"echoOpts":"hi!hi!"}}`, out) t.Run("execute with unordered args", func(t *testing.T) { out, err = modGen.With(daggerQuery(`{minimal{echoOpts(times: 2, msg: "order", suffix: "?")}}`)).Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"minimal":{"echoOpts":"order?order?"}}`, out) }) }) t.Run("echoMaybe(msg: string, isQuestion = false): string", func(t *testing.T) { out, err := modGen.With(daggerQuery(`{minimal{echoMaybe(msg: "hi")}}`)).Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"minimal":{"echoMaybe":"hi...hi...hi..."}}`, out) out, err = modGen.With(daggerQuery(`{minimal{echoMaybe(msg: "hi", isQuestion: true)}}`)).Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"minimal":{"echoMaybe":"hi?...hi?...hi?..."}}`, out) t.Run("execute with unordered args", func(t *testing.T) { out, err = modGen.With(daggerQuery(`{minimal{echoMaybe(isQuestion: false, msg: "hi")}}`)).Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"minimal":{"echoMaybe":"hi...hi...hi..."}}`, out) }) }) } func TestModuleGoSignaturesBuiltinTypes(t *testing.T) { t.Parallel() c, ctx := connect(t) modGen := c.Container().From(golangImage). WithMountedFile(testCLIBinPath, daggerCliFile(t, c)). WithWorkdir("/work").
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/integration/module_test.go
With(daggerExec("mod", "init", "--name=minimal", "--sdk=go")). WithNewFile("main.go", dagger.ContainerWithNewFileOpts{ Contents: `package main import "context" type Minimal struct {} func (m *Minimal) Read(ctx context.Context, dir Directory) (string, error) { return dir.File("foo").Contents(ctx) } func (m *Minimal) ReadPointer(ctx context.Context, dir *Directory) (string, error) { return dir.File("foo").Contents(ctx) } func (m *Minimal) ReadSlice(ctx context.Context, dir []Directory) (string, error) { return dir[0].File("foo").Contents(ctx) } func (m *Minimal) ReadVariadic(ctx context.Context, dir ...Directory) (string, error) { return dir[0].File("foo").Contents(ctx) } func (m *Minimal) ReadOptional(ctx context.Context, dir Optional[Directory]) (string, error) { d, ok := dir.Get() if ok { return d.File("foo").Contents(ctx) } return "", nil } `, }) logGen(ctx, t, modGen.Directory(".")) out, err := modGen.With(daggerQuery(`{directory{withNewFile(path: "foo", contents: "bar"){id}}}`)).Stdout(ctx) require.NoError(t, err) dirID := gjson.Get(out, "directory.withNewFile.id").String()
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/integration/module_test.go
t.Run("func Read(ctx, Directory) (string, error)", func(t *testing.T) { out, err := modGen.With(daggerQuery(fmt.Sprintf(`{minimal{read(dir: "%s")}}`, dirID))).Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"minimal":{"read":"bar"}}`, out) }) t.Run("func ReadPointer(ctx, *Directory) (string, error)", func(t *testing.T) { out, err := modGen.With(daggerQuery(fmt.Sprintf(`{minimal{readPointer(dir: "%s")}}`, dirID))).Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"minimal":{"readPointer":"bar"}}`, out) }) t.Run("func ReadSlice(ctx, []Directory) (string, error)", func(t *testing.T) { out, err := modGen.With(daggerQuery(fmt.Sprintf(`{minimal{readSlice(dir: ["%s"])}}`, dirID))).Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"minimal":{"readSlice":"bar"}}`, out) }) t.Run("func ReadVariadic(ctx, ...Directory) (string, error)", func(t *testing.T) { out, err := modGen.With(daggerQuery(fmt.Sprintf(`{minimal{readVariadic(dir: ["%s"])}}`, dirID))).Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"minimal":{"readVariadic":"bar"}}`, out) }) t.Run("func ReadOptional(ctx, Optional[Directory]) (string, error)", func(t *testing.T) { out, err := modGen.With(daggerQuery(fmt.Sprintf(`{minimal{readOptional(dir: "%s")}}`, dirID))).Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"minimal":{"readOptional":"bar"}}`, out) out, err = modGen.With(daggerQuery(`{minimal{readOptional}}`)).Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"minimal":{"readOptional":""}}`, out) }) } func TestModuleGoSignaturesUnexported(t *testing.T) {
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/integration/module_test.go
t.Parallel() var logs safeBuffer c, ctx := connect(t, dagger.WithLogOutput(&logs)) modGen := c.Container().From(golangImage). WithMountedFile(testCLIBinPath, daggerCliFile(t, c)). WithWorkdir("/work"). With(daggerExec("mod", "init", "--name=minimal", "--sdk=go")). WithNewFile("main.go", dagger.ContainerWithNewFileOpts{ Contents: `package main type Minimal struct {} type Foo struct {} type bar struct {} func (m *Minimal) Hello(name string) string { return name } func (f *Foo) Hello(name string) string { return name } func (b *bar) Hello(name string) string { return name } `, }) logGen(ctx, t, modGen.Directory(".")) out, err := modGen.With(inspectModule).Stdout(ctx) require.NoError(t, err) objs := gjson.Get(out, "host.directory.asModule.initialize.objects") require.Equal(t, 1, len(objs.Array()))
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/integration/module_test.go
minimal := objs.Get(`0.asObject`) require.Equal(t, "Minimal", minimal.Get("name").String()) modGen = c.Container().From(golangImage). WithMountedFile(testCLIBinPath, daggerCliFile(t, c)). WithWorkdir("/work"). With(daggerExec("mod", "init", "--name=minimal", "--sdk=go")). WithNewFile("main.go", dagger.ContainerWithNewFileOpts{ Contents: `package main type Minimal struct {} type Foo struct {} type bar struct {} func (m *Minimal) Hello(name string) Foo { return Foo{} } func (f *Foo) Hello(name string) string { return name } func (b *bar) Hello(name string) string { return name } `, }) logGen(ctx, t, modGen.Directory(".")) out, err = modGen.With(inspectModule).Stdout(ctx) require.NoError(t, err) objs = gjson.Get(out, "host.directory.asModule.initialize.objects") require.Equal(t, 2, len(objs.Array())) minimal = objs.Get(`0.asObject`) require.Equal(t, "Minimal", minimal.Get("name").String()) foo := objs.Get(`1.asObject`)
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/integration/module_test.go
require.Equal(t, "MinimalFoo", foo.Get("name").String()) modGen = c.Container().From(golangImage). WithMountedFile(testCLIBinPath, daggerCliFile(t, c)). WithWorkdir("/work"). With(daggerExec("mod", "init", "--name=minimal", "--sdk=go")). WithNewFile("main.go", dagger.ContainerWithNewFileOpts{ Contents: `package main type Minimal struct {} type Foo struct { Bar bar } type bar struct {} func (m *Minimal) Hello(name string) Foo { return Foo{} } func (f *Foo) Hello(name string) string { return name } func (b *bar) Hello(name string) string { return name } `, }) logGen(ctx, t, modGen.Directory(".")) _, err = modGen.With(inspectModule).Stderr(ctx) require.Error(t, err) require.NoError(t, c.Close()) require.Contains(t, logs.String(), "cannot code-generate unexported type bar") } func TestModuleGoSignaturesMixMatch(t *testing.T) {
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/integration/module_test.go
t.Parallel() var logs safeBuffer c, ctx := connect(t, dagger.WithLogOutput(&logs)) modGen := c.Container().From(golangImage). WithMountedFile(testCLIBinPath, daggerCliFile(t, c)). WithWorkdir("/work"). With(daggerExec("mod", "init", "--name=minimal", "--sdk=go")). WithNewFile("main.go", dagger.ContainerWithNewFileOpts{ Contents: `package main type Minimal struct {} func (m *Minimal) Hello(name string, opts struct{}, opts2 struct{}) string { return name } `, }) logGen(ctx, t, modGen.Directory(".")) _, err := modGen.With(daggerQuery(`{minimal{hello}}`)).Stdout(ctx) require.Error(t, err) require.NoError(t, c.Close()) require.Contains(t, logs.String(), "nested structs are not supported") } func TestModuleGoSignaturesNameConflict(t *testing.T) {
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/integration/module_test.go
t.Parallel() var logs safeBuffer c, ctx := connect(t, dagger.WithLogOutput(&logs)) modGen := c.Container().From(golangImage). WithMountedFile(testCLIBinPath, daggerCliFile(t, c)). WithWorkdir("/work"). With(daggerExec("mod", "init", "--name=minimal", "--sdk=go")). WithNewFile("main.go", dagger.ContainerWithNewFileOpts{ Contents: `package main type Minimal struct { Foo Foo Bar Bar Baz Baz } type Foo struct {}
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/integration/module_test.go
type Bar struct {} type Baz struct {} func (m *Foo) Hello(name string) string { return name } func (f *Bar) Hello(name string, name2 string) string { return name + name2 } func (b *Baz) Hello() (string, error) { return "", nil } `, }) logGen(ctx, t, modGen.Directory(".")) out, err := modGen.With(inspectModule).Stdout(ctx) require.NoError(t, err) objs := gjson.Get(out, "host.directory.asModule.initialize.objects") require.Equal(t, 4, len(objs.Array())) obj := objs.Get(`0.asObject`) require.Equal(t, "Minimal", obj.Get("name").String()) obj = objs.Get(`1.asObject`) require.Equal(t, "MinimalFoo", obj.Get("name").String()) obj = objs.Get(`2.asObject`) require.Equal(t, "MinimalBar", obj.Get("name").String()) obj = objs.Get(`3.asObject`) require.Equal(t, "MinimalBaz", obj.Get("name").String()) } var inspectModule = daggerQuery(` query { host {
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/integration/module_test.go
directory(path: ".") { asModule { initialize { description objects { asObject { name description functions { name description args { name description defaultValue } } fields { name description } } } } } } } } `) func TestModuleGoDocs(t *testing.T) {
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/integration/module_test.go
t.Parallel() c, ctx := connect(t) modGen := c.Container().From(golangImage). WithMountedFile(testCLIBinPath, daggerCliFile(t, c)). WithWorkdir("/work"). With(daggerExec("mod", "init", "--name=minimal", "--sdk=go")). WithNewFile("main.go", dagger.ContainerWithNewFileOpts{ Contents: goSignatures, }) logGen(ctx, t, modGen.Directory(".")) out, err := modGen.With(inspectModule).Stdout(ctx) require.NoError(t, err) obj := gjson.Get(out, "host.directory.asModule.initialize.objects.0.asObject") require.Equal(t, "Minimal", obj.Get("name").String()) hello := obj.Get(`functions.#(name="hello")`) require.Equal(t, "hello", hello.Get("name").String()) require.Empty(t, hello.Get("description").String()) require.Empty(t, hello.Get("args").Array()) echoOpts := obj.Get(`functions.#(name="echoOpts")`) require.Equal(t, "echoOpts", echoOpts.Get("name").String()) require.Equal(t, "EchoOpts does some opts things", echoOpts.Get("description").String()) require.Len(t, echoOpts.Get("args").Array(), 3) require.Equal(t, "msg", echoOpts.Get("args.0.name").String())
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/integration/module_test.go
require.Equal(t, "the message to echo", echoOpts.Get("args.0.description").String()) require.Equal(t, "suffix", echoOpts.Get("args.1.name").String()) require.Equal(t, "String to append to the echoed message", echoOpts.Get("args.1.description").String()) require.Equal(t, "times", echoOpts.Get("args.2.name").String()) require.Equal(t, "Number of times to repeat the message", echoOpts.Get("args.2.description").String()) echoOpts = obj.Get(`functions.#(name="echoOptsInline")`) require.Equal(t, "echoOptsInline", echoOpts.Get("name").String()) require.Equal(t, "EchoOptsInline does some opts things", echoOpts.Get("description").String()) require.Len(t, echoOpts.Get("args").Array(), 3) require.Equal(t, "msg", echoOpts.Get("args.0.name").String()) require.Equal(t, "the message to echo", echoOpts.Get("args.0.description").String()) require.Equal(t, "suffix", echoOpts.Get("args.1.name").String()) require.Equal(t, "String to append to the echoed message", echoOpts.Get("args.1.description").String()) require.Equal(t, "times", echoOpts.Get("args.2.name").String()) require.Equal(t, "Number of times to repeat the message", echoOpts.Get("args.2.description").String()) echoOpts = obj.Get(`functions.#(name="echoOptsPragmas")`) require.Equal(t, "echoOptsPragmas", echoOpts.Get("name").String()) require.Len(t, echoOpts.Get("args").Array(), 3) require.Equal(t, "msg", echoOpts.Get("args.0.name").String()) require.Equal(t, "", echoOpts.Get("args.0.defaultValue").String()) require.Equal(t, "suffix", echoOpts.Get("args.1.name").String()) require.Equal(t, "String to append to the echoed message", echoOpts.Get("args.1.description").String()) require.Equal(t, "\"...\"", echoOpts.Get("args.1.defaultValue").String()) require.Equal(t, "times", echoOpts.Get("args.2.name").String()) require.Equal(t, "3", echoOpts.Get("args.2.defaultValue").String()) require.Equal(t, "Number of times to repeat the message", echoOpts.Get("args.2.description").String()) } func TestModuleGoDocsEdgeCases(t *testing.T) {
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/integration/module_test.go
t.Parallel() c, ctx := connect(t) modGen := c.Container().From(golangImage). WithMountedFile(testCLIBinPath, daggerCliFile(t, c)). WithWorkdir("/work"). With(daggerExec("mod", "init", "--name=minimal", "--sdk=go")). WithNewFile("main.go", dagger.ContainerWithNewFileOpts{ Contents: `package main // Minimal is a thing type Minimal struct { // X is this X, Y string // Y is not this // +private Z string }
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/integration/module_test.go
// some docs func (m *Minimal) Hello(foo string, bar string, // hello baz string, qux string, x string, // lol ) string { return foo + bar } func (m *Minimal) HelloMore( // foo here foo, // bar here bar string, ) string { return foo + bar } func (m *Minimal) HelloMoreInline(opts struct{ // foo here foo, bar string }) string { return opts.foo + opts.bar } func (m *Minimal) HelloAgain( // docs for helloagain foo string, bar string, // docs for bar baz string, ) string { return foo + bar } func (m *Minimal) HelloFinal( foo string) string { // woops
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/integration/module_test.go
return foo } `, }) logGen(ctx, t, modGen.Directory(".")) out, err := modGen.With(inspectModule).Stdout(ctx) require.NoError(t, err) obj := gjson.Get(out, "host.directory.asModule.initialize.objects.0.asObject") require.Equal(t, "Minimal", obj.Get("name").String()) require.Equal(t, "Minimal is a thing", obj.Get("description").String()) hello := obj.Get(`functions.#(name="hello")`) require.Equal(t, "hello", hello.Get("name").String()) require.Len(t, hello.Get("args").Array(), 5) require.Equal(t, "foo", hello.Get("args.0.name").String()) require.Equal(t, "", hello.Get("args.0.description").String()) require.Equal(t, "bar", hello.Get("args.1.name").String()) require.Equal(t, "", hello.Get("args.1.description").String()) require.Equal(t, "baz", hello.Get("args.2.name").String()) require.Equal(t, "hello", hello.Get("args.2.description").String()) require.Equal(t, "qux", hello.Get("args.3.name").String()) require.Equal(t, "", hello.Get("args.3.description").String()) require.Equal(t, "x", hello.Get("args.4.name").String()) require.Equal(t, "lol", hello.Get("args.4.description").String()) hello = obj.Get(`functions.#(name="helloMore")`) require.Equal(t, "helloMore", hello.Get("name").String()) require.Len(t, hello.Get("args").Array(), 2) require.Equal(t, "foo", hello.Get("args.0.name").String()) require.Equal(t, "foo here", hello.Get("args.0.description").String()) require.Equal(t, "bar", hello.Get("args.1.name").String()) require.Equal(t, "bar here", hello.Get("args.1.description").String())
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/integration/module_test.go
hello = obj.Get(`functions.#(name="helloMoreInline")`) require.Equal(t, "helloMoreInline", hello.Get("name").String()) require.Len(t, hello.Get("args").Array(), 2) require.Equal(t, "foo", hello.Get("args.0.name").String()) require.Equal(t, "foo here", hello.Get("args.0.description").String()) require.Equal(t, "bar", hello.Get("args.1.name").String()) require.Equal(t, "", hello.Get("args.1.description").String()) hello = obj.Get(`functions.#(name="helloAgain")`) require.Equal(t, "helloAgain", hello.Get("name").String()) require.Len(t, hello.Get("args").Array(), 3) require.Equal(t, "foo", hello.Get("args.0.name").String()) require.Equal(t, "", hello.Get("args.0.description").String()) require.Equal(t, "bar", hello.Get("args.1.name").String()) require.Equal(t, "docs for bar", hello.Get("args.1.description").String()) require.Equal(t, "baz", hello.Get("args.2.name").String()) require.Equal(t, "", hello.Get("args.2.description").String()) hello = obj.Get(`functions.#(name="helloFinal")`) require.Equal(t, "helloFinal", hello.Get("name").String()) require.Len(t, hello.Get("args").Array(), 1) require.Equal(t, "foo", hello.Get("args.0.name").String()) require.Equal(t, "", hello.Get("args.0.description").String()) require.Len(t, obj.Get(`fields`).Array(), 2) prop := obj.Get(`fields.#(name="x")`) require.Equal(t, "x", prop.Get("name").String()) require.Equal(t, "X is this", prop.Get("description").String()) prop = obj.Get(`fields.#(name="y")`) require.Equal(t, "y", prop.Get("name").String()) require.Equal(t, "", prop.Get("description").String()) } func TestModuleGoWeirdFields(t *testing.T) {
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/integration/module_test.go
t.Parallel() c, ctx := connect(t) modGen := c.Container().From(golangImage). WithMountedFile(testCLIBinPath, daggerCliFile(t, c)). WithWorkdir("/work"). With(daggerExec("mod", "init", "--name=minimal", "--sdk=go")). WithNewFile("main.go", dagger.ContainerWithNewFileOpts{ Contents: `package main type Z string type Minimal struct { // field with single (normal) name W string // field with multiple names X, Y string // field with no names Z }
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/integration/module_test.go
func New() Minimal { return Minimal{ W: "-", X: "-", Y: "-", Z: Z("-"), } } // struct with no fields type Bar struct{} func (m *Minimal) Say( // field with single (normal) name a string, // field with multiple names b, c string, // field with no names (not included, mixed names not allowed) // string ) string { return a + " " + b + " " + c } func (m *Minimal) Hello( // field with no names string, ) string { return "hello" } func (m *Minimal) SayOpts(opts struct{ // field with single (normal) name A string // field with multiple names
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/integration/module_test.go
B, C string // field with no names (not included because of above) // string }) string { return opts.A + " " + opts.B + " " + opts.C } func (m *Minimal) HelloOpts(opts struct{ // field with no names string }) string { return "hello" } `, }) logGen(ctx, t, modGen.Directory(".")) out, err := modGen.With(daggerQuery(`{minimal{w, x, y, z}}`)).Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"minimal": {"w": "-", "x": "-", "y": "-", "z": "-"}}`, out) for _, name := range []string{"say", "sayOpts"} { out, err := modGen.With(daggerQuery(`{minimal{%s(a: "hello", b: "world", c: "!")}}`, name)).Stdout(ctx) require.NoError(t, err) require.JSONEq(t, fmt.Sprintf(`{"minimal": {"%s": "hello world !"}}`, name), out) } for _, name := range []string{"hello", "helloOpts"} { out, err := modGen.With(daggerQuery(`{minimal{%s(string: "")}}`, name)).Stdout(ctx) require.NoError(t, err) require.JSONEq(t, fmt.Sprintf(`{"minimal": {"%s": "hello"}}`, name), out) } } func TestModuleGoOptionalMustBeNil(t *testing.T) {
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/integration/module_test.go
t.Parallel() c, ctx := connect(t) modGen := c.Container().From(golangImage). WithMountedFile(testCLIBinPath, daggerCliFile(t, c)). WithWorkdir("/work"). With(daggerExec("mod", "init", "--name=minimal", "--sdk=go")). WithNewFile("main.go", dagger.ContainerWithNewFileOpts{ Contents: `package main type Minimal struct {} func (m *Minimal) Foo(x *Optional[*string]) string { if v, _ := x.Get(); v != nil { panic("uh oh") } return "" } func (m *Minimal) Bar(opts struct { x *Optional[*string] }) string { if v, _ := opts.x.Get(); v != nil { panic("uh oh") } return "" } func (m *Minimal) Baz( // +optional
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/integration/module_test.go
x *string, ) string { if x != nil { panic("uh oh") } return "" } func (m *Minimal) Qux(opts struct { // +optional x *string }) string { if opts.x != nil { panic("uh oh") } return "" } `, }) logGen(ctx, t, modGen.Directory(".")) for _, name := range []string{"foo", "bar", "baz", "qux"} { out, err := modGen.With(daggerQuery(`{minimal{%s}}`, name)).Stdout(ctx) require.NoError(t, err) require.JSONEq(t, fmt.Sprintf(`{"minimal": {"%s": ""}}`, name), out) } } func TestModuleGoFieldMustBeNil(t *testing.T) { t.Parallel() c, ctx := connect(t) modGen := c.Container().From(golangImage). WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/integration/module_test.go
WithWorkdir("/work"). With(daggerExec("mod", "init", "--name=minimal", "--sdk=go")). WithNewFile("main.go", dagger.ContainerWithNewFileOpts{ Contents: `package main import "fmt" type Minimal struct { Src *Directory Name *string } func New() *Minimal { return &Minimal{} } func (m *Minimal) IsEmpty() bool { if m.Name != nil { panic(fmt.Sprintf("name should be nil but is %v", m.Name)) } if m.Src != nil { panic(fmt.Sprintf("src should be nil but is %v", m.Src)) } return true } `, }) out, err := modGen.With(daggerQuery(`{minimal{isEmpty}}`)).Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"minimal": {"isEmpty": true}}`, out) } func TestModuleDescription(t *testing.T) { t.Parallel() for _, tc := range []struct {
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/integration/module_test.go
sdk string source string }{ { sdk: "python", source: `"""Minimal module, short description Long description, with full sentences. """ from dagger import field, function, object_type @object_type class Minimal: """Minimal object, short description""" foo: str = field(default="foo") `, },
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/integration/module_test.go
} { tc := tc t.Run(tc.sdk, func(t *testing.T) { t.Parallel() c, ctx := connect(t) modGen := c.Container().From(golangImage). WithMountedFile(testCLIBinPath, daggerCliFile(t, c)). WithWorkdir("/work"). With(daggerExec("mod", "init", "--name=minimal", "--sdk="+tc.sdk)). With(sdkSource(tc.sdk, tc.source)) if tc.sdk == "go" { logGen(ctx, t, modGen.Directory(".")) } out, err := modGen.With(inspectModule).Stdout(ctx) require.NoError(t, err) mod := gjson.Get(out, "host.directory.asModule.initialize") require.Equal(t, "Minimal module, short description\n\nLong description, with full sentences.", mod.Get("description").String(), ) require.Equal(t, "Minimal object, short description", mod.Get("objects.0.asObject.description").String(), ) }) } } func TestModulePrivateField(t *testing.T) { t.Parallel() for _, tc := range []struct {
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/integration/module_test.go
sdk string source string }{ { sdk: "go", source: `package main type Minimal struct { Foo string Bar string // +private } func (m *Minimal) Set(foo string, bar string) *Minimal { m.Foo = foo m.Bar = bar return m } func (m *Minimal) Hello() string { return m.Foo + m.Bar } `, }, { sdk: "python", source: `from dagger import field, function, object_type @object_type class Minimal: foo: str = field(default="") bar: str = "" @function def set(self, foo: str, bar: str) -> "Minimal": self.foo = foo
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/integration/module_test.go
self.bar = bar return self @function def hello(self) -> str: return self.foo + self.bar `, }, { sdk: "typescript", source: ` import { object, func, field } from "@dagger.io/dagger" @object class Minimal { @field foo: string bar?: string constructor(foo?: string, bar?: string) { this.foo = foo this.bar = bar } @func set(foo: string, bar: string): Minimal { this.foo = foo this.bar = bar return this } @func hello(): string { return this.foo + this.bar }
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/integration/module_test.go
} `, }, } { tc := tc t.Run(tc.sdk, func(t *testing.T) { t.Parallel() c, ctx := connect(t) modGen := c.Container().From(golangImage). WithMountedFile(testCLIBinPath, daggerCliFile(t, c)). WithWorkdir("/work"). With(daggerExec("mod", "init", "--name=minimal", "--sdk="+tc.sdk)). With(sdkSource(tc.sdk, tc.source)) if tc.sdk == "go" { logGen(ctx, t, modGen.Directory(".")) } out, err := modGen.With(inspectModule).Stdout(ctx) require.NoError(t, err) obj := gjson.Get(out, "host.directory.asModule.initialize.objects.0.asObject") require.Equal(t, "Minimal", obj.Get("name").String()) require.Len(t, obj.Get(`fields`).Array(), 1) prop := obj.Get(`fields.#(name="foo")`) require.Equal(t, "foo", prop.Get("name").String()) out, err = modGen.With(daggerQuery(`{minimal{set(foo: "abc", bar: "xyz"){hello}}}`)).Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"minimal":{"set":{"hello": "abcxyz"}}}`, out) out, err = modGen.With(daggerQuery(`{minimal{set(foo: "abc", bar: "xyz"){foo}}}`)).Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"minimal":{"set":{"foo": "abc"}}}`, out) _, err = modGen.With(daggerQuery(`{minimal{set(foo: "abc", bar: "xyz"){bar}}}`)).Stdout(ctx)
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/integration/module_test.go
require.ErrorContains(t, err, `Minimal has no such field: "bar"`) }) } } func TestModuleGoExtendCore(t *testing.T) { t.Parallel() var logs safeBuffer c, ctx := connect(t, dagger.WithLogOutput(&logs)) _, err := c.Container().From(golangImage). WithMountedFile(testCLIBinPath, daggerCliFile(t, c)). WithWorkdir("/work"). With(daggerExec("mod", "init", "--name=container", "--sdk=go")). WithNewFile("main.go", dagger.ContainerWithNewFileOpts{ Contents: `package main import "context" func (c *Container) Echo(ctx context.Context, msg string) (string, error) { return c.WithExec([]string{"echo", msg}).Stdout(ctx) } `, }). With(daggerQuery(`{container{from(address:"` + alpineImage + `"){echo(msg:"echo!"){stdout}}}}`)). Sync(ctx) require.Error(t, err) require.NoError(t, c.Close()) t.Log(logs.String()) require.Contains(t, logs.String(), "cannot define methods on objects from outside this module") } func TestModuleCustomTypes(t *testing.T) { t.Parallel() type testCase struct {
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/integration/module_test.go
sdk string source string } for _, tc := range []testCase{ { sdk: "go", source: `package main import "strings" type Test struct{} func (m *Test) Repeater(msg string, times int) *Repeater { return &Repeater{ Message: msg, Times: times, } } type Repeater struct { Message string Times int } func (t *Repeater) Render() string { return strings.Repeat(t.Message, t.Times) } `, }, { sdk: "python", source: `from dagger import field, function, object_type @object_type class Repeater:
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/integration/module_test.go
message: str = field(default="") times: int = field(default=0) @function def render(self) -> str: return self.message * self.times @function def repeater(msg: str, times: int) -> Repeater: return Repeater(message=msg, times=times) `, }, { sdk: "typescript", source: ` import { object, func, field } from "@dagger.io/dagger" @object class Repeater { @field message: string @field times: number constructor(message: string, times: number) { this.message = message this.times = times } @func render(): string { return this.message.repeat(this.times) } } @object
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/integration/module_test.go
class Test { @func repeater(msg: string, times: number): Repeater { return new Repeater(msg, times) } } `, }, } { tc := tc t.Run(fmt.Sprintf("custom %s types", tc.sdk), func(t *testing.T) { t.Parallel() c, ctx := connect(t) modGen := c.Container().From(golangImage). WithMountedFile(testCLIBinPath, daggerCliFile(t, c)). WithWorkdir("/work"). With(daggerExec("mod", "init", "--name=test", "--sdk="+tc.sdk)). With(sdkSource(tc.sdk, tc.source)) if tc.sdk == "go" { logGen(ctx, t, modGen.Directory(".")) } out, err := modGen.With(daggerQuery(`{test{repeater(msg:"echo!", times: 3){render}}}`)).Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"test":{"repeater":{"render":"echo!echo!echo!"}}}`, out) }) } } func TestModuleReturnTypeDetection(t *testing.T) { t.Parallel() type testCase struct {
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/integration/module_test.go
sdk string source string } for _, tc := range []testCase{ { sdk: "go", source: `package main type Foo struct {} type X struct { Message string ` + "`json:\"message\"`" + `
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/integration/module_test.go
} func (m *Foo) MyFunction() X { return X{Message: "foo"} } `, }, { sdk: "python", source: `from dagger import field, function, object_type @object_type class X: message: str = field(default="") @function def my_function() -> X: return X(message="foo") `, }, { sdk: "typescript", source: ` import { object, func, field } from "@dagger.io/dagger" @object class X { @field message: string constructor(message: string) { this.message = message; } } @object
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/integration/module_test.go
class Foo { @func myFunction(): X { return new X("foo"); } } `, }, } { tc := tc t.Run(tc.sdk, func(t *testing.T) { t.Parallel() c, ctx := connect(t) modGen := c.Container().From(golangImage). WithMountedFile(testCLIBinPath, daggerCliFile(t, c)). WithWorkdir("/work"). With(daggerExec("mod", "init", "--name=foo", "--sdk="+tc.sdk)). With(sdkSource(tc.sdk, tc.source)) if tc.sdk == "go" { logGen(ctx, t, modGen.Directory(".")) } out, err := modGen.With(daggerQuery(`{foo{myFunction{message}}}`)).Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"foo":{"myFunction":{"message":"foo"}}}`, out) }) } } func TestModuleReturnObject(t *testing.T) { t.Parallel() type testCase struct {
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/integration/module_test.go
sdk string source string } for _, tc := range []testCase{ { sdk: "go", source: `package main type Foo struct {} type X struct { Message string ` + "`json:\"message\"`" + ` When string ` + "`json:\"Timestamp\"`" + ` To string ` + "`json:\"recipient\"`" + ` From string } func (m *Foo) MyFunction() X { return X{Message: "foo", When: "now", To: "user", From: "admin"} } `, }, { sdk: "python", source: `from dagger import field, function, object_type @object_type class X: message: str = field(default="") when: str = field(default="", name="Timestamp") to: str = field(default="", name="recipient")
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/integration/module_test.go
from_: str = field(default="", name="from") @object_type class Foo: @function def my_function(self) -> X: return X(message="foo", when="now", to="user", from_="admin") `, }, { sdk: "typescript", source: ` import { object, func, field } from "@dagger.io/dagger" @object class X { @field message: string @field timestamp: string @field recipient: string @field from: string constructor(message: string, timestamp: string, recipient: string, from: string) { this.message = message; this.timestamp = timestamp; this.recipient = recipient; this.from = from; } } @object
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/integration/module_test.go
class Foo { @func myFunction(): X { return new X("foo", "now", "user", "admin"); } } `, }, } { tc := tc t.Run(tc.sdk, func(t *testing.T) { t.Parallel() c, ctx := connect(t) modGen := c.Container().From(golangImage). WithMountedFile(testCLIBinPath, daggerCliFile(t, c)). WithWorkdir("/work"). With(daggerExec("mod", "init", "--name=foo", "--sdk="+tc.sdk)). With(sdkSource(tc.sdk, tc.source)) if tc.sdk == "go" { logGen(ctx, t, modGen.Directory(".")) } out, err := modGen.With(daggerQuery(`{foo{myFunction{message, recipient, from, timestamp}}}`)).Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"foo":{"myFunction":{"message":"foo", "recipient":"user", "from":"admin", "timestamp":"now"}}}`, out) }) } } func TestModuleReturnNestedObject(t *testing.T) { t.Parallel() type testCase struct {
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/integration/module_test.go
sdk string source string } for _, tc := range []testCase{ { sdk: "go", source: `package main type Playground struct{} type Foo struct { MsgContainer Bar } type Bar struct { Msg string } func (m *Playground) MyFunction() Foo { return Foo{MsgContainer: Bar{Msg: "hello world"}} } `, }, { sdk: "python", source: `from dagger import field, function, object_type @object_type class Bar: msg: str = field() @object_type class Foo: msg_container: Bar = field() @object_type class Playground:
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/integration/module_test.go
@function def my_function(self) -> Foo: return Foo(msg_container=Bar(msg="hello world")) `, }, { sdk: "typescript", source: ` import { object, func, field } from "@dagger.io/dagger" @object class Bar { @field msg: string; constructor(msg: string) { this.msg = msg; } } @object class Foo { @field msgContainer: Bar; constructor(msgContainer: Bar) { this.msgContainer = msgContainer; } } @object class Playground { @func myFunction(): Foo { return new Foo(new Bar("hello world"));
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/integration/module_test.go
} } `, }, } { tc := tc t.Run(tc.sdk, func(t *testing.T) { t.Parallel() c, ctx := connect(t) modGen := c.Container().From(golangImage). WithMountedFile(testCLIBinPath, daggerCliFile(t, c)). WithWorkdir("/work"). With(daggerExec("mod", "init", "--name=playground", "--sdk="+tc.sdk)). With(sdkSource(tc.sdk, tc.source)) if tc.sdk == "go" { logGen(ctx, t, modGen.Directory(".")) } out, err := modGen.With(daggerQuery(`{playground{myFunction{msgContainer{msg}}}}`)).Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"playground":{"myFunction":{"msgContainer":{"msg": "hello world"}}}}`, out) }) } } func TestModuleReturnCompositeCore(t *testing.T) { t.Parallel() type testCase struct { sdk string source string } for _, tc := range []testCase{
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/integration/module_test.go
{ sdk: "go", source: `package main type Playground struct{} func (m *Playground) MySlice() []*Container { return []*Container{dag.Container().From("alpine:latest").WithExec([]string{"echo", "hello world"})} } type Foo struct { Con *Container // verify fields can remain nil w/out error too UnsetFile *File } func (m *Playground) MyStruct() *Foo { return &Foo{Con: dag.Container().From("alpine:latest").WithExec([]string{"echo", "hello world"})} } `, }, { sdk: "python", source: `import dagger from dagger import dag, field, function, object_type @object_type class Foo: con: dagger.Container = field() unset_file: dagger.File | None = field(default=None) @object_type class Playground: @function def my_slice(self) -> list[dagger.Container]: return [dag.container().from_("alpine:latest").with_exec(["echo", "hello world"])]
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/integration/module_test.go
@function def my_struct(self) -> Foo: return Foo(con=dag.container().from_("alpine:latest").with_exec(["echo", "hello world"])) `, }, { sdk: "typescript", source: ` import { dag, Container, File, object, func, field } from "@dagger.io/dagger" @object class Foo { @field con: Container @field unsetFile?: File constructor(con: Container, usetFile?: File) { this.con = con this.usetFile = usetFile } } @object class Playground { @func mySlice(): Container[] { return [ dag.container().from("alpine:latest").withExec(["echo", "hello world"]) ] } @func myStruct(): Foo {
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/integration/module_test.go
return new Foo( dag.container().from("alpine:latest").withExec(["echo", "hello world"]) ) } } `, }, } { tc := tc t.Run(tc.sdk, func(t *testing.T) { t.Parallel() c, ctx := connect(t) modGen := c.Container().From(golangImage). WithMountedFile(testCLIBinPath, daggerCliFile(t, c)). WithWorkdir("/work"). With(daggerExec("mod", "init", "--name=playground", "--sdk="+tc.sdk)). With(sdkSource(tc.sdk, tc.source)) if tc.sdk == "go" { logGen(ctx, t, modGen.Directory(".")) } out, err := modGen.With(daggerQuery(`{playground{mySlice{stdout}}}`)).Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"playground":{"mySlice":[{"stdout":"hello world\n"}]}}`, out) out, err = modGen.With(daggerQuery(`{playground{myStruct{con{stdout}}}}`)).Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"playground":{"myStruct":{"con":{"stdout":"hello world\n"}}}}`, out) }) } } func TestModuleReturnComplexThing(t *testing.T) {
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/integration/module_test.go
t.Parallel() type testCase struct { sdk string source string } for _, tc := range []testCase{ { sdk: "go", source: `package main type Playground struct{} type ScanResult struct { Containers []*Container ` + "`json:\"targets\"`" + ` Report ScanReport } type ScanReport struct { Contents string ` + "`json:\"contents\"`" + ` Authors []string ` + "`json:\"Authors\"`" + ` } func (m *Playground) Scan() ScanResult { return ScanResult{ Containers: []*Container{ dag.Container().From("alpine:latest").WithExec([]string{"echo", "hello world"}), }, Report: ScanReport{ Contents: "hello world", Authors: []string{"foo", "bar"}, }, }
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/integration/module_test.go
} `, }, { sdk: "python", source: `import dagger from dagger import dag, field, function, object_type @object_type class ScanReport: contents: str = field() authors: list[str] = field() @object_type class ScanResult: containers: list[dagger.Container] = field(name="targets") report: ScanReport = field() @object_type class Playground: @function def scan(self) -> ScanResult: return ScanResult( containers=[ dag.container().from_("alpine:latest").with_exec(["echo", "hello world"]), ], report=ScanReport( contents="hello world", authors=["foo", "bar"], ), ) `, },
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/integration/module_test.go
{ sdk: "typescript", source: ` import { dag, Container, object, func, field } from "@dagger.io/dagger" @object class ScanReport { @field contents: string @field authors: string[] constructor(contents: string, authors: string[]) { this.contents = contents this.authors = authors } } @object class ScanResult { @field targets: Container[] @field report: ScanReport constructor(containers: Container[], report: ScanReport) { this.targets = containers this.report = report } } @object class Playground { @func async scan(): Promise<ScanResult> {
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/integration/module_test.go
return new ScanResult( [ dag.container().from("alpine:latest").withExec(["echo", "hello world"]) ], new ScanReport("hello world", ["foo", "bar"]) ) } } `, }, } { tc := tc t.Run(tc.sdk, func(t *testing.T) { t.Parallel() c, ctx := connect(t) modGen := c.Container().From(golangImage). WithMountedFile(testCLIBinPath, daggerCliFile(t, c)). WithWorkdir("/work"). With(daggerExec("mod", "init", "--name=playground", "--sdk="+tc.sdk)). With(sdkSource(tc.sdk, tc.source)) if tc.sdk == "go" { logGen(ctx, t, modGen.Directory(".")) } out, err := modGen.With(daggerQuery(`{playground{scan{targets{stdout},report{contents,authors}}}}`)).Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"playground":{"scan":{"targets":[{"stdout":"hello world\n"}],"report":{"contents":"hello world","authors":["foo","bar"]}}}}`, out) }) } } func TestModulePythonReturnSelf(t *testing.T) {
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/integration/module_test.go
t.Parallel() c, ctx := connect(t) modGen := c.Container().From(golangImage). WithMountedFile(testCLIBinPath, daggerCliFile(t, c)). WithWorkdir("/work"). With(daggerExec("mod", "init", "--name=foo", "--sdk=python")). WithNewFile("src/main.py", dagger.ContainerWithNewFileOpts{ Contents: `from typing import Self from dagger import field, function, object_type @object_type class Foo: message: str = field(default="") @function def bar(self) -> Self: self.message = "foobar" return self `, }) out, err := modGen.With(daggerQuery(`{foo{bar{message}}}`)).Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"foo":{"bar":{"message":"foobar"}}}`, out) } func TestModuleGlobalVarDAG(t *testing.T) { t.Parallel() type testCase struct {
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/integration/module_test.go
sdk string source string } for _, tc := range []testCase{ { sdk: "go", source: `package main import "context" type Foo struct {} var someDefault = dag.Container().From("alpine:latest") func (m *Foo) Fn(ctx context.Context) (string, error) { return someDefault.WithExec([]string{"echo", "foo"}).Stdout(ctx) } `, }, { sdk: "python", source: `from dagger import dag, function, object_type SOME_DEFAULT = dag.container().from_("alpine:latest") @object_type class Foo: @function async def fn(self) -> str: return await SOME_DEFAULT.with_exec(["echo", "foo"]).stdout() `, }, { sdk: "typescript", source: ` import { dag, object, func } from "@dagger.io/dagger"
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/integration/module_test.go
var someDefault = dag.container().from("alpine:latest") @object class Foo { @func async fn(): Promise<string> { return someDefault.withExec(["echo", "foo"]).stdout() } } `, }, } { tc := tc t.Run(tc.sdk, func(t *testing.T) { t.Parallel() c, ctx := connect(t) modGen := c.Container().From(golangImage). WithMountedFile(testCLIBinPath, daggerCliFile(t, c)). WithWorkdir("/work"). With(daggerExec("mod", "init", "--name=foo", "--sdk="+tc.sdk)). With(sdkSource(tc.sdk, tc.source)) if tc.sdk == "go" { logGen(ctx, t, modGen.Directory(".")) } out, err := modGen.With(daggerQuery(`{foo{fn}}`)).Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"foo":{"fn":"foo\n"}}`, out) }) } } func TestModuleIDableType(t *testing.T) {
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/integration/module_test.go
t.Parallel() type testCase struct { sdk string source string } for _, tc := range []testCase{ { sdk: "go", source: `package main type Foo struct { Data string } func (m *Foo) Set(data string) *Foo { m.Data = data return m } func (m *Foo) Get() string { return m.Data } `, }, { sdk: "python", source: `from typing import Self from dagger import field, function, object_type @object_type class Foo:
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/integration/module_test.go
data: str = "" @function def set(self, data: str) -> Self: self.data = data return self @function def get(self) -> str: return self.data `, }, { sdk: "typescript", source: ` import { object, func } from "@dagger.io/dagger" @object class Foo { data: string = "" @func set(data: string): Foo { this.data = data return this } @func get(): string { return this.data } } `, }, } {
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/integration/module_test.go
tc := tc t.Run(tc.sdk, func(t *testing.T) { t.Parallel() c, ctx := connect(t) modGen := c.Container().From(golangImage). WithMountedFile(testCLIBinPath, daggerCliFile(t, c)). WithWorkdir("/work"). With(daggerExec("mod", "init", "--name=foo", "--sdk="+tc.sdk)). With(sdkSource(tc.sdk, tc.source)) if tc.sdk == "go" { logGen(ctx, t, modGen.Directory(".")) } out, err := modGen.With(daggerQuery(`{foo{set(data: "abc"){get}}}`)).Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"foo":{"set":{"get": "abc"}}}`, out) out, err = modGen.With(daggerQuery(`{foo{set(data: "abc"){id}}}`)).Stdout(ctx) require.NoError(t, err) id := gjson.Get(out, "foo.set.id").String() var idp idproto.ID err = idp.Decode(id) require.NoError(t, err) require.Equal(t, idp.Display(), `foo.set(data: "abc"): Foo!`) out, err = modGen.With(daggerQuery(`{loadFooFromID(id: "%s"){get}}`, id)).Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"loadFooFromID":{"get": "abc"}}`, out) }) } } func TestModuleArgOwnType(t *testing.T) {
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/integration/module_test.go
t.Parallel() type testCase struct { sdk string source string } for _, tc := range []testCase{ { sdk: "go", source: `package main import "strings" type Foo struct{} type Message struct { Content string } func (m *Foo) SayHello(name string) Message { return Message{Content: "hello " + name} } func (m *Foo) Upper(msg Message) Message { msg.Content = strings.ToUpper(msg.Content) return msg } func (m *Foo) Uppers(msg []Message) []Message { for i := range msg {
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/integration/module_test.go
msg[i].Content = strings.ToUpper(msg[i].Content) } return msg }`, }, { sdk: "python", source: `from dagger import field, function, object_type @object_type class Message: content: str = field() @object_type class Foo: @function def say_hello(self, name: str) -> Message: return Message(content=f"hello {name}") @function def upper(self, msg: Message) -> Message: msg.content = msg.content.upper() return msg @function def uppers(self, msg: list[Message]) -> list[Message]: for m in msg: m.content = m.content.upper() return msg `, }, { sdk: "typescript", source: `
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/integration/module_test.go
import { object, func, field } from "@dagger.io/dagger" @object class Message { @field content: string constructor(content: string) { this.content = content } } @object class Foo { @func sayHello(name: string): Message { return new Message("hello " + name) } @func upper(msg: Message): Message { msg.content = msg.content.toUpperCase() return msg } @func uppers(msg: Message[]): Message[] { for (let i = 0; i < msg.length; i++) { msg[i].content = msg[i].content.toUpperCase() } return msg } } `, },
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/integration/module_test.go
} { tc := tc t.Run(tc.sdk, func(t *testing.T) { t.Parallel() c, ctx := connect(t) modGen := c.Container().From(golangImage). WithMountedFile(testCLIBinPath, daggerCliFile(t, c)). WithWorkdir("/work"). With(daggerExec("mod", "init", "--name=foo", "--sdk="+tc.sdk)). With(sdkSource(tc.sdk, tc.source)) if tc.sdk == "go" { logGen(ctx, t, modGen.Directory(".")) } out, err := modGen.With(daggerQuery(`{foo{sayHello(name: "world"){id}}}`)).Stdout(ctx) require.NoError(t, err) id := gjson.Get(out, "foo.sayHello.id").String() var idp idproto.ID err = idp.Decode(id) require.NoError(t, err) require.Equal(t, idp.Display(), `foo.sayHello(name: "world"): FooMessage!`) out, err = modGen.With(daggerQuery(`{foo{upper(msg:"%s"){content}}}`, id)).Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"foo":{"upper":{"content": "HELLO WORLD"}}}`, out) out, err = modGen.With(daggerQuery(`{foo{uppers(msg:["%s", "%s"]){content}}}`, id, id)).Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"foo":{"uppers":[{"content": "HELLO WORLD"}, {"content": "HELLO WORLD"}]}}`, out) }) } } func TestModuleConflictingSameNameDeps(t *testing.T) {
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/integration/module_test.go
t.Parallel() c, ctx := connect(t) ctr := c.Container().From(golangImage). WithMountedFile(testCLIBinPath, daggerCliFile(t, c)). WithWorkdir("/work/dstr"). With(daggerExec("mod", "init", "--name=d", "--sdk=go")). WithNewFile("main.go", dagger.ContainerWithNewFileOpts{ Contents: `package main type D struct{} type Obj struct {
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/integration/module_test.go
Foo string } func (m *D) Fn(foo string) Obj { return Obj{Foo: foo} } `, }) ctr = ctr. WithMountedFile(testCLIBinPath, daggerCliFile(t, c)). WithWorkdir("/work/dint"). With(daggerExec("mod", "init", "--name=d", "--sdk=go")). WithNewFile("main.go", dagger.ContainerWithNewFileOpts{ Contents: `package main type D struct{} type Obj struct { Foo int } func (m *D) Fn(foo int) Obj { return Obj{Foo: foo} } `, }) ctr = ctr. WithWorkdir("/work"). With(daggerExec("mod", "init", "-m=c", "--name=c", "--sdk=go")). WithWorkdir("/work/c"). With(daggerExec("mod", "install", "../dstr")). WithNewFile("main.go", dagger.ContainerWithNewFileOpts{ Contents: `package main import (
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/integration/module_test.go
"context" ) type C struct{} func (m *C) Fn(ctx context.Context, foo string) (string, error) { return dag.D().Fn(foo).Foo(ctx) } `, }) ctr = ctr. WithWorkdir("/work"). With(daggerExec("mod", "init", "-m=b", "--name=b", "--sdk=go")). With(daggerExec("mod", "install", "-m=b", "./dint")). WithNewFile("/work/b/main.go", dagger.ContainerWithNewFileOpts{ Contents: `package main import ( "context" ) type B struct{} func (m *B) Fn(ctx context.Context, foo int) (int, error) { return dag.D().Fn(foo).Foo(ctx) } `, }) ctr = ctr. WithWorkdir("/work"). With(daggerExec("mod", "init", "-m=a", "--name=a", "--sdk=go")). WithWorkdir("/work/a"). With(daggerExec("mod", "install", "../b")). With(daggerExec("mod", "install", "../c")). WithNewFile("main.go", dagger.ContainerWithNewFileOpts{
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/integration/module_test.go
Contents: `package main import ( "context" "strconv" ) type A struct{} func (m *A) Fn(ctx context.Context) (string, error) { fooStr, err := dag.C().Fn(ctx, "foo") if err != nil { return "", err } fooInt, err := dag.B().Fn(ctx, 123) if err != nil { return "", err } return fooStr + strconv.Itoa(fooInt), nil } `, }) out, err := ctr.With(daggerQuery(`{a{fn}}`)).Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"a":{"fn": "foo123"}}`, out) types := currentSchema(ctx, t, ctr).Types require.NotNil(t, types.Get("A")) require.Nil(t, types.Get("B")) require.Nil(t, types.Get("C")) require.Nil(t, types.Get("D")) } func TestModuleSelfAPICall(t *testing.T) {
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/integration/module_test.go
t.Parallel() c, ctx := connect(t) out, err := c.Container().From(golangImage). WithMountedFile(testCLIBinPath, daggerCliFile(t, c)). WithWorkdir("/work"). With(daggerExec("mod", "init", "--name=test", "--sdk=go")). WithNewFile("main.go", dagger.ContainerWithNewFileOpts{ Contents: `package main import ( "context" "github.com/Khan/genqlient/graphql" ) type Test struct{} func (m *Test) FnA(ctx context.Context) (string, error) { resp := &graphql.Response{} err := dag.c.MakeRequest(ctx, &graphql.Request{ Query: "{test{fnB}}", }, resp) if err != nil { return "", err } return resp.Data.(map[string]any)["test"].(map[string]any)["fnB"].(string), nil } func (m *Test) FnB() string { return "hi from b"
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/integration/module_test.go
} `, }). With(daggerQuery(`{test{fnA}}`)). Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"test":{"fnA": "hi from b"}}`, out) } func TestModuleGoWithOtherModuleTypes(t *testing.T) { t.Parallel() c, ctx := connect(t) ctr := c.Container().From(golangImage). WithMountedFile(testCLIBinPath, daggerCliFile(t, c)). WithWorkdir("/work/dep"). With(daggerExec("mod", "init", "--name=dep", "--sdk=go")). WithNewFile("main.go", dagger.ContainerWithNewFileOpts{ Contents: `package main type Dep struct{} type Obj struct { Foo string } func (m *Dep) Fn() Obj { return Obj{Foo: "foo"} } `, }). WithWorkdir("/work"). With(daggerExec("mod", "init", "-m=test", "--name=test", "--sdk=go")). With(daggerExec("mod", "install", "-m=test", "./dep")). WithWorkdir("/work/test")
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/integration/module_test.go
t.Run("return as other module object", func(t *testing.T) { t.Run("direct", func(t *testing.T) { _, err := ctr. WithNewFile("main.go", dagger.ContainerWithNewFileOpts{ Contents: `package main type Test struct{} func (m *Test) Fn() (*DepObj, error) { return nil, nil } `, }). With(daggerFunctions()). Stdout(ctx) require.Error(t, err) require.ErrorContains(t, err, fmt.Sprintf( "object %q function %q cannot return external type from dependency module %q", "Test", "Fn", "dep", )) }) t.Run("list", func(t *testing.T) { _, err := ctr. WithNewFile("main.go", dagger.ContainerWithNewFileOpts{ Contents: `package main type Test struct{} func (m *Test) Fn() ([]*DepObj, error) { return nil, nil } `, }). With(daggerFunctions()).
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/integration/module_test.go
Stdout(ctx) require.Error(t, err) require.ErrorContains(t, err, fmt.Sprintf( "object %q function %q cannot return external type from dependency module %q", "Test", "Fn", "dep", )) }) }) t.Run("arg as other module object", func(t *testing.T) { t.Run("direct", func(t *testing.T) { _, err := ctr.WithNewFile("main.go", dagger.ContainerWithNewFileOpts{ Contents: `package main type Test struct{} func (m *Test) Fn(obj *DepObj) error { return nil } `, }). With(daggerFunctions()). Stdout(ctx) require.Error(t, err) require.ErrorContains(t, err, fmt.Sprintf( "object %q function %q arg %q cannot reference external type from dependency module %q", "Test", "Fn", "obj", "dep", )) }) t.Run("list", func(t *testing.T) { _, err := ctr.WithNewFile("main.go", dagger.ContainerWithNewFileOpts{ Contents: `package main type Test struct{}
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/integration/module_test.go
func (m *Test) Fn(obj []*DepObj) error { return nil } `, }). With(daggerFunctions()). Stdout(ctx) require.Error(t, err) require.ErrorContains(t, err, fmt.Sprintf( "object %q function %q arg %q cannot reference external type from dependency module %q", "Test", "Fn", "obj", "dep", )) }) }) t.Run("field as other module object", func(t *testing.T) { t.Run("direct", func(t *testing.T) { _, err := ctr. WithNewFile("main.go", dagger.ContainerWithNewFileOpts{ Contents: `package main type Test struct{} type Obj struct { Foo *DepObj } func (m *Test) Fn() (*Obj, error) { return nil, nil } `, }). With(daggerFunctions()). Stdout(ctx)
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/integration/module_test.go
require.Error(t, err) require.ErrorContains(t, err, fmt.Sprintf( "object %q field %q cannot reference external type from dependency module %q", "Obj", "Foo", "dep", )) }) t.Run("list", func(t *testing.T) { _, err := ctr. WithNewFile("main.go", dagger.ContainerWithNewFileOpts{ Contents: `package main type Test struct{} type Obj struct { Foo []*DepObj } func (m *Test) Fn() (*Obj, error) { return nil, nil } `, }). With(daggerFunctions()). Stdout(ctx) require.Error(t, err) require.ErrorContains(t, err, fmt.Sprintf( "object %q field %q cannot reference external type from dependency module %q", "Obj", "Foo", "dep", )) }) }) } func TestModulePythonWithOtherModuleTypes(t *testing.T) {
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/integration/module_test.go
t.Parallel() c, ctx := connect(t) ctr := c.Container().From(golangImage). WithMountedFile(testCLIBinPath, daggerCliFile(t, c)). WithWorkdir("/work/dep"). With(daggerExec("mod", "init", "--name=dep", "--sdk=python")). WithNewFile("src/main.py", dagger.ContainerWithNewFileOpts{ Contents: `from dagger import field, function, object_type @object_type class Foo: ... @object_type class Obj: foo: str = field() @object_type class Dep: @function def fn(self) -> Obj: return Obj(foo="foo") `, }). WithWorkdir("/work"). With(daggerExec("mod", "init", "-m=test", "--name=test", "--sdk=python")). WithWorkdir("/work/test"). With(daggerExec("mod", "install", "../dep")) t.Run("return as other module object", func(t *testing.T) { t.Run("direct", func(t *testing.T) { _, err := ctr. WithNewFile("src/main.py", dagger.ContainerWithNewFileOpts{
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/integration/module_test.go
Contents: `import dagger @dagger.object_type class Test: @dagger.function def fn(self) -> dagger.DepObj: ... `, }). With(daggerFunctions()). Stdout(ctx) require.Error(t, err) require.Regexp(t, fmt.Sprintf( `object\s+%q\s+function\s+%q\s+cannot\s+return\s+external\s+type\s+from\s+dependency\s+module\s+%q`, "Test", "fn", "dep", ), err.Error()) }) t.Run("list", func(t *testing.T) { _, err := ctr. WithNewFile("src/main.py", dagger.ContainerWithNewFileOpts{ Contents: `import dagger @dagger.object_type class Test: @dagger.function def fn(self) -> list[dagger.DepObj]: ... `, }). With(daggerFunctions()). Stdout(ctx) require.Error(t, err)
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/integration/module_test.go
require.Regexp(t, fmt.Sprintf( `object\s+%q\s+function\s+%q\s+cannot\s+return\s+external\s+type\s+from\s+dependency\s+module\s+%q`, "Test", "fn", "dep", ), err.Error()) }) }) t.Run("arg as other module object", func(t *testing.T) { t.Run("direct", func(t *testing.T) { _, err := ctr.WithNewFile("src/main.py", dagger.ContainerWithNewFileOpts{ Contents: `import dagger @dagger.object_type class Test: @dagger.function def fn(self, obj: dagger.DepObj): ... `, }). With(daggerFunctions()). Stdout(ctx) require.Error(t, err) require.Regexp(t, fmt.Sprintf( `object\s+%q\s+function\s+%q\s+arg\s+%q\s+cannot\s+reference\s+external\s+type\s+from\s+dependency\s+module\s+%q`, "Test", "fn", "obj", "dep", ), err.Error()) }) t.Run("list", func(t *testing.T) { _, err := ctr.WithNewFile("src/main.py", dagger.ContainerWithNewFileOpts{ Contents: `import dagger @dagger.object_type class Test:
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/integration/module_test.go
@dagger.function def fn(self, obj: list[dagger.DepObj]): ... `, }). With(daggerFunctions()). Stdout(ctx) require.Error(t, err) require.Regexp(t, fmt.Sprintf( `object\s+%q\s+function\s+%q\s+arg\s+%q\s+cannot\s+reference\s+external\s+type\s+from\s+dependency\s+module\s+%q`, "Test", "fn", "obj", "dep", ), err.Error()) }) }) t.Run("field as other module object", func(t *testing.T) { t.Run("direct", func(t *testing.T) { _, err := ctr. WithNewFile("src/main.py", dagger.ContainerWithNewFileOpts{ Contents: `import dagger @dagger.object_type class Obj: foo: dagger.DepObj = dagger.field() @dagger.object_type class Test: @dagger.function def fn(self) -> Obj: ... `, }). With(daggerFunctions()).
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/integration/module_test.go
Stdout(ctx) require.Error(t, err) require.Regexp(t, fmt.Sprintf( `object\s+%q\s+field\s+%q\s+cannot\s+reference\s+external\s+type\s+from\s+dependency\s+module\s+%q`, "Obj", "foo", "dep", ), err.Error()) }) t.Run("list", func(t *testing.T) { _, err := ctr. WithNewFile("src/main.py", dagger.ContainerWithNewFileOpts{ Contents: `import dagger @dagger.object_type class Obj: foo: list[dagger.DepObj] = dagger.field() @dagger.object_type class Test: @dagger.function def fn(self) -> list[Obj]: ... `, }). With(daggerFunctions()). Stdout(ctx) require.Error(t, err) require.Regexp(t, fmt.Sprintf( `object\s+%q\s+field\s+%q\s+cannot\s+reference\s+external\s+type\s+from\s+dependency\s+module\s+%q`, "Obj", "foo", "dep", ), err.Error()) }) })
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/integration/module_test.go
} var useInner = `package main type Dep struct{} func (m *Dep) Hello() string { return "hello" } ` var useGoOuter = `package main import "context" type Use struct{} func (m *Use) UseHello(ctx context.Context) (string, error) { return dag.Dep().Hello(ctx) } ` var usePythonOuter = `from dagger import dag, function @function def use_hello() -> str: return dag.dep().hello() ` var useTSOuter = ` import { dag, object, func } from '@dagger.io/dagger' @object class Use { @func async useHello(): Promise<string> { return dag.dep().hello() } } ` func TestModuleUseLocal(t *testing.T) {
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/integration/module_test.go
t.Parallel() type testCase struct { sdk string source string } for _, tc := range []testCase{ { sdk: "go", source: useGoOuter, }, { sdk: "python", source: usePythonOuter, }, { sdk: "typescript", source: useTSOuter, },
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/integration/module_test.go
} { tc := tc t.Run(fmt.Sprintf("%s uses go", tc.sdk), func(t *testing.T) { t.Parallel() c, ctx := connect(t) modGen := c.Container().From(golangImage). WithMountedFile(testCLIBinPath, daggerCliFile(t, c)). WithWorkdir("/work/dep"). With(daggerExec("mod", "init", "--name=dep", "--sdk=go")). With(sdkSource("go", useInner)). WithWorkdir("/work"). With(daggerExec("mod", "init", "--name=use", "--sdk="+tc.sdk)). With(sdkSource(tc.sdk, tc.source)). With(daggerExec("mod", "install", "./dep")) if tc.sdk == "go" { logGen(ctx, t, modGen.Directory(".")) } out, err := modGen.With(daggerQuery(`{use{useHello}}`)).Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"use":{"useHello":"hello"}}`, out) _, err = modGen.With(daggerQuery(`{dep{hello}}`)).Stdout(ctx) require.Error(t, err) require.ErrorContains(t, err, `Query has no such field: "dep"`) }) } } func TestModuleCodegenOnDepChange(t *testing.T) { t.Parallel() type testCase struct {
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/integration/module_test.go
sdk string source string changed string expected string } for _, tc := range []testCase{ { sdk: "go", source: useGoOuter, expected: "Hellov2", changed: strings.ReplaceAll(useGoOuter, `Hello(ctx)`, `Hellov2(ctx)`), }, { sdk: "python", source: usePythonOuter, expected: "hellov2", changed: strings.ReplaceAll(usePythonOuter, `.hello()`, `.hellov2()`), }, { sdk: "typescript", source: useTSOuter, expected: "hellov2", changed: strings.ReplaceAll(useTSOuter, `.hello()`, `.hellov2()`), }, } { tc := tc t.Run(fmt.Sprintf("%s uses go", tc.sdk), func(t *testing.T) { t.Parallel() c, ctx := connect(t) modGen := c.Container().From(golangImage).
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/integration/module_test.go
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)). WithWorkdir("/work/dep"). With(daggerExec("mod", "init", "--name=dep", "--sdk=go")). With(sdkSource("go", useInner)). WithWorkdir("/work"). With(daggerExec("mod", "init", "--name=use", "--sdk="+tc.sdk)). With(sdkSource(tc.sdk, tc.source)). With(daggerExec("mod", "install", "./dep")) if tc.sdk == "go" { logGen(ctx, t, modGen.Directory(".")) } out, err := modGen.With(daggerQuery(`{use{useHello}}`)).Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"use":{"useHello":"hello"}}`, out) newInner := strings.ReplaceAll(useInner, `Hello()`, `Hellov2()`) modGen = modGen. WithWorkdir("/work/dep"). With(sdkSource("go", newInner)). WithWorkdir("/work"). With(daggerExec("mod", "sync")) codegenContents, err := modGen.File(sdkCodegenFile(t, tc.sdk)).Contents(ctx) require.NoError(t, err) require.Contains(t, codegenContents, tc.expected) modGen = modGen.With(sdkSource(tc.sdk, tc.changed)) out, err = modGen.With(daggerQuery(`{use{useHello}}`)).Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"use":{"useHello":"hello"}}`, out) }) }
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/integration/module_test.go
} func TestModuleSyncDeps(t *testing.T) { t.Parallel() type testCase struct { sdk string source string } for _, tc := range []testCase{ { sdk: "go", source: useGoOuter, }, { sdk: "python", source: usePythonOuter, }, { sdk: "typescript", source: useTSOuter, }, } { tc := tc t.Run(fmt.Sprintf("%s uses go", tc.sdk), func(t *testing.T) { t.Parallel() c, ctx := connect(t) modGen := c.Container().From(golangImage). WithMountedFile(testCLIBinPath, daggerCliFile(t, c)). WithWorkdir("/work/dep"). With(daggerExec("mod", "init", "--name=dep", "--sdk=go")).
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/integration/module_test.go
With(sdkSource("go", useInner)). WithWorkdir("/work"). With(daggerExec("mod", "init", "--name=use", "--sdk="+tc.sdk)). With(sdkSource(tc.sdk, tc.source)). With(daggerExec("mod", "install", "./dep")) if tc.sdk == "go" { logGen(ctx, t, modGen.Directory(".")) } modGen = modGen.With(daggerQuery(`{use{useHello}}`)) out, err := modGen.Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"use":{"useHello":"hello"}}`, out) newInner := strings.ReplaceAll(useInner, `"hello"`, `"goodbye"`) modGen = modGen. WithWorkdir("/work/dep"). With(sdkSource("go", newInner)). WithWorkdir("/work"). With(daggerExec("mod", "sync")) if tc.sdk == "go" { logGen(ctx, t, modGen.Directory(".")) } out, err = modGen.With(daggerQuery(`{use{useHello}}`)).Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"use":{"useHello":"goodbye"}}`, out) }) } } func TestModuleUseLocalMulti(t *testing.T) { t.Parallel() type testCase struct {
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/integration/module_test.go
sdk string source string } for _, tc := range []testCase{ { sdk: "go", source: `package main import "context" import "fmt" type Use struct {} func (m *Use) Names(ctx context.Context) ([]string, error) { fooName, err := dag.Foo().Name(ctx) if err != nil { return nil, fmt.Errorf("foo.name: %w", err) } barName, err := dag.Bar().Name(ctx) if err != nil { return nil, fmt.Errorf("bar.name: %w", err) } return []string{fooName, barName}, nil } `, }, { sdk: "python", source: `from dagger import dag, function @function async def names() -> list[str]:
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/integration/module_test.go
return [ await dag.foo().name(), await dag.bar().name(), ] `, }, { sdk: "typescript", source: ` import { dag, object, func } from '@dagger.io/dagger' @object class Use { @func async names(): Promise<string[]> { return [await dag.foo().name(), await dag.bar().name()] } } `, }, } { tc := tc t.Run(fmt.Sprintf("%s uses go", tc.sdk), func(t *testing.T) { t.Parallel() c, ctx := connect(t) modGen := c.Container().From(golangImage). WithMountedFile(testCLIBinPath, daggerCliFile(t, c)). WithWorkdir("/work/foo"). WithNewFile("/work/foo/main.go", dagger.ContainerWithNewFileOpts{ Contents: `package main type Foo struct {}
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/integration/module_test.go
func (m *Foo) Name() string { return "foo" } `, }). With(daggerExec("mod", "init", "--name=foo", "--sdk=go")). WithWorkdir("/work/bar"). WithNewFile("/work/bar/main.go", dagger.ContainerWithNewFileOpts{ Contents: `package main type Bar struct {} func (m *Bar) Name() string { return "bar" } `, }). With(daggerExec("mod", "init", "--name=bar", "--sdk=go")). WithWorkdir("/work"). With(daggerExec("mod", "init", "--name=use", "--sdk="+tc.sdk)). With(daggerExec("mod", "install", "./foo")). With(daggerExec("mod", "install", "./bar")). With(sdkSource(tc.sdk, tc.source)). WithEnvVariable("BUST", identity.NewID()) if tc.sdk == "go" { logGen(ctx, t, modGen.Directory(".")) } out, err := modGen.With(daggerQuery(`{use{names}}`)).Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"use":{"names":["foo", "bar"]}}`, out) }) } } func TestModuleConstructor(t *testing.T) { t.Parallel() type testCase struct {
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/integration/module_test.go
sdk string source string } t.Run("basic", func(t *testing.T) { t.Parallel() for _, tc := range []testCase{ { sdk: "go", source: `package main import ( "context" ) func New( ctx context.Context, foo string, bar Optional[int], baz []string, dir *Directory, ) *Test { return &Test{ Foo: foo, Bar: bar.GetOr(42), Baz: baz, Dir: dir,
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/integration/module_test.go
} } type Test struct { Foo string Bar int Baz []string Dir *Directory NeverSetDir *Directory } func (m *Test) GimmeFoo() string { return m.Foo } func (m *Test) GimmeBar() int { return m.Bar } func (m *Test) GimmeBaz() []string { return m.Baz } func (m *Test) GimmeDirEnts(ctx context.Context) ([]string, error) { return m.Dir.Entries(ctx) } `, }, { sdk: "python", source: `import dagger from dagger import field, function, object_type @object_type class Test: foo: str = field()
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/integration/module_test.go
dir: dagger.Directory = field() bar: int = field(default=42) baz: list[str] = field(default=list) never_set_dir: dagger.Directory | None = field(default=None) @function def gimme_foo(self) -> str: return self.foo @function def gimme_bar(self) -> int: return self.bar @function def gimme_baz(self) -> list[str]: return self.baz @function async def gimme_dir_ents(self) -> list[str]: return await self.dir.entries() `, }, { sdk: "typescript", source: ` import { Directory, object, func, field } from '@dagger.io/dagger'; @object class Test { @field foo: string @field dir: Directory @field bar: number