-
Notifications
You must be signed in to change notification settings - Fork 0
/
sdk.go
71 lines (63 loc) · 1.96 KB
/
sdk.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package main
import (
"context"
"github.com/dagger/dagger/ci/build"
"github.com/dagger/dagger/ci/consts"
)
// A dev environment for the official Dagger SDKs
type SDK struct {
// Develop the Dagger Go SDK
Go *GoSDK
// Develop the Dagger Python SDK
Python *PythonSDK
// Develop the Dagger Typescript SDK
Typescript *TypescriptSDK
// Develop the Dagger Elixir SDK (experimental)
Elixir *ElixirSDK
// Develop the Dagger Rust SDK (experimental)
Rust *RustSDK
// Develop the Dagger Java SDK (experimental)
Java *JavaSDK
// Develop the Dagger PHP SDK (experimental)
PHP *PHPSDK
}
func (ci *Dagger) installer(ctx context.Context, name string) (func(*Container) *Container, error) {
engineSvc, err := ci.Engine().Service(ctx, name)
if err != nil {
return nil, err
}
engineEndpoint, err := engineSvc.Endpoint(ctx, ServiceEndpointOpts{Scheme: "tcp"})
if err != nil {
return nil, err
}
cliBinary, err := ci.CLI().File(ctx, "")
if err != nil {
return nil, err
}
cliBinaryPath := "/.dagger-cli"
return func(ctr *Container) *Container {
ctr = ctr.
WithServiceBinding("dagger-engine", engineSvc).
WithEnvVariable("_EXPERIMENTAL_DAGGER_RUNNER_HOST", engineEndpoint).
WithMountedFile(cliBinaryPath, cliBinary).
WithEnvVariable("_EXPERIMENTAL_DAGGER_CLI_BIN", cliBinaryPath).
WithExec([]string{"ln", "-s", cliBinaryPath, "/usr/local/bin/dagger"})
if ci.HostDockerConfig != nil {
// this avoids rate limiting in our ci tests
ctr = ctr.WithMountedSecret("/root/.docker/config.json", ci.HostDockerConfig)
}
return ctr
}, nil
}
func (ci *Dagger) introspection(ctx context.Context, installer func(*Container) *Container) (*File, error) {
builder, err := build.NewBuilder(ctx, ci.Source)
if err != nil {
return nil, err
}
return dag.Container().
From(consts.AlpineImage).
With(installer).
WithFile("/usr/local/bin/codegen", builder.CodegenBinary()).
WithExec([]string{"codegen", "introspect", "-o", "/schema.json"}).
File("/schema.json"), nil
}