-
Notifications
You must be signed in to change notification settings - Fork 3
/
resource_remote_builders.go
67 lines (59 loc) · 1.62 KB
/
resource_remote_builders.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
package fly
import "context"
func (client *Client) EnsureRemoteBuilder(ctx context.Context, orgID, appName, region string) (*GqlMachine, *App, error) {
query := `
mutation($input: EnsureMachineRemoteBuilderInput!) {
ensureMachineRemoteBuilder(input: $input) {
machine {
id
state
ips {
nodes {
family
kind
ip
}
}
},
app {
name
organization {
id
slug
}
}
}
}
`
req := client.NewRequest(query)
ctx = ctxWithAction(ctx, "ensure_remote_builder")
input := EnsureRemoteBuilderInput{}
if region != "" {
input.Region = StringPointer(region)
}
if orgID != "" {
input.OrganizationID = StringPointer(orgID)
} else {
input.AppName = StringPointer(appName)
}
req.Var("input", input)
data, err := client.RunWithContext(ctx, req)
if err != nil {
return nil, nil, err
}
return data.EnsureMachineRemoteBuilder.Machine, data.EnsureMachineRemoteBuilder.App, nil
}
// in order to auto generate the EnsureDepotRemoteBuilder function, we just need to create a string assigned to a variable, making sure to include the query, the input type, and the response type
// we use pointer: true to make specifying the inputs optional
func (client *Client) EnsureDepotRemoteBuilder(ctx context.Context, input *EnsureDepotRemoteBuilderInput) (*EnsureDepotRemoteBuilderResponse, error) {
_ = `
# @genqlient(pointer: true)
mutation EnsureDepotRemoteBuilder($input: EnsureDepotRemoteBuilderInput!) {
ensureDepotRemoteBuilder(input:$input) {
buildId
buildToken
}
}
`
return EnsureDepotRemoteBuilder(ctx, client.genqClient, input)
}