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
@field baz: string[] @field neverSetDir?: Directory constructor(foo: string, dir: Directory, bar = 42, baz: string[] = []) { this.foo = foo; this.dir = dir; this.bar = bar; this.baz = baz; } @func gimmeFoo(): string { return this.foo; } @func gimmeBar(): number { return this.bar; } @func gimmeBaz(): string[] { return this.baz; } @func async gimmeDirEnts(): Promise<string[]> { return this.dir.entries(); } } `, }, } {
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) ctr := c.Container().From(golangImage). WithMountedFile(testCLIBinPath, daggerCliFile(t, c)). WithWorkdir("/work/test"). With(daggerExec("mod", "init", "--name=test", "--sdk="+tc.sdk)). With(sdkSource(tc.sdk, tc.source)) out, err := ctr.With(daggerCall("--foo=abc", "--baz=x,y,z", "--dir=.", "foo")).Stdout(ctx) require.NoError(t, err) require.Equal(t, strings.TrimSpace(out), "abc") out, err = ctr.With(daggerCall("--foo=abc", "--baz=x,y,z", "--dir=.", "gimme-foo")).Stdout(ctx) require.NoError(t, err) require.Equal(t, strings.TrimSpace(out), "abc") out, err = ctr.With(daggerCall("--foo=abc", "--baz=x,y,z", "--dir=.", "bar")).Stdout(ctx) require.NoError(t, err) require.Equal(t, strings.TrimSpace(out), "42") out, err = ctr.With(daggerCall("--foo=abc", "--baz=x,y,z", "--dir=.", "gimme-bar")).Stdout(ctx) require.NoError(t, err) require.Equal(t, strings.TrimSpace(out), "42") out, err = ctr.With(daggerCall("--foo=abc", "--bar=123", "--baz=x,y,z", "--dir=.", "bar")).Stdout(ctx) require.NoError(t, err) require.Equal(t, strings.TrimSpace(out), "123") out, err = ctr.With(daggerCall("--foo=abc", "--bar=123", "--baz=x,y,z", "--dir=.", "gimme-bar")).Stdout(ctx) require.NoError(t, err) require.Equal(t, strings.TrimSpace(out), "123") out, err = ctr.With(daggerCall("--foo=abc", "--bar=123", "--baz=x,y,z", "--dir=.", "baz")).Stdout(ctx) require.NoError(t, err) require.Equal(t, strings.TrimSpace(out), "x\ny\nz")
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 = ctr.With(daggerCall("--foo=abc", "--bar=123", "--baz=x,y,z", "--dir=.", "gimme-baz")).Stdout(ctx) require.NoError(t, err) require.Equal(t, strings.TrimSpace(out), "x\ny\nz") out, err = ctr.With(daggerCall("--foo=abc", "--bar=123", "--baz=x,y,z", "--dir=.", "gimme-dir-ents")).Stdout(ctx) require.NoError(t, err) require.Contains(t, strings.TrimSpace(out), "dagger.json") }) } }) t.Run("fields only", func(t *testing.T) { t.Parallel() for _, tc := range []testCase{ { sdk: "go", source: `package main import ( "context" ) func New(ctx context.Context) (Test, error) { v, err := dag.Container().From("alpine:3.18.4").File("/etc/alpine-release").Contents(ctx) if err != nil { return Test{}, err } return Test{ AlpineVersion: v, }, nil } type Test struct { AlpineVersion 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
`, }, { sdk: "python", source: `from dagger import dag, field, function, object_type @object_type class Test: alpine_version: str = field() @classmethod async def create(cls) -> "Test": return cls(alpine_version=await ( dag.container() .from_("alpine:3.18.4") .file("/etc/alpine-release") .contents() )) `, }, { sdk: "typescript", source: ` import { dag, object, field } from "@dagger.io/dagger" @object class Test { @field alpineVersion: string // NOTE: this is standard to do async operations in the constructor. // This is only for testing purpose but it shouldn't be done in real usage. constructor() { return (async () => {
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
this.alpineVersion = await dag.container().from("alpine:3.18.4").file("/etc/alpine-release").contents() return this; // Return the newly-created instance })(); } } `, }, } { tc := tc t.Run(tc.sdk, func(t *testing.T) { t.Parallel() c, ctx := connect(t) ctr := c.Container().From(golangImage). WithMountedFile(testCLIBinPath, daggerCliFile(t, c)). WithWorkdir("/work/test"). With(daggerExec("mod", "init", "--name=test", "--sdk="+tc.sdk)). With(sdkSource(tc.sdk, tc.source)) out, err := ctr.With(daggerCall("alpine-version")).Stdout(ctx) require.NoError(t, err) require.Equal(t, strings.TrimSpace(out), "3.18.4") }) } }) t.Run("return error", func(t *testing.T) { t.Parallel() for _, tc := range []testCase{ { sdk: "go", source: `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
"fmt" ) func New() (*Test, error) { return nil, fmt.Errorf("too bad") } type Test struct { Foo string } `, }, { sdk: "python", source: `from dagger import object_type, field @object_type class Test: foo: str = field() def __init__(self): raise ValueError("too bad") `, }, { sdk: "typescript", source: ` import { object, field } from "@dagger.io/dagger" @object class Test { @field foo: string constructor() { throw new Error("too bad")
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() var logs safeBuffer c, ctx := connect(t, dagger.WithLogOutput(&logs)) ctr := c.Container().From(golangImage). WithMountedFile(testCLIBinPath, daggerCliFile(t, c)). WithWorkdir("/work/test"). With(daggerExec("mod", "init", "--name=test", "--sdk="+tc.sdk)). With(sdkSource(tc.sdk, tc.source)) _, err := ctr.With(daggerCall("foo")).Stdout(ctx) require.Error(t, err) require.NoError(t, c.Close()) t.Log(logs.String()) require.Contains(t, logs.String(), "too bad") }) } }) t.Run("python: with default factory", func(t *testing.T) { t.Parallel() c, ctx := connect(t) content := identity.NewID() ctr := c.Container().From(golangImage). WithMountedFile(testCLIBinPath, daggerCliFile(t, c)). 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
With(daggerExec("mod", "init", "--name=test", "--sdk=python")). With(sdkSource("python", fmt.Sprintf(`import dagger from dagger import dag, object_type, field @object_type class Test: foo: dagger.File = field(default=lambda: ( dag.directory() .with_new_file("foo.txt", contents="%s") .file("foo.txt") )) bar: list[str] = field(default=list) `, content), )) out, err := ctr.With(daggerCall("foo", "contents")).Stdout(ctx) require.NoError(t, err) require.Equal(t, content, strings.TrimSpace(out)) out, err = ctr.With(daggerCall("--foo=dagger.json", "foo", "contents")).Stdout(ctx) require.NoError(t, err) require.Contains(t, out, `"sdk": "python"`) _, err = ctr.With(daggerCall("bar")).Sync(ctx) require.NoError(t, err) }) t.Run("typescript: with default factory", func(t *testing.T) { t.Parallel() c, ctx := connect(t) content := identity.NewID() ctr := c.Container().From(golangImage). WithMountedFile(testCLIBinPath, daggerCliFile(t, c)). WithWorkdir("/work/test"). With(daggerExec("mod", "init", "--name=test", "--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
With(sdkSource("typescript", fmt.Sprintf(` import { dag, File, object, field } from "@dagger.io/dagger" @object class Test { @field foo: File = dag.directory().withNewFile("foo.txt", "%s").file("foo.txt") @field bar: string[] = [] // Allow foo to be set through the constructor constructor(foo?: File) { if (foo) { this.foo = foo } } } `, content), )) out, err := ctr.With(daggerCall("foo", "contents")).Stdout(ctx) require.NoError(t, err) require.Equal(t, content, strings.TrimSpace(out)) out, err = ctr.With(daggerCall("--foo=dagger.json", "foo", "contents")).Stdout(ctx) require.NoError(t, err) require.Contains(t, out, `"sdk": "typescript"`) _, err = ctr.With(daggerCall("bar")).Sync(ctx) require.NoError(t, err) }) } func TestModuleWrapping(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 Wrapper struct{} func (m *Wrapper) Container() *WrappedContainer { return &WrappedContainer{ dag.Container().From("alpine"), } } type WrappedContainer struct { Unwrap *Container` + "`" + `json:"unwrap"` + "`" + ` } func (c *WrappedContainer) Echo(msg string) *WrappedContainer {
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 &WrappedContainer{ c.Unwrap.WithExec([]string{"echo", "-n", msg}), } } `, }, { sdk: "python", source: `from typing import Self import dagger from dagger import dag, field, function, object_type @object_type class WrappedContainer: unwrap: dagger.Container = field() @function def echo(self, msg: str) -> Self: return WrappedContainer(unwrap=self.unwrap.with_exec(["echo", "-n", msg])) @object_type class Wrapper: @function def container(self) -> WrappedContainer: return WrappedContainer(unwrap=dag.container().from_("alpine")) `, }, { sdk: "typescript", source: ` import { dag, Container, object, func, field } from "@dagger.io/dagger" @object class WrappedContainer {
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
@field unwrap: Container constructor(unwrap: Container) { this.unwrap = unwrap } @func echo(msg: string): WrappedContainer { return new WrappedContainer(this.unwrap.withExec(["echo", "-n", msg])) } } @object class Wrapper { @func container(): WrappedContainer { return new WrappedContainer(dag.container().from("alpine")) } } `, }, } { 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=wrapper", "--sdk="+tc.sdk)). With(sdkSource(tc.sdk, tc.source)) if tc.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
logGen(ctx, t, modGen.Directory(".")) } id := identity.NewID() out, err := modGen.With(daggerQuery( fmt.Sprintf(`{wrapper{container{echo(msg:%q){unwrap{stdout}}}}}`, id), )).Stdout(ctx) require.NoError(t, err) require.JSONEq(t, fmt.Sprintf(`{"wrapper":{"container":{"echo":{"unwrap":{"stdout":%q}}}}}`, id), out) }) } } func TestModuleTypescriptInit(t *testing.T) { 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=typescript")) 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)
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
modGen := c.Container().From(golangImage). WithMountedFile(testCLIBinPath, daggerCliFile(t, c)). WithWorkdir("/work"). With(daggerExec("mod", "init", "-m=child", "--name=bare", "--sdk=typescript")) 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) out, err = modGen. WithWorkdir("/work/child"). With(daggerQuery(`{bare{containerEcho(stringArg:"hello"){stdout}}}`)). Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"bare":{"containerEcho":{"stdout":"hello\n"}}}`, out) }) t.Run("camel-cases Dagger module name", 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=My-Module", "--sdk=typescript")) out, err := modGen. With(daggerQuery(`{myModule{containerEcho(stringArg:"hello"){stdout}}}`)). Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"myModule":{"containerEcho":{"stdout":"hello\n"}}}`, out) }) t.Run("respect existing package.json", 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/package.json", dagger.ContainerWithNewFileOpts{ Contents: `{ "name": "my-module", "version": "1.0.0", "description": "My module", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "author": "John doe", "license": "MIT" }`, }). With(daggerExec("mod", "init", "--name=hasPkgJson", "--sdk=typescript")) out, err := modGen. With(daggerQuery(`{hasPkgJson{containerEcho(stringArg:"hello"){stdout}}}`)). Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"hasPkgJson":{"containerEcho":{"stdout":"hello\n"}}}`, out) t.Run("Add dagger dependencies to the existing package.json", func(t *testing.T) { pkgJSON, err := modGen.File("/work/package.json").Contents(ctx) require.NoError(t, err) require.Contains(t, pkgJSON, `"@dagger.io/dagger":`) require.Contains(t, pkgJSON, `"name": "my-module"`) })
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("respect existing tsconfig.json", func(t *testing.T) { t.Parallel() c, ctx := connect(t) modGen := c.Container().From(golangImage). WithMountedFile(testCLIBinPath, daggerCliFile(t, c)). WithWorkdir("/work"). WithNewFile("/work/tsconfig.json", dagger.ContainerWithNewFileOpts{ Contents: `{ "compilerOptions": { "target": "ES2022", "moduleResolution": "Node", "experimentalDecorators": true } }`, }). With(daggerExec("mod", "init", "--name=hasTsConfig", "--sdk=typescript")) out, err := modGen. With(daggerQuery(`{hasTsConfig{containerEcho(stringArg:"hello"){stdout}}}`)). Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"hasTsConfig":{"containerEcho":{"stdout":"hello\n"}}}`, out) t.Run("Add dagger paths to the existing tsconfig.json", func(t *testing.T) { tsConfig, err := modGen.File("/work/tsconfig.json").Contents(ctx) require.NoError(t, err) require.Contains(t, tsConfig, `"@dagger.io/dagger":`) }) }) t.Run("respect existing src/index.ts", func(t *testing.T) { t.Parallel()
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
c, ctx := connect(t) modGen := c.Container().From(golangImage). WithMountedFile(testCLIBinPath, daggerCliFile(t, c)). WithWorkdir("/work"). WithDirectory("/work/src", c.Directory()). WithNewFile("/work/src/index.ts", dagger.ContainerWithNewFileOpts{ Contents: ` import { dag, Container, object, func } from "@dagger.io/dagger" @object // eslint-disable-next-line @typescript-eslint/no-unused-vars class ExistingSource { /** * example usage: "dagger call container-echo --string-arg yo" */ @func helloWorld(stringArg: string): Container { return dag.container().from("alpine:latest").withExec(["echo", stringArg]) } } `, }). With(daggerExec("mod", "init", "--name=existingSource", "--sdk=typescript")) out, err := modGen. With(daggerQuery(`{existingSource{helloWorld(stringArg:"hello"){stdout}}}`)). Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"existingSource":{"helloWorld":{"stdout":"hello\n"}}}`, out) }) } func TestModuleLotsOfFunctions(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() const funcCount = 100 t.Run("go sdk", func(t *testing.T) { t.Parallel() c, ctx := connect(t) mainSrc := ` package main type PotatoSack struct {} ` for i := 0; i < funcCount; i++ { mainSrc += fmt.Sprintf(` func (m *PotatoSack) Potato%d() string { return "potato #%d" } `, i, i) } modGen := c.Container().From(golangImage). WithMountedFile(testCLIBinPath, daggerCliFile(t, c)). WithWorkdir("/work"). WithNewFile("/work/main.go", dagger.ContainerWithNewFileOpts{ Contents: mainSrc, }). With(daggerExec("mod", "init", "--name=potatoSack", "--sdk=go")) logGen(ctx, t, modGen.Directory(".")) var eg errgroup.Group for i := 0; i < funcCount; i++ { i := i
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
if i%10 != 0 { continue } eg.Go(func() error { _, err := modGen. With(daggerCall(fmt.Sprintf("potato%d", i))). Sync(ctx) return err }) } require.NoError(t, eg.Wait()) }) t.Run("python sdk", func(t *testing.T) { t.Parallel() c, ctx := connect(t) mainSrc := `from dagger import function ` for i := 0; i < funcCount; i++ { mainSrc += fmt.Sprintf(` @function def potato_%d() -> str: return "potato #%d" `, i, i) } modGen := c.Container().From(golangImage). WithMountedFile(testCLIBinPath, daggerCliFile(t, c)). WithWorkdir("/work"). WithNewFile("./src/main.py", dagger.ContainerWithNewFileOpts{ Contents: mainSrc,
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=potatoSack", "--sdk=python")) var eg errgroup.Group for i := 0; i < funcCount; i++ { i := i if i%10 != 0 { continue } eg.Go(func() error { _, err := modGen. With(daggerCall(fmt.Sprintf("potato%d", i))). Sync(ctx) return err }) } require.NoError(t, eg.Wait()) }) t.Run("typescript sdk", func(t *testing.T) { t.Parallel() c, ctx := connect(t) mainSrc := ` import { object, func } from "@dagger.io/dagger" @object class PotatoSack { ` for i := 0; i < funcCount; i++ { mainSrc += fmt.Sprintf(` @func potato_%d(): 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
return "potato #%d" } `, i, i) } mainSrc += "\n}" modGen := c. Container(). From(golangImage). WithMountedFile(testCLIBinPath, daggerCliFile(t, c)). WithWorkdir("/work"). With(sdkSource("typescript", mainSrc)). With(daggerExec("mod", "init", "--name=potatoSack", "--sdk=typescript")) var eg errgroup.Group for i := 0; i < funcCount; i++ { i := i if i%10 != 0 { continue } eg.Go(func() error { _, err := modGen. With(daggerCall(fmt.Sprintf("potato%d", i))). Sync(ctx) return err }) } require.NoError(t, eg.Wait()) }) } func TestModuleLotsOfDeps(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") modCount := 0 getModMainSrc := func(name string, depNames []string) string { t.Helper() mainSrc := fmt.Sprintf(`package main import "context" type %s struct {} func (m *%s) Fn(ctx context.Context) (string, error) { s := "%s" var depS string _ = depS var err error _ = err `, strcase.ToCamel(name), strcase.ToCamel(name), name) for _, depName := range depNames { mainSrc += fmt.Sprintf(` depS, err = dag.%s().Fn(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
if err != nil { return "", err } s += depS `, strcase.ToCamel(depName)) } mainSrc += "return s, nil\n}\n" fmted, err := format.Source([]byte(mainSrc)) require.NoError(t, err) return string(fmted) } var rootCfg modules.ModuleConfig addModulesWithDeps := func(newMods int, depNames []string) []string { t.Helper() var newModNames []string for i := 0; i < newMods; i++ { name := fmt.Sprintf("mod%d", modCount) modCount++ newModNames = append(newModNames, name) modGen = modGen. WithWorkdir("/work/"+name). WithNewFile("./main.go", dagger.ContainerWithNewFileOpts{ Contents: getModMainSrc(name, depNames), }) var depCfgs []*modules.ModuleConfigDependency for _, depName := range depNames { depCfgs = append(depCfgs, &modules.ModuleConfigDependency{ Name: depName,
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
Source: filepath.Join("..", depName), }) } modGen = modGen.With(configFile(".", &modules.ModuleConfig{ Name: name, SDK: "go", Dependencies: depCfgs, })) rootCfg.RootFor = append(rootCfg.RootFor, &modules.ModuleConfigRootFor{ Source: name, }) } return newModNames } curDeps := addModulesWithDeps(1, nil) for i := 0; i < 6; i++ { curDeps = addModulesWithDeps(len(curDeps)+1, curDeps) } addModulesWithDeps(1, curDeps) modGen = modGen.With(configFile("..", &rootCfg)) _, err := modGen.With(daggerCall("fn")).Sync(ctx) require.NoError(t, err) } func TestModuleNamespacing(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) moduleSrcPath, err := filepath.Abs("./testdata/modules/go/namespacing") require.NoError(t, err) ctr := c.Container().From(alpineImage). WithMountedFile(testCLIBinPath, daggerCliFile(t, c)). WithMountedDirectory("/work", c.Host().Directory(moduleSrcPath)). WithWorkdir("/work") out, err := ctr. With(daggerQuery(`{test{fn(s:"yo")}}`)). Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"test":{"fn":["*main.Sub1Obj made 1:yo", "*main.Sub2Obj made 2:yo"]}}`, out) } func TestModuleLoops(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) _, err := c.Container().From(golangImage). WithMountedFile(testCLIBinPath, daggerCliFile(t, c)). With(daggerExec("mod", "init", "-m=depA", "--name=depA", "--sdk=go")). With(daggerExec("mod", "init", "-m=depB", "--name=depB", "--sdk=go")). With(daggerExec("mod", "init", "-m=depC", "--name=depC", "--sdk=go")). With(daggerExec("mod", "install", "-m=depC", "./depB")). With(daggerExec("mod", "install", "-m=depB", "./depA")). With(daggerExec("mod", "install", "-m=depA", "./depC")). Sync(ctx) require.ErrorContains(t, err, "module depA has a circular dependency") } var badIDArgGoSrc string var badIDArgPySrc string var badIDArgTSSrc string var badIDFieldGoSrc string var badIDFieldTSSrc string var badIDFnGoSrc string var badIDFnPySrc string var badIDFnTSSrc string func TestModuleReservedWords(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("id", func(t *testing.T) { t.Parallel() t.Run("arg", func(t *testing.T) { t.Parallel() 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: badIDArgGoSrc, }, { sdk: "python", source: badIDArgPySrc, }, { sdk: "typescript", source: badIDArgTSSrc, }, } { tc := tc t.Run(tc.sdk, func(t *testing.T) { t.Parallel() c, ctx := connect(t) _, err := 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)). With(daggerQuery(`{test{fn(id:"no")}}`)). Sync(ctx) require.ErrorContains(t, err, "cannot define argument with reserved name \"id\"") }) } }) t.Run("field", func(t *testing.T) { t.Parallel()
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
for _, tc := range []testCase{ { sdk: "go", source: badIDFieldGoSrc, }, { sdk: "typescript", source: badIDFieldTSSrc, }, } { tc := tc t.Run(tc.sdk, func(t *testing.T) { t.Parallel() c, ctx := connect(t) _, err := 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)). With(daggerQuery(`{test{fn{id}}}`)). Sync(ctx) require.ErrorContains(t, err, "cannot define field with reserved name \"id\"") }) } }) t.Run("fn", func(t *testing.T) { t.Parallel() for _, tc := range []testCase{ { 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
source: badIDFnGoSrc, }, { sdk: "python", source: badIDFnPySrc, }, { sdk: "typescript", source: badIDFnTSSrc, }, } { tc := tc t.Run(tc.sdk, func(t *testing.T) { t.Parallel() c, ctx := connect(t) _, err := 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)). With(daggerQuery(`{test{id}}`)). Sync(ctx) require.ErrorContains(t, err, "cannot define function with reserved name \"id\"") }) } }) }) } var tsSyntax string func TestModuleTypescriptSyntaxSupport(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=syntax", "--sdk=typescript")). WithNewFile("src/index.ts", dagger.ContainerWithNewFileOpts{ Contents: tsSyntax, }) t.Run("singleQuoteDefaultArgHello(msg: string = 'world'): string", func(t *testing.T) { t.Parallel() defaultOut, err := modGen.With(daggerQuery(`{syntax{singleQuoteDefaultArgHello}}`)).Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"syntax":{"singleQuoteDefaultArgHello":"hello world"}}`, defaultOut) out, err := modGen.With(daggerQuery(`{syntax{singleQuoteDefaultArgHello(msg: "dagger")}}`)).Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"syntax":{"singleQuoteDefaultArgHello":"hello dagger"}}`, out) }) t.Run("doubleQuotesDefaultArgHello(msg: string = \"world\"): string", func(t *testing.T) { t.Parallel() defaultOut, err := modGen.With(daggerQuery(`{syntax{doubleQuotesDefaultArgHello}}`)).Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"syntax":{"doubleQuotesDefaultArgHello":"hello world"}}`, defaultOut) out, err := modGen.With(daggerQuery(`{syntax{doubleQuotesDefaultArgHello(msg: "dagger")}}`)).Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"syntax":{"doubleQuotesDefaultArgHello":"hello dagger"}}`, out) }) } func TestModuleExecError(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(alpineImage). WithMountedFile(testCLIBinPath, daggerCliFile(t, c)). WithWorkdir("/work"). With(daggerExec("mod", "init", "--name=playground", "--sdk=go")). WithNewFile("main.go", dagger.ContainerWithNewFileOpts{ Contents: ` package main import ( "context" "errors" ) type Playground struct{} func (p *Playground) DoThing(ctx context.Context) error { _, err := dag.Container().From("alpine").WithExec([]string{"sh", "-c", "exit 5"}).Sync(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
var e *ExecError if errors.As(err, &e) { if e.ExitCode == 5 { return nil } } panic("yikes") } `}) logGen(ctx, t, modGen.Directory(".")) _, err := modGen. With(daggerQuery(`{playground{doThing}}`)). Stdout(ctx) require.NoError(t, err) } func TestModuleCurrentModuleAPI(t *testing.T) { t.Parallel() c, ctx := connect(t) t.Run("name", func(t *testing.T) { t.Parallel() out, err := c.Container().From(golangImage). WithMountedFile(testCLIBinPath, daggerCliFile(t, c)). WithWorkdir("/work"). With(daggerExec("mod", "init", "--name=WaCkY", "--sdk=go")). WithNewFile("/work/main.go", dagger.ContainerWithNewFileOpts{ Contents: `package main import "context" type WaCkY struct {} func (m *WaCkY) Fn(ctx context.Context) (string, error) { return dag.CurrentModule().Name(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
} `, }). With(daggerCall("fn")). Stdout(ctx) require.NoError(t, err) require.Equal(t, "WaCkY", strings.TrimSpace(out)) }) t.Run("source", func(t *testing.T) { t.Parallel() out, err := c.Container().From(golangImage). WithMountedFile(testCLIBinPath, daggerCliFile(t, c)). WithWorkdir("/work"). With(daggerExec("mod", "init", "--name=test", "--sdk=go")). WithNewFile("/work/subdir/coolfile.txt", dagger.ContainerWithNewFileOpts{ Contents: "nice", }). WithNewFile("/work/main.go", dagger.ContainerWithNewFileOpts{ Contents: `package main import "context" type Test struct {} func (m *Test) Fn(ctx context.Context) *File { return dag.CurrentModule().Source().File("subdir/coolfile.txt") } `, }). With(daggerCall("fn", "contents")). Stdout(ctx) require.NoError(t, err) require.Equal(t, "nice", strings.TrimSpace(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
}) t.Run("workdir", func(t *testing.T) { t.Parallel() t.Run("dir", func(t *testing.T) { t.Parallel() out, err := c.Container().From(golangImage). WithMountedFile(testCLIBinPath, daggerCliFile(t, c)). WithWorkdir("/work"). With(daggerExec("mod", "init", "--name=test", "--sdk=go")). WithNewFile("/work/main.go", dagger.ContainerWithNewFileOpts{ Contents: `package main import ( "context" "os" ) type Test struct {} func (m *Test) Fn(ctx context.Context) (*Directory, error) { if err := os.MkdirAll("subdir/moresubdir", 0755); err != nil { return nil, err } if err := os.WriteFile("subdir/moresubdir/coolfile.txt", []byte("nice"), 0644); err != nil { return nil, err } return dag.CurrentModule().Workdir("subdir/moresubdir"), nil } `, }). With(daggerCall("fn", "file", "--path=coolfile.txt", "contents")). 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.Equal(t, "nice", strings.TrimSpace(out)) }) t.Run("file", func(t *testing.T) { t.Parallel() out, err := c.Container().From(golangImage). WithMountedFile(testCLIBinPath, daggerCliFile(t, c)). WithWorkdir("/work"). With(daggerExec("mod", "init", "--name=test", "--sdk=go")). WithNewFile("/work/main.go", dagger.ContainerWithNewFileOpts{ Contents: `package main import ( "context" "os" ) type Test struct {} func (m *Test) Fn(ctx context.Context) (*File, error) { if err := os.MkdirAll("subdir/moresubdir", 0755); err != nil { return nil, err } if err := os.WriteFile("subdir/moresubdir/coolfile.txt", []byte("nice"), 0644); err != nil { return nil, err } return dag.CurrentModule().WorkdirFile("subdir/moresubdir/coolfile.txt"), nil } `, }). With(daggerCall("fn", "contents")). Stdout(ctx) require.NoError(t, err) require.Equal(t, "nice", strings.TrimSpace(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
}) t.Run("error on escape", func(t *testing.T) { t.Parallel() ctr := c.Container().From(golangImage). WithMountedFile(testCLIBinPath, daggerCliFile(t, c)). WithWorkdir("/work"). With(daggerExec("mod", "init", "--name=test", "--sdk=go")). WithNewFile("/work/main.go", dagger.ContainerWithNewFileOpts{ Contents: `package main import ( "context" "os" ) func New() (*Test, error) { if err := os.WriteFile("/rootfile.txt", []byte("notnice"), 0644); err != nil { return nil, err } if err := os.MkdirAll("/foo", 0755); err != nil { return nil, err } if err := os.WriteFile("/foo/foofile.txt", []byte("notnice"), 0644); err != nil { return nil, err } return &Test{}, nil } type Test struct {} func (m *Test) EscapeFile(ctx context.Context) *File { return dag.CurrentModule().WorkdirFile("../rootfile.txt") } func (m *Test) EscapeFileAbs(ctx context.Context) *File {
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 dag.CurrentModule().WorkdirFile("/rootfile.txt") } func (m *Test) EscapeDir(ctx context.Context) *Directory { return dag.CurrentModule().Workdir("../foo") } func (m *Test) EscapeDirAbs(ctx context.Context) *Directory { return dag.CurrentModule().Workdir("/foo") } `, }) _, err := ctr. With(daggerCall("escape-file", "contents")). Stdout(ctx) require.ErrorContains(t, err, `workdir path "../rootfile.txt" escapes workdir`) _, err = ctr. With(daggerCall("escape-file-abs", "contents")). Stdout(ctx) require.ErrorContains(t, err, `workdir path "/rootfile.txt" escapes workdir`) _, err = ctr. With(daggerCall("escape-dir", "entries")). Stdout(ctx) require.ErrorContains(t, err, `workdir path "../foo" escapes workdir`) _, err = ctr. With(daggerCall("escape-dir-abs", "entries")). Stdout(ctx) require.ErrorContains(t, err, `workdir path "/foo" escapes workdir`) }) }) } func TestModuleCustomSDK(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/coolsdk"). With(daggerExec("mod", "init", "--name=cool-sdk", "--sdk=go")). WithNewFile("main.go", dagger.ContainerWithNewFileOpts{ Contents: `package main type CoolSdk struct {} func (m *CoolSdk) ModuleRuntime(modSource *ModuleSource, introspectionJson string) *Container { return modSource.AsModule().WithSDK("go").Initialize().Runtime().WithEnvVariable("COOL", "true") } func (m *CoolSdk) Codegen(modSource *ModuleSource, introspectionJson string) *GeneratedCode { existingConfig := modSource.Directory("/").File("dagger.json") return dag.GeneratedCode(modSource. AsModule(). WithSDK("go"). GeneratedSourceRootDirectory().
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
WithFile("dagger.json", existingConfig), ) } `, }). WithWorkdir("/work"). With(daggerExec("mod", "init", "--name=test", "--sdk=coolsdk")). WithNewFile("main.go", dagger.ContainerWithNewFileOpts{ Contents: `package main import "os" type Test struct {} func (m *Test) Fn() string { return os.Getenv("COOL") } `, }) out, err := ctr. With(daggerCall("fn")). Stdout(ctx) require.NoError(t, err) require.Equal(t, "true", strings.TrimSpace(out)) } func daggerExec(args ...string) dagger.WithContainerFunc { return func(c *dagger.Container) *dagger.Container { return c.WithExec(append([]string{"dagger", "--debug"}, args...), dagger.ContainerWithExecOpts{ ExperimentalPrivilegedNesting: true, }) } } func daggerQuery(query string, args ...any) dagger.WithContainerFunc {
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 daggerQueryAt("", query, args...) } func daggerQueryAt(modPath string, query string, args ...any) dagger.WithContainerFunc { query = fmt.Sprintf(query, args...) return func(c *dagger.Container) *dagger.Container { execArgs := []string{"dagger", "--debug", "query"} if modPath != "" { execArgs = append(execArgs, "-m", modPath) } return c.WithExec(execArgs, dagger.ContainerWithExecOpts{ Stdin: query, ExperimentalPrivilegedNesting: true, }) } } func daggerCall(args ...string) dagger.WithContainerFunc { return daggerCallAt("", args...) } func daggerCallAt(modPath string, args ...string) dagger.WithContainerFunc { return func(c *dagger.Container) *dagger.Container { execArgs := []string{"dagger", "--debug", "call"} if modPath != "" { execArgs = append(execArgs, "-m", modPath) } return c.WithExec(append(execArgs, args...), dagger.ContainerWithExecOpts{ ExperimentalPrivilegedNesting: true, }) } } func daggerFunctions(args ...string) dagger.WithContainerFunc {
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 func(c *dagger.Container) *dagger.Container { return c.WithExec(append([]string{"dagger", "--debug", "functions"}, args...), dagger.ContainerWithExecOpts{ ExperimentalPrivilegedNesting: true, }) } } func configFile(dirPath string, cfg *modules.ModuleConfig) dagger.WithContainerFunc { return func(c *dagger.Container) *dagger.Container { cfgPath := filepath.Join(dirPath, "dagger.json") cfgBytes, err := json.Marshal(cfg) if err != nil { panic(err) } return c.WithNewFile(cfgPath, dagger.ContainerWithNewFileOpts{ Contents: string(cfgBytes), }) } } func hostDaggerCommand(ctx context.Context, t testing.TB, workdir string, args ...string) *exec.Cmd { t.Helper() cmd := exec.CommandContext(ctx, daggerCliPath(t), args...) cmd.Dir = workdir return cmd } func hostDaggerExec(ctx context.Context, t testing.TB, workdir string, args ...string) ([]byte, 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
t.Helper() cmd := hostDaggerCommand(ctx, t, workdir, args...) output, err := cmd.CombinedOutput() if err != nil { err = fmt.Errorf("%s: %w", string(output), err) } return output, err } func sdkSource(sdk, contents string) dagger.WithContainerFunc { return func(c *dagger.Container) *dagger.Container { var sourcePath string switch sdk { case "go": sourcePath = "main.go" case "python": sourcePath = "src/main.py" case "typescript": sourcePath = "src/index.ts" default: return c } return c.WithNewFile(sourcePath, dagger.ContainerWithNewFileOpts{ Contents: contents, }) } } func sdkCodegenFile(t *testing.T, sdk string) 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.Helper() switch sdk { case "go": return "dagger.gen.go" case "python": return "sdk/src/dagger/client/gen.py" case "typescript": return "sdk/api/client.gen.ts" default: return "" } } func currentSchema(ctx context.Context, t *testing.T, ctr *dagger.Container) *introspection.Schema {
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.Helper() out, err := ctr.With(daggerQuery(introspection.Query)).Stdout(ctx) require.NoError(t, err) var schemaResp introspection.Response err = json.Unmarshal([]byte(out), &schemaResp) require.NoError(t, err) return schemaResp.Schema } func goGitBase(t *testing.T, c *dagger.Client) *dagger.Container { t.Helper() return c.Container().From(golangImage). WithExec([]string{"apk", "add", "git"}). WithExec([]string{"git", "config", "--global", "user.email", "dagger@example.com"}). WithExec([]string{"git", "config", "--global", "user.name", "Dagger Tests"}). WithMountedFile(testCLIBinPath, daggerCliFile(t, c)). WithWorkdir("/work"). WithExec([]string{"git", "init"}) } func logGen(ctx context.Context, t *testing.T, modSrc *dagger.Directory) {
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.Helper() generated, err := modSrc.File("dagger.gen.go").Contents(ctx) require.NoError(t, err) t.Cleanup(func() { t.Name() fileName := filepath.Join( os.TempDir(), t.Name(), fmt.Sprintf("dagger.gen.%d.go", time.Now().Unix()), ) if err := os.MkdirAll(filepath.Dir(fileName), 0o755); err != nil { t.Logf("failed to create temp dir for generated code: %v", err) return } if err := os.WriteFile(fileName, []byte(generated), 0644); err != nil { t.Logf("failed to write generated code to %s: %v", fileName, err) } else { t.Logf("wrote generated code to %s", fileName) } }) }
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/moddeps.go
package core import ( "context" "encoding/json" "fmt" "sync" "github.com/dagger/dagger/cmd/codegen/introspection" "github.com/dagger/dagger/dagql" dagintro "github.com/dagger/dagger/dagql/introspection" "github.com/dagger/dagger/tracing" ) const ( modMetaDirPath = "/.daggermod" modMetaOutputPath = "output.json" ModuleName = "daggercore" ) /* ModDeps represents a set of dependencies for a module or for a caller depending on a particular set of modules to be served. */ type ModDeps 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/moddeps.go
root *Query Mods []Mod lazilyLoadedSchema *dagql.Server lazilyLoadedIntrospectionJSON string loadSchemaErr error loadSchemaLock sync.Mutex } func NewModDeps(root *Query, mods []Mod) *ModDeps { return &ModDeps{ root: root, Mods: mods, } } func (d *ModDeps) Prepend(mods ...Mod) *ModDeps { deps := append([]Mod{}, mods...) deps = append(deps, d.Mods...) return NewModDeps(d.root, deps) } func (d *ModDeps) Append(mods ...Mod) *ModDeps {
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/moddeps.go
deps := append([]Mod{}, d.Mods...) deps = append(deps, mods...) return NewModDeps(d.root, deps) } func (d *ModDeps) Schema(ctx context.Context) (*dagql.Server, error) { schema, _, err := d.lazilyLoadSchema(ctx) if err != nil { return nil, err } return schema, nil } func (d *ModDeps) SchemaIntrospectionJSON(ctx context.Context) (string, error) { _, introspectionJSON, err := d.lazilyLoadSchema(ctx) if err != nil { return "", err } return introspectionJSON, nil } func (d *ModDeps) TypeDefs(ctx context.Context) ([]*TypeDef, error) { var typeDefs []*TypeDef for _, mod := range d.Mods { modTypeDefs, err := mod.TypeDefs(ctx) if err != nil { return nil, fmt.Errorf("failed to get objects from mod %q: %w", mod.Name(), err) } typeDefs = append(typeDefs, modTypeDefs...) } return typeDefs, nil } func schemaIntrospectionJSON(ctx context.Context, dag *dagql.Server) (json.RawMessage, 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/moddeps.go
data, err := dag.Query(ctx, introspection.Query, nil) if err != nil { return nil, fmt.Errorf("introspection query failed: %w", err) } jsonBytes, err := json.Marshal(data) if err != nil { return nil, fmt.Errorf("failed to marshal introspection result: %w", err) } return json.RawMessage(jsonBytes), nil } func (d *ModDeps) lazilyLoadSchema(ctx context.Context) (loadedSchema *dagql.Server, loadedIntrospectionJSON string, rerr error) { d.loadSchemaLock.Lock() defer d.loadSchemaLock.Unlock() if d.lazilyLoadedSchema != nil { return d.lazilyLoadedSchema, d.lazilyLoadedIntrospectionJSON, nil } if d.loadSchemaErr != nil { return nil, "", d.loadSchemaErr } defer func() { d.lazilyLoadedSchema = loadedSchema d.lazilyLoadedIntrospectionJSON = loadedIntrospectionJSON d.loadSchemaErr = rerr }() dag := dagql.NewServer[*Query](d.root)
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/moddeps.go
dag.Around(tracing.AroundFunc) dag.Cache = d.root.Cache dagintro.Install[*Query](dag) var objects []*ModuleObjectType var ifaces []*InterfaceType for _, mod := range d.Mods { err := mod.Install(ctx, dag) if err != nil { return nil, "", fmt.Errorf("failed to get schema for module %q: %w", mod.Name(), err) } if userMod, ok := mod.(*Module); ok { defs, err := mod.TypeDefs(ctx) if err != nil { return nil, "", fmt.Errorf("failed to get type defs for module %q: %w", mod.Name(), err) } for _, def := range defs { switch def.Kind { case TypeDefKindObject: objects = append(objects, &ModuleObjectType{ typeDef: def.AsObject.Value, mod: userMod, }) case TypeDefKindInterface: ifaces = append(ifaces, &InterfaceType{ typeDef: def.AsInterface.Value, mod: userMod, }) }
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/moddeps.go
} } } for _, objType := range objects { obj := objType.typeDef class, found := dag.ObjectType(obj.Name) if !found { return nil, "", fmt.Errorf("failed to find object %q in schema", obj.Name) } for _, ifaceType := range ifaces { iface := ifaceType.typeDef if !obj.IsSubtypeOf(iface) { continue } objType := objType ifaceType := ifaceType asIfaceFieldName := gqlFieldName(fmt.Sprintf("as%s", iface.Name)) class.Extend( dagql.FieldSpec{ Name: asIfaceFieldName, Description: fmt.Sprintf("Converts this %s to a %s.", obj.Name, iface.Name), Type: &InterfaceAnnotatedValue{TypeDef: iface}, Module: ifaceType.mod.InstanceID, }, func(ctx context.Context, self dagql.Object, args map[string]dagql.Input) (dagql.Typed, error) { inst, ok := self.(dagql.Instance[*ModuleObject]) if !ok { return nil, fmt.Errorf("expected %T to be a ModuleObject", self) }
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/moddeps.go
return &InterfaceAnnotatedValue{ TypeDef: iface, Fields: inst.Self.Fields, UnderlyingType: objType, IfaceType: ifaceType, }, nil }, ) } } introspectionJSON, err := schemaIntrospectionJSON(ctx, dag) if err != nil { return nil, "", fmt.Errorf("failed to get schema introspection JSON: %w", err) } return dag, string(introspectionJSON), nil } func (d *ModDeps) ModTypeFor(ctx context.Context, typeDef *TypeDef) (ModType, bool, error) { for _, mod := range d.Mods { modType, ok, err := mod.ModTypeFor(ctx, typeDef, false) if err != nil { return nil, false, fmt.Errorf("failed to get type from mod %q: %w", mod.Name(), err) } if !ok { continue } return modType, true, nil } return nil, false, nil }
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/module.go
package core import ( "context" "fmt" "log/slog" "sort" "strings" "time" "github.com/dagger/dagger/dagql" "github.com/dagger/dagger/dagql/idproto" "github.com/moby/buildkit/solver/pb" "github.com/opencontainers/go-digest" "github.com/pkg/errors" "github.com/vektah/gqlparser/v2/ast" "golang.org/x/sync/errgroup" ) type Module 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/module.go
Query *Query Source dagql.Instance[*ModuleSource] `field:"true" name:"source" doc:"The source for the module."` NameField string `field:"true" name:"name" doc:"The name of the module"` OriginalName string Description string `field:"true" doc:"The doc string of the module, if any"` SDKConfig string `field:"true" name:"sdk" doc:"The SDK used by this module. Either a name of a builtin SDK or a module source ref string pointing to the SDK's implementation."` GeneratedSourceRootDirectory dagql.Instance[*Directory]
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/module.go
GeneratedSourceSubpath string DependencyConfig []*ModuleDependency `field:"true" doc:"The dependencies as configured by the module."` DependenciesField []dagql.Instance[*Module] `field:"true" name:"dependencies" doc:"Modules used by this module."` Deps *ModDeps DirectoryIncludeConfig []string DirectoryExcludeConfig []string Runtime *Container `field:"true" name:"runtime" doc:"The container that runs the module's entrypoint. It will fail to execute if the module doesn't compile."` ObjectDefs []*TypeDef `field:"true" name:"objects" doc:"Objects served by this module."` InterfaceDefs []*TypeDef `field:"true" name:"interfaces" doc:"Interfaces served by this module."` InstanceID *idproto.ID } func (*Module) Type() *ast.Type { return &ast.Type{ NamedType: "Module", NonNull: true, } } func (*Module) TypeDescription() string { return "A Dagger module." } type ModuleDependency 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/module.go
Source dagql.Instance[*ModuleSource] `field:"true" name:"source" doc:"The source for the dependency module."` Name string `field:"true" name:"name" doc:"The name of the dependency module."` } func (*ModuleDependency) Type() *ast.Type { return &ast.Type{ NamedType: "ModuleDependency", NonNull: true, } } func (*ModuleDependency) TypeDescription() string { return "The configuration of dependency of a module." } func (dep ModuleDependency) Clone() *ModuleDependency { cp := dep cp.Source.Self = dep.Source.Self.Clone() return &cp } var _ Mod = (*Module)(nil) func (mod *Module) Name() string { return mod.NameField
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/module.go
} func (mod *Module) Dependencies() []Mod { mods := make([]Mod, len(mod.DependenciesField)) for i, dep := range mod.DependenciesField { mods[i] = dep.Self } return mods } func (mod *Module) WithName(ctx context.Context, name string) (*Module, error) { if mod.InstanceID != nil { return nil, fmt.Errorf("cannot update name on initialized module") } mod = mod.Clone() mod.NameField = name if mod.OriginalName == "" { mod.OriginalName = name } return mod, nil } func (mod *Module) WithSDK(ctx context.Context, sdk string) (*Module, error) { if mod.InstanceID != nil { return nil, fmt.Errorf("cannot update sdk on initialized module") } mod = mod.Clone() mod.SDKConfig = sdk return mod, nil } func (mod *Module) WithDependencies( ctx context.Context, srv *dagql.Server,
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/module.go
dependencies []*ModuleDependency, ) (*Module, error) { if mod.InstanceID != nil { return nil, fmt.Errorf("cannot update dependencies on initialized module") } if mod.Source.Self == nil { return nil, fmt.Errorf("cannot update dependencies on module without source") } mod = mod.Clone() clonedDependencies := make([]*ModuleDependency, len(dependencies)) for i, dep := range dependencies { clonedDependencies[i] = dep.Clone() } var eg errgroup.Group for i, dep := range dependencies { if dep.Source.Self == nil { return nil, fmt.Errorf("dependency %d has no source", i) } i, dep := i, dep eg.Go(func() error { err := srv.Select(ctx, mod.Source, &clonedDependencies[i].Source, dagql.Selector{ Field: "resolveDependency", Args: []dagql.NamedInput{ {Name: "dep", Value: dagql.NewID[*ModuleSource](dep.Source.ID())}, }, }, ) if err != nil {
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/module.go
return fmt.Errorf("failed to resolve dependency module: %w", err) } return nil }) } if err := eg.Wait(); err != nil { return nil, err } depSet := make(map[string]*ModuleDependency) for _, dep := range mod.DependencyConfig { symbolic, err := dep.Source.Self.Symbolic() if err != nil { return nil, fmt.Errorf("failed to get symbolic source ref: %w", err) } depSet[symbolic] = dep } for _, newDep := range clonedDependencies { symbolic, err := newDep.Source.Self.Symbolic() if err != nil { return nil, fmt.Errorf("failed to get symbolic source ref: %w", err) } depSet[symbolic] = newDep } mod.DependencyConfig = make([]*ModuleDependency, 0, len(depSet)) for _, dep := range depSet { mod.DependencyConfig = append(mod.DependencyConfig, dep) }
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/module.go
refStrs := make([]string, 0, len(mod.DependencyConfig)) for _, dep := range mod.DependencyConfig { refStr, err := dep.Source.Self.RefString() if err != nil { return nil, fmt.Errorf("failed to get ref string for dependency: %w", err) } refStrs = append(refStrs, refStr) } sort.Slice(mod.DependencyConfig, func(i, j int) bool { return refStrs[i] < refStrs[j] }) mod.DependenciesField = make([]dagql.Instance[*Module], len(mod.DependencyConfig)) eg = errgroup.Group{} for i, depCfg := range mod.DependencyConfig { i, depCfg := i, depCfg eg.Go(func() error { err := srv.Select(ctx, depCfg.Source, &mod.DependenciesField[i], dagql.Selector{ Field: "asModule", }, dagql.Selector{ Field: "withName", Args: []dagql.NamedInput{ {Name: "name", Value: dagql.NewString(depCfg.Name)}, }, }, dagql.Selector{ Field: "initialize", }, )
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/module.go
if err != nil { return fmt.Errorf("failed to initialize dependency module: %w", err) } return nil }) } if err := eg.Wait(); err != nil { if errors.Is(err, dagql.ErrCacheMapRecursiveCall) { err = fmt.Errorf("module %s has a circular dependency: %w", mod.NameField, err) } return nil, fmt.Errorf("failed to load updated dependencies: %w", err) } for i, dep := range mod.DependencyConfig { if dep.Name == "" { dep.Name = mod.DependenciesField[i].Self.Name() } } selfDgst, err := mod.Source.ID().Digest() if err != nil { return nil, fmt.Errorf("failed to get digest of module source: %w", err) } memo := make(map[digest.Digest]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/module.go
var visit func(dagql.Instance[*Module]) error visit = func(inst dagql.Instance[*Module]) error { instDgst, err := inst.Self.Source.ID().Digest() if err != nil { return fmt.Errorf("failed to get digest of module source: %w", err) } if instDgst == selfDgst { return fmt.Errorf("module %s has a circular dependency", mod.NameField) } if _, ok := memo[instDgst]; ok { return nil } memo[instDgst] = 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/module.go
for _, dep := range inst.Self.DependenciesField { if err := visit(dep); err != nil { return err } } return nil } for _, dep := range mod.DependenciesField { if err := visit(dep); err != nil { return nil, err } } mod.Deps = NewModDeps(mod.Query, mod.Dependencies()). Append(mod.Query.DefaultDeps.Mods...) return mod, nil } func (mod *Module) Initialize(ctx context.Context, oldSelf dagql.Instance[*Module], newID *idproto.ID) (*Module, error) { getModDefFn, err := newModFunction( ctx, mod.Query, oldSelf.Self, oldSelf.ID(), nil, mod.Runtime,
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/module.go
NewFunction("", &TypeDef{ Kind: TypeDefKindObject, AsObject: dagql.NonNull(NewObjectTypeDef("Module", "")), })) if err != nil { return nil, fmt.Errorf("failed to create module definition function for module %q: %w", mod.Name(), err) } result, err := getModDefFn.Call(ctx, newID, &CallOpts{Cache: true, SkipSelfSchema: true}) if err != nil { return nil, fmt.Errorf("failed to call module %q to get functions: %w", mod.Name(), err) } inst, ok := result.(dagql.Instance[*Module]) if !ok { return nil, fmt.Errorf("expected Module result, got %T", result) } newMod := mod.Clone() newMod.Description = inst.Self.Description for _, obj := range inst.Self.ObjectDefs { newMod, err = newMod.WithObject(ctx, obj) if err != nil { return nil, fmt.Errorf("failed to add object to module %q: %w", mod.Name(), err) } } for _, iface := range inst.Self.InterfaceDefs { newMod, err = newMod.WithInterface(ctx, iface) if err != nil { return nil, fmt.Errorf("failed to add interface to module %q: %w", mod.Name(), err) } } newMod.InstanceID = newID
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/module.go
return newMod, nil } func (mod *Module) Install(ctx context.Context, dag *dagql.Server) error { slog.Debug("installing module", "name", mod.Name()) start := time.Now() defer func() { slog.Debug("done installing module", "name", mod.Name(), "took", time.Since(start)) }() for _, def := range mod.ObjectDefs { objDef := def.AsObject.Value slog.Debug("installing object", "name", mod.Name(), "object", objDef.Name) modType, ok, err := mod.Deps.ModTypeFor(ctx, def) if err != nil { return fmt.Errorf("failed to get mod type for type def: %w", err) } if ok { return fmt.Errorf("type %q is already defined by module %q", objDef.Name, modType.SourceMod().Name()) } obj := &ModuleObject{ Module: mod, TypeDef: objDef, } if err := obj.Install(ctx, dag); err != nil { return err } } for _, def := range mod.InterfaceDefs {
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/module.go
ifaceDef := def.AsInterface.Value slog.Debug("installing interface", "name", mod.Name(), "interface", ifaceDef.Name) iface := &InterfaceType{ typeDef: ifaceDef, mod: mod, } if err := iface.Install(ctx, dag); err != nil { return err } } return nil } func (mod *Module) TypeDefs(ctx context.Context) ([]*TypeDef, error) { typeDefs := make([]*TypeDef, 0, len(mod.ObjectDefs)+len(mod.InterfaceDefs)) for _, def := range mod.ObjectDefs { typeDef := def.Clone() if typeDef.AsObject.Valid { typeDef.AsObject.Value.SourceModuleName = mod.Name() } typeDefs = append(typeDefs, typeDef) } for _, def := range mod.InterfaceDefs { typeDef := def.Clone() if typeDef.AsInterface.Valid { typeDef.AsInterface.Value.SourceModuleName = mod.Name() } typeDefs = append(typeDefs, typeDef) } return typeDefs, nil }
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/module.go
func (mod *Module) DependencySchemaIntrospectionJSON(ctx context.Context) (string, error) { return mod.Deps.SchemaIntrospectionJSON(ctx) } func (mod *Module) ModTypeFor(ctx context.Context, typeDef *TypeDef, checkDirectDeps bool) (ModType, bool, error) { var modType ModType switch typeDef.Kind { case TypeDefKindString, TypeDefKindInteger, TypeDefKindBoolean, TypeDefKindVoid: modType = &PrimitiveType{typeDef} case TypeDefKindList: underlyingType, ok, err := mod.ModTypeFor(ctx, typeDef.AsList.Value.ElementTypeDef, checkDirectDeps) if err != nil { return nil, false, fmt.Errorf("failed to get underlying type: %w", err) } if !ok { return nil, false, nil } modType = &ListType{ Elem: typeDef.AsList.Value.ElementTypeDef, Underlying: underlyingType, } case TypeDefKindObject: if checkDirectDeps { depType, ok, err := mod.Deps.ModTypeFor(ctx, typeDef) if err != nil { return nil, false, fmt.Errorf("failed to get type from dependency: %w", err) } if ok { return depType, true, nil }
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/module.go
} var found bool for _, obj := range mod.ObjectDefs { if obj.AsObject.Value.Name == typeDef.AsObject.Value.Name { modType = &ModuleObjectType{ typeDef: obj.AsObject.Value, mod: mod, } found = true break } } if !found { slog.Debug("module did not find object", "mod", mod.Name(), "object", typeDef.AsObject.Value.Name) return nil, false, nil } case TypeDefKindInterface: if checkDirectDeps { depType, ok, err := mod.Deps.ModTypeFor(ctx, typeDef) if err != nil { return nil, false, fmt.Errorf("failed to get interface type from dependency: %w", err) } if ok { return depType, true, nil } } var found bool
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/module.go
for _, iface := range mod.InterfaceDefs { if iface.AsInterface.Value.Name == typeDef.AsInterface.Value.Name { modType = &InterfaceType{ mod: mod, typeDef: iface.AsInterface.Value, } found = true break } } if !found { slog.Debug("module did not find interface", "mod", mod.Name(), "interface", typeDef.AsInterface.Value.Name) return nil, false, nil } default: return nil, false, fmt.Errorf("unexpected type def kind %s", typeDef.Kind) } if typeDef.Optional { modType = &NullableType{ InnerDef: typeDef.WithOptional(false), Inner: modType, } } return modType, true, nil } func (mod *Module) validateTypeDef(ctx context.Context, typeDef *TypeDef) error { switch typeDef.Kind { case TypeDefKindList: return mod.validateTypeDef(ctx, typeDef.AsList.Value.ElementTypeDef) case TypeDefKindObject:
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/module.go
return mod.validateObjectTypeDef(ctx, typeDef) case TypeDefKindInterface: return mod.validateInterfaceTypeDef(ctx, typeDef) } return nil } func (mod *Module) validateObjectTypeDef(ctx context.Context, typeDef *TypeDef) error { modType, ok, err := mod.Deps.ModTypeFor(ctx, typeDef) if err != nil { return fmt.Errorf("failed to get mod type for type def: %w", err) } if ok { if sourceMod := modType.SourceMod(); sourceMod != nil && sourceMod != mod { return nil } } obj := typeDef.AsObject.Value for _, field := range obj.Fields { if gqlFieldName(field.Name) == "id" { return fmt.Errorf("cannot define field with reserved name %q on object %q", field.Name, obj.Name) } fieldType, ok, err := mod.Deps.ModTypeFor(ctx, field.TypeDef) if err != nil { return fmt.Errorf("failed to get mod type for type def: %w", err) } if ok { sourceMod := fieldType.SourceMod()
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/module.go
if sourceMod != nil && sourceMod.Name() != ModuleName && sourceMod != mod { return fmt.Errorf("object %q field %q cannot reference external type from dependency module %q", obj.OriginalName, field.OriginalName, sourceMod.Name(), ) } } if err := mod.validateTypeDef(ctx, field.TypeDef); err != nil { return err } } for _, fn := range obj.Functions { if gqlFieldName(fn.Name) == "id" { return fmt.Errorf("cannot define function with reserved name %q on object %q", fn.Name, obj.Name) } retType, ok, err := mod.Deps.ModTypeFor(ctx, fn.ReturnType) if err != nil { return fmt.Errorf("failed to get mod type for type def: %w", err) } if ok { if sourceMod := retType.SourceMod(); sourceMod != nil && sourceMod.Name() != ModuleName && sourceMod != mod { return fmt.Errorf("object %q function %q cannot return external type from dependency module %q", obj.OriginalName, fn.OriginalName, sourceMod.Name(), )
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/module.go
} } if err := mod.validateTypeDef(ctx, fn.ReturnType); err != nil { return err } for _, arg := range fn.Args { if gqlArgName(arg.Name) == "id" { return fmt.Errorf("cannot define argument with reserved name %q on function %q", arg.Name, fn.Name) } argType, ok, err := mod.Deps.ModTypeFor(ctx, arg.TypeDef) if err != nil { return fmt.Errorf("failed to get mod type for type def: %w", err) } if ok { if sourceMod := argType.SourceMod(); sourceMod != nil && sourceMod.Name() != ModuleName && sourceMod != mod { return fmt.Errorf("object %q function %q arg %q cannot reference external type from dependency module %q", obj.OriginalName, fn.OriginalName, arg.OriginalName, sourceMod.Name(), ) } } if err := mod.validateTypeDef(ctx, arg.TypeDef); err != nil { return err } } } return nil
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/module.go
} func (mod *Module) validateInterfaceTypeDef(ctx context.Context, typeDef *TypeDef) error { iface := typeDef.AsInterface.Value modType, ok, err := mod.Deps.ModTypeFor(ctx, typeDef) if err != nil { return fmt.Errorf("failed to get mod type for type def: %w", err) } if ok { if sourceMod := modType.SourceMod(); sourceMod != nil && sourceMod != mod { return nil } } for _, fn := range iface.Functions { if gqlFieldName(fn.Name) == "id" { return fmt.Errorf("cannot define function with reserved name %q on interface %q", fn.Name, iface.Name) } if err := mod.validateTypeDef(ctx, fn.ReturnType); err != nil { return err } for _, arg := range fn.Args { if gqlArgName(arg.Name) == "id" { return fmt.Errorf("cannot define argument with reserved name %q on function %q", arg.Name, fn.Name) } if err := mod.validateTypeDef(ctx, arg.TypeDef); err != nil { return 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/module.go
return nil } func (mod *Module) namespaceTypeDef(ctx context.Context, typeDef *TypeDef) error { switch typeDef.Kind { case TypeDefKindList: if err := mod.namespaceTypeDef(ctx, typeDef.AsList.Value.ElementTypeDef); err != nil { return err } case TypeDefKindObject: obj := typeDef.AsObject.Value _, ok, err := mod.Deps.ModTypeFor(ctx, typeDef) if err != nil { return fmt.Errorf("failed to get mod type for type def: %w", err) } if !ok { obj.Name = namespaceObject(obj.OriginalName, mod.Name(), mod.OriginalName) } for _, field := range obj.Fields { if err := mod.namespaceTypeDef(ctx, field.TypeDef); err != nil { return err } } for _, fn := range obj.Functions { if err := mod.namespaceTypeDef(ctx, fn.ReturnType); err != nil { return err } for _, arg := range fn.Args { if err := mod.namespaceTypeDef(ctx, arg.TypeDef); err != nil { return 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/module.go
} } } case TypeDefKindInterface: iface := typeDef.AsInterface.Value _, ok, err := mod.Deps.ModTypeFor(ctx, typeDef) if err != nil { return fmt.Errorf("failed to get mod type for type def: %w", err) } if !ok { iface.Name = namespaceObject(iface.OriginalName, mod.Name(), mod.OriginalName) } for _, fn := range iface.Functions { if err := mod.namespaceTypeDef(ctx, fn.ReturnType); err != nil { return err } for _, arg := range fn.Args { if err := mod.namespaceTypeDef(ctx, arg.TypeDef); err != nil { return err } } } } return nil } /* Mod is a module in loaded into the server's DAG of modules; it's the vertex type of the DAG. It's an interface so we can abstract over user modules and core and treat them the same. */
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/module.go
type Mod interface { Name() string Dependencies() []Mod Install(context.Context, *dagql.Server) error ModTypeFor(ctx context.Context, typeDef *TypeDef, checkDirectDeps bool) (ModType, bool, error) TypeDefs(ctx context.Context) ([]*TypeDef, error) } /* An SDK is an implementation of the functionality needed to generate code for and execute a module. There is one special SDK, the Go SDK, which is implemented in `goSDK` below. It's used as the "seed" for all other SDK implementations. All other SDKs are themselves implemented as Modules, with Functions matching the two defined in this SDK interface. An SDK Module needs to choose its own SDK for its implementation. This can be "well-known" built-in SDKs like "go", "python", etc. Or it can be any external module as specified with a module source ref string. You can thus think of SDK Modules as a DAG of dependencies, with each SDK using a different SDK to implement its Module, with the Go SDK as the root of the DAG and the only one without any dependencies. Built-in SDKs are also a bit special in that they come bundled w/ the engine container image, which allows them to be used without hard dependencies on the internet. They are loaded w/ the `loadBuiltinSDK` function below, which loads them as modules from the engine container. */ type SDK interface { /* Codegen generates code for the module at the given source directory and subpath. The Code field of the returned GeneratedCode object should be the generated contents of the module sourceDirSubpath,
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/module.go
in the case where that's different than the root of the sourceDir. The provided Module is not fully initialized; the Runtime field will not be set yet. */ Codegen(context.Context, *Module, dagql.Instance[*ModuleSource]) (*GeneratedCode, error) /* Runtime returns a container that is used to execute module code at runtime in the Dagger engine. The provided Module is not fully initialized; the Runtime field will not be set yet. */ Runtime(context.Context, *Module, dagql.Instance[*ModuleSource]) (*Container, error) } var _ HasPBDefinitions = (*Module)(nil) func (mod *Module) PBDefinitions(ctx context.Context) ([]*pb.Definition, error) { var defs []*pb.Definition if mod.GeneratedSourceRootDirectory.Self != nil { dirDefs, err := mod.GeneratedSourceRootDirectory.Self.PBDefinitions(ctx) if err != nil { return nil, err } defs = append(defs, dirDefs...) } return defs, nil } func (mod Module) Clone() *Module { cp := mod if mod.Source.Self != nil { cp.Source.Self = mod.Source.Self.Clone() } if mod.GeneratedSourceRootDirectory.Self != nil { cp.GeneratedSourceRootDirectory.Self = mod.GeneratedSourceRootDirectory.Self.Clone() } cp.DependencyConfig = make([]*ModuleDependency, len(mod.DependencyConfig))
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/module.go
for i, dep := range mod.DependencyConfig { cp.DependencyConfig[i] = dep.Clone() } cp.DependenciesField = make([]dagql.Instance[*Module], len(mod.DependenciesField)) for i, dep := range mod.DependenciesField { cp.DependenciesField[i].Self = dep.Self.Clone() } if len(mod.DirectoryIncludeConfig) > 0 { cp.DirectoryIncludeConfig = make([]string, len(mod.DirectoryIncludeConfig)) copy(cp.DirectoryIncludeConfig, mod.DirectoryIncludeConfig) } if len(mod.DirectoryExcludeConfig) > 0 { cp.DirectoryExcludeConfig = make([]string, len(mod.DirectoryExcludeConfig)) copy(cp.DirectoryExcludeConfig, mod.DirectoryExcludeConfig) } cp.ObjectDefs = make([]*TypeDef, len(mod.ObjectDefs)) for i, def := range mod.ObjectDefs { cp.ObjectDefs[i] = def.Clone() } cp.InterfaceDefs = make([]*TypeDef, len(mod.InterfaceDefs)) for i, def := range mod.InterfaceDefs { cp.InterfaceDefs[i] = def.Clone() } return &cp } func (mod *Module) WithDescription(desc string) *Module { mod = mod.Clone() mod.Description = strings.TrimSpace(desc) return mod }
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/module.go
func (mod *Module) WithObject(ctx context.Context, def *TypeDef) (*Module, error) { mod = mod.Clone() if !def.AsObject.Valid { return nil, fmt.Errorf("expected object type def, got %s: %+v", def.Kind, def) } if mod.Deps != nil { if err := mod.validateTypeDef(ctx, def); err != nil { return nil, fmt.Errorf("failed to validate type def: %w", err) } } if mod.NameField != "" { def = def.Clone() if err := mod.namespaceTypeDef(ctx, def); err != nil { return nil, fmt.Errorf("failed to namespace type def: %w", err) } } mod.ObjectDefs = append(mod.ObjectDefs, def) return mod, nil } func (mod *Module) WithInterface(ctx context.Context, def *TypeDef) (*Module, error) { mod = mod.Clone() if !def.AsInterface.Valid { return nil, fmt.Errorf("expected interface type def, got %s: %+v", def.Kind, def) } if mod.Deps != nil { if err := mod.validateTypeDef(ctx, def); err != nil {
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/module.go
return nil, fmt.Errorf("failed to validate type def: %w", err) } } if mod.NameField != "" { def = def.Clone() if err := mod.namespaceTypeDef(ctx, def); err != nil { return nil, fmt.Errorf("failed to namespace type def: %w", err) } } mod.InterfaceDefs = append(mod.InterfaceDefs, def) return mod, nil } type CurrentModule struct { Module dagql.Instance[*Module] } func (*CurrentModule) Type() *ast.Type { return &ast.Type{ NamedType: "CurrentModule", NonNull: true, } } func (*CurrentModule) TypeDescription() string { return "Reflective module API provided to functions at runtime." } func (mod CurrentModule) Clone() *CurrentModule { cp := mod cp.Module.Self = mod.Module.Self.Clone() return &cp }
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/schema/schema.go
package schema import ( "context" "encoding/json" "fmt" "net/http" "runtime/debug" "strings" "github.com/99designs/gqlgen/graphql" "github.com/99designs/gqlgen/graphql/handler" "github.com/containerd/containerd/content" "github.com/dagger/dagger/auth" "github.com/dagger/dagger/cmd/codegen/introspection" "github.com/dagger/dagger/core" "github.com/dagger/dagger/dagql" "github.com/dagger/dagger/engine" "github.com/dagger/dagger/engine/buildkit" "github.com/dagger/dagger/tracing" "github.com/iancoleman/strcase" "github.com/moby/buildkit/util/bklog" "github.com/moby/buildkit/util/leaseutil" specs "github.com/opencontainers/image-spec/specs-go/v1" "github.com/vektah/gqlparser/v2/gqlerror" "github.com/vito/progrock" ) type InitializeArgs 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/schema/schema.go
BuildkitClient *buildkit.Client Platform specs.Platform ProgSockPath string OCIStore content.Store LeaseManager *leaseutil.Manager Auth *auth.RegistryAuthProvider Secrets *core.SecretStore } type APIServer 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/schema/schema.go
root *core.Query } func New(ctx context.Context, params InitializeArgs) (*APIServer, error) { svcs := core.NewServices(params.BuildkitClient) root := core.NewRoot() root.Buildkit = params.BuildkitClient root.Services = svcs root.ProgrockSocketPath = params.ProgSockPath root.Platform = core.Platform(params.Platform) root.Secrets = params.Secrets root.OCIStore = params.OCIStore root.LeaseManager = params.LeaseManager root.Auth = params.Auth dag := dagql.NewServer(root) root.Cache = dag.Cache dag.Around(tracing.AroundFunc) coreMod := &CoreMod{dag: dag} if err := coreMod.Install(ctx, dag); err != nil { return nil, 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/schema/schema.go
} root.InstallDefaultClientContext( core.NewModDeps(root, []core.Mod{coreMod}), ) return &APIServer{ root: root, }, nil } func (s *APIServer) ServeHTTP(w http.ResponseWriter, r *http.Request) { ctx := r.Context() errorOut := func(err error, code int) { bklog.G(ctx).WithError(err).Error("failed to serve request") http.Error(w, err.Error(), code) } clientMetadata, err := engine.ClientMetadataFromContext(ctx) if err != nil { errorOut(err, http.StatusInternalServerError) return } callContext, ok := s.root.ClientCallContext(clientMetadata.ModuleCallerDigest) if !ok { errorOut(fmt.Errorf("client call %s not found", clientMetadata.ModuleCallerDigest), http.StatusInternalServerError) return } rec := progrock.FromContext(ctx) if callContext.ProgrockParent != "" { rec = rec.WithParent(callContext.ProgrockParent) } ctx = progrock.ToContext(ctx, rec)
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/schema/schema.go
schema, err := callContext.Deps.Schema(ctx) if err != nil { errorOut(err, http.StatusBadRequest) return } defer func() { if v := recover(); v != nil { bklog.G(context.TODO()).Errorf("panic serving schema: %v %s", v, string(debug.Stack())) _, err := w.Write(nil) if err == http.ErrHijacked { return } gqlErr := &gqlerror.Error{ Message: "Internal Server Error", } code := http.StatusInternalServerError switch v := v.(type) { case error: gqlErr.Err = v gqlErr.Message = v.Error() case string: gqlErr.Message = v } res := graphql.Response{ Errors: gqlerror.List{gqlErr}, } bytes, err := json.Marshal(res) if err != nil {
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/schema/schema.go
panic(err) } http.Error(w, string(bytes), code) } }() srv := handler.NewDefaultServer(schema) mux := http.NewServeMux() mux.Handle("/query", srv) mux.Handle("/shutdown", http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { ctx := req.Context() bklog.G(ctx).Debugf("shutting down client %s", clientMetadata.ClientID) if err := s.root.Services.StopClientServices(ctx, clientMetadata); err != nil { bklog.G(ctx).WithError(err).Error("failed to shutdown") } })) s.root.MuxEndpoints(mux) r = r.WithContext(ctx) var handler http.Handler = mux handler = flushAfterNBytes(buildkit.MaxFileContentsChunkSize)(handler) handler.ServeHTTP(w, r) } func (s *APIServer) ShutdownClient(ctx context.Context, client *engine.ClientMetadata) error { return s.root.Services.StopClientServices(ctx, client)
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/schema/schema.go
} func (s *APIServer) CurrentServedDeps(ctx context.Context) (*core.ModDeps, error) { clientMetadata, err := engine.ClientMetadataFromContext(ctx) if err != nil { return nil, err } callCtx, ok := s.root.ClientCallContext(clientMetadata.ModuleCallerDigest) if !ok { return nil, fmt.Errorf("client call %s not found", clientMetadata.ModuleCallerDigest) } return callCtx.Deps, nil } func (s *APIServer) Introspect(ctx context.Context) (string, error) { return s.root.DefaultDeps.SchemaIntrospectionJSON(ctx) } type SchemaResolvers interface { Install() } func schemaIntrospectionJSON(ctx context.Context, dag *dagql.Server) (json.RawMessage, error) { data, err := dag.Query(ctx, introspection.Query, nil) if err != nil { return nil, fmt.Errorf("introspection query failed: %w", err) } jsonBytes, err := json.Marshal(data) if err != nil { return nil, fmt.Errorf("failed to marshal introspection result: %w", err) } return json.RawMessage(jsonBytes), nil } func gqlObjectName(name string) 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/schema/schema.go
return strcase.ToCamel(name) } func namespaceObject(objName, namespace string) string { gqlObjName := gqlObjectName(objName) if rest := strings.TrimPrefix(gqlObjName, gqlObjectName(namespace)); rest != gqlObjName { if len(rest) == 0 { return gqlObjName } if 'A' <= rest[0] && rest[0] <= 'Z' { return gqlObjName } } return gqlObjectName(namespace + "_" + objName) } func gqlFieldName(name string) string { return strcase.ToLowerCamel(name) }
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/schema/sdk.go
package schema import ( "context" "errors" "fmt" "path/filepath" "github.com/dagger/dagger/dagql" "github.com/vito/progrock" "github.com/dagger/dagger/core" "github.com/dagger/dagger/internal/distconsts" ) const ( runtimeWorkdirPath = "/scratch" ) func (s *moduleSchema) sdkForModule( ctx context.Context, root *core.Query,
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/schema/sdk.go
sdk string, parentDir dagql.Instance[*core.Directory], ) (core.SDK, error) { builtinSDK, err := s.builtinSDK(ctx, root, sdk) if err == nil { return builtinSDK, nil } else if !errors.Is(err, errUnknownBuiltinSDK) { return nil, err } var sdkMod dagql.Instance[*core.Module] err = s.dag.Select(ctx, s.dag.Root(), &sdkMod, dagql.Selector{ Field: "moduleSource", Args: []dagql.NamedInput{ {Name: "refString", Value: dagql.String(sdk)}, {Name: "rootDirectory", Value: dagql.Opt(dagql.NewID[*core.Directory](parentDir.ID()))}, }, }, dagql.Selector{ Field: "asModule", }, dagql.Selector{ Field: "initialize", }, ) if err != nil { return nil, fmt.Errorf("failed to load sdk module %s: %w", sdk, err) } return s.newModuleSDK(ctx, root, sdkMod, dagql.Instance[*core.Directory]{})
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/schema/sdk.go
} var errUnknownBuiltinSDK = fmt.Errorf("unknown builtin sdk") func (s *moduleSchema) builtinSDK(ctx context.Context, root *core.Query, sdkName string) (core.SDK, error) { switch sdkName { case "go": return &goSDK{root: root, dag: s.dag}, nil case "python": return s.loadBuiltinSDK(ctx, root, sdkName, distconsts.PythonSDKEngineContainerModulePath) case "typescript": return s.loadBuiltinSDK(ctx, root, sdkName, distconsts.TypescriptSDKEngineContainerModulePath) default: return nil, fmt.Errorf("%s: %w", sdkName, errUnknownBuiltinSDK) } } type moduleSDK struct { mod dagql.Instance[*core.Module] dag *dagql.Server sdk dagql.Object } func (s *moduleSchema) newModuleSDK( ctx context.Context, root *core.Query, sdkModMeta dagql.Instance[*core.Module], optionalFullSDKSourceDir dagql.Instance[*core.Directory], ) (*moduleSDK, error) { dag := dagql.NewServer(root) dag.Cache = root.Cache
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/schema/sdk.go
if err := sdkModMeta.Self.Install(ctx, dag); err != nil { return nil, fmt.Errorf("failed to install sdk module %s: %w", sdkModMeta.Self.Name(), err) } for _, defaultDep := range sdkModMeta.Self.Query.DefaultDeps.Mods { if err := defaultDep.Install(ctx, dag); err != nil { return nil, fmt.Errorf("failed to install default dep %s for sdk module %s: %w", defaultDep.Name(), sdkModMeta.Self.Name(), err) } } var sdk dagql.Object var constructorArgs []dagql.NamedInput if optionalFullSDKSourceDir.Self != nil { constructorArgs = []dagql.NamedInput{ {Name: "sdkSourceDir", Value: dagql.Opt(dagql.NewID[*core.Directory](optionalFullSDKSourceDir.ID()))}, } } if err := dag.Select(ctx, dag.Root(), &sdk, dagql.Selector{ Field: gqlFieldName(sdkModMeta.Self.Name()), Args: constructorArgs, }, ); err != nil { return nil, fmt.Errorf("failed to get sdk object for sdk module %s: %w", sdkModMeta.Self.Name(), err) } return &moduleSDK{mod: sdkModMeta, dag: dag, sdk: sdk}, nil } func (sdk *moduleSDK) Codegen(ctx context.Context, mod *core.Module, source dagql.Instance[*core.ModuleSource]) (*core.GeneratedCode, error) { introspectionJSON, err := mod.DependencySchemaIntrospectionJSON(ctx) if err != nil { return nil, fmt.Errorf("failed to get schema introspection json during %s module sdk codegen: %w", sdk.mod.Self.Name(), 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/schema/sdk.go
var inst dagql.Instance[*core.GeneratedCode] err = sdk.dag.Select(ctx, sdk.sdk, &inst, dagql.Selector{ Field: "codegen", Args: []dagql.NamedInput{ { Name: "modSource", Value: dagql.NewID[*core.ModuleSource](source.ID()), }, { Name: "introspectionJson", Value: dagql.String(introspectionJSON), }, }, }) if err != nil { return nil, fmt.Errorf("failed to call sdk module codegen: %w", err) } return inst.Self, nil } func (sdk *moduleSDK) Runtime(ctx context.Context, mod *core.Module, source dagql.Instance[*core.ModuleSource]) (*core.Container, error) { introspectionJSON, err := mod.DependencySchemaIntrospectionJSON(ctx) if err != nil { return nil, fmt.Errorf("failed to get schema introspection json during %s module sdk runtime: %w", sdk.mod.Self.Name(), err) } var inst dagql.Instance[*core.Container] err = sdk.dag.Select(ctx, sdk.sdk, &inst, dagql.Selector{ Field: "moduleRuntime", Args: []dagql.NamedInput{ {
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/schema/sdk.go
Name: "modSource", Value: dagql.NewID[*core.ModuleSource](source.ID()), }, { Name: "introspectionJson", Value: dagql.String(introspectionJSON), }, }, }, dagql.Selector{ Field: "withWorkdir", Args: []dagql.NamedInput{ { Name: "path", Value: dagql.NewString(runtimeWorkdirPath), }, }, }, ) if err != nil { return nil, fmt.Errorf("failed to call sdk module moduleRuntime: %w", err) } return inst.Self, nil } func (s *moduleSchema) loadBuiltinSDK( ctx context.Context, root *core.Query, name string, engineContainerModulePath string, ) (*moduleSDK, 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/schema/sdk.go
ctx, recorder := progrock.WithGroup(ctx, fmt.Sprintf("load builtin module sdk %s", name)) fullSDKSourcePath := filepath.Dir(engineContainerModulePath) _, desc, err := root.Buildkit.EngineContainerLocalImport( ctx, recorder, root.Platform.Spec(), fullSDKSourcePath, nil, nil, ) if err != nil { return nil, fmt.Errorf("failed to import full sdk source for sdk %s from engine container filesystem: %w", name, err) } fullSDKDir, err := core.LoadBlob(ctx, s.dag, desc) if err != nil { return nil, fmt.Errorf("failed to load full sdk source for module sdk %s: %w", name, err) } var sdkModDir dagql.Instance[*core.Directory] err = s.dag.Select(ctx, fullSDKDir, &sdkModDir, dagql.Selector{ Field: "directory", Args: []dagql.NamedInput{ {Name: "path", Value: dagql.String(filepath.Base(engineContainerModulePath))}, }, }, ) if err != nil {
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/schema/sdk.go
return nil, fmt.Errorf("failed to import module sdk %s: %w", name, err) } var sdkMod dagql.Instance[*core.Module] err = s.dag.Select(ctx, sdkModDir, &sdkMod, dagql.Selector{ Field: "asModule", }, dagql.Selector{ Field: "initialize", }, ) if err != nil { return nil, fmt.Errorf("failed to load embedded sdk module %q: %w", name, err) } return s.newModuleSDK(ctx, root, sdkMod, fullSDKDir) } const ( goSDKUserModSourceDirPath = "/src" goSDKRuntimePath = "/runtime" goSDKIntrospectionJSONPath = "/schema.json" ) /* goSDK is the one special sdk not implemented as module, instead the `cmd/codegen/` binary is packaged into a container w/ the go runtime, tarball'd up and included in the engine image. The Codegen and Runtime methods are implemented by loading that tarball and executing the codegen binary inside it to generate user code and then execute it with the resulting /runtime binary. */ type goSDK 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/schema/sdk.go
root *core.Query dag *dagql.Server } func (sdk *goSDK) Codegen( ctx context.Context, mod *core.Module, source dagql.Instance[*core.ModuleSource], ) (*core.GeneratedCode, error) { configDir := source.Self.RootDirectory sourceDirSubpath, err := source.Self.Subpath() if err != nil { return nil, fmt.Errorf("failed to get source subpath for go module sdk codegen: %w", err) } ctr, err := sdk.baseWithCodegen(ctx, mod, configDir, sourceDirSubpath) if err != nil { return nil, err } var modifiedSrcDir dagql.Instance[*core.Directory] if err := sdk.dag.Select(ctx, ctr, &modifiedSrcDir, dagql.Selector{
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/schema/sdk.go
Field: "directory", Args: []dagql.NamedInput{ { Name: "path", Value: dagql.String(goSDKUserModSourceDirPath), }, }, }); err != nil { return nil, fmt.Errorf("failed to get modified source directory for go module sdk codegen: %w", err) } return &core.GeneratedCode{ Code: modifiedSrcDir, VCSGeneratedPaths: []string{ "dagger.gen.go", "querybuilder/**", }, }, nil } func (sdk *goSDK) Runtime( ctx context.Context, mod *core.Module, source dagql.Instance[*core.ModuleSource], ) (*core.Container, error) { configDir := source.Self.RootDirectory sourceDirSubpath, err := source.Self.Subpath() if err != nil { return nil, fmt.Errorf("failed to get source subpath for go module sdk codegen: %w", err) } ctr, err := sdk.baseWithCodegen(ctx, mod, configDir, sourceDirSubpath) if err != nil {
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/schema/sdk.go
return nil, err } if err := sdk.dag.Select(ctx, ctr, &ctr, dagql.Selector{ Field: "withExec", Args: []dagql.NamedInput{ { Name: "args", Value: dagql.ArrayInput[dagql.String]{ "go", "build", "-o", goSDKRuntimePath, ".", }, }, { Name: "skipEntrypoint", Value: dagql.NewBoolean(true), }, }, }, dagql.Selector{ Field: "withEntrypoint", Args: []dagql.NamedInput{ { Name: "args", Value: dagql.ArrayInput[dagql.String]{ goSDKRuntimePath, }, }, },