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
5,904
Zenith: fix handling of list inputs
```go package main import ( "fmt" ) type Test struct{} type Foo struct { Msg string } func (m *Test) TestListInput(foos []Foo) string { return fmt.Sprintf("%+v", foos) } ``` Currently fails when building the module w/ error `41: [0.44s] ./dagger.gen.go:4250:15: undefined: test` Something must have broken in handling of list input types at some point I'm guessing? cc @jedevc @vito This should at least work in terms of codegen, handling it in `dagger call` is also important but probably a separate task, unless of course we already handled it (cc @helderco)
https://github.com/dagger/dagger/issues/5904
https://github.com/dagger/dagger/pull/5907
db901c8fe4c70cc32336e304492ca37f12b8f389
e8ad5c62275172e3d54ae46447e741ff5d603450
2023-10-16T18:21:57Z
go
2023-10-25T19:38:59Z
sdk/go/dagger.gen.go
q *querybuilder.Selection c graphql.Client } type HostDirectoryOpts struct {
closed
dagger/dagger
https://github.com/dagger/dagger
5,904
Zenith: fix handling of list inputs
```go package main import ( "fmt" ) type Test struct{} type Foo struct { Msg string } func (m *Test) TestListInput(foos []Foo) string { return fmt.Sprintf("%+v", foos) } ``` Currently fails when building the module w/ error `41: [0.44s] ./dagger.gen.go:4250:15: undefined: test` Something must have broken in handling of list input types at some point I'm guessing? cc @jedevc @vito This should at least work in terms of codegen, handling it in `dagger call` is also important but probably a separate task, unless of course we already handled it (cc @helderco)
https://github.com/dagger/dagger/issues/5904
https://github.com/dagger/dagger/pull/5907
db901c8fe4c70cc32336e304492ca37f12b8f389
e8ad5c62275172e3d54ae46447e741ff5d603450
2023-10-16T18:21:57Z
go
2023-10-25T19:38:59Z
sdk/go/dagger.gen.go
Exclude []string Include []string } func (r *Host) Directory(path string, opts ...HostDirectoryOpts) *Directory { q := r.q.Select("directory") for i := len(opts) - 1; i >= 0; i-- { if !querybuilder.IsZeroValue(opts[i].Exclude) { q = q.Arg("exclude", opts[i].Exclude) } if !querybuilder.IsZeroValue(opts[i].Include) { q = q.Arg("include", opts[i].Include) } } q = q.Arg("path", path) return &Directory{ q: q, c: r.c, } } func (r *Host) File(path string) *File { q := r.q.Select("file") q = q.Arg("path", path) return &File{ q: q, c: r.c,
closed
dagger/dagger
https://github.com/dagger/dagger
5,904
Zenith: fix handling of list inputs
```go package main import ( "fmt" ) type Test struct{} type Foo struct { Msg string } func (m *Test) TestListInput(foos []Foo) string { return fmt.Sprintf("%+v", foos) } ``` Currently fails when building the module w/ error `41: [0.44s] ./dagger.gen.go:4250:15: undefined: test` Something must have broken in handling of list input types at some point I'm guessing? cc @jedevc @vito This should at least work in terms of codegen, handling it in `dagger call` is also important but probably a separate task, unless of course we already handled it (cc @helderco)
https://github.com/dagger/dagger/issues/5904
https://github.com/dagger/dagger/pull/5907
db901c8fe4c70cc32336e304492ca37f12b8f389
e8ad5c62275172e3d54ae46447e741ff5d603450
2023-10-16T18:21:57Z
go
2023-10-25T19:38:59Z
sdk/go/dagger.gen.go
} } type HostServiceOpts struct { Host string } func (r *Host) Service(ports []PortForward, opts ...HostServiceOpts) *Service { q := r.q.Select("service") for i := len(opts) - 1; i >= 0; i-- { if !querybuilder.IsZeroValue(opts[i].Host) { q = q.Arg("host", opts[i].Host) } } q = q.Arg("ports", ports) return &Service{ q: q, c: r.c, } } func (r *Host) SetSecretFile(name string, path string) *Secret { q := r.q.Select("setSecretFile") q = q.Arg("name", name) q = q.Arg("path", path) return &Secret{ q: q, c: r.c, } } type HostTunnelOpts struct {
closed
dagger/dagger
https://github.com/dagger/dagger
5,904
Zenith: fix handling of list inputs
```go package main import ( "fmt" ) type Test struct{} type Foo struct { Msg string } func (m *Test) TestListInput(foos []Foo) string { return fmt.Sprintf("%+v", foos) } ``` Currently fails when building the module w/ error `41: [0.44s] ./dagger.gen.go:4250:15: undefined: test` Something must have broken in handling of list input types at some point I'm guessing? cc @jedevc @vito This should at least work in terms of codegen, handling it in `dagger call` is also important but probably a separate task, unless of course we already handled it (cc @helderco)
https://github.com/dagger/dagger/issues/5904
https://github.com/dagger/dagger/pull/5907
db901c8fe4c70cc32336e304492ca37f12b8f389
e8ad5c62275172e3d54ae46447e741ff5d603450
2023-10-16T18:21:57Z
go
2023-10-25T19:38:59Z
sdk/go/dagger.gen.go
Native bool
closed
dagger/dagger
https://github.com/dagger/dagger
5,904
Zenith: fix handling of list inputs
```go package main import ( "fmt" ) type Test struct{} type Foo struct { Msg string } func (m *Test) TestListInput(foos []Foo) string { return fmt.Sprintf("%+v", foos) } ``` Currently fails when building the module w/ error `41: [0.44s] ./dagger.gen.go:4250:15: undefined: test` Something must have broken in handling of list input types at some point I'm guessing? cc @jedevc @vito This should at least work in terms of codegen, handling it in `dagger call` is also important but probably a separate task, unless of course we already handled it (cc @helderco)
https://github.com/dagger/dagger/issues/5904
https://github.com/dagger/dagger/pull/5907
db901c8fe4c70cc32336e304492ca37f12b8f389
e8ad5c62275172e3d54ae46447e741ff5d603450
2023-10-16T18:21:57Z
go
2023-10-25T19:38:59Z
sdk/go/dagger.gen.go
Ports []PortForward } func (r *Host) Tunnel(service *Service, opts ...HostTunnelOpts) *Service { assertNotNil("service", service) q := r.q.Select("tunnel") for i := len(opts) - 1; i >= 0; i-- { if !querybuilder.IsZeroValue(opts[i].Native) { q = q.Arg("native", opts[i].Native) } if !querybuilder.IsZeroValue(opts[i].Ports) { q = q.Arg("ports", opts[i].Ports) } } q = q.Arg("service", service) return &Service{ q: q, c: r.c, } } func (r *Host) UnixSocket(path string) *Socket { q := r.q.Select("unixSocket") q = q.Arg("path", path) return &Socket{ q: q, c: r.c, } } type Label struct {
closed
dagger/dagger
https://github.com/dagger/dagger
5,904
Zenith: fix handling of list inputs
```go package main import ( "fmt" ) type Test struct{} type Foo struct { Msg string } func (m *Test) TestListInput(foos []Foo) string { return fmt.Sprintf("%+v", foos) } ``` Currently fails when building the module w/ error `41: [0.44s] ./dagger.gen.go:4250:15: undefined: test` Something must have broken in handling of list input types at some point I'm guessing? cc @jedevc @vito This should at least work in terms of codegen, handling it in `dagger call` is also important but probably a separate task, unless of course we already handled it (cc @helderco)
https://github.com/dagger/dagger/issues/5904
https://github.com/dagger/dagger/pull/5907
db901c8fe4c70cc32336e304492ca37f12b8f389
e8ad5c62275172e3d54ae46447e741ff5d603450
2023-10-16T18:21:57Z
go
2023-10-25T19:38:59Z
sdk/go/dagger.gen.go
q *querybuilder.Selection c graphql.Client name *string value *string } func (r *Label) Name(ctx context.Context) (string, error) { if r.name != nil { return *r.name, nil } q := r.q.Select("name") var response string q = q.Bind(&response) return response, q.Execute(ctx, r.c) } func (r *Label) Value(ctx context.Context) (string, error) { if r.value != nil { return *r.value, nil } q := r.q.Select("value") var response string q = q.Bind(&response) return response, q.Execute(ctx, r.c) } type ListTypeDef struct {
closed
dagger/dagger
https://github.com/dagger/dagger
5,904
Zenith: fix handling of list inputs
```go package main import ( "fmt" ) type Test struct{} type Foo struct { Msg string } func (m *Test) TestListInput(foos []Foo) string { return fmt.Sprintf("%+v", foos) } ``` Currently fails when building the module w/ error `41: [0.44s] ./dagger.gen.go:4250:15: undefined: test` Something must have broken in handling of list input types at some point I'm guessing? cc @jedevc @vito This should at least work in terms of codegen, handling it in `dagger call` is also important but probably a separate task, unless of course we already handled it (cc @helderco)
https://github.com/dagger/dagger/issues/5904
https://github.com/dagger/dagger/pull/5907
db901c8fe4c70cc32336e304492ca37f12b8f389
e8ad5c62275172e3d54ae46447e741ff5d603450
2023-10-16T18:21:57Z
go
2023-10-25T19:38:59Z
sdk/go/dagger.gen.go
q *querybuilder.Selection c graphql.Client } func (r *ListTypeDef) ElementTypeDef() *TypeDef { q := r.q.Select("elementTypeDef") return &TypeDef{ q: q, c: r.c, } } type Module struct { q *querybuilder.Selection c graphql.Client description *string id *ModuleID name *string sdk *string serve *Void sourceDirectorySubPath *string } type WithModuleFunc func(r *Module) *Module func (r *Module) With(f WithModuleFunc) *Module { return f(r) } func (r *Module) Dependencies(ctx context.Context) ([]Module, error) { q := r.q.Select("dependencies") q = q.Select("id") type dependencies struct {
closed
dagger/dagger
https://github.com/dagger/dagger
5,904
Zenith: fix handling of list inputs
```go package main import ( "fmt" ) type Test struct{} type Foo struct { Msg string } func (m *Test) TestListInput(foos []Foo) string { return fmt.Sprintf("%+v", foos) } ``` Currently fails when building the module w/ error `41: [0.44s] ./dagger.gen.go:4250:15: undefined: test` Something must have broken in handling of list input types at some point I'm guessing? cc @jedevc @vito This should at least work in terms of codegen, handling it in `dagger call` is also important but probably a separate task, unless of course we already handled it (cc @helderco)
https://github.com/dagger/dagger/issues/5904
https://github.com/dagger/dagger/pull/5907
db901c8fe4c70cc32336e304492ca37f12b8f389
e8ad5c62275172e3d54ae46447e741ff5d603450
2023-10-16T18:21:57Z
go
2023-10-25T19:38:59Z
sdk/go/dagger.gen.go
Id ModuleID } convert := func(fields []dependencies) []Module { out := []Module{} for i := range fields { val := Module{id: &fields[i].Id} val.q = querybuilder.Query().Select("loadModuleFromID").Arg("id", fields[i].Id) val.c = r.c out = append(out, val) } return out } var response []dependencies q = q.Bind(&response) err := q.Execute(ctx, r.c) if err != nil { return nil, err } return convert(response), nil } func (r *Module) DependencyConfig(ctx context.Context) ([]string, error) { q := r.q.Select("dependencyConfig") var response []string q = q.Bind(&response)
closed
dagger/dagger
https://github.com/dagger/dagger
5,904
Zenith: fix handling of list inputs
```go package main import ( "fmt" ) type Test struct{} type Foo struct { Msg string } func (m *Test) TestListInput(foos []Foo) string { return fmt.Sprintf("%+v", foos) } ``` Currently fails when building the module w/ error `41: [0.44s] ./dagger.gen.go:4250:15: undefined: test` Something must have broken in handling of list input types at some point I'm guessing? cc @jedevc @vito This should at least work in terms of codegen, handling it in `dagger call` is also important but probably a separate task, unless of course we already handled it (cc @helderco)
https://github.com/dagger/dagger/issues/5904
https://github.com/dagger/dagger/pull/5907
db901c8fe4c70cc32336e304492ca37f12b8f389
e8ad5c62275172e3d54ae46447e741ff5d603450
2023-10-16T18:21:57Z
go
2023-10-25T19:38:59Z
sdk/go/dagger.gen.go
return response, q.Execute(ctx, r.c) } func (r *Module) Description(ctx context.Context) (string, error) { if r.description != nil { return *r.description, nil } q := r.q.Select("description") var response string q = q.Bind(&response) return response, q.Execute(ctx, r.c) } func (r *Module) GeneratedCode() *GeneratedCode { q := r.q.Select("generatedCode") return &GeneratedCode{ q: q, c: r.c, } } func (r *Module) ID(ctx context.Context) (ModuleID, error) { if r.id != nil { return *r.id, nil } q := r.q.Select("id") var response ModuleID q = q.Bind(&response) return response, q.Execute(ctx, r.c) } func (r *Module) XXX_GraphQLType() string { return "Module" }
closed
dagger/dagger
https://github.com/dagger/dagger
5,904
Zenith: fix handling of list inputs
```go package main import ( "fmt" ) type Test struct{} type Foo struct { Msg string } func (m *Test) TestListInput(foos []Foo) string { return fmt.Sprintf("%+v", foos) } ``` Currently fails when building the module w/ error `41: [0.44s] ./dagger.gen.go:4250:15: undefined: test` Something must have broken in handling of list input types at some point I'm guessing? cc @jedevc @vito This should at least work in terms of codegen, handling it in `dagger call` is also important but probably a separate task, unless of course we already handled it (cc @helderco)
https://github.com/dagger/dagger/issues/5904
https://github.com/dagger/dagger/pull/5907
db901c8fe4c70cc32336e304492ca37f12b8f389
e8ad5c62275172e3d54ae46447e741ff5d603450
2023-10-16T18:21:57Z
go
2023-10-25T19:38:59Z
sdk/go/dagger.gen.go
func (r *Module) XXX_GraphQLIDType() string { return "ModuleID" } func (r *Module) XXX_GraphQLID(ctx context.Context) (string, error) { id, err := r.ID(ctx) if err != nil { return "", err } return string(id), nil } func (r *Module) MarshalJSON() ([]byte, error) { id, err := r.ID(context.Background()) if err != nil { return nil, err } return json.Marshal(id) } func (r *Module) Name(ctx context.Context) (string, error) { if r.name != nil { return *r.name, nil } q := r.q.Select("name") var response string q = q.Bind(&response) return response, q.Execute(ctx, r.c) } func (r *Module) Objects(ctx context.Context) ([]TypeDef, error) { q := r.q.Select("objects") q = q.Select("id") type objects struct {
closed
dagger/dagger
https://github.com/dagger/dagger
5,904
Zenith: fix handling of list inputs
```go package main import ( "fmt" ) type Test struct{} type Foo struct { Msg string } func (m *Test) TestListInput(foos []Foo) string { return fmt.Sprintf("%+v", foos) } ``` Currently fails when building the module w/ error `41: [0.44s] ./dagger.gen.go:4250:15: undefined: test` Something must have broken in handling of list input types at some point I'm guessing? cc @jedevc @vito This should at least work in terms of codegen, handling it in `dagger call` is also important but probably a separate task, unless of course we already handled it (cc @helderco)
https://github.com/dagger/dagger/issues/5904
https://github.com/dagger/dagger/pull/5907
db901c8fe4c70cc32336e304492ca37f12b8f389
e8ad5c62275172e3d54ae46447e741ff5d603450
2023-10-16T18:21:57Z
go
2023-10-25T19:38:59Z
sdk/go/dagger.gen.go
Id TypeDefID } convert := func(fields []objects) []TypeDef { out := []TypeDef{} for i := range fields { val := TypeDef{id: &fields[i].Id} val.q = querybuilder.Query().Select("loadTypeDefFromID").Arg("id", fields[i].Id) val.c = r.c out = append(out, val) } return out } var response []objects q = q.Bind(&response) err := q.Execute(ctx, r.c) if err != nil { return nil, err } return convert(response), nil } func (r *Module) SDK(ctx context.Context) (string, error) { if r.sdk != nil { return *r.sdk, nil } q := r.q.Select("sdk") var response string
closed
dagger/dagger
https://github.com/dagger/dagger
5,904
Zenith: fix handling of list inputs
```go package main import ( "fmt" ) type Test struct{} type Foo struct { Msg string } func (m *Test) TestListInput(foos []Foo) string { return fmt.Sprintf("%+v", foos) } ``` Currently fails when building the module w/ error `41: [0.44s] ./dagger.gen.go:4250:15: undefined: test` Something must have broken in handling of list input types at some point I'm guessing? cc @jedevc @vito This should at least work in terms of codegen, handling it in `dagger call` is also important but probably a separate task, unless of course we already handled it (cc @helderco)
https://github.com/dagger/dagger/issues/5904
https://github.com/dagger/dagger/pull/5907
db901c8fe4c70cc32336e304492ca37f12b8f389
e8ad5c62275172e3d54ae46447e741ff5d603450
2023-10-16T18:21:57Z
go
2023-10-25T19:38:59Z
sdk/go/dagger.gen.go
q = q.Bind(&response) return response, q.Execute(ctx, r.c) } func (r *Module) Serve(ctx context.Context) (Void, error) { if r.serve != nil { return *r.serve, nil } q := r.q.Select("serve") var response Void q = q.Bind(&response) return response, q.Execute(ctx, r.c) } func (r *Module) SourceDirectory() *Directory { q := r.q.Select("sourceDirectory") return &Directory{ q: q, c: r.c, } } func (r *Module) SourceDirectorySubPath(ctx context.Context) (string, error) { if r.sourceDirectorySubPath != nil { return *r.sourceDirectorySubPath, nil } q := r.q.Select("sourceDirectorySubPath") var response string q = q.Bind(&response) return response, q.Execute(ctx, r.c) } func (r *Module) WithObject(object *TypeDef) *Module { assertNotNil("object", object)
closed
dagger/dagger
https://github.com/dagger/dagger
5,904
Zenith: fix handling of list inputs
```go package main import ( "fmt" ) type Test struct{} type Foo struct { Msg string } func (m *Test) TestListInput(foos []Foo) string { return fmt.Sprintf("%+v", foos) } ``` Currently fails when building the module w/ error `41: [0.44s] ./dagger.gen.go:4250:15: undefined: test` Something must have broken in handling of list input types at some point I'm guessing? cc @jedevc @vito This should at least work in terms of codegen, handling it in `dagger call` is also important but probably a separate task, unless of course we already handled it (cc @helderco)
https://github.com/dagger/dagger/issues/5904
https://github.com/dagger/dagger/pull/5907
db901c8fe4c70cc32336e304492ca37f12b8f389
e8ad5c62275172e3d54ae46447e741ff5d603450
2023-10-16T18:21:57Z
go
2023-10-25T19:38:59Z
sdk/go/dagger.gen.go
q := r.q.Select("withObject") q = q.Arg("object", object) return &Module{ q: q, c: r.c, } } type ModuleConfig struct { q *querybuilder.Selection c graphql.Client name *string root *string sdk *string } func (r *ModuleConfig) Dependencies(ctx context.Context) ([]string, error) { q := r.q.Select("dependencies") var response []string q = q.Bind(&response) return response, q.Execute(ctx, r.c) } func (r *ModuleConfig) Exclude(ctx context.Context) ([]string, error) { q := r.q.Select("exclude") var response []string q = q.Bind(&response) return response, q.Execute(ctx, r.c) } func (r *ModuleConfig) Include(ctx context.Context) ([]string, error) { q := r.q.Select("include") var response []string q = q.Bind(&response)
closed
dagger/dagger
https://github.com/dagger/dagger
5,904
Zenith: fix handling of list inputs
```go package main import ( "fmt" ) type Test struct{} type Foo struct { Msg string } func (m *Test) TestListInput(foos []Foo) string { return fmt.Sprintf("%+v", foos) } ``` Currently fails when building the module w/ error `41: [0.44s] ./dagger.gen.go:4250:15: undefined: test` Something must have broken in handling of list input types at some point I'm guessing? cc @jedevc @vito This should at least work in terms of codegen, handling it in `dagger call` is also important but probably a separate task, unless of course we already handled it (cc @helderco)
https://github.com/dagger/dagger/issues/5904
https://github.com/dagger/dagger/pull/5907
db901c8fe4c70cc32336e304492ca37f12b8f389
e8ad5c62275172e3d54ae46447e741ff5d603450
2023-10-16T18:21:57Z
go
2023-10-25T19:38:59Z
sdk/go/dagger.gen.go
return response, q.Execute(ctx, r.c) } func (r *ModuleConfig) Name(ctx context.Context) (string, error) { if r.name != nil { return *r.name, nil } q := r.q.Select("name") var response string q = q.Bind(&response) return response, q.Execute(ctx, r.c) } func (r *ModuleConfig) Root(ctx context.Context) (string, error) { if r.root != nil { return *r.root, nil } q := r.q.Select("root") var response string q = q.Bind(&response) return response, q.Execute(ctx, r.c) } func (r *ModuleConfig) SDK(ctx context.Context) (string, error) { if r.sdk != nil { return *r.sdk, nil } q := r.q.Select("sdk") var response string q = q.Bind(&response) return response, q.Execute(ctx, r.c) } type ObjectTypeDef struct {
closed
dagger/dagger
https://github.com/dagger/dagger
5,904
Zenith: fix handling of list inputs
```go package main import ( "fmt" ) type Test struct{} type Foo struct { Msg string } func (m *Test) TestListInput(foos []Foo) string { return fmt.Sprintf("%+v", foos) } ``` Currently fails when building the module w/ error `41: [0.44s] ./dagger.gen.go:4250:15: undefined: test` Something must have broken in handling of list input types at some point I'm guessing? cc @jedevc @vito This should at least work in terms of codegen, handling it in `dagger call` is also important but probably a separate task, unless of course we already handled it (cc @helderco)
https://github.com/dagger/dagger/issues/5904
https://github.com/dagger/dagger/pull/5907
db901c8fe4c70cc32336e304492ca37f12b8f389
e8ad5c62275172e3d54ae46447e741ff5d603450
2023-10-16T18:21:57Z
go
2023-10-25T19:38:59Z
sdk/go/dagger.gen.go
q *querybuilder.Selection c graphql.Client description *string name *string } func (r *ObjectTypeDef) Description(ctx context.Context) (string, error) { if r.description != nil { return *r.description, nil } q := r.q.Select("description") var response string q = q.Bind(&response) return response, q.Execute(ctx, r.c) } func (r *ObjectTypeDef) Fields(ctx context.Context) ([]FieldTypeDef, error) { q := r.q.Select("fields") q = q.Select("description name") type fields struct {
closed
dagger/dagger
https://github.com/dagger/dagger
5,904
Zenith: fix handling of list inputs
```go package main import ( "fmt" ) type Test struct{} type Foo struct { Msg string } func (m *Test) TestListInput(foos []Foo) string { return fmt.Sprintf("%+v", foos) } ``` Currently fails when building the module w/ error `41: [0.44s] ./dagger.gen.go:4250:15: undefined: test` Something must have broken in handling of list input types at some point I'm guessing? cc @jedevc @vito This should at least work in terms of codegen, handling it in `dagger call` is also important but probably a separate task, unless of course we already handled it (cc @helderco)
https://github.com/dagger/dagger/issues/5904
https://github.com/dagger/dagger/pull/5907
db901c8fe4c70cc32336e304492ca37f12b8f389
e8ad5c62275172e3d54ae46447e741ff5d603450
2023-10-16T18:21:57Z
go
2023-10-25T19:38:59Z
sdk/go/dagger.gen.go
Description string Name string } convert := func(fields []fields) []FieldTypeDef { out := []FieldTypeDef{} for i := range fields { val := FieldTypeDef{description: &fields[i].Description, name: &fields[i].Name} out = append(out, val) } return out } var response []fields q = q.Bind(&response) err := q.Execute(ctx, r.c) if err != nil { return nil, err } return convert(response), nil } func (r *ObjectTypeDef) Functions(ctx context.Context) ([]Function, error) { q := r.q.Select("functions") q = q.Select("id") type functions struct {
closed
dagger/dagger
https://github.com/dagger/dagger
5,904
Zenith: fix handling of list inputs
```go package main import ( "fmt" ) type Test struct{} type Foo struct { Msg string } func (m *Test) TestListInput(foos []Foo) string { return fmt.Sprintf("%+v", foos) } ``` Currently fails when building the module w/ error `41: [0.44s] ./dagger.gen.go:4250:15: undefined: test` Something must have broken in handling of list input types at some point I'm guessing? cc @jedevc @vito This should at least work in terms of codegen, handling it in `dagger call` is also important but probably a separate task, unless of course we already handled it (cc @helderco)
https://github.com/dagger/dagger/issues/5904
https://github.com/dagger/dagger/pull/5907
db901c8fe4c70cc32336e304492ca37f12b8f389
e8ad5c62275172e3d54ae46447e741ff5d603450
2023-10-16T18:21:57Z
go
2023-10-25T19:38:59Z
sdk/go/dagger.gen.go
Id FunctionID } convert := func(fields []functions) []Function { out := []Function{} for i := range fields { val := Function{id: &fields[i].Id} val.q = querybuilder.Query().Select("loadFunctionFromID").Arg("id", fields[i].Id) val.c = r.c out = append(out, val) } return out } var response []functions q = q.Bind(&response) err := q.Execute(ctx, r.c) if err != nil { return nil, err } return convert(response), nil } func (r *ObjectTypeDef) Name(ctx context.Context) (string, error) { if r.name != nil { return *r.name, nil } q := r.q.Select("name") var response string q = q.Bind(&response) return response, q.Execute(ctx, r.c) } type Port struct {
closed
dagger/dagger
https://github.com/dagger/dagger
5,904
Zenith: fix handling of list inputs
```go package main import ( "fmt" ) type Test struct{} type Foo struct { Msg string } func (m *Test) TestListInput(foos []Foo) string { return fmt.Sprintf("%+v", foos) } ``` Currently fails when building the module w/ error `41: [0.44s] ./dagger.gen.go:4250:15: undefined: test` Something must have broken in handling of list input types at some point I'm guessing? cc @jedevc @vito This should at least work in terms of codegen, handling it in `dagger call` is also important but probably a separate task, unless of course we already handled it (cc @helderco)
https://github.com/dagger/dagger/issues/5904
https://github.com/dagger/dagger/pull/5907
db901c8fe4c70cc32336e304492ca37f12b8f389
e8ad5c62275172e3d54ae46447e741ff5d603450
2023-10-16T18:21:57Z
go
2023-10-25T19:38:59Z
sdk/go/dagger.gen.go
q *querybuilder.Selection c graphql.Client description *string port *int protocol *NetworkProtocol } func (r *Port) Description(ctx context.Context) (string, error) { if r.description != nil { return *r.description, nil } q := r.q.Select("description") var response string q = q.Bind(&response) return response, q.Execute(ctx, r.c) } func (r *Port) Port(ctx context.Context) (int, error) { if r.port != nil { return *r.port, nil } q := r.q.Select("port") var response int q = q.Bind(&response) return response, q.Execute(ctx, r.c)
closed
dagger/dagger
https://github.com/dagger/dagger
5,904
Zenith: fix handling of list inputs
```go package main import ( "fmt" ) type Test struct{} type Foo struct { Msg string } func (m *Test) TestListInput(foos []Foo) string { return fmt.Sprintf("%+v", foos) } ``` Currently fails when building the module w/ error `41: [0.44s] ./dagger.gen.go:4250:15: undefined: test` Something must have broken in handling of list input types at some point I'm guessing? cc @jedevc @vito This should at least work in terms of codegen, handling it in `dagger call` is also important but probably a separate task, unless of course we already handled it (cc @helderco)
https://github.com/dagger/dagger/issues/5904
https://github.com/dagger/dagger/pull/5907
db901c8fe4c70cc32336e304492ca37f12b8f389
e8ad5c62275172e3d54ae46447e741ff5d603450
2023-10-16T18:21:57Z
go
2023-10-25T19:38:59Z
sdk/go/dagger.gen.go
} func (r *Port) Protocol(ctx context.Context) (NetworkProtocol, error) { if r.protocol != nil { return *r.protocol, nil } q := r.q.Select("protocol") var response NetworkProtocol q = q.Bind(&response) return response, q.Execute(ctx, r.c) } type WithClientFunc func(r *Client) *Client func (r *Client) With(f WithClientFunc) *Client { return f(r) } func (r *Client) CacheVolume(key string) *CacheVolume { q := r.q.Select("cacheVolume") q = q.Arg("key", key) return &CacheVolume{ q: q, c: r.c, } } func (r *Client) CheckVersionCompatibility(ctx context.Context, version string) (bool, error) { q := r.q.Select("checkVersionCompatibility") q = q.Arg("version", version) var response bool q = q.Bind(&response) return response, q.Execute(ctx, r.c) } type ContainerOpts struct {
closed
dagger/dagger
https://github.com/dagger/dagger
5,904
Zenith: fix handling of list inputs
```go package main import ( "fmt" ) type Test struct{} type Foo struct { Msg string } func (m *Test) TestListInput(foos []Foo) string { return fmt.Sprintf("%+v", foos) } ``` Currently fails when building the module w/ error `41: [0.44s] ./dagger.gen.go:4250:15: undefined: test` Something must have broken in handling of list input types at some point I'm guessing? cc @jedevc @vito This should at least work in terms of codegen, handling it in `dagger call` is also important but probably a separate task, unless of course we already handled it (cc @helderco)
https://github.com/dagger/dagger/issues/5904
https://github.com/dagger/dagger/pull/5907
db901c8fe4c70cc32336e304492ca37f12b8f389
e8ad5c62275172e3d54ae46447e741ff5d603450
2023-10-16T18:21:57Z
go
2023-10-25T19:38:59Z
sdk/go/dagger.gen.go
ID ContainerID Platform Platform } func (r *Client) Container(opts ...ContainerOpts) *Container { q := r.q.Select("container") for i := len(opts) - 1; i >= 0; i-- { if !querybuilder.IsZeroValue(opts[i].ID) { q = q.Arg("id", opts[i].ID) } if !querybuilder.IsZeroValue(opts[i].Platform) { q = q.Arg("platform", opts[i].Platform) } } return &Container{ q: q, c: r.c, } } func (r *Client) CurrentFunctionCall() *FunctionCall { q := r.q.Select("currentFunctionCall") return &FunctionCall{ q: q, c: r.c,
closed
dagger/dagger
https://github.com/dagger/dagger
5,904
Zenith: fix handling of list inputs
```go package main import ( "fmt" ) type Test struct{} type Foo struct { Msg string } func (m *Test) TestListInput(foos []Foo) string { return fmt.Sprintf("%+v", foos) } ``` Currently fails when building the module w/ error `41: [0.44s] ./dagger.gen.go:4250:15: undefined: test` Something must have broken in handling of list input types at some point I'm guessing? cc @jedevc @vito This should at least work in terms of codegen, handling it in `dagger call` is also important but probably a separate task, unless of course we already handled it (cc @helderco)
https://github.com/dagger/dagger/issues/5904
https://github.com/dagger/dagger/pull/5907
db901c8fe4c70cc32336e304492ca37f12b8f389
e8ad5c62275172e3d54ae46447e741ff5d603450
2023-10-16T18:21:57Z
go
2023-10-25T19:38:59Z
sdk/go/dagger.gen.go
} } func (r *Client) CurrentModule() *Module { q := r.q.Select("currentModule") return &Module{ q: q, c: r.c, } } func (r *Client) DefaultPlatform(ctx context.Context) (Platform, error) { q := r.q.Select("defaultPlatform") var response Platform q = q.Bind(&response) return response, q.Execute(ctx, r.c) } type DirectoryOpts struct { ID DirectoryID } func (r *Client) Directory(opts ...DirectoryOpts) *Directory { q := r.q.Select("directory") for i := len(opts) - 1; i >= 0; i-- { if !querybuilder.IsZeroValue(opts[i].ID) { q = q.Arg("id", opts[i].ID) } } return &Directory{ q: q, c: r.c, }
closed
dagger/dagger
https://github.com/dagger/dagger
5,904
Zenith: fix handling of list inputs
```go package main import ( "fmt" ) type Test struct{} type Foo struct { Msg string } func (m *Test) TestListInput(foos []Foo) string { return fmt.Sprintf("%+v", foos) } ``` Currently fails when building the module w/ error `41: [0.44s] ./dagger.gen.go:4250:15: undefined: test` Something must have broken in handling of list input types at some point I'm guessing? cc @jedevc @vito This should at least work in terms of codegen, handling it in `dagger call` is also important but probably a separate task, unless of course we already handled it (cc @helderco)
https://github.com/dagger/dagger/issues/5904
https://github.com/dagger/dagger/pull/5907
db901c8fe4c70cc32336e304492ca37f12b8f389
e8ad5c62275172e3d54ae46447e741ff5d603450
2023-10-16T18:21:57Z
go
2023-10-25T19:38:59Z
sdk/go/dagger.gen.go
} func (r *Client) File(id FileID) *File { q := r.q.Select("file") q = q.Arg("id", id) return &File{ q: q, c: r.c, } } func (r *Client) Function(name string, returnType *TypeDef) *Function { assertNotNil("returnType", returnType) q := r.q.Select("function") q = q.Arg("name", name) q = q.Arg("returnType", returnType) return &Function{ q: q, c: r.c, } } func (r *Client) GeneratedCode(code *Directory) *GeneratedCode { assertNotNil("code", code) q := r.q.Select("generatedCode") q = q.Arg("code", code) return &GeneratedCode{ q: q, c: r.c, } } type GitOpts struct {
closed
dagger/dagger
https://github.com/dagger/dagger
5,904
Zenith: fix handling of list inputs
```go package main import ( "fmt" ) type Test struct{} type Foo struct { Msg string } func (m *Test) TestListInput(foos []Foo) string { return fmt.Sprintf("%+v", foos) } ``` Currently fails when building the module w/ error `41: [0.44s] ./dagger.gen.go:4250:15: undefined: test` Something must have broken in handling of list input types at some point I'm guessing? cc @jedevc @vito This should at least work in terms of codegen, handling it in `dagger call` is also important but probably a separate task, unless of course we already handled it (cc @helderco)
https://github.com/dagger/dagger/issues/5904
https://github.com/dagger/dagger/pull/5907
db901c8fe4c70cc32336e304492ca37f12b8f389
e8ad5c62275172e3d54ae46447e741ff5d603450
2023-10-16T18:21:57Z
go
2023-10-25T19:38:59Z
sdk/go/dagger.gen.go
KeepGitDir bool ExperimentalServiceHost *Service } func (r *Client) Git(url string, opts ...GitOpts) *GitRepository { q := r.q.Select("git") for i := len(opts) - 1; i >= 0; i-- { if !querybuilder.IsZeroValue(opts[i].KeepGitDir) { q = q.Arg("keepGitDir", opts[i].KeepGitDir) } if !querybuilder.IsZeroValue(opts[i].ExperimentalServiceHost) { q = q.Arg("experimentalServiceHost", opts[i].ExperimentalServiceHost) } } q = q.Arg("url", url) return &GitRepository{ q: q, c: r.c, } } func (r *Client) Host() *Host { q := r.q.Select("host") return &Host{ q: q, c: r.c, } } type HTTPOpts struct {
closed
dagger/dagger
https://github.com/dagger/dagger
5,904
Zenith: fix handling of list inputs
```go package main import ( "fmt" ) type Test struct{} type Foo struct { Msg string } func (m *Test) TestListInput(foos []Foo) string { return fmt.Sprintf("%+v", foos) } ``` Currently fails when building the module w/ error `41: [0.44s] ./dagger.gen.go:4250:15: undefined: test` Something must have broken in handling of list input types at some point I'm guessing? cc @jedevc @vito This should at least work in terms of codegen, handling it in `dagger call` is also important but probably a separate task, unless of course we already handled it (cc @helderco)
https://github.com/dagger/dagger/issues/5904
https://github.com/dagger/dagger/pull/5907
db901c8fe4c70cc32336e304492ca37f12b8f389
e8ad5c62275172e3d54ae46447e741ff5d603450
2023-10-16T18:21:57Z
go
2023-10-25T19:38:59Z
sdk/go/dagger.gen.go
ExperimentalServiceHost *Service } func (r *Client) HTTP(url string, opts ...HTTPOpts) *File { q := r.q.Select("http") for i := len(opts) - 1; i >= 0; i-- { if !querybuilder.IsZeroValue(opts[i].ExperimentalServiceHost) { q = q.Arg("experimentalServiceHost", opts[i].ExperimentalServiceHost) } } q = q.Arg("url", url) return &File{ q: q, c: r.c, } } func (r *Client) LoadCacheVolumeFromID(id CacheVolumeID) *CacheVolume { q := r.q.Select("loadCacheVolumeFromID") q = q.Arg("id", id) return &CacheVolume{ q: q, c: r.c, } } func (r *Client) LoadContainerFromID(id ContainerID) *Container { q := r.q.Select("loadContainerFromID") q = q.Arg("id", id) return &Container{ q: q,
closed
dagger/dagger
https://github.com/dagger/dagger
5,904
Zenith: fix handling of list inputs
```go package main import ( "fmt" ) type Test struct{} type Foo struct { Msg string } func (m *Test) TestListInput(foos []Foo) string { return fmt.Sprintf("%+v", foos) } ``` Currently fails when building the module w/ error `41: [0.44s] ./dagger.gen.go:4250:15: undefined: test` Something must have broken in handling of list input types at some point I'm guessing? cc @jedevc @vito This should at least work in terms of codegen, handling it in `dagger call` is also important but probably a separate task, unless of course we already handled it (cc @helderco)
https://github.com/dagger/dagger/issues/5904
https://github.com/dagger/dagger/pull/5907
db901c8fe4c70cc32336e304492ca37f12b8f389
e8ad5c62275172e3d54ae46447e741ff5d603450
2023-10-16T18:21:57Z
go
2023-10-25T19:38:59Z
sdk/go/dagger.gen.go
c: r.c, } } func (r *Client) LoadDirectoryFromID(id DirectoryID) *Directory { q := r.q.Select("loadDirectoryFromID") q = q.Arg("id", id) return &Directory{ q: q, c: r.c, } } func (r *Client) LoadFileFromID(id FileID) *File { q := r.q.Select("loadFileFromID") q = q.Arg("id", id) return &File{ q: q, c: r.c, } } func (r *Client) LoadFunctionArgFromID(id FunctionArgID) *FunctionArg { q := r.q.Select("loadFunctionArgFromID") q = q.Arg("id", id) return &FunctionArg{ q: q, c: r.c, } } func (r *Client) LoadFunctionFromID(id FunctionID) *Function { q := r.q.Select("loadFunctionFromID") q = q.Arg("id", id)
closed
dagger/dagger
https://github.com/dagger/dagger
5,904
Zenith: fix handling of list inputs
```go package main import ( "fmt" ) type Test struct{} type Foo struct { Msg string } func (m *Test) TestListInput(foos []Foo) string { return fmt.Sprintf("%+v", foos) } ``` Currently fails when building the module w/ error `41: [0.44s] ./dagger.gen.go:4250:15: undefined: test` Something must have broken in handling of list input types at some point I'm guessing? cc @jedevc @vito This should at least work in terms of codegen, handling it in `dagger call` is also important but probably a separate task, unless of course we already handled it (cc @helderco)
https://github.com/dagger/dagger/issues/5904
https://github.com/dagger/dagger/pull/5907
db901c8fe4c70cc32336e304492ca37f12b8f389
e8ad5c62275172e3d54ae46447e741ff5d603450
2023-10-16T18:21:57Z
go
2023-10-25T19:38:59Z
sdk/go/dagger.gen.go
return &Function{ q: q, c: r.c, } } func (r *Client) LoadGeneratedCodeFromID(id GeneratedCodeID) *GeneratedCode { q := r.q.Select("loadGeneratedCodeFromID") q = q.Arg("id", id) return &GeneratedCode{ q: q, c: r.c, } } func (r *Client) LoadModuleFromID(id ModuleID) *Module { q := r.q.Select("loadModuleFromID") q = q.Arg("id", id) return &Module{ q: q, c: r.c, } } func (r *Client) LoadSecretFromID(id SecretID) *Secret { q := r.q.Select("loadSecretFromID") q = q.Arg("id", id) return &Secret{ q: q, c: r.c, } } func (r *Client) LoadServiceFromID(id ServiceID) *Service {
closed
dagger/dagger
https://github.com/dagger/dagger
5,904
Zenith: fix handling of list inputs
```go package main import ( "fmt" ) type Test struct{} type Foo struct { Msg string } func (m *Test) TestListInput(foos []Foo) string { return fmt.Sprintf("%+v", foos) } ``` Currently fails when building the module w/ error `41: [0.44s] ./dagger.gen.go:4250:15: undefined: test` Something must have broken in handling of list input types at some point I'm guessing? cc @jedevc @vito This should at least work in terms of codegen, handling it in `dagger call` is also important but probably a separate task, unless of course we already handled it (cc @helderco)
https://github.com/dagger/dagger/issues/5904
https://github.com/dagger/dagger/pull/5907
db901c8fe4c70cc32336e304492ca37f12b8f389
e8ad5c62275172e3d54ae46447e741ff5d603450
2023-10-16T18:21:57Z
go
2023-10-25T19:38:59Z
sdk/go/dagger.gen.go
q := r.q.Select("loadServiceFromID") q = q.Arg("id", id) return &Service{ q: q, c: r.c, } } func (r *Client) LoadSocketFromID(id SocketID) *Socket { q := r.q.Select("loadSocketFromID") q = q.Arg("id", id) return &Socket{ q: q, c: r.c, } } func (r *Client) LoadTypeDefFromID(id TypeDefID) *TypeDef { q := r.q.Select("loadTypeDefFromID") q = q.Arg("id", id) return &TypeDef{ q: q, c: r.c, } } func (r *Client) Module() *Module { q := r.q.Select("module") return &Module{ q: q, c: r.c, } }
closed
dagger/dagger
https://github.com/dagger/dagger
5,904
Zenith: fix handling of list inputs
```go package main import ( "fmt" ) type Test struct{} type Foo struct { Msg string } func (m *Test) TestListInput(foos []Foo) string { return fmt.Sprintf("%+v", foos) } ``` Currently fails when building the module w/ error `41: [0.44s] ./dagger.gen.go:4250:15: undefined: test` Something must have broken in handling of list input types at some point I'm guessing? cc @jedevc @vito This should at least work in terms of codegen, handling it in `dagger call` is also important but probably a separate task, unless of course we already handled it (cc @helderco)
https://github.com/dagger/dagger/issues/5904
https://github.com/dagger/dagger/pull/5907
db901c8fe4c70cc32336e304492ca37f12b8f389
e8ad5c62275172e3d54ae46447e741ff5d603450
2023-10-16T18:21:57Z
go
2023-10-25T19:38:59Z
sdk/go/dagger.gen.go
type ModuleConfigOpts struct { Subpath string } func (r *Client) ModuleConfig(sourceDirectory *Directory, opts ...ModuleConfigOpts) *ModuleConfig { assertNotNil("sourceDirectory", sourceDirectory) q := r.q.Select("moduleConfig") for i := len(opts) - 1; i >= 0; i-- { if !querybuilder.IsZeroValue(opts[i].Subpath) { q = q.Arg("subpath", opts[i].Subpath) } } q = q.Arg("sourceDirectory", sourceDirectory) return &ModuleConfig{ q: q, c: r.c, } } type PipelineOpts struct { Description string Labels []PipelineLabel } func (r *Client) Pipeline(name string, opts ...PipelineOpts) *Client { q := r.q.Select("pipeline") for i := len(opts) - 1; i >= 0; i-- { if !querybuilder.IsZeroValue(opts[i].Description) { q = q.Arg("description", opts[i].Description)
closed
dagger/dagger
https://github.com/dagger/dagger
5,904
Zenith: fix handling of list inputs
```go package main import ( "fmt" ) type Test struct{} type Foo struct { Msg string } func (m *Test) TestListInput(foos []Foo) string { return fmt.Sprintf("%+v", foos) } ``` Currently fails when building the module w/ error `41: [0.44s] ./dagger.gen.go:4250:15: undefined: test` Something must have broken in handling of list input types at some point I'm guessing? cc @jedevc @vito This should at least work in terms of codegen, handling it in `dagger call` is also important but probably a separate task, unless of course we already handled it (cc @helderco)
https://github.com/dagger/dagger/issues/5904
https://github.com/dagger/dagger/pull/5907
db901c8fe4c70cc32336e304492ca37f12b8f389
e8ad5c62275172e3d54ae46447e741ff5d603450
2023-10-16T18:21:57Z
go
2023-10-25T19:38:59Z
sdk/go/dagger.gen.go
} if !querybuilder.IsZeroValue(opts[i].Labels) { q = q.Arg("labels", opts[i].Labels) } } q = q.Arg("name", name) return &Client{ q: q, c: r.c, } } func (r *Client) Secret(id SecretID) *Secret { q := r.q.Select("secret") q = q.Arg("id", id) return &Secret{ q: q, c: r.c, } } func (r *Client) SetSecret(name string, plaintext string) *Secret { q := r.q.Select("setSecret") q = q.Arg("name", name) q = q.Arg("plaintext", plaintext) return &Secret{ q: q, c: r.c, } } type SocketOpts struct {
closed
dagger/dagger
https://github.com/dagger/dagger
5,904
Zenith: fix handling of list inputs
```go package main import ( "fmt" ) type Test struct{} type Foo struct { Msg string } func (m *Test) TestListInput(foos []Foo) string { return fmt.Sprintf("%+v", foos) } ``` Currently fails when building the module w/ error `41: [0.44s] ./dagger.gen.go:4250:15: undefined: test` Something must have broken in handling of list input types at some point I'm guessing? cc @jedevc @vito This should at least work in terms of codegen, handling it in `dagger call` is also important but probably a separate task, unless of course we already handled it (cc @helderco)
https://github.com/dagger/dagger/issues/5904
https://github.com/dagger/dagger/pull/5907
db901c8fe4c70cc32336e304492ca37f12b8f389
e8ad5c62275172e3d54ae46447e741ff5d603450
2023-10-16T18:21:57Z
go
2023-10-25T19:38:59Z
sdk/go/dagger.gen.go
ID SocketID } func (r *Client) Socket(opts ...SocketOpts) *Socket { q := r.q.Select("socket") for i := len(opts) - 1; i >= 0; i-- { if !querybuilder.IsZeroValue(opts[i].ID) { q = q.Arg("id", opts[i].ID) } } return &Socket{ q: q, c: r.c, } } func (r *Client) TypeDef() *TypeDef { q := r.q.Select("typeDef") return &TypeDef{ q: q, c: r.c, } } type Secret struct {
closed
dagger/dagger
https://github.com/dagger/dagger
5,904
Zenith: fix handling of list inputs
```go package main import ( "fmt" ) type Test struct{} type Foo struct { Msg string } func (m *Test) TestListInput(foos []Foo) string { return fmt.Sprintf("%+v", foos) } ``` Currently fails when building the module w/ error `41: [0.44s] ./dagger.gen.go:4250:15: undefined: test` Something must have broken in handling of list input types at some point I'm guessing? cc @jedevc @vito This should at least work in terms of codegen, handling it in `dagger call` is also important but probably a separate task, unless of course we already handled it (cc @helderco)
https://github.com/dagger/dagger/issues/5904
https://github.com/dagger/dagger/pull/5907
db901c8fe4c70cc32336e304492ca37f12b8f389
e8ad5c62275172e3d54ae46447e741ff5d603450
2023-10-16T18:21:57Z
go
2023-10-25T19:38:59Z
sdk/go/dagger.gen.go
q *querybuilder.Selection c graphql.Client id *SecretID plaintext *string } func (r *Secret) ID(ctx context.Context) (SecretID, error) { if r.id != nil { return *r.id, nil } q := r.q.Select("id") var response SecretID q = q.Bind(&response) return response, q.Execute(ctx, r.c) } func (r *Secret) XXX_GraphQLType() string { return "Secret" } func (r *Secret) XXX_GraphQLIDType() string { return "SecretID" } func (r *Secret) XXX_GraphQLID(ctx context.Context) (string, error) { id, err := r.ID(ctx) if err != nil { return "", err } return string(id), nil } func (r *Secret) MarshalJSON() ([]byte, error) { id, err := r.ID(context.Background())
closed
dagger/dagger
https://github.com/dagger/dagger
5,904
Zenith: fix handling of list inputs
```go package main import ( "fmt" ) type Test struct{} type Foo struct { Msg string } func (m *Test) TestListInput(foos []Foo) string { return fmt.Sprintf("%+v", foos) } ``` Currently fails when building the module w/ error `41: [0.44s] ./dagger.gen.go:4250:15: undefined: test` Something must have broken in handling of list input types at some point I'm guessing? cc @jedevc @vito This should at least work in terms of codegen, handling it in `dagger call` is also important but probably a separate task, unless of course we already handled it (cc @helderco)
https://github.com/dagger/dagger/issues/5904
https://github.com/dagger/dagger/pull/5907
db901c8fe4c70cc32336e304492ca37f12b8f389
e8ad5c62275172e3d54ae46447e741ff5d603450
2023-10-16T18:21:57Z
go
2023-10-25T19:38:59Z
sdk/go/dagger.gen.go
if err != nil { return nil, err } return json.Marshal(id) } func (r *Secret) Plaintext(ctx context.Context) (string, error) { if r.plaintext != nil { return *r.plaintext, nil } q := r.q.Select("plaintext") var response string q = q.Bind(&response) return response, q.Execute(ctx, r.c) } type Service struct { q *querybuilder.Selection c graphql.Client endpoint *string hostname *string id *ServiceID start *ServiceID stop *ServiceID } type ServiceEndpointOpts struct { Port int Scheme string } func (r *Service) Endpoint(ctx context.Context, opts ...ServiceEndpointOpts) (string, error) {
closed
dagger/dagger
https://github.com/dagger/dagger
5,904
Zenith: fix handling of list inputs
```go package main import ( "fmt" ) type Test struct{} type Foo struct { Msg string } func (m *Test) TestListInput(foos []Foo) string { return fmt.Sprintf("%+v", foos) } ``` Currently fails when building the module w/ error `41: [0.44s] ./dagger.gen.go:4250:15: undefined: test` Something must have broken in handling of list input types at some point I'm guessing? cc @jedevc @vito This should at least work in terms of codegen, handling it in `dagger call` is also important but probably a separate task, unless of course we already handled it (cc @helderco)
https://github.com/dagger/dagger/issues/5904
https://github.com/dagger/dagger/pull/5907
db901c8fe4c70cc32336e304492ca37f12b8f389
e8ad5c62275172e3d54ae46447e741ff5d603450
2023-10-16T18:21:57Z
go
2023-10-25T19:38:59Z
sdk/go/dagger.gen.go
if r.endpoint != nil { return *r.endpoint, nil } q := r.q.Select("endpoint") for i := len(opts) - 1; i >= 0; i-- { if !querybuilder.IsZeroValue(opts[i].Port) { q = q.Arg("port", opts[i].Port) } if !querybuilder.IsZeroValue(opts[i].Scheme) { q = q.Arg("scheme", opts[i].Scheme) } } var response string q = q.Bind(&response) return response, q.Execute(ctx, r.c) } func (r *Service) Hostname(ctx context.Context) (string, error) { if r.hostname != nil { return *r.hostname, nil } q := r.q.Select("hostname") var response string q = q.Bind(&response) return response, q.Execute(ctx, r.c) } func (r *Service) ID(ctx context.Context) (ServiceID, error) { if r.id != nil { return *r.id, nil
closed
dagger/dagger
https://github.com/dagger/dagger
5,904
Zenith: fix handling of list inputs
```go package main import ( "fmt" ) type Test struct{} type Foo struct { Msg string } func (m *Test) TestListInput(foos []Foo) string { return fmt.Sprintf("%+v", foos) } ``` Currently fails when building the module w/ error `41: [0.44s] ./dagger.gen.go:4250:15: undefined: test` Something must have broken in handling of list input types at some point I'm guessing? cc @jedevc @vito This should at least work in terms of codegen, handling it in `dagger call` is also important but probably a separate task, unless of course we already handled it (cc @helderco)
https://github.com/dagger/dagger/issues/5904
https://github.com/dagger/dagger/pull/5907
db901c8fe4c70cc32336e304492ca37f12b8f389
e8ad5c62275172e3d54ae46447e741ff5d603450
2023-10-16T18:21:57Z
go
2023-10-25T19:38:59Z
sdk/go/dagger.gen.go
} q := r.q.Select("id") var response ServiceID q = q.Bind(&response) return response, q.Execute(ctx, r.c) } func (r *Service) XXX_GraphQLType() string { return "Service" } func (r *Service) XXX_GraphQLIDType() string { return "ServiceID" } func (r *Service) XXX_GraphQLID(ctx context.Context) (string, error) { id, err := r.ID(ctx) if err != nil { return "", err } return string(id), nil } func (r *Service) MarshalJSON() ([]byte, error) { id, err := r.ID(context.Background()) if err != nil { return nil, err } return json.Marshal(id) } func (r *Service) Ports(ctx context.Context) ([]Port, error) { q := r.q.Select("ports") q = q.Select("description port protocol") type ports struct {
closed
dagger/dagger
https://github.com/dagger/dagger
5,904
Zenith: fix handling of list inputs
```go package main import ( "fmt" ) type Test struct{} type Foo struct { Msg string } func (m *Test) TestListInput(foos []Foo) string { return fmt.Sprintf("%+v", foos) } ``` Currently fails when building the module w/ error `41: [0.44s] ./dagger.gen.go:4250:15: undefined: test` Something must have broken in handling of list input types at some point I'm guessing? cc @jedevc @vito This should at least work in terms of codegen, handling it in `dagger call` is also important but probably a separate task, unless of course we already handled it (cc @helderco)
https://github.com/dagger/dagger/issues/5904
https://github.com/dagger/dagger/pull/5907
db901c8fe4c70cc32336e304492ca37f12b8f389
e8ad5c62275172e3d54ae46447e741ff5d603450
2023-10-16T18:21:57Z
go
2023-10-25T19:38:59Z
sdk/go/dagger.gen.go
Description string Port int Protocol NetworkProtocol } convert := func(fields []ports) []Port { out := []Port{} for i := range fields { val := Port{description: &fields[i].Description, port: &fields[i].Port, protocol: &fields[i].Protocol} out = append(out, val) } return out } var response []ports q = q.Bind(&response) err := q.Execute(ctx, r.c) if err != nil { return nil, err } return convert(response), nil } func (r *Service) Start(ctx context.Context) (*Service, error) { q := r.q.Select("start") return r, q.Execute(ctx, r.c) } func (r *Service) Stop(ctx context.Context) (*Service, error) { q := r.q.Select("stop") return r, q.Execute(ctx, r.c) } type Socket struct {
closed
dagger/dagger
https://github.com/dagger/dagger
5,904
Zenith: fix handling of list inputs
```go package main import ( "fmt" ) type Test struct{} type Foo struct { Msg string } func (m *Test) TestListInput(foos []Foo) string { return fmt.Sprintf("%+v", foos) } ``` Currently fails when building the module w/ error `41: [0.44s] ./dagger.gen.go:4250:15: undefined: test` Something must have broken in handling of list input types at some point I'm guessing? cc @jedevc @vito This should at least work in terms of codegen, handling it in `dagger call` is also important but probably a separate task, unless of course we already handled it (cc @helderco)
https://github.com/dagger/dagger/issues/5904
https://github.com/dagger/dagger/pull/5907
db901c8fe4c70cc32336e304492ca37f12b8f389
e8ad5c62275172e3d54ae46447e741ff5d603450
2023-10-16T18:21:57Z
go
2023-10-25T19:38:59Z
sdk/go/dagger.gen.go
q *querybuilder.Selection c graphql.Client id *SocketID }
closed
dagger/dagger
https://github.com/dagger/dagger
5,904
Zenith: fix handling of list inputs
```go package main import ( "fmt" ) type Test struct{} type Foo struct { Msg string } func (m *Test) TestListInput(foos []Foo) string { return fmt.Sprintf("%+v", foos) } ``` Currently fails when building the module w/ error `41: [0.44s] ./dagger.gen.go:4250:15: undefined: test` Something must have broken in handling of list input types at some point I'm guessing? cc @jedevc @vito This should at least work in terms of codegen, handling it in `dagger call` is also important but probably a separate task, unless of course we already handled it (cc @helderco)
https://github.com/dagger/dagger/issues/5904
https://github.com/dagger/dagger/pull/5907
db901c8fe4c70cc32336e304492ca37f12b8f389
e8ad5c62275172e3d54ae46447e741ff5d603450
2023-10-16T18:21:57Z
go
2023-10-25T19:38:59Z
sdk/go/dagger.gen.go
func (r *Socket) ID(ctx context.Context) (SocketID, error) { if r.id != nil { return *r.id, nil } q := r.q.Select("id") var response SocketID q = q.Bind(&response) return response, q.Execute(ctx, r.c) } func (r *Socket) XXX_GraphQLType() string { return "Socket" } func (r *Socket) XXX_GraphQLIDType() string { return "SocketID" } func (r *Socket) XXX_GraphQLID(ctx context.Context) (string, error) { id, err := r.ID(ctx) if err != nil { return "", err } return string(id), nil } func (r *Socket) MarshalJSON() ([]byte, error) { id, err := r.ID(context.Background()) if err != nil { return nil, err } return json.Marshal(id) } type TypeDef struct {
closed
dagger/dagger
https://github.com/dagger/dagger
5,904
Zenith: fix handling of list inputs
```go package main import ( "fmt" ) type Test struct{} type Foo struct { Msg string } func (m *Test) TestListInput(foos []Foo) string { return fmt.Sprintf("%+v", foos) } ``` Currently fails when building the module w/ error `41: [0.44s] ./dagger.gen.go:4250:15: undefined: test` Something must have broken in handling of list input types at some point I'm guessing? cc @jedevc @vito This should at least work in terms of codegen, handling it in `dagger call` is also important but probably a separate task, unless of course we already handled it (cc @helderco)
https://github.com/dagger/dagger/issues/5904
https://github.com/dagger/dagger/pull/5907
db901c8fe4c70cc32336e304492ca37f12b8f389
e8ad5c62275172e3d54ae46447e741ff5d603450
2023-10-16T18:21:57Z
go
2023-10-25T19:38:59Z
sdk/go/dagger.gen.go
q *querybuilder.Selection c graphql.Client id *TypeDefID kind *TypeDefKind optional *bool } type WithTypeDefFunc func(r *TypeDef) *TypeDef func (r *TypeDef) With(f WithTypeDefFunc) *TypeDef { return f(r) } func (r *TypeDef) AsList() *ListTypeDef { q := r.q.Select("asList") return &ListTypeDef{ q: q, c: r.c, } } func (r *TypeDef) AsObject() *ObjectTypeDef { q := r.q.Select("asObject") return &ObjectTypeDef{ q: q, c: r.c, } } func (r *TypeDef) ID(ctx context.Context) (TypeDefID, error) { if r.id != nil { return *r.id, nil } q := r.q.Select("id") var response TypeDefID
closed
dagger/dagger
https://github.com/dagger/dagger
5,904
Zenith: fix handling of list inputs
```go package main import ( "fmt" ) type Test struct{} type Foo struct { Msg string } func (m *Test) TestListInput(foos []Foo) string { return fmt.Sprintf("%+v", foos) } ``` Currently fails when building the module w/ error `41: [0.44s] ./dagger.gen.go:4250:15: undefined: test` Something must have broken in handling of list input types at some point I'm guessing? cc @jedevc @vito This should at least work in terms of codegen, handling it in `dagger call` is also important but probably a separate task, unless of course we already handled it (cc @helderco)
https://github.com/dagger/dagger/issues/5904
https://github.com/dagger/dagger/pull/5907
db901c8fe4c70cc32336e304492ca37f12b8f389
e8ad5c62275172e3d54ae46447e741ff5d603450
2023-10-16T18:21:57Z
go
2023-10-25T19:38:59Z
sdk/go/dagger.gen.go
q = q.Bind(&response) return response, q.Execute(ctx, r.c) } func (r *TypeDef) XXX_GraphQLType() string { return "TypeDef" } func (r *TypeDef) XXX_GraphQLIDType() string { return "TypeDefID" } func (r *TypeDef) XXX_GraphQLID(ctx context.Context) (string, error) { id, err := r.ID(ctx) if err != nil { return "", err } return string(id), nil } func (r *TypeDef) MarshalJSON() ([]byte, error) { id, err := r.ID(context.Background()) if err != nil { return nil, err } return json.Marshal(id) } func (r *TypeDef) Kind(ctx context.Context) (TypeDefKind, error) { if r.kind != nil { return *r.kind, nil } q := r.q.Select("kind") var response TypeDefKind q = q.Bind(&response)
closed
dagger/dagger
https://github.com/dagger/dagger
5,904
Zenith: fix handling of list inputs
```go package main import ( "fmt" ) type Test struct{} type Foo struct { Msg string } func (m *Test) TestListInput(foos []Foo) string { return fmt.Sprintf("%+v", foos) } ``` Currently fails when building the module w/ error `41: [0.44s] ./dagger.gen.go:4250:15: undefined: test` Something must have broken in handling of list input types at some point I'm guessing? cc @jedevc @vito This should at least work in terms of codegen, handling it in `dagger call` is also important but probably a separate task, unless of course we already handled it (cc @helderco)
https://github.com/dagger/dagger/issues/5904
https://github.com/dagger/dagger/pull/5907
db901c8fe4c70cc32336e304492ca37f12b8f389
e8ad5c62275172e3d54ae46447e741ff5d603450
2023-10-16T18:21:57Z
go
2023-10-25T19:38:59Z
sdk/go/dagger.gen.go
return response, q.Execute(ctx, r.c) } func (r *TypeDef) Optional(ctx context.Context) (bool, error) { if r.optional != nil { return *r.optional, nil } q := r.q.Select("optional") var response bool q = q.Bind(&response) return response, q.Execute(ctx, r.c) } type TypeDefWithFieldOpts struct { Description string } func (r *TypeDef) WithField(name string, typeDef *TypeDef, opts ...TypeDefWithFieldOpts) *TypeDef { assertNotNil("typeDef", typeDef) q := r.q.Select("withField") for i := len(opts) - 1; i >= 0; i-- { if !querybuilder.IsZeroValue(opts[i].Description) { q = q.Arg("description", opts[i].Description) } } q = q.Arg("name", name) q = q.Arg("typeDef", typeDef) return &TypeDef{ q: q, c: r.c, }
closed
dagger/dagger
https://github.com/dagger/dagger
5,904
Zenith: fix handling of list inputs
```go package main import ( "fmt" ) type Test struct{} type Foo struct { Msg string } func (m *Test) TestListInput(foos []Foo) string { return fmt.Sprintf("%+v", foos) } ``` Currently fails when building the module w/ error `41: [0.44s] ./dagger.gen.go:4250:15: undefined: test` Something must have broken in handling of list input types at some point I'm guessing? cc @jedevc @vito This should at least work in terms of codegen, handling it in `dagger call` is also important but probably a separate task, unless of course we already handled it (cc @helderco)
https://github.com/dagger/dagger/issues/5904
https://github.com/dagger/dagger/pull/5907
db901c8fe4c70cc32336e304492ca37f12b8f389
e8ad5c62275172e3d54ae46447e741ff5d603450
2023-10-16T18:21:57Z
go
2023-10-25T19:38:59Z
sdk/go/dagger.gen.go
} func (r *TypeDef) WithFunction(function *Function) *TypeDef { assertNotNil("function", function) q := r.q.Select("withFunction") q = q.Arg("function", function) return &TypeDef{ q: q, c: r.c, } } func (r *TypeDef) WithKind(kind TypeDefKind) *TypeDef { q := r.q.Select("withKind") q = q.Arg("kind", kind) return &TypeDef{ q: q, c: r.c, } } func (r *TypeDef) WithListOf(elementType *TypeDef) *TypeDef { assertNotNil("elementType", elementType) q := r.q.Select("withListOf") q = q.Arg("elementType", elementType) return &TypeDef{ q: q, c: r.c, } } type TypeDefWithObjectOpts struct { Description string }
closed
dagger/dagger
https://github.com/dagger/dagger
5,904
Zenith: fix handling of list inputs
```go package main import ( "fmt" ) type Test struct{} type Foo struct { Msg string } func (m *Test) TestListInput(foos []Foo) string { return fmt.Sprintf("%+v", foos) } ``` Currently fails when building the module w/ error `41: [0.44s] ./dagger.gen.go:4250:15: undefined: test` Something must have broken in handling of list input types at some point I'm guessing? cc @jedevc @vito This should at least work in terms of codegen, handling it in `dagger call` is also important but probably a separate task, unless of course we already handled it (cc @helderco)
https://github.com/dagger/dagger/issues/5904
https://github.com/dagger/dagger/pull/5907
db901c8fe4c70cc32336e304492ca37f12b8f389
e8ad5c62275172e3d54ae46447e741ff5d603450
2023-10-16T18:21:57Z
go
2023-10-25T19:38:59Z
sdk/go/dagger.gen.go
func (r *TypeDef) WithObject(name string, opts ...TypeDefWithObjectOpts) *TypeDef { q := r.q.Select("withObject") for i := len(opts) - 1; i >= 0; i-- { if !querybuilder.IsZeroValue(opts[i].Description) { q = q.Arg("description", opts[i].Description) } } q = q.Arg("name", name) return &TypeDef{ q: q, c: r.c, } } func (r *TypeDef) WithOptional(optional bool) *TypeDef { q := r.q.Select("withOptional") q = q.Arg("optional", optional) return &TypeDef{ q: q, c: r.c, } } type CacheSharingMode string func (CacheSharingMode) IsEnum() {} const ( Locked CacheSharingMode = "LOCKED" Private CacheSharingMode = "PRIVATE" Shared CacheSharingMode = "SHARED" ) type ImageLayerCompression string
closed
dagger/dagger
https://github.com/dagger/dagger
5,904
Zenith: fix handling of list inputs
```go package main import ( "fmt" ) type Test struct{} type Foo struct { Msg string } func (m *Test) TestListInput(foos []Foo) string { return fmt.Sprintf("%+v", foos) } ``` Currently fails when building the module w/ error `41: [0.44s] ./dagger.gen.go:4250:15: undefined: test` Something must have broken in handling of list input types at some point I'm guessing? cc @jedevc @vito This should at least work in terms of codegen, handling it in `dagger call` is also important but probably a separate task, unless of course we already handled it (cc @helderco)
https://github.com/dagger/dagger/issues/5904
https://github.com/dagger/dagger/pull/5907
db901c8fe4c70cc32336e304492ca37f12b8f389
e8ad5c62275172e3d54ae46447e741ff5d603450
2023-10-16T18:21:57Z
go
2023-10-25T19:38:59Z
sdk/go/dagger.gen.go
func (ImageLayerCompression) IsEnum() {} const ( Estargz ImageLayerCompression = "EStarGZ" Gzip ImageLayerCompression = "Gzip" Uncompressed ImageLayerCompression = "Uncompressed" Zstd ImageLayerCompression = "Zstd" ) type ImageMediaTypes string func (ImageMediaTypes) IsEnum() {} const ( Dockermediatypes ImageMediaTypes = "DockerMediaTypes" Ocimediatypes ImageMediaTypes = "OCIMediaTypes" ) type NetworkProtocol string func (NetworkProtocol) IsEnum() {} const ( Tcp NetworkProtocol = "TCP" Udp NetworkProtocol = "UDP" ) type TypeDefKind string func (TypeDefKind) IsEnum() {} const ( Booleankind TypeDefKind = "BooleanKind" Integerkind TypeDefKind = "IntegerKind" Listkind TypeDefKind = "ListKind" Objectkind TypeDefKind = "ObjectKind" Stringkind TypeDefKind = "StringKind" Voidkind TypeDefKind = "VoidKind" )
closed
dagger/dagger
https://github.com/dagger/dagger
5,864
Zenith: Fix `Opts` types in Go SDK
From @jedevc: --- Looks like `Opt` types can't be pointers, e.g. something like this doesn't work: ```go type EchoOpts struct { Suffix string `doc:"String to append to the echoed message." default:"..."` Times int `doc:"Number of times to repeat the message." default:"3"` } func (m *Minimal) EchoOpts(msg string, opts *EchoOpts) string { return m.EchoOptsInline(msg, opts) } ``` The arg type needs to be changed to `opts EchoOpts` for it to work as intended. Giving: ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1809: Undefined type EchoOptsID. ``` --- `Opts` structs cannot be nested: ```go package main import "fmt" type Potato struct{} type PotatoOptions struct { Count int TestingOptions TestingOptions } type TestingOptions struct { Foo string } func (m *Potato) HelloWorld(opts PotatoOptions) string { return fmt.Sprintf("Hello world, I have %d potatoes (%s)", opts.Count, opts.TestingOptions.Foo) } ``` ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1803: Undefined type TestingOptionsID. ```
https://github.com/dagger/dagger/issues/5864
https://github.com/dagger/dagger/pull/5907
db901c8fe4c70cc32336e304492ca37f12b8f389
e8ad5c62275172e3d54ae46447e741ff5d603450
2023-10-10T22:55:05Z
go
2023-10-25T19:38:59Z
cmd/codegen/generator/go/templates/modules.go
package templates import ( "encoding/json" "fmt" "go/ast" "go/token" "go/types" "path/filepath" "sort" "strings" . "github.com/dave/jennifer/jen" "github.com/fatih/structtag" "github.com/iancoleman/strcase" "golang.org/x/tools/go/packages" ) const daggerGenFilename = "dagger.gen.go" /* TODO: * Handle types from 3rd party imports in the type signature * Add packages.NeedImports and packages.NeedDependencies to packages.Load opts, ensure performance is okay (or deal with that by lazy loading) * Fix problem where changing a function signature requires running `dagger mod sync` twice (first one will result in package errors being seen, second one fixes) * Use Overlays field in packages.Config to provide partial generation of dagger.gen.go, without the unupdated code we generate here * Handle automatically re-running `dagger mod sync` when invoking functions from CLI, to save users from having to always remember while developing locally * Support methods defined on non-pointer receivers */ /* moduleMainSrc generates the source code of the main func for Dagger Module code using the Go SDK. The overall idea is that users just need to create a struct with the same name as their Module and then
closed
dagger/dagger
https://github.com/dagger/dagger
5,864
Zenith: Fix `Opts` types in Go SDK
From @jedevc: --- Looks like `Opt` types can't be pointers, e.g. something like this doesn't work: ```go type EchoOpts struct { Suffix string `doc:"String to append to the echoed message." default:"..."` Times int `doc:"Number of times to repeat the message." default:"3"` } func (m *Minimal) EchoOpts(msg string, opts *EchoOpts) string { return m.EchoOptsInline(msg, opts) } ``` The arg type needs to be changed to `opts EchoOpts` for it to work as intended. Giving: ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1809: Undefined type EchoOptsID. ``` --- `Opts` structs cannot be nested: ```go package main import "fmt" type Potato struct{} type PotatoOptions struct { Count int TestingOptions TestingOptions } type TestingOptions struct { Foo string } func (m *Potato) HelloWorld(opts PotatoOptions) string { return fmt.Sprintf("Hello world, I have %d potatoes (%s)", opts.Count, opts.TestingOptions.Foo) } ``` ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1803: Undefined type TestingOptionsID. ```
https://github.com/dagger/dagger/issues/5864
https://github.com/dagger/dagger/pull/5907
db901c8fe4c70cc32336e304492ca37f12b8f389
e8ad5c62275172e3d54ae46447e741ff5d603450
2023-10-10T22:55:05Z
go
2023-10-25T19:38:59Z
cmd/codegen/generator/go/templates/modules.go
add methods to that struct to implement their Module. Methods on that struct become Functions. They are also free to return custom objects from Functions, which themselves may have methods that become Functions too. However, only the "top-level" Module struct's Functions will be directly invokable. This is essentially just the GraphQL execution model. The implementation works by parsing the user's code and generating a main func that reads function call inputs from the Engine, calls the relevant function and returns the result. The generated code is mostly a giant switch/case on the object+function name, with each case doing json deserialization of the input arguments and calling the actual Go function. */ func (funcs goTemplateFuncs) moduleMainSrc() string { if funcs.modulePkg == nil { return `func main() { panic("no code yet") }` } ps := &parseState{ pkg: funcs.modulePkg, fset: funcs.moduleFset, methods: make(map[string][]method), } pkgScope := funcs.modulePkg.Types.Scope() objFunctionCases := map[string][]Code{} createMod := Qual("dag", "CurrentModule").Call() objs := []types.Object{} for _, name := range pkgScope.Names() { obj := pkgScope.Lookup(name) if obj == nil { continue } objs = append(objs, obj)
closed
dagger/dagger
https://github.com/dagger/dagger
5,864
Zenith: Fix `Opts` types in Go SDK
From @jedevc: --- Looks like `Opt` types can't be pointers, e.g. something like this doesn't work: ```go type EchoOpts struct { Suffix string `doc:"String to append to the echoed message." default:"..."` Times int `doc:"Number of times to repeat the message." default:"3"` } func (m *Minimal) EchoOpts(msg string, opts *EchoOpts) string { return m.EchoOptsInline(msg, opts) } ``` The arg type needs to be changed to `opts EchoOpts` for it to work as intended. Giving: ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1809: Undefined type EchoOptsID. ``` --- `Opts` structs cannot be nested: ```go package main import "fmt" type Potato struct{} type PotatoOptions struct { Count int TestingOptions TestingOptions } type TestingOptions struct { Foo string } func (m *Potato) HelloWorld(opts PotatoOptions) string { return fmt.Sprintf("Hello world, I have %d potatoes (%s)", opts.Count, opts.TestingOptions.Foo) } ``` ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1803: Undefined type TestingOptionsID. ```
https://github.com/dagger/dagger/issues/5864
https://github.com/dagger/dagger/pull/5907
db901c8fe4c70cc32336e304492ca37f12b8f389
e8ad5c62275172e3d54ae46447e741ff5d603450
2023-10-10T22:55:05Z
go
2023-10-25T19:38:59Z
cmd/codegen/generator/go/templates/modules.go
} sort.Slice(objs, func(i, j int) bool { return objs[i].Pos() < objs[j].Pos() }) tps := []types.Type{} for _, obj := range objs { tps = append(tps, obj.Type()) } added := map[string]struct{}{} topLevel := true for len(tps) != 0 { for _, tp := range tps { named, isNamed := tp.(*types.Named) if !isNamed { continue } obj := named.Obj() if obj.Pkg() != funcs.modulePkg.Types { continue } strct, isStruct := named.Underlying().(*types.Struct) if !isStruct { continue } if _, ok := added[obj.Name()]; ok { continue
closed
dagger/dagger
https://github.com/dagger/dagger
5,864
Zenith: Fix `Opts` types in Go SDK
From @jedevc: --- Looks like `Opt` types can't be pointers, e.g. something like this doesn't work: ```go type EchoOpts struct { Suffix string `doc:"String to append to the echoed message." default:"..."` Times int `doc:"Number of times to repeat the message." default:"3"` } func (m *Minimal) EchoOpts(msg string, opts *EchoOpts) string { return m.EchoOptsInline(msg, opts) } ``` The arg type needs to be changed to `opts EchoOpts` for it to work as intended. Giving: ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1809: Undefined type EchoOptsID. ``` --- `Opts` structs cannot be nested: ```go package main import "fmt" type Potato struct{} type PotatoOptions struct { Count int TestingOptions TestingOptions } type TestingOptions struct { Foo string } func (m *Potato) HelloWorld(opts PotatoOptions) string { return fmt.Sprintf("Hello world, I have %d potatoes (%s)", opts.Count, opts.TestingOptions.Foo) } ``` ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1803: Undefined type TestingOptionsID. ```
https://github.com/dagger/dagger/issues/5864
https://github.com/dagger/dagger/pull/5907
db901c8fe4c70cc32336e304492ca37f12b8f389
e8ad5c62275172e3d54ae46447e741ff5d603450
2023-10-10T22:55:05Z
go
2023-10-25T19:38:59Z
cmd/codegen/generator/go/templates/modules.go
} objType, err := ps.goStructToAPIType(strct, named) if err != nil { panic(err) } if objType == nil { continue } if err := ps.fillObjectFunctionCases(named, objFunctionCases); err != nil { panic(err) } if len(objFunctionCases[obj.Name()]) == 0 { if topLevel { continue } tokenFile := ps.fset.File(named.Obj().Pos()) isDaggerGenerated := filepath.Base(tokenFile.Name()) == daggerGenFilename if isDaggerGenerated { continue } } createMod = dotLine(createMod, "WithObject").Call(Add(Line(), objType)) added[obj.Name()] = struct{}{}
closed
dagger/dagger
https://github.com/dagger/dagger
5,864
Zenith: Fix `Opts` types in Go SDK
From @jedevc: --- Looks like `Opt` types can't be pointers, e.g. something like this doesn't work: ```go type EchoOpts struct { Suffix string `doc:"String to append to the echoed message." default:"..."` Times int `doc:"Number of times to repeat the message." default:"3"` } func (m *Minimal) EchoOpts(msg string, opts *EchoOpts) string { return m.EchoOptsInline(msg, opts) } ``` The arg type needs to be changed to `opts EchoOpts` for it to work as intended. Giving: ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1809: Undefined type EchoOptsID. ``` --- `Opts` structs cannot be nested: ```go package main import "fmt" type Potato struct{} type PotatoOptions struct { Count int TestingOptions TestingOptions } type TestingOptions struct { Foo string } func (m *Potato) HelloWorld(opts PotatoOptions) string { return fmt.Sprintf("Hello world, I have %d potatoes (%s)", opts.Count, opts.TestingOptions.Foo) } ``` ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1803: Undefined type TestingOptionsID. ```
https://github.com/dagger/dagger/issues/5864
https://github.com/dagger/dagger/pull/5907
db901c8fe4c70cc32336e304492ca37f12b8f389
e8ad5c62275172e3d54ae46447e741ff5d603450
2023-10-10T22:55:05Z
go
2023-10-25T19:38:59Z
cmd/codegen/generator/go/templates/modules.go
} tps, ps.extraTypes = ps.extraTypes, nil topLevel = false } return strings.Join([]string{mainSrc, invokeSrc(objFunctionCases, createMod)}, "\n") } func dotLine(a *Statement, id string) *Statement { return a.Op(".").Line().Id(id) } const ( mainSrc = `func main() {
closed
dagger/dagger
https://github.com/dagger/dagger
5,864
Zenith: Fix `Opts` types in Go SDK
From @jedevc: --- Looks like `Opt` types can't be pointers, e.g. something like this doesn't work: ```go type EchoOpts struct { Suffix string `doc:"String to append to the echoed message." default:"..."` Times int `doc:"Number of times to repeat the message." default:"3"` } func (m *Minimal) EchoOpts(msg string, opts *EchoOpts) string { return m.EchoOptsInline(msg, opts) } ``` The arg type needs to be changed to `opts EchoOpts` for it to work as intended. Giving: ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1809: Undefined type EchoOptsID. ``` --- `Opts` structs cannot be nested: ```go package main import "fmt" type Potato struct{} type PotatoOptions struct { Count int TestingOptions TestingOptions } type TestingOptions struct { Foo string } func (m *Potato) HelloWorld(opts PotatoOptions) string { return fmt.Sprintf("Hello world, I have %d potatoes (%s)", opts.Count, opts.TestingOptions.Foo) } ``` ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1803: Undefined type TestingOptionsID. ```
https://github.com/dagger/dagger/issues/5864
https://github.com/dagger/dagger/pull/5907
db901c8fe4c70cc32336e304492ca37f12b8f389
e8ad5c62275172e3d54ae46447e741ff5d603450
2023-10-10T22:55:05Z
go
2023-10-25T19:38:59Z
cmd/codegen/generator/go/templates/modules.go
ctx := context.Background() fnCall := dag.CurrentFunctionCall() parentName, err := fnCall.ParentName(ctx) if err != nil { fmt.Println(err.Error()) os.Exit(2) } fnName, err := fnCall.Name(ctx) if err != nil { fmt.Println(err.Error()) os.Exit(2) } parentJson, err := fnCall.Parent(ctx) if err != nil { fmt.Println(err.Error()) os.Exit(2) } fnArgs, err := fnCall.InputArgs(ctx) if err != nil { fmt.Println(err.Error()) os.Exit(2) } inputArgs := map[string][]byte{} for _, fnArg := range fnArgs { argName, err := fnArg.Name(ctx) if err != nil { fmt.Println(err.Error()) os.Exit(2) } argValue, err := fnArg.Value(ctx)
closed
dagger/dagger
https://github.com/dagger/dagger
5,864
Zenith: Fix `Opts` types in Go SDK
From @jedevc: --- Looks like `Opt` types can't be pointers, e.g. something like this doesn't work: ```go type EchoOpts struct { Suffix string `doc:"String to append to the echoed message." default:"..."` Times int `doc:"Number of times to repeat the message." default:"3"` } func (m *Minimal) EchoOpts(msg string, opts *EchoOpts) string { return m.EchoOptsInline(msg, opts) } ``` The arg type needs to be changed to `opts EchoOpts` for it to work as intended. Giving: ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1809: Undefined type EchoOptsID. ``` --- `Opts` structs cannot be nested: ```go package main import "fmt" type Potato struct{} type PotatoOptions struct { Count int TestingOptions TestingOptions } type TestingOptions struct { Foo string } func (m *Potato) HelloWorld(opts PotatoOptions) string { return fmt.Sprintf("Hello world, I have %d potatoes (%s)", opts.Count, opts.TestingOptions.Foo) } ``` ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1803: Undefined type TestingOptionsID. ```
https://github.com/dagger/dagger/issues/5864
https://github.com/dagger/dagger/pull/5907
db901c8fe4c70cc32336e304492ca37f12b8f389
e8ad5c62275172e3d54ae46447e741ff5d603450
2023-10-10T22:55:05Z
go
2023-10-25T19:38:59Z
cmd/codegen/generator/go/templates/modules.go
if err != nil { fmt.Println(err.Error()) os.Exit(2) } inputArgs[argName] = []byte(argValue) } result, err := invoke(ctx, []byte(parentJson), parentName, fnName, inputArgs) if err != nil { fmt.Println(err.Error()) os.Exit(2) } resultBytes, err := json.Marshal(result) if err != nil { fmt.Println(err.Error()) os.Exit(2) } _, err = fnCall.ReturnValue(ctx, JSON(resultBytes)) if err != nil { fmt.Println(err.Error()) os.Exit(2) } } ` parentJSONVar = "parentJSON" parentNameVar = "parentName" fnNameVar = "fnName" inputArgsVar = "inputArgs" invokeFuncName = "invoke" ) func invokeSrc(objFunctionCases map[string][]Code, createMod Code) string {
closed
dagger/dagger
https://github.com/dagger/dagger
5,864
Zenith: Fix `Opts` types in Go SDK
From @jedevc: --- Looks like `Opt` types can't be pointers, e.g. something like this doesn't work: ```go type EchoOpts struct { Suffix string `doc:"String to append to the echoed message." default:"..."` Times int `doc:"Number of times to repeat the message." default:"3"` } func (m *Minimal) EchoOpts(msg string, opts *EchoOpts) string { return m.EchoOptsInline(msg, opts) } ``` The arg type needs to be changed to `opts EchoOpts` for it to work as intended. Giving: ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1809: Undefined type EchoOptsID. ``` --- `Opts` structs cannot be nested: ```go package main import "fmt" type Potato struct{} type PotatoOptions struct { Count int TestingOptions TestingOptions } type TestingOptions struct { Foo string } func (m *Potato) HelloWorld(opts PotatoOptions) string { return fmt.Sprintf("Hello world, I have %d potatoes (%s)", opts.Count, opts.TestingOptions.Foo) } ``` ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1803: Undefined type TestingOptionsID. ```
https://github.com/dagger/dagger/issues/5864
https://github.com/dagger/dagger/pull/5907
db901c8fe4c70cc32336e304492ca37f12b8f389
e8ad5c62275172e3d54ae46447e741ff5d603450
2023-10-10T22:55:05Z
go
2023-10-25T19:38:59Z
cmd/codegen/generator/go/templates/modules.go
objCases := []Code{} for objName, functionCases := range objFunctionCases { objCases = append(objCases, Case(Lit(objName)).Block(Switch(Id(fnNameVar)).Block(functionCases...))) } objCases = append(objCases, Case(Lit("")).Block( Return(createMod, Nil()), )) objCases = append(objCases, Default().Block( Return(Nil(), Qual("fmt", "Errorf").Call(Lit("unknown object %s"), Id(parentNameVar))), )) objSwitch := Switch(Id(parentNameVar)).Block(objCases...) invokeFunc := Func().Id(invokeFuncName).Params( Id("ctx").Qual("context", "Context"), Id(parentJSONVar).Index().Byte(), Id(parentNameVar).String(), Id(fnNameVar).String(), Id(inputArgsVar).Map(String()).Index().Byte(), ).Params(
closed
dagger/dagger
https://github.com/dagger/dagger
5,864
Zenith: Fix `Opts` types in Go SDK
From @jedevc: --- Looks like `Opt` types can't be pointers, e.g. something like this doesn't work: ```go type EchoOpts struct { Suffix string `doc:"String to append to the echoed message." default:"..."` Times int `doc:"Number of times to repeat the message." default:"3"` } func (m *Minimal) EchoOpts(msg string, opts *EchoOpts) string { return m.EchoOptsInline(msg, opts) } ``` The arg type needs to be changed to `opts EchoOpts` for it to work as intended. Giving: ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1809: Undefined type EchoOptsID. ``` --- `Opts` structs cannot be nested: ```go package main import "fmt" type Potato struct{} type PotatoOptions struct { Count int TestingOptions TestingOptions } type TestingOptions struct { Foo string } func (m *Potato) HelloWorld(opts PotatoOptions) string { return fmt.Sprintf("Hello world, I have %d potatoes (%s)", opts.Count, opts.TestingOptions.Foo) } ``` ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1803: Undefined type TestingOptionsID. ```
https://github.com/dagger/dagger/issues/5864
https://github.com/dagger/dagger/pull/5907
db901c8fe4c70cc32336e304492ca37f12b8f389
e8ad5c62275172e3d54ae46447e741ff5d603450
2023-10-10T22:55:05Z
go
2023-10-25T19:38:59Z
cmd/codegen/generator/go/templates/modules.go
Id("any"), Error(), ).Block(objSwitch) return fmt.Sprintf("%#v", invokeFunc) } func renderNameOrStruct(t types.Type) string { if ptr, ok := t.(*types.Pointer); ok { return "*" + renderNameOrStruct(ptr.Elem()) } if named, ok := t.(*types.Named); ok { return named.Obj().Name() } return t.String() } var checkErrStatement = If(Err().Op("!=").Nil()).Block( Qual("fmt", "Println").Call(Err().Dot("Error").Call()), Qual("os", "Exit").Call(Lit(2)), ) func (ps *parseState) fillObjectFunctionCases(type_ types.Type, cases map[string][]Code) error { var objName string switch x := type_.(type) { case *types.Pointer: return ps.fillObjectFunctionCases(x.Elem(), cases) case *types.Named:
closed
dagger/dagger
https://github.com/dagger/dagger
5,864
Zenith: Fix `Opts` types in Go SDK
From @jedevc: --- Looks like `Opt` types can't be pointers, e.g. something like this doesn't work: ```go type EchoOpts struct { Suffix string `doc:"String to append to the echoed message." default:"..."` Times int `doc:"Number of times to repeat the message." default:"3"` } func (m *Minimal) EchoOpts(msg string, opts *EchoOpts) string { return m.EchoOptsInline(msg, opts) } ``` The arg type needs to be changed to `opts EchoOpts` for it to work as intended. Giving: ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1809: Undefined type EchoOptsID. ``` --- `Opts` structs cannot be nested: ```go package main import "fmt" type Potato struct{} type PotatoOptions struct { Count int TestingOptions TestingOptions } type TestingOptions struct { Foo string } func (m *Potato) HelloWorld(opts PotatoOptions) string { return fmt.Sprintf("Hello world, I have %d potatoes (%s)", opts.Count, opts.TestingOptions.Foo) } ``` ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1803: Undefined type TestingOptionsID. ```
https://github.com/dagger/dagger/issues/5864
https://github.com/dagger/dagger/pull/5907
db901c8fe4c70cc32336e304492ca37f12b8f389
e8ad5c62275172e3d54ae46447e741ff5d603450
2023-10-10T22:55:05Z
go
2023-10-25T19:38:59Z
cmd/codegen/generator/go/templates/modules.go
objName = x.Obj().Name() default: return nil } if existingCases := cases[objName]; len(existingCases) > 0 { return nil } methods := ps.methods[objName] if len(methods) == 0 { return nil } for _, method := range methods { fnName, sig := method.name, method.sig statements := []Code{ Var().Id("err").Error(), } parentVarName := "parent" statements = append(statements, Var().Id(parentVarName).Id(objName), Err().Op("=").Qual("json", "Unmarshal").Call(Id(parentJSONVar), Op("&").Id(parentVarName)), checkErrStatement, ) fnCallArgs := []Code{Op("&").Id(parentVarName)} for i := 0; i < sig.Params().Len(); i++ { arg := sig.Params().At(i) if i == 0 && arg.Type().String() == "context.Context" { fnCallArgs = append(fnCallArgs, Id("ctx")) continue }
closed
dagger/dagger
https://github.com/dagger/dagger
5,864
Zenith: Fix `Opts` types in Go SDK
From @jedevc: --- Looks like `Opt` types can't be pointers, e.g. something like this doesn't work: ```go type EchoOpts struct { Suffix string `doc:"String to append to the echoed message." default:"..."` Times int `doc:"Number of times to repeat the message." default:"3"` } func (m *Minimal) EchoOpts(msg string, opts *EchoOpts) string { return m.EchoOptsInline(msg, opts) } ``` The arg type needs to be changed to `opts EchoOpts` for it to work as intended. Giving: ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1809: Undefined type EchoOptsID. ``` --- `Opts` structs cannot be nested: ```go package main import "fmt" type Potato struct{} type PotatoOptions struct { Count int TestingOptions TestingOptions } type TestingOptions struct { Foo string } func (m *Potato) HelloWorld(opts PotatoOptions) string { return fmt.Sprintf("Hello world, I have %d potatoes (%s)", opts.Count, opts.TestingOptions.Foo) } ``` ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1803: Undefined type TestingOptionsID. ```
https://github.com/dagger/dagger/issues/5864
https://github.com/dagger/dagger/pull/5907
db901c8fe4c70cc32336e304492ca37f12b8f389
e8ad5c62275172e3d54ae46447e741ff5d603450
2023-10-10T22:55:05Z
go
2023-10-25T19:38:59Z
cmd/codegen/generator/go/templates/modules.go
if opts, ok := namedOrDirectStruct(arg.Type()); ok { optsName := arg.Name() statements = append(statements, Var().Id(optsName).Id(renderNameOrStruct(arg.Type()))) for f := 0; f < opts.NumFields(); f++ { param := opts.Field(f) argName := strcase.ToLowerCamel(param.Name()) statements = append(statements, If(Id(inputArgsVar).Index(Lit(argName)).Op("!=").Nil()).Block( Err().Op("=").Qual("json", "Unmarshal").Call( Index().Byte().Parens(Id(inputArgsVar).Index(Lit(argName))), Op("&").Id(optsName).Dot(param.Name()), ), checkErrStatement, )) } fnCallArgs = append(fnCallArgs, Id(optsName)) } else { argName := strcase.ToLowerCamel(arg.Name()) statements = append(statements, Var().Id(argName).Id(renderNameOrStruct(arg.Type())), Err().Op("=").Qual("json", "Unmarshal").Call( Index().Byte().Parens(Id(inputArgsVar).Index(Lit(argName))), Op("&").Id(argName), ), checkErrStatement, ) fnCallArgs = append(fnCallArgs, Id(argName)) } }
closed
dagger/dagger
https://github.com/dagger/dagger
5,864
Zenith: Fix `Opts` types in Go SDK
From @jedevc: --- Looks like `Opt` types can't be pointers, e.g. something like this doesn't work: ```go type EchoOpts struct { Suffix string `doc:"String to append to the echoed message." default:"..."` Times int `doc:"Number of times to repeat the message." default:"3"` } func (m *Minimal) EchoOpts(msg string, opts *EchoOpts) string { return m.EchoOptsInline(msg, opts) } ``` The arg type needs to be changed to `opts EchoOpts` for it to work as intended. Giving: ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1809: Undefined type EchoOptsID. ``` --- `Opts` structs cannot be nested: ```go package main import "fmt" type Potato struct{} type PotatoOptions struct { Count int TestingOptions TestingOptions } type TestingOptions struct { Foo string } func (m *Potato) HelloWorld(opts PotatoOptions) string { return fmt.Sprintf("Hello world, I have %d potatoes (%s)", opts.Count, opts.TestingOptions.Foo) } ``` ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1803: Undefined type TestingOptionsID. ```
https://github.com/dagger/dagger/issues/5864
https://github.com/dagger/dagger/pull/5907
db901c8fe4c70cc32336e304492ca37f12b8f389
e8ad5c62275172e3d54ae46447e741ff5d603450
2023-10-10T22:55:05Z
go
2023-10-25T19:38:59Z
cmd/codegen/generator/go/templates/modules.go
results := sig.Results() switch results.Len() { case 2: if results.At(1).Type().String() != errorTypeName { return fmt.Errorf("second return value must be error, have %s", results.At(0).Type().String()) } statements = append(statements, Return( Parens(Op("*").Id(objName)).Dot(fnName).Call(fnCallArgs...), )) cases[objName] = append(cases[objName], Case(Lit(fnName)).Block(statements...)) if err := ps.fillObjectFunctionCases(results.At(0).Type(), cases); err != nil { return err } case 1: if results.At(0).Type().String() == errorTypeName { statements = append(statements, Return( Nil(), Parens(Op("*").Id(objName)).Dot(fnName).Call(fnCallArgs...), )) cases[objName] = append(cases[objName], Case(Lit(fnName)).Block(statements...)) } else { statements = append(statements, Return( Parens(Op("*").Id(objName)).Dot(fnName).Call(fnCallArgs...), Nil(), )) cases[objName] = append(cases[objName], Case(Lit(fnName)).Block(statements...))
closed
dagger/dagger
https://github.com/dagger/dagger
5,864
Zenith: Fix `Opts` types in Go SDK
From @jedevc: --- Looks like `Opt` types can't be pointers, e.g. something like this doesn't work: ```go type EchoOpts struct { Suffix string `doc:"String to append to the echoed message." default:"..."` Times int `doc:"Number of times to repeat the message." default:"3"` } func (m *Minimal) EchoOpts(msg string, opts *EchoOpts) string { return m.EchoOptsInline(msg, opts) } ``` The arg type needs to be changed to `opts EchoOpts` for it to work as intended. Giving: ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1809: Undefined type EchoOptsID. ``` --- `Opts` structs cannot be nested: ```go package main import "fmt" type Potato struct{} type PotatoOptions struct { Count int TestingOptions TestingOptions } type TestingOptions struct { Foo string } func (m *Potato) HelloWorld(opts PotatoOptions) string { return fmt.Sprintf("Hello world, I have %d potatoes (%s)", opts.Count, opts.TestingOptions.Foo) } ``` ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1803: Undefined type TestingOptionsID. ```
https://github.com/dagger/dagger/issues/5864
https://github.com/dagger/dagger/pull/5907
db901c8fe4c70cc32336e304492ca37f12b8f389
e8ad5c62275172e3d54ae46447e741ff5d603450
2023-10-10T22:55:05Z
go
2023-10-25T19:38:59Z
cmd/codegen/generator/go/templates/modules.go
if err := ps.fillObjectFunctionCases(results.At(0).Type(), cases); err != nil { return err } } case 0: statements = append(statements, Parens(Op("*").Id(objName)).Dot(fnName).Call(fnCallArgs...), Return(Nil(), Nil())) cases[objName] = append(cases[objName], Case(Lit(fnName)).Block(statements...)) default: return fmt.Errorf("unexpected number of results from method %s: %d", fnName, results.Len()) } } cases[objName] = append(cases[objName], Default().Block( Return(Nil(), Qual("fmt", "Errorf").Call(Lit("unknown function %s"), Id(fnNameVar))), )) return nil } type parseState struct { pkg *packages.Package fset *token.FileSet methods map[string][]method extraTypes []types.Type } type method struct {
closed
dagger/dagger
https://github.com/dagger/dagger
5,864
Zenith: Fix `Opts` types in Go SDK
From @jedevc: --- Looks like `Opt` types can't be pointers, e.g. something like this doesn't work: ```go type EchoOpts struct { Suffix string `doc:"String to append to the echoed message." default:"..."` Times int `doc:"Number of times to repeat the message." default:"3"` } func (m *Minimal) EchoOpts(msg string, opts *EchoOpts) string { return m.EchoOptsInline(msg, opts) } ``` The arg type needs to be changed to `opts EchoOpts` for it to work as intended. Giving: ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1809: Undefined type EchoOptsID. ``` --- `Opts` structs cannot be nested: ```go package main import "fmt" type Potato struct{} type PotatoOptions struct { Count int TestingOptions TestingOptions } type TestingOptions struct { Foo string } func (m *Potato) HelloWorld(opts PotatoOptions) string { return fmt.Sprintf("Hello world, I have %d potatoes (%s)", opts.Count, opts.TestingOptions.Foo) } ``` ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1803: Undefined type TestingOptionsID. ```
https://github.com/dagger/dagger/issues/5864
https://github.com/dagger/dagger/pull/5907
db901c8fe4c70cc32336e304492ca37f12b8f389
e8ad5c62275172e3d54ae46447e741ff5d603450
2023-10-10T22:55:05Z
go
2023-10-25T19:38:59Z
cmd/codegen/generator/go/templates/modules.go
name string sig *types.Signature } func (ps *parseState) goTypeToAPIType(typ types.Type, named *types.Named) (*Statement, error) { ps.extraTypes = append(ps.extraTypes, typ) switch t := typ.(type) { case *types.Named: typeDef, err := ps.goTypeToAPIType(t.Underlying(), t) if err != nil { return nil, fmt.Errorf("failed to convert named type: %w", err) } return typeDef, nil case *types.Pointer: return ps.goTypeToAPIType(t.Elem(), named) case *types.Basic: if t.Kind() == types.Invalid { return nil, fmt.Errorf("invalid type: %+v", t) } var kind Code switch t.Info() { case types.IsString: kind = Id("Stringkind") case types.IsInteger: kind = Id("Integerkind") case types.IsBoolean: kind = Id("Booleankind")
closed
dagger/dagger
https://github.com/dagger/dagger
5,864
Zenith: Fix `Opts` types in Go SDK
From @jedevc: --- Looks like `Opt` types can't be pointers, e.g. something like this doesn't work: ```go type EchoOpts struct { Suffix string `doc:"String to append to the echoed message." default:"..."` Times int `doc:"Number of times to repeat the message." default:"3"` } func (m *Minimal) EchoOpts(msg string, opts *EchoOpts) string { return m.EchoOptsInline(msg, opts) } ``` The arg type needs to be changed to `opts EchoOpts` for it to work as intended. Giving: ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1809: Undefined type EchoOptsID. ``` --- `Opts` structs cannot be nested: ```go package main import "fmt" type Potato struct{} type PotatoOptions struct { Count int TestingOptions TestingOptions } type TestingOptions struct { Foo string } func (m *Potato) HelloWorld(opts PotatoOptions) string { return fmt.Sprintf("Hello world, I have %d potatoes (%s)", opts.Count, opts.TestingOptions.Foo) } ``` ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1803: Undefined type TestingOptionsID. ```
https://github.com/dagger/dagger/issues/5864
https://github.com/dagger/dagger/pull/5907
db901c8fe4c70cc32336e304492ca37f12b8f389
e8ad5c62275172e3d54ae46447e741ff5d603450
2023-10-10T22:55:05Z
go
2023-10-25T19:38:59Z
cmd/codegen/generator/go/templates/modules.go
default: return nil, fmt.Errorf("unsupported basic type: %+v", t) } return Qual("dag", "TypeDef").Call().Dot("WithKind").Call( kind, ), nil case *types.Slice: elemTypeDef, err := ps.goTypeToAPIType(t.Elem(), nil) if err != nil { return nil, fmt.Errorf("failed to convert slice element type: %w", err) } return Qual("dag", "TypeDef").Call().Dot("WithListOf").Call( elemTypeDef, ), nil case *types.Struct: if named == nil { return nil, fmt.Errorf("struct types must be named") } typeName := named.Obj().Name() if typeName == "" { return nil, fmt.Errorf("struct types must be named") } return Qual("dag", "TypeDef").Call().Dot("WithObject").Call( Lit(typeName), ), nil default: return nil, fmt.Errorf("unsupported type %T", t) } } const errorTypeName = "error"
closed
dagger/dagger
https://github.com/dagger/dagger
5,864
Zenith: Fix `Opts` types in Go SDK
From @jedevc: --- Looks like `Opt` types can't be pointers, e.g. something like this doesn't work: ```go type EchoOpts struct { Suffix string `doc:"String to append to the echoed message." default:"..."` Times int `doc:"Number of times to repeat the message." default:"3"` } func (m *Minimal) EchoOpts(msg string, opts *EchoOpts) string { return m.EchoOptsInline(msg, opts) } ``` The arg type needs to be changed to `opts EchoOpts` for it to work as intended. Giving: ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1809: Undefined type EchoOptsID. ``` --- `Opts` structs cannot be nested: ```go package main import "fmt" type Potato struct{} type PotatoOptions struct { Count int TestingOptions TestingOptions } type TestingOptions struct { Foo string } func (m *Potato) HelloWorld(opts PotatoOptions) string { return fmt.Sprintf("Hello world, I have %d potatoes (%s)", opts.Count, opts.TestingOptions.Foo) } ``` ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1803: Undefined type TestingOptionsID. ```
https://github.com/dagger/dagger/issues/5864
https://github.com/dagger/dagger/pull/5907
db901c8fe4c70cc32336e304492ca37f12b8f389
e8ad5c62275172e3d54ae46447e741ff5d603450
2023-10-10T22:55:05Z
go
2023-10-25T19:38:59Z
cmd/codegen/generator/go/templates/modules.go
func (ps *parseState) goStructToAPIType(t *types.Struct, named *types.Named) (*Statement, error) { if named == nil { return nil, fmt.Errorf("struct types must be named") } typeName := named.Obj().Name() if typeName == "" { return nil, fmt.Errorf("struct types must be named") } tokenFile := ps.fset.File(named.Obj().Pos()) objectIsDaggerGenerated := filepath.Base(tokenFile.Name()) == daggerGenFilename methods := []*types.Func{} methodSet := types.NewMethodSet(types.NewPointer(named)) for i := 0; i < methodSet.Len(); i++ { methodObj := methodSet.At(i).Obj() methodTokenFile := ps.fset.File(methodObj.Pos()) methodIsDaggerGenerated := filepath.Base(methodTokenFile.Name()) == daggerGenFilename if methodIsDaggerGenerated { continue } if objectIsDaggerGenerated { return nil, fmt.Errorf("cannot define methods on objects from outside this module") } method, ok := methodObj.(*types.Func) if !ok {
closed
dagger/dagger
https://github.com/dagger/dagger
5,864
Zenith: Fix `Opts` types in Go SDK
From @jedevc: --- Looks like `Opt` types can't be pointers, e.g. something like this doesn't work: ```go type EchoOpts struct { Suffix string `doc:"String to append to the echoed message." default:"..."` Times int `doc:"Number of times to repeat the message." default:"3"` } func (m *Minimal) EchoOpts(msg string, opts *EchoOpts) string { return m.EchoOptsInline(msg, opts) } ``` The arg type needs to be changed to `opts EchoOpts` for it to work as intended. Giving: ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1809: Undefined type EchoOptsID. ``` --- `Opts` structs cannot be nested: ```go package main import "fmt" type Potato struct{} type PotatoOptions struct { Count int TestingOptions TestingOptions } type TestingOptions struct { Foo string } func (m *Potato) HelloWorld(opts PotatoOptions) string { return fmt.Sprintf("Hello world, I have %d potatoes (%s)", opts.Count, opts.TestingOptions.Foo) } ``` ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1803: Undefined type TestingOptionsID. ```
https://github.com/dagger/dagger/issues/5864
https://github.com/dagger/dagger/pull/5907
db901c8fe4c70cc32336e304492ca37f12b8f389
e8ad5c62275172e3d54ae46447e741ff5d603450
2023-10-10T22:55:05Z
go
2023-10-25T19:38:59Z
cmd/codegen/generator/go/templates/modules.go
return nil, fmt.Errorf("expected method to be a func, got %T", methodObj) } if !method.Exported() { continue } methods = append(methods, method) } if objectIsDaggerGenerated { return nil, nil } sort.Slice(methods, func(i, j int) bool { return methods[i].Pos() < methods[j].Pos() }) withObjectArgs := []Code{ Lit(typeName), } withObjectOpts := []Code{} typeSpec, err := ps.typeSpecForNamedType(named) if err != nil { return nil, fmt.Errorf("failed to find decl for named type %s: %w", typeName, err) } if doc := typeSpec.Doc; doc != nil { withObjectOpts = append(withObjectOpts, Id("Description").Op(":").Lit(doc.Text())) } if len(withObjectOpts) > 0 { withObjectArgs = append(withObjectArgs, Id("TypeDefWithObjectOpts").Values(withObjectOpts...)) } typeDef := Qual("dag", "TypeDef").Call().Dot("WithObject").Call(withObjectArgs...)
closed
dagger/dagger
https://github.com/dagger/dagger
5,864
Zenith: Fix `Opts` types in Go SDK
From @jedevc: --- Looks like `Opt` types can't be pointers, e.g. something like this doesn't work: ```go type EchoOpts struct { Suffix string `doc:"String to append to the echoed message." default:"..."` Times int `doc:"Number of times to repeat the message." default:"3"` } func (m *Minimal) EchoOpts(msg string, opts *EchoOpts) string { return m.EchoOptsInline(msg, opts) } ``` The arg type needs to be changed to `opts EchoOpts` for it to work as intended. Giving: ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1809: Undefined type EchoOptsID. ``` --- `Opts` structs cannot be nested: ```go package main import "fmt" type Potato struct{} type PotatoOptions struct { Count int TestingOptions TestingOptions } type TestingOptions struct { Foo string } func (m *Potato) HelloWorld(opts PotatoOptions) string { return fmt.Sprintf("Hello world, I have %d potatoes (%s)", opts.Count, opts.TestingOptions.Foo) } ``` ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1803: Undefined type TestingOptionsID. ```
https://github.com/dagger/dagger/issues/5864
https://github.com/dagger/dagger/pull/5907
db901c8fe4c70cc32336e304492ca37f12b8f389
e8ad5c62275172e3d54ae46447e741ff5d603450
2023-10-10T22:55:05Z
go
2023-10-25T19:38:59Z
cmd/codegen/generator/go/templates/modules.go
for _, method := range methods { fnTypeDef, err := ps.goMethodToAPIFunctionDef(typeName, method, named) if err != nil { return nil, fmt.Errorf("failed to convert method %s to function def: %w", method.Name(), err) } typeDef = dotLine(typeDef, "WithFunction").Call(Add(Line(), fnTypeDef)) } astStructType, ok := typeSpec.Type.(*ast.StructType) if !ok { return nil, fmt.Errorf("expected type spec to be a struct, got %T", typeSpec.Type) } for i := 0; i < t.NumFields(); i++ { field := t.Field(i) if !field.Exported() { continue } fieldTypeDef, err := ps.goTypeToAPIType(field.Type(), nil) if err != nil { return nil, fmt.Errorf("failed to convert field type: %w", err) } var description string if doc := astStructType.Fields.List[i].Doc; doc != nil { description = doc.Text() } withFieldArgs := []Code{ Lit(field.Name()), fieldTypeDef, } if description != "" {
closed
dagger/dagger
https://github.com/dagger/dagger
5,864
Zenith: Fix `Opts` types in Go SDK
From @jedevc: --- Looks like `Opt` types can't be pointers, e.g. something like this doesn't work: ```go type EchoOpts struct { Suffix string `doc:"String to append to the echoed message." default:"..."` Times int `doc:"Number of times to repeat the message." default:"3"` } func (m *Minimal) EchoOpts(msg string, opts *EchoOpts) string { return m.EchoOptsInline(msg, opts) } ``` The arg type needs to be changed to `opts EchoOpts` for it to work as intended. Giving: ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1809: Undefined type EchoOptsID. ``` --- `Opts` structs cannot be nested: ```go package main import "fmt" type Potato struct{} type PotatoOptions struct { Count int TestingOptions TestingOptions } type TestingOptions struct { Foo string } func (m *Potato) HelloWorld(opts PotatoOptions) string { return fmt.Sprintf("Hello world, I have %d potatoes (%s)", opts.Count, opts.TestingOptions.Foo) } ``` ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1803: Undefined type TestingOptionsID. ```
https://github.com/dagger/dagger/issues/5864
https://github.com/dagger/dagger/pull/5907
db901c8fe4c70cc32336e304492ca37f12b8f389
e8ad5c62275172e3d54ae46447e741ff5d603450
2023-10-10T22:55:05Z
go
2023-10-25T19:38:59Z
cmd/codegen/generator/go/templates/modules.go
withFieldArgs = append(withFieldArgs, Id("TypeDefWithFieldOpts").Values( Id("Description").Op(":").Lit(description), )) } typeDef = dotLine(typeDef, "WithField").Call(withFieldArgs...) } return typeDef, nil } var voidDef = Qual("dag", "TypeDef").Call(). Dot("WithKind").Call(Id("Voidkind")). Dot("WithOptional").Call(Lit(true)) func (ps *parseState) goMethodToAPIFunctionDef(typeName string, fn *types.Func, named *types.Named) (*Statement, error) { methodSig, ok := fn.Type().(*types.Signature) if !ok { return nil, fmt.Errorf("expected method to be a func, got %T", fn.Type()) } ps.methods[typeName] = append(ps.methods[typeName], method{ name: fn.Name(), sig: methodSig, }) var err error var fnReturnType *Statement methodResults := methodSig.Results() switch methodResults.Len() { case 0: fnReturnType = voidDef case 1:
closed
dagger/dagger
https://github.com/dagger/dagger
5,864
Zenith: Fix `Opts` types in Go SDK
From @jedevc: --- Looks like `Opt` types can't be pointers, e.g. something like this doesn't work: ```go type EchoOpts struct { Suffix string `doc:"String to append to the echoed message." default:"..."` Times int `doc:"Number of times to repeat the message." default:"3"` } func (m *Minimal) EchoOpts(msg string, opts *EchoOpts) string { return m.EchoOptsInline(msg, opts) } ``` The arg type needs to be changed to `opts EchoOpts` for it to work as intended. Giving: ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1809: Undefined type EchoOptsID. ``` --- `Opts` structs cannot be nested: ```go package main import "fmt" type Potato struct{} type PotatoOptions struct { Count int TestingOptions TestingOptions } type TestingOptions struct { Foo string } func (m *Potato) HelloWorld(opts PotatoOptions) string { return fmt.Sprintf("Hello world, I have %d potatoes (%s)", opts.Count, opts.TestingOptions.Foo) } ``` ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1803: Undefined type TestingOptionsID. ```
https://github.com/dagger/dagger/issues/5864
https://github.com/dagger/dagger/pull/5907
db901c8fe4c70cc32336e304492ca37f12b8f389
e8ad5c62275172e3d54ae46447e741ff5d603450
2023-10-10T22:55:05Z
go
2023-10-25T19:38:59Z
cmd/codegen/generator/go/templates/modules.go
result := methodResults.At(0).Type() if result.String() == errorTypeName { fnReturnType = voidDef } else { fnReturnType, err = ps.goTypeToAPIType(result, nil) if err != nil { return nil, fmt.Errorf("failed to convert result type: %w", err) } } case 2: result := methodResults.At(0).Type() fnReturnType, err = ps.goTypeToAPIType(result, nil) if err != nil { return nil, fmt.Errorf("failed to convert result type: %w", err) } default: return nil, fmt.Errorf("method %s has too many return values", fn.Name()) } fnDef := Qual("dag", "Function").Call(Lit(fn.Name()), Add(Line(), fnReturnType)) funcDecl, err := ps.declForFunc(fn) if err != nil { return nil, fmt.Errorf("failed to find decl for method %s: %w", fn.Name(), err) } if doc := funcDecl.Doc; doc != nil { fnDef = dotLine(fnDef, "WithDescription").Call(Lit(doc.Text())) } for i := 0; i < methodSig.Params().Len(); i++ { param := methodSig.Params().At(i) if i == 0 && param.Type().String() == "context.Context" {
closed
dagger/dagger
https://github.com/dagger/dagger
5,864
Zenith: Fix `Opts` types in Go SDK
From @jedevc: --- Looks like `Opt` types can't be pointers, e.g. something like this doesn't work: ```go type EchoOpts struct { Suffix string `doc:"String to append to the echoed message." default:"..."` Times int `doc:"Number of times to repeat the message." default:"3"` } func (m *Minimal) EchoOpts(msg string, opts *EchoOpts) string { return m.EchoOptsInline(msg, opts) } ``` The arg type needs to be changed to `opts EchoOpts` for it to work as intended. Giving: ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1809: Undefined type EchoOptsID. ``` --- `Opts` structs cannot be nested: ```go package main import "fmt" type Potato struct{} type PotatoOptions struct { Count int TestingOptions TestingOptions } type TestingOptions struct { Foo string } func (m *Potato) HelloWorld(opts PotatoOptions) string { return fmt.Sprintf("Hello world, I have %d potatoes (%s)", opts.Count, opts.TestingOptions.Foo) } ``` ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1803: Undefined type TestingOptionsID. ```
https://github.com/dagger/dagger/issues/5864
https://github.com/dagger/dagger/pull/5907
db901c8fe4c70cc32336e304492ca37f12b8f389
e8ad5c62275172e3d54ae46447e741ff5d603450
2023-10-10T22:55:05Z
go
2023-10-25T19:38:59Z
cmd/codegen/generator/go/templates/modules.go
continue } if opts, ok := namedOrDirectStruct(param.Type()); ok { for f := 0; f < opts.NumFields(); f++ { param := opts.Field(f) tags, err := structtag.Parse(opts.Tag(f)) if err != nil { return nil, fmt.Errorf("failed to parse struct tag: %w", err) } argTypeDef, err := ps.goTypeToAPIType(param.Type(), nil) if err != nil { return nil, fmt.Errorf("failed to convert param type: %w", err) } argOptional := true if tags != nil { if tag, err := tags.Get("required"); err == nil { argOptional = tag.Value() == "true" } } argTypeDef = argTypeDef.Dot("WithOptional").Call(Lit(argOptional)) argArgs := []Code{ Lit(param.Name()), argTypeDef, } argOpts := []Code{} if tags != nil {
closed
dagger/dagger
https://github.com/dagger/dagger
5,864
Zenith: Fix `Opts` types in Go SDK
From @jedevc: --- Looks like `Opt` types can't be pointers, e.g. something like this doesn't work: ```go type EchoOpts struct { Suffix string `doc:"String to append to the echoed message." default:"..."` Times int `doc:"Number of times to repeat the message." default:"3"` } func (m *Minimal) EchoOpts(msg string, opts *EchoOpts) string { return m.EchoOptsInline(msg, opts) } ``` The arg type needs to be changed to `opts EchoOpts` for it to work as intended. Giving: ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1809: Undefined type EchoOptsID. ``` --- `Opts` structs cannot be nested: ```go package main import "fmt" type Potato struct{} type PotatoOptions struct { Count int TestingOptions TestingOptions } type TestingOptions struct { Foo string } func (m *Potato) HelloWorld(opts PotatoOptions) string { return fmt.Sprintf("Hello world, I have %d potatoes (%s)", opts.Count, opts.TestingOptions.Foo) } ``` ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1803: Undefined type TestingOptionsID. ```
https://github.com/dagger/dagger/issues/5864
https://github.com/dagger/dagger/pull/5907
db901c8fe4c70cc32336e304492ca37f12b8f389
e8ad5c62275172e3d54ae46447e741ff5d603450
2023-10-10T22:55:05Z
go
2023-10-25T19:38:59Z
cmd/codegen/generator/go/templates/modules.go
if tag, err := tags.Get("doc"); err == nil { argOpts = append(argOpts, Id("Description").Op(":").Lit(tag.Value())) } if tag, err := tags.Get("default"); err == nil { var jsonEnc string if param.Type().String() == "string" { enc, err := json.Marshal(tag.Value()) if err != nil { return nil, fmt.Errorf("failed to marshal default value: %w", err) } jsonEnc = string(enc) } else { jsonEnc = tag.Value() } argOpts = append(argOpts, Id("DefaultValue").Op(":").Id("JSON").Call(Lit(jsonEnc))) } } if len(argOpts) > 0 { argArgs = append(argArgs, Id("FunctionWithArgOpts").Values(argOpts...)) } fnDef = dotLine(fnDef, "WithArg").Call(argArgs...) } } else { argTypeDef, err := ps.goTypeToAPIType(param.Type(), nil) if err != nil { return nil, fmt.Errorf("failed to convert param type: %w", err) } fnDef = dotLine(fnDef, "WithArg").Call(Lit(param.Name()), argTypeDef)
closed
dagger/dagger
https://github.com/dagger/dagger
5,864
Zenith: Fix `Opts` types in Go SDK
From @jedevc: --- Looks like `Opt` types can't be pointers, e.g. something like this doesn't work: ```go type EchoOpts struct { Suffix string `doc:"String to append to the echoed message." default:"..."` Times int `doc:"Number of times to repeat the message." default:"3"` } func (m *Minimal) EchoOpts(msg string, opts *EchoOpts) string { return m.EchoOptsInline(msg, opts) } ``` The arg type needs to be changed to `opts EchoOpts` for it to work as intended. Giving: ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1809: Undefined type EchoOptsID. ``` --- `Opts` structs cannot be nested: ```go package main import "fmt" type Potato struct{} type PotatoOptions struct { Count int TestingOptions TestingOptions } type TestingOptions struct { Foo string } func (m *Potato) HelloWorld(opts PotatoOptions) string { return fmt.Sprintf("Hello world, I have %d potatoes (%s)", opts.Count, opts.TestingOptions.Foo) } ``` ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1803: Undefined type TestingOptionsID. ```
https://github.com/dagger/dagger/issues/5864
https://github.com/dagger/dagger/pull/5907
db901c8fe4c70cc32336e304492ca37f12b8f389
e8ad5c62275172e3d54ae46447e741ff5d603450
2023-10-10T22:55:05Z
go
2023-10-25T19:38:59Z
cmd/codegen/generator/go/templates/modules.go
} } return fnDef, nil } func namedOrDirectStruct(t types.Type) (*types.Struct, bool) { switch x := t.(type) { case *types.Named: return namedOrDirectStruct(x.Underlying()) case *types.Struct: return x, true default: return nil, false } } func (ps *parseState) typeSpecForNamedType(namedType *types.Named) (*ast.TypeSpec, error) { tokenFile := ps.fset.File(namedType.Obj().Pos()) if tokenFile == nil { return nil, fmt.Errorf("no file for %s", namedType.Obj().Name()) } for _, f := range ps.pkg.Syntax { if ps.fset.File(f.Pos()) != tokenFile { continue } for _, decl := range f.Decls { genDecl, ok := decl.(*ast.GenDecl) if !ok { continue } for _, spec := range genDecl.Specs { typeSpec, ok := spec.(*ast.TypeSpec)
closed
dagger/dagger
https://github.com/dagger/dagger
5,864
Zenith: Fix `Opts` types in Go SDK
From @jedevc: --- Looks like `Opt` types can't be pointers, e.g. something like this doesn't work: ```go type EchoOpts struct { Suffix string `doc:"String to append to the echoed message." default:"..."` Times int `doc:"Number of times to repeat the message." default:"3"` } func (m *Minimal) EchoOpts(msg string, opts *EchoOpts) string { return m.EchoOptsInline(msg, opts) } ``` The arg type needs to be changed to `opts EchoOpts` for it to work as intended. Giving: ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1809: Undefined type EchoOptsID. ``` --- `Opts` structs cannot be nested: ```go package main import "fmt" type Potato struct{} type PotatoOptions struct { Count int TestingOptions TestingOptions } type TestingOptions struct { Foo string } func (m *Potato) HelloWorld(opts PotatoOptions) string { return fmt.Sprintf("Hello world, I have %d potatoes (%s)", opts.Count, opts.TestingOptions.Foo) } ``` ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1803: Undefined type TestingOptionsID. ```
https://github.com/dagger/dagger/issues/5864
https://github.com/dagger/dagger/pull/5907
db901c8fe4c70cc32336e304492ca37f12b8f389
e8ad5c62275172e3d54ae46447e741ff5d603450
2023-10-10T22:55:05Z
go
2023-10-25T19:38:59Z
cmd/codegen/generator/go/templates/modules.go
if !ok { continue } if typeSpec.Name.Name == namedType.Obj().Name() { return typeSpec, nil } } } } return nil, fmt.Errorf("no decl for %s", namedType.Obj().Name()) } func (ps *parseState) declForFunc(fnType *types.Func) (*ast.FuncDecl, error) { tokenFile := ps.fset.File(fnType.Pos()) if tokenFile == nil { return nil, fmt.Errorf("no file for %s", fnType.Name()) } for _, f := range ps.pkg.Syntax { if ps.fset.File(f.Pos()) != tokenFile { continue } for _, decl := range f.Decls { fnDecl, ok := decl.(*ast.FuncDecl) if ok && fnDecl.Name.Name == fnType.Name() { return fnDecl, nil } } } return nil, fmt.Errorf("no decl for %s", fnType.Name()) }
closed
dagger/dagger
https://github.com/dagger/dagger
5,864
Zenith: Fix `Opts` types in Go SDK
From @jedevc: --- Looks like `Opt` types can't be pointers, e.g. something like this doesn't work: ```go type EchoOpts struct { Suffix string `doc:"String to append to the echoed message." default:"..."` Times int `doc:"Number of times to repeat the message." default:"3"` } func (m *Minimal) EchoOpts(msg string, opts *EchoOpts) string { return m.EchoOptsInline(msg, opts) } ``` The arg type needs to be changed to `opts EchoOpts` for it to work as intended. Giving: ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1809: Undefined type EchoOptsID. ``` --- `Opts` structs cannot be nested: ```go package main import "fmt" type Potato struct{} type PotatoOptions struct { Count int TestingOptions TestingOptions } type TestingOptions struct { Foo string } func (m *Potato) HelloWorld(opts PotatoOptions) string { return fmt.Sprintf("Hello world, I have %d potatoes (%s)", opts.Count, opts.TestingOptions.Foo) } ``` ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1803: Undefined type TestingOptionsID. ```
https://github.com/dagger/dagger/issues/5864
https://github.com/dagger/dagger/pull/5907
db901c8fe4c70cc32336e304492ca37f12b8f389
e8ad5c62275172e3d54ae46447e741ff5d603450
2023-10-10T22:55:05Z
go
2023-10-25T19:38:59Z
core/integration/module_test.go
package core import ( "context" _ "embed" "errors" "fmt" "os" "path/filepath" "strconv" "strings" "testing" "time" "dagger.io/dagger" "github.com/iancoleman/strcase" "github.com/moby/buildkit/identity" "github.com/stretchr/testify/require" "golang.org/x/sync/errgroup" ) /* TODO: add coverage for * dagger mod use * dagger mod sync * that the codegen of the testdata envs are up to date (or incorporate that into a cli command) * if a dependency changes, then checks should re-run */ func TestModuleGoInit(t *testing.T) {
closed
dagger/dagger
https://github.com/dagger/dagger
5,864
Zenith: Fix `Opts` types in Go SDK
From @jedevc: --- Looks like `Opt` types can't be pointers, e.g. something like this doesn't work: ```go type EchoOpts struct { Suffix string `doc:"String to append to the echoed message." default:"..."` Times int `doc:"Number of times to repeat the message." default:"3"` } func (m *Minimal) EchoOpts(msg string, opts *EchoOpts) string { return m.EchoOptsInline(msg, opts) } ``` The arg type needs to be changed to `opts EchoOpts` for it to work as intended. Giving: ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1809: Undefined type EchoOptsID. ``` --- `Opts` structs cannot be nested: ```go package main import "fmt" type Potato struct{} type PotatoOptions struct { Count int TestingOptions TestingOptions } type TestingOptions struct { Foo string } func (m *Potato) HelloWorld(opts PotatoOptions) string { return fmt.Sprintf("Hello world, I have %d potatoes (%s)", opts.Count, opts.TestingOptions.Foo) } ``` ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1803: Undefined type TestingOptionsID. ```
https://github.com/dagger/dagger/issues/5864
https://github.com/dagger/dagger/pull/5907
db901c8fe4c70cc32336e304492ca37f12b8f389
e8ad5c62275172e3d54ae46447e741ff5d603450
2023-10-10T22:55:05Z
go
2023-10-25T19:38:59Z
core/integration/module_test.go
t.Run("from scratch", func(t *testing.T) { t.Parallel() c, ctx := connect(t) modGen := c.Container().From(golangImage). WithMountedFile(testCLIBinPath, daggerCliFile(t, c)). WithWorkdir("/work"). With(daggerExec("mod", "init", "--name=bare", "--sdk=go")) logGen(ctx, t, modGen.Directory(".")) out, err := modGen. With(daggerQuery(`{bare{myFunction(stringArg:"hello"){stdout}}}`)). Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"bare":{"myFunction":{"stdout":"hello\n"}}}`, out) }) t.Run("kebab-cases Go module name, 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=go")) logGen(ctx, t, modGen.Directory(".")) out, err := modGen. With(daggerQuery(`{myModule{myFunction(stringArg:"hello"){stdout}}}`)). Stdout(ctx)
closed
dagger/dagger
https://github.com/dagger/dagger
5,864
Zenith: Fix `Opts` types in Go SDK
From @jedevc: --- Looks like `Opt` types can't be pointers, e.g. something like this doesn't work: ```go type EchoOpts struct { Suffix string `doc:"String to append to the echoed message." default:"..."` Times int `doc:"Number of times to repeat the message." default:"3"` } func (m *Minimal) EchoOpts(msg string, opts *EchoOpts) string { return m.EchoOptsInline(msg, opts) } ``` The arg type needs to be changed to `opts EchoOpts` for it to work as intended. Giving: ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1809: Undefined type EchoOptsID. ``` --- `Opts` structs cannot be nested: ```go package main import "fmt" type Potato struct{} type PotatoOptions struct { Count int TestingOptions TestingOptions } type TestingOptions struct { Foo string } func (m *Potato) HelloWorld(opts PotatoOptions) string { return fmt.Sprintf("Hello world, I have %d potatoes (%s)", opts.Count, opts.TestingOptions.Foo) } ``` ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1803: Undefined type TestingOptionsID. ```
https://github.com/dagger/dagger/issues/5864
https://github.com/dagger/dagger/pull/5907
db901c8fe4c70cc32336e304492ca37f12b8f389
e8ad5c62275172e3d54ae46447e741ff5d603450
2023-10-10T22:55:05Z
go
2023-10-25T19:38:59Z
core/integration/module_test.go
require.NoError(t, err) require.JSONEq(t, `{"myModule":{"myFunction":{"stdout":"hello\n"}}}`, out) generated, err := modGen.File("go.mod").Contents(ctx) require.NoError(t, err) require.Contains(t, generated, "module my-module") }) t.Run("creates go.mod beneath an existing go.mod if root points beneath it", func(t *testing.T) { t.Parallel() c, ctx := connect(t) modGen := c.Container().From(golangImage). WithMountedFile(testCLIBinPath, daggerCliFile(t, c)). WithWorkdir("/work"). WithNewFile("/work/go.mod", dagger.ContainerWithNewFileOpts{ Contents: "module example.com/test\n", }). WithNewFile("/work/foo.go", dagger.ContainerWithNewFileOpts{ Contents: "package foo\n", }). WithWorkdir("/work/ci"). With(daggerExec("mod", "init", "--name=beneathGoMod", "--sdk=go")) logGen(ctx, t, modGen.Directory(".")) out, err := modGen. With(daggerQuery(`{beneathGoMod{myFunction(stringArg:"hello"){stdout}}}`)). Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"beneathGoMod":{"myFunction":{"stdout":"hello\n"}}}`, out) t.Run("names Go module after Dagger module", func(t *testing.T) { generated, err := modGen.File("go.mod").Contents(ctx) require.NoError(t, err) require.Contains(t, generated, "module beneath-go-mod")
closed
dagger/dagger
https://github.com/dagger/dagger
5,864
Zenith: Fix `Opts` types in Go SDK
From @jedevc: --- Looks like `Opt` types can't be pointers, e.g. something like this doesn't work: ```go type EchoOpts struct { Suffix string `doc:"String to append to the echoed message." default:"..."` Times int `doc:"Number of times to repeat the message." default:"3"` } func (m *Minimal) EchoOpts(msg string, opts *EchoOpts) string { return m.EchoOptsInline(msg, opts) } ``` The arg type needs to be changed to `opts EchoOpts` for it to work as intended. Giving: ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1809: Undefined type EchoOptsID. ``` --- `Opts` structs cannot be nested: ```go package main import "fmt" type Potato struct{} type PotatoOptions struct { Count int TestingOptions TestingOptions } type TestingOptions struct { Foo string } func (m *Potato) HelloWorld(opts PotatoOptions) string { return fmt.Sprintf("Hello world, I have %d potatoes (%s)", opts.Count, opts.TestingOptions.Foo) } ``` ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1803: Undefined type TestingOptionsID. ```
https://github.com/dagger/dagger/issues/5864
https://github.com/dagger/dagger/pull/5907
db901c8fe4c70cc32336e304492ca37f12b8f389
e8ad5c62275172e3d54ae46447e741ff5d603450
2023-10-10T22:55:05Z
go
2023-10-25T19:38:59Z
core/integration/module_test.go
}) }) t.Run("respects existing go.mod", func(t *testing.T) { t.Parallel() c, ctx := connect(t) modGen := c.Container().From(golangImage). WithMountedFile(testCLIBinPath, daggerCliFile(t, c)). WithWorkdir("/work"). WithExec([]string{"go", "mod", "init", "example.com/test"}). With(daggerExec("mod", "init", "--name=hasGoMod", "--sdk=go")) logGen(ctx, t, modGen.Directory(".")) out, err := modGen. With(daggerQuery(`{hasGoMod{myFunction(stringArg:"hello"){stdout}}}`)). Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"hasGoMod":{"myFunction":{"stdout":"hello\n"}}}`, out) t.Run("preserves module name", func(t *testing.T) { generated, err := modGen.File("go.mod").Contents(ctx) require.NoError(t, err) require.Contains(t, generated, "module example.com/test") }) }) t.Run("respects parent go.mod if root points to it", func(t *testing.T) { t.Parallel() c, ctx := connect(t) modGen := c.Container().From(golangImage). WithMountedFile(testCLIBinPath, daggerCliFile(t, c)). WithWorkdir("/work"). WithExec([]string{"go", "mod", "init", "example.com/test"}). WithNewFile("/work/foo.go", dagger.ContainerWithNewFileOpts{
closed
dagger/dagger
https://github.com/dagger/dagger
5,864
Zenith: Fix `Opts` types in Go SDK
From @jedevc: --- Looks like `Opt` types can't be pointers, e.g. something like this doesn't work: ```go type EchoOpts struct { Suffix string `doc:"String to append to the echoed message." default:"..."` Times int `doc:"Number of times to repeat the message." default:"3"` } func (m *Minimal) EchoOpts(msg string, opts *EchoOpts) string { return m.EchoOptsInline(msg, opts) } ``` The arg type needs to be changed to `opts EchoOpts` for it to work as intended. Giving: ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1809: Undefined type EchoOptsID. ``` --- `Opts` structs cannot be nested: ```go package main import "fmt" type Potato struct{} type PotatoOptions struct { Count int TestingOptions TestingOptions } type TestingOptions struct { Foo string } func (m *Potato) HelloWorld(opts PotatoOptions) string { return fmt.Sprintf("Hello world, I have %d potatoes (%s)", opts.Count, opts.TestingOptions.Foo) } ``` ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1803: Undefined type TestingOptionsID. ```
https://github.com/dagger/dagger/issues/5864
https://github.com/dagger/dagger/pull/5907
db901c8fe4c70cc32336e304492ca37f12b8f389
e8ad5c62275172e3d54ae46447e741ff5d603450
2023-10-10T22:55:05Z
go
2023-10-25T19:38:59Z
core/integration/module_test.go
Contents: "package foo\n", }). WithWorkdir("/work/child"). With(daggerExec("mod", "init", "--name=child", "--sdk=go", "--root=..")). WithNewFile("/work/child/main.go", dagger.ContainerWithNewFileOpts{ Contents: ` package main import "os" type Child struct{} func (m *Child) Root() *Directory { wd, err := os.Getwd() if err != nil { panic(err) } return dag.Host().Directory(wd+"/..") } `, }) generated := modGen. With(daggerExec("mod", "sync")). Directory(".") logGen(ctx, t, generated) out, err := modGen. With(daggerQuery(`{child{root{entries}}}`)). Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"child":{"root":{"entries":["child","foo.go","go.mod","go.sum"]}}}`, out) childEntries, err := generated.Entries(ctx) require.NoError(t, err)
closed
dagger/dagger
https://github.com/dagger/dagger
5,864
Zenith: Fix `Opts` types in Go SDK
From @jedevc: --- Looks like `Opt` types can't be pointers, e.g. something like this doesn't work: ```go type EchoOpts struct { Suffix string `doc:"String to append to the echoed message." default:"..."` Times int `doc:"Number of times to repeat the message." default:"3"` } func (m *Minimal) EchoOpts(msg string, opts *EchoOpts) string { return m.EchoOptsInline(msg, opts) } ``` The arg type needs to be changed to `opts EchoOpts` for it to work as intended. Giving: ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1809: Undefined type EchoOptsID. ``` --- `Opts` structs cannot be nested: ```go package main import "fmt" type Potato struct{} type PotatoOptions struct { Count int TestingOptions TestingOptions } type TestingOptions struct { Foo string } func (m *Potato) HelloWorld(opts PotatoOptions) string { return fmt.Sprintf("Hello world, I have %d potatoes (%s)", opts.Count, opts.TestingOptions.Foo) } ``` ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1803: Undefined type TestingOptionsID. ```
https://github.com/dagger/dagger/issues/5864
https://github.com/dagger/dagger/pull/5907
db901c8fe4c70cc32336e304492ca37f12b8f389
e8ad5c62275172e3d54ae46447e741ff5d603450
2023-10-10T22:55:05Z
go
2023-10-25T19:38:59Z
core/integration/module_test.go
require.NotContains(t, childEntries, "go.mod") t.Run("preserves parent module name", func(t *testing.T) { generated, err := modGen.File("/work/go.mod").Contents(ctx) require.NoError(t, err) require.Contains(t, generated, "module example.com/test") }) }) t.Run("respects existing go.mod even if root points to parent that has go.mod", func(t *testing.T) { t.Parallel() c, ctx := connect(t) modGen := c.Container().From(golangImage). WithMountedFile(testCLIBinPath, daggerCliFile(t, c)). WithWorkdir("/work"). WithExec([]string{"go", "mod", "init", "example.com/test"}). WithNewFile("/work/foo.go", dagger.ContainerWithNewFileOpts{ Contents: "package foo\n", }). WithWorkdir("/work/child"). WithExec([]string{"go", "mod", "init", "my-mod"}). With(daggerExec("mod", "init", "--name=child", "--sdk=go", "--root=..")). WithNewFile("/work/child/main.go", dagger.ContainerWithNewFileOpts{ Contents: ` package main import "os" type Child struct{} func (m *Child) Root() *Directory { wd, err := os.Getwd() if err != nil { panic(err) }
closed
dagger/dagger
https://github.com/dagger/dagger
5,864
Zenith: Fix `Opts` types in Go SDK
From @jedevc: --- Looks like `Opt` types can't be pointers, e.g. something like this doesn't work: ```go type EchoOpts struct { Suffix string `doc:"String to append to the echoed message." default:"..."` Times int `doc:"Number of times to repeat the message." default:"3"` } func (m *Minimal) EchoOpts(msg string, opts *EchoOpts) string { return m.EchoOptsInline(msg, opts) } ``` The arg type needs to be changed to `opts EchoOpts` for it to work as intended. Giving: ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1809: Undefined type EchoOptsID. ``` --- `Opts` structs cannot be nested: ```go package main import "fmt" type Potato struct{} type PotatoOptions struct { Count int TestingOptions TestingOptions } type TestingOptions struct { Foo string } func (m *Potato) HelloWorld(opts PotatoOptions) string { return fmt.Sprintf("Hello world, I have %d potatoes (%s)", opts.Count, opts.TestingOptions.Foo) } ``` ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1803: Undefined type TestingOptionsID. ```
https://github.com/dagger/dagger/issues/5864
https://github.com/dagger/dagger/pull/5907
db901c8fe4c70cc32336e304492ca37f12b8f389
e8ad5c62275172e3d54ae46447e741ff5d603450
2023-10-10T22:55:05Z
go
2023-10-25T19:38:59Z
core/integration/module_test.go
return dag.Host().Directory(wd+"/..") } `, }) generated := modGen. With(daggerExec("mod", "sync")). Directory(".") logGen(ctx, t, generated) out, err := modGen. With(daggerQuery(`{child{root{entries}}}`)). Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"child":{"root":{"entries":["child","foo.go","go.mod"]}}}`, out) childEntries, err := generated.Entries(ctx) require.NoError(t, err) require.Contains(t, childEntries, "go.mod") require.Contains(t, childEntries, "go.sum") }) t.Run("respects existing main.go", func(t *testing.T) { t.Parallel() c, ctx := connect(t) modGen := c.Container().From(golangImage). WithMountedFile(testCLIBinPath, daggerCliFile(t, c)). WithWorkdir("/work"). WithNewFile("/work/main.go", dagger.ContainerWithNewFileOpts{ Contents: ` package main type HasMainGo struct {}
closed
dagger/dagger
https://github.com/dagger/dagger
5,864
Zenith: Fix `Opts` types in Go SDK
From @jedevc: --- Looks like `Opt` types can't be pointers, e.g. something like this doesn't work: ```go type EchoOpts struct { Suffix string `doc:"String to append to the echoed message." default:"..."` Times int `doc:"Number of times to repeat the message." default:"3"` } func (m *Minimal) EchoOpts(msg string, opts *EchoOpts) string { return m.EchoOptsInline(msg, opts) } ``` The arg type needs to be changed to `opts EchoOpts` for it to work as intended. Giving: ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1809: Undefined type EchoOptsID. ``` --- `Opts` structs cannot be nested: ```go package main import "fmt" type Potato struct{} type PotatoOptions struct { Count int TestingOptions TestingOptions } type TestingOptions struct { Foo string } func (m *Potato) HelloWorld(opts PotatoOptions) string { return fmt.Sprintf("Hello world, I have %d potatoes (%s)", opts.Count, opts.TestingOptions.Foo) } ``` ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1803: Undefined type TestingOptionsID. ```
https://github.com/dagger/dagger/issues/5864
https://github.com/dagger/dagger/pull/5907
db901c8fe4c70cc32336e304492ca37f12b8f389
e8ad5c62275172e3d54ae46447e741ff5d603450
2023-10-10T22:55:05Z
go
2023-10-25T19:38:59Z
core/integration/module_test.go
func (m *HasMainGo) Hello() string { return "Hello, world!" } `, }). With(daggerExec("mod", "init", "--name=hasMainGo", "--sdk=go")) logGen(ctx, t, modGen.Directory(".")) out, err := modGen. With(daggerQuery(`{hasMainGo{hello}}`)). Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"hasMainGo":{"hello":"Hello, world!"}}`, out) }) t.Run("respects existing main.go even if it uses types not generated yet", func(t *testing.T) { t.Parallel() c, ctx := connect(t) modGen := c.Container().From(golangImage). WithMountedFile(testCLIBinPath, daggerCliFile(t, c)). WithWorkdir("/work"). WithNewFile("/work/main.go", dagger.ContainerWithNewFileOpts{ Contents: ` package main type HasDaggerTypes struct {} func (m *HasDaggerTypes) Hello() *Container { return dag.Container(). From("` + alpineImage + `"). WithExec([]string{"echo", "Hello, world!"}) } `, }). With(daggerExec("mod", "init", "--name=hasDaggerTypes", "--sdk=go")) logGen(ctx, t, modGen.Directory("."))
closed
dagger/dagger
https://github.com/dagger/dagger
5,864
Zenith: Fix `Opts` types in Go SDK
From @jedevc: --- Looks like `Opt` types can't be pointers, e.g. something like this doesn't work: ```go type EchoOpts struct { Suffix string `doc:"String to append to the echoed message." default:"..."` Times int `doc:"Number of times to repeat the message." default:"3"` } func (m *Minimal) EchoOpts(msg string, opts *EchoOpts) string { return m.EchoOptsInline(msg, opts) } ``` The arg type needs to be changed to `opts EchoOpts` for it to work as intended. Giving: ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1809: Undefined type EchoOptsID. ``` --- `Opts` structs cannot be nested: ```go package main import "fmt" type Potato struct{} type PotatoOptions struct { Count int TestingOptions TestingOptions } type TestingOptions struct { Foo string } func (m *Potato) HelloWorld(opts PotatoOptions) string { return fmt.Sprintf("Hello world, I have %d potatoes (%s)", opts.Count, opts.TestingOptions.Foo) } ``` ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1803: Undefined type TestingOptionsID. ```
https://github.com/dagger/dagger/issues/5864
https://github.com/dagger/dagger/pull/5907
db901c8fe4c70cc32336e304492ca37f12b8f389
e8ad5c62275172e3d54ae46447e741ff5d603450
2023-10-10T22:55:05Z
go
2023-10-25T19:38:59Z
core/integration/module_test.go
out, err := modGen. With(daggerQuery(`{hasDaggerTypes{hello{stdout}}}`)). Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"hasDaggerTypes":{"hello":{"stdout":"Hello, world!\n"}}}`, out) }) t.Run("respects existing package without creating main.go", func(t *testing.T) { t.Parallel() c, ctx := connect(t) modGen := c.Container().From(golangImage). WithMountedFile(testCLIBinPath, daggerCliFile(t, c)). WithWorkdir("/work"). WithNewFile("/work/notmain.go", dagger.ContainerWithNewFileOpts{ Contents: `package main type HasNotMainGo struct {} func (m *HasNotMainGo) Hello() string { return "Hello, world!" } `, }). With(daggerExec("mod", "init", "--name=hasNotMainGo", "--sdk=go")) logGen(ctx, t, modGen.Directory(".")) out, err := modGen. With(daggerQuery(`{hasNotMainGo{hello}}`)). Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"hasNotMainGo":{"hello":"Hello, world!"}}`, out) }) } func TestModuleGit(t *testing.T) { t.Parallel() type testCase struct {
closed
dagger/dagger
https://github.com/dagger/dagger
5,864
Zenith: Fix `Opts` types in Go SDK
From @jedevc: --- Looks like `Opt` types can't be pointers, e.g. something like this doesn't work: ```go type EchoOpts struct { Suffix string `doc:"String to append to the echoed message." default:"..."` Times int `doc:"Number of times to repeat the message." default:"3"` } func (m *Minimal) EchoOpts(msg string, opts *EchoOpts) string { return m.EchoOptsInline(msg, opts) } ``` The arg type needs to be changed to `opts EchoOpts` for it to work as intended. Giving: ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1809: Undefined type EchoOptsID. ``` --- `Opts` structs cannot be nested: ```go package main import "fmt" type Potato struct{} type PotatoOptions struct { Count int TestingOptions TestingOptions } type TestingOptions struct { Foo string } func (m *Potato) HelloWorld(opts PotatoOptions) string { return fmt.Sprintf("Hello world, I have %d potatoes (%s)", opts.Count, opts.TestingOptions.Foo) } ``` ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1803: Undefined type TestingOptionsID. ```
https://github.com/dagger/dagger/issues/5864
https://github.com/dagger/dagger/pull/5907
db901c8fe4c70cc32336e304492ca37f12b8f389
e8ad5c62275172e3d54ae46447e741ff5d603450
2023-10-10T22:55:05Z
go
2023-10-25T19:38:59Z
core/integration/module_test.go
sdk string gitignores []string gitattributes string } for _, tc := range []testCase{ { sdk: "go", gitignores: []string{ "/dagger.gen.go\n", "/querybuilder/\n", }, }, { sdk: "python",
closed
dagger/dagger
https://github.com/dagger/dagger
5,864
Zenith: Fix `Opts` types in Go SDK
From @jedevc: --- Looks like `Opt` types can't be pointers, e.g. something like this doesn't work: ```go type EchoOpts struct { Suffix string `doc:"String to append to the echoed message." default:"..."` Times int `doc:"Number of times to repeat the message." default:"3"` } func (m *Minimal) EchoOpts(msg string, opts *EchoOpts) string { return m.EchoOptsInline(msg, opts) } ``` The arg type needs to be changed to `opts EchoOpts` for it to work as intended. Giving: ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1809: Undefined type EchoOptsID. ``` --- `Opts` structs cannot be nested: ```go package main import "fmt" type Potato struct{} type PotatoOptions struct { Count int TestingOptions TestingOptions } type TestingOptions struct { Foo string } func (m *Potato) HelloWorld(opts PotatoOptions) string { return fmt.Sprintf("Hello world, I have %d potatoes (%s)", opts.Count, opts.TestingOptions.Foo) } ``` ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1803: Undefined type TestingOptionsID. ```
https://github.com/dagger/dagger/issues/5864
https://github.com/dagger/dagger/pull/5907
db901c8fe4c70cc32336e304492ca37f12b8f389
e8ad5c62275172e3d54ae46447e741ff5d603450
2023-10-10T22:55:05Z
go
2023-10-25T19:38:59Z
core/integration/module_test.go
gitignores: []string{ "/sdk\n", }, }, } { tc := tc t.Run(fmt.Sprintf("module %s git", tc.sdk), func(t *testing.T) { t.Parallel() c, ctx := connect(t) modGen := goGitBase(t, c). With(daggerExec("mod", "init", "--name=bare", "--sdk="+tc.sdk)) if tc.sdk == "go" { logGen(ctx, t, modGen.Directory(".")) } out, err := modGen. With(daggerQuery(`{bare{myFunction(stringArg:"hello"){stdout}}}`)). Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"bare":{"myFunction":{"stdout":"hello\n"}}}`, out) t.Run("configures .gitignore", func(t *testing.T) { ignore, err := modGen.File(".gitignore").Contents(ctx) require.NoError(t, err) for _, gitignore := range tc.gitignores { require.Contains(t, ignore, gitignore) } }) }) } } func TestModuleGoGitRemovesIgnored(t *testing.T) {
closed
dagger/dagger
https://github.com/dagger/dagger
5,864
Zenith: Fix `Opts` types in Go SDK
From @jedevc: --- Looks like `Opt` types can't be pointers, e.g. something like this doesn't work: ```go type EchoOpts struct { Suffix string `doc:"String to append to the echoed message." default:"..."` Times int `doc:"Number of times to repeat the message." default:"3"` } func (m *Minimal) EchoOpts(msg string, opts *EchoOpts) string { return m.EchoOptsInline(msg, opts) } ``` The arg type needs to be changed to `opts EchoOpts` for it to work as intended. Giving: ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1809: Undefined type EchoOptsID. ``` --- `Opts` structs cannot be nested: ```go package main import "fmt" type Potato struct{} type PotatoOptions struct { Count int TestingOptions TestingOptions } type TestingOptions struct { Foo string } func (m *Potato) HelloWorld(opts PotatoOptions) string { return fmt.Sprintf("Hello world, I have %d potatoes (%s)", opts.Count, opts.TestingOptions.Foo) } ``` ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1803: Undefined type TestingOptionsID. ```
https://github.com/dagger/dagger/issues/5864
https://github.com/dagger/dagger/pull/5907
db901c8fe4c70cc32336e304492ca37f12b8f389
e8ad5c62275172e3d54ae46447e741ff5d603450
2023-10-10T22:55:05Z
go
2023-10-25T19:38:59Z
core/integration/module_test.go
t.Parallel() c, ctx := connect(t) committedModGen := goGitBase(t, c). With(daggerExec("mod", "init", "--name=bare", "--sdk=go")). WithExec([]string{"rm", ".gitignore"}). WithExec([]string{"mkdir", "./internal"}). WithExec([]string{"cp", "-a", "./querybuilder", "./internal/querybuilder"}). WithExec([]string{"git", "add", "."}). WithExec([]string{"git", "commit", "-m", "init with generated files"}) changedAfterSync, err := committedModGen. With(daggerExec("mod", "sync")). WithExec([]string{"git", "diff"}). WithExec([]string{"git", "status", "--short"}). Stdout(ctx) require.NoError(t, err) t.Logf("changed after sync:\n%s", changedAfterSync) require.Contains(t, changedAfterSync, "D dagger.gen.go\n") require.Contains(t, changedAfterSync, "D querybuilder/marshal.go\n") require.Contains(t, changedAfterSync, "D querybuilder/querybuilder.go\n") require.Contains(t, changedAfterSync, "D internal/querybuilder/marshal.go\n") require.Contains(t, changedAfterSync, "D internal/querybuilder/querybuilder.go\n") } func TestModulePythonGitRemovesIgnored(t *testing.T) {
closed
dagger/dagger
https://github.com/dagger/dagger
5,864
Zenith: Fix `Opts` types in Go SDK
From @jedevc: --- Looks like `Opt` types can't be pointers, e.g. something like this doesn't work: ```go type EchoOpts struct { Suffix string `doc:"String to append to the echoed message." default:"..."` Times int `doc:"Number of times to repeat the message." default:"3"` } func (m *Minimal) EchoOpts(msg string, opts *EchoOpts) string { return m.EchoOptsInline(msg, opts) } ``` The arg type needs to be changed to `opts EchoOpts` for it to work as intended. Giving: ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1809: Undefined type EchoOptsID. ``` --- `Opts` structs cannot be nested: ```go package main import "fmt" type Potato struct{} type PotatoOptions struct { Count int TestingOptions TestingOptions } type TestingOptions struct { Foo string } func (m *Potato) HelloWorld(opts PotatoOptions) string { return fmt.Sprintf("Hello world, I have %d potatoes (%s)", opts.Count, opts.TestingOptions.Foo) } ``` ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1803: Undefined type TestingOptionsID. ```
https://github.com/dagger/dagger/issues/5864
https://github.com/dagger/dagger/pull/5907
db901c8fe4c70cc32336e304492ca37f12b8f389
e8ad5c62275172e3d54ae46447e741ff5d603450
2023-10-10T22:55:05Z
go
2023-10-25T19:38:59Z
core/integration/module_test.go
t.Parallel() c, ctx := connect(t) committedModGen := goGitBase(t, c). With(daggerExec("mod", "init", "--name=bare", "--sdk=python")). WithExec([]string{"rm", ".gitignore"}). WithExec([]string{"git", "add", "."}). WithExec([]string{"git", "commit", "-m", "init with generated files"}) changedAfterSync, err := committedModGen. With(daggerExec("mod", "sync")). WithExec([]string{"git", "diff"}). WithExec([]string{"git", "status", "--short"}). Stdout(ctx) require.NoError(t, err) t.Logf("changed after sync:\n%s", changedAfterSync) require.Contains(t, changedAfterSync, "D sdk/pyproject.toml\n") require.Contains(t, changedAfterSync, "D sdk/src/dagger/__init__.py\n") } var goSignatures string func TestModuleGoSignatures(t *testing.T) {
closed
dagger/dagger
https://github.com/dagger/dagger
5,864
Zenith: Fix `Opts` types in Go SDK
From @jedevc: --- Looks like `Opt` types can't be pointers, e.g. something like this doesn't work: ```go type EchoOpts struct { Suffix string `doc:"String to append to the echoed message." default:"..."` Times int `doc:"Number of times to repeat the message." default:"3"` } func (m *Minimal) EchoOpts(msg string, opts *EchoOpts) string { return m.EchoOptsInline(msg, opts) } ``` The arg type needs to be changed to `opts EchoOpts` for it to work as intended. Giving: ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1809: Undefined type EchoOptsID. ``` --- `Opts` structs cannot be nested: ```go package main import "fmt" type Potato struct{} type PotatoOptions struct { Count int TestingOptions TestingOptions } type TestingOptions struct { Foo string } func (m *Potato) HelloWorld(opts PotatoOptions) string { return fmt.Sprintf("Hello world, I have %d potatoes (%s)", opts.Count, opts.TestingOptions.Foo) } ``` ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1803: Undefined type TestingOptionsID. ```
https://github.com/dagger/dagger/issues/5864
https://github.com/dagger/dagger/pull/5907
db901c8fe4c70cc32336e304492ca37f12b8f389
e8ad5c62275172e3d54ae46447e741ff5d603450
2023-10-10T22:55:05Z
go
2023-10-25T19:38:59Z
core/integration/module_test.go
t.Parallel() c, ctx := connect(t) modGen := c.Container().From(golangImage). WithMountedFile(testCLIBinPath, daggerCliFile(t, c)). WithWorkdir("/work"). With(daggerExec("mod", "init", "--name=minimal", "--sdk=go")). WithNewFile("main.go", dagger.ContainerWithNewFileOpts{ Contents: goSignatures, }) logGen(ctx, t, modGen.Directory(".")) t.Run("func Hello() string", func(t *testing.T) { t.Parallel() out, err := modGen.With(daggerQuery(`{minimal{hello}}`)).Stdout(ctx)
closed
dagger/dagger
https://github.com/dagger/dagger
5,864
Zenith: Fix `Opts` types in Go SDK
From @jedevc: --- Looks like `Opt` types can't be pointers, e.g. something like this doesn't work: ```go type EchoOpts struct { Suffix string `doc:"String to append to the echoed message." default:"..."` Times int `doc:"Number of times to repeat the message." default:"3"` } func (m *Minimal) EchoOpts(msg string, opts *EchoOpts) string { return m.EchoOptsInline(msg, opts) } ``` The arg type needs to be changed to `opts EchoOpts` for it to work as intended. Giving: ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1809: Undefined type EchoOptsID. ``` --- `Opts` structs cannot be nested: ```go package main import "fmt" type Potato struct{} type PotatoOptions struct { Count int TestingOptions TestingOptions } type TestingOptions struct { Foo string } func (m *Potato) HelloWorld(opts PotatoOptions) string { return fmt.Sprintf("Hello world, I have %d potatoes (%s)", opts.Count, opts.TestingOptions.Foo) } ``` ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1803: Undefined type TestingOptionsID. ```
https://github.com/dagger/dagger/issues/5864
https://github.com/dagger/dagger/pull/5907
db901c8fe4c70cc32336e304492ca37f12b8f389
e8ad5c62275172e3d54ae46447e741ff5d603450
2023-10-10T22:55:05Z
go
2023-10-25T19:38:59Z
core/integration/module_test.go
require.NoError(t, err) require.JSONEq(t, `{"minimal":{"hello":"hello"}}`, out) }) t.Run("func Echo(string) string", func(t *testing.T) { t.Parallel() out, err := modGen.With(daggerQuery(`{minimal{echo(msg: "hello")}}`)).Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"minimal":{"echo":"hello...hello...hello..."}}`, out) }) t.Run("func HelloContext(context.Context) string", func(t *testing.T) { t.Parallel() out, err := modGen.With(daggerQuery(`{minimal{helloContext}}`)).Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"minimal":{"helloContext":"hello context"}}`, out) }) t.Run("func EchoContext(context.Context, string) string", func(t *testing.T) { t.Parallel() out, err := modGen.With(daggerQuery(`{minimal{echoContext(msg: "hello")}}`)).Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"minimal":{"echoContext":"ctx.hello...ctx.hello...ctx.hello..."}}`, out) }) t.Run("func HelloStringError() (string, error)", func(t *testing.T) { t.Parallel() out, err := modGen.With(daggerQuery(`{minimal{helloStringError}}`)).Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"minimal":{"helloStringError":"hello i worked"}}`, out) }) t.Run("func HelloVoid()", func(t *testing.T) { t.Parallel() out, err := modGen.With(daggerQuery(`{minimal{helloVoid}}`)).Stdout(ctx)
closed
dagger/dagger
https://github.com/dagger/dagger
5,864
Zenith: Fix `Opts` types in Go SDK
From @jedevc: --- Looks like `Opt` types can't be pointers, e.g. something like this doesn't work: ```go type EchoOpts struct { Suffix string `doc:"String to append to the echoed message." default:"..."` Times int `doc:"Number of times to repeat the message." default:"3"` } func (m *Minimal) EchoOpts(msg string, opts *EchoOpts) string { return m.EchoOptsInline(msg, opts) } ``` The arg type needs to be changed to `opts EchoOpts` for it to work as intended. Giving: ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1809: Undefined type EchoOptsID. ``` --- `Opts` structs cannot be nested: ```go package main import "fmt" type Potato struct{} type PotatoOptions struct { Count int TestingOptions TestingOptions } type TestingOptions struct { Foo string } func (m *Potato) HelloWorld(opts PotatoOptions) string { return fmt.Sprintf("Hello world, I have %d potatoes (%s)", opts.Count, opts.TestingOptions.Foo) } ``` ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1803: Undefined type TestingOptionsID. ```
https://github.com/dagger/dagger/issues/5864
https://github.com/dagger/dagger/pull/5907
db901c8fe4c70cc32336e304492ca37f12b8f389
e8ad5c62275172e3d54ae46447e741ff5d603450
2023-10-10T22:55:05Z
go
2023-10-25T19:38:59Z
core/integration/module_test.go
require.NoError(t, err) require.JSONEq(t, `{"minimal":{"helloVoid":null}}`, out) }) t.Run("func HelloVoidError() error", func(t *testing.T) { t.Parallel() out, err := modGen.With(daggerQuery(`{minimal{helloVoidError}}`)).Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"minimal":{"helloVoidError":null}}`, out) }) t.Run("func EchoOpts(string, Opts) error", func(t *testing.T) { t.Parallel() out, err := modGen.With(daggerQuery(`{minimal{echoOpts(msg: "hi")}}`)).Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"minimal":{"echoOpts":"hi...hi...hi..."}}`, out) out, err = modGen.With(daggerQuery(`{minimal{echoOpts(msg: "hi", suffix: "!", times: 2)}}`)).Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"minimal":{"echoOpts":"hi!hi!"}}`, out) }) t.Run("func EchoOptsInline(string, struct{Suffix string, Times int}) error", func(t *testing.T) { t.Parallel() out, err := modGen.With(daggerQuery(`{minimal{echoOptsInline(msg: "hi")}}`)).Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"minimal":{"echoOptsInline":"hi...hi...hi..."}}`, out) out, err = modGen.With(daggerQuery(`{minimal{echoOptsInline(msg: "hi", suffix: "!", times: 2)}}`)).Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"minimal":{"echoOptsInline":"hi!hi!"}}`, out) }) } var goExtend string func TestModuleGoExtendCore(t *testing.T) {
closed
dagger/dagger
https://github.com/dagger/dagger
5,864
Zenith: Fix `Opts` types in Go SDK
From @jedevc: --- Looks like `Opt` types can't be pointers, e.g. something like this doesn't work: ```go type EchoOpts struct { Suffix string `doc:"String to append to the echoed message." default:"..."` Times int `doc:"Number of times to repeat the message." default:"3"` } func (m *Minimal) EchoOpts(msg string, opts *EchoOpts) string { return m.EchoOptsInline(msg, opts) } ``` The arg type needs to be changed to `opts EchoOpts` for it to work as intended. Giving: ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1809: Undefined type EchoOptsID. ``` --- `Opts` structs cannot be nested: ```go package main import "fmt" type Potato struct{} type PotatoOptions struct { Count int TestingOptions TestingOptions } type TestingOptions struct { Foo string } func (m *Potato) HelloWorld(opts PotatoOptions) string { return fmt.Sprintf("Hello world, I have %d potatoes (%s)", opts.Count, opts.TestingOptions.Foo) } ``` ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1803: Undefined type TestingOptionsID. ```
https://github.com/dagger/dagger/issues/5864
https://github.com/dagger/dagger/pull/5907
db901c8fe4c70cc32336e304492ca37f12b8f389
e8ad5c62275172e3d54ae46447e741ff5d603450
2023-10-10T22:55:05Z
go
2023-10-25T19:38:59Z
core/integration/module_test.go
t.Parallel() var logs safeBuffer c, ctx := connect(t, dagger.WithLogOutput(&logs)) _, err := c.Container().From(golangImage). WithMountedFile(testCLIBinPath, daggerCliFile(t, c)). WithWorkdir("/work"). With(daggerExec("mod", "init", "--name=test", "--sdk=go")). WithNewFile("main.go", dagger.ContainerWithNewFileOpts{ Contents: goExtend, }). With(daggerExec("mod", "sync")). Sync(ctx) require.Error(t, err) require.NoError(t, c.Close()) require.Contains(t, logs.String(), "cannot define methods on objects from outside this module") } var customTypes string func TestModuleGoCustomTypes(t *testing.T) {
closed
dagger/dagger
https://github.com/dagger/dagger
5,864
Zenith: Fix `Opts` types in Go SDK
From @jedevc: --- Looks like `Opt` types can't be pointers, e.g. something like this doesn't work: ```go type EchoOpts struct { Suffix string `doc:"String to append to the echoed message." default:"..."` Times int `doc:"Number of times to repeat the message." default:"3"` } func (m *Minimal) EchoOpts(msg string, opts *EchoOpts) string { return m.EchoOptsInline(msg, opts) } ``` The arg type needs to be changed to `opts EchoOpts` for it to work as intended. Giving: ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1809: Undefined type EchoOptsID. ``` --- `Opts` structs cannot be nested: ```go package main import "fmt" type Potato struct{} type PotatoOptions struct { Count int TestingOptions TestingOptions } type TestingOptions struct { Foo string } func (m *Potato) HelloWorld(opts PotatoOptions) string { return fmt.Sprintf("Hello world, I have %d potatoes (%s)", opts.Count, opts.TestingOptions.Foo) } ``` ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1803: Undefined type TestingOptionsID. ```
https://github.com/dagger/dagger/issues/5864
https://github.com/dagger/dagger/pull/5907
db901c8fe4c70cc32336e304492ca37f12b8f389
e8ad5c62275172e3d54ae46447e741ff5d603450
2023-10-10T22:55:05Z
go
2023-10-25T19:38:59Z
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=test", "--sdk=go")). WithNewFile("main.go", dagger.ContainerWithNewFileOpts{ Contents: customTypes, }) logGen(ctx, t, modGen.Directory(".")) out, err := modGen.With(daggerQuery(`{test{repeater(msg:"echo!", times: 3){render}}}`)).Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"test":{"repeater":{"render":"echo!echo!echo!"}}}`, out) } func TestModuleGoReturnTypeDetection(t *testing.T) {
closed
dagger/dagger
https://github.com/dagger/dagger
5,864
Zenith: Fix `Opts` types in Go SDK
From @jedevc: --- Looks like `Opt` types can't be pointers, e.g. something like this doesn't work: ```go type EchoOpts struct { Suffix string `doc:"String to append to the echoed message." default:"..."` Times int `doc:"Number of times to repeat the message." default:"3"` } func (m *Minimal) EchoOpts(msg string, opts *EchoOpts) string { return m.EchoOptsInline(msg, opts) } ``` The arg type needs to be changed to `opts EchoOpts` for it to work as intended. Giving: ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1809: Undefined type EchoOptsID. ``` --- `Opts` structs cannot be nested: ```go package main import "fmt" type Potato struct{} type PotatoOptions struct { Count int TestingOptions TestingOptions } type TestingOptions struct { Foo string } func (m *Potato) HelloWorld(opts PotatoOptions) string { return fmt.Sprintf("Hello world, I have %d potatoes (%s)", opts.Count, opts.TestingOptions.Foo) } ``` ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1803: Undefined type TestingOptionsID. ```
https://github.com/dagger/dagger/issues/5864
https://github.com/dagger/dagger/pull/5907
db901c8fe4c70cc32336e304492ca37f12b8f389
e8ad5c62275172e3d54ae46447e741ff5d603450
2023-10-10T22:55:05Z
go
2023-10-25T19:38:59Z
core/integration/module_test.go
t.Parallel() c, ctx := connect(t) modGen := c.Container().From(golangImage). WithMountedFile(testCLIBinPath, daggerCliFile(t, c)). WithWorkdir("/work"). With(daggerExec("mod", "init", "--name=foo", "--sdk=go")). WithNewFile("main.go", dagger.ContainerWithNewFileOpts{ Contents: `package main type Foo struct {} type X struct { Message string ` + "`json:\"message\"`" + ` } func (m *Foo) MyFunction() X { return X{Message: "foo"} } `, }) logGen(ctx, t, modGen.Directory(".")) out, err := modGen.With(daggerQuery(`{foo{myFunction{message}}}`)).Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"foo":{"myFunction":{"message":"foo"}}}`, out) } var useInner string var useOuter string func TestModuleGoUseLocal(t *testing.T) {
closed
dagger/dagger
https://github.com/dagger/dagger
5,864
Zenith: Fix `Opts` types in Go SDK
From @jedevc: --- Looks like `Opt` types can't be pointers, e.g. something like this doesn't work: ```go type EchoOpts struct { Suffix string `doc:"String to append to the echoed message." default:"..."` Times int `doc:"Number of times to repeat the message." default:"3"` } func (m *Minimal) EchoOpts(msg string, opts *EchoOpts) string { return m.EchoOptsInline(msg, opts) } ``` The arg type needs to be changed to `opts EchoOpts` for it to work as intended. Giving: ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1809: Undefined type EchoOptsID. ``` --- `Opts` structs cannot be nested: ```go package main import "fmt" type Potato struct{} type PotatoOptions struct { Count int TestingOptions TestingOptions } type TestingOptions struct { Foo string } func (m *Potato) HelloWorld(opts PotatoOptions) string { return fmt.Sprintf("Hello world, I have %d potatoes (%s)", opts.Count, opts.TestingOptions.Foo) } ``` ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1803: Undefined type TestingOptionsID. ```
https://github.com/dagger/dagger/issues/5864
https://github.com/dagger/dagger/pull/5907
db901c8fe4c70cc32336e304492ca37f12b8f389
e8ad5c62275172e3d54ae46447e741ff5d603450
2023-10-10T22:55:05Z
go
2023-10-25T19:38:59Z
core/integration/module_test.go
t.Parallel() c, ctx := connect(t) modGen := c.Container().From(golangImage). WithMountedFile(testCLIBinPath, daggerCliFile(t, c)). WithWorkdir("/work/dep"). With(daggerExec("mod", "init", "--name=dep", "--sdk=go")). WithWorkdir("/work"). With(daggerExec("mod", "init", "--name=use", "--sdk=go")). WithNewFile("/work/dep/main.go", dagger.ContainerWithNewFileOpts{ Contents: useInner, }). WithNewFile("/work/main.go", dagger.ContainerWithNewFileOpts{ Contents: useOuter, }). With(daggerExec("mod", "use", "./dep")). WithEnvVariable("BUST", identity.NewID()) logGen(ctx, t, modGen.Directory(".")) out, err := modGen.With(daggerQuery(`{use{useHello}}`)).Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"use":{"useHello":"hello"}}`, out) _, err = modGen.With(daggerQuery(`{dep{hello}}`)).Stdout(ctx) require.Error(t, err) require.ErrorContains(t, err, `Cannot query field "dep" on type "Query".`) } func TestModuleGoUseLocalMulti(t *testing.T) {
closed
dagger/dagger
https://github.com/dagger/dagger
5,864
Zenith: Fix `Opts` types in Go SDK
From @jedevc: --- Looks like `Opt` types can't be pointers, e.g. something like this doesn't work: ```go type EchoOpts struct { Suffix string `doc:"String to append to the echoed message." default:"..."` Times int `doc:"Number of times to repeat the message." default:"3"` } func (m *Minimal) EchoOpts(msg string, opts *EchoOpts) string { return m.EchoOptsInline(msg, opts) } ``` The arg type needs to be changed to `opts EchoOpts` for it to work as intended. Giving: ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1809: Undefined type EchoOptsID. ``` --- `Opts` structs cannot be nested: ```go package main import "fmt" type Potato struct{} type PotatoOptions struct { Count int TestingOptions TestingOptions } type TestingOptions struct { Foo string } func (m *Potato) HelloWorld(opts PotatoOptions) string { return fmt.Sprintf("Hello world, I have %d potatoes (%s)", opts.Count, opts.TestingOptions.Foo) } ``` ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1803: Undefined type TestingOptionsID. ```
https://github.com/dagger/dagger/issues/5864
https://github.com/dagger/dagger/pull/5907
db901c8fe4c70cc32336e304492ca37f12b8f389
e8ad5c62275172e3d54ae46447e741ff5d603450
2023-10-10T22:55:05Z
go
2023-10-25T19:38:59Z
core/integration/module_test.go
t.Parallel() c, ctx := connect(t) modGen := c.Container().From(golangImage). WithMountedFile(testCLIBinPath, daggerCliFile(t, c)). WithWorkdir("/work/foo"). WithNewFile("/work/foo/main.go", dagger.ContainerWithNewFileOpts{ Contents: `package main type Foo struct {} func (m *Foo) Name() string { return "foo" } `, }). With(daggerExec("mod", "init", "--name=foo", "--sdk=go")). WithWorkdir("/work/bar"). WithNewFile("/work/bar/main.go", dagger.ContainerWithNewFileOpts{ Contents: `package main type Bar struct {} func (m *Bar) Name() string { return "bar" } `, }). With(daggerExec("mod", "init", "--name=bar", "--sdk=go")).
closed
dagger/dagger
https://github.com/dagger/dagger
5,864
Zenith: Fix `Opts` types in Go SDK
From @jedevc: --- Looks like `Opt` types can't be pointers, e.g. something like this doesn't work: ```go type EchoOpts struct { Suffix string `doc:"String to append to the echoed message." default:"..."` Times int `doc:"Number of times to repeat the message." default:"3"` } func (m *Minimal) EchoOpts(msg string, opts *EchoOpts) string { return m.EchoOptsInline(msg, opts) } ``` The arg type needs to be changed to `opts EchoOpts` for it to work as intended. Giving: ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1809: Undefined type EchoOptsID. ``` --- `Opts` structs cannot be nested: ```go package main import "fmt" type Potato struct{} type PotatoOptions struct { Count int TestingOptions TestingOptions } type TestingOptions struct { Foo string } func (m *Potato) HelloWorld(opts PotatoOptions) string { return fmt.Sprintf("Hello world, I have %d potatoes (%s)", opts.Count, opts.TestingOptions.Foo) } ``` ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1803: Undefined type TestingOptionsID. ```
https://github.com/dagger/dagger/issues/5864
https://github.com/dagger/dagger/pull/5907
db901c8fe4c70cc32336e304492ca37f12b8f389
e8ad5c62275172e3d54ae46447e741ff5d603450
2023-10-10T22:55:05Z
go
2023-10-25T19:38:59Z
core/integration/module_test.go
WithWorkdir("/work"). With(daggerExec("mod", "init", "--name=use", "--sdk=go")). With(daggerExec("mod", "use", "./foo")). With(daggerExec("mod", "use", "./bar")). WithNewFile("/work/main.go", dagger.ContainerWithNewFileOpts{ Contents: `package main import "context" import "fmt" type Use struct {} func (m *Use) Names(ctx context.Context) ([]string, error) { fooName, err := dag.Foo().Name(ctx) if err != nil { return nil, fmt.Errorf("foo.name: %w", err) } barName, err := dag.Bar().Name(ctx) if err != nil { return nil, fmt.Errorf("bar.name: %w", err) } return []string{fooName, barName}, nil } `, }). WithEnvVariable("BUST", identity.NewID()) logGen(ctx, t, modGen.Directory(".")) out, err := modGen.With(daggerQuery(`{use{names}}`)).Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"use":{"names":["foo", "bar"]}}`, out) } var wrapper string func TestModuleGoWrapping(t *testing.T) {
closed
dagger/dagger
https://github.com/dagger/dagger
5,864
Zenith: Fix `Opts` types in Go SDK
From @jedevc: --- Looks like `Opt` types can't be pointers, e.g. something like this doesn't work: ```go type EchoOpts struct { Suffix string `doc:"String to append to the echoed message." default:"..."` Times int `doc:"Number of times to repeat the message." default:"3"` } func (m *Minimal) EchoOpts(msg string, opts *EchoOpts) string { return m.EchoOptsInline(msg, opts) } ``` The arg type needs to be changed to `opts EchoOpts` for it to work as intended. Giving: ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1809: Undefined type EchoOptsID. ``` --- `Opts` structs cannot be nested: ```go package main import "fmt" type Potato struct{} type PotatoOptions struct { Count int TestingOptions TestingOptions } type TestingOptions struct { Foo string } func (m *Potato) HelloWorld(opts PotatoOptions) string { return fmt.Sprintf("Hello world, I have %d potatoes (%s)", opts.Count, opts.TestingOptions.Foo) } ``` ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1803: Undefined type TestingOptionsID. ```
https://github.com/dagger/dagger/issues/5864
https://github.com/dagger/dagger/pull/5907
db901c8fe4c70cc32336e304492ca37f12b8f389
e8ad5c62275172e3d54ae46447e741ff5d603450
2023-10-10T22:55:05Z
go
2023-10-25T19:38:59Z
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=wrapper", "--sdk=go")). WithNewFile("/work/main.go", dagger.ContainerWithNewFileOpts{ Contents: wrapper, }) 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 TestModuleConfigAPI(t *testing.T) {
closed
dagger/dagger
https://github.com/dagger/dagger
5,864
Zenith: Fix `Opts` types in Go SDK
From @jedevc: --- Looks like `Opt` types can't be pointers, e.g. something like this doesn't work: ```go type EchoOpts struct { Suffix string `doc:"String to append to the echoed message." default:"..."` Times int `doc:"Number of times to repeat the message." default:"3"` } func (m *Minimal) EchoOpts(msg string, opts *EchoOpts) string { return m.EchoOptsInline(msg, opts) } ``` The arg type needs to be changed to `opts EchoOpts` for it to work as intended. Giving: ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1809: Undefined type EchoOptsID. ``` --- `Opts` structs cannot be nested: ```go package main import "fmt" type Potato struct{} type PotatoOptions struct { Count int TestingOptions TestingOptions } type TestingOptions struct { Foo string } func (m *Potato) HelloWorld(opts PotatoOptions) string { return fmt.Sprintf("Hello world, I have %d potatoes (%s)", opts.Count, opts.TestingOptions.Foo) } ``` ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1803: Undefined type TestingOptionsID. ```
https://github.com/dagger/dagger/issues/5864
https://github.com/dagger/dagger/pull/5907
db901c8fe4c70cc32336e304492ca37f12b8f389
e8ad5c62275172e3d54ae46447e741ff5d603450
2023-10-10T22:55:05Z
go
2023-10-25T19:38:59Z
core/integration/module_test.go
t.Parallel() c, ctx := connect(t) moduleDir := c.Container().From(golangImage). WithMountedFile(testCLIBinPath, daggerCliFile(t, c)). WithWorkdir("/work/subdir"). With(daggerExec("mod", "init", "--name=test", "--sdk=go", "--root=..")). Directory("/work") cfg := c.ModuleConfig(moduleDir, dagger.ModuleConfigOpts{Subpath: "subdir"}) name, err := cfg.Name(ctx) require.NoError(t, err) require.Equal(t, "test", name) sdk, err := cfg.SDK(ctx) require.NoError(t, err) require.Equal(t, "go", sdk) root, err := cfg.Root(ctx) require.NoError(t, err) require.Equal(t, "..", root) } func TestModulePythonInit(t *testing.T) {
closed
dagger/dagger
https://github.com/dagger/dagger
5,864
Zenith: Fix `Opts` types in Go SDK
From @jedevc: --- Looks like `Opt` types can't be pointers, e.g. something like this doesn't work: ```go type EchoOpts struct { Suffix string `doc:"String to append to the echoed message." default:"..."` Times int `doc:"Number of times to repeat the message." default:"3"` } func (m *Minimal) EchoOpts(msg string, opts *EchoOpts) string { return m.EchoOptsInline(msg, opts) } ``` The arg type needs to be changed to `opts EchoOpts` for it to work as intended. Giving: ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1809: Undefined type EchoOptsID. ``` --- `Opts` structs cannot be nested: ```go package main import "fmt" type Potato struct{} type PotatoOptions struct { Count int TestingOptions TestingOptions } type TestingOptions struct { Foo string } func (m *Potato) HelloWorld(opts PotatoOptions) string { return fmt.Sprintf("Hello world, I have %d potatoes (%s)", opts.Count, opts.TestingOptions.Foo) } ``` ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1803: Undefined type TestingOptionsID. ```
https://github.com/dagger/dagger/issues/5864
https://github.com/dagger/dagger/pull/5907
db901c8fe4c70cc32336e304492ca37f12b8f389
e8ad5c62275172e3d54ae46447e741ff5d603450
2023-10-10T22:55:05Z
go
2023-10-25T19:38:59Z
core/integration/module_test.go
t.Run("from scratch", func(t *testing.T) { t.Parallel() c, ctx := connect(t) modGen := c.Container().From(golangImage). WithMountedFile(testCLIBinPath, daggerCliFile(t, c)). WithWorkdir("/work"). With(daggerExec("mod", "init", "--name=bare", "--sdk=python")) out, err := modGen. With(daggerQuery(`{bare{myFunction(stringArg:"hello"){stdout}}}`)). Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"bare":{"myFunction":{"stdout":"hello\n"}}}`, out) }) t.Run("respects existing pyproject.toml", func(t *testing.T) { t.Parallel() c, ctx := connect(t) modGen := c.Container().From(golangImage). WithMountedFile(testCLIBinPath, daggerCliFile(t, c)). WithWorkdir("/work").
closed
dagger/dagger
https://github.com/dagger/dagger
5,864
Zenith: Fix `Opts` types in Go SDK
From @jedevc: --- Looks like `Opt` types can't be pointers, e.g. something like this doesn't work: ```go type EchoOpts struct { Suffix string `doc:"String to append to the echoed message." default:"..."` Times int `doc:"Number of times to repeat the message." default:"3"` } func (m *Minimal) EchoOpts(msg string, opts *EchoOpts) string { return m.EchoOptsInline(msg, opts) } ``` The arg type needs to be changed to `opts EchoOpts` for it to work as intended. Giving: ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1809: Undefined type EchoOptsID. ``` --- `Opts` structs cannot be nested: ```go package main import "fmt" type Potato struct{} type PotatoOptions struct { Count int TestingOptions TestingOptions } type TestingOptions struct { Foo string } func (m *Potato) HelloWorld(opts PotatoOptions) string { return fmt.Sprintf("Hello world, I have %d potatoes (%s)", opts.Count, opts.TestingOptions.Foo) } ``` ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1803: Undefined type TestingOptionsID. ```
https://github.com/dagger/dagger/issues/5864
https://github.com/dagger/dagger/pull/5907
db901c8fe4c70cc32336e304492ca37f12b8f389
e8ad5c62275172e3d54ae46447e741ff5d603450
2023-10-10T22:55:05Z
go
2023-10-25T19:38:59Z
core/integration/module_test.go
WithNewFile("pyproject.toml", dagger.ContainerWithNewFileOpts{ Contents: `[project] name = "has-pyproject" version = "0.0.0" `, }). With(daggerExec("mod", "init", "--name=hasPyproject", "--sdk=python")) out, err := modGen. With(daggerQuery(`{hasPyproject{myFunction(stringArg:"hello"){stdout}}}`)). Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"hasPyproject":{"myFunction":{"stdout":"hello\n"}}}`, out) t.Run("preserves module name", func(t *testing.T) { generated, err := modGen.File("pyproject.toml").Contents(ctx) require.NoError(t, err) require.Contains(t, generated, `name = "has-pyproject"`) }) }) t.Run("respects existing main.py", func(t *testing.T) { t.Parallel() c, ctx := connect(t) modGen := c.Container().From(golangImage). WithMountedFile(testCLIBinPath, daggerCliFile(t, c)). WithWorkdir("/work"). WithNewFile("/work/src/main/__init__.py", dagger.ContainerWithNewFileOpts{ Contents: "from . import notmain\n", }). WithNewFile("/work/src/main/notmain.py", dagger.ContainerWithNewFileOpts{ Contents: `from dagger.mod import function @function
closed
dagger/dagger
https://github.com/dagger/dagger
5,864
Zenith: Fix `Opts` types in Go SDK
From @jedevc: --- Looks like `Opt` types can't be pointers, e.g. something like this doesn't work: ```go type EchoOpts struct { Suffix string `doc:"String to append to the echoed message." default:"..."` Times int `doc:"Number of times to repeat the message." default:"3"` } func (m *Minimal) EchoOpts(msg string, opts *EchoOpts) string { return m.EchoOptsInline(msg, opts) } ``` The arg type needs to be changed to `opts EchoOpts` for it to work as intended. Giving: ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1809: Undefined type EchoOptsID. ``` --- `Opts` structs cannot be nested: ```go package main import "fmt" type Potato struct{} type PotatoOptions struct { Count int TestingOptions TestingOptions } type TestingOptions struct { Foo string } func (m *Potato) HelloWorld(opts PotatoOptions) string { return fmt.Sprintf("Hello world, I have %d potatoes (%s)", opts.Count, opts.TestingOptions.Foo) } ``` ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1803: Undefined type TestingOptionsID. ```
https://github.com/dagger/dagger/issues/5864
https://github.com/dagger/dagger/pull/5907
db901c8fe4c70cc32336e304492ca37f12b8f389
e8ad5c62275172e3d54ae46447e741ff5d603450
2023-10-10T22:55:05Z
go
2023-10-25T19:38:59Z
core/integration/module_test.go
def hello() -> str: return "Hello, world!" `, }). With(daggerExec("mod", "init", "--name=hasMainPy", "--sdk=python")) out, err := modGen. With(daggerQuery(`{hasMainPy{hello}}`)). Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"hasMainPy":{"hello":"Hello, world!"}}`, out) }) } func TestModuleLotsOfFunctions(t *testing.T) { 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).
closed
dagger/dagger
https://github.com/dagger/dagger
5,864
Zenith: Fix `Opts` types in Go SDK
From @jedevc: --- Looks like `Opt` types can't be pointers, e.g. something like this doesn't work: ```go type EchoOpts struct { Suffix string `doc:"String to append to the echoed message." default:"..."` Times int `doc:"Number of times to repeat the message." default:"3"` } func (m *Minimal) EchoOpts(msg string, opts *EchoOpts) string { return m.EchoOptsInline(msg, opts) } ``` The arg type needs to be changed to `opts EchoOpts` for it to work as intended. Giving: ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1809: Undefined type EchoOptsID. ``` --- `Opts` structs cannot be nested: ```go package main import "fmt" type Potato struct{} type PotatoOptions struct { Count int TestingOptions TestingOptions } type TestingOptions struct { Foo string } func (m *Potato) HelloWorld(opts PotatoOptions) string { return fmt.Sprintf("Hello world, I have %d potatoes (%s)", opts.Count, opts.TestingOptions.Foo) } ``` ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1803: Undefined type TestingOptionsID. ```
https://github.com/dagger/dagger/issues/5864
https://github.com/dagger/dagger/pull/5907
db901c8fe4c70cc32336e304492ca37f12b8f389
e8ad5c62275172e3d54ae46447e741ff5d603450
2023-10-10T22:55:05Z
go
2023-10-25T19:38:59Z
core/integration/module_test.go
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 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.mod import function ` for i := 0; i < funcCount; i++ { mainSrc += fmt.Sprintf(`
closed
dagger/dagger
https://github.com/dagger/dagger
5,864
Zenith: Fix `Opts` types in Go SDK
From @jedevc: --- Looks like `Opt` types can't be pointers, e.g. something like this doesn't work: ```go type EchoOpts struct { Suffix string `doc:"String to append to the echoed message." default:"..."` Times int `doc:"Number of times to repeat the message." default:"3"` } func (m *Minimal) EchoOpts(msg string, opts *EchoOpts) string { return m.EchoOptsInline(msg, opts) } ``` The arg type needs to be changed to `opts EchoOpts` for it to work as intended. Giving: ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1809: Undefined type EchoOptsID. ``` --- `Opts` structs cannot be nested: ```go package main import "fmt" type Potato struct{} type PotatoOptions struct { Count int TestingOptions TestingOptions } type TestingOptions struct { Foo string } func (m *Potato) HelloWorld(opts PotatoOptions) string { return fmt.Sprintf("Hello world, I have %d potatoes (%s)", opts.Count, opts.TestingOptions.Foo) } ``` ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1803: Undefined type TestingOptionsID. ```
https://github.com/dagger/dagger/issues/5864
https://github.com/dagger/dagger/pull/5907
db901c8fe4c70cc32336e304492ca37f12b8f389
e8ad5c62275172e3d54ae46447e741ff5d603450
2023-10-10T22:55:05Z
go
2023-10-25T19:38:59Z
core/integration/module_test.go
@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, }). 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()) }) } func TestModuleNamespacing(t *testing.T) {
closed
dagger/dagger
https://github.com/dagger/dagger
5,864
Zenith: Fix `Opts` types in Go SDK
From @jedevc: --- Looks like `Opt` types can't be pointers, e.g. something like this doesn't work: ```go type EchoOpts struct { Suffix string `doc:"String to append to the echoed message." default:"..."` Times int `doc:"Number of times to repeat the message." default:"3"` } func (m *Minimal) EchoOpts(msg string, opts *EchoOpts) string { return m.EchoOptsInline(msg, opts) } ``` The arg type needs to be changed to `opts EchoOpts` for it to work as intended. Giving: ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1809: Undefined type EchoOptsID. ``` --- `Opts` structs cannot be nested: ```go package main import "fmt" type Potato struct{} type PotatoOptions struct { Count int TestingOptions TestingOptions } type TestingOptions struct { Foo string } func (m *Potato) HelloWorld(opts PotatoOptions) string { return fmt.Sprintf("Hello world, I have %d potatoes (%s)", opts.Count, opts.TestingOptions.Foo) } ``` ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1803: Undefined type TestingOptionsID. ```
https://github.com/dagger/dagger/issues/5864
https://github.com/dagger/dagger/pull/5907
db901c8fe4c70cc32336e304492ca37f12b8f389
e8ad5c62275172e3d54ae46447e741ff5d603450
2023-10-10T22:55:05Z
go
2023-10-25T19:38:59Z
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":"1:yo 2:yo"}}`, out) } func TestEnvCmd(t *testing.T) { t.Skip("pending conversion to modules") t.Parallel() type testCase struct {
closed
dagger/dagger
https://github.com/dagger/dagger
5,864
Zenith: Fix `Opts` types in Go SDK
From @jedevc: --- Looks like `Opt` types can't be pointers, e.g. something like this doesn't work: ```go type EchoOpts struct { Suffix string `doc:"String to append to the echoed message." default:"..."` Times int `doc:"Number of times to repeat the message." default:"3"` } func (m *Minimal) EchoOpts(msg string, opts *EchoOpts) string { return m.EchoOptsInline(msg, opts) } ``` The arg type needs to be changed to `opts EchoOpts` for it to work as intended. Giving: ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1809: Undefined type EchoOptsID. ``` --- `Opts` structs cannot be nested: ```go package main import "fmt" type Potato struct{} type PotatoOptions struct { Count int TestingOptions TestingOptions } type TestingOptions struct { Foo string } func (m *Potato) HelloWorld(opts PotatoOptions) string { return fmt.Sprintf("Hello world, I have %d potatoes (%s)", opts.Count, opts.TestingOptions.Foo) } ``` ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1803: Undefined type TestingOptionsID. ```
https://github.com/dagger/dagger/issues/5864
https://github.com/dagger/dagger/pull/5907
db901c8fe4c70cc32336e304492ca37f12b8f389
e8ad5c62275172e3d54ae46447e741ff5d603450
2023-10-10T22:55:05Z
go
2023-10-25T19:38:59Z
core/integration/module_test.go
environmentPath string expectedSDK string expectedName string expectedRoot string } for _, tc := range []testCase{ { environmentPath: "core/integration/testdata/environments/go/basic", expectedSDK: "go", expectedName: "basic", expectedRoot: "../../../../../../", }, } { tc := tc for _, testGitEnv := range []bool{false, true} { testGitEnv := testGitEnv testName := "local environment" if testGitEnv { testName = "git environment"
closed
dagger/dagger
https://github.com/dagger/dagger
5,864
Zenith: Fix `Opts` types in Go SDK
From @jedevc: --- Looks like `Opt` types can't be pointers, e.g. something like this doesn't work: ```go type EchoOpts struct { Suffix string `doc:"String to append to the echoed message." default:"..."` Times int `doc:"Number of times to repeat the message." default:"3"` } func (m *Minimal) EchoOpts(msg string, opts *EchoOpts) string { return m.EchoOptsInline(msg, opts) } ``` The arg type needs to be changed to `opts EchoOpts` for it to work as intended. Giving: ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1809: Undefined type EchoOptsID. ``` --- `Opts` structs cannot be nested: ```go package main import "fmt" type Potato struct{} type PotatoOptions struct { Count int TestingOptions TestingOptions } type TestingOptions struct { Foo string } func (m *Potato) HelloWorld(opts PotatoOptions) string { return fmt.Sprintf("Hello world, I have %d potatoes (%s)", opts.Count, opts.TestingOptions.Foo) } ``` ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1803: Undefined type TestingOptionsID. ```
https://github.com/dagger/dagger/issues/5864
https://github.com/dagger/dagger/pull/5907
db901c8fe4c70cc32336e304492ca37f12b8f389
e8ad5c62275172e3d54ae46447e741ff5d603450
2023-10-10T22:55:05Z
go
2023-10-25T19:38:59Z
core/integration/module_test.go
} testName += "/" + tc.environmentPath t.Run(testName, func(t *testing.T) { t.Parallel() c, ctx := connect(t) stderr, err := CLITestContainer(ctx, t, c). WithLoadedEnv(tc.environmentPath, testGitEnv). CallEnv(). Stderr(ctx) require.NoError(t, err) require.Contains(t, stderr, fmt.Sprintf(`"root": %q`, tc.expectedRoot)) require.Contains(t, stderr, fmt.Sprintf(`"name": %q`, tc.expectedName)) require.Contains(t, stderr, fmt.Sprintf(`"sdk": %q`, tc.expectedSDK)) }) } } } func TestEnvCmdHelps(t *testing.T) { t.Skip("pending conversion to modules") t.Parallel() c, ctx := connect(t) baseCtr := CLITestContainer(ctx, t, c).WithHelpArg(true) noEnvCtr := baseCtr validLocalEnvCtr := baseCtr.WithLoadedEnv("core/integration/testdata/environments/go/basic", false) brokenLocalEnvCtr := baseCtr.WithLoadedEnv("core/integration/testdata/environments/go/broken", false) for _, ctr := range []*DaggerCLIContainer{noEnvCtr, validLocalEnvCtr, brokenLocalEnvCtr} { type testCase struct {
closed
dagger/dagger
https://github.com/dagger/dagger
5,864
Zenith: Fix `Opts` types in Go SDK
From @jedevc: --- Looks like `Opt` types can't be pointers, e.g. something like this doesn't work: ```go type EchoOpts struct { Suffix string `doc:"String to append to the echoed message." default:"..."` Times int `doc:"Number of times to repeat the message." default:"3"` } func (m *Minimal) EchoOpts(msg string, opts *EchoOpts) string { return m.EchoOptsInline(msg, opts) } ``` The arg type needs to be changed to `opts EchoOpts` for it to work as intended. Giving: ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1809: Undefined type EchoOptsID. ``` --- `Opts` structs cannot be nested: ```go package main import "fmt" type Potato struct{} type PotatoOptions struct { Count int TestingOptions TestingOptions } type TestingOptions struct { Foo string } func (m *Potato) HelloWorld(opts PotatoOptions) string { return fmt.Sprintf("Hello world, I have %d potatoes (%s)", opts.Count, opts.TestingOptions.Foo) } ``` ``` Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1803: Undefined type TestingOptionsID. ```
https://github.com/dagger/dagger/issues/5864
https://github.com/dagger/dagger/pull/5907
db901c8fe4c70cc32336e304492ca37f12b8f389
e8ad5c62275172e3d54ae46447e741ff5d603450
2023-10-10T22:55:05Z
go
2023-10-25T19:38:59Z
core/integration/module_test.go
testName string cmdCtr *DaggerCLIContainer expectedOutput string } for _, tc := range []testCase{ { testName: "dagger env/" + ctr.EnvArg, cmdCtr: ctr.CallEnv(), expectedOutput: "Usage:\n dagger environment [flags]\n\nAliases:\n environment, env", }, { testName: "dagger env init/" + ctr.EnvArg, cmdCtr: ctr.CallEnvInit(), expectedOutput: "Usage:\n dagger environment init", }, { testName: "dagger env sync/" + ctr.EnvArg, cmdCtr: ctr.CallEnvSync(), expectedOutput: "Usage:\n dagger environment sync", }, { testName: "dagger env extend/" + ctr.EnvArg, cmdCtr: ctr.CallEnvExtend("./fake/dep"), expectedOutput: "Usage:\n dagger environment extend", },