-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3acc0cf
commit 05f7fc1
Showing
6 changed files
with
104 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
package models | ||
|
||
type BuildRequest struct { | ||
Dockerfile string `json:"dockerfile"` | ||
Tags []string `json:"tags"` | ||
Project string `json:"project"` | ||
Commit string `json:"commit"` | ||
Dockerfile string `json:"dockerfile"` | ||
Tag string `json:"tag"` | ||
Repository string `json:"repository"` | ||
Commit string `json:"commit"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package graphql | ||
|
||
import ( | ||
"github.com/graphql-go/graphql" | ||
"github.com/harbourrocks/harbour/pkg/apiclient" | ||
"github.com/harbourrocks/harbour/pkg/auth" | ||
"github.com/harbourrocks/harbour/pkg/harbourbuild/models" | ||
) | ||
|
||
var triggerBuildType = graphql.NewObject( | ||
graphql.ObjectConfig{ | ||
Name: "Build", | ||
Fields: graphql.Fields{ | ||
"dockerfile": &graphql.Field{ | ||
Type: graphql.String, | ||
Description: "Name of dockerfile which should be used for build", | ||
}, | ||
"tag": &graphql.Field{ | ||
Type: graphql.String, | ||
Description: "Tag which should be used for the image", | ||
}, | ||
"repository": &graphql.Field{ | ||
Type: graphql.String, | ||
Description: "Code-Repo which should be built", | ||
}, | ||
"commit": &graphql.Field{ | ||
Type: graphql.String, | ||
Description: "Commit which sould be used for built", | ||
}, | ||
}, | ||
}) | ||
|
||
func TriggerBuildField() *graphql.Field { | ||
return &graphql.Field{ | ||
Type: triggerBuildType, | ||
Resolve: func(p graphql.ResolveParams) (interface{}, error) { | ||
oidcTokenStr := auth.GetOidcTokenStrCtx(p.Context) | ||
|
||
repository, isOK := p.Args["repository"].(string) | ||
if !isOK { | ||
return nil, nil | ||
} | ||
|
||
dockerfile, isOK := p.Args["dockerfile"].(string) | ||
if !isOK { | ||
return nil, nil | ||
} | ||
|
||
tag, isOK := p.Args["tag"].(string) | ||
if !isOK { | ||
return nil, nil | ||
} | ||
|
||
commit, isOK := p.Args["commit"].(string) | ||
if !isOK { | ||
return nil, nil | ||
} | ||
|
||
build := &models.BuildRequest{ | ||
Repository: repository, | ||
Dockerfile: dockerfile, | ||
Tag: tag, | ||
Commit: commit, | ||
} | ||
|
||
var response interface{} | ||
_, err := apiclient.Post(p.Context, "http://localhost:5200/build", response, build, oidcTokenStr, nil) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return nil, nil | ||
}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters