M api/graph/model/artifact.go => api/graph/model/artifact.go +5 -5
@@ 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
M api/graph/model/group.go => api/graph/model/group.go +7 -7
@@ 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
M api/graph/model/job.go => api/graph/model/job.go +18 -18
@@ 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
M api/graph/model/secrets.go => api/graph/model/secrets.go +25 -25
@@ 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
M api/graph/model/task.go => api/graph/model/task.go +11 -11
@@ 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
M api/graph/model/user.go => api/graph/model/user.go +18 -18
@@ 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
M api/graph/schema.resolvers.go => api/graph/schema.resolvers.go +7 -7
@@ 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 {
M api/loaders/middleware.go => api/loaders/middleware.go +10 -10
@@ 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