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,696 | 🐞Need to check pointer for nil in `WithMountedFile`? User reported. | ### What is the issue?
Encountered by @verdverm here: https://discord.com/channels/707636530424053791/1144428151766790184/1144437805632716922
https://github.com/dagger/dagger-go-sdk/blob/v0.8.4/api.gen.go#L1027
### Log output
_No response_
### Steps to reproduce
_No response_
### SDK version
Go SDK
### OS version
?
cc @vito @helderco | https://github.com/dagger/dagger/issues/5696 | https://github.com/dagger/dagger/pull/5785 | 669898a922697e7f65d18c3c2a5ea309e5585584 | 528418afc645c3ad3c506ceb9675c90f47f75590 | 2023-08-25T02:09:51Z | go | 2023-09-18T16:57:11Z | sdk/go/api.gen.go | 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,
}
}
func (r *Client) File(id FileID) *File {
q := r.q.Select("file")
q = q.Arg("id", id)
return &File{
q: q,
c: r.c,
}
}
type GitOpts struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,696 | 🐞Need to check pointer for nil in `WithMountedFile`? User reported. | ### What is the issue?
Encountered by @verdverm here: https://discord.com/channels/707636530424053791/1144428151766790184/1144437805632716922
https://github.com/dagger/dagger-go-sdk/blob/v0.8.4/api.gen.go#L1027
### Log output
_No response_
### Steps to reproduce
_No response_
### SDK version
Go SDK
### OS version
?
cc @vito @helderco | https://github.com/dagger/dagger/issues/5696 | https://github.com/dagger/dagger/pull/5785 | 669898a922697e7f65d18c3c2a5ea309e5585584 | 528418afc645c3ad3c506ceb9675c90f47f75590 | 2023-08-25T02:09:51Z | go | 2023-09-18T16:57:11Z | sdk/go/api.gen.go | KeepGitDir bool
ExperimentalServiceHost *Container
}
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{ |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,696 | 🐞Need to check pointer for nil in `WithMountedFile`? User reported. | ### What is the issue?
Encountered by @verdverm here: https://discord.com/channels/707636530424053791/1144428151766790184/1144437805632716922
https://github.com/dagger/dagger-go-sdk/blob/v0.8.4/api.gen.go#L1027
### Log output
_No response_
### Steps to reproduce
_No response_
### SDK version
Go SDK
### OS version
?
cc @vito @helderco | https://github.com/dagger/dagger/issues/5696 | https://github.com/dagger/dagger/pull/5785 | 669898a922697e7f65d18c3c2a5ea309e5585584 | 528418afc645c3ad3c506ceb9675c90f47f75590 | 2023-08-25T02:09:51Z | go | 2023-09-18T16:57:11Z | sdk/go/api.gen.go | 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 {
ExperimentalServiceHost *Container
}
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,
}
}
type PipelineOpts struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,696 | 🐞Need to check pointer for nil in `WithMountedFile`? User reported. | ### What is the issue?
Encountered by @verdverm here: https://discord.com/channels/707636530424053791/1144428151766790184/1144437805632716922
https://github.com/dagger/dagger-go-sdk/blob/v0.8.4/api.gen.go#L1027
### Log output
_No response_
### Steps to reproduce
_No response_
### SDK version
Go SDK
### OS version
?
cc @vito @helderco | https://github.com/dagger/dagger/issues/5696 | https://github.com/dagger/dagger/pull/5785 | 669898a922697e7f65d18c3c2a5ea309e5585584 | 528418afc645c3ad3c506ceb9675c90f47f75590 | 2023-08-25T02:09:51Z | go | 2023-09-18T16:57:11Z | sdk/go/api.gen.go | 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)
}
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,
}
}
type ProjectOpts struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,696 | 🐞Need to check pointer for nil in `WithMountedFile`? User reported. | ### What is the issue?
Encountered by @verdverm here: https://discord.com/channels/707636530424053791/1144428151766790184/1144437805632716922
https://github.com/dagger/dagger-go-sdk/blob/v0.8.4/api.gen.go#L1027
### Log output
_No response_
### Steps to reproduce
_No response_
### SDK version
Go SDK
### OS version
?
cc @vito @helderco | https://github.com/dagger/dagger/issues/5696 | https://github.com/dagger/dagger/pull/5785 | 669898a922697e7f65d18c3c2a5ea309e5585584 | 528418afc645c3ad3c506ceb9675c90f47f75590 | 2023-08-25T02:09:51Z | go | 2023-09-18T16:57:11Z | sdk/go/api.gen.go | ID ProjectID
}
func (r *Client) Project(opts ...ProjectOpts) *Project {
q := r.q.Select("project")
for i := len(opts) - 1; i >= 0; i-- {
if !querybuilder.IsZeroValue(opts[i].ID) {
q = q.Arg("id", opts[i].ID)
}
}
return &Project{
q: q,
c: r.c,
}
}
type ProjectCommandOpts struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,696 | 🐞Need to check pointer for nil in `WithMountedFile`? User reported. | ### What is the issue?
Encountered by @verdverm here: https://discord.com/channels/707636530424053791/1144428151766790184/1144437805632716922
https://github.com/dagger/dagger-go-sdk/blob/v0.8.4/api.gen.go#L1027
### Log output
_No response_
### Steps to reproduce
_No response_
### SDK version
Go SDK
### OS version
?
cc @vito @helderco | https://github.com/dagger/dagger/issues/5696 | https://github.com/dagger/dagger/pull/5785 | 669898a922697e7f65d18c3c2a5ea309e5585584 | 528418afc645c3ad3c506ceb9675c90f47f75590 | 2023-08-25T02:09:51Z | go | 2023-09-18T16:57:11Z | sdk/go/api.gen.go | ID ProjectCommandID
}
func (r *Client) ProjectCommand(opts ...ProjectCommandOpts) *ProjectCommand {
q := r.q.Select("projectCommand")
for i := len(opts) - 1; i >= 0; i-- {
if !querybuilder.IsZeroValue(opts[i].ID) {
q = q.Arg("id", opts[i].ID)
}
}
return &ProjectCommand{
q: q,
c: r.c,
}
}
func (r *Client) Secret(id SecretID) *Secret {
q := r.q.Select("secret")
q = q.Arg("id", id)
return &Secret{ |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,696 | 🐞Need to check pointer for nil in `WithMountedFile`? User reported. | ### What is the issue?
Encountered by @verdverm here: https://discord.com/channels/707636530424053791/1144428151766790184/1144437805632716922
https://github.com/dagger/dagger-go-sdk/blob/v0.8.4/api.gen.go#L1027
### Log output
_No response_
### Steps to reproduce
_No response_
### SDK version
Go SDK
### OS version
?
cc @vito @helderco | https://github.com/dagger/dagger/issues/5696 | https://github.com/dagger/dagger/pull/5785 | 669898a922697e7f65d18c3c2a5ea309e5585584 | 528418afc645c3ad3c506ceb9675c90f47f75590 | 2023-08-25T02:09:51Z | go | 2023-09-18T16:57:11Z | sdk/go/api.gen.go | 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 {
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,
}
}
type Secret struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,696 | 🐞Need to check pointer for nil in `WithMountedFile`? User reported. | ### What is the issue?
Encountered by @verdverm here: https://discord.com/channels/707636530424053791/1144428151766790184/1144437805632716922
https://github.com/dagger/dagger-go-sdk/blob/v0.8.4/api.gen.go#L1027
### Log output
_No response_
### Steps to reproduce
_No response_
### SDK version
Go SDK
### OS version
?
cc @vito @helderco | https://github.com/dagger/dagger/issues/5696 | https://github.com/dagger/dagger/pull/5785 | 669898a922697e7f65d18c3c2a5ea309e5585584 | 528418afc645c3ad3c506ceb9675c90f47f75590 | 2023-08-25T02:09:51Z | go | 2023-09-18T16:57:11Z | sdk/go/api.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
} |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,696 | 🐞Need to check pointer for nil in `WithMountedFile`? User reported. | ### What is the issue?
Encountered by @verdverm here: https://discord.com/channels/707636530424053791/1144428151766790184/1144437805632716922
https://github.com/dagger/dagger-go-sdk/blob/v0.8.4/api.gen.go#L1027
### Log output
_No response_
### Steps to reproduce
_No response_
### SDK version
Go SDK
### OS version
?
cc @vito @helderco | https://github.com/dagger/dagger/issues/5696 | https://github.com/dagger/dagger/pull/5785 | 669898a922697e7f65d18c3c2a5ea309e5585584 | 528418afc645c3ad3c506ceb9675c90f47f75590 | 2023-08-25T02:09:51Z | go | 2023-09-18T16:57:11Z | sdk/go/api.gen.go | 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 Socket struct {
q *querybuilder.Selection
c graphql.Client
id *SocketID
}
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) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,696 | 🐞Need to check pointer for nil in `WithMountedFile`? User reported. | ### What is the issue?
Encountered by @verdverm here: https://discord.com/channels/707636530424053791/1144428151766790184/1144437805632716922
https://github.com/dagger/dagger-go-sdk/blob/v0.8.4/api.gen.go#L1027
### Log output
_No response_
### Steps to reproduce
_No response_
### SDK version
Go SDK
### OS version
?
cc @vito @helderco | https://github.com/dagger/dagger/issues/5696 | https://github.com/dagger/dagger/pull/5785 | 669898a922697e7f65d18c3c2a5ea309e5585584 | 528418afc645c3ad3c506ceb9675c90f47f75590 | 2023-08-25T02:09:51Z | go | 2023-09-18T16:57:11Z | sdk/go/api.gen.go | id, err := r.ID(ctx)
if err != nil {
return "", err
}
return string(id), nil
}
type CacheSharingMode string
const (
Locked CacheSharingMode = "LOCKED"
Private CacheSharingMode = "PRIVATE"
Shared CacheSharingMode = "SHARED"
)
type ImageLayerCompression string
const (
Estargz ImageLayerCompression = "EStarGZ"
Gzip ImageLayerCompression = "Gzip"
Uncompressed ImageLayerCompression = "Uncompressed"
Zstd ImageLayerCompression = "Zstd"
)
type ImageMediaTypes string
const (
Dockermediatypes ImageMediaTypes = "DockerMediaTypes"
Ocimediatypes ImageMediaTypes = "OCIMediaTypes"
)
type NetworkProtocol string
const (
Tcp NetworkProtocol = "TCP"
Udp NetworkProtocol = "UDP"
) |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,823 | 🐞 sdk:java:generate build target should use engine version to name API schema file | ### What is the issue?
The build target `sdk:java:generate` uses the `daggerengine.version` property to determine the name of the file where the API JSON schema is written. However if the engine version and property version do not match the schema file may contain an incorrect version API (e.g. if the engine version is 0.8.2 and the `daggerengine.version` property is 0.6.4 `schema-0.6.4.json` will contain the 0.8.2 API version)
The schema version should be inferred from the engine.
### Log output
_No response_
### Steps to reproduce
1. set the `daggerengine.version` property in the `sdk/java/pom.xml` file to the last stable engine version
2. and run `./hack/make sdk:java:generate`
### SDK version
Java
### OS version
N/A | https://github.com/dagger/dagger/issues/5823 | https://github.com/dagger/dagger/pull/5826 | 67b87ed34b9a9b1610d6ff6c147b874cf418905c | 926bdb3fc204549a3c1aa14ee1bfe5efb636b50e | 2023-09-25T21:09:21Z | go | 2023-09-29T09:08:07Z | internal/mage/sdk/java.go | package sdk
import (
"context"
"fmt"
"os"
"regexp"
"strings"
"dagger.io/dagger"
"github.com/dagger/dagger/internal/mage/util"
"github.com/magefile/mage/mg"
)
const (
javaSDKPath = "sdk/java"
javaSDKVersionPomPath = javaSDKPath + "/pom.xml"
javaSchemasDirPath = javaSDKPath + "/dagger-codegen-maven-plugin/src/main/resources/schemas"
javaGeneratedSchemaPath = "target/generated-schema/schema.json"
javaVersion = "17"
mavenVersion = "3.9"
)
var _ SDK = Java{}
type Java mg.Namespace
func (Java) Lint(ctx context.Context) error {
c, err := dagger.Connect(ctx, dagger.WithLogOutput(os.Stderr))
if err != nil {
return err
}
defer c.Close()
c = c.Pipeline("sdk").Pipeline("java").Pipeline("lint")
_, err = javaBase(c).
WithExec([]string{"mvn", "fmt:check"}). |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,823 | 🐞 sdk:java:generate build target should use engine version to name API schema file | ### What is the issue?
The build target `sdk:java:generate` uses the `daggerengine.version` property to determine the name of the file where the API JSON schema is written. However if the engine version and property version do not match the schema file may contain an incorrect version API (e.g. if the engine version is 0.8.2 and the `daggerengine.version` property is 0.6.4 `schema-0.6.4.json` will contain the 0.8.2 API version)
The schema version should be inferred from the engine.
### Log output
_No response_
### Steps to reproduce
1. set the `daggerengine.version` property in the `sdk/java/pom.xml` file to the last stable engine version
2. and run `./hack/make sdk:java:generate`
### SDK version
Java
### OS version
N/A | https://github.com/dagger/dagger/issues/5823 | https://github.com/dagger/dagger/pull/5826 | 67b87ed34b9a9b1610d6ff6c147b874cf418905c | 926bdb3fc204549a3c1aa14ee1bfe5efb636b50e | 2023-09-25T21:09:21Z | go | 2023-09-29T09:08:07Z | internal/mage/sdk/java.go | Sync(ctx)
return err
}
func (Java) Test(ctx context.Context) error {
c, err := dagger.Connect(ctx, dagger.WithLogOutput(os.Stderr))
if err != nil {
return err
}
defer c.Close()
c = c.Pipeline("sdk").Pipeline("java").Pipeline("test")
devEngine, endpoint, err := util.CIDevEngineContainerAndEndpoint(
ctx,
c.Pipeline("dev-engine"),
util.DevEngineOpts{Name: "sdk-java-test"},
)
if err != nil {
return err
}
cliBinPath := "/.dagger-cli"
_, err = javaBase(c).
WithServiceBinding("dagger-engine", devEngine).
WithEnvVariable("_EXPERIMENTAL_DAGGER_RUNNER_HOST", endpoint).
WithMountedFile(cliBinPath, util.DaggerBinary(c)).
WithEnvVariable("_EXPERIMENTAL_DAGGER_CLI_BIN", cliBinPath).
WithExec([]string{"mvn", "clean", "verify", "-Ddaggerengine.version=local"}).
Sync(ctx)
if err != nil {
return err
}
return nil |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,823 | 🐞 sdk:java:generate build target should use engine version to name API schema file | ### What is the issue?
The build target `sdk:java:generate` uses the `daggerengine.version` property to determine the name of the file where the API JSON schema is written. However if the engine version and property version do not match the schema file may contain an incorrect version API (e.g. if the engine version is 0.8.2 and the `daggerengine.version` property is 0.6.4 `schema-0.6.4.json` will contain the 0.8.2 API version)
The schema version should be inferred from the engine.
### Log output
_No response_
### Steps to reproduce
1. set the `daggerengine.version` property in the `sdk/java/pom.xml` file to the last stable engine version
2. and run `./hack/make sdk:java:generate`
### SDK version
Java
### OS version
N/A | https://github.com/dagger/dagger/issues/5823 | https://github.com/dagger/dagger/pull/5826 | 67b87ed34b9a9b1610d6ff6c147b874cf418905c | 926bdb3fc204549a3c1aa14ee1bfe5efb636b50e | 2023-09-25T21:09:21Z | go | 2023-09-29T09:08:07Z | internal/mage/sdk/java.go | }
func (Java) Generate(ctx context.Context) error {
c, err := dagger.Connect(ctx, dagger.WithLogOutput(os.Stderr))
if err != nil {
return err
}
defer c.Close()
c = c.Pipeline("sdk").Pipeline("java").Pipeline("generate")
devEngine, endpoint, err := util.CIDevEngineContainerAndEndpoint(
ctx,
c.Pipeline("dev-engine"),
util.DevEngineOpts{Name: "sdk-java-generate"},
)
if err != nil {
return err
}
cliBinPath := "/.dagger-cli"
generatedSchema, err := javaBase(c).
WithServiceBinding("dagger-engine", devEngine).
WithEnvVariable("_EXPERIMENTAL_DAGGER_RUNNER_HOST", endpoint).
WithMountedFile(cliBinPath, util.DaggerBinary(c)).
WithEnvVariable("_EXPERIMENTAL_DAGGER_CLI_BIN", cliBinPath).
WithExec([]string{"mvn", "clean", "install", "-pl", "dagger-codegen-maven-plugin"}).
WithExec([]string{"mvn", "-N", "dagger-codegen:generateSchema"}).
File(javaGeneratedSchemaPath).
Contents(ctx)
if err != nil {
return err
}
engineVersion, err := javaBase(c). |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,823 | 🐞 sdk:java:generate build target should use engine version to name API schema file | ### What is the issue?
The build target `sdk:java:generate` uses the `daggerengine.version` property to determine the name of the file where the API JSON schema is written. However if the engine version and property version do not match the schema file may contain an incorrect version API (e.g. if the engine version is 0.8.2 and the `daggerengine.version` property is 0.6.4 `schema-0.6.4.json` will contain the 0.8.2 API version)
The schema version should be inferred from the engine.
### Log output
_No response_
### Steps to reproduce
1. set the `daggerengine.version` property in the `sdk/java/pom.xml` file to the last stable engine version
2. and run `./hack/make sdk:java:generate`
### SDK version
Java
### OS version
N/A | https://github.com/dagger/dagger/issues/5823 | https://github.com/dagger/dagger/pull/5826 | 67b87ed34b9a9b1610d6ff6c147b874cf418905c | 926bdb3fc204549a3c1aa14ee1bfe5efb636b50e | 2023-09-25T21:09:21Z | go | 2023-09-29T09:08:07Z | internal/mage/sdk/java.go | WithServiceBinding("dagger-engine", devEngine).
WithEnvVariable("_EXPERIMENTAL_DAGGER_RUNNER_HOST", endpoint).
WithMountedFile(cliBinPath, util.DaggerBinary(c)).
WithEnvVariable("_EXPERIMENTAL_DAGGER_CLI_BIN", cliBinPath).
WithExec([]string{"mvn", "help:evaluate", "-q", "-DforceStdout", "-Dexpression=daggerengine.version"}).
Stdout(ctx)
if err != nil {
return err
}
return os.WriteFile(javaSchemasDirPath+fmt.Sprintf("/schema-%s.json", engineVersion), []byte(generatedSchema), 0o600)
}
func (Java) Publish(ctx context.Context, tag string) error {
c, err := dagger.Connect(ctx, dagger.WithLogOutput(os.Stderr))
if err != nil {
return err
}
defer c.Close()
var (
version = strings.TrimPrefix(tag, "sdk/java/v")
dryRun = os.Getenv("MVN_DEPLOY_DRY_RUN")
)
skipDeploy := "true"
if dryRun != "" {
skipDeploy = "true"
}
c = c.Pipeline("sdk").Pipeline("java").Pipeline("deploy")
_, err = javaBase(c).
WithExec([]string{"apt-get", "update"}).
WithExec([]string{"apt-get", "-y", "install", "gpg"}).
WithExec([]string{"mvn", "versions:set", fmt.Sprintf("-DnewVersion=%s", version)}). |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,823 | 🐞 sdk:java:generate build target should use engine version to name API schema file | ### What is the issue?
The build target `sdk:java:generate` uses the `daggerengine.version` property to determine the name of the file where the API JSON schema is written. However if the engine version and property version do not match the schema file may contain an incorrect version API (e.g. if the engine version is 0.8.2 and the `daggerengine.version` property is 0.6.4 `schema-0.6.4.json` will contain the 0.8.2 API version)
The schema version should be inferred from the engine.
### Log output
_No response_
### Steps to reproduce
1. set the `daggerengine.version` property in the `sdk/java/pom.xml` file to the last stable engine version
2. and run `./hack/make sdk:java:generate`
### SDK version
Java
### OS version
N/A | https://github.com/dagger/dagger/issues/5823 | https://github.com/dagger/dagger/pull/5826 | 67b87ed34b9a9b1610d6ff6c147b874cf418905c | 926bdb3fc204549a3c1aa14ee1bfe5efb636b50e | 2023-09-25T21:09:21Z | go | 2023-09-29T09:08:07Z | internal/mage/sdk/java.go | WithExec([]string{"mvn", "clean", "deploy", "-Prelease", fmt.Sprintf("-Dmaven.deploy.skip=%s", skipDeploy)}).
WithExec([]string{"find", ".", "-name", "*.jar"}).
Sync(ctx)
return err
}
func (Java) Bump(ctx context.Context, engineVersion string) error {
contents, err := os.ReadFile(javaSDKVersionPomPath)
if err != nil {
return err
}
newVersion := fmt.Sprintf(`<daggerengine.version>%s</daggerengine.version>`, strings.TrimPrefix(engineVersion, "v"))
versionRe, err := regexp.Compile(`<daggerengine.version>([0-9\.-a-zA-Z]+)</daggerengine.version>`)
if err != nil {
return err
}
newContents := versionRe.ReplaceAll(contents, []byte(newVersion))
return os.WriteFile(javaSDKVersionPomPath, newContents, 0o600)
}
func javaBase(c *dagger.Client) *dagger.Container {
const appDir = "sdk/java"
src := c.Directory().WithDirectory("/", util.Repository(c).Directory(appDir))
mountPath := fmt.Sprintf("/%s", appDir)
mavenCache := c.CacheVolume("maven-cache")
return (c.Container().
From(fmt.Sprintf("maven:%s-eclipse-temurin-%s", mavenVersion, javaVersion)).
WithWorkdir(mountPath).
WithDirectory(mountPath, src)).
WithMountedCache("/root/.m2", mavenCache)
} |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,666 | 🐞 Elixir SDK always hang when running with dagger run | ### What is the issue?
Found on Dagger 0.8.4. When using `dagger run elixir test.exs` (the script provided in steps to reproduce section). Instead of finish execution, it still hang.
<img width="1287" alt="Screenshot 2566-08-18 at 23 44 25" src="https://github.com/dagger/dagger/assets/484530/0259f47c-0310-4c12-83d8-3bd3b604af6e">
### Log output
_No response_
### Steps to reproduce
Use this script:
```elixir
Mix.install([{:dagger, "0.8.4"}])
client = Dagger.connect!()
client
|> Dagger.Client.container()
|> Dagger.Container.from("alpine")
|> Dagger.Container.with_exec(~w[echo hello])
|> Dagger.Sync.sync()
Dagger.close(client)
```
And then run `dagger run elixir test.exs`. It now hangs. :/
### SDK version
Elixir 0.8.4
### OS version
macOS | https://github.com/dagger/dagger/issues/5666 | https://github.com/dagger/dagger/pull/5712 | 28e09abe14bc4b27ed7515d22d59191c42194229 | 41634f3ad3f64c02cedc18c77fda1d4ca36c798a | 2023-08-18T16:14:17Z | go | 2023-10-10T14:22:53Z | cmd/dagger/exec_unix.go | package main
import (
"os/exec"
"syscall"
)
func ensureChildProcessesAreKilled(cmd *exec.Cmd) {
if cmd.SysProcAttr == nil {
cmd.SysProcAttr = &syscall.SysProcAttr{}
}
cmd.SysProcAttr.Setpgid = true
cmd.Cancel = func() error {
pgid, err := syscall.Getpgid(cmd.Process.Pid)
if err != nil {
return err
}
return syscall.Kill(-pgid, syscall.SIGTERM)
}
cmd.WaitDelay = waitDelay
} |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,287 | `dagger run` does not work with Gradle | ### What is the issue?
[Gradle](https://gradle.org/) does not work when run within a `dagger run` context.
### Log output
Example. I have a simple application in a gradle module called playground. I can run the app easily with the following
```
$ ./gradlew playground:run -q --console=plain
hi
```
however, feed this through `dagger run ./gradlew playground:run -q --console=plain` and the process hangs indefinitely.
Adding a `--debug` does not offer a whole lot of insight
```
$ dagger run -s ./gradlew playground:run --debug --console=plain
Connected to engine b406cfb838a0
2023-06-04T14:00:30.865-0400 [INFO] [org.gradle.internal.nativeintegration.services.NativeServices] Initialized native services in: /Users/megame/.gradle/native
2023-06-04T14:00:30.890-0400 [INFO] [org.gradle.internal.nativeintegration.services.NativeServices] Initialized jansi services in: /Users/megame/.gradle/native
```
At this point, it just hangs indefinitely.
### Steps to reproduce
This can be reproduced even without an associated project. Install Gradle (my version is 8.1.1) and run `gradle tasks`. Assuming you are in a directory with no gradle project, this operation will fail, but it will show some output. Do the same via `dagger run -s gradle tasks --console=plain` and you will see that even this command hangs.
### SDK version
Dagger CLI 0.6.1
### OS version
Confirmed on both MacOS Mojave and Ubuntu 22.04 | https://github.com/dagger/dagger/issues/5287 | https://github.com/dagger/dagger/pull/5712 | 28e09abe14bc4b27ed7515d22d59191c42194229 | 41634f3ad3f64c02cedc18c77fda1d4ca36c798a | 2023-06-04T18:03:09Z | go | 2023-10-10T14:22:53Z | cmd/dagger/exec_unix.go | package main
import (
"os/exec"
"syscall"
)
func ensureChildProcessesAreKilled(cmd *exec.Cmd) {
if cmd.SysProcAttr == nil {
cmd.SysProcAttr = &syscall.SysProcAttr{}
}
cmd.SysProcAttr.Setpgid = true
cmd.Cancel = func() error {
pgid, err := syscall.Getpgid(cmd.Process.Pid)
if err != nil {
return err
}
return syscall.Kill(-pgid, syscall.SIGTERM)
}
cmd.WaitDelay = waitDelay
} |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,871 | Zenith: custom return types require at least one method defined | Custom function return types require at least one empty method defined on them to be detected by codegen (note the JSON tags are currently required, #5860).
```go
// This is for a module "foo"
package main
import (
"context"
)
type Foo struct{}
type X struct {
Message string `json:"message"`
}
// This function definition is required, or we don't detect and incorporate this into schema generation.
// func (x *X) Void() {}
func (m *Foo) MyFunction(ctx context.Context, stringArg string) X {
return X{Message: stringArg}
}
```
```
$ echo '{foo{myFunction(stringArg: "hello"){message}}' | dagger query -m ".
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1813: Undefined type X.
``` | https://github.com/dagger/dagger/issues/5871 | https://github.com/dagger/dagger/pull/5893 | c847458d6df1e184487e3a29f6d00a86ef67e661 | b74df2479214020502fcb917d77325f00bd4d4e1 | 2023-10-11T10:50:42Z | go | 2023-10-18T12:22:03Z | 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"
)
/* 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
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. |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,871 | Zenith: custom return types require at least one method defined | Custom function return types require at least one empty method defined on them to be detected by codegen (note the JSON tags are currently required, #5860).
```go
// This is for a module "foo"
package main
import (
"context"
)
type Foo struct{}
type X struct {
Message string `json:"message"`
}
// This function definition is required, or we don't detect and incorporate this into schema generation.
// func (x *X) Void() {}
func (m *Foo) MyFunction(ctx context.Context, stringArg string) X {
return X{Message: stringArg}
}
```
```
$ echo '{foo{myFunction(stringArg: "hello"){message}}' | dagger query -m ".
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1813: Undefined type X.
``` | https://github.com/dagger/dagger/issues/5871 | https://github.com/dagger/dagger/pull/5893 | c847458d6df1e184487e3a29f6d00a86ef67e661 | b74df2479214020502fcb917d77325f00bd4d4e1 | 2023-10-11T10:50:42Z | go | 2023-10-18T12:22:03Z | cmd/codegen/generator/go/templates/modules.go | 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)
}
sort.Slice(objs, func(i, j int) bool { |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,871 | Zenith: custom return types require at least one method defined | Custom function return types require at least one empty method defined on them to be detected by codegen (note the JSON tags are currently required, #5860).
```go
// This is for a module "foo"
package main
import (
"context"
)
type Foo struct{}
type X struct {
Message string `json:"message"`
}
// This function definition is required, or we don't detect and incorporate this into schema generation.
// func (x *X) Void() {}
func (m *Foo) MyFunction(ctx context.Context, stringArg string) X {
return X{Message: stringArg}
}
```
```
$ echo '{foo{myFunction(stringArg: "hello"){message}}' | dagger query -m ".
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1813: Undefined type X.
``` | https://github.com/dagger/dagger/issues/5871 | https://github.com/dagger/dagger/pull/5893 | c847458d6df1e184487e3a29f6d00a86ef67e661 | b74df2479214020502fcb917d77325f00bd4d4e1 | 2023-10-11T10:50:42Z | go | 2023-10-18T12:22:03Z | cmd/codegen/generator/go/templates/modules.go | return objs[i].Pos() < objs[j].Pos()
})
for _, obj := range objs {
named, isNamed := obj.Type().(*types.Named)
if !isNamed {
continue
}
strct, isStruct := named.Underlying().(*types.Struct)
if !isStruct {
continue
}
objType, err := ps.goStructToAPIType(strct, named)
if err != nil {
panic(err)
}
if err := ps.fillObjectFunctionCases(named, objFunctionCases); err != nil {
panic(err)
}
if len(objFunctionCases[obj.Name()]) == 0 {
continue
}
createMod = dotLine(createMod, "WithObject").Call(Add(Line(), objType))
} |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,871 | Zenith: custom return types require at least one method defined | Custom function return types require at least one empty method defined on them to be detected by codegen (note the JSON tags are currently required, #5860).
```go
// This is for a module "foo"
package main
import (
"context"
)
type Foo struct{}
type X struct {
Message string `json:"message"`
}
// This function definition is required, or we don't detect and incorporate this into schema generation.
// func (x *X) Void() {}
func (m *Foo) MyFunction(ctx context.Context, stringArg string) X {
return X{Message: stringArg}
}
```
```
$ echo '{foo{myFunction(stringArg: "hello"){message}}' | dagger query -m ".
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1813: Undefined type X.
``` | https://github.com/dagger/dagger/issues/5871 | https://github.com/dagger/dagger/pull/5893 | c847458d6df1e184487e3a29f6d00a86ef67e661 | b74df2479214020502fcb917d77325f00bd4d4e1 | 2023-10-11T10:50:42Z | go | 2023-10-18T12:22:03Z | cmd/codegen/generator/go/templates/modules.go | 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() {
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) |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,871 | Zenith: custom return types require at least one method defined | Custom function return types require at least one empty method defined on them to be detected by codegen (note the JSON tags are currently required, #5860).
```go
// This is for a module "foo"
package main
import (
"context"
)
type Foo struct{}
type X struct {
Message string `json:"message"`
}
// This function definition is required, or we don't detect and incorporate this into schema generation.
// func (x *X) Void() {}
func (m *Foo) MyFunction(ctx context.Context, stringArg string) X {
return X{Message: stringArg}
}
```
```
$ echo '{foo{myFunction(stringArg: "hello"){message}}' | dagger query -m ".
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1813: Undefined type X.
``` | https://github.com/dagger/dagger/issues/5871 | https://github.com/dagger/dagger/pull/5893 | c847458d6df1e184487e3a29f6d00a86ef67e661 | b74df2479214020502fcb917d77325f00bd4d4e1 | 2023-10-11T10:50:42Z | go | 2023-10-18T12:22:03Z | cmd/codegen/generator/go/templates/modules.go | }
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)
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)
} |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,871 | Zenith: custom return types require at least one method defined | Custom function return types require at least one empty method defined on them to be detected by codegen (note the JSON tags are currently required, #5860).
```go
// This is for a module "foo"
package main
import (
"context"
)
type Foo struct{}
type X struct {
Message string `json:"message"`
}
// This function definition is required, or we don't detect and incorporate this into schema generation.
// func (x *X) Void() {}
func (m *Foo) MyFunction(ctx context.Context, stringArg string) X {
return X{Message: stringArg}
}
```
```
$ echo '{foo{myFunction(stringArg: "hello"){message}}' | dagger query -m ".
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1813: Undefined type X.
``` | https://github.com/dagger/dagger/issues/5871 | https://github.com/dagger/dagger/pull/5893 | c847458d6df1e184487e3a29f6d00a86ef67e661 | b74df2479214020502fcb917d77325f00bd4d4e1 | 2023-10-11T10:50:42Z | go | 2023-10-18T12:22:03Z | cmd/codegen/generator/go/templates/modules.go | }
`
parentJSONVar = "parentJSON"
parentNameVar = "parentName"
fnNameVar = "fnName"
inputArgsVar = "inputArgs"
invokeFuncName = "invoke"
)
func invokeSrc(objFunctionCases map[string][]Code, createMod Code) string {
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(), |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,871 | Zenith: custom return types require at least one method defined | Custom function return types require at least one empty method defined on them to be detected by codegen (note the JSON tags are currently required, #5860).
```go
// This is for a module "foo"
package main
import (
"context"
)
type Foo struct{}
type X struct {
Message string `json:"message"`
}
// This function definition is required, or we don't detect and incorporate this into schema generation.
// func (x *X) Void() {}
func (m *Foo) MyFunction(ctx context.Context, stringArg string) X {
return X{Message: stringArg}
}
```
```
$ echo '{foo{myFunction(stringArg: "hello"){message}}' | dagger query -m ".
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1813: Undefined type X.
``` | https://github.com/dagger/dagger/issues/5871 | https://github.com/dagger/dagger/pull/5893 | c847458d6df1e184487e3a29f6d00a86ef67e661 | b74df2479214020502fcb917d77325f00bd4d4e1 | 2023-10-11T10:50:42Z | go | 2023-10-18T12:22:03Z | cmd/codegen/generator/go/templates/modules.go | Id(parentNameVar).String(),
Id(fnNameVar).String(),
Id(inputArgsVar).Map(String()).Index().Byte(),
).Params(
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)),
) |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,871 | Zenith: custom return types require at least one method defined | Custom function return types require at least one empty method defined on them to be detected by codegen (note the JSON tags are currently required, #5860).
```go
// This is for a module "foo"
package main
import (
"context"
)
type Foo struct{}
type X struct {
Message string `json:"message"`
}
// This function definition is required, or we don't detect and incorporate this into schema generation.
// func (x *X) Void() {}
func (m *Foo) MyFunction(ctx context.Context, stringArg string) X {
return X{Message: stringArg}
}
```
```
$ echo '{foo{myFunction(stringArg: "hello"){message}}' | dagger query -m ".
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1813: Undefined type X.
``` | https://github.com/dagger/dagger/issues/5871 | https://github.com/dagger/dagger/pull/5893 | c847458d6df1e184487e3a29f6d00a86ef67e661 | b74df2479214020502fcb917d77325f00bd4d4e1 | 2023-10-11T10:50:42Z | go | 2023-10-18T12:22:03Z | cmd/codegen/generator/go/templates/modules.go | 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:
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)} |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,871 | Zenith: custom return types require at least one method defined | Custom function return types require at least one empty method defined on them to be detected by codegen (note the JSON tags are currently required, #5860).
```go
// This is for a module "foo"
package main
import (
"context"
)
type Foo struct{}
type X struct {
Message string `json:"message"`
}
// This function definition is required, or we don't detect and incorporate this into schema generation.
// func (x *X) Void() {}
func (m *Foo) MyFunction(ctx context.Context, stringArg string) X {
return X{Message: stringArg}
}
```
```
$ echo '{foo{myFunction(stringArg: "hello"){message}}' | dagger query -m ".
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1813: Undefined type X.
``` | https://github.com/dagger/dagger/issues/5871 | https://github.com/dagger/dagger/pull/5893 | c847458d6df1e184487e3a29f6d00a86ef67e661 | b74df2479214020502fcb917d77325f00bd4d4e1 | 2023-10-11T10:50:42Z | go | 2023-10-18T12:22:03Z | cmd/codegen/generator/go/templates/modules.go | 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
}
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), |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,871 | Zenith: custom return types require at least one method defined | Custom function return types require at least one empty method defined on them to be detected by codegen (note the JSON tags are currently required, #5860).
```go
// This is for a module "foo"
package main
import (
"context"
)
type Foo struct{}
type X struct {
Message string `json:"message"`
}
// This function definition is required, or we don't detect and incorporate this into schema generation.
// func (x *X) Void() {}
func (m *Foo) MyFunction(ctx context.Context, stringArg string) X {
return X{Message: stringArg}
}
```
```
$ echo '{foo{myFunction(stringArg: "hello"){message}}' | dagger query -m ".
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1813: Undefined type X.
``` | https://github.com/dagger/dagger/issues/5871 | https://github.com/dagger/dagger/pull/5893 | c847458d6df1e184487e3a29f6d00a86ef67e661 | b74df2479214020502fcb917d77325f00bd4d4e1 | 2023-10-11T10:50:42Z | go | 2023-10-18T12:22:03Z | cmd/codegen/generator/go/templates/modules.go | ),
checkErrStatement,
)
fnCallArgs = append(fnCallArgs, Id(argName))
}
}
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 { |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,871 | Zenith: custom return types require at least one method defined | Custom function return types require at least one empty method defined on them to be detected by codegen (note the JSON tags are currently required, #5860).
```go
// This is for a module "foo"
package main
import (
"context"
)
type Foo struct{}
type X struct {
Message string `json:"message"`
}
// This function definition is required, or we don't detect and incorporate this into schema generation.
// func (x *X) Void() {}
func (m *Foo) MyFunction(ctx context.Context, stringArg string) X {
return X{Message: stringArg}
}
```
```
$ echo '{foo{myFunction(stringArg: "hello"){message}}' | dagger query -m ".
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1813: Undefined type X.
``` | https://github.com/dagger/dagger/issues/5871 | https://github.com/dagger/dagger/pull/5893 | c847458d6df1e184487e3a29f6d00a86ef67e661 | b74df2479214020502fcb917d77325f00bd4d4e1 | 2023-10-11T10:50:42Z | go | 2023-10-18T12:22:03Z | cmd/codegen/generator/go/templates/modules.go | statements = append(statements, Return(
Parens(Op("*").Id(objName)).Dot(fnName).Call(fnCallArgs...),
Nil(),
))
cases[objName] = append(cases[objName], Case(Lit(fnName)).Block(statements...))
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 { |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,871 | Zenith: custom return types require at least one method defined | Custom function return types require at least one empty method defined on them to be detected by codegen (note the JSON tags are currently required, #5860).
```go
// This is for a module "foo"
package main
import (
"context"
)
type Foo struct{}
type X struct {
Message string `json:"message"`
}
// This function definition is required, or we don't detect and incorporate this into schema generation.
// func (x *X) Void() {}
func (m *Foo) MyFunction(ctx context.Context, stringArg string) X {
return X{Message: stringArg}
}
```
```
$ echo '{foo{myFunction(stringArg: "hello"){message}}' | dagger query -m ".
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1813: Undefined type X.
``` | https://github.com/dagger/dagger/issues/5871 | https://github.com/dagger/dagger/pull/5893 | c847458d6df1e184487e3a29f6d00a86ef67e661 | b74df2479214020502fcb917d77325f00bd4d4e1 | 2023-10-11T10:50:42Z | go | 2023-10-18T12:22:03Z | cmd/codegen/generator/go/templates/modules.go | pkg *packages.Package
fset *token.FileSet
methods map[string][]method
}
type method struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,871 | Zenith: custom return types require at least one method defined | Custom function return types require at least one empty method defined on them to be detected by codegen (note the JSON tags are currently required, #5860).
```go
// This is for a module "foo"
package main
import (
"context"
)
type Foo struct{}
type X struct {
Message string `json:"message"`
}
// This function definition is required, or we don't detect and incorporate this into schema generation.
// func (x *X) Void() {}
func (m *Foo) MyFunction(ctx context.Context, stringArg string) X {
return X{Message: stringArg}
}
```
```
$ echo '{foo{myFunction(stringArg: "hello"){message}}' | dagger query -m ".
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1813: Undefined type X.
``` | https://github.com/dagger/dagger/issues/5871 | https://github.com/dagger/dagger/pull/5893 | c847458d6df1e184487e3a29f6d00a86ef67e661 | b74df2479214020502fcb917d77325f00bd4d4e1 | 2023-10-11T10:50:42Z | go | 2023-10-18T12:22:03Z | cmd/codegen/generator/go/templates/modules.go | name string
sig *types.Signature
}
func (ps *parseState) goTypeToAPIType(typ types.Type, named *types.Named) (*Statement, error) {
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")
default:
return nil, fmt.Errorf("unsupported basic type: %+v", t) |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,871 | Zenith: custom return types require at least one method defined | Custom function return types require at least one empty method defined on them to be detected by codegen (note the JSON tags are currently required, #5860).
```go
// This is for a module "foo"
package main
import (
"context"
)
type Foo struct{}
type X struct {
Message string `json:"message"`
}
// This function definition is required, or we don't detect and incorporate this into schema generation.
// func (x *X) Void() {}
func (m *Foo) MyFunction(ctx context.Context, stringArg string) X {
return X{Message: stringArg}
}
```
```
$ echo '{foo{myFunction(stringArg: "hello"){message}}' | dagger query -m ".
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1813: Undefined type X.
``` | https://github.com/dagger/dagger/issues/5871 | https://github.com/dagger/dagger/pull/5893 | c847458d6df1e184487e3a29f6d00a86ef67e661 | b74df2479214020502fcb917d77325f00bd4d4e1 | 2023-10-11T10:50:42Z | go | 2023-10-18T12:22:03Z | cmd/codegen/generator/go/templates/modules.go | }
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"
func (ps *parseState) goStructToAPIType(t *types.Struct, named *types.Named) (*Statement, error) {
if named == nil { |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,871 | Zenith: custom return types require at least one method defined | Custom function return types require at least one empty method defined on them to be detected by codegen (note the JSON tags are currently required, #5860).
```go
// This is for a module "foo"
package main
import (
"context"
)
type Foo struct{}
type X struct {
Message string `json:"message"`
}
// This function definition is required, or we don't detect and incorporate this into schema generation.
// func (x *X) Void() {}
func (m *Foo) MyFunction(ctx context.Context, stringArg string) X {
return X{Message: stringArg}
}
```
```
$ echo '{foo{myFunction(stringArg: "hello"){message}}' | dagger query -m ".
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1813: Undefined type X.
``` | https://github.com/dagger/dagger/issues/5871 | https://github.com/dagger/dagger/pull/5893 | c847458d6df1e184487e3a29f6d00a86ef67e661 | b74df2479214020502fcb917d77325f00bd4d4e1 | 2023-10-11T10:50:42Z | go | 2023-10-18T12:22:03Z | cmd/codegen/generator/go/templates/modules.go | return nil, fmt.Errorf("struct types must be named")
}
typeName := named.Obj().Name()
if typeName == "" {
return nil, fmt.Errorf("struct types must be named")
}
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...)
tokenFile := ps.fset.File(named.Obj().Pos())
isDaggerGenerated := filepath.Base(tokenFile.Name()) == "dagger.gen.go"
methods := []*types.Func{}
methodSet := types.NewMethodSet(types.NewPointer(named))
for i := 0; i < methodSet.Len(); i++ { |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,871 | Zenith: custom return types require at least one method defined | Custom function return types require at least one empty method defined on them to be detected by codegen (note the JSON tags are currently required, #5860).
```go
// This is for a module "foo"
package main
import (
"context"
)
type Foo struct{}
type X struct {
Message string `json:"message"`
}
// This function definition is required, or we don't detect and incorporate this into schema generation.
// func (x *X) Void() {}
func (m *Foo) MyFunction(ctx context.Context, stringArg string) X {
return X{Message: stringArg}
}
```
```
$ echo '{foo{myFunction(stringArg: "hello"){message}}' | dagger query -m ".
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1813: Undefined type X.
``` | https://github.com/dagger/dagger/issues/5871 | https://github.com/dagger/dagger/pull/5893 | c847458d6df1e184487e3a29f6d00a86ef67e661 | b74df2479214020502fcb917d77325f00bd4d4e1 | 2023-10-11T10:50:42Z | go | 2023-10-18T12:22:03Z | cmd/codegen/generator/go/templates/modules.go | methodObj := methodSet.At(i).Obj()
methodTokenFile := ps.fset.File(methodObj.Pos())
methodIsDaggerGenerated := filepath.Base(methodTokenFile.Name()) == "dagger.gen.go"
if methodIsDaggerGenerated {
continue
}
method, ok := methodObj.(*types.Func)
if !ok {
return nil, fmt.Errorf("expected method to be a func, got %T", methodObj)
}
if !method.Exported() {
continue
}
methods = append(methods, method)
}
sort.Slice(methods, func(i, j int) bool {
return methods[i].Pos() < methods[j].Pos()
})
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))
}
if isDaggerGenerated { |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,871 | Zenith: custom return types require at least one method defined | Custom function return types require at least one empty method defined on them to be detected by codegen (note the JSON tags are currently required, #5860).
```go
// This is for a module "foo"
package main
import (
"context"
)
type Foo struct{}
type X struct {
Message string `json:"message"`
}
// This function definition is required, or we don't detect and incorporate this into schema generation.
// func (x *X) Void() {}
func (m *Foo) MyFunction(ctx context.Context, stringArg string) X {
return X{Message: stringArg}
}
```
```
$ echo '{foo{myFunction(stringArg: "hello"){message}}' | dagger query -m ".
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1813: Undefined type X.
``` | https://github.com/dagger/dagger/issues/5871 | https://github.com/dagger/dagger/pull/5893 | c847458d6df1e184487e3a29f6d00a86ef67e661 | b74df2479214020502fcb917d77325f00bd4d4e1 | 2023-10-11T10:50:42Z | go | 2023-10-18T12:22:03Z | cmd/codegen/generator/go/templates/modules.go | return typeDef, nil
}
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 != "" {
withFieldArgs = append(withFieldArgs,
Id("TypeDefWithFieldOpts").Values(
Id("Description").Op(":").Lit(description),
))
} |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,871 | Zenith: custom return types require at least one method defined | Custom function return types require at least one empty method defined on them to be detected by codegen (note the JSON tags are currently required, #5860).
```go
// This is for a module "foo"
package main
import (
"context"
)
type Foo struct{}
type X struct {
Message string `json:"message"`
}
// This function definition is required, or we don't detect and incorporate this into schema generation.
// func (x *X) Void() {}
func (m *Foo) MyFunction(ctx context.Context, stringArg string) X {
return X{Message: stringArg}
}
```
```
$ echo '{foo{myFunction(stringArg: "hello"){message}}' | dagger query -m ".
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1813: Undefined type X.
``` | https://github.com/dagger/dagger/issues/5871 | https://github.com/dagger/dagger/pull/5893 | c847458d6df1e184487e3a29f6d00a86ef67e661 | b74df2479214020502fcb917d77325f00bd4d4e1 | 2023-10-11T10:50:42Z | go | 2023-10-18T12:22:03Z | cmd/codegen/generator/go/templates/modules.go | 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:
result := methodResults.At(0).Type()
if result.String() == errorTypeName {
fnReturnType = voidDef
} else {
fnReturnType, err = ps.goTypeToAPIType(result, nil) |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,871 | Zenith: custom return types require at least one method defined | Custom function return types require at least one empty method defined on them to be detected by codegen (note the JSON tags are currently required, #5860).
```go
// This is for a module "foo"
package main
import (
"context"
)
type Foo struct{}
type X struct {
Message string `json:"message"`
}
// This function definition is required, or we don't detect and incorporate this into schema generation.
// func (x *X) Void() {}
func (m *Foo) MyFunction(ctx context.Context, stringArg string) X {
return X{Message: stringArg}
}
```
```
$ echo '{foo{myFunction(stringArg: "hello"){message}}' | dagger query -m ".
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1813: Undefined type X.
``` | https://github.com/dagger/dagger/issues/5871 | https://github.com/dagger/dagger/pull/5893 | c847458d6df1e184487e3a29f6d00a86ef67e661 | b74df2479214020502fcb917d77325f00bd4d4e1 | 2023-10-11T10:50:42Z | go | 2023-10-18T12:22:03Z | cmd/codegen/generator/go/templates/modules.go | 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" {
continue
}
if opts, ok := namedOrDirectStruct(param.Type()); ok {
for f := 0; f < opts.NumFields(); f++ {
param := opts.Field(f) |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,871 | Zenith: custom return types require at least one method defined | Custom function return types require at least one empty method defined on them to be detected by codegen (note the JSON tags are currently required, #5860).
```go
// This is for a module "foo"
package main
import (
"context"
)
type Foo struct{}
type X struct {
Message string `json:"message"`
}
// This function definition is required, or we don't detect and incorporate this into schema generation.
// func (x *X) Void() {}
func (m *Foo) MyFunction(ctx context.Context, stringArg string) X {
return X{Message: stringArg}
}
```
```
$ echo '{foo{myFunction(stringArg: "hello"){message}}' | dagger query -m ".
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1813: Undefined type X.
``` | https://github.com/dagger/dagger/issues/5871 | https://github.com/dagger/dagger/pull/5893 | c847458d6df1e184487e3a29f6d00a86ef67e661 | b74df2479214020502fcb917d77325f00bd4d4e1 | 2023-10-11T10:50:42Z | go | 2023-10-18T12:22:03Z | cmd/codegen/generator/go/templates/modules.go | 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 {
if tag, err := tags.Get("doc"); err == nil {
argOpts = append(argOpts, Id("Description").Op(":").Lit(tag.Value()))
} |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,871 | Zenith: custom return types require at least one method defined | Custom function return types require at least one empty method defined on them to be detected by codegen (note the JSON tags are currently required, #5860).
```go
// This is for a module "foo"
package main
import (
"context"
)
type Foo struct{}
type X struct {
Message string `json:"message"`
}
// This function definition is required, or we don't detect and incorporate this into schema generation.
// func (x *X) Void() {}
func (m *Foo) MyFunction(ctx context.Context, stringArg string) X {
return X{Message: stringArg}
}
```
```
$ echo '{foo{myFunction(stringArg: "hello"){message}}' | dagger query -m ".
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1813: Undefined type X.
``` | https://github.com/dagger/dagger/issues/5871 | https://github.com/dagger/dagger/pull/5893 | c847458d6df1e184487e3a29f6d00a86ef67e661 | b74df2479214020502fcb917d77325f00bd4d4e1 | 2023-10-11T10:50:42Z | go | 2023-10-18T12:22:03Z | cmd/codegen/generator/go/templates/modules.go | 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)
}
}
return fnDef, nil
}
func namedOrDirectStruct(t types.Type) (*types.Struct, bool) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,871 | Zenith: custom return types require at least one method defined | Custom function return types require at least one empty method defined on them to be detected by codegen (note the JSON tags are currently required, #5860).
```go
// This is for a module "foo"
package main
import (
"context"
)
type Foo struct{}
type X struct {
Message string `json:"message"`
}
// This function definition is required, or we don't detect and incorporate this into schema generation.
// func (x *X) Void() {}
func (m *Foo) MyFunction(ctx context.Context, stringArg string) X {
return X{Message: stringArg}
}
```
```
$ echo '{foo{myFunction(stringArg: "hello"){message}}' | dagger query -m ".
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1813: Undefined type X.
``` | https://github.com/dagger/dagger/issues/5871 | https://github.com/dagger/dagger/pull/5893 | c847458d6df1e184487e3a29f6d00a86ef67e661 | b74df2479214020502fcb917d77325f00bd4d4e1 | 2023-10-11T10:50:42Z | go | 2023-10-18T12:22:03Z | cmd/codegen/generator/go/templates/modules.go | 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,871 | Zenith: custom return types require at least one method defined | Custom function return types require at least one empty method defined on them to be detected by codegen (note the JSON tags are currently required, #5860).
```go
// This is for a module "foo"
package main
import (
"context"
)
type Foo struct{}
type X struct {
Message string `json:"message"`
}
// This function definition is required, or we don't detect and incorporate this into schema generation.
// func (x *X) Void() {}
func (m *Foo) MyFunction(ctx context.Context, stringArg string) X {
return X{Message: stringArg}
}
```
```
$ echo '{foo{myFunction(stringArg: "hello"){message}}' | dagger query -m ".
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1813: Undefined type X.
``` | https://github.com/dagger/dagger/issues/5871 | https://github.com/dagger/dagger/pull/5893 | c847458d6df1e184487e3a29f6d00a86ef67e661 | b74df2479214020502fcb917d77325f00bd4d4e1 | 2023-10-11T10:50:42Z | go | 2023-10-18T12:22:03Z | 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,871 | Zenith: custom return types require at least one method defined | Custom function return types require at least one empty method defined on them to be detected by codegen (note the JSON tags are currently required, #5860).
```go
// This is for a module "foo"
package main
import (
"context"
)
type Foo struct{}
type X struct {
Message string `json:"message"`
}
// This function definition is required, or we don't detect and incorporate this into schema generation.
// func (x *X) Void() {}
func (m *Foo) MyFunction(ctx context.Context, stringArg string) X {
return X{Message: stringArg}
}
```
```
$ echo '{foo{myFunction(stringArg: "hello"){message}}' | dagger query -m ".
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1813: Undefined type X.
``` | https://github.com/dagger/dagger/issues/5871 | https://github.com/dagger/dagger/pull/5893 | c847458d6df1e184487e3a29f6d00a86ef67e661 | b74df2479214020502fcb917d77325f00bd4d4e1 | 2023-10-11T10:50:42Z | go | 2023-10-18T12:22:03Z | 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"
)
/* 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,871 | Zenith: custom return types require at least one method defined | Custom function return types require at least one empty method defined on them to be detected by codegen (note the JSON tags are currently required, #5860).
```go
// This is for a module "foo"
package main
import (
"context"
)
type Foo struct{}
type X struct {
Message string `json:"message"`
}
// This function definition is required, or we don't detect and incorporate this into schema generation.
// func (x *X) Void() {}
func (m *Foo) MyFunction(ctx context.Context, stringArg string) X {
return X{Message: stringArg}
}
```
```
$ echo '{foo{myFunction(stringArg: "hello"){message}}' | dagger query -m ".
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1813: Undefined type X.
``` | https://github.com/dagger/dagger/issues/5871 | https://github.com/dagger/dagger/pull/5893 | c847458d6df1e184487e3a29f6d00a86ef67e661 | b74df2479214020502fcb917d77325f00bd4d4e1 | 2023-10-11T10:50:42Z | go | 2023-10-18T12:22:03Z | 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. |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,871 | Zenith: custom return types require at least one method defined | Custom function return types require at least one empty method defined on them to be detected by codegen (note the JSON tags are currently required, #5860).
```go
// This is for a module "foo"
package main
import (
"context"
)
type Foo struct{}
type X struct {
Message string `json:"message"`
}
// This function definition is required, or we don't detect and incorporate this into schema generation.
// func (x *X) Void() {}
func (m *Foo) MyFunction(ctx context.Context, stringArg string) X {
return X{Message: stringArg}
}
```
```
$ echo '{foo{myFunction(stringArg: "hello"){message}}' | dagger query -m ".
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1813: Undefined type X.
``` | https://github.com/dagger/dagger/issues/5871 | https://github.com/dagger/dagger/pull/5893 | c847458d6df1e184487e3a29f6d00a86ef67e661 | b74df2479214020502fcb917d77325f00bd4d4e1 | 2023-10-11T10:50:42Z | go | 2023-10-18T12:22:03Z | core/integration/module_test.go | With(daggerQuery(`{myModule{myFunction(stringArg:"hello"){stdout}}}`)).
Stdout(ctx)
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) |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,871 | Zenith: custom return types require at least one method defined | Custom function return types require at least one empty method defined on them to be detected by codegen (note the JSON tags are currently required, #5860).
```go
// This is for a module "foo"
package main
import (
"context"
)
type Foo struct{}
type X struct {
Message string `json:"message"`
}
// This function definition is required, or we don't detect and incorporate this into schema generation.
// func (x *X) Void() {}
func (m *Foo) MyFunction(ctx context.Context, stringArg string) X {
return X{Message: stringArg}
}
```
```
$ echo '{foo{myFunction(stringArg: "hello"){message}}' | dagger query -m ".
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1813: Undefined type X.
``` | https://github.com/dagger/dagger/issues/5871 | https://github.com/dagger/dagger/pull/5893 | c847458d6df1e184487e3a29f6d00a86ef67e661 | b74df2479214020502fcb917d77325f00bd4d4e1 | 2023-10-11T10:50:42Z | go | 2023-10-18T12:22:03Z | core/integration/module_test.go | require.NoError(t, err)
require.Contains(t, generated, "module beneath-go-mod")
})
})
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"). |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,871 | Zenith: custom return types require at least one method defined | Custom function return types require at least one empty method defined on them to be detected by codegen (note the JSON tags are currently required, #5860).
```go
// This is for a module "foo"
package main
import (
"context"
)
type Foo struct{}
type X struct {
Message string `json:"message"`
}
// This function definition is required, or we don't detect and incorporate this into schema generation.
// func (x *X) Void() {}
func (m *Foo) MyFunction(ctx context.Context, stringArg string) X {
return X{Message: stringArg}
}
```
```
$ echo '{foo{myFunction(stringArg: "hello"){message}}' | dagger query -m ".
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1813: Undefined type X.
``` | https://github.com/dagger/dagger/issues/5871 | https://github.com/dagger/dagger/pull/5893 | c847458d6df1e184487e3a29f6d00a86ef67e661 | b74df2479214020502fcb917d77325f00bd4d4e1 | 2023-10-11T10:50:42Z | go | 2023-10-18T12:22:03Z | core/integration/module_test.go | WithExec([]string{"go", "mod", "init", "example.com/test"}).
WithNewFile("/work/foo.go", dagger.ContainerWithNewFileOpts{
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) |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,871 | Zenith: custom return types require at least one method defined | Custom function return types require at least one empty method defined on them to be detected by codegen (note the JSON tags are currently required, #5860).
```go
// This is for a module "foo"
package main
import (
"context"
)
type Foo struct{}
type X struct {
Message string `json:"message"`
}
// This function definition is required, or we don't detect and incorporate this into schema generation.
// func (x *X) Void() {}
func (m *Foo) MyFunction(ctx context.Context, stringArg string) X {
return X{Message: stringArg}
}
```
```
$ echo '{foo{myFunction(stringArg: "hello"){message}}' | dagger query -m ".
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1813: Undefined type X.
``` | https://github.com/dagger/dagger/issues/5871 | https://github.com/dagger/dagger/pull/5893 | c847458d6df1e184487e3a29f6d00a86ef67e661 | b74df2479214020502fcb917d77325f00bd4d4e1 | 2023-10-11T10:50:42Z | go | 2023-10-18T12:22:03Z | core/integration/module_test.go | childEntries, err := generated.Entries(ctx)
require.NoError(t, err)
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 { |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,871 | Zenith: custom return types require at least one method defined | Custom function return types require at least one empty method defined on them to be detected by codegen (note the JSON tags are currently required, #5860).
```go
// This is for a module "foo"
package main
import (
"context"
)
type Foo struct{}
type X struct {
Message string `json:"message"`
}
// This function definition is required, or we don't detect and incorporate this into schema generation.
// func (x *X) Void() {}
func (m *Foo) MyFunction(ctx context.Context, stringArg string) X {
return X{Message: stringArg}
}
```
```
$ echo '{foo{myFunction(stringArg: "hello"){message}}' | dagger query -m ".
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1813: Undefined type X.
``` | https://github.com/dagger/dagger/issues/5871 | https://github.com/dagger/dagger/pull/5893 | c847458d6df1e184487e3a29f6d00a86ef67e661 | b74df2479214020502fcb917d77325f00bd4d4e1 | 2023-10-11T10:50:42Z | go | 2023-10-18T12:22:03Z | core/integration/module_test.go | 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"]}}}`, 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: ` |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,871 | Zenith: custom return types require at least one method defined | Custom function return types require at least one empty method defined on them to be detected by codegen (note the JSON tags are currently required, #5860).
```go
// This is for a module "foo"
package main
import (
"context"
)
type Foo struct{}
type X struct {
Message string `json:"message"`
}
// This function definition is required, or we don't detect and incorporate this into schema generation.
// func (x *X) Void() {}
func (m *Foo) MyFunction(ctx context.Context, stringArg string) X {
return X{Message: stringArg}
}
```
```
$ echo '{foo{myFunction(stringArg: "hello"){message}}' | dagger query -m ".
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1813: Undefined type X.
``` | https://github.com/dagger/dagger/issues/5871 | https://github.com/dagger/dagger/pull/5893 | c847458d6df1e184487e3a29f6d00a86ef67e661 | b74df2479214020502fcb917d77325f00bd4d4e1 | 2023-10-11T10:50:42Z | go | 2023-10-18T12:22:03Z | core/integration/module_test.go | package main
type HasMainGo struct {}
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!"})
}
`,
}). |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,871 | Zenith: custom return types require at least one method defined | Custom function return types require at least one empty method defined on them to be detected by codegen (note the JSON tags are currently required, #5860).
```go
// This is for a module "foo"
package main
import (
"context"
)
type Foo struct{}
type X struct {
Message string `json:"message"`
}
// This function definition is required, or we don't detect and incorporate this into schema generation.
// func (x *X) Void() {}
func (m *Foo) MyFunction(ctx context.Context, stringArg string) X {
return X{Message: stringArg}
}
```
```
$ echo '{foo{myFunction(stringArg: "hello"){message}}' | dagger query -m ".
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1813: Undefined type X.
``` | https://github.com/dagger/dagger/issues/5871 | https://github.com/dagger/dagger/pull/5893 | c847458d6df1e184487e3a29f6d00a86ef67e661 | b74df2479214020502fcb917d77325f00bd4d4e1 | 2023-10-11T10:50:42Z | go | 2023-10-18T12:22:03Z | core/integration/module_test.go | With(daggerExec("mod", "init", "--name=hasDaggerTypes", "--sdk=go"))
logGen(ctx, t, modGen.Directory("."))
out, err := modGen.
With(daggerQuery(`{hasDaggerTypes{hello{stdout}}}`)).
Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"hasDaggerTypes":{"hello":{"stdout":"Hello, world!\n"}}}`, out)
})
t.Run("respects existing package without creating main.go", func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
WithNewFile("/work/notmain.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
type HasNotMainGo struct {}
func (m *HasNotMainGo) Hello() string { return "Hello, world!" }
`,
}).
With(daggerExec("mod", "init", "--name=hasNotMainGo", "--sdk=go"))
logGen(ctx, t, modGen.Directory("."))
out, err := modGen.
With(daggerQuery(`{hasNotMainGo{hello}}`)).
Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"hasNotMainGo":{"hello":"Hello, world!"}}`, out)
})
}
func TestModuleGoGit(t *testing.T) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,871 | Zenith: custom return types require at least one method defined | Custom function return types require at least one empty method defined on them to be detected by codegen (note the JSON tags are currently required, #5860).
```go
// This is for a module "foo"
package main
import (
"context"
)
type Foo struct{}
type X struct {
Message string `json:"message"`
}
// This function definition is required, or we don't detect and incorporate this into schema generation.
// func (x *X) Void() {}
func (m *Foo) MyFunction(ctx context.Context, stringArg string) X {
return X{Message: stringArg}
}
```
```
$ echo '{foo{myFunction(stringArg: "hello"){message}}' | dagger query -m ".
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1813: Undefined type X.
``` | https://github.com/dagger/dagger/issues/5871 | https://github.com/dagger/dagger/pull/5893 | c847458d6df1e184487e3a29f6d00a86ef67e661 | b74df2479214020502fcb917d77325f00bd4d4e1 | 2023-10-11T10:50:42Z | go | 2023-10-18T12:22:03Z | core/integration/module_test.go | t.Parallel()
c, ctx := connect(t)
modGen := goGitBase(t, c).
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("configures .gitignore", func(t *testing.T) {
ignore, err := modGen.File(".gitignore").Contents(ctx)
require.NoError(t, err)
require.Contains(t, ignore, "/dagger.gen.go\n")
require.Contains(t, ignore, "/internal/querybuilder/\n")
})
t.Run("configures .gitattributes", func(t *testing.T) {
t.Skip("it doesn't anymore, since it's .gitignored anyway")
attributes, err := modGen.File(".gitattributes").Contents(ctx)
require.NoError(t, err)
require.Contains(t, attributes, "/dagger.gen.go linguist-generated=true\n")
})
}
func TestModuleGoGitRemovesIgnored(t *testing.T) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,871 | Zenith: custom return types require at least one method defined | Custom function return types require at least one empty method defined on them to be detected by codegen (note the JSON tags are currently required, #5860).
```go
// This is for a module "foo"
package main
import (
"context"
)
type Foo struct{}
type X struct {
Message string `json:"message"`
}
// This function definition is required, or we don't detect and incorporate this into schema generation.
// func (x *X) Void() {}
func (m *Foo) MyFunction(ctx context.Context, stringArg string) X {
return X{Message: stringArg}
}
```
```
$ echo '{foo{myFunction(stringArg: "hello"){message}}' | dagger query -m ".
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1813: Undefined type X.
``` | https://github.com/dagger/dagger/issues/5871 | https://github.com/dagger/dagger/pull/5893 | c847458d6df1e184487e3a29f6d00a86ef67e661 | b74df2479214020502fcb917d77325f00bd4d4e1 | 2023-10-11T10:50:42Z | go | 2023-10-18T12:22:03Z | 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{"cp", "-a", "./internal/querybuilder", "./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")
}
var goSignatures string
func TestModuleGoSignatures(t *testing.T) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,871 | Zenith: custom return types require at least one method defined | Custom function return types require at least one empty method defined on them to be detected by codegen (note the JSON tags are currently required, #5860).
```go
// This is for a module "foo"
package main
import (
"context"
)
type Foo struct{}
type X struct {
Message string `json:"message"`
}
// This function definition is required, or we don't detect and incorporate this into schema generation.
// func (x *X) Void() {}
func (m *Foo) MyFunction(ctx context.Context, stringArg string) X {
return X{Message: stringArg}
}
```
```
$ echo '{foo{myFunction(stringArg: "hello"){message}}' | dagger query -m ".
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1813: Undefined type X.
``` | https://github.com/dagger/dagger/issues/5871 | https://github.com/dagger/dagger/pull/5893 | c847458d6df1e184487e3a29f6d00a86ef67e661 | b74df2479214020502fcb917d77325f00bd4d4e1 | 2023-10-11T10:50:42Z | go | 2023-10-18T12:22:03Z | 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)
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) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,871 | Zenith: custom return types require at least one method defined | Custom function return types require at least one empty method defined on them to be detected by codegen (note the JSON tags are currently required, #5860).
```go
// This is for a module "foo"
package main
import (
"context"
)
type Foo struct{}
type X struct {
Message string `json:"message"`
}
// This function definition is required, or we don't detect and incorporate this into schema generation.
// func (x *X) Void() {}
func (m *Foo) MyFunction(ctx context.Context, stringArg string) X {
return X{Message: stringArg}
}
```
```
$ echo '{foo{myFunction(stringArg: "hello"){message}}' | dagger query -m ".
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1813: Undefined type X.
``` | https://github.com/dagger/dagger/issues/5871 | https://github.com/dagger/dagger/pull/5893 | c847458d6df1e184487e3a29f6d00a86ef67e661 | b74df2479214020502fcb917d77325f00bd4d4e1 | 2023-10-11T10:50:42Z | go | 2023-10-18T12:22:03Z | core/integration/module_test.go | 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)
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) |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,871 | Zenith: custom return types require at least one method defined | Custom function return types require at least one empty method defined on them to be detected by codegen (note the JSON tags are currently required, #5860).
```go
// This is for a module "foo"
package main
import (
"context"
)
type Foo struct{}
type X struct {
Message string `json:"message"`
}
// This function definition is required, or we don't detect and incorporate this into schema generation.
// func (x *X) Void() {}
func (m *Foo) MyFunction(ctx context.Context, stringArg string) X {
return X{Message: stringArg}
}
```
```
$ echo '{foo{myFunction(stringArg: "hello"){message}}' | dagger query -m ".
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1813: Undefined type X.
``` | https://github.com/dagger/dagger/issues/5871 | https://github.com/dagger/dagger/pull/5893 | c847458d6df1e184487e3a29f6d00a86ef67e661 | b74df2479214020502fcb917d77325f00bd4d4e1 | 2023-10-11T10:50:42Z | go | 2023-10-18T12:22:03Z | core/integration/module_test.go | 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) {
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: goExtend,
})
logGen(ctx, t, modGen.Directory("."))
out, err := modGen.With(daggerQuery(`{container{from(address:"` + alpineImage + `"){echo(msg:"hi!")}}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"container":{"from":{"echo":"hi!\n"}}}`, out)
}
var customTypes string
func TestModuleGoCustomTypes(t *testing.T) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,871 | Zenith: custom return types require at least one method defined | Custom function return types require at least one empty method defined on them to be detected by codegen (note the JSON tags are currently required, #5860).
```go
// This is for a module "foo"
package main
import (
"context"
)
type Foo struct{}
type X struct {
Message string `json:"message"`
}
// This function definition is required, or we don't detect and incorporate this into schema generation.
// func (x *X) Void() {}
func (m *Foo) MyFunction(ctx context.Context, stringArg string) X {
return X{Message: stringArg}
}
```
```
$ echo '{foo{myFunction(stringArg: "hello"){message}}' | dagger query -m ".
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1813: Undefined type X.
``` | https://github.com/dagger/dagger/issues/5871 | https://github.com/dagger/dagger/pull/5893 | c847458d6df1e184487e3a29f6d00a86ef67e661 | b74df2479214020502fcb917d77325f00bd4d4e1 | 2023-10-11T10:50:42Z | go | 2023-10-18T12:22:03Z | 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)
}
var useInner string
var useOuter string
func TestModuleGoUseLocal(t *testing.T) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,871 | Zenith: custom return types require at least one method defined | Custom function return types require at least one empty method defined on them to be detected by codegen (note the JSON tags are currently required, #5860).
```go
// This is for a module "foo"
package main
import (
"context"
)
type Foo struct{}
type X struct {
Message string `json:"message"`
}
// This function definition is required, or we don't detect and incorporate this into schema generation.
// func (x *X) Void() {}
func (m *Foo) MyFunction(ctx context.Context, stringArg string) X {
return X{Message: stringArg}
}
```
```
$ echo '{foo{myFunction(stringArg: "hello"){message}}' | dagger query -m ".
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1813: Undefined type X.
``` | https://github.com/dagger/dagger/issues/5871 | https://github.com/dagger/dagger/pull/5893 | c847458d6df1e184487e3a29f6d00a86ef67e661 | b74df2479214020502fcb917d77325f00bd4d4e1 | 2023-10-11T10:50:42Z | go | 2023-10-18T12:22:03Z | 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,871 | Zenith: custom return types require at least one method defined | Custom function return types require at least one empty method defined on them to be detected by codegen (note the JSON tags are currently required, #5860).
```go
// This is for a module "foo"
package main
import (
"context"
)
type Foo struct{}
type X struct {
Message string `json:"message"`
}
// This function definition is required, or we don't detect and incorporate this into schema generation.
// func (x *X) Void() {}
func (m *Foo) MyFunction(ctx context.Context, stringArg string) X {
return X{Message: stringArg}
}
```
```
$ echo '{foo{myFunction(stringArg: "hello"){message}}' | dagger query -m ".
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1813: Undefined type X.
``` | https://github.com/dagger/dagger/issues/5871 | https://github.com/dagger/dagger/pull/5893 | c847458d6df1e184487e3a29f6d00a86ef67e661 | b74df2479214020502fcb917d77325f00bd4d4e1 | 2023-10-11T10:50:42Z | go | 2023-10-18T12:22:03Z | 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,871 | Zenith: custom return types require at least one method defined | Custom function return types require at least one empty method defined on them to be detected by codegen (note the JSON tags are currently required, #5860).
```go
// This is for a module "foo"
package main
import (
"context"
)
type Foo struct{}
type X struct {
Message string `json:"message"`
}
// This function definition is required, or we don't detect and incorporate this into schema generation.
// func (x *X) Void() {}
func (m *Foo) MyFunction(ctx context.Context, stringArg string) X {
return X{Message: stringArg}
}
```
```
$ echo '{foo{myFunction(stringArg: "hello"){message}}' | dagger query -m ".
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1813: Undefined type X.
``` | https://github.com/dagger/dagger/issues/5871 | https://github.com/dagger/dagger/pull/5893 | c847458d6df1e184487e3a29f6d00a86ef67e661 | b74df2479214020502fcb917d77325f00bd4d4e1 | 2023-10-11T10:50:42Z | go | 2023-10-18T12:22:03Z | 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,871 | Zenith: custom return types require at least one method defined | Custom function return types require at least one empty method defined on them to be detected by codegen (note the JSON tags are currently required, #5860).
```go
// This is for a module "foo"
package main
import (
"context"
)
type Foo struct{}
type X struct {
Message string `json:"message"`
}
// This function definition is required, or we don't detect and incorporate this into schema generation.
// func (x *X) Void() {}
func (m *Foo) MyFunction(ctx context.Context, stringArg string) X {
return X{Message: stringArg}
}
```
```
$ echo '{foo{myFunction(stringArg: "hello"){message}}' | dagger query -m ".
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1813: Undefined type X.
``` | https://github.com/dagger/dagger/issues/5871 | https://github.com/dagger/dagger/pull/5893 | c847458d6df1e184487e3a29f6d00a86ef67e661 | b74df2479214020502fcb917d77325f00bd4d4e1 | 2023-10-11T10:50:42Z | go | 2023-10-18T12:22:03Z | 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,871 | Zenith: custom return types require at least one method defined | Custom function return types require at least one empty method defined on them to be detected by codegen (note the JSON tags are currently required, #5860).
```go
// This is for a module "foo"
package main
import (
"context"
)
type Foo struct{}
type X struct {
Message string `json:"message"`
}
// This function definition is required, or we don't detect and incorporate this into schema generation.
// func (x *X) Void() {}
func (m *Foo) MyFunction(ctx context.Context, stringArg string) X {
return X{Message: stringArg}
}
```
```
$ echo '{foo{myFunction(stringArg: "hello"){message}}' | dagger query -m ".
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1813: Undefined type X.
``` | https://github.com/dagger/dagger/issues/5871 | https://github.com/dagger/dagger/pull/5893 | c847458d6df1e184487e3a29f6d00a86ef67e661 | b74df2479214020502fcb917d77325f00bd4d4e1 | 2023-10-11T10:50:42Z | go | 2023-10-18T12:22:03Z | 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 TestModulePython(t *testing.T) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,871 | Zenith: custom return types require at least one method defined | Custom function return types require at least one empty method defined on them to be detected by codegen (note the JSON tags are currently required, #5860).
```go
// This is for a module "foo"
package main
import (
"context"
)
type Foo struct{}
type X struct {
Message string `json:"message"`
}
// This function definition is required, or we don't detect and incorporate this into schema generation.
// func (x *X) Void() {}
func (m *Foo) MyFunction(ctx context.Context, stringArg string) X {
return X{Message: stringArg}
}
```
```
$ echo '{foo{myFunction(stringArg: "hello"){message}}' | dagger query -m ".
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1813: Undefined type X.
``` | https://github.com/dagger/dagger/issues/5871 | https://github.com/dagger/dagger/pull/5893 | c847458d6df1e184487e3a29f6d00a86ef67e661 | b74df2479214020502fcb917d77325f00bd4d4e1 | 2023-10-11T10:50:42Z | go | 2023-10-18T12:22:03Z | core/integration/module_test.go | t.Parallel()
c, ctx := connect(t)
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
WithNewFile("./pyproject.toml", dagger.ContainerWithNewFileOpts{
Contents: `[project]
name = "test"
version = "0.0.0"
`,
}).
WithNewFile("./src/main.py", dagger.ContainerWithNewFileOpts{
Contents: `from dagger.ext import function
@function
def hello(name: str) -> str:
"""Say hello to someone."""
return f"Hello, {name}!"
`,
}).
With(daggerExec("mod", "init", "--name=test", "--sdk=python"))
t.Run("func Hello() string", func(t *testing.T) {
t.Parallel()
out, err := modGen.With(daggerQuery(`{test{hello(name: "there")}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"test":{"hello":"Hello, there!"}}`, out)
})
}
func TestEnvCmd(t *testing.T) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,871 | Zenith: custom return types require at least one method defined | Custom function return types require at least one empty method defined on them to be detected by codegen (note the JSON tags are currently required, #5860).
```go
// This is for a module "foo"
package main
import (
"context"
)
type Foo struct{}
type X struct {
Message string `json:"message"`
}
// This function definition is required, or we don't detect and incorporate this into schema generation.
// func (x *X) Void() {}
func (m *Foo) MyFunction(ctx context.Context, stringArg string) X {
return X{Message: stringArg}
}
```
```
$ echo '{foo{myFunction(stringArg: "hello"){message}}' | dagger query -m ".
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1813: Undefined type X.
``` | https://github.com/dagger/dagger/issues/5871 | https://github.com/dagger/dagger/pull/5893 | c847458d6df1e184487e3a29f6d00a86ef67e661 | b74df2479214020502fcb917d77325f00bd4d4e1 | 2023-10-11T10:50:42Z | go | 2023-10-18T12:22:03Z | core/integration/module_test.go | t.Skip("pending conversion to modules")
t.Parallel()
type testCase struct {
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,871 | Zenith: custom return types require at least one method defined | Custom function return types require at least one empty method defined on them to be detected by codegen (note the JSON tags are currently required, #5860).
```go
// This is for a module "foo"
package main
import (
"context"
)
type Foo struct{}
type X struct {
Message string `json:"message"`
}
// This function definition is required, or we don't detect and incorporate this into schema generation.
// func (x *X) Void() {}
func (m *Foo) MyFunction(ctx context.Context, stringArg string) X {
return X{Message: stringArg}
}
```
```
$ echo '{foo{myFunction(stringArg: "hello"){message}}' | dagger query -m ".
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1813: Undefined type X.
``` | https://github.com/dagger/dagger/issues/5871 | https://github.com/dagger/dagger/pull/5893 | c847458d6df1e184487e3a29f6d00a86ef67e661 | b74df2479214020502fcb917d77325f00bd4d4e1 | 2023-10-11T10:50:42Z | go | 2023-10-18T12:22:03Z | 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,871 | Zenith: custom return types require at least one method defined | Custom function return types require at least one empty method defined on them to be detected by codegen (note the JSON tags are currently required, #5860).
```go
// This is for a module "foo"
package main
import (
"context"
)
type Foo struct{}
type X struct {
Message string `json:"message"`
}
// This function definition is required, or we don't detect and incorporate this into schema generation.
// func (x *X) Void() {}
func (m *Foo) MyFunction(ctx context.Context, stringArg string) X {
return X{Message: stringArg}
}
```
```
$ echo '{foo{myFunction(stringArg: "hello"){message}}' | dagger query -m ".
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1813: Undefined type X.
``` | https://github.com/dagger/dagger/issues/5871 | https://github.com/dagger/dagger/pull/5893 | c847458d6df1e184487e3a29f6d00a86ef67e661 | b74df2479214020502fcb917d77325f00bd4d4e1 | 2023-10-11T10:50:42Z | go | 2023-10-18T12:22:03Z | 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",
}, |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,871 | Zenith: custom return types require at least one method defined | Custom function return types require at least one empty method defined on them to be detected by codegen (note the JSON tags are currently required, #5860).
```go
// This is for a module "foo"
package main
import (
"context"
)
type Foo struct{}
type X struct {
Message string `json:"message"`
}
// This function definition is required, or we don't detect and incorporate this into schema generation.
// func (x *X) Void() {}
func (m *Foo) MyFunction(ctx context.Context, stringArg string) X {
return X{Message: stringArg}
}
```
```
$ echo '{foo{myFunction(stringArg: "hello"){message}}' | dagger query -m ".
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1813: Undefined type X.
``` | https://github.com/dagger/dagger/issues/5871 | https://github.com/dagger/dagger/pull/5893 | c847458d6df1e184487e3a29f6d00a86ef67e661 | b74df2479214020502fcb917d77325f00bd4d4e1 | 2023-10-11T10:50:42Z | go | 2023-10-18T12:22:03Z | core/integration/module_test.go | {
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",
},
{
testName: "dagger checks/" + ctr.EnvArg,
cmdCtr: ctr.CallChecks(),
expectedOutput: "Usage:\n dagger checks",
},
} {
tc := tc
t.Run(tc.testName, func(t *testing.T) {
t.Parallel()
stdout, err := tc.cmdCtr.Stdout(ctx)
require.NoError(t, err)
require.Contains(t, stdout, tc.expectedOutput)
})
}
}
}
func TestEnvCmdInit(t *testing.T) {
t.Skip("pending conversion to modules")
t.Parallel()
type testCase struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,871 | Zenith: custom return types require at least one method defined | Custom function return types require at least one empty method defined on them to be detected by codegen (note the JSON tags are currently required, #5860).
```go
// This is for a module "foo"
package main
import (
"context"
)
type Foo struct{}
type X struct {
Message string `json:"message"`
}
// This function definition is required, or we don't detect and incorporate this into schema generation.
// func (x *X) Void() {}
func (m *Foo) MyFunction(ctx context.Context, stringArg string) X {
return X{Message: stringArg}
}
```
```
$ echo '{foo{myFunction(stringArg: "hello"){message}}' | dagger query -m ".
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1813: Undefined type X.
``` | https://github.com/dagger/dagger/issues/5871 | https://github.com/dagger/dagger/pull/5893 | c847458d6df1e184487e3a29f6d00a86ef67e661 | b74df2479214020502fcb917d77325f00bd4d4e1 | 2023-10-11T10:50:42Z | go | 2023-10-18T12:22:03Z | core/integration/module_test.go | testName string
environmentPath string
sdk string
name string
root string
expectedErrorMessage string
}
for _, tc := range []testCase{
{
testName: "explicit environment dir/go",
environmentPath: "/var/testenvironment/subdir",
sdk: "go",
name: identity.NewID(),
root: "../",
},
{
testName: "explicit environment dir/python",
environmentPath: "/var/testenvironment/subdir",
sdk: "python",
name: identity.NewID(),
root: "../..",
},
{
testName: "explicit environment file", |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,871 | Zenith: custom return types require at least one method defined | Custom function return types require at least one empty method defined on them to be detected by codegen (note the JSON tags are currently required, #5860).
```go
// This is for a module "foo"
package main
import (
"context"
)
type Foo struct{}
type X struct {
Message string `json:"message"`
}
// This function definition is required, or we don't detect and incorporate this into schema generation.
// func (x *X) Void() {}
func (m *Foo) MyFunction(ctx context.Context, stringArg string) X {
return X{Message: stringArg}
}
```
```
$ echo '{foo{myFunction(stringArg: "hello"){message}}' | dagger query -m ".
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1813: Undefined type X.
``` | https://github.com/dagger/dagger/issues/5871 | https://github.com/dagger/dagger/pull/5893 | c847458d6df1e184487e3a29f6d00a86ef67e661 | b74df2479214020502fcb917d77325f00bd4d4e1 | 2023-10-11T10:50:42Z | go | 2023-10-18T12:22:03Z | core/integration/module_test.go | environmentPath: "/var/testenvironment/subdir/dagger.json",
sdk: "python",
name: identity.NewID(),
},
{
testName: "implicit environment",
sdk: "go",
name: identity.NewID(),
},
{
testName: "implicit environment with root",
environmentPath: "/var/testenvironment",
sdk: "python",
name: identity.NewID(),
root: "..",
},
{
testName: "invalid sdk",
environmentPath: "/var/testenvironment",
sdk: "c++--",
name: identity.NewID(),
expectedErrorMessage: "unsupported environment SDK",
},
{
testName: "error on git",
environmentPath: "git://github.com/dagger/dagger.git",
sdk: "go",
name: identity.NewID(),
expectedErrorMessage: "environment init is not supported for git environments",
}, |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,871 | Zenith: custom return types require at least one method defined | Custom function return types require at least one empty method defined on them to be detected by codegen (note the JSON tags are currently required, #5860).
```go
// This is for a module "foo"
package main
import (
"context"
)
type Foo struct{}
type X struct {
Message string `json:"message"`
}
// This function definition is required, or we don't detect and incorporate this into schema generation.
// func (x *X) Void() {}
func (m *Foo) MyFunction(ctx context.Context, stringArg string) X {
return X{Message: stringArg}
}
```
```
$ echo '{foo{myFunction(stringArg: "hello"){message}}' | dagger query -m ".
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1813: Undefined type X.
``` | https://github.com/dagger/dagger/issues/5871 | https://github.com/dagger/dagger/pull/5893 | c847458d6df1e184487e3a29f6d00a86ef67e661 | b74df2479214020502fcb917d77325f00bd4d4e1 | 2023-10-11T10:50:42Z | go | 2023-10-18T12:22:03Z | core/integration/module_test.go | } {
tc := tc
t.Run(tc.testName, func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
ctr := CLITestContainer(ctx, t, c).
WithEnvArg(tc.environmentPath).
WithSDKArg(tc.sdk).
WithNameArg(tc.name).
CallEnvInit()
if tc.expectedErrorMessage != "" {
_, err := ctr.Sync(ctx)
require.ErrorContains(t, err, tc.expectedErrorMessage)
return
}
expectedConfigPath := tc.environmentPath
if !strings.HasSuffix(expectedConfigPath, "dagger.json") {
expectedConfigPath = filepath.Join(expectedConfigPath, "dagger.json")
}
_, err := ctr.File(expectedConfigPath).Contents(ctx)
require.NoError(t, err)
if tc.sdk == "go" {
codegenFile := filepath.Join(filepath.Dir(expectedConfigPath), "dagger.gen.go")
_, err := ctr.File(codegenFile).Contents(ctx)
require.NoError(t, err)
}
stderr, err := ctr.CallEnv().Stderr(ctx)
require.NoError(t, err)
require.Contains(t, stderr, fmt.Sprintf(`"name": %q`, tc.name)) |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,871 | Zenith: custom return types require at least one method defined | Custom function return types require at least one empty method defined on them to be detected by codegen (note the JSON tags are currently required, #5860).
```go
// This is for a module "foo"
package main
import (
"context"
)
type Foo struct{}
type X struct {
Message string `json:"message"`
}
// This function definition is required, or we don't detect and incorporate this into schema generation.
// func (x *X) Void() {}
func (m *Foo) MyFunction(ctx context.Context, stringArg string) X {
return X{Message: stringArg}
}
```
```
$ echo '{foo{myFunction(stringArg: "hello"){message}}' | dagger query -m ".
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1813: Undefined type X.
``` | https://github.com/dagger/dagger/issues/5871 | https://github.com/dagger/dagger/pull/5893 | c847458d6df1e184487e3a29f6d00a86ef67e661 | b74df2479214020502fcb917d77325f00bd4d4e1 | 2023-10-11T10:50:42Z | go | 2023-10-18T12:22:03Z | core/integration/module_test.go | require.Contains(t, stderr, fmt.Sprintf(`"sdk": %q`, tc.sdk))
})
}
t.Run("error on existing environment", func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
_, err := CLITestContainer(ctx, t, c).
WithLoadedEnv("core/integration/testdata/environments/go/basic", false).
WithSDKArg("go").
WithNameArg("foo").
CallEnvInit().
Sync(ctx)
require.ErrorContains(t, err, "environment init config path already exists")
})
}
func TestEnvChecks(t *testing.T) {
t.Skip("pending conversion to modules")
t.Parallel()
allChecks := []string{
"cool-static-check",
"sad-static-check",
"cool-container-check",
"sad-container-check",
"cool-composite-check",
"sad-composite-check",
"another-cool-static-check",
"another-sad-static-check",
"cool-composite-check-from-explicit-dep",
"sad-composite-check-from-explicit-dep",
"cool-composite-check-from-dynamic-dep", |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,871 | Zenith: custom return types require at least one method defined | Custom function return types require at least one empty method defined on them to be detected by codegen (note the JSON tags are currently required, #5860).
```go
// This is for a module "foo"
package main
import (
"context"
)
type Foo struct{}
type X struct {
Message string `json:"message"`
}
// This function definition is required, or we don't detect and incorporate this into schema generation.
// func (x *X) Void() {}
func (m *Foo) MyFunction(ctx context.Context, stringArg string) X {
return X{Message: stringArg}
}
```
```
$ echo '{foo{myFunction(stringArg: "hello"){message}}' | dagger query -m ".
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1813: Undefined type X.
``` | https://github.com/dagger/dagger/issues/5871 | https://github.com/dagger/dagger/pull/5893 | c847458d6df1e184487e3a29f6d00a86ef67e661 | b74df2479214020502fcb917d77325f00bd4d4e1 | 2023-10-11T10:50:42Z | go | 2023-10-18T12:22:03Z | core/integration/module_test.go | "sad-composite-check-from-dynamic-dep",
"cool-check-only-return",
"cool-check-result-only-return",
"cool-string-only-return",
"cool-error-only-return",
"sad-error-only-return",
"cool-string-error-return",
"sad-string-error-return",
}
compositeCheckToSubcheckNames := map[string][]string{
"cool-composite-check": {
"cool-subcheck-a",
"cool-subcheck-b",
},
"sad-composite-check": {
"sad-subcheck-a",
"sad-subcheck-b",
},
"cool-composite-check-from-explicit-dep": {
"another-cool-static-check",
"another-cool-container-check",
"another-cool-composite-check",
},
"sad-composite-check-from-explicit-dep": {
"another-sad-static-check",
"another-sad-container-check",
"another-sad-composite-check",
},
"cool-composite-check-from-dynamic-dep": {
"yet-another-cool-static-check", |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,871 | Zenith: custom return types require at least one method defined | Custom function return types require at least one empty method defined on them to be detected by codegen (note the JSON tags are currently required, #5860).
```go
// This is for a module "foo"
package main
import (
"context"
)
type Foo struct{}
type X struct {
Message string `json:"message"`
}
// This function definition is required, or we don't detect and incorporate this into schema generation.
// func (x *X) Void() {}
func (m *Foo) MyFunction(ctx context.Context, stringArg string) X {
return X{Message: stringArg}
}
```
```
$ echo '{foo{myFunction(stringArg: "hello"){message}}' | dagger query -m ".
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1813: Undefined type X.
``` | https://github.com/dagger/dagger/issues/5871 | https://github.com/dagger/dagger/pull/5893 | c847458d6df1e184487e3a29f6d00a86ef67e661 | b74df2479214020502fcb917d77325f00bd4d4e1 | 2023-10-11T10:50:42Z | go | 2023-10-18T12:22:03Z | core/integration/module_test.go | "yet-another-cool-container-check",
"yet-another-cool-composite-check",
},
"sad-composite-check-from-dynamic-dep": {
"yet-another-sad-static-check",
"yet-another-sad-container-check",
"yet-another-sad-composite-check",
},
"another-cool-composite-check": {
"another-cool-subcheck-a",
"another-cool-subcheck-b",
},
"another-sad-composite-check": {
"another-sad-subcheck-a",
"another-sad-subcheck-b",
},
"yet-another-cool-composite-check": {
"yet-another-cool-subcheck-a",
"yet-another-cool-subcheck-b",
},
"yet-another-sad-composite-check": {
"yet-another-sad-subcheck-a",
"yet-another-sad-subcheck-b",
},
}
checkOutput := func(name string) string {
return "WE ARE RUNNING CHECK " + strcase.ToKebab(name)
}
type testCase struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,871 | Zenith: custom return types require at least one method defined | Custom function return types require at least one empty method defined on them to be detected by codegen (note the JSON tags are currently required, #5860).
```go
// This is for a module "foo"
package main
import (
"context"
)
type Foo struct{}
type X struct {
Message string `json:"message"`
}
// This function definition is required, or we don't detect and incorporate this into schema generation.
// func (x *X) Void() {}
func (m *Foo) MyFunction(ctx context.Context, stringArg string) X {
return X{Message: stringArg}
}
```
```
$ echo '{foo{myFunction(stringArg: "hello"){message}}' | dagger query -m ".
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1813: Undefined type X.
``` | https://github.com/dagger/dagger/issues/5871 | https://github.com/dagger/dagger/pull/5893 | c847458d6df1e184487e3a29f6d00a86ef67e661 | b74df2479214020502fcb917d77325f00bd4d4e1 | 2023-10-11T10:50:42Z | go | 2023-10-18T12:22:03Z | core/integration/module_test.go | name string
environmentPath string
selectedChecks []string
expectFailure bool
}
for _, tc := range []testCase{
{
name: "happy-path",
environmentPath: "core/integration/testdata/environments/go/basic",
selectedChecks: []string{
"cool-static-check",
"cool-container-check",
"cool-composite-check",
"another-cool-static-check",
"cool-composite-check-from-explicit-dep",
"cool-composite-check-from-dynamic-dep",
"cool-check-only-return",
"cool-check-result-only-return",
"cool-string-only-return",
"cool-error-only-return",
"cool-string-error-return",
},
},
{
name: "sad-path",
expectFailure: true,
environmentPath: "core/integration/testdata/environments/go/basic", |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,871 | Zenith: custom return types require at least one method defined | Custom function return types require at least one empty method defined on them to be detected by codegen (note the JSON tags are currently required, #5860).
```go
// This is for a module "foo"
package main
import (
"context"
)
type Foo struct{}
type X struct {
Message string `json:"message"`
}
// This function definition is required, or we don't detect and incorporate this into schema generation.
// func (x *X) Void() {}
func (m *Foo) MyFunction(ctx context.Context, stringArg string) X {
return X{Message: stringArg}
}
```
```
$ echo '{foo{myFunction(stringArg: "hello"){message}}' | dagger query -m ".
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1813: Undefined type X.
``` | https://github.com/dagger/dagger/issues/5871 | https://github.com/dagger/dagger/pull/5893 | c847458d6df1e184487e3a29f6d00a86ef67e661 | b74df2479214020502fcb917d77325f00bd4d4e1 | 2023-10-11T10:50:42Z | go | 2023-10-18T12:22:03Z | core/integration/module_test.go | selectedChecks: []string{
"sad-static-check",
"sad-container-check",
"sad-composite-check",
"another-sad-static-check",
"sad-composite-check-from-explicit-dep",
"sad-composite-check-from-dynamic-dep",
"sad-error-only-return",
"sad-string-error-return",
},
},
{
name: "mixed-path",
expectFailure: true,
environmentPath: "core/integration/testdata/environments/go/basic",
},
} {
tc := tc
for _, testGitEnv := range []bool{false, true} {
testGitEnv := testGitEnv
testName := tc.name
testName += "/gitenv=" + strconv.FormatBool(testGitEnv)
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).
CallChecks(tc.selectedChecks...). |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,871 | Zenith: custom return types require at least one method defined | Custom function return types require at least one empty method defined on them to be detected by codegen (note the JSON tags are currently required, #5860).
```go
// This is for a module "foo"
package main
import (
"context"
)
type Foo struct{}
type X struct {
Message string `json:"message"`
}
// This function definition is required, or we don't detect and incorporate this into schema generation.
// func (x *X) Void() {}
func (m *Foo) MyFunction(ctx context.Context, stringArg string) X {
return X{Message: stringArg}
}
```
```
$ echo '{foo{myFunction(stringArg: "hello"){message}}' | dagger query -m ".
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1813: Undefined type X.
``` | https://github.com/dagger/dagger/issues/5871 | https://github.com/dagger/dagger/pull/5893 | c847458d6df1e184487e3a29f6d00a86ef67e661 | b74df2479214020502fcb917d77325f00bd4d4e1 | 2023-10-11T10:50:42Z | go | 2023-10-18T12:22:03Z | core/integration/module_test.go | Stderr(ctx)
if tc.expectFailure {
require.Error(t, err)
execErr := new(dagger.ExecError)
require.True(t, errors.As(err, &execErr))
stderr = execErr.Stderr
} else {
require.NoError(t, err)
}
selectedChecks := tc.selectedChecks
if len(selectedChecks) == 0 {
selectedChecks = allChecks
}
curChecks := selectedChecks
for len(curChecks) > 0 {
var nextChecks []string
for _, checkName := range curChecks {
subChecks, ok := compositeCheckToSubcheckNames[checkName]
if ok {
nextChecks = append(nextChecks, subChecks...)
} else {
if checkName == "cool-error-only-return" {
continue
}
require.Contains(t, stderr, checkOutput(checkName))
}
}
curChecks = nextChecks
} |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,871 | Zenith: custom return types require at least one method defined | Custom function return types require at least one empty method defined on them to be detected by codegen (note the JSON tags are currently required, #5860).
```go
// This is for a module "foo"
package main
import (
"context"
)
type Foo struct{}
type X struct {
Message string `json:"message"`
}
// This function definition is required, or we don't detect and incorporate this into schema generation.
// func (x *X) Void() {}
func (m *Foo) MyFunction(ctx context.Context, stringArg string) X {
return X{Message: stringArg}
}
```
```
$ echo '{foo{myFunction(stringArg: "hello"){message}}' | dagger query -m ".
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1813: Undefined type X.
``` | https://github.com/dagger/dagger/issues/5871 | https://github.com/dagger/dagger/pull/5893 | c847458d6df1e184487e3a29f6d00a86ef67e661 | b74df2479214020502fcb917d77325f00bd4d4e1 | 2023-10-11T10:50:42Z | go | 2023-10-18T12:22:03Z | core/integration/module_test.go | })
}
}
}
func daggerExec(args ...string) dagger.WithContainerFunc {
return func(c *dagger.Container) *dagger.Container {
return c.WithExec(append([]string{"dagger", "--debug"}, args...), dagger.ContainerWithExecOpts{
ExperimentalPrivilegedNesting: true,
})
}
}
func daggerQuery(query string) dagger.WithContainerFunc {
return func(c *dagger.Container) *dagger.Container {
return c.WithExec([]string{"dagger", "--debug", "query"}, dagger.ContainerWithExecOpts{
Stdin: query,
ExperimentalPrivilegedNesting: true,
})
}
}
func goGitBase(t *testing.T, c *dagger.Client) *dagger.Container {
t.Helper()
return c.Container().From(golangImage).
WithExec([]string{"apk", "add", "git"}).
WithExec([]string{"git", "config", "--global", "user.email", "dagger@example.com"}).
WithExec([]string{"git", "config", "--global", "user.name", "Dagger Tests"}).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
WithExec([]string{"git", "init"})
}
func logGen(ctx context.Context, t *testing.T, modSrc *dagger.Directory) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,871 | Zenith: custom return types require at least one method defined | Custom function return types require at least one empty method defined on them to be detected by codegen (note the JSON tags are currently required, #5860).
```go
// This is for a module "foo"
package main
import (
"context"
)
type Foo struct{}
type X struct {
Message string `json:"message"`
}
// This function definition is required, or we don't detect and incorporate this into schema generation.
// func (x *X) Void() {}
func (m *Foo) MyFunction(ctx context.Context, stringArg string) X {
return X{Message: stringArg}
}
```
```
$ echo '{foo{myFunction(stringArg: "hello"){message}}' | dagger query -m ".
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1813: Undefined type X.
``` | https://github.com/dagger/dagger/issues/5871 | https://github.com/dagger/dagger/pull/5893 | c847458d6df1e184487e3a29f6d00a86ef67e661 | b74df2479214020502fcb917d77325f00bd4d4e1 | 2023-10-11T10:50:42Z | go | 2023-10-18T12:22:03Z | core/integration/module_test.go | t.Helper()
generated, err := modSrc.File("dagger.gen.go").Contents(ctx)
require.NoError(t, err)
t.Cleanup(func() {
t.Name()
fileName := filepath.Join(
os.TempDir(),
t.Name(),
fmt.Sprintf("dagger.gen.%d.go", time.Now().Unix()),
)
if err := os.MkdirAll(filepath.Dir(fileName), 0o755); err != nil {
t.Logf("failed to create temp dir for generated code: %v", err)
return
}
if err := os.WriteFile(fileName, []byte(generated), 0644); err != nil {
t.Logf("failed to write generated code to %s: %v", fileName, err)
} else {
t.Logf("wrote generated code to %s", fileName)
}
})
} |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,917 | ci: use separate cache mounts for different python versions | We are getting flaky pip cache errors like https://github.com/dagger/dagger/actions/runs/6552195369/job/17794987073#step:4:1007
@helderco suggested it may be due to separate python versions being used in parallel on the same cache mount: https://github.com/dagger/dagger/pull/5906#issuecomment-1767391090
(I'll squash this quick since the flakes are quite annoying; just filing issue since I'm currently squashing something else and don't want to forget) | https://github.com/dagger/dagger/issues/5917 | https://github.com/dagger/dagger/pull/5919 | d6b3585f481dba441b77f521fd2b094e483b31c7 | 7560f6ec3e061c94adcb75740124c670cd4d07c7 | 2023-10-18T21:04:46Z | go | 2023-10-19T02:21:32Z | internal/mage/sdk/python.go | package sdk
import (
"context"
"errors"
"fmt"
"os"
"strings"
"github.com/dagger/dagger/internal/mage/util"
"dagger.io/dagger"
"github.com/magefile/mage/mg"
"golang.org/x/sync/errgroup"
)
var (
pythonGeneratedAPIPath = "sdk/python/src/dagger/client/gen.py"
pythonDefaultVersion = "3.11"
) |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,917 | ci: use separate cache mounts for different python versions | We are getting flaky pip cache errors like https://github.com/dagger/dagger/actions/runs/6552195369/job/17794987073#step:4:1007
@helderco suggested it may be due to separate python versions being used in parallel on the same cache mount: https://github.com/dagger/dagger/pull/5906#issuecomment-1767391090
(I'll squash this quick since the flakes are quite annoying; just filing issue since I'm currently squashing something else and don't want to forget) | https://github.com/dagger/dagger/issues/5917 | https://github.com/dagger/dagger/pull/5919 | d6b3585f481dba441b77f521fd2b094e483b31c7 | 7560f6ec3e061c94adcb75740124c670cd4d07c7 | 2023-10-18T21:04:46Z | go | 2023-10-19T02:21:32Z | internal/mage/sdk/python.go | var _ SDK = Python{}
type Python mg.Namespace
func (t Python) Lint(ctx context.Context) error {
c, err := dagger.Connect(ctx, dagger.WithLogOutput(os.Stderr))
if err != nil {
return err
}
defer c.Close()
c = c.Pipeline("sdk").Pipeline("python").Pipeline("lint")
eg, gctx := errgroup.WithContext(ctx)
base := pythonBase(c, pythonDefaultVersion)
eg.Go(func() error {
path := "docs/current"
_, err = base.
WithDirectory(
fmt.Sprintf("/%s", path),
util.Repository(c).Directory(path),
dagger.ContainerWithDirectoryOpts{
Include: []string{
"**/*.py",
".ruff.toml",
},
},
).
WithExec([]string{"hatch", "run", "lint"}).
Sync(gctx)
return err
})
eg.Go(func() error {
return lintGeneratedCode(func() error { |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,917 | ci: use separate cache mounts for different python versions | We are getting flaky pip cache errors like https://github.com/dagger/dagger/actions/runs/6552195369/job/17794987073#step:4:1007
@helderco suggested it may be due to separate python versions being used in parallel on the same cache mount: https://github.com/dagger/dagger/pull/5906#issuecomment-1767391090
(I'll squash this quick since the flakes are quite annoying; just filing issue since I'm currently squashing something else and don't want to forget) | https://github.com/dagger/dagger/issues/5917 | https://github.com/dagger/dagger/pull/5919 | d6b3585f481dba441b77f521fd2b094e483b31c7 | 7560f6ec3e061c94adcb75740124c670cd4d07c7 | 2023-10-18T21:04:46Z | go | 2023-10-19T02:21:32Z | internal/mage/sdk/python.go | return t.Generate(gctx)
}, pythonGeneratedAPIPath)
})
return eg.Wait()
}
func (t Python) Test(ctx context.Context) error {
c, err := dagger.Connect(ctx, dagger.WithLogOutput(os.Stderr))
if err != nil {
return err
}
defer c.Close()
c = c.Pipeline("sdk").Pipeline("python").Pipeline("test")
versions := []string{"3.10", "3.11"}
devEngine, endpoint, err := util.CIDevEngineContainerAndEndpoint(ctx, c.Pipeline("dev-engine"), util.DevEngineOpts{Name: "sdk-python-test"})
if err != nil {
return err
}
cliBinPath := "/.dagger-cli"
eg, gctx := errgroup.WithContext(ctx)
for _, version := range versions {
version := version
c := c.Pipeline(version)
base := pythonBase(c, version)
eg.Go(func() error {
_, err := base.
WithServiceBinding("dagger-engine", devEngine).
WithEnvVariable("_EXPERIMENTAL_DAGGER_RUNNER_HOST", endpoint).
WithMountedFile(cliBinPath, util.DaggerBinary(c)).
WithEnvVariable("_EXPERIMENTAL_DAGGER_CLI_BIN", cliBinPath).
WithExec([]string{"hatch", "run", "test", "--exitfirst"}). |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,917 | ci: use separate cache mounts for different python versions | We are getting flaky pip cache errors like https://github.com/dagger/dagger/actions/runs/6552195369/job/17794987073#step:4:1007
@helderco suggested it may be due to separate python versions being used in parallel on the same cache mount: https://github.com/dagger/dagger/pull/5906#issuecomment-1767391090
(I'll squash this quick since the flakes are quite annoying; just filing issue since I'm currently squashing something else and don't want to forget) | https://github.com/dagger/dagger/issues/5917 | https://github.com/dagger/dagger/pull/5919 | d6b3585f481dba441b77f521fd2b094e483b31c7 | 7560f6ec3e061c94adcb75740124c670cd4d07c7 | 2023-10-18T21:04:46Z | go | 2023-10-19T02:21:32Z | internal/mage/sdk/python.go | Sync(gctx)
return err
})
dist := pythonBaseEnv(c, version).
Pipeline("build").
WithMountedDirectory(
"/dist",
base.Pipeline("build").
WithExec([]string{"hatch", "build", "--clean"}).
Directory("dist"),
)
for name, ext := range map[string]string{"sdist": "tar.gz", "bdist": "whl"} {
name := name
ext := ext
eg.Go(func() error {
_, err := dist.Pipeline(name).
WithExec([]string{"sh", "-c", "pip install /dist/*" + ext}).
WithExec([]string{"python", "-c", "import dagger"}).
Sync(gctx)
return err
})
}
}
return eg.Wait()
}
func (t Python) Generate(ctx context.Context) error {
c, err := dagger.Connect(ctx, dagger.WithLogOutput(os.Stderr))
if err != nil {
return err |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,917 | ci: use separate cache mounts for different python versions | We are getting flaky pip cache errors like https://github.com/dagger/dagger/actions/runs/6552195369/job/17794987073#step:4:1007
@helderco suggested it may be due to separate python versions being used in parallel on the same cache mount: https://github.com/dagger/dagger/pull/5906#issuecomment-1767391090
(I'll squash this quick since the flakes are quite annoying; just filing issue since I'm currently squashing something else and don't want to forget) | https://github.com/dagger/dagger/issues/5917 | https://github.com/dagger/dagger/pull/5919 | d6b3585f481dba441b77f521fd2b094e483b31c7 | 7560f6ec3e061c94adcb75740124c670cd4d07c7 | 2023-10-18T21:04:46Z | go | 2023-10-19T02:21:32Z | internal/mage/sdk/python.go | }
defer c.Close()
c = c.Pipeline("sdk").Pipeline("python").Pipeline("generate")
devEngine, endpoint, err := util.CIDevEngineContainerAndEndpoint(ctx, c.Pipeline("dev-engine"), util.DevEngineOpts{Name: "sdk-python-generate"})
if err != nil {
return err
}
cliBinPath := "/.dagger-cli"
generated, err := pythonBase(c, pythonDefaultVersion).
WithServiceBinding("dagger-engine", devEngine).
WithEnvVariable("_EXPERIMENTAL_DAGGER_RUNNER_HOST", endpoint).
WithMountedFile(cliBinPath, util.DaggerBinary(c)).
WithEnvVariable("_EXPERIMENTAL_DAGGER_CLI_BIN", cliBinPath).
WithWorkdir("/").
WithExec([]string{cliBinPath, "run", "python", "-m", "dagger", "generate", pythonGeneratedAPIPath}).
WithExec([]string{"black", pythonGeneratedAPIPath}).
File(pythonGeneratedAPIPath).
Contents(ctx)
if err != nil {
return err
}
return os.WriteFile(pythonGeneratedAPIPath, []byte(generated), 0o600)
}
func (t Python) Publish(ctx context.Context, tag string) error {
c, err := dagger.Connect(ctx, dagger.WithLogOutput(os.Stderr))
if err != nil {
return err
}
defer c.Close()
c = c.Pipeline("sdk").Pipeline("python").Pipeline("publish") |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,917 | ci: use separate cache mounts for different python versions | We are getting flaky pip cache errors like https://github.com/dagger/dagger/actions/runs/6552195369/job/17794987073#step:4:1007
@helderco suggested it may be due to separate python versions being used in parallel on the same cache mount: https://github.com/dagger/dagger/pull/5906#issuecomment-1767391090
(I'll squash this quick since the flakes are quite annoying; just filing issue since I'm currently squashing something else and don't want to forget) | https://github.com/dagger/dagger/issues/5917 | https://github.com/dagger/dagger/pull/5919 | d6b3585f481dba441b77f521fd2b094e483b31c7 | 7560f6ec3e061c94adcb75740124c670cd4d07c7 | 2023-10-18T21:04:46Z | go | 2023-10-19T02:21:32Z | internal/mage/sdk/python.go | var (
version = strings.TrimPrefix(tag, "sdk/python/v")
token = os.Getenv("PYPI_TOKEN")
repo = os.Getenv("PYPI_REPO")
)
if token == "" {
return errors.New("PYPI_TOKEN environment variable must be set")
}
if repo == "" || repo == "pypi" {
repo = "main"
}
_, err = pythonBase(c, pythonDefaultVersion).
WithEnvVariable("SETUPTOOLS_SCM_PRETEND_VERSION", version).
WithEnvVariable("HATCH_INDEX_REPO", repo).
WithEnvVariable("HATCH_INDEX_USER", "__token__").
WithSecretVariable("HATCH_INDEX_AUTH", c.SetSecret("pypiToken", token)).
WithExec([]string{"hatch", "build"}).
WithExec([]string{"hatch", "publish"}).
Sync(ctx)
return err
}
func (t Python) Bump(_ context.Context, version string) error {
version = strings.TrimPrefix(version, "v")
engineReference := fmt.Sprintf("# Code generated by dagger. DO NOT EDIT.\n\nCLI_VERSION = %q\n", version)
return os.WriteFile("sdk/python/src/dagger/_engine/_version.py", []byte(engineReference), 0o600)
}
func pythonBaseEnv(c *dagger.Client, version string) *dagger.Container { |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,917 | ci: use separate cache mounts for different python versions | We are getting flaky pip cache errors like https://github.com/dagger/dagger/actions/runs/6552195369/job/17794987073#step:4:1007
@helderco suggested it may be due to separate python versions being used in parallel on the same cache mount: https://github.com/dagger/dagger/pull/5906#issuecomment-1767391090
(I'll squash this quick since the flakes are quite annoying; just filing issue since I'm currently squashing something else and don't want to forget) | https://github.com/dagger/dagger/issues/5917 | https://github.com/dagger/dagger/pull/5919 | d6b3585f481dba441b77f521fd2b094e483b31c7 | 7560f6ec3e061c94adcb75740124c670cd4d07c7 | 2023-10-18T21:04:46Z | go | 2023-10-19T02:21:32Z | internal/mage/sdk/python.go | pipx := c.HTTP("https://github.com/pypa/pipx/releases/download/1.2.0/pipx.pyz")
venv := "/opt/venv"
return c.Container().
From(fmt.Sprintf("python:%s-slim", version)).
WithEnvVariable("PIPX_BIN_DIR", "/usr/local/bin").
WithMountedCache("/root/.cache/pip", c.CacheVolume("pip_cache")).
WithMountedCache("/root/.local/pipx/cache", c.CacheVolume("pipx_cache")).
WithMountedCache("/root/.cache/hatch", c.CacheVolume("hatch_cache")).
WithMountedFile("/pipx.pyz", pipx).
WithExec([]string{"python", "/pipx.pyz", "install", "hatch==1.7.0"}).
WithExec([]string{"python", "-m", "venv", venv}).
WithEnvVariable("VIRTUAL_ENV", venv).
WithEnvVariable(
"PATH",
"$VIRTUAL_ENV/bin:$PATH",
dagger.ContainerWithEnvVariableOpts{
Expand: true,
},
).
WithEnvVariable("HATCH_ENV_TYPE_VIRTUAL_PATH", venv)
}
func pythonBase(c *dagger.Client, version string) *dagger.Container { |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,917 | ci: use separate cache mounts for different python versions | We are getting flaky pip cache errors like https://github.com/dagger/dagger/actions/runs/6552195369/job/17794987073#step:4:1007
@helderco suggested it may be due to separate python versions being used in parallel on the same cache mount: https://github.com/dagger/dagger/pull/5906#issuecomment-1767391090
(I'll squash this quick since the flakes are quite annoying; just filing issue since I'm currently squashing something else and don't want to forget) | https://github.com/dagger/dagger/issues/5917 | https://github.com/dagger/dagger/pull/5919 | d6b3585f481dba441b77f521fd2b094e483b31c7 | 7560f6ec3e061c94adcb75740124c670cd4d07c7 | 2023-10-18T21:04:46Z | go | 2023-10-19T02:21:32Z | internal/mage/sdk/python.go | var (
appDir = "sdk/python"
reqFile = "requirements.txt"
)
src := util.Repository(c).Directory(appDir)
mountPath := fmt.Sprintf("/%s", appDir)
reqPath := fmt.Sprintf("%s/%s", appDir, reqFile)
return pythonBaseEnv(c, version).
WithFile(reqPath, src.File(reqFile)).
WithExec([]string{"pip", "install", "-r", reqPath}).
WithDirectory(mountPath, src).
WithWorkdir(mountPath).
WithExec([]string{"pip", "install", "."})
} |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,911 | POST http://dagger/query rpc error | Every Dagger run has something like:
```
[0.08s] Failed to connect; retrying... name:"error" value:"make request: Post \"http://dagger/query\": rpc error: code = Unknown desc = server \"wu4a6pa0asl96zq39iaijneaq\" not found"
```
It seems like it can be safely ignored, but the error message is concerning. | https://github.com/dagger/dagger/issues/5911 | https://github.com/dagger/dagger/pull/5918 | 70609dd344b7703de9ea52e2162ea574358e3fda | 572bd3de9340dea4121627163f4f7b58c818beb4 | 2023-10-18T17:09:08Z | go | 2023-10-19T17:12:45Z | engine/client/client.go | package client
import (
"context"
"encoding/base64"
"encoding/json"
"errors"
"fmt"
"io"
"net"
"net/http"
"net/http/httptest"
"net/url" |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,911 | POST http://dagger/query rpc error | Every Dagger run has something like:
```
[0.08s] Failed to connect; retrying... name:"error" value:"make request: Post \"http://dagger/query\": rpc error: code = Unknown desc = server \"wu4a6pa0asl96zq39iaijneaq\" not found"
```
It seems like it can be safely ignored, but the error message is concerning. | https://github.com/dagger/dagger/issues/5911 | https://github.com/dagger/dagger/pull/5918 | 70609dd344b7703de9ea52e2162ea574358e3fda | 572bd3de9340dea4121627163f4f7b58c818beb4 | 2023-10-18T17:09:08Z | go | 2023-10-19T17:12:45Z | engine/client/client.go | "os"
"path/filepath"
"strconv"
"strings"
"sync"
"time"
"dagger.io/dagger"
"github.com/Khan/genqlient/graphql"
"github.com/cenkalti/backoff/v4"
"github.com/docker/cli/cli/config"
"github.com/google/uuid"
controlapi "github.com/moby/buildkit/api/services/control"
bkclient "github.com/moby/buildkit/client"
"github.com/moby/buildkit/identity"
bksession "github.com/moby/buildkit/session"
"github.com/moby/buildkit/session/auth/authprovider"
"github.com/moby/buildkit/session/filesync"
"github.com/moby/buildkit/session/grpchijack"
"github.com/opencontainers/go-digest"
"github.com/tonistiigi/fsutil"
fstypes "github.com/tonistiigi/fsutil/types"
"github.com/vito/progrock"
"golang.org/x/sync/errgroup"
"google.golang.org/grpc"
"github.com/dagger/dagger/core/pipeline"
"github.com/dagger/dagger/engine"
"github.com/dagger/dagger/engine/session"
"github.com/dagger/dagger/telemetry"
)
type Params struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,911 | POST http://dagger/query rpc error | Every Dagger run has something like:
```
[0.08s] Failed to connect; retrying... name:"error" value:"make request: Post \"http://dagger/query\": rpc error: code = Unknown desc = server \"wu4a6pa0asl96zq39iaijneaq\" not found"
```
It seems like it can be safely ignored, but the error message is concerning. | https://github.com/dagger/dagger/issues/5911 | https://github.com/dagger/dagger/pull/5918 | 70609dd344b7703de9ea52e2162ea574358e3fda | 572bd3de9340dea4121627163f4f7b58c818beb4 | 2023-10-18T17:09:08Z | go | 2023-10-19T17:12:45Z | engine/client/client.go | ServerID string
ParentClientIDs []string
SecretToken string
RunnerHost string
UserAgent string
DisableHostRW bool
JournalFile string
ProgrockWriter progrock.Writer
EngineNameCallback func(string)
CloudURLCallback func(string)
ModuleDigest digest.Digest
FunctionContextDigest digest.Digest
}
type Client struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,911 | POST http://dagger/query rpc error | Every Dagger run has something like:
```
[0.08s] Failed to connect; retrying... name:"error" value:"make request: Post \"http://dagger/query\": rpc error: code = Unknown desc = server \"wu4a6pa0asl96zq39iaijneaq\" not found"
```
It seems like it can be safely ignored, but the error message is concerning. | https://github.com/dagger/dagger/issues/5911 | https://github.com/dagger/dagger/pull/5918 | 70609dd344b7703de9ea52e2162ea574358e3fda | 572bd3de9340dea4121627163f4f7b58c818beb4 | 2023-10-18T17:09:08Z | go | 2023-10-19T17:12:45Z | engine/client/client.go | Params
eg *errgroup.Group
internalCtx context.Context
internalCancel context.CancelFunc
closeCtx context.Context
closeRequests context.CancelFunc
closeMu sync.RWMutex
Recorder *progrock.Recorder
httpClient *http.Client
bkClient *bkclient.Client
bkSession *bksession.Session
daggerClient *dagger.Client
upstreamCacheImportOptions []*controlapi.CacheOptionsEntry
upstreamCacheExportOptions []*controlapi.CacheOptionsEntry
hostname string
nestedSessionPort int
labels []pipeline.Label
}
func Connect(ctx context.Context, params Params) (_ *Client, _ context.Context, rerr error) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,911 | POST http://dagger/query rpc error | Every Dagger run has something like:
```
[0.08s] Failed to connect; retrying... name:"error" value:"make request: Post \"http://dagger/query\": rpc error: code = Unknown desc = server \"wu4a6pa0asl96zq39iaijneaq\" not found"
```
It seems like it can be safely ignored, but the error message is concerning. | https://github.com/dagger/dagger/issues/5911 | https://github.com/dagger/dagger/pull/5918 | 70609dd344b7703de9ea52e2162ea574358e3fda | 572bd3de9340dea4121627163f4f7b58c818beb4 | 2023-10-18T17:09:08Z | go | 2023-10-19T17:12:45Z | engine/client/client.go | c := &Client{Params: params}
if c.SecretToken == "" {
c.SecretToken = uuid.New().String()
}
if c.ServerID == "" {
c.ServerID = identity.NewID()
}
c.internalCtx, c.internalCancel = context.WithCancel(context.Background())
c.eg, c.internalCtx = errgroup.WithContext(c.internalCtx)
defer func() {
if rerr != nil {
c.internalCancel()
}
}()
c.closeCtx, c.closeRequests = context.WithCancel(context.Background())
progMultiW := progrock.MultiWriter{}
if c.ProgrockWriter != nil {
progMultiW = append(progMultiW, c.ProgrockWriter)
}
if c.JournalFile != "" {
fw, err := newProgrockFileWriter(c.JournalFile)
if err != nil {
return nil, nil, err
} |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,911 | POST http://dagger/query rpc error | Every Dagger run has something like:
```
[0.08s] Failed to connect; retrying... name:"error" value:"make request: Post \"http://dagger/query\": rpc error: code = Unknown desc = server \"wu4a6pa0asl96zq39iaijneaq\" not found"
```
It seems like it can be safely ignored, but the error message is concerning. | https://github.com/dagger/dagger/issues/5911 | https://github.com/dagger/dagger/pull/5918 | 70609dd344b7703de9ea52e2162ea574358e3fda | 572bd3de9340dea4121627163f4f7b58c818beb4 | 2023-10-18T17:09:08Z | go | 2023-10-19T17:12:45Z | engine/client/client.go | progMultiW = append(progMultiW, fw)
}
tel := telemetry.New()
var cloudURL string
if tel.Enabled() {
cloudURL = tel.URL()
progMultiW = append(progMultiW, telemetry.NewWriter(tel))
}
c.Recorder = progrock.NewRecorder(progMultiW)
ctx = progrock.ToContext(ctx, c.Recorder)
nestedSessionPortVal, isNestedSession := os.LookupEnv("DAGGER_SESSION_PORT")
if isNestedSession {
nestedSessionPort, err := strconv.Atoi(nestedSessionPortVal)
if err != nil {
return nil, nil, fmt.Errorf("parse DAGGER_SESSION_PORT: %w", err)
}
c.nestedSessionPort = nestedSessionPort
c.SecretToken = os.Getenv("DAGGER_SESSION_TOKEN")
c.httpClient = &http.Client{
Transport: &http.Transport{
DialContext: c.DialContext,
DisableKeepAlives: true,
},
}
if err := c.daggerConnect(ctx); err != nil {
return nil, nil, fmt.Errorf("failed to connect to dagger: %w", err)
}
return c, ctx, nil
}
initGroup := progrock.FromContext(ctx).WithGroup("init", progrock.Weak()) |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,911 | POST http://dagger/query rpc error | Every Dagger run has something like:
```
[0.08s] Failed to connect; retrying... name:"error" value:"make request: Post \"http://dagger/query\": rpc error: code = Unknown desc = server \"wu4a6pa0asl96zq39iaijneaq\" not found"
```
It seems like it can be safely ignored, but the error message is concerning. | https://github.com/dagger/dagger/issues/5911 | https://github.com/dagger/dagger/pull/5918 | 70609dd344b7703de9ea52e2162ea574358e3fda | 572bd3de9340dea4121627163f4f7b58c818beb4 | 2023-10-18T17:09:08Z | go | 2023-10-19T17:12:45Z | engine/client/client.go | loader := initGroup.Vertex("starting-engine", "connect")
defer func() {
loader.Done(rerr)
}()
var err error
c.upstreamCacheImportOptions, c.upstreamCacheExportOptions, err = allCacheConfigsFromEnv()
if err != nil {
return nil, nil, fmt.Errorf("cache config from env: %w", err)
}
remote, err := url.Parse(c.RunnerHost)
if err != nil {
return nil, nil, fmt.Errorf("parse runner host: %w", err)
}
engineTask := loader.Task("starting engine")
bkClient, bkInfo, err := newBuildkitClient(ctx, remote, c.UserAgent, loader)
engineTask.Done(err)
if err != nil {
return nil, nil, fmt.Errorf("new client: %w", err)
}
c.bkClient = bkClient
defer func() {
if rerr != nil {
c.bkClient.Close()
}
}()
if c.EngineNameCallback != nil {
engineName := fmt.Sprintf("%s (version %s)", bkInfo.BuildkitVersion.Revision, bkInfo.BuildkitVersion.Version) |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,911 | POST http://dagger/query rpc error | Every Dagger run has something like:
```
[0.08s] Failed to connect; retrying... name:"error" value:"make request: Post \"http://dagger/query\": rpc error: code = Unknown desc = server \"wu4a6pa0asl96zq39iaijneaq\" not found"
```
It seems like it can be safely ignored, but the error message is concerning. | https://github.com/dagger/dagger/issues/5911 | https://github.com/dagger/dagger/pull/5918 | 70609dd344b7703de9ea52e2162ea574358e3fda | 572bd3de9340dea4121627163f4f7b58c818beb4 | 2023-10-18T17:09:08Z | go | 2023-10-19T17:12:45Z | engine/client/client.go | c.EngineNameCallback(engineName)
}
hostname, err := os.Hostname()
if err != nil {
return nil, nil, fmt.Errorf("get hostname: %w", err)
}
c.hostname = hostname
sessionTask := loader.Task("starting session")
sharedKey := c.ServerID
bkSession, err := bksession.NewSession(ctx, identity.NewID(), sharedKey)
if err != nil {
return nil, nil, fmt.Errorf("new s: %w", err)
}
c.bkSession = bkSession
defer func() {
if rerr != nil {
c.bkSession.Close()
}
}()
workdir, err := os.Getwd()
if err != nil {
return nil, nil, fmt.Errorf("get workdir: %w", err)
}
c.labels = pipeline.LoadVCSLabels(workdir)
c.labels = append(c.labels, pipeline.LoadClientLabels(engine.Version)...)
c.internalCtx = engine.ContextWithClientMetadata(c.internalCtx, &engine.ClientMetadata{
ClientID: c.ID(),
ClientSecretToken: c.SecretToken,
ServerID: c.ServerID,
ClientHostname: c.hostname, |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,911 | POST http://dagger/query rpc error | Every Dagger run has something like:
```
[0.08s] Failed to connect; retrying... name:"error" value:"make request: Post \"http://dagger/query\": rpc error: code = Unknown desc = server \"wu4a6pa0asl96zq39iaijneaq\" not found"
```
It seems like it can be safely ignored, but the error message is concerning. | https://github.com/dagger/dagger/issues/5911 | https://github.com/dagger/dagger/pull/5918 | 70609dd344b7703de9ea52e2162ea574358e3fda | 572bd3de9340dea4121627163f4f7b58c818beb4 | 2023-10-18T17:09:08Z | go | 2023-10-19T17:12:45Z | engine/client/client.go | Labels: c.labels,
ParentClientIDs: c.ParentClientIDs,
ModuleDigest: c.ModuleDigest,
FunctionContextDigest: c.FunctionContextDigest,
})
bkSession.Allow(progRockAttachable{progMultiW})
if !c.DisableHostRW {
bkSession.Allow(AnyDirSource{})
bkSession.Allow(AnyDirTarget{})
}
bkSession.Allow(SocketProvider{
EnableHostNetworkAccess: !c.DisableHostRW,
})
bkSession.Allow(authprovider.NewDockerAuthProvider(config.LoadDefaultConfigFile(os.Stderr), nil))
c.Recorder = progrock.NewRecorder(progMultiW)
bkSession.Allow(session.NewTunnelListenerAttachable(c.Recorder))
ctx = progrock.ToContext(ctx, c.Recorder)
c.eg.Go(func() error {
return bkSession.Run(c.internalCtx, func(ctx context.Context, proto string, meta map[string][]string) (net.Conn, error) {
return grpchijack.Dialer(c.bkClient.ControlClient())(ctx, proto, engine.ClientMetadata{
RegisterClient: true,
ClientID: c.ID(),
ClientSecretToken: c.SecretToken, |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,911 | POST http://dagger/query rpc error | Every Dagger run has something like:
```
[0.08s] Failed to connect; retrying... name:"error" value:"make request: Post \"http://dagger/query\": rpc error: code = Unknown desc = server \"wu4a6pa0asl96zq39iaijneaq\" not found"
```
It seems like it can be safely ignored, but the error message is concerning. | https://github.com/dagger/dagger/issues/5911 | https://github.com/dagger/dagger/pull/5918 | 70609dd344b7703de9ea52e2162ea574358e3fda | 572bd3de9340dea4121627163f4f7b58c818beb4 | 2023-10-18T17:09:08Z | go | 2023-10-19T17:12:45Z | engine/client/client.go | ServerID: c.ServerID,
ParentClientIDs: c.ParentClientIDs,
ClientHostname: hostname,
UpstreamCacheImportConfig: c.upstreamCacheImportOptions,
Labels: c.labels,
ModuleDigest: c.ModuleDigest,
FunctionContextDigest: c.FunctionContextDigest,
}.AppendToMD(meta))
})
})
c.httpClient = &http.Client{Transport: &http.Transport{
DialContext: c.DialContext,
DisableKeepAlives: true,
}}
bo := backoff.NewExponentialBackOff()
bo.InitialInterval = 100 * time.Millisecond
connectRetryCtx, connectRetryCancel := context.WithTimeout(ctx, 300*time.Second)
defer connectRetryCancel()
err = backoff.Retry(func() error {
ctx, cancel := context.WithTimeout(connectRetryCtx, bo.NextBackOff())
defer cancel()
innerErr := c.Do(ctx, `{defaultPlatform}`, "", nil, nil)
if innerErr != nil {
fmt.Fprintln(loader.Stdout(), "Failed to connect; retrying...", progrock.ErrorLabel(innerErr))
} else {
fmt.Fprintln(loader.Stdout(), "OK!") |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,911 | POST http://dagger/query rpc error | Every Dagger run has something like:
```
[0.08s] Failed to connect; retrying... name:"error" value:"make request: Post \"http://dagger/query\": rpc error: code = Unknown desc = server \"wu4a6pa0asl96zq39iaijneaq\" not found"
```
It seems like it can be safely ignored, but the error message is concerning. | https://github.com/dagger/dagger/issues/5911 | https://github.com/dagger/dagger/pull/5918 | 70609dd344b7703de9ea52e2162ea574358e3fda | 572bd3de9340dea4121627163f4f7b58c818beb4 | 2023-10-18T17:09:08Z | go | 2023-10-19T17:12:45Z | engine/client/client.go | }
return innerErr
}, backoff.WithContext(bo, connectRetryCtx))
sessionTask.Done(err)
if err != nil {
return nil, nil, fmt.Errorf("connect: %w", err)
}
if c.CloudURLCallback != nil && cloudURL != "" {
c.CloudURLCallback(cloudURL)
}
if err := c.daggerConnect(ctx); err != nil {
return nil, nil, fmt.Errorf("failed to connect to dagger: %w", err)
}
return c, ctx, nil
}
func (c *Client) daggerConnect(ctx context.Context) error {
var err error
c.daggerClient, err = dagger.Connect(context.Background(),
dagger.WithConn(EngineConn(c)),
dagger.WithSkipCompatibilityCheck())
return err
}
func (c *Client) Close() (rerr error) {
if err := c.shutdownServer(); err != nil {
rerr = errors.Join(rerr, fmt.Errorf("shutdown: %w", err))
}
c.closeMu.Lock()
defer c.closeMu.Unlock()
select { |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,911 | POST http://dagger/query rpc error | Every Dagger run has something like:
```
[0.08s] Failed to connect; retrying... name:"error" value:"make request: Post \"http://dagger/query\": rpc error: code = Unknown desc = server \"wu4a6pa0asl96zq39iaijneaq\" not found"
```
It seems like it can be safely ignored, but the error message is concerning. | https://github.com/dagger/dagger/issues/5911 | https://github.com/dagger/dagger/pull/5918 | 70609dd344b7703de9ea52e2162ea574358e3fda | 572bd3de9340dea4121627163f4f7b58c818beb4 | 2023-10-18T17:09:08Z | go | 2023-10-19T17:12:45Z | engine/client/client.go | case <-c.closeCtx.Done():
return nil
default:
}
if len(c.upstreamCacheExportOptions) > 0 {
cacheExportCtx, cacheExportCancel := context.WithTimeout(c.internalCtx, 600*time.Second)
defer cacheExportCancel()
_, err := c.bkClient.ControlClient().Solve(cacheExportCtx, &controlapi.SolveRequest{
Cache: controlapi.CacheOptions{
Exports: c.upstreamCacheExportOptions,
},
})
rerr = errors.Join(rerr, err)
}
c.closeRequests()
if c.internalCancel != nil {
c.internalCancel()
}
if c.daggerClient != nil {
c.eg.Go(c.daggerClient.Close)
}
if c.httpClient != nil {
c.eg.Go(func() error {
c.httpClient.CloseIdleConnections()
return nil
})
}
if c.bkSession != nil {
c.eg.Go(c.bkSession.Close) |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,911 | POST http://dagger/query rpc error | Every Dagger run has something like:
```
[0.08s] Failed to connect; retrying... name:"error" value:"make request: Post \"http://dagger/query\": rpc error: code = Unknown desc = server \"wu4a6pa0asl96zq39iaijneaq\" not found"
```
It seems like it can be safely ignored, but the error message is concerning. | https://github.com/dagger/dagger/issues/5911 | https://github.com/dagger/dagger/pull/5918 | 70609dd344b7703de9ea52e2162ea574358e3fda | 572bd3de9340dea4121627163f4f7b58c818beb4 | 2023-10-18T17:09:08Z | go | 2023-10-19T17:12:45Z | engine/client/client.go | }
if c.bkClient != nil {
c.eg.Go(c.bkClient.Close)
}
if err := c.eg.Wait(); err != nil {
rerr = errors.Join(rerr, err)
}
if c.Recorder != nil {
c.Recorder.Complete()
c.Recorder.Close()
}
return rerr
}
func (c *Client) shutdownServer() error {
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
req, err := http.NewRequestWithContext(ctx, "POST", "http:dagger/shutdown", nil)
if err != nil {
return fmt.Errorf("new request: %w", err)
}
req.SetBasicAuth(c.SecretToken, "")
resp, err := c.httpClient.Do(req)
if err != nil {
return fmt.Errorf("do shutdown: %w", err)
}
return resp.Body.Close()
}
func (c *Client) withClientCloseCancel(ctx context.Context) (context.Context, context.CancelFunc, error) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,911 | POST http://dagger/query rpc error | Every Dagger run has something like:
```
[0.08s] Failed to connect; retrying... name:"error" value:"make request: Post \"http://dagger/query\": rpc error: code = Unknown desc = server \"wu4a6pa0asl96zq39iaijneaq\" not found"
```
It seems like it can be safely ignored, but the error message is concerning. | https://github.com/dagger/dagger/issues/5911 | https://github.com/dagger/dagger/pull/5918 | 70609dd344b7703de9ea52e2162ea574358e3fda | 572bd3de9340dea4121627163f4f7b58c818beb4 | 2023-10-18T17:09:08Z | go | 2023-10-19T17:12:45Z | engine/client/client.go | c.closeMu.RLock()
defer c.closeMu.RUnlock()
select {
case <-c.closeCtx.Done():
return nil, nil, errors.New("client closed")
default:
}
ctx, cancel := context.WithCancel(ctx)
go func() {
select {
case <-c.closeCtx.Done():
cancel()
case <-ctx.Done():
}
}()
return ctx, cancel, nil
}
func (c *Client) ID() string {
return c.bkSession.ID()
}
func (c *Client) DialContext(ctx context.Context, _, _ string) (conn net.Conn, err error) {
ctx, cancel, err := c.withClientCloseCancel(ctx)
if err != nil {
return nil, err
}
isNestedSession := c.nestedSessionPort != 0
if isNestedSession {
conn, err = (&net.Dialer{ |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,911 | POST http://dagger/query rpc error | Every Dagger run has something like:
```
[0.08s] Failed to connect; retrying... name:"error" value:"make request: Post \"http://dagger/query\": rpc error: code = Unknown desc = server \"wu4a6pa0asl96zq39iaijneaq\" not found"
```
It seems like it can be safely ignored, but the error message is concerning. | https://github.com/dagger/dagger/issues/5911 | https://github.com/dagger/dagger/pull/5918 | 70609dd344b7703de9ea52e2162ea574358e3fda | 572bd3de9340dea4121627163f4f7b58c818beb4 | 2023-10-18T17:09:08Z | go | 2023-10-19T17:12:45Z | engine/client/client.go | Cancel: ctx.Done(),
KeepAlive: -1,
}).Dial("tcp", "127.0.0.1:"+strconv.Itoa(c.nestedSessionPort))
} else {
conn, err = grpchijack.Dialer(c.bkClient.ControlClient())(ctx, "", engine.ClientMetadata{
ClientID: c.ID(),
ClientSecretToken: c.SecretToken,
ServerID: c.ServerID,
ClientHostname: c.hostname,
ParentClientIDs: c.ParentClientIDs,
Labels: c.labels,
ModuleDigest: c.ModuleDigest,
FunctionContextDigest: c.FunctionContextDigest,
}.ToGRPCMD())
}
if err != nil {
return nil, err
}
go func() {
<-c.closeCtx.Done()
cancel()
conn.Close()
}()
return conn, nil
}
func (c *Client) Do(
ctx context.Context,
query string,
opName string,
variables map[string]any, |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,911 | POST http://dagger/query rpc error | Every Dagger run has something like:
```
[0.08s] Failed to connect; retrying... name:"error" value:"make request: Post \"http://dagger/query\": rpc error: code = Unknown desc = server \"wu4a6pa0asl96zq39iaijneaq\" not found"
```
It seems like it can be safely ignored, but the error message is concerning. | https://github.com/dagger/dagger/issues/5911 | https://github.com/dagger/dagger/pull/5918 | 70609dd344b7703de9ea52e2162ea574358e3fda | 572bd3de9340dea4121627163f4f7b58c818beb4 | 2023-10-18T17:09:08Z | go | 2023-10-19T17:12:45Z | engine/client/client.go | data any,
) (rerr error) {
ctx, cancel, err := c.withClientCloseCancel(ctx)
if err != nil {
return err
}
defer cancel()
gqlClient := graphql.NewClient("http:dagger/query", doerWithHeaders{
inner: c.httpClient,
headers: http.Header{
"Authorization": []string{"Basic " + base64.StdEncoding.EncodeToString([]byte(c.SecretToken+":"))},
},
})
req := &graphql.Request{
Query: query,
Variables: variables,
OpName: opName,
}
resp := &graphql.Response{}
err = gqlClient.MakeRequest(ctx, req, resp)
if err != nil {
return fmt.Errorf("make request: %w", err)
}
if resp.Errors != nil {
errs := make([]error, len(resp.Errors))
for i, err := range resp.Errors {
errs[i] = err
}
return errors.Join(errs...)
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.