diff --git a/cmd/codegen/generator/go/templates/src/_types/object.go.tmpl b/cmd/codegen/generator/go/templates/src/_types/object.go.tmpl index 54bce83eeec..eacf3e30437 100644 --- a/cmd/codegen/generator/go/templates/src/_types/object.go.tmpl +++ b/cmd/codegen/generator/go/templates/src/_types/object.go.tmpl @@ -88,6 +88,9 @@ type {{ $field | FieldOptionsStructName }} struct { {{ $typeName := $field.TypeRef | FormatOutputType }} return &{{ $field.TypeRef | FormatOutputType }} { Query: q, + {{- if eq $typeName "Client" }} + client: r.client, + {{ end }} } {{- else if or $field.TypeRef.IsScalar $field.TypeRef.IsList }} diff --git a/core/integration/pipeline_test.go b/core/integration/pipeline_test.go index affc15037cb..3448507833f 100644 --- a/core/integration/pipeline_test.go +++ b/core/integration/pipeline_test.go @@ -14,6 +14,27 @@ func TestPipeline(t *testing.T) { cacheBuster := fmt.Sprintf("%d", time.Now().UTC().UnixNano()) + t.Run("client pipeline", func(t *testing.T) { + t.Parallel() + + var logs safeBuffer + c, ctx := connect(t, dagger.WithLogOutput(&logs)) + + _, err := c. + Pipeline("client pipeline"). + Container(). + From(alpineImage). + WithExec([]string{"echo", cacheBuster}). + Sync(ctx) + + require.NoError(t, err) + + require.NoError(t, c.Close()) // close + flush logs + + t.Log(logs.String()) + require.Contains(t, logs.String(), "client pipeline") + }) + t.Run("container pipeline", func(t *testing.T) { t.Parallel() @@ -88,6 +109,14 @@ func TestPipeline(t *testing.T) { }) } +func TestPipelineGraphQLClient(t *testing.T) { + t.Parallel() + + c, _ := connect(t) + require.NotNil(t, c.GraphQLClient()) + require.NotNil(t, c.Pipeline("client pipeline").GraphQLClient()) +} + func TestInternalVertexes(t *testing.T) { t.Parallel() diff --git a/sdk/go/dagger.gen.go b/sdk/go/dagger.gen.go index e692645040f..54455d1cfb6 100644 --- a/sdk/go/dagger.gen.go +++ b/sdk/go/dagger.gen.go @@ -5592,7 +5592,8 @@ func (r *Client) Pipeline(name string, opts ...PipelineOpts) *Client { q = q.Arg("name", name) return &Client{ - Query: q, + Query: q, + client: r.client, } }