From 4ba8dcd6fb7855f78a8e073227a85d14be53b5c3 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Sun, 12 Dec 2021 16:01:09 +0000 Subject: [PATCH] go fmt --- api/graph/model/artifact.go | 10 +++---- api/graph/model/group.go | 14 +++++----- api/graph/model/job.go | 36 ++++++++++++------------- api/graph/model/secrets.go | 50 +++++++++++++++++------------------ api/graph/model/task.go | 22 +++++++-------- api/graph/model/user.go | 36 ++++++++++++------------- api/graph/schema.resolvers.go | 14 +++++----- api/loaders/middleware.go | 20 +++++++------- 8 files changed, 101 insertions(+), 101 deletions(-) diff --git a/api/graph/model/artifact.go b/api/graph/model/artifact.go index 5431de0..037defc 100644 --- a/api/graph/model/artifact.go +++ b/api/graph/model/artifact.go @@ -36,13 +36,13 @@ func (a *Artifact) Fields() *database.ModelFields { } a.fields = &database.ModelFields{ Fields: []*database.FieldMap{ - { "created", "created", &a.Created }, - { "path", "path", &a.Path }, - { "size", "size", &a.Size }, - { "url", "url", &a.URL }, + {"created", "created", &a.Created}, + {"path", "path", &a.Path}, + {"size", "size", &a.Size}, + {"url", "url", &a.URL}, // Always fetch: - { "id", "", &a.ID }, + {"id", "", &a.ID}, }, } return a.fields diff --git a/api/graph/model/group.go b/api/graph/model/group.go index 170c837..cdd5eea 100644 --- a/api/graph/model/group.go +++ b/api/graph/model/group.go @@ -7,9 +7,9 @@ import ( ) type JobGroup struct { - ID int `json:"id"` - Created time.Time `json:"created"` - Note *string `json:"note"` + ID int `json:"id"` + Created time.Time `json:"created"` + Note *string `json:"note"` OwnerID int @@ -36,12 +36,12 @@ func (j *JobGroup) Fields() *database.ModelFields { } j.fields = &database.ModelFields{ Fields: []*database.FieldMap{ - { "created", "created", &j.Created }, - { "note", "note", &j.Note }, + {"created", "created", &j.Created}, + {"note", "note", &j.Note}, // Always fetch: - { "id", "", &j.ID }, - { "owner_id", "", &j.OwnerID }, + {"id", "", &j.ID}, + {"owner_id", "", &j.OwnerID}, }, } return j.fields diff --git a/api/graph/model/job.go b/api/graph/model/job.go index 7f3fdca..aa465a1 100644 --- a/api/graph/model/job.go +++ b/api/graph/model/job.go @@ -15,13 +15,13 @@ import ( ) type Job struct { - ID int `json:"id"` - Created time.Time `json:"created"` - Updated time.Time `json:"updated"` - Manifest string `json:"manifest"` - Note *string `json:"note"` - Image string `json:"image"` - Runner *string `json:"runner"` + ID int `json:"id"` + Created time.Time `json:"created"` + Updated time.Time `json:"updated"` + Manifest string `json:"manifest"` + Note *string `json:"note"` + Image string `json:"image"` + Runner *string `json:"runner"` OwnerID int JobGroupID *int @@ -68,19 +68,19 @@ func (j *Job) Fields() *database.ModelFields { } j.fields = &database.ModelFields{ Fields: []*database.FieldMap{ - { "created", "created", &j.Created }, - { "updated", "updated", &j.Updated }, - { "manifest", "manifest", &j.Manifest }, - { "note", "note", &j.Note }, - { "tags", "tags", &j.RawTags }, - { "status", "status", &j.RawStatus }, - { "image", "image", &j.Image }, + {"created", "created", &j.Created}, + {"updated", "updated", &j.Updated}, + {"manifest", "manifest", &j.Manifest}, + {"note", "note", &j.Note}, + {"tags", "tags", &j.RawTags}, + {"status", "status", &j.RawStatus}, + {"image", "image", &j.Image}, // Always fetch: - { "id", "", &j.ID }, - { "owner_id", "", &j.OwnerID }, - { "job_group_id", "", &j.JobGroupID }, - { "runner", "", &j.Runner }, + {"id", "", &j.ID}, + {"owner_id", "", &j.OwnerID}, + {"job_group_id", "", &j.JobGroupID}, + {"runner", "", &j.Runner}, }, } return j.fields diff --git a/api/graph/model/secrets.go b/api/graph/model/secrets.go index e33ab45..b09e682 100644 --- a/api/graph/model/secrets.go +++ b/api/graph/model/secrets.go @@ -3,19 +3,19 @@ package model import ( "context" "database/sql" - "time" "strconv" + "time" sq "github.com/Masterminds/squirrel" - "git.sr.ht/~sircmpwn/core-go/model" "git.sr.ht/~sircmpwn/core-go/database" + "git.sr.ht/~sircmpwn/core-go/model" ) const ( SECRET_PGPKEY = "pgp_key" SECRET_SSHKEY = "ssh_key" - SECRET_FILE = "plaintext_file" + SECRET_FILE = "plaintext_file" ) type Secret interface { @@ -85,29 +85,29 @@ func (s *RawSecret) ToSecret() Secret { switch s.SecretType { case SECRET_PGPKEY: return &PGPKey{ - ID: s.ID, - Created: s.Created, - UUID: s.UUID, - Name: s.Name, + ID: s.ID, + Created: s.Created, + UUID: s.UUID, + Name: s.Name, PrivateKey: s.Secret, } case SECRET_SSHKEY: return &SSHKey{ - ID: s.ID, - Created: s.Created, - UUID: s.UUID, - Name: s.Name, + ID: s.ID, + Created: s.Created, + UUID: s.UUID, + Name: s.Name, PrivateKey: s.Secret, } case SECRET_FILE: return &SecretFile{ - ID: s.ID, + ID: s.ID, Created: s.Created, - UUID: s.UUID, - Name: s.Name, - Path: *s.Path, - Mode: *s.Mode, - Data: s.Secret, + UUID: s.UUID, + Name: s.Name, + Path: *s.Path, + Mode: *s.Mode, + Data: s.Secret, } default: panic("Database invariant broken: unknown secret type") @@ -120,16 +120,16 @@ func (s *RawSecret) Fields() *database.ModelFields { } s.fields = &database.ModelFields{ Fields: []*database.FieldMap{ - { "created", "created", &s.Created }, - { "uuid", "uuid", &s.UUID }, - { "name", "name", &s.Name }, + {"created", "created", &s.Created}, + {"uuid", "uuid", &s.UUID}, + {"name", "name", &s.Name}, // Always fetch: - { "id", "", &s.ID }, - { "secret_type", "", &s.SecretType }, - { "secret", "", &s.Secret }, - { "path", "", &s.Path }, - { "mode", "", &s.Mode }, + {"id", "", &s.ID}, + {"secret_type", "", &s.SecretType}, + {"secret", "", &s.Secret}, + {"path", "", &s.Path}, + {"mode", "", &s.Mode}, }, } return s.fields diff --git a/api/graph/model/task.go b/api/graph/model/task.go index cae29e5..516291b 100644 --- a/api/graph/model/task.go +++ b/api/graph/model/task.go @@ -4,8 +4,8 @@ import ( "context" "database/sql" "fmt" - "strings" "strconv" + "strings" "time" sq "github.com/Masterminds/squirrel" @@ -15,10 +15,10 @@ import ( ) type Task struct { - ID int `json:"id"` - Created time.Time `json:"created"` - Updated time.Time `json:"updated"` - Name string `json:"name"` + ID int `json:"id"` + Created time.Time `json:"created"` + Updated time.Time `json:"updated"` + Name string `json:"name"` JobID int RawStatus string @@ -56,14 +56,14 @@ func (t *Task) Fields() *database.ModelFields { } t.fields = &database.ModelFields{ Fields: []*database.FieldMap{ - { "created", "created", &t.Created }, - { "updated", "updated", &t.Updated }, - { "name", "name", &t.Name }, - { "status", "status", &t.RawStatus }, + {"created", "created", &t.Created}, + {"updated", "updated", &t.Updated}, + {"name", "name", &t.Name}, + {"status", "status", &t.RawStatus}, // Always fetch: - { "id", "", &t.ID }, - { "job_id", "", &t.JobID }, + {"id", "", &t.ID}, + {"job_id", "", &t.JobID}, }, } return t.fields diff --git a/api/graph/model/user.go b/api/graph/model/user.go index 3619406..29c4806 100644 --- a/api/graph/model/user.go +++ b/api/graph/model/user.go @@ -13,14 +13,14 @@ import ( ) type User struct { - ID int `json:"id"` - Created time.Time `json:"created"` - Updated time.Time `json:"updated"` - Username string `json:"username"` - Email string `json:"email"` - URL *string `json:"url"` - Location *string `json:"location"` - Bio *string `json:"bio"` + ID int `json:"id"` + Created time.Time `json:"created"` + Updated time.Time `json:"updated"` + Username string `json:"username"` + Email string `json:"email"` + URL *string `json:"url"` + Location *string `json:"location"` + Bio *string `json:"bio"` alias string fields *database.ModelFields @@ -51,18 +51,18 @@ func (u *User) Fields() *database.ModelFields { } u.fields = &database.ModelFields{ Fields: []*database.FieldMap{ - { "id", "id", &u.ID }, - { "created", "created", &u.Created }, - { "updated", "updated", &u.Updated }, - { "username", "username", &u.Username }, - { "email", "email", &u.Email }, - { "url", "url", &u.URL }, - { "location", "location", &u.Location }, - { "bio", "bio", &u.Bio }, + {"id", "id", &u.ID}, + {"created", "created", &u.Created}, + {"updated", "updated", &u.Updated}, + {"username", "username", &u.Username}, + {"email", "email", &u.Email}, + {"url", "url", &u.URL}, + {"location", "location", &u.Location}, + {"bio", "bio", &u.Bio}, // Always fetch: - { "id", "", &u.ID }, - { "username", "", &u.Username }, + {"id", "", &u.ID}, + {"username", "", &u.Username}, }, } return u.fields diff --git a/api/graph/schema.resolvers.go b/api/graph/schema.resolvers.go index 3d27a1f..c202e7b 100644 --- a/api/graph/schema.resolvers.go +++ b/api/graph/schema.resolvers.go @@ -465,11 +465,11 @@ func (r *mutationResolver) CreateGroup(ctx context.Context, jobIds []int, trigge switch trigger.Type { case model.TriggerTypeEmail: triggerType = "email" - email := EmailDetails { - Action: "email", + email := EmailDetails{ + Action: "email", Condition: strings.ToLower(trigger.Condition.String()), - To: trigger.Email.To, - Cc: trigger.Email.Cc, + To: trigger.Email.To, + Cc: trigger.Email.Cc, InReplyTo: trigger.Email.InReplyTo, } buf, err := json.Marshal(&email) @@ -479,10 +479,10 @@ func (r *mutationResolver) CreateGroup(ctx context.Context, jobIds []int, trigge details = string(buf) case model.TriggerTypeWebhook: triggerType = "webhook" - webhook := WebhookDetails { - Action: "webhook", + webhook := WebhookDetails{ + Action: "webhook", Condition: strings.ToLower(trigger.Condition.String()), - URL: trigger.Webhook.URL, + URL: trigger.Webhook.URL, } buf, err := json.Marshal(&webhook) if err != nil { diff --git a/api/loaders/middleware.go b/api/loaders/middleware.go index e9892a0..432c2de 100644 --- a/api/loaders/middleware.go +++ b/api/loaders/middleware.go @@ -12,11 +12,11 @@ import ( "net/http" "time" - "github.com/lib/pq" sq "github.com/Masterminds/squirrel" + "github.com/lib/pq" - "git.sr.ht/~sircmpwn/core-go/database" "git.sr.ht/~sircmpwn/builds.sr.ht/api/graph/model" + "git.sr.ht/~sircmpwn/core-go/database" ) var loadersCtxKey = &contextKey{"loaders"} @@ -37,8 +37,8 @@ func fetchUsersByID(ctx context.Context) func(ids []int) ([]*model.User, []error users := make([]*model.User, len(ids)) if err := database.WithTx(ctx, &sql.TxOptions{ Isolation: 0, - ReadOnly: true, - }, func (tx *sql.Tx) error { + ReadOnly: true, + }, func(tx *sql.Tx) error { var ( err error rows *sql.Rows @@ -82,8 +82,8 @@ func fetchUsersByName(ctx context.Context) func(names []string) ([]*model.User, users := make([]*model.User, len(names)) if err := database.WithTx(ctx, &sql.TxOptions{ Isolation: 0, - ReadOnly: true, - }, func (tx *sql.Tx) error { + ReadOnly: true, + }, func(tx *sql.Tx) error { var ( err error rows *sql.Rows @@ -127,8 +127,8 @@ func fetchJobsByID(ctx context.Context) func(ids []int) ([]*model.Job, []error) jobs := make([]*model.Job, len(ids)) if err := database.WithTx(ctx, &sql.TxOptions{ Isolation: 0, - ReadOnly: true, - }, func (tx *sql.Tx) error { + ReadOnly: true, + }, func(tx *sql.Tx) error { var ( err error rows *sql.Rows @@ -172,8 +172,8 @@ func fetchJobGroupsByID(ctx context.Context) func(ids []int) ([]*model.JobGroup, groups := make([]*model.JobGroup, len(ids)) if err := database.WithTx(ctx, &sql.TxOptions{ Isolation: 0, - ReadOnly: true, - }, func (tx *sql.Tx) error { + ReadOnly: true, + }, func(tx *sql.Tx) error { var ( err error rows *sql.Rows -- 2.38.5