Skip to content

Commit

Permalink
chore: Replace deprecated CreateBuild with StartBuild mutation
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeldwan committed Apr 1, 2020
1 parent 5e0f435 commit 7a44cd2
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 11 deletions.
14 changes: 5 additions & 9 deletions api/resource_builds.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ func (c *Client) CreateSignedUrls(appId string, filename string) (getUrl string,
return data.CreateSignedUrl.GetUrl, data.CreateSignedUrl.PutUrl, nil
}

func (c *Client) CreateBuild(appId string, sourceUrl, sourceType string, buildType string) (*Build, error) {
func (c *Client) StartBuild(input StartBuildInput) (*Build, error) {
query := `
mutation($appId: ID!, $sourceUrl: String!, $sourceType: UrlSource!, $buildType: String!) {
createBuild(appId: $appId, sourceUrl: $sourceUrl, sourceType: $sourceType, buildType: $buildType) {
mutation($input: StartBuildInput!) {
startBuild(input: $input) {
build {
id
inProgress
Expand All @@ -45,18 +45,14 @@ func (c *Client) CreateBuild(appId string, sourceUrl, sourceType string, buildTy
`

req := c.NewRequest(query)

req.Var("appId", appId)
req.Var("sourceUrl", sourceUrl)
req.Var("sourceType", sourceType)
req.Var("buildType", buildType)
req.Var("input", input)

data, err := c.Run(req)
if err != nil {
return nil, err
}

return &data.CreateBuild.Build, nil
return &data.StartBuild.Build, nil
}

func (c *Client) ListBuilds(appName string) ([]Build, error) {
Expand Down
15 changes: 14 additions & 1 deletion api/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ type Query struct {

CreateSignedUrl SignedUrls

CreateBuild struct {
StartBuild struct {
Build Build
}

Expand Down Expand Up @@ -422,3 +422,16 @@ type SetVMSizeInput struct {
AppID string `json:"appId"`
SizeName string `json:"sizeName"`
}

type StartBuildInput struct {
AppID string `json:"appId"`
SourceURL string `json:"sourceUrl"`
SourceType string `json:"sourceType"`
BuildType *string `json:"buildType"`
BuildArgs []BuildArgInput `json:"buildArgs"`
}

type BuildArgInput struct {
Name string `json:"name"`
Value string `json:"value"`
}
9 changes: 8 additions & 1 deletion docker/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,14 @@ func (op *DeployOperation) StartRemoteBuild(cwd string, appConfig *flyctl.AppCon
return nil, fmt.Errorf("Error submitting build: %s", body)
}

build, err := op.apiClient.CreateBuild(op.AppName(), getURL, "targz", "flyctl_build_only")
input := api.StartBuildInput{
AppID: op.AppName(),
SourceURL: getURL,
SourceType: "targz",
BuildType: api.StringPointer("flyctl_v1"),
}

build, err := op.apiClient.StartBuild(input)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 7a44cd2

Please sign in to comment.