~emersion/yojo

cd4219b55d2d4bd789d21c4f240bd3713173e59f — Simon Ser 11 months ago 9716514
Set build job visibility

Closes: https://todo.sr.ht/~emersion/yojo/15
4 files changed, 15 insertions(+), 5 deletions(-)

M buildssrht/gql.go
M buildssrht/operations.graphql
M gitea.go
M job.go
M buildssrht/gql.go => buildssrht/gql.go +3 -2
@@ 531,11 531,12 @@ type WebhookTriggerInput struct {
	Url string `json:"url"`
}

func SubmitJob(client *gqlclient.Client, ctx context.Context, manifest string, tags []string, note *string) (submit *Job, err error) {
	op := gqlclient.NewOperation("mutation submitJob ($manifest: String!, $tags: [String!], $note: String) {\n\tsubmit(manifest: $manifest, secrets: false, tags: $tags, note: $note) {\n\t\tid\n\t\towner {\n\t\t\tcanonicalName\n\t\t}\n\t}\n}\n")
func SubmitJob(client *gqlclient.Client, ctx context.Context, manifest string, tags []string, note *string, visibility *Visibility) (submit *Job, err error) {
	op := gqlclient.NewOperation("mutation submitJob ($manifest: String!, $tags: [String!], $note: String, $visibility: Visibility) {\n\tsubmit(manifest: $manifest, secrets: false, tags: $tags, note: $note, visibility: $visibility) {\n\t\tid\n\t\towner {\n\t\t\tcanonicalName\n\t\t}\n\t}\n}\n")
	op.Var("manifest", manifest)
	op.Var("tags", tags)
	op.Var("note", note)
	op.Var("visibility", visibility)
	var respData struct {
		Submit *Job
	}

M buildssrht/operations.graphql => buildssrht/operations.graphql +2 -2
@@ 1,5 1,5 @@
mutation submitJob($manifest: String!, $tags: [String!], $note: String) {
    submit(manifest: $manifest, secrets: false, tags: $tags, note: $note) {
mutation submitJob($manifest: String!, $tags: [String!], $note: String, $visibility: Visibility) {
    submit(manifest: $manifest, secrets: false, tags: $tags, note: $note, visibility: $visibility) {
        id
        owner {
            canonicalName

M gitea.go => gitea.go +2 -0
@@ 18,6 18,8 @@ type giteaRepository struct {
	Owner    struct {
		Username string `json:"username"`
	} `json:"owner"`
	Private  bool `json:"private"`
	Internal bool `json:"internal"`
}

type giteaCommit struct {

M job.go => job.go +8 -1
@@ 208,7 208,14 @@ func startJob(ctx *buildContext, filename string) error {
		panic("unreachable")
	}

	job, err := buildssrht.SubmitJob(ctx.srht, ctx, string(manifestBuf), tags, &note)
	visibility := buildssrht.VisibilityPublic
	if ctx.headRepo.Private {
		visibility = buildssrht.VisibilityPrivate
	} else if ctx.headRepo.Internal {
		visibility = buildssrht.VisibilityUnlisted
	}

	job, err := buildssrht.SubmitJob(ctx.srht, ctx, string(manifestBuf), tags, &note, &visibility)
	if err != nil {
		return fmt.Errorf("failed to submit sr.ht job: %v", err)
	}