From b0cfe7b205d78e8162be3aa7de505fe2bdd6abd7 Mon Sep 17 00:00:00 2001 From: Giovanni Harting <539@idlegandalf.com> Date: Tue, 13 Jul 2021 18:07:29 +0200 Subject: [PATCH] Add database backend (SQLite) (#26) Add database with background information for each pkgbase, for possible future use. A static status page is generated from the db. Currently includes: * sub-packages * build-time * build-duration * status (failed, latest, skipped, queued, building, build) * version (both from PKGBUILD and repo) * last checked Database is currently only used for informational purposes. Goal is to refactor many (expensive) methods to use the db instead of searching/parsing files. Reviewed-on: https://git.harting.dev/anonfunc/ALHP.GO/pulls/26 Co-authored-by: Giovanni Harting <539@idlegandalf.com> Co-committed-by: Giovanni Harting <539@idlegandalf.com> --- config.yaml | 1 + ent/client.go | 212 ++++++ ent/config.go | 59 ++ ent/context.go | 33 + ent/dbpackage.go | 208 ++++++ ent/dbpackage/dbpackage.go | 73 +++ ent/dbpackage/where.go | 1277 ++++++++++++++++++++++++++++++++++++ ent/dbpackage_create.go | 412 ++++++++++++ ent/dbpackage_delete.go | 108 +++ ent/dbpackage_query.go | 906 +++++++++++++++++++++++++ ent/dbpackage_update.go | 915 ++++++++++++++++++++++++++ ent/ent.go | 279 ++++++++ ent/enttest/enttest.go | 78 +++ ent/generate.go | 3 + ent/hook/hook.go | 204 ++++++ ent/migrate/migrate.go | 72 ++ ent/migrate/schema.go | 40 ++ ent/mutation.go | 1080 ++++++++++++++++++++++++++++++ ent/predicate/predicate.go | 10 + ent/runtime.go | 36 + ent/runtime/runtime.go | 10 + ent/schema/dbpackage.go | 33 + ent/tx.go | 210 ++++++ go.mod | 2 + go.sum | 384 ++++++++++- main.go | 279 ++++++-- tpl/status.html | 72 ++ 27 files changed, 6949 insertions(+), 47 deletions(-) create mode 100644 ent/client.go create mode 100644 ent/config.go create mode 100644 ent/context.go create mode 100644 ent/dbpackage.go create mode 100644 ent/dbpackage/dbpackage.go create mode 100644 ent/dbpackage/where.go create mode 100644 ent/dbpackage_create.go create mode 100644 ent/dbpackage_delete.go create mode 100644 ent/dbpackage_query.go create mode 100644 ent/dbpackage_update.go create mode 100644 ent/ent.go create mode 100644 ent/enttest/enttest.go create mode 100644 ent/generate.go create mode 100644 ent/hook/hook.go create mode 100644 ent/migrate/migrate.go create mode 100644 ent/migrate/schema.go create mode 100644 ent/mutation.go create mode 100644 ent/predicate/predicate.go create mode 100644 ent/runtime.go create mode 100644 ent/runtime/runtime.go create mode 100644 ent/schema/dbpackage.go create mode 100644 ent/tx.go create mode 100644 tpl/status.html diff --git a/config.yaml b/config.yaml index 8919ddc..9395edb 100644 --- a/config.yaml +++ b/config.yaml @@ -13,6 +13,7 @@ basedir: chroot: /var/lib/alhp/chroot/ makepkg: /var/lib/alhp/makepkg/ upstream: /var/lib/alhp/upstream/ + db: /var/lib/alhp/alhp.db march: - x86-64-v3 diff --git a/ent/client.go b/ent/client.go new file mode 100644 index 0000000..4f51008 --- /dev/null +++ b/ent/client.go @@ -0,0 +1,212 @@ +// Code generated by entc, DO NOT EDIT. + +package ent + +import ( + "context" + "fmt" + "log" + + "ALHP.go/ent/migrate" + + "ALHP.go/ent/dbpackage" + + "entgo.io/ent/dialect" + "entgo.io/ent/dialect/sql" +) + +// Client is the client that holds all ent builders. +type Client struct { + config + // Schema is the client for creating, migrating and dropping schema. + Schema *migrate.Schema + // DbPackage is the client for interacting with the DbPackage builders. + DbPackage *DbPackageClient +} + +// NewClient creates a new client configured with the given options. +func NewClient(opts ...Option) *Client { + cfg := config{log: log.Println, hooks: &hooks{}} + cfg.options(opts...) + client := &Client{config: cfg} + client.init() + return client +} + +func (c *Client) init() { + c.Schema = migrate.NewSchema(c.driver) + c.DbPackage = NewDbPackageClient(c.config) +} + +// Open opens a database/sql.DB specified by the driver name and +// the data source name, and returns a new client attached to it. +// Optional parameters can be added for configuring the client. +func Open(driverName, dataSourceName string, options ...Option) (*Client, error) { + switch driverName { + case dialect.MySQL, dialect.Postgres, dialect.SQLite: + drv, err := sql.Open(driverName, dataSourceName) + if err != nil { + return nil, err + } + return NewClient(append(options, Driver(drv))...), nil + default: + return nil, fmt.Errorf("unsupported driver: %q", driverName) + } +} + +// Tx returns a new transactional client. The provided context +// is used until the transaction is committed or rolled back. +func (c *Client) Tx(ctx context.Context) (*Tx, error) { + if _, ok := c.driver.(*txDriver); ok { + return nil, fmt.Errorf("ent: cannot start a transaction within a transaction") + } + tx, err := newTx(ctx, c.driver) + if err != nil { + return nil, fmt.Errorf("ent: starting a transaction: %w", err) + } + cfg := c.config + cfg.driver = tx + return &Tx{ + ctx: ctx, + config: cfg, + DbPackage: NewDbPackageClient(cfg), + }, nil +} + +// BeginTx returns a transactional client with specified options. +func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error) { + if _, ok := c.driver.(*txDriver); ok { + return nil, fmt.Errorf("ent: cannot start a transaction within a transaction") + } + tx, err := c.driver.(interface { + BeginTx(context.Context, *sql.TxOptions) (dialect.Tx, error) + }).BeginTx(ctx, opts) + if err != nil { + return nil, fmt.Errorf("ent: starting a transaction: %w", err) + } + cfg := c.config + cfg.driver = &txDriver{tx: tx, drv: c.driver} + return &Tx{ + config: cfg, + DbPackage: NewDbPackageClient(cfg), + }, nil +} + +// Debug returns a new debug-client. It's used to get verbose logging on specific operations. +// +// client.Debug(). +// DbPackage. +// Query(). +// Count(ctx) +// +func (c *Client) Debug() *Client { + if c.debug { + return c + } + cfg := c.config + cfg.driver = dialect.Debug(c.driver, c.log) + client := &Client{config: cfg} + client.init() + return client +} + +// Close closes the database connection and prevents new queries from starting. +func (c *Client) Close() error { + return c.driver.Close() +} + +// Use adds the mutation hooks to all the entity clients. +// In order to add hooks to a specific client, call: `client.Node.Use(...)`. +func (c *Client) Use(hooks ...Hook) { + c.DbPackage.Use(hooks...) +} + +// DbPackageClient is a client for the DbPackage schema. +type DbPackageClient struct { + config +} + +// NewDbPackageClient returns a client for the DbPackage from the given config. +func NewDbPackageClient(c config) *DbPackageClient { + return &DbPackageClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `dbpackage.Hooks(f(g(h())))`. +func (c *DbPackageClient) Use(hooks ...Hook) { + c.hooks.DbPackage = append(c.hooks.DbPackage, hooks...) +} + +// Create returns a create builder for DbPackage. +func (c *DbPackageClient) Create() *DbPackageCreate { + mutation := newDbPackageMutation(c.config, OpCreate) + return &DbPackageCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of DbPackage entities. +func (c *DbPackageClient) CreateBulk(builders ...*DbPackageCreate) *DbPackageCreateBulk { + return &DbPackageCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for DbPackage. +func (c *DbPackageClient) Update() *DbPackageUpdate { + mutation := newDbPackageMutation(c.config, OpUpdate) + return &DbPackageUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *DbPackageClient) UpdateOne(dp *DbPackage) *DbPackageUpdateOne { + mutation := newDbPackageMutation(c.config, OpUpdateOne, withDbPackage(dp)) + return &DbPackageUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *DbPackageClient) UpdateOneID(id int) *DbPackageUpdateOne { + mutation := newDbPackageMutation(c.config, OpUpdateOne, withDbPackageID(id)) + return &DbPackageUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for DbPackage. +func (c *DbPackageClient) Delete() *DbPackageDelete { + mutation := newDbPackageMutation(c.config, OpDelete) + return &DbPackageDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a delete builder for the given entity. +func (c *DbPackageClient) DeleteOne(dp *DbPackage) *DbPackageDeleteOne { + return c.DeleteOneID(dp.ID) +} + +// DeleteOneID returns a delete builder for the given id. +func (c *DbPackageClient) DeleteOneID(id int) *DbPackageDeleteOne { + builder := c.Delete().Where(dbpackage.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &DbPackageDeleteOne{builder} +} + +// Query returns a query builder for DbPackage. +func (c *DbPackageClient) Query() *DbPackageQuery { + return &DbPackageQuery{ + config: c.config, + } +} + +// Get returns a DbPackage entity by its id. +func (c *DbPackageClient) Get(ctx context.Context, id int) (*DbPackage, error) { + return c.Query().Where(dbpackage.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *DbPackageClient) GetX(ctx context.Context, id int) *DbPackage { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// Hooks returns the client hooks. +func (c *DbPackageClient) Hooks() []Hook { + return c.hooks.DbPackage +} diff --git a/ent/config.go b/ent/config.go new file mode 100644 index 0000000..b200d00 --- /dev/null +++ b/ent/config.go @@ -0,0 +1,59 @@ +// Code generated by entc, DO NOT EDIT. + +package ent + +import ( + "entgo.io/ent" + "entgo.io/ent/dialect" +) + +// Option function to configure the client. +type Option func(*config) + +// Config is the configuration for the client and its builder. +type config struct { + // driver used for executing database requests. + driver dialect.Driver + // debug enable a debug logging. + debug bool + // log used for logging on debug mode. + log func(...interface{}) + // hooks to execute on mutations. + hooks *hooks +} + +// hooks per client, for fast access. +type hooks struct { + DbPackage []ent.Hook +} + +// Options applies the options on the config object. +func (c *config) options(opts ...Option) { + for _, opt := range opts { + opt(c) + } + if c.debug { + c.driver = dialect.Debug(c.driver, c.log) + } +} + +// Debug enables debug logging on the ent.Driver. +func Debug() Option { + return func(c *config) { + c.debug = true + } +} + +// Log sets the logging function for debug mode. +func Log(fn func(...interface{})) Option { + return func(c *config) { + c.log = fn + } +} + +// Driver configures the client driver. +func Driver(driver dialect.Driver) Option { + return func(c *config) { + c.driver = driver + } +} diff --git a/ent/context.go b/ent/context.go new file mode 100644 index 0000000..0840726 --- /dev/null +++ b/ent/context.go @@ -0,0 +1,33 @@ +// Code generated by entc, DO NOT EDIT. + +package ent + +import ( + "context" +) + +type clientCtxKey struct{} + +// FromContext returns a Client stored inside a context, or nil if there isn't one. +func FromContext(ctx context.Context) *Client { + c, _ := ctx.Value(clientCtxKey{}).(*Client) + return c +} + +// NewContext returns a new context with the given Client attached. +func NewContext(parent context.Context, c *Client) context.Context { + return context.WithValue(parent, clientCtxKey{}, c) +} + +type txCtxKey struct{} + +// TxFromContext returns a Tx stored inside a context, or nil if there isn't one. +func TxFromContext(ctx context.Context) *Tx { + tx, _ := ctx.Value(txCtxKey{}).(*Tx) + return tx +} + +// NewTxContext returns a new context with the given Tx attached. +func NewTxContext(parent context.Context, tx *Tx) context.Context { + return context.WithValue(parent, txCtxKey{}, tx) +} diff --git a/ent/dbpackage.go b/ent/dbpackage.go new file mode 100644 index 0000000..a5c9bdf --- /dev/null +++ b/ent/dbpackage.go @@ -0,0 +1,208 @@ +// Code generated by entc, DO NOT EDIT. + +package ent + +import ( + "encoding/json" + "fmt" + "strings" + "time" + + "ALHP.go/ent/dbpackage" + "entgo.io/ent/dialect/sql" +) + +// DbPackage is the model entity for the DbPackage schema. +type DbPackage struct { + config `json:"-"` + // ID of the ent. + ID int `json:"id,omitempty"` + // Pkgbase holds the value of the "pkgbase" field. + Pkgbase string `json:"pkgbase,omitempty"` + // Packages holds the value of the "packages" field. + Packages []string `json:"packages,omitempty"` + // Status holds the value of the "status" field. + Status int `json:"status,omitempty"` + // SkipReason holds the value of the "skip_reason" field. + SkipReason string `json:"skip_reason,omitempty"` + // Repository holds the value of the "repository" field. + Repository string `json:"repository,omitempty"` + // March holds the value of the "march" field. + March string `json:"march,omitempty"` + // Version holds the value of the "version" field. + Version string `json:"version,omitempty"` + // RepoVersion holds the value of the "repo_version" field. + RepoVersion string `json:"repo_version,omitempty"` + // BuildTime holds the value of the "build_time" field. + BuildTime time.Time `json:"build_time,omitempty"` + // BuildDuration holds the value of the "build_duration" field. + BuildDuration uint64 `json:"build_duration,omitempty"` + // Updated holds the value of the "updated" field. + Updated time.Time `json:"updated,omitempty"` +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*DbPackage) scanValues(columns []string) ([]interface{}, error) { + values := make([]interface{}, len(columns)) + for i := range columns { + switch columns[i] { + case dbpackage.FieldPackages: + values[i] = new([]byte) + case dbpackage.FieldID, dbpackage.FieldStatus, dbpackage.FieldBuildDuration: + values[i] = new(sql.NullInt64) + case dbpackage.FieldPkgbase, dbpackage.FieldSkipReason, dbpackage.FieldRepository, dbpackage.FieldMarch, dbpackage.FieldVersion, dbpackage.FieldRepoVersion: + values[i] = new(sql.NullString) + case dbpackage.FieldBuildTime, dbpackage.FieldUpdated: + values[i] = new(sql.NullTime) + default: + return nil, fmt.Errorf("unexpected column %q for type DbPackage", columns[i]) + } + } + return values, nil +} + +// assignValues assigns the values that were returned from sql.Rows (after scanning) +// to the DbPackage fields. +func (dp *DbPackage) assignValues(columns []string, values []interface{}) error { + if m, n := len(values), len(columns); m < n { + return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) + } + for i := range columns { + switch columns[i] { + case dbpackage.FieldID: + value, ok := values[i].(*sql.NullInt64) + if !ok { + return fmt.Errorf("unexpected type %T for field id", value) + } + dp.ID = int(value.Int64) + case dbpackage.FieldPkgbase: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field pkgbase", values[i]) + } else if value.Valid { + dp.Pkgbase = value.String + } + case dbpackage.FieldPackages: + + if value, ok := values[i].(*[]byte); !ok { + return fmt.Errorf("unexpected type %T for field packages", values[i]) + } else if value != nil && len(*value) > 0 { + if err := json.Unmarshal(*value, &dp.Packages); err != nil { + return fmt.Errorf("unmarshal field packages: %w", err) + } + } + case dbpackage.FieldStatus: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field status", values[i]) + } else if value.Valid { + dp.Status = int(value.Int64) + } + case dbpackage.FieldSkipReason: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field skip_reason", values[i]) + } else if value.Valid { + dp.SkipReason = value.String + } + case dbpackage.FieldRepository: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field repository", values[i]) + } else if value.Valid { + dp.Repository = value.String + } + case dbpackage.FieldMarch: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field march", values[i]) + } else if value.Valid { + dp.March = value.String + } + case dbpackage.FieldVersion: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field version", values[i]) + } else if value.Valid { + dp.Version = value.String + } + case dbpackage.FieldRepoVersion: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field repo_version", values[i]) + } else if value.Valid { + dp.RepoVersion = value.String + } + case dbpackage.FieldBuildTime: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field build_time", values[i]) + } else if value.Valid { + dp.BuildTime = value.Time + } + case dbpackage.FieldBuildDuration: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field build_duration", values[i]) + } else if value.Valid { + dp.BuildDuration = uint64(value.Int64) + } + case dbpackage.FieldUpdated: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field updated", values[i]) + } else if value.Valid { + dp.Updated = value.Time + } + } + } + return nil +} + +// Update returns a builder for updating this DbPackage. +// Note that you need to call DbPackage.Unwrap() before calling this method if this DbPackage +// was returned from a transaction, and the transaction was committed or rolled back. +func (dp *DbPackage) Update() *DbPackageUpdateOne { + return (&DbPackageClient{config: dp.config}).UpdateOne(dp) +} + +// Unwrap unwraps the DbPackage entity that was returned from a transaction after it was closed, +// so that all future queries will be executed through the driver which created the transaction. +func (dp *DbPackage) Unwrap() *DbPackage { + tx, ok := dp.config.driver.(*txDriver) + if !ok { + panic("ent: DbPackage is not a transactional entity") + } + dp.config.driver = tx.drv + return dp +} + +// String implements the fmt.Stringer. +func (dp *DbPackage) String() string { + var builder strings.Builder + builder.WriteString("DbPackage(") + builder.WriteString(fmt.Sprintf("id=%v", dp.ID)) + builder.WriteString(", pkgbase=") + builder.WriteString(dp.Pkgbase) + builder.WriteString(", packages=") + builder.WriteString(fmt.Sprintf("%v", dp.Packages)) + builder.WriteString(", status=") + builder.WriteString(fmt.Sprintf("%v", dp.Status)) + builder.WriteString(", skip_reason=") + builder.WriteString(dp.SkipReason) + builder.WriteString(", repository=") + builder.WriteString(dp.Repository) + builder.WriteString(", march=") + builder.WriteString(dp.March) + builder.WriteString(", version=") + builder.WriteString(dp.Version) + builder.WriteString(", repo_version=") + builder.WriteString(dp.RepoVersion) + builder.WriteString(", build_time=") + builder.WriteString(dp.BuildTime.Format(time.ANSIC)) + builder.WriteString(", build_duration=") + builder.WriteString(fmt.Sprintf("%v", dp.BuildDuration)) + builder.WriteString(", updated=") + builder.WriteString(dp.Updated.Format(time.ANSIC)) + builder.WriteByte(')') + return builder.String() +} + +// DbPackages is a parsable slice of DbPackage. +type DbPackages []*DbPackage + +func (dp DbPackages) config(cfg config) { + for _i := range dp { + dp[_i].config = cfg + } +} diff --git a/ent/dbpackage/dbpackage.go b/ent/dbpackage/dbpackage.go new file mode 100644 index 0000000..8e35390 --- /dev/null +++ b/ent/dbpackage/dbpackage.go @@ -0,0 +1,73 @@ +// Code generated by entc, DO NOT EDIT. + +package dbpackage + +const ( + // Label holds the string label denoting the dbpackage type in the database. + Label = "db_package" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // FieldPkgbase holds the string denoting the pkgbase field in the database. + FieldPkgbase = "pkgbase" + // FieldPackages holds the string denoting the packages field in the database. + FieldPackages = "packages" + // FieldStatus holds the string denoting the status field in the database. + FieldStatus = "status" + // FieldSkipReason holds the string denoting the skip_reason field in the database. + FieldSkipReason = "skip_reason" + // FieldRepository holds the string denoting the repository field in the database. + FieldRepository = "repository" + // FieldMarch holds the string denoting the march field in the database. + FieldMarch = "march" + // FieldVersion holds the string denoting the version field in the database. + FieldVersion = "version" + // FieldRepoVersion holds the string denoting the repo_version field in the database. + FieldRepoVersion = "repo_version" + // FieldBuildTime holds the string denoting the build_time field in the database. + FieldBuildTime = "build_time" + // FieldBuildDuration holds the string denoting the build_duration field in the database. + FieldBuildDuration = "build_duration" + // FieldUpdated holds the string denoting the updated field in the database. + FieldUpdated = "updated" + // Table holds the table name of the dbpackage in the database. + Table = "db_packages" +) + +// Columns holds all SQL columns for dbpackage fields. +var Columns = []string{ + FieldID, + FieldPkgbase, + FieldPackages, + FieldStatus, + FieldSkipReason, + FieldRepository, + FieldMarch, + FieldVersion, + FieldRepoVersion, + FieldBuildTime, + FieldBuildDuration, + FieldUpdated, +} + +// ValidColumn reports if the column name is valid (part of the table columns). +func ValidColumn(column string) bool { + for i := range Columns { + if column == Columns[i] { + return true + } + } + return false +} + +var ( + // PkgbaseValidator is a validator for the "pkgbase" field. It is called by the builders before save. + PkgbaseValidator func(string) error + // StatusValidator is a validator for the "status" field. It is called by the builders before save. + StatusValidator func(int) error + // RepositoryValidator is a validator for the "repository" field. It is called by the builders before save. + RepositoryValidator func(string) error + // MarchValidator is a validator for the "march" field. It is called by the builders before save. + MarchValidator func(string) error + // BuildDurationValidator is a validator for the "build_duration" field. It is called by the builders before save. + BuildDurationValidator func(uint64) error +) diff --git a/ent/dbpackage/where.go b/ent/dbpackage/where.go new file mode 100644 index 0000000..296a986 --- /dev/null +++ b/ent/dbpackage/where.go @@ -0,0 +1,1277 @@ +// Code generated by entc, DO NOT EDIT. + +package dbpackage + +import ( + "time" + + "ALHP.go/ent/predicate" + "entgo.io/ent/dialect/sql" +) + +// ID filters vertices based on their ID field. +func ID(id int) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldID), id)) + }) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id int) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldID), id)) + }) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id int) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldID), id)) + }) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...int) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(ids) == 0 { + s.Where(sql.False()) + return + } + v := make([]interface{}, len(ids)) + for i := range v { + v[i] = ids[i] + } + s.Where(sql.In(s.C(FieldID), v...)) + }) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...int) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(ids) == 0 { + s.Where(sql.False()) + return + } + v := make([]interface{}, len(ids)) + for i := range v { + v[i] = ids[i] + } + s.Where(sql.NotIn(s.C(FieldID), v...)) + }) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id int) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldID), id)) + }) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id int) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldID), id)) + }) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id int) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldID), id)) + }) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id int) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldID), id)) + }) +} + +// Pkgbase applies equality check predicate on the "pkgbase" field. It's identical to PkgbaseEQ. +func Pkgbase(v string) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldPkgbase), v)) + }) +} + +// Status applies equality check predicate on the "status" field. It's identical to StatusEQ. +func Status(v int) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldStatus), v)) + }) +} + +// SkipReason applies equality check predicate on the "skip_reason" field. It's identical to SkipReasonEQ. +func SkipReason(v string) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldSkipReason), v)) + }) +} + +// Repository applies equality check predicate on the "repository" field. It's identical to RepositoryEQ. +func Repository(v string) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldRepository), v)) + }) +} + +// March applies equality check predicate on the "march" field. It's identical to MarchEQ. +func March(v string) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldMarch), v)) + }) +} + +// Version applies equality check predicate on the "version" field. It's identical to VersionEQ. +func Version(v string) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldVersion), v)) + }) +} + +// RepoVersion applies equality check predicate on the "repo_version" field. It's identical to RepoVersionEQ. +func RepoVersion(v string) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldRepoVersion), v)) + }) +} + +// BuildTime applies equality check predicate on the "build_time" field. It's identical to BuildTimeEQ. +func BuildTime(v time.Time) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldBuildTime), v)) + }) +} + +// BuildDuration applies equality check predicate on the "build_duration" field. It's identical to BuildDurationEQ. +func BuildDuration(v uint64) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldBuildDuration), v)) + }) +} + +// Updated applies equality check predicate on the "updated" field. It's identical to UpdatedEQ. +func Updated(v time.Time) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldUpdated), v)) + }) +} + +// PkgbaseEQ applies the EQ predicate on the "pkgbase" field. +func PkgbaseEQ(v string) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldPkgbase), v)) + }) +} + +// PkgbaseNEQ applies the NEQ predicate on the "pkgbase" field. +func PkgbaseNEQ(v string) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldPkgbase), v)) + }) +} + +// PkgbaseIn applies the In predicate on the "pkgbase" field. +func PkgbaseIn(vs ...string) predicate.DbPackage { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.DbPackage(func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(v) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.In(s.C(FieldPkgbase), v...)) + }) +} + +// PkgbaseNotIn applies the NotIn predicate on the "pkgbase" field. +func PkgbaseNotIn(vs ...string) predicate.DbPackage { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.DbPackage(func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(v) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.NotIn(s.C(FieldPkgbase), v...)) + }) +} + +// PkgbaseGT applies the GT predicate on the "pkgbase" field. +func PkgbaseGT(v string) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldPkgbase), v)) + }) +} + +// PkgbaseGTE applies the GTE predicate on the "pkgbase" field. +func PkgbaseGTE(v string) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldPkgbase), v)) + }) +} + +// PkgbaseLT applies the LT predicate on the "pkgbase" field. +func PkgbaseLT(v string) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldPkgbase), v)) + }) +} + +// PkgbaseLTE applies the LTE predicate on the "pkgbase" field. +func PkgbaseLTE(v string) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldPkgbase), v)) + }) +} + +// PkgbaseContains applies the Contains predicate on the "pkgbase" field. +func PkgbaseContains(v string) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.Contains(s.C(FieldPkgbase), v)) + }) +} + +// PkgbaseHasPrefix applies the HasPrefix predicate on the "pkgbase" field. +func PkgbaseHasPrefix(v string) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.HasPrefix(s.C(FieldPkgbase), v)) + }) +} + +// PkgbaseHasSuffix applies the HasSuffix predicate on the "pkgbase" field. +func PkgbaseHasSuffix(v string) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.HasSuffix(s.C(FieldPkgbase), v)) + }) +} + +// PkgbaseEqualFold applies the EqualFold predicate on the "pkgbase" field. +func PkgbaseEqualFold(v string) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.EqualFold(s.C(FieldPkgbase), v)) + }) +} + +// PkgbaseContainsFold applies the ContainsFold predicate on the "pkgbase" field. +func PkgbaseContainsFold(v string) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.ContainsFold(s.C(FieldPkgbase), v)) + }) +} + +// PackagesIsNil applies the IsNil predicate on the "packages" field. +func PackagesIsNil() predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.IsNull(s.C(FieldPackages))) + }) +} + +// PackagesNotNil applies the NotNil predicate on the "packages" field. +func PackagesNotNil() predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.NotNull(s.C(FieldPackages))) + }) +} + +// StatusEQ applies the EQ predicate on the "status" field. +func StatusEQ(v int) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldStatus), v)) + }) +} + +// StatusNEQ applies the NEQ predicate on the "status" field. +func StatusNEQ(v int) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldStatus), v)) + }) +} + +// StatusIn applies the In predicate on the "status" field. +func StatusIn(vs ...int) predicate.DbPackage { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.DbPackage(func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(v) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.In(s.C(FieldStatus), v...)) + }) +} + +// StatusNotIn applies the NotIn predicate on the "status" field. +func StatusNotIn(vs ...int) predicate.DbPackage { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.DbPackage(func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(v) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.NotIn(s.C(FieldStatus), v...)) + }) +} + +// StatusGT applies the GT predicate on the "status" field. +func StatusGT(v int) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldStatus), v)) + }) +} + +// StatusGTE applies the GTE predicate on the "status" field. +func StatusGTE(v int) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldStatus), v)) + }) +} + +// StatusLT applies the LT predicate on the "status" field. +func StatusLT(v int) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldStatus), v)) + }) +} + +// StatusLTE applies the LTE predicate on the "status" field. +func StatusLTE(v int) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldStatus), v)) + }) +} + +// StatusIsNil applies the IsNil predicate on the "status" field. +func StatusIsNil() predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.IsNull(s.C(FieldStatus))) + }) +} + +// StatusNotNil applies the NotNil predicate on the "status" field. +func StatusNotNil() predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.NotNull(s.C(FieldStatus))) + }) +} + +// SkipReasonEQ applies the EQ predicate on the "skip_reason" field. +func SkipReasonEQ(v string) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldSkipReason), v)) + }) +} + +// SkipReasonNEQ applies the NEQ predicate on the "skip_reason" field. +func SkipReasonNEQ(v string) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldSkipReason), v)) + }) +} + +// SkipReasonIn applies the In predicate on the "skip_reason" field. +func SkipReasonIn(vs ...string) predicate.DbPackage { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.DbPackage(func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(v) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.In(s.C(FieldSkipReason), v...)) + }) +} + +// SkipReasonNotIn applies the NotIn predicate on the "skip_reason" field. +func SkipReasonNotIn(vs ...string) predicate.DbPackage { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.DbPackage(func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(v) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.NotIn(s.C(FieldSkipReason), v...)) + }) +} + +// SkipReasonGT applies the GT predicate on the "skip_reason" field. +func SkipReasonGT(v string) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldSkipReason), v)) + }) +} + +// SkipReasonGTE applies the GTE predicate on the "skip_reason" field. +func SkipReasonGTE(v string) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldSkipReason), v)) + }) +} + +// SkipReasonLT applies the LT predicate on the "skip_reason" field. +func SkipReasonLT(v string) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldSkipReason), v)) + }) +} + +// SkipReasonLTE applies the LTE predicate on the "skip_reason" field. +func SkipReasonLTE(v string) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldSkipReason), v)) + }) +} + +// SkipReasonContains applies the Contains predicate on the "skip_reason" field. +func SkipReasonContains(v string) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.Contains(s.C(FieldSkipReason), v)) + }) +} + +// SkipReasonHasPrefix applies the HasPrefix predicate on the "skip_reason" field. +func SkipReasonHasPrefix(v string) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.HasPrefix(s.C(FieldSkipReason), v)) + }) +} + +// SkipReasonHasSuffix applies the HasSuffix predicate on the "skip_reason" field. +func SkipReasonHasSuffix(v string) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.HasSuffix(s.C(FieldSkipReason), v)) + }) +} + +// SkipReasonIsNil applies the IsNil predicate on the "skip_reason" field. +func SkipReasonIsNil() predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.IsNull(s.C(FieldSkipReason))) + }) +} + +// SkipReasonNotNil applies the NotNil predicate on the "skip_reason" field. +func SkipReasonNotNil() predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.NotNull(s.C(FieldSkipReason))) + }) +} + +// SkipReasonEqualFold applies the EqualFold predicate on the "skip_reason" field. +func SkipReasonEqualFold(v string) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.EqualFold(s.C(FieldSkipReason), v)) + }) +} + +// SkipReasonContainsFold applies the ContainsFold predicate on the "skip_reason" field. +func SkipReasonContainsFold(v string) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.ContainsFold(s.C(FieldSkipReason), v)) + }) +} + +// RepositoryEQ applies the EQ predicate on the "repository" field. +func RepositoryEQ(v string) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldRepository), v)) + }) +} + +// RepositoryNEQ applies the NEQ predicate on the "repository" field. +func RepositoryNEQ(v string) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldRepository), v)) + }) +} + +// RepositoryIn applies the In predicate on the "repository" field. +func RepositoryIn(vs ...string) predicate.DbPackage { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.DbPackage(func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(v) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.In(s.C(FieldRepository), v...)) + }) +} + +// RepositoryNotIn applies the NotIn predicate on the "repository" field. +func RepositoryNotIn(vs ...string) predicate.DbPackage { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.DbPackage(func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(v) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.NotIn(s.C(FieldRepository), v...)) + }) +} + +// RepositoryGT applies the GT predicate on the "repository" field. +func RepositoryGT(v string) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldRepository), v)) + }) +} + +// RepositoryGTE applies the GTE predicate on the "repository" field. +func RepositoryGTE(v string) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldRepository), v)) + }) +} + +// RepositoryLT applies the LT predicate on the "repository" field. +func RepositoryLT(v string) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldRepository), v)) + }) +} + +// RepositoryLTE applies the LTE predicate on the "repository" field. +func RepositoryLTE(v string) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldRepository), v)) + }) +} + +// RepositoryContains applies the Contains predicate on the "repository" field. +func RepositoryContains(v string) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.Contains(s.C(FieldRepository), v)) + }) +} + +// RepositoryHasPrefix applies the HasPrefix predicate on the "repository" field. +func RepositoryHasPrefix(v string) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.HasPrefix(s.C(FieldRepository), v)) + }) +} + +// RepositoryHasSuffix applies the HasSuffix predicate on the "repository" field. +func RepositoryHasSuffix(v string) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.HasSuffix(s.C(FieldRepository), v)) + }) +} + +// RepositoryEqualFold applies the EqualFold predicate on the "repository" field. +func RepositoryEqualFold(v string) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.EqualFold(s.C(FieldRepository), v)) + }) +} + +// RepositoryContainsFold applies the ContainsFold predicate on the "repository" field. +func RepositoryContainsFold(v string) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.ContainsFold(s.C(FieldRepository), v)) + }) +} + +// MarchEQ applies the EQ predicate on the "march" field. +func MarchEQ(v string) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldMarch), v)) + }) +} + +// MarchNEQ applies the NEQ predicate on the "march" field. +func MarchNEQ(v string) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldMarch), v)) + }) +} + +// MarchIn applies the In predicate on the "march" field. +func MarchIn(vs ...string) predicate.DbPackage { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.DbPackage(func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(v) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.In(s.C(FieldMarch), v...)) + }) +} + +// MarchNotIn applies the NotIn predicate on the "march" field. +func MarchNotIn(vs ...string) predicate.DbPackage { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.DbPackage(func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(v) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.NotIn(s.C(FieldMarch), v...)) + }) +} + +// MarchGT applies the GT predicate on the "march" field. +func MarchGT(v string) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldMarch), v)) + }) +} + +// MarchGTE applies the GTE predicate on the "march" field. +func MarchGTE(v string) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldMarch), v)) + }) +} + +// MarchLT applies the LT predicate on the "march" field. +func MarchLT(v string) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldMarch), v)) + }) +} + +// MarchLTE applies the LTE predicate on the "march" field. +func MarchLTE(v string) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldMarch), v)) + }) +} + +// MarchContains applies the Contains predicate on the "march" field. +func MarchContains(v string) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.Contains(s.C(FieldMarch), v)) + }) +} + +// MarchHasPrefix applies the HasPrefix predicate on the "march" field. +func MarchHasPrefix(v string) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.HasPrefix(s.C(FieldMarch), v)) + }) +} + +// MarchHasSuffix applies the HasSuffix predicate on the "march" field. +func MarchHasSuffix(v string) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.HasSuffix(s.C(FieldMarch), v)) + }) +} + +// MarchEqualFold applies the EqualFold predicate on the "march" field. +func MarchEqualFold(v string) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.EqualFold(s.C(FieldMarch), v)) + }) +} + +// MarchContainsFold applies the ContainsFold predicate on the "march" field. +func MarchContainsFold(v string) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.ContainsFold(s.C(FieldMarch), v)) + }) +} + +// VersionEQ applies the EQ predicate on the "version" field. +func VersionEQ(v string) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldVersion), v)) + }) +} + +// VersionNEQ applies the NEQ predicate on the "version" field. +func VersionNEQ(v string) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldVersion), v)) + }) +} + +// VersionIn applies the In predicate on the "version" field. +func VersionIn(vs ...string) predicate.DbPackage { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.DbPackage(func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(v) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.In(s.C(FieldVersion), v...)) + }) +} + +// VersionNotIn applies the NotIn predicate on the "version" field. +func VersionNotIn(vs ...string) predicate.DbPackage { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.DbPackage(func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(v) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.NotIn(s.C(FieldVersion), v...)) + }) +} + +// VersionGT applies the GT predicate on the "version" field. +func VersionGT(v string) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldVersion), v)) + }) +} + +// VersionGTE applies the GTE predicate on the "version" field. +func VersionGTE(v string) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldVersion), v)) + }) +} + +// VersionLT applies the LT predicate on the "version" field. +func VersionLT(v string) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldVersion), v)) + }) +} + +// VersionLTE applies the LTE predicate on the "version" field. +func VersionLTE(v string) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldVersion), v)) + }) +} + +// VersionContains applies the Contains predicate on the "version" field. +func VersionContains(v string) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.Contains(s.C(FieldVersion), v)) + }) +} + +// VersionHasPrefix applies the HasPrefix predicate on the "version" field. +func VersionHasPrefix(v string) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.HasPrefix(s.C(FieldVersion), v)) + }) +} + +// VersionHasSuffix applies the HasSuffix predicate on the "version" field. +func VersionHasSuffix(v string) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.HasSuffix(s.C(FieldVersion), v)) + }) +} + +// VersionIsNil applies the IsNil predicate on the "version" field. +func VersionIsNil() predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.IsNull(s.C(FieldVersion))) + }) +} + +// VersionNotNil applies the NotNil predicate on the "version" field. +func VersionNotNil() predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.NotNull(s.C(FieldVersion))) + }) +} + +// VersionEqualFold applies the EqualFold predicate on the "version" field. +func VersionEqualFold(v string) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.EqualFold(s.C(FieldVersion), v)) + }) +} + +// VersionContainsFold applies the ContainsFold predicate on the "version" field. +func VersionContainsFold(v string) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.ContainsFold(s.C(FieldVersion), v)) + }) +} + +// RepoVersionEQ applies the EQ predicate on the "repo_version" field. +func RepoVersionEQ(v string) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldRepoVersion), v)) + }) +} + +// RepoVersionNEQ applies the NEQ predicate on the "repo_version" field. +func RepoVersionNEQ(v string) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldRepoVersion), v)) + }) +} + +// RepoVersionIn applies the In predicate on the "repo_version" field. +func RepoVersionIn(vs ...string) predicate.DbPackage { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.DbPackage(func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(v) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.In(s.C(FieldRepoVersion), v...)) + }) +} + +// RepoVersionNotIn applies the NotIn predicate on the "repo_version" field. +func RepoVersionNotIn(vs ...string) predicate.DbPackage { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.DbPackage(func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(v) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.NotIn(s.C(FieldRepoVersion), v...)) + }) +} + +// RepoVersionGT applies the GT predicate on the "repo_version" field. +func RepoVersionGT(v string) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldRepoVersion), v)) + }) +} + +// RepoVersionGTE applies the GTE predicate on the "repo_version" field. +func RepoVersionGTE(v string) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldRepoVersion), v)) + }) +} + +// RepoVersionLT applies the LT predicate on the "repo_version" field. +func RepoVersionLT(v string) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldRepoVersion), v)) + }) +} + +// RepoVersionLTE applies the LTE predicate on the "repo_version" field. +func RepoVersionLTE(v string) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldRepoVersion), v)) + }) +} + +// RepoVersionContains applies the Contains predicate on the "repo_version" field. +func RepoVersionContains(v string) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.Contains(s.C(FieldRepoVersion), v)) + }) +} + +// RepoVersionHasPrefix applies the HasPrefix predicate on the "repo_version" field. +func RepoVersionHasPrefix(v string) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.HasPrefix(s.C(FieldRepoVersion), v)) + }) +} + +// RepoVersionHasSuffix applies the HasSuffix predicate on the "repo_version" field. +func RepoVersionHasSuffix(v string) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.HasSuffix(s.C(FieldRepoVersion), v)) + }) +} + +// RepoVersionIsNil applies the IsNil predicate on the "repo_version" field. +func RepoVersionIsNil() predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.IsNull(s.C(FieldRepoVersion))) + }) +} + +// RepoVersionNotNil applies the NotNil predicate on the "repo_version" field. +func RepoVersionNotNil() predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.NotNull(s.C(FieldRepoVersion))) + }) +} + +// RepoVersionEqualFold applies the EqualFold predicate on the "repo_version" field. +func RepoVersionEqualFold(v string) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.EqualFold(s.C(FieldRepoVersion), v)) + }) +} + +// RepoVersionContainsFold applies the ContainsFold predicate on the "repo_version" field. +func RepoVersionContainsFold(v string) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.ContainsFold(s.C(FieldRepoVersion), v)) + }) +} + +// BuildTimeEQ applies the EQ predicate on the "build_time" field. +func BuildTimeEQ(v time.Time) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldBuildTime), v)) + }) +} + +// BuildTimeNEQ applies the NEQ predicate on the "build_time" field. +func BuildTimeNEQ(v time.Time) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldBuildTime), v)) + }) +} + +// BuildTimeIn applies the In predicate on the "build_time" field. +func BuildTimeIn(vs ...time.Time) predicate.DbPackage { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.DbPackage(func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(v) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.In(s.C(FieldBuildTime), v...)) + }) +} + +// BuildTimeNotIn applies the NotIn predicate on the "build_time" field. +func BuildTimeNotIn(vs ...time.Time) predicate.DbPackage { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.DbPackage(func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(v) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.NotIn(s.C(FieldBuildTime), v...)) + }) +} + +// BuildTimeGT applies the GT predicate on the "build_time" field. +func BuildTimeGT(v time.Time) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldBuildTime), v)) + }) +} + +// BuildTimeGTE applies the GTE predicate on the "build_time" field. +func BuildTimeGTE(v time.Time) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldBuildTime), v)) + }) +} + +// BuildTimeLT applies the LT predicate on the "build_time" field. +func BuildTimeLT(v time.Time) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldBuildTime), v)) + }) +} + +// BuildTimeLTE applies the LTE predicate on the "build_time" field. +func BuildTimeLTE(v time.Time) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldBuildTime), v)) + }) +} + +// BuildTimeIsNil applies the IsNil predicate on the "build_time" field. +func BuildTimeIsNil() predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.IsNull(s.C(FieldBuildTime))) + }) +} + +// BuildTimeNotNil applies the NotNil predicate on the "build_time" field. +func BuildTimeNotNil() predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.NotNull(s.C(FieldBuildTime))) + }) +} + +// BuildDurationEQ applies the EQ predicate on the "build_duration" field. +func BuildDurationEQ(v uint64) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldBuildDuration), v)) + }) +} + +// BuildDurationNEQ applies the NEQ predicate on the "build_duration" field. +func BuildDurationNEQ(v uint64) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldBuildDuration), v)) + }) +} + +// BuildDurationIn applies the In predicate on the "build_duration" field. +func BuildDurationIn(vs ...uint64) predicate.DbPackage { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.DbPackage(func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(v) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.In(s.C(FieldBuildDuration), v...)) + }) +} + +// BuildDurationNotIn applies the NotIn predicate on the "build_duration" field. +func BuildDurationNotIn(vs ...uint64) predicate.DbPackage { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.DbPackage(func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(v) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.NotIn(s.C(FieldBuildDuration), v...)) + }) +} + +// BuildDurationGT applies the GT predicate on the "build_duration" field. +func BuildDurationGT(v uint64) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldBuildDuration), v)) + }) +} + +// BuildDurationGTE applies the GTE predicate on the "build_duration" field. +func BuildDurationGTE(v uint64) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldBuildDuration), v)) + }) +} + +// BuildDurationLT applies the LT predicate on the "build_duration" field. +func BuildDurationLT(v uint64) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldBuildDuration), v)) + }) +} + +// BuildDurationLTE applies the LTE predicate on the "build_duration" field. +func BuildDurationLTE(v uint64) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldBuildDuration), v)) + }) +} + +// BuildDurationIsNil applies the IsNil predicate on the "build_duration" field. +func BuildDurationIsNil() predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.IsNull(s.C(FieldBuildDuration))) + }) +} + +// BuildDurationNotNil applies the NotNil predicate on the "build_duration" field. +func BuildDurationNotNil() predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.NotNull(s.C(FieldBuildDuration))) + }) +} + +// UpdatedEQ applies the EQ predicate on the "updated" field. +func UpdatedEQ(v time.Time) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldUpdated), v)) + }) +} + +// UpdatedNEQ applies the NEQ predicate on the "updated" field. +func UpdatedNEQ(v time.Time) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldUpdated), v)) + }) +} + +// UpdatedIn applies the In predicate on the "updated" field. +func UpdatedIn(vs ...time.Time) predicate.DbPackage { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.DbPackage(func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(v) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.In(s.C(FieldUpdated), v...)) + }) +} + +// UpdatedNotIn applies the NotIn predicate on the "updated" field. +func UpdatedNotIn(vs ...time.Time) predicate.DbPackage { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.DbPackage(func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(v) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.NotIn(s.C(FieldUpdated), v...)) + }) +} + +// UpdatedGT applies the GT predicate on the "updated" field. +func UpdatedGT(v time.Time) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldUpdated), v)) + }) +} + +// UpdatedGTE applies the GTE predicate on the "updated" field. +func UpdatedGTE(v time.Time) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldUpdated), v)) + }) +} + +// UpdatedLT applies the LT predicate on the "updated" field. +func UpdatedLT(v time.Time) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldUpdated), v)) + }) +} + +// UpdatedLTE applies the LTE predicate on the "updated" field. +func UpdatedLTE(v time.Time) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldUpdated), v)) + }) +} + +// UpdatedIsNil applies the IsNil predicate on the "updated" field. +func UpdatedIsNil() predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.IsNull(s.C(FieldUpdated))) + }) +} + +// UpdatedNotNil applies the NotNil predicate on the "updated" field. +func UpdatedNotNil() predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.NotNull(s.C(FieldUpdated))) + }) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.DbPackage) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s1 := s.Clone().SetP(nil) + for _, p := range predicates { + p(s1) + } + s.Where(s1.P()) + }) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.DbPackage) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s1 := s.Clone().SetP(nil) + for i, p := range predicates { + if i > 0 { + s1.Or() + } + p(s1) + } + s.Where(s1.P()) + }) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.DbPackage) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + p(s.Not()) + }) +} diff --git a/ent/dbpackage_create.go b/ent/dbpackage_create.go new file mode 100644 index 0000000..19de16b --- /dev/null +++ b/ent/dbpackage_create.go @@ -0,0 +1,412 @@ +// Code generated by entc, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "time" + + "ALHP.go/ent/dbpackage" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// DbPackageCreate is the builder for creating a DbPackage entity. +type DbPackageCreate struct { + config + mutation *DbPackageMutation + hooks []Hook +} + +// SetPkgbase sets the "pkgbase" field. +func (dpc *DbPackageCreate) SetPkgbase(s string) *DbPackageCreate { + dpc.mutation.SetPkgbase(s) + return dpc +} + +// SetPackages sets the "packages" field. +func (dpc *DbPackageCreate) SetPackages(s []string) *DbPackageCreate { + dpc.mutation.SetPackages(s) + return dpc +} + +// SetStatus sets the "status" field. +func (dpc *DbPackageCreate) SetStatus(i int) *DbPackageCreate { + dpc.mutation.SetStatus(i) + return dpc +} + +// SetNillableStatus sets the "status" field if the given value is not nil. +func (dpc *DbPackageCreate) SetNillableStatus(i *int) *DbPackageCreate { + if i != nil { + dpc.SetStatus(*i) + } + return dpc +} + +// SetSkipReason sets the "skip_reason" field. +func (dpc *DbPackageCreate) SetSkipReason(s string) *DbPackageCreate { + dpc.mutation.SetSkipReason(s) + return dpc +} + +// SetNillableSkipReason sets the "skip_reason" field if the given value is not nil. +func (dpc *DbPackageCreate) SetNillableSkipReason(s *string) *DbPackageCreate { + if s != nil { + dpc.SetSkipReason(*s) + } + return dpc +} + +// SetRepository sets the "repository" field. +func (dpc *DbPackageCreate) SetRepository(s string) *DbPackageCreate { + dpc.mutation.SetRepository(s) + return dpc +} + +// SetMarch sets the "march" field. +func (dpc *DbPackageCreate) SetMarch(s string) *DbPackageCreate { + dpc.mutation.SetMarch(s) + return dpc +} + +// SetVersion sets the "version" field. +func (dpc *DbPackageCreate) SetVersion(s string) *DbPackageCreate { + dpc.mutation.SetVersion(s) + return dpc +} + +// SetNillableVersion sets the "version" field if the given value is not nil. +func (dpc *DbPackageCreate) SetNillableVersion(s *string) *DbPackageCreate { + if s != nil { + dpc.SetVersion(*s) + } + return dpc +} + +// SetRepoVersion sets the "repo_version" field. +func (dpc *DbPackageCreate) SetRepoVersion(s string) *DbPackageCreate { + dpc.mutation.SetRepoVersion(s) + return dpc +} + +// SetNillableRepoVersion sets the "repo_version" field if the given value is not nil. +func (dpc *DbPackageCreate) SetNillableRepoVersion(s *string) *DbPackageCreate { + if s != nil { + dpc.SetRepoVersion(*s) + } + return dpc +} + +// SetBuildTime sets the "build_time" field. +func (dpc *DbPackageCreate) SetBuildTime(t time.Time) *DbPackageCreate { + dpc.mutation.SetBuildTime(t) + return dpc +} + +// SetNillableBuildTime sets the "build_time" field if the given value is not nil. +func (dpc *DbPackageCreate) SetNillableBuildTime(t *time.Time) *DbPackageCreate { + if t != nil { + dpc.SetBuildTime(*t) + } + return dpc +} + +// SetBuildDuration sets the "build_duration" field. +func (dpc *DbPackageCreate) SetBuildDuration(u uint64) *DbPackageCreate { + dpc.mutation.SetBuildDuration(u) + return dpc +} + +// SetNillableBuildDuration sets the "build_duration" field if the given value is not nil. +func (dpc *DbPackageCreate) SetNillableBuildDuration(u *uint64) *DbPackageCreate { + if u != nil { + dpc.SetBuildDuration(*u) + } + return dpc +} + +// SetUpdated sets the "updated" field. +func (dpc *DbPackageCreate) SetUpdated(t time.Time) *DbPackageCreate { + dpc.mutation.SetUpdated(t) + return dpc +} + +// SetNillableUpdated sets the "updated" field if the given value is not nil. +func (dpc *DbPackageCreate) SetNillableUpdated(t *time.Time) *DbPackageCreate { + if t != nil { + dpc.SetUpdated(*t) + } + return dpc +} + +// Mutation returns the DbPackageMutation object of the builder. +func (dpc *DbPackageCreate) Mutation() *DbPackageMutation { + return dpc.mutation +} + +// Save creates the DbPackage in the database. +func (dpc *DbPackageCreate) Save(ctx context.Context) (*DbPackage, error) { + var ( + err error + node *DbPackage + ) + if len(dpc.hooks) == 0 { + if err = dpc.check(); err != nil { + return nil, err + } + node, err = dpc.sqlSave(ctx) + } else { + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*DbPackageMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + if err = dpc.check(); err != nil { + return nil, err + } + dpc.mutation = mutation + node, err = dpc.sqlSave(ctx) + mutation.done = true + return node, err + }) + for i := len(dpc.hooks) - 1; i >= 0; i-- { + mut = dpc.hooks[i](mut) + } + if _, err := mut.Mutate(ctx, dpc.mutation); err != nil { + return nil, err + } + } + return node, err +} + +// SaveX calls Save and panics if Save returns an error. +func (dpc *DbPackageCreate) SaveX(ctx context.Context) *DbPackage { + v, err := dpc.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// check runs all checks and user-defined validators on the builder. +func (dpc *DbPackageCreate) check() error { + if _, ok := dpc.mutation.Pkgbase(); !ok { + return &ValidationError{Name: "pkgbase", err: errors.New("ent: missing required field \"pkgbase\"")} + } + if v, ok := dpc.mutation.Pkgbase(); ok { + if err := dbpackage.PkgbaseValidator(v); err != nil { + return &ValidationError{Name: "pkgbase", err: fmt.Errorf("ent: validator failed for field \"pkgbase\": %w", err)} + } + } + if v, ok := dpc.mutation.Status(); ok { + if err := dbpackage.StatusValidator(v); err != nil { + return &ValidationError{Name: "status", err: fmt.Errorf("ent: validator failed for field \"status\": %w", err)} + } + } + if _, ok := dpc.mutation.Repository(); !ok { + return &ValidationError{Name: "repository", err: errors.New("ent: missing required field \"repository\"")} + } + if v, ok := dpc.mutation.Repository(); ok { + if err := dbpackage.RepositoryValidator(v); err != nil { + return &ValidationError{Name: "repository", err: fmt.Errorf("ent: validator failed for field \"repository\": %w", err)} + } + } + if _, ok := dpc.mutation.March(); !ok { + return &ValidationError{Name: "march", err: errors.New("ent: missing required field \"march\"")} + } + if v, ok := dpc.mutation.March(); ok { + if err := dbpackage.MarchValidator(v); err != nil { + return &ValidationError{Name: "march", err: fmt.Errorf("ent: validator failed for field \"march\": %w", err)} + } + } + if v, ok := dpc.mutation.BuildDuration(); ok { + if err := dbpackage.BuildDurationValidator(v); err != nil { + return &ValidationError{Name: "build_duration", err: fmt.Errorf("ent: validator failed for field \"build_duration\": %w", err)} + } + } + return nil +} + +func (dpc *DbPackageCreate) sqlSave(ctx context.Context) (*DbPackage, error) { + _node, _spec := dpc.createSpec() + if err := sqlgraph.CreateNode(ctx, dpc.driver, _spec); err != nil { + if cerr, ok := isSQLConstraintError(err); ok { + err = cerr + } + return nil, err + } + id := _spec.ID.Value.(int64) + _node.ID = int(id) + return _node, nil +} + +func (dpc *DbPackageCreate) createSpec() (*DbPackage, *sqlgraph.CreateSpec) { + var ( + _node = &DbPackage{config: dpc.config} + _spec = &sqlgraph.CreateSpec{ + Table: dbpackage.Table, + ID: &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: dbpackage.FieldID, + }, + } + ) + if value, ok := dpc.mutation.Pkgbase(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Value: value, + Column: dbpackage.FieldPkgbase, + }) + _node.Pkgbase = value + } + if value, ok := dpc.mutation.Packages(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeJSON, + Value: value, + Column: dbpackage.FieldPackages, + }) + _node.Packages = value + } + if value, ok := dpc.mutation.Status(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: dbpackage.FieldStatus, + }) + _node.Status = value + } + if value, ok := dpc.mutation.SkipReason(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Value: value, + Column: dbpackage.FieldSkipReason, + }) + _node.SkipReason = value + } + if value, ok := dpc.mutation.Repository(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Value: value, + Column: dbpackage.FieldRepository, + }) + _node.Repository = value + } + if value, ok := dpc.mutation.March(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Value: value, + Column: dbpackage.FieldMarch, + }) + _node.March = value + } + if value, ok := dpc.mutation.Version(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Value: value, + Column: dbpackage.FieldVersion, + }) + _node.Version = value + } + if value, ok := dpc.mutation.RepoVersion(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Value: value, + Column: dbpackage.FieldRepoVersion, + }) + _node.RepoVersion = value + } + if value, ok := dpc.mutation.BuildTime(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeTime, + Value: value, + Column: dbpackage.FieldBuildTime, + }) + _node.BuildTime = value + } + if value, ok := dpc.mutation.BuildDuration(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeUint64, + Value: value, + Column: dbpackage.FieldBuildDuration, + }) + _node.BuildDuration = value + } + if value, ok := dpc.mutation.Updated(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeTime, + Value: value, + Column: dbpackage.FieldUpdated, + }) + _node.Updated = value + } + return _node, _spec +} + +// DbPackageCreateBulk is the builder for creating many DbPackage entities in bulk. +type DbPackageCreateBulk struct { + config + builders []*DbPackageCreate +} + +// Save creates the DbPackage entities in the database. +func (dpcb *DbPackageCreateBulk) Save(ctx context.Context) ([]*DbPackage, error) { + specs := make([]*sqlgraph.CreateSpec, len(dpcb.builders)) + nodes := make([]*DbPackage, len(dpcb.builders)) + mutators := make([]Mutator, len(dpcb.builders)) + for i := range dpcb.builders { + func(i int, root context.Context) { + builder := dpcb.builders[i] + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*DbPackageMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + if err := builder.check(); err != nil { + return nil, err + } + builder.mutation = mutation + nodes[i], specs[i] = builder.createSpec() + var err error + if i < len(mutators)-1 { + _, err = mutators[i+1].Mutate(root, dpcb.builders[i+1].mutation) + } else { + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, dpcb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil { + if cerr, ok := isSQLConstraintError(err); ok { + err = cerr + } + } + } + mutation.done = true + if err != nil { + return nil, err + } + id := specs[i].ID.Value.(int64) + nodes[i].ID = int(id) + return nodes[i], nil + }) + for i := len(builder.hooks) - 1; i >= 0; i-- { + mut = builder.hooks[i](mut) + } + mutators[i] = mut + }(i, ctx) + } + if len(mutators) > 0 { + if _, err := mutators[0].Mutate(ctx, dpcb.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (dpcb *DbPackageCreateBulk) SaveX(ctx context.Context) []*DbPackage { + v, err := dpcb.Save(ctx) + if err != nil { + panic(err) + } + return v +} diff --git a/ent/dbpackage_delete.go b/ent/dbpackage_delete.go new file mode 100644 index 0000000..f550944 --- /dev/null +++ b/ent/dbpackage_delete.go @@ -0,0 +1,108 @@ +// Code generated by entc, DO NOT EDIT. + +package ent + +import ( + "context" + "fmt" + + "ALHP.go/ent/dbpackage" + "ALHP.go/ent/predicate" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// DbPackageDelete is the builder for deleting a DbPackage entity. +type DbPackageDelete struct { + config + hooks []Hook + mutation *DbPackageMutation +} + +// Where adds a new predicate to the DbPackageDelete builder. +func (dpd *DbPackageDelete) Where(ps ...predicate.DbPackage) *DbPackageDelete { + dpd.mutation.predicates = append(dpd.mutation.predicates, ps...) + return dpd +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (dpd *DbPackageDelete) Exec(ctx context.Context) (int, error) { + var ( + err error + affected int + ) + if len(dpd.hooks) == 0 { + affected, err = dpd.sqlExec(ctx) + } else { + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*DbPackageMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + dpd.mutation = mutation + affected, err = dpd.sqlExec(ctx) + mutation.done = true + return affected, err + }) + for i := len(dpd.hooks) - 1; i >= 0; i-- { + mut = dpd.hooks[i](mut) + } + if _, err := mut.Mutate(ctx, dpd.mutation); err != nil { + return 0, err + } + } + return affected, err +} + +// ExecX is like Exec, but panics if an error occurs. +func (dpd *DbPackageDelete) ExecX(ctx context.Context) int { + n, err := dpd.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (dpd *DbPackageDelete) sqlExec(ctx context.Context) (int, error) { + _spec := &sqlgraph.DeleteSpec{ + Node: &sqlgraph.NodeSpec{ + Table: dbpackage.Table, + ID: &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: dbpackage.FieldID, + }, + }, + } + if ps := dpd.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return sqlgraph.DeleteNodes(ctx, dpd.driver, _spec) +} + +// DbPackageDeleteOne is the builder for deleting a single DbPackage entity. +type DbPackageDeleteOne struct { + dpd *DbPackageDelete +} + +// Exec executes the deletion query. +func (dpdo *DbPackageDeleteOne) Exec(ctx context.Context) error { + n, err := dpdo.dpd.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{dbpackage.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (dpdo *DbPackageDeleteOne) ExecX(ctx context.Context) { + dpdo.dpd.ExecX(ctx) +} diff --git a/ent/dbpackage_query.go b/ent/dbpackage_query.go new file mode 100644 index 0000000..bff6cc8 --- /dev/null +++ b/ent/dbpackage_query.go @@ -0,0 +1,906 @@ +// Code generated by entc, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "math" + + "ALHP.go/ent/dbpackage" + "ALHP.go/ent/predicate" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// DbPackageQuery is the builder for querying DbPackage entities. +type DbPackageQuery struct { + config + limit *int + offset *int + unique *bool + order []OrderFunc + fields []string + predicates []predicate.DbPackage + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Where adds a new predicate for the DbPackageQuery builder. +func (dpq *DbPackageQuery) Where(ps ...predicate.DbPackage) *DbPackageQuery { + dpq.predicates = append(dpq.predicates, ps...) + return dpq +} + +// Limit adds a limit step to the query. +func (dpq *DbPackageQuery) Limit(limit int) *DbPackageQuery { + dpq.limit = &limit + return dpq +} + +// Offset adds an offset step to the query. +func (dpq *DbPackageQuery) Offset(offset int) *DbPackageQuery { + dpq.offset = &offset + return dpq +} + +// Unique configures the query builder to filter duplicate records on query. +// By default, unique is set to true, and can be disabled using this method. +func (dpq *DbPackageQuery) Unique(unique bool) *DbPackageQuery { + dpq.unique = &unique + return dpq +} + +// Order adds an order step to the query. +func (dpq *DbPackageQuery) Order(o ...OrderFunc) *DbPackageQuery { + dpq.order = append(dpq.order, o...) + return dpq +} + +// First returns the first DbPackage entity from the query. +// Returns a *NotFoundError when no DbPackage was found. +func (dpq *DbPackageQuery) First(ctx context.Context) (*DbPackage, error) { + nodes, err := dpq.Limit(1).All(ctx) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{dbpackage.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (dpq *DbPackageQuery) FirstX(ctx context.Context) *DbPackage { + node, err := dpq.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first DbPackage ID from the query. +// Returns a *NotFoundError when no DbPackage ID was found. +func (dpq *DbPackageQuery) FirstID(ctx context.Context) (id int, err error) { + var ids []int + if ids, err = dpq.Limit(1).IDs(ctx); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{dbpackage.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (dpq *DbPackageQuery) FirstIDX(ctx context.Context) int { + id, err := dpq.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single DbPackage entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when exactly one DbPackage entity is not found. +// Returns a *NotFoundError when no DbPackage entities are found. +func (dpq *DbPackageQuery) Only(ctx context.Context) (*DbPackage, error) { + nodes, err := dpq.Limit(2).All(ctx) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{dbpackage.Label} + default: + return nil, &NotSingularError{dbpackage.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (dpq *DbPackageQuery) OnlyX(ctx context.Context) *DbPackage { + node, err := dpq.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only DbPackage ID in the query. +// Returns a *NotSingularError when exactly one DbPackage ID is not found. +// Returns a *NotFoundError when no entities are found. +func (dpq *DbPackageQuery) OnlyID(ctx context.Context) (id int, err error) { + var ids []int + if ids, err = dpq.Limit(2).IDs(ctx); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{dbpackage.Label} + default: + err = &NotSingularError{dbpackage.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (dpq *DbPackageQuery) OnlyIDX(ctx context.Context) int { + id, err := dpq.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of DbPackages. +func (dpq *DbPackageQuery) All(ctx context.Context) ([]*DbPackage, error) { + if err := dpq.prepareQuery(ctx); err != nil { + return nil, err + } + return dpq.sqlAll(ctx) +} + +// AllX is like All, but panics if an error occurs. +func (dpq *DbPackageQuery) AllX(ctx context.Context) []*DbPackage { + nodes, err := dpq.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of DbPackage IDs. +func (dpq *DbPackageQuery) IDs(ctx context.Context) ([]int, error) { + var ids []int + if err := dpq.Select(dbpackage.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (dpq *DbPackageQuery) IDsX(ctx context.Context) []int { + ids, err := dpq.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (dpq *DbPackageQuery) Count(ctx context.Context) (int, error) { + if err := dpq.prepareQuery(ctx); err != nil { + return 0, err + } + return dpq.sqlCount(ctx) +} + +// CountX is like Count, but panics if an error occurs. +func (dpq *DbPackageQuery) CountX(ctx context.Context) int { + count, err := dpq.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (dpq *DbPackageQuery) Exist(ctx context.Context) (bool, error) { + if err := dpq.prepareQuery(ctx); err != nil { + return false, err + } + return dpq.sqlExist(ctx) +} + +// ExistX is like Exist, but panics if an error occurs. +func (dpq *DbPackageQuery) ExistX(ctx context.Context) bool { + exist, err := dpq.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the DbPackageQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (dpq *DbPackageQuery) Clone() *DbPackageQuery { + if dpq == nil { + return nil + } + return &DbPackageQuery{ + config: dpq.config, + limit: dpq.limit, + offset: dpq.offset, + order: append([]OrderFunc{}, dpq.order...), + predicates: append([]predicate.DbPackage{}, dpq.predicates...), + // clone intermediate query. + sql: dpq.sql.Clone(), + path: dpq.path, + } +} + +// GroupBy is used to group vertices by one or more fields/columns. +// It is often used with aggregate functions, like: count, max, mean, min, sum. +// +// Example: +// +// var v []struct { +// Pkgbase string `json:"pkgbase,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.DbPackage.Query(). +// GroupBy(dbpackage.FieldPkgbase). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +// +func (dpq *DbPackageQuery) GroupBy(field string, fields ...string) *DbPackageGroupBy { + group := &DbPackageGroupBy{config: dpq.config} + group.fields = append([]string{field}, fields...) + group.path = func(ctx context.Context) (prev *sql.Selector, err error) { + if err := dpq.prepareQuery(ctx); err != nil { + return nil, err + } + return dpq.sqlQuery(ctx), nil + } + return group +} + +// Select allows the selection one or more fields/columns for the given query, +// instead of selecting all fields in the entity. +// +// Example: +// +// var v []struct { +// Pkgbase string `json:"pkgbase,omitempty"` +// } +// +// client.DbPackage.Query(). +// Select(dbpackage.FieldPkgbase). +// Scan(ctx, &v) +// +func (dpq *DbPackageQuery) Select(field string, fields ...string) *DbPackageSelect { + dpq.fields = append([]string{field}, fields...) + return &DbPackageSelect{DbPackageQuery: dpq} +} + +func (dpq *DbPackageQuery) prepareQuery(ctx context.Context) error { + for _, f := range dpq.fields { + if !dbpackage.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + } + if dpq.path != nil { + prev, err := dpq.path(ctx) + if err != nil { + return err + } + dpq.sql = prev + } + return nil +} + +func (dpq *DbPackageQuery) sqlAll(ctx context.Context) ([]*DbPackage, error) { + var ( + nodes = []*DbPackage{} + _spec = dpq.querySpec() + ) + _spec.ScanValues = func(columns []string) ([]interface{}, error) { + node := &DbPackage{config: dpq.config} + nodes = append(nodes, node) + return node.scanValues(columns) + } + _spec.Assign = func(columns []string, values []interface{}) error { + if len(nodes) == 0 { + return fmt.Errorf("ent: Assign called without calling ScanValues") + } + node := nodes[len(nodes)-1] + return node.assignValues(columns, values) + } + if err := sqlgraph.QueryNodes(ctx, dpq.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + return nodes, nil +} + +func (dpq *DbPackageQuery) sqlCount(ctx context.Context) (int, error) { + _spec := dpq.querySpec() + return sqlgraph.CountNodes(ctx, dpq.driver, _spec) +} + +func (dpq *DbPackageQuery) sqlExist(ctx context.Context) (bool, error) { + n, err := dpq.sqlCount(ctx) + if err != nil { + return false, fmt.Errorf("ent: check existence: %w", err) + } + return n > 0, nil +} + +func (dpq *DbPackageQuery) querySpec() *sqlgraph.QuerySpec { + _spec := &sqlgraph.QuerySpec{ + Node: &sqlgraph.NodeSpec{ + Table: dbpackage.Table, + Columns: dbpackage.Columns, + ID: &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: dbpackage.FieldID, + }, + }, + From: dpq.sql, + Unique: true, + } + if unique := dpq.unique; unique != nil { + _spec.Unique = *unique + } + if fields := dpq.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, dbpackage.FieldID) + for i := range fields { + if fields[i] != dbpackage.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + } + if ps := dpq.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := dpq.limit; limit != nil { + _spec.Limit = *limit + } + if offset := dpq.offset; offset != nil { + _spec.Offset = *offset + } + if ps := dpq.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (dpq *DbPackageQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(dpq.driver.Dialect()) + t1 := builder.Table(dbpackage.Table) + selector := builder.Select(t1.Columns(dbpackage.Columns...)...).From(t1) + if dpq.sql != nil { + selector = dpq.sql + selector.Select(selector.Columns(dbpackage.Columns...)...) + } + for _, p := range dpq.predicates { + p(selector) + } + for _, p := range dpq.order { + p(selector) + } + if offset := dpq.offset; offset != nil { + // limit is mandatory for offset clause. We start + // with default value, and override it below if needed. + selector.Offset(*offset).Limit(math.MaxInt32) + } + if limit := dpq.limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// DbPackageGroupBy is the group-by builder for DbPackage entities. +type DbPackageGroupBy struct { + config + fields []string + fns []AggregateFunc + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (dpgb *DbPackageGroupBy) Aggregate(fns ...AggregateFunc) *DbPackageGroupBy { + dpgb.fns = append(dpgb.fns, fns...) + return dpgb +} + +// Scan applies the group-by query and scans the result into the given value. +func (dpgb *DbPackageGroupBy) Scan(ctx context.Context, v interface{}) error { + query, err := dpgb.path(ctx) + if err != nil { + return err + } + dpgb.sql = query + return dpgb.sqlScan(ctx, v) +} + +// ScanX is like Scan, but panics if an error occurs. +func (dpgb *DbPackageGroupBy) ScanX(ctx context.Context, v interface{}) { + if err := dpgb.Scan(ctx, v); err != nil { + panic(err) + } +} + +// Strings returns list of strings from group-by. +// It is only allowed when executing a group-by query with one field. +func (dpgb *DbPackageGroupBy) Strings(ctx context.Context) ([]string, error) { + if len(dpgb.fields) > 1 { + return nil, errors.New("ent: DbPackageGroupBy.Strings is not achievable when grouping more than 1 field") + } + var v []string + if err := dpgb.Scan(ctx, &v); err != nil { + return nil, err + } + return v, nil +} + +// StringsX is like Strings, but panics if an error occurs. +func (dpgb *DbPackageGroupBy) StringsX(ctx context.Context) []string { + v, err := dpgb.Strings(ctx) + if err != nil { + panic(err) + } + return v +} + +// String returns a single string from a group-by query. +// It is only allowed when executing a group-by query with one field. +func (dpgb *DbPackageGroupBy) String(ctx context.Context) (_ string, err error) { + var v []string + if v, err = dpgb.Strings(ctx); err != nil { + return + } + switch len(v) { + case 1: + return v[0], nil + case 0: + err = &NotFoundError{dbpackage.Label} + default: + err = fmt.Errorf("ent: DbPackageGroupBy.Strings returned %d results when one was expected", len(v)) + } + return +} + +// StringX is like String, but panics if an error occurs. +func (dpgb *DbPackageGroupBy) StringX(ctx context.Context) string { + v, err := dpgb.String(ctx) + if err != nil { + panic(err) + } + return v +} + +// Ints returns list of ints from group-by. +// It is only allowed when executing a group-by query with one field. +func (dpgb *DbPackageGroupBy) Ints(ctx context.Context) ([]int, error) { + if len(dpgb.fields) > 1 { + return nil, errors.New("ent: DbPackageGroupBy.Ints is not achievable when grouping more than 1 field") + } + var v []int + if err := dpgb.Scan(ctx, &v); err != nil { + return nil, err + } + return v, nil +} + +// IntsX is like Ints, but panics if an error occurs. +func (dpgb *DbPackageGroupBy) IntsX(ctx context.Context) []int { + v, err := dpgb.Ints(ctx) + if err != nil { + panic(err) + } + return v +} + +// Int returns a single int from a group-by query. +// It is only allowed when executing a group-by query with one field. +func (dpgb *DbPackageGroupBy) Int(ctx context.Context) (_ int, err error) { + var v []int + if v, err = dpgb.Ints(ctx); err != nil { + return + } + switch len(v) { + case 1: + return v[0], nil + case 0: + err = &NotFoundError{dbpackage.Label} + default: + err = fmt.Errorf("ent: DbPackageGroupBy.Ints returned %d results when one was expected", len(v)) + } + return +} + +// IntX is like Int, but panics if an error occurs. +func (dpgb *DbPackageGroupBy) IntX(ctx context.Context) int { + v, err := dpgb.Int(ctx) + if err != nil { + panic(err) + } + return v +} + +// Float64s returns list of float64s from group-by. +// It is only allowed when executing a group-by query with one field. +func (dpgb *DbPackageGroupBy) Float64s(ctx context.Context) ([]float64, error) { + if len(dpgb.fields) > 1 { + return nil, errors.New("ent: DbPackageGroupBy.Float64s is not achievable when grouping more than 1 field") + } + var v []float64 + if err := dpgb.Scan(ctx, &v); err != nil { + return nil, err + } + return v, nil +} + +// Float64sX is like Float64s, but panics if an error occurs. +func (dpgb *DbPackageGroupBy) Float64sX(ctx context.Context) []float64 { + v, err := dpgb.Float64s(ctx) + if err != nil { + panic(err) + } + return v +} + +// Float64 returns a single float64 from a group-by query. +// It is only allowed when executing a group-by query with one field. +func (dpgb *DbPackageGroupBy) Float64(ctx context.Context) (_ float64, err error) { + var v []float64 + if v, err = dpgb.Float64s(ctx); err != nil { + return + } + switch len(v) { + case 1: + return v[0], nil + case 0: + err = &NotFoundError{dbpackage.Label} + default: + err = fmt.Errorf("ent: DbPackageGroupBy.Float64s returned %d results when one was expected", len(v)) + } + return +} + +// Float64X is like Float64, but panics if an error occurs. +func (dpgb *DbPackageGroupBy) Float64X(ctx context.Context) float64 { + v, err := dpgb.Float64(ctx) + if err != nil { + panic(err) + } + return v +} + +// Bools returns list of bools from group-by. +// It is only allowed when executing a group-by query with one field. +func (dpgb *DbPackageGroupBy) Bools(ctx context.Context) ([]bool, error) { + if len(dpgb.fields) > 1 { + return nil, errors.New("ent: DbPackageGroupBy.Bools is not achievable when grouping more than 1 field") + } + var v []bool + if err := dpgb.Scan(ctx, &v); err != nil { + return nil, err + } + return v, nil +} + +// BoolsX is like Bools, but panics if an error occurs. +func (dpgb *DbPackageGroupBy) BoolsX(ctx context.Context) []bool { + v, err := dpgb.Bools(ctx) + if err != nil { + panic(err) + } + return v +} + +// Bool returns a single bool from a group-by query. +// It is only allowed when executing a group-by query with one field. +func (dpgb *DbPackageGroupBy) Bool(ctx context.Context) (_ bool, err error) { + var v []bool + if v, err = dpgb.Bools(ctx); err != nil { + return + } + switch len(v) { + case 1: + return v[0], nil + case 0: + err = &NotFoundError{dbpackage.Label} + default: + err = fmt.Errorf("ent: DbPackageGroupBy.Bools returned %d results when one was expected", len(v)) + } + return +} + +// BoolX is like Bool, but panics if an error occurs. +func (dpgb *DbPackageGroupBy) BoolX(ctx context.Context) bool { + v, err := dpgb.Bool(ctx) + if err != nil { + panic(err) + } + return v +} + +func (dpgb *DbPackageGroupBy) sqlScan(ctx context.Context, v interface{}) error { + for _, f := range dpgb.fields { + if !dbpackage.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("invalid field %q for group-by", f)} + } + } + selector := dpgb.sqlQuery() + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := dpgb.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +func (dpgb *DbPackageGroupBy) sqlQuery() *sql.Selector { + selector := dpgb.sql + columns := make([]string, 0, len(dpgb.fields)+len(dpgb.fns)) + columns = append(columns, dpgb.fields...) + for _, fn := range dpgb.fns { + columns = append(columns, fn(selector)) + } + return selector.Select(columns...).GroupBy(dpgb.fields...) +} + +// DbPackageSelect is the builder for selecting fields of DbPackage entities. +type DbPackageSelect struct { + *DbPackageQuery + // intermediate query (i.e. traversal path). + sql *sql.Selector +} + +// Scan applies the selector query and scans the result into the given value. +func (dps *DbPackageSelect) Scan(ctx context.Context, v interface{}) error { + if err := dps.prepareQuery(ctx); err != nil { + return err + } + dps.sql = dps.DbPackageQuery.sqlQuery(ctx) + return dps.sqlScan(ctx, v) +} + +// ScanX is like Scan, but panics if an error occurs. +func (dps *DbPackageSelect) ScanX(ctx context.Context, v interface{}) { + if err := dps.Scan(ctx, v); err != nil { + panic(err) + } +} + +// Strings returns list of strings from a selector. It is only allowed when selecting one field. +func (dps *DbPackageSelect) Strings(ctx context.Context) ([]string, error) { + if len(dps.fields) > 1 { + return nil, errors.New("ent: DbPackageSelect.Strings is not achievable when selecting more than 1 field") + } + var v []string + if err := dps.Scan(ctx, &v); err != nil { + return nil, err + } + return v, nil +} + +// StringsX is like Strings, but panics if an error occurs. +func (dps *DbPackageSelect) StringsX(ctx context.Context) []string { + v, err := dps.Strings(ctx) + if err != nil { + panic(err) + } + return v +} + +// String returns a single string from a selector. It is only allowed when selecting one field. +func (dps *DbPackageSelect) String(ctx context.Context) (_ string, err error) { + var v []string + if v, err = dps.Strings(ctx); err != nil { + return + } + switch len(v) { + case 1: + return v[0], nil + case 0: + err = &NotFoundError{dbpackage.Label} + default: + err = fmt.Errorf("ent: DbPackageSelect.Strings returned %d results when one was expected", len(v)) + } + return +} + +// StringX is like String, but panics if an error occurs. +func (dps *DbPackageSelect) StringX(ctx context.Context) string { + v, err := dps.String(ctx) + if err != nil { + panic(err) + } + return v +} + +// Ints returns list of ints from a selector. It is only allowed when selecting one field. +func (dps *DbPackageSelect) Ints(ctx context.Context) ([]int, error) { + if len(dps.fields) > 1 { + return nil, errors.New("ent: DbPackageSelect.Ints is not achievable when selecting more than 1 field") + } + var v []int + if err := dps.Scan(ctx, &v); err != nil { + return nil, err + } + return v, nil +} + +// IntsX is like Ints, but panics if an error occurs. +func (dps *DbPackageSelect) IntsX(ctx context.Context) []int { + v, err := dps.Ints(ctx) + if err != nil { + panic(err) + } + return v +} + +// Int returns a single int from a selector. It is only allowed when selecting one field. +func (dps *DbPackageSelect) Int(ctx context.Context) (_ int, err error) { + var v []int + if v, err = dps.Ints(ctx); err != nil { + return + } + switch len(v) { + case 1: + return v[0], nil + case 0: + err = &NotFoundError{dbpackage.Label} + default: + err = fmt.Errorf("ent: DbPackageSelect.Ints returned %d results when one was expected", len(v)) + } + return +} + +// IntX is like Int, but panics if an error occurs. +func (dps *DbPackageSelect) IntX(ctx context.Context) int { + v, err := dps.Int(ctx) + if err != nil { + panic(err) + } + return v +} + +// Float64s returns list of float64s from a selector. It is only allowed when selecting one field. +func (dps *DbPackageSelect) Float64s(ctx context.Context) ([]float64, error) { + if len(dps.fields) > 1 { + return nil, errors.New("ent: DbPackageSelect.Float64s is not achievable when selecting more than 1 field") + } + var v []float64 + if err := dps.Scan(ctx, &v); err != nil { + return nil, err + } + return v, nil +} + +// Float64sX is like Float64s, but panics if an error occurs. +func (dps *DbPackageSelect) Float64sX(ctx context.Context) []float64 { + v, err := dps.Float64s(ctx) + if err != nil { + panic(err) + } + return v +} + +// Float64 returns a single float64 from a selector. It is only allowed when selecting one field. +func (dps *DbPackageSelect) Float64(ctx context.Context) (_ float64, err error) { + var v []float64 + if v, err = dps.Float64s(ctx); err != nil { + return + } + switch len(v) { + case 1: + return v[0], nil + case 0: + err = &NotFoundError{dbpackage.Label} + default: + err = fmt.Errorf("ent: DbPackageSelect.Float64s returned %d results when one was expected", len(v)) + } + return +} + +// Float64X is like Float64, but panics if an error occurs. +func (dps *DbPackageSelect) Float64X(ctx context.Context) float64 { + v, err := dps.Float64(ctx) + if err != nil { + panic(err) + } + return v +} + +// Bools returns list of bools from a selector. It is only allowed when selecting one field. +func (dps *DbPackageSelect) Bools(ctx context.Context) ([]bool, error) { + if len(dps.fields) > 1 { + return nil, errors.New("ent: DbPackageSelect.Bools is not achievable when selecting more than 1 field") + } + var v []bool + if err := dps.Scan(ctx, &v); err != nil { + return nil, err + } + return v, nil +} + +// BoolsX is like Bools, but panics if an error occurs. +func (dps *DbPackageSelect) BoolsX(ctx context.Context) []bool { + v, err := dps.Bools(ctx) + if err != nil { + panic(err) + } + return v +} + +// Bool returns a single bool from a selector. It is only allowed when selecting one field. +func (dps *DbPackageSelect) Bool(ctx context.Context) (_ bool, err error) { + var v []bool + if v, err = dps.Bools(ctx); err != nil { + return + } + switch len(v) { + case 1: + return v[0], nil + case 0: + err = &NotFoundError{dbpackage.Label} + default: + err = fmt.Errorf("ent: DbPackageSelect.Bools returned %d results when one was expected", len(v)) + } + return +} + +// BoolX is like Bool, but panics if an error occurs. +func (dps *DbPackageSelect) BoolX(ctx context.Context) bool { + v, err := dps.Bool(ctx) + if err != nil { + panic(err) + } + return v +} + +func (dps *DbPackageSelect) sqlScan(ctx context.Context, v interface{}) error { + rows := &sql.Rows{} + query, args := dps.sqlQuery().Query() + if err := dps.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +func (dps *DbPackageSelect) sqlQuery() sql.Querier { + selector := dps.sql + selector.Select(selector.Columns(dps.fields...)...) + return selector +} diff --git a/ent/dbpackage_update.go b/ent/dbpackage_update.go new file mode 100644 index 0000000..3a80164 --- /dev/null +++ b/ent/dbpackage_update.go @@ -0,0 +1,915 @@ +// Code generated by entc, DO NOT EDIT. + +package ent + +import ( + "context" + "fmt" + "time" + + "ALHP.go/ent/dbpackage" + "ALHP.go/ent/predicate" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// DbPackageUpdate is the builder for updating DbPackage entities. +type DbPackageUpdate struct { + config + hooks []Hook + mutation *DbPackageMutation +} + +// Where adds a new predicate for the DbPackageUpdate builder. +func (dpu *DbPackageUpdate) Where(ps ...predicate.DbPackage) *DbPackageUpdate { + dpu.mutation.predicates = append(dpu.mutation.predicates, ps...) + return dpu +} + +// SetPackages sets the "packages" field. +func (dpu *DbPackageUpdate) SetPackages(s []string) *DbPackageUpdate { + dpu.mutation.SetPackages(s) + return dpu +} + +// ClearPackages clears the value of the "packages" field. +func (dpu *DbPackageUpdate) ClearPackages() *DbPackageUpdate { + dpu.mutation.ClearPackages() + return dpu +} + +// SetStatus sets the "status" field. +func (dpu *DbPackageUpdate) SetStatus(i int) *DbPackageUpdate { + dpu.mutation.ResetStatus() + dpu.mutation.SetStatus(i) + return dpu +} + +// SetNillableStatus sets the "status" field if the given value is not nil. +func (dpu *DbPackageUpdate) SetNillableStatus(i *int) *DbPackageUpdate { + if i != nil { + dpu.SetStatus(*i) + } + return dpu +} + +// AddStatus adds i to the "status" field. +func (dpu *DbPackageUpdate) AddStatus(i int) *DbPackageUpdate { + dpu.mutation.AddStatus(i) + return dpu +} + +// ClearStatus clears the value of the "status" field. +func (dpu *DbPackageUpdate) ClearStatus() *DbPackageUpdate { + dpu.mutation.ClearStatus() + return dpu +} + +// SetSkipReason sets the "skip_reason" field. +func (dpu *DbPackageUpdate) SetSkipReason(s string) *DbPackageUpdate { + dpu.mutation.SetSkipReason(s) + return dpu +} + +// SetNillableSkipReason sets the "skip_reason" field if the given value is not nil. +func (dpu *DbPackageUpdate) SetNillableSkipReason(s *string) *DbPackageUpdate { + if s != nil { + dpu.SetSkipReason(*s) + } + return dpu +} + +// ClearSkipReason clears the value of the "skip_reason" field. +func (dpu *DbPackageUpdate) ClearSkipReason() *DbPackageUpdate { + dpu.mutation.ClearSkipReason() + return dpu +} + +// SetRepository sets the "repository" field. +func (dpu *DbPackageUpdate) SetRepository(s string) *DbPackageUpdate { + dpu.mutation.SetRepository(s) + return dpu +} + +// SetMarch sets the "march" field. +func (dpu *DbPackageUpdate) SetMarch(s string) *DbPackageUpdate { + dpu.mutation.SetMarch(s) + return dpu +} + +// SetVersion sets the "version" field. +func (dpu *DbPackageUpdate) SetVersion(s string) *DbPackageUpdate { + dpu.mutation.SetVersion(s) + return dpu +} + +// SetNillableVersion sets the "version" field if the given value is not nil. +func (dpu *DbPackageUpdate) SetNillableVersion(s *string) *DbPackageUpdate { + if s != nil { + dpu.SetVersion(*s) + } + return dpu +} + +// ClearVersion clears the value of the "version" field. +func (dpu *DbPackageUpdate) ClearVersion() *DbPackageUpdate { + dpu.mutation.ClearVersion() + return dpu +} + +// SetRepoVersion sets the "repo_version" field. +func (dpu *DbPackageUpdate) SetRepoVersion(s string) *DbPackageUpdate { + dpu.mutation.SetRepoVersion(s) + return dpu +} + +// SetNillableRepoVersion sets the "repo_version" field if the given value is not nil. +func (dpu *DbPackageUpdate) SetNillableRepoVersion(s *string) *DbPackageUpdate { + if s != nil { + dpu.SetRepoVersion(*s) + } + return dpu +} + +// ClearRepoVersion clears the value of the "repo_version" field. +func (dpu *DbPackageUpdate) ClearRepoVersion() *DbPackageUpdate { + dpu.mutation.ClearRepoVersion() + return dpu +} + +// SetBuildTime sets the "build_time" field. +func (dpu *DbPackageUpdate) SetBuildTime(t time.Time) *DbPackageUpdate { + dpu.mutation.SetBuildTime(t) + return dpu +} + +// SetNillableBuildTime sets the "build_time" field if the given value is not nil. +func (dpu *DbPackageUpdate) SetNillableBuildTime(t *time.Time) *DbPackageUpdate { + if t != nil { + dpu.SetBuildTime(*t) + } + return dpu +} + +// ClearBuildTime clears the value of the "build_time" field. +func (dpu *DbPackageUpdate) ClearBuildTime() *DbPackageUpdate { + dpu.mutation.ClearBuildTime() + return dpu +} + +// SetBuildDuration sets the "build_duration" field. +func (dpu *DbPackageUpdate) SetBuildDuration(u uint64) *DbPackageUpdate { + dpu.mutation.ResetBuildDuration() + dpu.mutation.SetBuildDuration(u) + return dpu +} + +// SetNillableBuildDuration sets the "build_duration" field if the given value is not nil. +func (dpu *DbPackageUpdate) SetNillableBuildDuration(u *uint64) *DbPackageUpdate { + if u != nil { + dpu.SetBuildDuration(*u) + } + return dpu +} + +// AddBuildDuration adds u to the "build_duration" field. +func (dpu *DbPackageUpdate) AddBuildDuration(u uint64) *DbPackageUpdate { + dpu.mutation.AddBuildDuration(u) + return dpu +} + +// ClearBuildDuration clears the value of the "build_duration" field. +func (dpu *DbPackageUpdate) ClearBuildDuration() *DbPackageUpdate { + dpu.mutation.ClearBuildDuration() + return dpu +} + +// SetUpdated sets the "updated" field. +func (dpu *DbPackageUpdate) SetUpdated(t time.Time) *DbPackageUpdate { + dpu.mutation.SetUpdated(t) + return dpu +} + +// SetNillableUpdated sets the "updated" field if the given value is not nil. +func (dpu *DbPackageUpdate) SetNillableUpdated(t *time.Time) *DbPackageUpdate { + if t != nil { + dpu.SetUpdated(*t) + } + return dpu +} + +// ClearUpdated clears the value of the "updated" field. +func (dpu *DbPackageUpdate) ClearUpdated() *DbPackageUpdate { + dpu.mutation.ClearUpdated() + return dpu +} + +// Mutation returns the DbPackageMutation object of the builder. +func (dpu *DbPackageUpdate) Mutation() *DbPackageMutation { + return dpu.mutation +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (dpu *DbPackageUpdate) Save(ctx context.Context) (int, error) { + var ( + err error + affected int + ) + if len(dpu.hooks) == 0 { + if err = dpu.check(); err != nil { + return 0, err + } + affected, err = dpu.sqlSave(ctx) + } else { + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*DbPackageMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + if err = dpu.check(); err != nil { + return 0, err + } + dpu.mutation = mutation + affected, err = dpu.sqlSave(ctx) + mutation.done = true + return affected, err + }) + for i := len(dpu.hooks) - 1; i >= 0; i-- { + mut = dpu.hooks[i](mut) + } + if _, err := mut.Mutate(ctx, dpu.mutation); err != nil { + return 0, err + } + } + return affected, err +} + +// SaveX is like Save, but panics if an error occurs. +func (dpu *DbPackageUpdate) SaveX(ctx context.Context) int { + affected, err := dpu.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (dpu *DbPackageUpdate) Exec(ctx context.Context) error { + _, err := dpu.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (dpu *DbPackageUpdate) ExecX(ctx context.Context) { + if err := dpu.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (dpu *DbPackageUpdate) check() error { + if v, ok := dpu.mutation.Status(); ok { + if err := dbpackage.StatusValidator(v); err != nil { + return &ValidationError{Name: "status", err: fmt.Errorf("ent: validator failed for field \"status\": %w", err)} + } + } + if v, ok := dpu.mutation.Repository(); ok { + if err := dbpackage.RepositoryValidator(v); err != nil { + return &ValidationError{Name: "repository", err: fmt.Errorf("ent: validator failed for field \"repository\": %w", err)} + } + } + if v, ok := dpu.mutation.March(); ok { + if err := dbpackage.MarchValidator(v); err != nil { + return &ValidationError{Name: "march", err: fmt.Errorf("ent: validator failed for field \"march\": %w", err)} + } + } + if v, ok := dpu.mutation.BuildDuration(); ok { + if err := dbpackage.BuildDurationValidator(v); err != nil { + return &ValidationError{Name: "build_duration", err: fmt.Errorf("ent: validator failed for field \"build_duration\": %w", err)} + } + } + return nil +} + +func (dpu *DbPackageUpdate) sqlSave(ctx context.Context) (n int, err error) { + _spec := &sqlgraph.UpdateSpec{ + Node: &sqlgraph.NodeSpec{ + Table: dbpackage.Table, + Columns: dbpackage.Columns, + ID: &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: dbpackage.FieldID, + }, + }, + } + if ps := dpu.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := dpu.mutation.Packages(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeJSON, + Value: value, + Column: dbpackage.FieldPackages, + }) + } + if dpu.mutation.PackagesCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeJSON, + Column: dbpackage.FieldPackages, + }) + } + if value, ok := dpu.mutation.Status(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: dbpackage.FieldStatus, + }) + } + if value, ok := dpu.mutation.AddedStatus(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: dbpackage.FieldStatus, + }) + } + if dpu.mutation.StatusCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: dbpackage.FieldStatus, + }) + } + if value, ok := dpu.mutation.SkipReason(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Value: value, + Column: dbpackage.FieldSkipReason, + }) + } + if dpu.mutation.SkipReasonCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Column: dbpackage.FieldSkipReason, + }) + } + if value, ok := dpu.mutation.Repository(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Value: value, + Column: dbpackage.FieldRepository, + }) + } + if value, ok := dpu.mutation.March(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Value: value, + Column: dbpackage.FieldMarch, + }) + } + if value, ok := dpu.mutation.Version(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Value: value, + Column: dbpackage.FieldVersion, + }) + } + if dpu.mutation.VersionCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Column: dbpackage.FieldVersion, + }) + } + if value, ok := dpu.mutation.RepoVersion(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Value: value, + Column: dbpackage.FieldRepoVersion, + }) + } + if dpu.mutation.RepoVersionCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Column: dbpackage.FieldRepoVersion, + }) + } + if value, ok := dpu.mutation.BuildTime(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeTime, + Value: value, + Column: dbpackage.FieldBuildTime, + }) + } + if dpu.mutation.BuildTimeCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeTime, + Column: dbpackage.FieldBuildTime, + }) + } + if value, ok := dpu.mutation.BuildDuration(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeUint64, + Value: value, + Column: dbpackage.FieldBuildDuration, + }) + } + if value, ok := dpu.mutation.AddedBuildDuration(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeUint64, + Value: value, + Column: dbpackage.FieldBuildDuration, + }) + } + if dpu.mutation.BuildDurationCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeUint64, + Column: dbpackage.FieldBuildDuration, + }) + } + if value, ok := dpu.mutation.Updated(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeTime, + Value: value, + Column: dbpackage.FieldUpdated, + }) + } + if dpu.mutation.UpdatedCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeTime, + Column: dbpackage.FieldUpdated, + }) + } + if n, err = sqlgraph.UpdateNodes(ctx, dpu.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{dbpackage.Label} + } else if cerr, ok := isSQLConstraintError(err); ok { + err = cerr + } + return 0, err + } + return n, nil +} + +// DbPackageUpdateOne is the builder for updating a single DbPackage entity. +type DbPackageUpdateOne struct { + config + fields []string + hooks []Hook + mutation *DbPackageMutation +} + +// SetPackages sets the "packages" field. +func (dpuo *DbPackageUpdateOne) SetPackages(s []string) *DbPackageUpdateOne { + dpuo.mutation.SetPackages(s) + return dpuo +} + +// ClearPackages clears the value of the "packages" field. +func (dpuo *DbPackageUpdateOne) ClearPackages() *DbPackageUpdateOne { + dpuo.mutation.ClearPackages() + return dpuo +} + +// SetStatus sets the "status" field. +func (dpuo *DbPackageUpdateOne) SetStatus(i int) *DbPackageUpdateOne { + dpuo.mutation.ResetStatus() + dpuo.mutation.SetStatus(i) + return dpuo +} + +// SetNillableStatus sets the "status" field if the given value is not nil. +func (dpuo *DbPackageUpdateOne) SetNillableStatus(i *int) *DbPackageUpdateOne { + if i != nil { + dpuo.SetStatus(*i) + } + return dpuo +} + +// AddStatus adds i to the "status" field. +func (dpuo *DbPackageUpdateOne) AddStatus(i int) *DbPackageUpdateOne { + dpuo.mutation.AddStatus(i) + return dpuo +} + +// ClearStatus clears the value of the "status" field. +func (dpuo *DbPackageUpdateOne) ClearStatus() *DbPackageUpdateOne { + dpuo.mutation.ClearStatus() + return dpuo +} + +// SetSkipReason sets the "skip_reason" field. +func (dpuo *DbPackageUpdateOne) SetSkipReason(s string) *DbPackageUpdateOne { + dpuo.mutation.SetSkipReason(s) + return dpuo +} + +// SetNillableSkipReason sets the "skip_reason" field if the given value is not nil. +func (dpuo *DbPackageUpdateOne) SetNillableSkipReason(s *string) *DbPackageUpdateOne { + if s != nil { + dpuo.SetSkipReason(*s) + } + return dpuo +} + +// ClearSkipReason clears the value of the "skip_reason" field. +func (dpuo *DbPackageUpdateOne) ClearSkipReason() *DbPackageUpdateOne { + dpuo.mutation.ClearSkipReason() + return dpuo +} + +// SetRepository sets the "repository" field. +func (dpuo *DbPackageUpdateOne) SetRepository(s string) *DbPackageUpdateOne { + dpuo.mutation.SetRepository(s) + return dpuo +} + +// SetMarch sets the "march" field. +func (dpuo *DbPackageUpdateOne) SetMarch(s string) *DbPackageUpdateOne { + dpuo.mutation.SetMarch(s) + return dpuo +} + +// SetVersion sets the "version" field. +func (dpuo *DbPackageUpdateOne) SetVersion(s string) *DbPackageUpdateOne { + dpuo.mutation.SetVersion(s) + return dpuo +} + +// SetNillableVersion sets the "version" field if the given value is not nil. +func (dpuo *DbPackageUpdateOne) SetNillableVersion(s *string) *DbPackageUpdateOne { + if s != nil { + dpuo.SetVersion(*s) + } + return dpuo +} + +// ClearVersion clears the value of the "version" field. +func (dpuo *DbPackageUpdateOne) ClearVersion() *DbPackageUpdateOne { + dpuo.mutation.ClearVersion() + return dpuo +} + +// SetRepoVersion sets the "repo_version" field. +func (dpuo *DbPackageUpdateOne) SetRepoVersion(s string) *DbPackageUpdateOne { + dpuo.mutation.SetRepoVersion(s) + return dpuo +} + +// SetNillableRepoVersion sets the "repo_version" field if the given value is not nil. +func (dpuo *DbPackageUpdateOne) SetNillableRepoVersion(s *string) *DbPackageUpdateOne { + if s != nil { + dpuo.SetRepoVersion(*s) + } + return dpuo +} + +// ClearRepoVersion clears the value of the "repo_version" field. +func (dpuo *DbPackageUpdateOne) ClearRepoVersion() *DbPackageUpdateOne { + dpuo.mutation.ClearRepoVersion() + return dpuo +} + +// SetBuildTime sets the "build_time" field. +func (dpuo *DbPackageUpdateOne) SetBuildTime(t time.Time) *DbPackageUpdateOne { + dpuo.mutation.SetBuildTime(t) + return dpuo +} + +// SetNillableBuildTime sets the "build_time" field if the given value is not nil. +func (dpuo *DbPackageUpdateOne) SetNillableBuildTime(t *time.Time) *DbPackageUpdateOne { + if t != nil { + dpuo.SetBuildTime(*t) + } + return dpuo +} + +// ClearBuildTime clears the value of the "build_time" field. +func (dpuo *DbPackageUpdateOne) ClearBuildTime() *DbPackageUpdateOne { + dpuo.mutation.ClearBuildTime() + return dpuo +} + +// SetBuildDuration sets the "build_duration" field. +func (dpuo *DbPackageUpdateOne) SetBuildDuration(u uint64) *DbPackageUpdateOne { + dpuo.mutation.ResetBuildDuration() + dpuo.mutation.SetBuildDuration(u) + return dpuo +} + +// SetNillableBuildDuration sets the "build_duration" field if the given value is not nil. +func (dpuo *DbPackageUpdateOne) SetNillableBuildDuration(u *uint64) *DbPackageUpdateOne { + if u != nil { + dpuo.SetBuildDuration(*u) + } + return dpuo +} + +// AddBuildDuration adds u to the "build_duration" field. +func (dpuo *DbPackageUpdateOne) AddBuildDuration(u uint64) *DbPackageUpdateOne { + dpuo.mutation.AddBuildDuration(u) + return dpuo +} + +// ClearBuildDuration clears the value of the "build_duration" field. +func (dpuo *DbPackageUpdateOne) ClearBuildDuration() *DbPackageUpdateOne { + dpuo.mutation.ClearBuildDuration() + return dpuo +} + +// SetUpdated sets the "updated" field. +func (dpuo *DbPackageUpdateOne) SetUpdated(t time.Time) *DbPackageUpdateOne { + dpuo.mutation.SetUpdated(t) + return dpuo +} + +// SetNillableUpdated sets the "updated" field if the given value is not nil. +func (dpuo *DbPackageUpdateOne) SetNillableUpdated(t *time.Time) *DbPackageUpdateOne { + if t != nil { + dpuo.SetUpdated(*t) + } + return dpuo +} + +// ClearUpdated clears the value of the "updated" field. +func (dpuo *DbPackageUpdateOne) ClearUpdated() *DbPackageUpdateOne { + dpuo.mutation.ClearUpdated() + return dpuo +} + +// Mutation returns the DbPackageMutation object of the builder. +func (dpuo *DbPackageUpdateOne) Mutation() *DbPackageMutation { + return dpuo.mutation +} + +// Select allows selecting one or more fields (columns) of the returned entity. +// The default is selecting all fields defined in the entity schema. +func (dpuo *DbPackageUpdateOne) Select(field string, fields ...string) *DbPackageUpdateOne { + dpuo.fields = append([]string{field}, fields...) + return dpuo +} + +// Save executes the query and returns the updated DbPackage entity. +func (dpuo *DbPackageUpdateOne) Save(ctx context.Context) (*DbPackage, error) { + var ( + err error + node *DbPackage + ) + if len(dpuo.hooks) == 0 { + if err = dpuo.check(); err != nil { + return nil, err + } + node, err = dpuo.sqlSave(ctx) + } else { + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*DbPackageMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + if err = dpuo.check(); err != nil { + return nil, err + } + dpuo.mutation = mutation + node, err = dpuo.sqlSave(ctx) + mutation.done = true + return node, err + }) + for i := len(dpuo.hooks) - 1; i >= 0; i-- { + mut = dpuo.hooks[i](mut) + } + if _, err := mut.Mutate(ctx, dpuo.mutation); err != nil { + return nil, err + } + } + return node, err +} + +// SaveX is like Save, but panics if an error occurs. +func (dpuo *DbPackageUpdateOne) SaveX(ctx context.Context) *DbPackage { + node, err := dpuo.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (dpuo *DbPackageUpdateOne) Exec(ctx context.Context) error { + _, err := dpuo.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (dpuo *DbPackageUpdateOne) ExecX(ctx context.Context) { + if err := dpuo.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (dpuo *DbPackageUpdateOne) check() error { + if v, ok := dpuo.mutation.Status(); ok { + if err := dbpackage.StatusValidator(v); err != nil { + return &ValidationError{Name: "status", err: fmt.Errorf("ent: validator failed for field \"status\": %w", err)} + } + } + if v, ok := dpuo.mutation.Repository(); ok { + if err := dbpackage.RepositoryValidator(v); err != nil { + return &ValidationError{Name: "repository", err: fmt.Errorf("ent: validator failed for field \"repository\": %w", err)} + } + } + if v, ok := dpuo.mutation.March(); ok { + if err := dbpackage.MarchValidator(v); err != nil { + return &ValidationError{Name: "march", err: fmt.Errorf("ent: validator failed for field \"march\": %w", err)} + } + } + if v, ok := dpuo.mutation.BuildDuration(); ok { + if err := dbpackage.BuildDurationValidator(v); err != nil { + return &ValidationError{Name: "build_duration", err: fmt.Errorf("ent: validator failed for field \"build_duration\": %w", err)} + } + } + return nil +} + +func (dpuo *DbPackageUpdateOne) sqlSave(ctx context.Context) (_node *DbPackage, err error) { + _spec := &sqlgraph.UpdateSpec{ + Node: &sqlgraph.NodeSpec{ + Table: dbpackage.Table, + Columns: dbpackage.Columns, + ID: &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: dbpackage.FieldID, + }, + }, + } + id, ok := dpuo.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "ID", err: fmt.Errorf("missing DbPackage.ID for update")} + } + _spec.Node.ID.Value = id + if fields := dpuo.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, dbpackage.FieldID) + for _, f := range fields { + if !dbpackage.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != dbpackage.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, f) + } + } + } + if ps := dpuo.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := dpuo.mutation.Packages(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeJSON, + Value: value, + Column: dbpackage.FieldPackages, + }) + } + if dpuo.mutation.PackagesCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeJSON, + Column: dbpackage.FieldPackages, + }) + } + if value, ok := dpuo.mutation.Status(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: dbpackage.FieldStatus, + }) + } + if value, ok := dpuo.mutation.AddedStatus(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: dbpackage.FieldStatus, + }) + } + if dpuo.mutation.StatusCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: dbpackage.FieldStatus, + }) + } + if value, ok := dpuo.mutation.SkipReason(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Value: value, + Column: dbpackage.FieldSkipReason, + }) + } + if dpuo.mutation.SkipReasonCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Column: dbpackage.FieldSkipReason, + }) + } + if value, ok := dpuo.mutation.Repository(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Value: value, + Column: dbpackage.FieldRepository, + }) + } + if value, ok := dpuo.mutation.March(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Value: value, + Column: dbpackage.FieldMarch, + }) + } + if value, ok := dpuo.mutation.Version(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Value: value, + Column: dbpackage.FieldVersion, + }) + } + if dpuo.mutation.VersionCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Column: dbpackage.FieldVersion, + }) + } + if value, ok := dpuo.mutation.RepoVersion(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Value: value, + Column: dbpackage.FieldRepoVersion, + }) + } + if dpuo.mutation.RepoVersionCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Column: dbpackage.FieldRepoVersion, + }) + } + if value, ok := dpuo.mutation.BuildTime(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeTime, + Value: value, + Column: dbpackage.FieldBuildTime, + }) + } + if dpuo.mutation.BuildTimeCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeTime, + Column: dbpackage.FieldBuildTime, + }) + } + if value, ok := dpuo.mutation.BuildDuration(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeUint64, + Value: value, + Column: dbpackage.FieldBuildDuration, + }) + } + if value, ok := dpuo.mutation.AddedBuildDuration(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeUint64, + Value: value, + Column: dbpackage.FieldBuildDuration, + }) + } + if dpuo.mutation.BuildDurationCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeUint64, + Column: dbpackage.FieldBuildDuration, + }) + } + if value, ok := dpuo.mutation.Updated(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeTime, + Value: value, + Column: dbpackage.FieldUpdated, + }) + } + if dpuo.mutation.UpdatedCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeTime, + Column: dbpackage.FieldUpdated, + }) + } + _node = &DbPackage{config: dpuo.config} + _spec.Assign = _node.assignValues + _spec.ScanValues = _node.scanValues + if err = sqlgraph.UpdateNode(ctx, dpuo.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{dbpackage.Label} + } else if cerr, ok := isSQLConstraintError(err); ok { + err = cerr + } + return nil, err + } + return _node, nil +} diff --git a/ent/ent.go b/ent/ent.go new file mode 100644 index 0000000..c201ea1 --- /dev/null +++ b/ent/ent.go @@ -0,0 +1,279 @@ +// Code generated by entc, DO NOT EDIT. + +package ent + +import ( + "errors" + "fmt" + + "ALHP.go/ent/dbpackage" + "entgo.io/ent" + "entgo.io/ent/dialect" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +// ent aliases to avoid import conflicts in user's code. +type ( + Op = ent.Op + Hook = ent.Hook + Value = ent.Value + Query = ent.Query + Policy = ent.Policy + Mutator = ent.Mutator + Mutation = ent.Mutation + MutateFunc = ent.MutateFunc +) + +// OrderFunc applies an ordering on the sql selector. +type OrderFunc func(*sql.Selector) + +// columnChecker returns a function indicates if the column exists in the given column. +func columnChecker(table string) func(string) error { + checks := map[string]func(string) bool{ + dbpackage.Table: dbpackage.ValidColumn, + } + check, ok := checks[table] + if !ok { + return func(string) error { + return fmt.Errorf("unknown table %q", table) + } + } + return func(column string) error { + if !check(column) { + return fmt.Errorf("unknown column %q for table %q", column, table) + } + return nil + } +} + +// Asc applies the given fields in ASC order. +func Asc(fields ...string) OrderFunc { + return func(s *sql.Selector) { + check := columnChecker(s.TableName()) + for _, f := range fields { + if err := check(f); err != nil { + s.AddError(&ValidationError{Name: f, err: fmt.Errorf("ent: %w", err)}) + } + s.OrderBy(sql.Asc(s.C(f))) + } + } +} + +// Desc applies the given fields in DESC order. +func Desc(fields ...string) OrderFunc { + return func(s *sql.Selector) { + check := columnChecker(s.TableName()) + for _, f := range fields { + if err := check(f); err != nil { + s.AddError(&ValidationError{Name: f, err: fmt.Errorf("ent: %w", err)}) + } + s.OrderBy(sql.Desc(s.C(f))) + } + } +} + +// AggregateFunc applies an aggregation step on the group-by traversal/selector. +type AggregateFunc func(*sql.Selector) string + +// As is a pseudo aggregation function for renaming another other functions with custom names. For example: +// +// GroupBy(field1, field2). +// Aggregate(ent.As(ent.Sum(field1), "sum_field1"), (ent.As(ent.Sum(field2), "sum_field2")). +// Scan(ctx, &v) +// +func As(fn AggregateFunc, end string) AggregateFunc { + return func(s *sql.Selector) string { + return sql.As(fn(s), end) + } +} + +// Count applies the "count" aggregation function on each group. +func Count() AggregateFunc { + return func(s *sql.Selector) string { + return sql.Count("*") + } +} + +// Max applies the "max" aggregation function on the given field of each group. +func Max(field string) AggregateFunc { + return func(s *sql.Selector) string { + check := columnChecker(s.TableName()) + if err := check(field); err != nil { + s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)}) + return "" + } + return sql.Max(s.C(field)) + } +} + +// Mean applies the "mean" aggregation function on the given field of each group. +func Mean(field string) AggregateFunc { + return func(s *sql.Selector) string { + check := columnChecker(s.TableName()) + if err := check(field); err != nil { + s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)}) + return "" + } + return sql.Avg(s.C(field)) + } +} + +// Min applies the "min" aggregation function on the given field of each group. +func Min(field string) AggregateFunc { + return func(s *sql.Selector) string { + check := columnChecker(s.TableName()) + if err := check(field); err != nil { + s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)}) + return "" + } + return sql.Min(s.C(field)) + } +} + +// Sum applies the "sum" aggregation function on the given field of each group. +func Sum(field string) AggregateFunc { + return func(s *sql.Selector) string { + check := columnChecker(s.TableName()) + if err := check(field); err != nil { + s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)}) + return "" + } + return sql.Sum(s.C(field)) + } +} + +// ValidationError returns when validating a field fails. +type ValidationError struct { + Name string // Field or edge name. + err error +} + +// Error implements the error interface. +func (e *ValidationError) Error() string { + return e.err.Error() +} + +// Unwrap implements the errors.Wrapper interface. +func (e *ValidationError) Unwrap() error { + return e.err +} + +// IsValidationError returns a boolean indicating whether the error is a validaton error. +func IsValidationError(err error) bool { + if err == nil { + return false + } + var e *ValidationError + return errors.As(err, &e) +} + +// NotFoundError returns when trying to fetch a specific entity and it was not found in the database. +type NotFoundError struct { + label string +} + +// Error implements the error interface. +func (e *NotFoundError) Error() string { + return "ent: " + e.label + " not found" +} + +// IsNotFound returns a boolean indicating whether the error is a not found error. +func IsNotFound(err error) bool { + if err == nil { + return false + } + var e *NotFoundError + return errors.As(err, &e) +} + +// MaskNotFound masks not found error. +func MaskNotFound(err error) error { + if IsNotFound(err) { + return nil + } + return err +} + +// NotSingularError returns when trying to fetch a singular entity and more then one was found in the database. +type NotSingularError struct { + label string +} + +// Error implements the error interface. +func (e *NotSingularError) Error() string { + return "ent: " + e.label + " not singular" +} + +// IsNotSingular returns a boolean indicating whether the error is a not singular error. +func IsNotSingular(err error) bool { + if err == nil { + return false + } + var e *NotSingularError + return errors.As(err, &e) +} + +// NotLoadedError returns when trying to get a node that was not loaded by the query. +type NotLoadedError struct { + edge string +} + +// Error implements the error interface. +func (e *NotLoadedError) Error() string { + return "ent: " + e.edge + " edge was not loaded" +} + +// IsNotLoaded returns a boolean indicating whether the error is a not loaded error. +func IsNotLoaded(err error) bool { + if err == nil { + return false + } + var e *NotLoadedError + return errors.As(err, &e) +} + +// ConstraintError returns when trying to create/update one or more entities and +// one or more of their constraints failed. For example, violation of edge or +// field uniqueness. +type ConstraintError struct { + msg string + wrap error +} + +// Error implements the error interface. +func (e ConstraintError) Error() string { + return "ent: constraint failed: " + e.msg +} + +// Unwrap implements the errors.Wrapper interface. +func (e *ConstraintError) Unwrap() error { + return e.wrap +} + +// IsConstraintError returns a boolean indicating whether the error is a constraint failure. +func IsConstraintError(err error) bool { + if err == nil { + return false + } + var e *ConstraintError + return errors.As(err, &e) +} + +func isSQLConstraintError(err error) (*ConstraintError, bool) { + if sqlgraph.IsConstraintError(err) { + return &ConstraintError{err.Error(), err}, true + } + return nil, false +} + +// rollback calls tx.Rollback and wraps the given error with the rollback error if present. +func rollback(tx dialect.Tx, err error) error { + if rerr := tx.Rollback(); rerr != nil { + err = fmt.Errorf("%w: %v", err, rerr) + } + if err, ok := isSQLConstraintError(err); ok { + return err + } + return err +} diff --git a/ent/enttest/enttest.go b/ent/enttest/enttest.go new file mode 100644 index 0000000..1706e64 --- /dev/null +++ b/ent/enttest/enttest.go @@ -0,0 +1,78 @@ +// Code generated by entc, DO NOT EDIT. + +package enttest + +import ( + "context" + + "ALHP.go/ent" + // required by schema hooks. + _ "ALHP.go/ent/runtime" + + "entgo.io/ent/dialect/sql/schema" +) + +type ( + // TestingT is the interface that is shared between + // testing.T and testing.B and used by enttest. + TestingT interface { + FailNow() + Error(...interface{}) + } + + // Option configures client creation. + Option func(*options) + + options struct { + opts []ent.Option + migrateOpts []schema.MigrateOption + } +) + +// WithOptions forwards options to client creation. +func WithOptions(opts ...ent.Option) Option { + return func(o *options) { + o.opts = append(o.opts, opts...) + } +} + +// WithMigrateOptions forwards options to auto migration. +func WithMigrateOptions(opts ...schema.MigrateOption) Option { + return func(o *options) { + o.migrateOpts = append(o.migrateOpts, opts...) + } +} + +func newOptions(opts []Option) *options { + o := &options{} + for _, opt := range opts { + opt(o) + } + return o +} + +// Open calls ent.Open and auto-run migration. +func Open(t TestingT, driverName, dataSourceName string, opts ...Option) *ent.Client { + o := newOptions(opts) + c, err := ent.Open(driverName, dataSourceName, o.opts...) + if err != nil { + t.Error(err) + t.FailNow() + } + if err := c.Schema.Create(context.Background(), o.migrateOpts...); err != nil { + t.Error(err) + t.FailNow() + } + return c +} + +// NewClient calls ent.NewClient and auto-run migration. +func NewClient(t TestingT, opts ...Option) *ent.Client { + o := newOptions(opts) + c := ent.NewClient(o.opts...) + if err := c.Schema.Create(context.Background(), o.migrateOpts...); err != nil { + t.Error(err) + t.FailNow() + } + return c +} diff --git a/ent/generate.go b/ent/generate.go new file mode 100644 index 0000000..8d3fdfd --- /dev/null +++ b/ent/generate.go @@ -0,0 +1,3 @@ +package ent + +//go:generate go run -mod=mod entgo.io/ent/cmd/ent generate ./schema diff --git a/ent/hook/hook.go b/ent/hook/hook.go new file mode 100644 index 0000000..73190d9 --- /dev/null +++ b/ent/hook/hook.go @@ -0,0 +1,204 @@ +// Code generated by entc, DO NOT EDIT. + +package hook + +import ( + "context" + "fmt" + + "ALHP.go/ent" +) + +// The DbPackageFunc type is an adapter to allow the use of ordinary +// function as DbPackage mutator. +type DbPackageFunc func(context.Context, *ent.DbPackageMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f DbPackageFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + mv, ok := m.(*ent.DbPackageMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.DbPackageMutation", m) + } + return f(ctx, mv) +} + +// Condition is a hook condition function. +type Condition func(context.Context, ent.Mutation) bool + +// And groups conditions with the AND operator. +func And(first, second Condition, rest ...Condition) Condition { + return func(ctx context.Context, m ent.Mutation) bool { + if !first(ctx, m) || !second(ctx, m) { + return false + } + for _, cond := range rest { + if !cond(ctx, m) { + return false + } + } + return true + } +} + +// Or groups conditions with the OR operator. +func Or(first, second Condition, rest ...Condition) Condition { + return func(ctx context.Context, m ent.Mutation) bool { + if first(ctx, m) || second(ctx, m) { + return true + } + for _, cond := range rest { + if cond(ctx, m) { + return true + } + } + return false + } +} + +// Not negates a given condition. +func Not(cond Condition) Condition { + return func(ctx context.Context, m ent.Mutation) bool { + return !cond(ctx, m) + } +} + +// HasOp is a condition testing mutation operation. +func HasOp(op ent.Op) Condition { + return func(_ context.Context, m ent.Mutation) bool { + return m.Op().Is(op) + } +} + +// HasAddedFields is a condition validating `.AddedField` on fields. +func HasAddedFields(field string, fields ...string) Condition { + return func(_ context.Context, m ent.Mutation) bool { + if _, exists := m.AddedField(field); !exists { + return false + } + for _, field := range fields { + if _, exists := m.AddedField(field); !exists { + return false + } + } + return true + } +} + +// HasClearedFields is a condition validating `.FieldCleared` on fields. +func HasClearedFields(field string, fields ...string) Condition { + return func(_ context.Context, m ent.Mutation) bool { + if exists := m.FieldCleared(field); !exists { + return false + } + for _, field := range fields { + if exists := m.FieldCleared(field); !exists { + return false + } + } + return true + } +} + +// HasFields is a condition validating `.Field` on fields. +func HasFields(field string, fields ...string) Condition { + return func(_ context.Context, m ent.Mutation) bool { + if _, exists := m.Field(field); !exists { + return false + } + for _, field := range fields { + if _, exists := m.Field(field); !exists { + return false + } + } + return true + } +} + +// If executes the given hook under condition. +// +// hook.If(ComputeAverage, And(HasFields(...), HasAddedFields(...))) +// +func If(hk ent.Hook, cond Condition) ent.Hook { + return func(next ent.Mutator) ent.Mutator { + return ent.MutateFunc(func(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if cond(ctx, m) { + return hk(next).Mutate(ctx, m) + } + return next.Mutate(ctx, m) + }) + } +} + +// On executes the given hook only for the given operation. +// +// hook.On(Log, ent.Delete|ent.Create) +// +func On(hk ent.Hook, op ent.Op) ent.Hook { + return If(hk, HasOp(op)) +} + +// Unless skips the given hook only for the given operation. +// +// hook.Unless(Log, ent.Update|ent.UpdateOne) +// +func Unless(hk ent.Hook, op ent.Op) ent.Hook { + return If(hk, Not(HasOp(op))) +} + +// FixedError is a hook returning a fixed error. +func FixedError(err error) ent.Hook { + return func(ent.Mutator) ent.Mutator { + return ent.MutateFunc(func(context.Context, ent.Mutation) (ent.Value, error) { + return nil, err + }) + } +} + +// Reject returns a hook that rejects all operations that match op. +// +// func (T) Hooks() []ent.Hook { +// return []ent.Hook{ +// Reject(ent.Delete|ent.Update), +// } +// } +// +func Reject(op ent.Op) ent.Hook { + hk := FixedError(fmt.Errorf("%s operation is not allowed", op)) + return On(hk, op) +} + +// Chain acts as a list of hooks and is effectively immutable. +// Once created, it will always hold the same set of hooks in the same order. +type Chain struct { + hooks []ent.Hook +} + +// NewChain creates a new chain of hooks. +func NewChain(hooks ...ent.Hook) Chain { + return Chain{append([]ent.Hook(nil), hooks...)} +} + +// Hook chains the list of hooks and returns the final hook. +func (c Chain) Hook() ent.Hook { + return func(mutator ent.Mutator) ent.Mutator { + for i := len(c.hooks) - 1; i >= 0; i-- { + mutator = c.hooks[i](mutator) + } + return mutator + } +} + +// Append extends a chain, adding the specified hook +// as the last ones in the mutation flow. +func (c Chain) Append(hooks ...ent.Hook) Chain { + newHooks := make([]ent.Hook, 0, len(c.hooks)+len(hooks)) + newHooks = append(newHooks, c.hooks...) + newHooks = append(newHooks, hooks...) + return Chain{newHooks} +} + +// Extend extends a chain, adding the specified chain +// as the last ones in the mutation flow. +func (c Chain) Extend(chain Chain) Chain { + return c.Append(chain.hooks...) +} diff --git a/ent/migrate/migrate.go b/ent/migrate/migrate.go new file mode 100644 index 0000000..e4a9a22 --- /dev/null +++ b/ent/migrate/migrate.go @@ -0,0 +1,72 @@ +// Code generated by entc, DO NOT EDIT. + +package migrate + +import ( + "context" + "fmt" + "io" + + "entgo.io/ent/dialect" + "entgo.io/ent/dialect/sql/schema" +) + +var ( + // WithGlobalUniqueID sets the universal ids options to the migration. + // If this option is enabled, ent migration will allocate a 1<<32 range + // for the ids of each entity (table). + // Note that this option cannot be applied on tables that already exist. + WithGlobalUniqueID = schema.WithGlobalUniqueID + // WithDropColumn sets the drop column option to the migration. + // If this option is enabled, ent migration will drop old columns + // that were used for both fields and edges. This defaults to false. + WithDropColumn = schema.WithDropColumn + // WithDropIndex sets the drop index option to the migration. + // If this option is enabled, ent migration will drop old indexes + // that were defined in the schema. This defaults to false. + // Note that unique constraints are defined using `UNIQUE INDEX`, + // and therefore, it's recommended to enable this option to get more + // flexibility in the schema changes. + WithDropIndex = schema.WithDropIndex + // WithFixture sets the foreign-key renaming option to the migration when upgrading + // ent from v0.1.0 (issue-#285). Defaults to false. + WithFixture = schema.WithFixture + // WithForeignKeys enables creating foreign-key in schema DDL. This defaults to true. + WithForeignKeys = schema.WithForeignKeys +) + +// Schema is the API for creating, migrating and dropping a schema. +type Schema struct { + drv dialect.Driver + universalID bool +} + +// NewSchema creates a new schema client. +func NewSchema(drv dialect.Driver) *Schema { return &Schema{drv: drv} } + +// Create creates all schema resources. +func (s *Schema) Create(ctx context.Context, opts ...schema.MigrateOption) error { + migrate, err := schema.NewMigrate(s.drv, opts...) + if err != nil { + return fmt.Errorf("ent/migrate: %w", err) + } + return migrate.Create(ctx, Tables...) +} + +// WriteTo writes the schema changes to w instead of running them against the database. +// +// if err := client.Schema.WriteTo(context.Background(), os.Stdout); err != nil { +// log.Fatal(err) +// } +// +func (s *Schema) WriteTo(ctx context.Context, w io.Writer, opts ...schema.MigrateOption) error { + drv := &schema.WriteDriver{ + Writer: w, + Driver: s.drv, + } + migrate, err := schema.NewMigrate(drv, opts...) + if err != nil { + return fmt.Errorf("ent/migrate: %w", err) + } + return migrate.Create(ctx, Tables...) +} diff --git a/ent/migrate/schema.go b/ent/migrate/schema.go new file mode 100644 index 0000000..0b092d4 --- /dev/null +++ b/ent/migrate/schema.go @@ -0,0 +1,40 @@ +// Code generated by entc, DO NOT EDIT. + +package migrate + +import ( + "entgo.io/ent/dialect/sql/schema" + "entgo.io/ent/schema/field" +) + +var ( + // DbPackagesColumns holds the columns for the "db_packages" table. + DbPackagesColumns = []*schema.Column{ + {Name: "id", Type: field.TypeInt, Increment: true}, + {Name: "pkgbase", Type: field.TypeString, Unique: true}, + {Name: "packages", Type: field.TypeJSON, Nullable: true}, + {Name: "status", Type: field.TypeInt, Nullable: true}, + {Name: "skip_reason", Type: field.TypeString, Nullable: true}, + {Name: "repository", Type: field.TypeString}, + {Name: "march", Type: field.TypeString}, + {Name: "version", Type: field.TypeString, Nullable: true}, + {Name: "repo_version", Type: field.TypeString, Nullable: true}, + {Name: "build_time", Type: field.TypeTime, Nullable: true}, + {Name: "build_duration", Type: field.TypeUint64, Nullable: true}, + {Name: "updated", Type: field.TypeTime, Nullable: true}, + } + // DbPackagesTable holds the schema information for the "db_packages" table. + DbPackagesTable = &schema.Table{ + Name: "db_packages", + Columns: DbPackagesColumns, + PrimaryKey: []*schema.Column{DbPackagesColumns[0]}, + ForeignKeys: []*schema.ForeignKey{}, + } + // Tables holds all the tables in the schema. + Tables = []*schema.Table{ + DbPackagesTable, + } +) + +func init() { +} diff --git a/ent/mutation.go b/ent/mutation.go new file mode 100644 index 0000000..9e12f4a --- /dev/null +++ b/ent/mutation.go @@ -0,0 +1,1080 @@ +// Code generated by entc, DO NOT EDIT. + +package ent + +import ( + "context" + "fmt" + "sync" + "time" + + "ALHP.go/ent/dbpackage" + "ALHP.go/ent/predicate" + + "entgo.io/ent" +) + +const ( + // Operation types. + OpCreate = ent.OpCreate + OpDelete = ent.OpDelete + OpDeleteOne = ent.OpDeleteOne + OpUpdate = ent.OpUpdate + OpUpdateOne = ent.OpUpdateOne + + // Node types. + TypeDbPackage = "DbPackage" +) + +// DbPackageMutation represents an operation that mutates the DbPackage nodes in the graph. +type DbPackageMutation struct { + config + op Op + typ string + id *int + pkgbase *string + packages *[]string + status *int + addstatus *int + skip_reason *string + repository *string + march *string + version *string + repo_version *string + build_time *time.Time + build_duration *uint64 + addbuild_duration *uint64 + updated *time.Time + clearedFields map[string]struct{} + done bool + oldValue func(context.Context) (*DbPackage, error) + predicates []predicate.DbPackage +} + +var _ ent.Mutation = (*DbPackageMutation)(nil) + +// dbpackageOption allows management of the mutation configuration using functional options. +type dbpackageOption func(*DbPackageMutation) + +// newDbPackageMutation creates new mutation for the DbPackage entity. +func newDbPackageMutation(c config, op Op, opts ...dbpackageOption) *DbPackageMutation { + m := &DbPackageMutation{ + config: c, + op: op, + typ: TypeDbPackage, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withDbPackageID sets the ID field of the mutation. +func withDbPackageID(id int) dbpackageOption { + return func(m *DbPackageMutation) { + var ( + err error + once sync.Once + value *DbPackage + ) + m.oldValue = func(ctx context.Context) (*DbPackage, error) { + once.Do(func() { + if m.done { + err = fmt.Errorf("querying old values post mutation is not allowed") + } else { + value, err = m.Client().DbPackage.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withDbPackage sets the old DbPackage of the mutation. +func withDbPackage(node *DbPackage) dbpackageOption { + return func(m *DbPackageMutation) { + m.oldValue = func(context.Context) (*DbPackage, error) { + return node, nil + } + m.id = &node.ID + } +} + +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m DbPackageMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client +} + +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m DbPackageMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, fmt.Errorf("ent: mutation is not running in a transaction") + } + tx := &Tx{config: m.config} + tx.init() + return tx, nil +} + +// ID returns the ID value in the mutation. Note that the ID +// is only available if it was provided to the builder. +func (m *DbPackageMutation) ID() (id int, exists bool) { + if m.id == nil { + return + } + return *m.id, true +} + +// SetPkgbase sets the "pkgbase" field. +func (m *DbPackageMutation) SetPkgbase(s string) { + m.pkgbase = &s +} + +// Pkgbase returns the value of the "pkgbase" field in the mutation. +func (m *DbPackageMutation) Pkgbase() (r string, exists bool) { + v := m.pkgbase + if v == nil { + return + } + return *v, true +} + +// OldPkgbase returns the old "pkgbase" field's value of the DbPackage entity. +// If the DbPackage object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *DbPackageMutation) OldPkgbase(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, fmt.Errorf("OldPkgbase is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, fmt.Errorf("OldPkgbase requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldPkgbase: %w", err) + } + return oldValue.Pkgbase, nil +} + +// ResetPkgbase resets all changes to the "pkgbase" field. +func (m *DbPackageMutation) ResetPkgbase() { + m.pkgbase = nil +} + +// SetPackages sets the "packages" field. +func (m *DbPackageMutation) SetPackages(s []string) { + m.packages = &s +} + +// Packages returns the value of the "packages" field in the mutation. +func (m *DbPackageMutation) Packages() (r []string, exists bool) { + v := m.packages + if v == nil { + return + } + return *v, true +} + +// OldPackages returns the old "packages" field's value of the DbPackage entity. +// If the DbPackage object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *DbPackageMutation) OldPackages(ctx context.Context) (v []string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, fmt.Errorf("OldPackages is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, fmt.Errorf("OldPackages requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldPackages: %w", err) + } + return oldValue.Packages, nil +} + +// ClearPackages clears the value of the "packages" field. +func (m *DbPackageMutation) ClearPackages() { + m.packages = nil + m.clearedFields[dbpackage.FieldPackages] = struct{}{} +} + +// PackagesCleared returns if the "packages" field was cleared in this mutation. +func (m *DbPackageMutation) PackagesCleared() bool { + _, ok := m.clearedFields[dbpackage.FieldPackages] + return ok +} + +// ResetPackages resets all changes to the "packages" field. +func (m *DbPackageMutation) ResetPackages() { + m.packages = nil + delete(m.clearedFields, dbpackage.FieldPackages) +} + +// SetStatus sets the "status" field. +func (m *DbPackageMutation) SetStatus(i int) { + m.status = &i + m.addstatus = nil +} + +// Status returns the value of the "status" field in the mutation. +func (m *DbPackageMutation) Status() (r int, exists bool) { + v := m.status + if v == nil { + return + } + return *v, true +} + +// OldStatus returns the old "status" field's value of the DbPackage entity. +// If the DbPackage object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *DbPackageMutation) OldStatus(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, fmt.Errorf("OldStatus is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, fmt.Errorf("OldStatus requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldStatus: %w", err) + } + return oldValue.Status, nil +} + +// AddStatus adds i to the "status" field. +func (m *DbPackageMutation) AddStatus(i int) { + if m.addstatus != nil { + *m.addstatus += i + } else { + m.addstatus = &i + } +} + +// AddedStatus returns the value that was added to the "status" field in this mutation. +func (m *DbPackageMutation) AddedStatus() (r int, exists bool) { + v := m.addstatus + if v == nil { + return + } + return *v, true +} + +// ClearStatus clears the value of the "status" field. +func (m *DbPackageMutation) ClearStatus() { + m.status = nil + m.addstatus = nil + m.clearedFields[dbpackage.FieldStatus] = struct{}{} +} + +// StatusCleared returns if the "status" field was cleared in this mutation. +func (m *DbPackageMutation) StatusCleared() bool { + _, ok := m.clearedFields[dbpackage.FieldStatus] + return ok +} + +// ResetStatus resets all changes to the "status" field. +func (m *DbPackageMutation) ResetStatus() { + m.status = nil + m.addstatus = nil + delete(m.clearedFields, dbpackage.FieldStatus) +} + +// SetSkipReason sets the "skip_reason" field. +func (m *DbPackageMutation) SetSkipReason(s string) { + m.skip_reason = &s +} + +// SkipReason returns the value of the "skip_reason" field in the mutation. +func (m *DbPackageMutation) SkipReason() (r string, exists bool) { + v := m.skip_reason + if v == nil { + return + } + return *v, true +} + +// OldSkipReason returns the old "skip_reason" field's value of the DbPackage entity. +// If the DbPackage object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *DbPackageMutation) OldSkipReason(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, fmt.Errorf("OldSkipReason is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, fmt.Errorf("OldSkipReason requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldSkipReason: %w", err) + } + return oldValue.SkipReason, nil +} + +// ClearSkipReason clears the value of the "skip_reason" field. +func (m *DbPackageMutation) ClearSkipReason() { + m.skip_reason = nil + m.clearedFields[dbpackage.FieldSkipReason] = struct{}{} +} + +// SkipReasonCleared returns if the "skip_reason" field was cleared in this mutation. +func (m *DbPackageMutation) SkipReasonCleared() bool { + _, ok := m.clearedFields[dbpackage.FieldSkipReason] + return ok +} + +// ResetSkipReason resets all changes to the "skip_reason" field. +func (m *DbPackageMutation) ResetSkipReason() { + m.skip_reason = nil + delete(m.clearedFields, dbpackage.FieldSkipReason) +} + +// SetRepository sets the "repository" field. +func (m *DbPackageMutation) SetRepository(s string) { + m.repository = &s +} + +// Repository returns the value of the "repository" field in the mutation. +func (m *DbPackageMutation) Repository() (r string, exists bool) { + v := m.repository + if v == nil { + return + } + return *v, true +} + +// OldRepository returns the old "repository" field's value of the DbPackage entity. +// If the DbPackage object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *DbPackageMutation) OldRepository(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, fmt.Errorf("OldRepository is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, fmt.Errorf("OldRepository requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldRepository: %w", err) + } + return oldValue.Repository, nil +} + +// ResetRepository resets all changes to the "repository" field. +func (m *DbPackageMutation) ResetRepository() { + m.repository = nil +} + +// SetMarch sets the "march" field. +func (m *DbPackageMutation) SetMarch(s string) { + m.march = &s +} + +// March returns the value of the "march" field in the mutation. +func (m *DbPackageMutation) March() (r string, exists bool) { + v := m.march + if v == nil { + return + } + return *v, true +} + +// OldMarch returns the old "march" field's value of the DbPackage entity. +// If the DbPackage object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *DbPackageMutation) OldMarch(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, fmt.Errorf("OldMarch is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, fmt.Errorf("OldMarch requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldMarch: %w", err) + } + return oldValue.March, nil +} + +// ResetMarch resets all changes to the "march" field. +func (m *DbPackageMutation) ResetMarch() { + m.march = nil +} + +// SetVersion sets the "version" field. +func (m *DbPackageMutation) SetVersion(s string) { + m.version = &s +} + +// Version returns the value of the "version" field in the mutation. +func (m *DbPackageMutation) Version() (r string, exists bool) { + v := m.version + if v == nil { + return + } + return *v, true +} + +// OldVersion returns the old "version" field's value of the DbPackage entity. +// If the DbPackage object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *DbPackageMutation) OldVersion(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, fmt.Errorf("OldVersion is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, fmt.Errorf("OldVersion requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldVersion: %w", err) + } + return oldValue.Version, nil +} + +// ClearVersion clears the value of the "version" field. +func (m *DbPackageMutation) ClearVersion() { + m.version = nil + m.clearedFields[dbpackage.FieldVersion] = struct{}{} +} + +// VersionCleared returns if the "version" field was cleared in this mutation. +func (m *DbPackageMutation) VersionCleared() bool { + _, ok := m.clearedFields[dbpackage.FieldVersion] + return ok +} + +// ResetVersion resets all changes to the "version" field. +func (m *DbPackageMutation) ResetVersion() { + m.version = nil + delete(m.clearedFields, dbpackage.FieldVersion) +} + +// SetRepoVersion sets the "repo_version" field. +func (m *DbPackageMutation) SetRepoVersion(s string) { + m.repo_version = &s +} + +// RepoVersion returns the value of the "repo_version" field in the mutation. +func (m *DbPackageMutation) RepoVersion() (r string, exists bool) { + v := m.repo_version + if v == nil { + return + } + return *v, true +} + +// OldRepoVersion returns the old "repo_version" field's value of the DbPackage entity. +// If the DbPackage object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *DbPackageMutation) OldRepoVersion(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, fmt.Errorf("OldRepoVersion is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, fmt.Errorf("OldRepoVersion requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldRepoVersion: %w", err) + } + return oldValue.RepoVersion, nil +} + +// ClearRepoVersion clears the value of the "repo_version" field. +func (m *DbPackageMutation) ClearRepoVersion() { + m.repo_version = nil + m.clearedFields[dbpackage.FieldRepoVersion] = struct{}{} +} + +// RepoVersionCleared returns if the "repo_version" field was cleared in this mutation. +func (m *DbPackageMutation) RepoVersionCleared() bool { + _, ok := m.clearedFields[dbpackage.FieldRepoVersion] + return ok +} + +// ResetRepoVersion resets all changes to the "repo_version" field. +func (m *DbPackageMutation) ResetRepoVersion() { + m.repo_version = nil + delete(m.clearedFields, dbpackage.FieldRepoVersion) +} + +// SetBuildTime sets the "build_time" field. +func (m *DbPackageMutation) SetBuildTime(t time.Time) { + m.build_time = &t +} + +// BuildTime returns the value of the "build_time" field in the mutation. +func (m *DbPackageMutation) BuildTime() (r time.Time, exists bool) { + v := m.build_time + if v == nil { + return + } + return *v, true +} + +// OldBuildTime returns the old "build_time" field's value of the DbPackage entity. +// If the DbPackage object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *DbPackageMutation) OldBuildTime(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, fmt.Errorf("OldBuildTime is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, fmt.Errorf("OldBuildTime requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldBuildTime: %w", err) + } + return oldValue.BuildTime, nil +} + +// ClearBuildTime clears the value of the "build_time" field. +func (m *DbPackageMutation) ClearBuildTime() { + m.build_time = nil + m.clearedFields[dbpackage.FieldBuildTime] = struct{}{} +} + +// BuildTimeCleared returns if the "build_time" field was cleared in this mutation. +func (m *DbPackageMutation) BuildTimeCleared() bool { + _, ok := m.clearedFields[dbpackage.FieldBuildTime] + return ok +} + +// ResetBuildTime resets all changes to the "build_time" field. +func (m *DbPackageMutation) ResetBuildTime() { + m.build_time = nil + delete(m.clearedFields, dbpackage.FieldBuildTime) +} + +// SetBuildDuration sets the "build_duration" field. +func (m *DbPackageMutation) SetBuildDuration(u uint64) { + m.build_duration = &u + m.addbuild_duration = nil +} + +// BuildDuration returns the value of the "build_duration" field in the mutation. +func (m *DbPackageMutation) BuildDuration() (r uint64, exists bool) { + v := m.build_duration + if v == nil { + return + } + return *v, true +} + +// OldBuildDuration returns the old "build_duration" field's value of the DbPackage entity. +// If the DbPackage object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *DbPackageMutation) OldBuildDuration(ctx context.Context) (v uint64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, fmt.Errorf("OldBuildDuration is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, fmt.Errorf("OldBuildDuration requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldBuildDuration: %w", err) + } + return oldValue.BuildDuration, nil +} + +// AddBuildDuration adds u to the "build_duration" field. +func (m *DbPackageMutation) AddBuildDuration(u uint64) { + if m.addbuild_duration != nil { + *m.addbuild_duration += u + } else { + m.addbuild_duration = &u + } +} + +// AddedBuildDuration returns the value that was added to the "build_duration" field in this mutation. +func (m *DbPackageMutation) AddedBuildDuration() (r uint64, exists bool) { + v := m.addbuild_duration + if v == nil { + return + } + return *v, true +} + +// ClearBuildDuration clears the value of the "build_duration" field. +func (m *DbPackageMutation) ClearBuildDuration() { + m.build_duration = nil + m.addbuild_duration = nil + m.clearedFields[dbpackage.FieldBuildDuration] = struct{}{} +} + +// BuildDurationCleared returns if the "build_duration" field was cleared in this mutation. +func (m *DbPackageMutation) BuildDurationCleared() bool { + _, ok := m.clearedFields[dbpackage.FieldBuildDuration] + return ok +} + +// ResetBuildDuration resets all changes to the "build_duration" field. +func (m *DbPackageMutation) ResetBuildDuration() { + m.build_duration = nil + m.addbuild_duration = nil + delete(m.clearedFields, dbpackage.FieldBuildDuration) +} + +// SetUpdated sets the "updated" field. +func (m *DbPackageMutation) SetUpdated(t time.Time) { + m.updated = &t +} + +// Updated returns the value of the "updated" field in the mutation. +func (m *DbPackageMutation) Updated() (r time.Time, exists bool) { + v := m.updated + if v == nil { + return + } + return *v, true +} + +// OldUpdated returns the old "updated" field's value of the DbPackage entity. +// If the DbPackage object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *DbPackageMutation) OldUpdated(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, fmt.Errorf("OldUpdated is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, fmt.Errorf("OldUpdated requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUpdated: %w", err) + } + return oldValue.Updated, nil +} + +// ClearUpdated clears the value of the "updated" field. +func (m *DbPackageMutation) ClearUpdated() { + m.updated = nil + m.clearedFields[dbpackage.FieldUpdated] = struct{}{} +} + +// UpdatedCleared returns if the "updated" field was cleared in this mutation. +func (m *DbPackageMutation) UpdatedCleared() bool { + _, ok := m.clearedFields[dbpackage.FieldUpdated] + return ok +} + +// ResetUpdated resets all changes to the "updated" field. +func (m *DbPackageMutation) ResetUpdated() { + m.updated = nil + delete(m.clearedFields, dbpackage.FieldUpdated) +} + +// Op returns the operation name. +func (m *DbPackageMutation) Op() Op { + return m.op +} + +// Type returns the node type of this mutation (DbPackage). +func (m *DbPackageMutation) Type() string { + return m.typ +} + +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *DbPackageMutation) Fields() []string { + fields := make([]string, 0, 11) + if m.pkgbase != nil { + fields = append(fields, dbpackage.FieldPkgbase) + } + if m.packages != nil { + fields = append(fields, dbpackage.FieldPackages) + } + if m.status != nil { + fields = append(fields, dbpackage.FieldStatus) + } + if m.skip_reason != nil { + fields = append(fields, dbpackage.FieldSkipReason) + } + if m.repository != nil { + fields = append(fields, dbpackage.FieldRepository) + } + if m.march != nil { + fields = append(fields, dbpackage.FieldMarch) + } + if m.version != nil { + fields = append(fields, dbpackage.FieldVersion) + } + if m.repo_version != nil { + fields = append(fields, dbpackage.FieldRepoVersion) + } + if m.build_time != nil { + fields = append(fields, dbpackage.FieldBuildTime) + } + if m.build_duration != nil { + fields = append(fields, dbpackage.FieldBuildDuration) + } + if m.updated != nil { + fields = append(fields, dbpackage.FieldUpdated) + } + return fields +} + +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *DbPackageMutation) Field(name string) (ent.Value, bool) { + switch name { + case dbpackage.FieldPkgbase: + return m.Pkgbase() + case dbpackage.FieldPackages: + return m.Packages() + case dbpackage.FieldStatus: + return m.Status() + case dbpackage.FieldSkipReason: + return m.SkipReason() + case dbpackage.FieldRepository: + return m.Repository() + case dbpackage.FieldMarch: + return m.March() + case dbpackage.FieldVersion: + return m.Version() + case dbpackage.FieldRepoVersion: + return m.RepoVersion() + case dbpackage.FieldBuildTime: + return m.BuildTime() + case dbpackage.FieldBuildDuration: + return m.BuildDuration() + case dbpackage.FieldUpdated: + return m.Updated() + } + return nil, false +} + +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *DbPackageMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case dbpackage.FieldPkgbase: + return m.OldPkgbase(ctx) + case dbpackage.FieldPackages: + return m.OldPackages(ctx) + case dbpackage.FieldStatus: + return m.OldStatus(ctx) + case dbpackage.FieldSkipReason: + return m.OldSkipReason(ctx) + case dbpackage.FieldRepository: + return m.OldRepository(ctx) + case dbpackage.FieldMarch: + return m.OldMarch(ctx) + case dbpackage.FieldVersion: + return m.OldVersion(ctx) + case dbpackage.FieldRepoVersion: + return m.OldRepoVersion(ctx) + case dbpackage.FieldBuildTime: + return m.OldBuildTime(ctx) + case dbpackage.FieldBuildDuration: + return m.OldBuildDuration(ctx) + case dbpackage.FieldUpdated: + return m.OldUpdated(ctx) + } + return nil, fmt.Errorf("unknown DbPackage field %s", name) +} + +// SetField sets the value of a field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *DbPackageMutation) SetField(name string, value ent.Value) error { + switch name { + case dbpackage.FieldPkgbase: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetPkgbase(v) + return nil + case dbpackage.FieldPackages: + v, ok := value.([]string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetPackages(v) + return nil + case dbpackage.FieldStatus: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetStatus(v) + return nil + case dbpackage.FieldSkipReason: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetSkipReason(v) + return nil + case dbpackage.FieldRepository: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetRepository(v) + return nil + case dbpackage.FieldMarch: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetMarch(v) + return nil + case dbpackage.FieldVersion: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetVersion(v) + return nil + case dbpackage.FieldRepoVersion: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetRepoVersion(v) + return nil + case dbpackage.FieldBuildTime: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetBuildTime(v) + return nil + case dbpackage.FieldBuildDuration: + v, ok := value.(uint64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetBuildDuration(v) + return nil + case dbpackage.FieldUpdated: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUpdated(v) + return nil + } + return fmt.Errorf("unknown DbPackage field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *DbPackageMutation) AddedFields() []string { + var fields []string + if m.addstatus != nil { + fields = append(fields, dbpackage.FieldStatus) + } + if m.addbuild_duration != nil { + fields = append(fields, dbpackage.FieldBuildDuration) + } + return fields +} + +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *DbPackageMutation) AddedField(name string) (ent.Value, bool) { + switch name { + case dbpackage.FieldStatus: + return m.AddedStatus() + case dbpackage.FieldBuildDuration: + return m.AddedBuildDuration() + } + return nil, false +} + +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *DbPackageMutation) AddField(name string, value ent.Value) error { + switch name { + case dbpackage.FieldStatus: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddStatus(v) + return nil + case dbpackage.FieldBuildDuration: + v, ok := value.(uint64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddBuildDuration(v) + return nil + } + return fmt.Errorf("unknown DbPackage numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *DbPackageMutation) ClearedFields() []string { + var fields []string + if m.FieldCleared(dbpackage.FieldPackages) { + fields = append(fields, dbpackage.FieldPackages) + } + if m.FieldCleared(dbpackage.FieldStatus) { + fields = append(fields, dbpackage.FieldStatus) + } + if m.FieldCleared(dbpackage.FieldSkipReason) { + fields = append(fields, dbpackage.FieldSkipReason) + } + if m.FieldCleared(dbpackage.FieldVersion) { + fields = append(fields, dbpackage.FieldVersion) + } + if m.FieldCleared(dbpackage.FieldRepoVersion) { + fields = append(fields, dbpackage.FieldRepoVersion) + } + if m.FieldCleared(dbpackage.FieldBuildTime) { + fields = append(fields, dbpackage.FieldBuildTime) + } + if m.FieldCleared(dbpackage.FieldBuildDuration) { + fields = append(fields, dbpackage.FieldBuildDuration) + } + if m.FieldCleared(dbpackage.FieldUpdated) { + fields = append(fields, dbpackage.FieldUpdated) + } + return fields +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *DbPackageMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] + return ok +} + +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *DbPackageMutation) ClearField(name string) error { + switch name { + case dbpackage.FieldPackages: + m.ClearPackages() + return nil + case dbpackage.FieldStatus: + m.ClearStatus() + return nil + case dbpackage.FieldSkipReason: + m.ClearSkipReason() + return nil + case dbpackage.FieldVersion: + m.ClearVersion() + return nil + case dbpackage.FieldRepoVersion: + m.ClearRepoVersion() + return nil + case dbpackage.FieldBuildTime: + m.ClearBuildTime() + return nil + case dbpackage.FieldBuildDuration: + m.ClearBuildDuration() + return nil + case dbpackage.FieldUpdated: + m.ClearUpdated() + return nil + } + return fmt.Errorf("unknown DbPackage nullable field %s", name) +} + +// ResetField resets all changes in the mutation for the field with the given name. +// It returns an error if the field is not defined in the schema. +func (m *DbPackageMutation) ResetField(name string) error { + switch name { + case dbpackage.FieldPkgbase: + m.ResetPkgbase() + return nil + case dbpackage.FieldPackages: + m.ResetPackages() + return nil + case dbpackage.FieldStatus: + m.ResetStatus() + return nil + case dbpackage.FieldSkipReason: + m.ResetSkipReason() + return nil + case dbpackage.FieldRepository: + m.ResetRepository() + return nil + case dbpackage.FieldMarch: + m.ResetMarch() + return nil + case dbpackage.FieldVersion: + m.ResetVersion() + return nil + case dbpackage.FieldRepoVersion: + m.ResetRepoVersion() + return nil + case dbpackage.FieldBuildTime: + m.ResetBuildTime() + return nil + case dbpackage.FieldBuildDuration: + m.ResetBuildDuration() + return nil + case dbpackage.FieldUpdated: + m.ResetUpdated() + return nil + } + return fmt.Errorf("unknown DbPackage field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *DbPackageMutation) AddedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *DbPackageMutation) AddedIDs(name string) []ent.Value { + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *DbPackageMutation) RemovedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *DbPackageMutation) RemovedIDs(name string) []ent.Value { + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *DbPackageMutation) ClearedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *DbPackageMutation) EdgeCleared(name string) bool { + return false +} + +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *DbPackageMutation) ClearEdge(name string) error { + return fmt.Errorf("unknown DbPackage unique edge %s", name) +} + +// ResetEdge resets all changes to the edge with the given name in this mutation. +// It returns an error if the edge is not defined in the schema. +func (m *DbPackageMutation) ResetEdge(name string) error { + return fmt.Errorf("unknown DbPackage edge %s", name) +} diff --git a/ent/predicate/predicate.go b/ent/predicate/predicate.go new file mode 100644 index 0000000..adaef0b --- /dev/null +++ b/ent/predicate/predicate.go @@ -0,0 +1,10 @@ +// Code generated by entc, DO NOT EDIT. + +package predicate + +import ( + "entgo.io/ent/dialect/sql" +) + +// DbPackage is the predicate function for dbpackage builders. +type DbPackage func(*sql.Selector) diff --git a/ent/runtime.go b/ent/runtime.go new file mode 100644 index 0000000..0a1a626 --- /dev/null +++ b/ent/runtime.go @@ -0,0 +1,36 @@ +// Code generated by entc, DO NOT EDIT. + +package ent + +import ( + "ALHP.go/ent/dbpackage" + "ALHP.go/ent/schema" +) + +// The init function reads all schema descriptors with runtime code +// (default values, validators, hooks and policies) and stitches it +// to their package variables. +func init() { + dbpackageFields := schema.DbPackage{}.Fields() + _ = dbpackageFields + // dbpackageDescPkgbase is the schema descriptor for pkgbase field. + dbpackageDescPkgbase := dbpackageFields[0].Descriptor() + // dbpackage.PkgbaseValidator is a validator for the "pkgbase" field. It is called by the builders before save. + dbpackage.PkgbaseValidator = dbpackageDescPkgbase.Validators[0].(func(string) error) + // dbpackageDescStatus is the schema descriptor for status field. + dbpackageDescStatus := dbpackageFields[2].Descriptor() + // dbpackage.StatusValidator is a validator for the "status" field. It is called by the builders before save. + dbpackage.StatusValidator = dbpackageDescStatus.Validators[0].(func(int) error) + // dbpackageDescRepository is the schema descriptor for repository field. + dbpackageDescRepository := dbpackageFields[4].Descriptor() + // dbpackage.RepositoryValidator is a validator for the "repository" field. It is called by the builders before save. + dbpackage.RepositoryValidator = dbpackageDescRepository.Validators[0].(func(string) error) + // dbpackageDescMarch is the schema descriptor for march field. + dbpackageDescMarch := dbpackageFields[5].Descriptor() + // dbpackage.MarchValidator is a validator for the "march" field. It is called by the builders before save. + dbpackage.MarchValidator = dbpackageDescMarch.Validators[0].(func(string) error) + // dbpackageDescBuildDuration is the schema descriptor for build_duration field. + dbpackageDescBuildDuration := dbpackageFields[9].Descriptor() + // dbpackage.BuildDurationValidator is a validator for the "build_duration" field. It is called by the builders before save. + dbpackage.BuildDurationValidator = dbpackageDescBuildDuration.Validators[0].(func(uint64) error) +} diff --git a/ent/runtime/runtime.go b/ent/runtime/runtime.go new file mode 100644 index 0000000..c28fe4e --- /dev/null +++ b/ent/runtime/runtime.go @@ -0,0 +1,10 @@ +// Code generated by entc, DO NOT EDIT. + +package runtime + +// The schema-stitching logic is generated in ALHP.go/ent/runtime.go + +const ( + Version = "v0.8.0" // Version of ent codegen. + Sum = "h1:xirrW//1oda7pp0bz+XssSOv4/C3nmgYQOxjIfljFt8=" // Sum of ent codegen. +) diff --git a/ent/schema/dbpackage.go b/ent/schema/dbpackage.go new file mode 100644 index 0000000..2b5081b --- /dev/null +++ b/ent/schema/dbpackage.go @@ -0,0 +1,33 @@ +package schema + +import ( + "entgo.io/ent" + "entgo.io/ent/schema/field" +) + +// DbPackage holds the schema definition for the DbPackage entity. +type DbPackage struct { + ent.Schema +} + +// Fields of the DbPackage. +func (DbPackage) Fields() []ent.Field { + return []ent.Field{ + field.String("pkgbase").NotEmpty().Immutable().Unique(), + field.Strings("packages").Optional(), + field.Int("status").Optional().Min(0), + field.String("skip_reason").Optional(), + field.String("repository").NotEmpty(), + field.String("march").NotEmpty(), + field.String("version").Optional(), + field.String("repo_version").Optional(), + field.Time("build_time").Optional(), + field.Uint64("build_duration").Positive().Optional(), + field.Time("updated").Optional(), + } +} + +// Edges of the DbPackage. +func (DbPackage) Edges() []ent.Edge { + return nil +} diff --git a/ent/tx.go b/ent/tx.go new file mode 100644 index 0000000..fbda86f --- /dev/null +++ b/ent/tx.go @@ -0,0 +1,210 @@ +// Code generated by entc, DO NOT EDIT. + +package ent + +import ( + "context" + "sync" + + "entgo.io/ent/dialect" +) + +// Tx is a transactional client that is created by calling Client.Tx(). +type Tx struct { + config + // DbPackage is the client for interacting with the DbPackage builders. + DbPackage *DbPackageClient + + // lazily loaded. + client *Client + clientOnce sync.Once + + // completion callbacks. + mu sync.Mutex + onCommit []CommitHook + onRollback []RollbackHook + + // ctx lives for the life of the transaction. It is + // the same context used by the underlying connection. + ctx context.Context +} + +type ( + // Committer is the interface that wraps the Committer method. + Committer interface { + Commit(context.Context, *Tx) error + } + + // The CommitFunc type is an adapter to allow the use of ordinary + // function as a Committer. If f is a function with the appropriate + // signature, CommitFunc(f) is a Committer that calls f. + CommitFunc func(context.Context, *Tx) error + + // CommitHook defines the "commit middleware". A function that gets a Committer + // and returns a Committer. For example: + // + // hook := func(next ent.Committer) ent.Committer { + // return ent.CommitFunc(func(context.Context, tx *ent.Tx) error { + // // Do some stuff before. + // if err := next.Commit(ctx, tx); err != nil { + // return err + // } + // // Do some stuff after. + // return nil + // }) + // } + // + CommitHook func(Committer) Committer +) + +// Commit calls f(ctx, m). +func (f CommitFunc) Commit(ctx context.Context, tx *Tx) error { + return f(ctx, tx) +} + +// Commit commits the transaction. +func (tx *Tx) Commit() error { + txDriver := tx.config.driver.(*txDriver) + var fn Committer = CommitFunc(func(context.Context, *Tx) error { + return txDriver.tx.Commit() + }) + tx.mu.Lock() + hooks := append([]CommitHook(nil), tx.onCommit...) + tx.mu.Unlock() + for i := len(hooks) - 1; i >= 0; i-- { + fn = hooks[i](fn) + } + return fn.Commit(tx.ctx, tx) +} + +// OnCommit adds a hook to call on commit. +func (tx *Tx) OnCommit(f CommitHook) { + tx.mu.Lock() + defer tx.mu.Unlock() + tx.onCommit = append(tx.onCommit, f) +} + +type ( + // Rollbacker is the interface that wraps the Rollbacker method. + Rollbacker interface { + Rollback(context.Context, *Tx) error + } + + // The RollbackFunc type is an adapter to allow the use of ordinary + // function as a Rollbacker. If f is a function with the appropriate + // signature, RollbackFunc(f) is a Rollbacker that calls f. + RollbackFunc func(context.Context, *Tx) error + + // RollbackHook defines the "rollback middleware". A function that gets a Rollbacker + // and returns a Rollbacker. For example: + // + // hook := func(next ent.Rollbacker) ent.Rollbacker { + // return ent.RollbackFunc(func(context.Context, tx *ent.Tx) error { + // // Do some stuff before. + // if err := next.Rollback(ctx, tx); err != nil { + // return err + // } + // // Do some stuff after. + // return nil + // }) + // } + // + RollbackHook func(Rollbacker) Rollbacker +) + +// Rollback calls f(ctx, m). +func (f RollbackFunc) Rollback(ctx context.Context, tx *Tx) error { + return f(ctx, tx) +} + +// Rollback rollbacks the transaction. +func (tx *Tx) Rollback() error { + txDriver := tx.config.driver.(*txDriver) + var fn Rollbacker = RollbackFunc(func(context.Context, *Tx) error { + return txDriver.tx.Rollback() + }) + tx.mu.Lock() + hooks := append([]RollbackHook(nil), tx.onRollback...) + tx.mu.Unlock() + for i := len(hooks) - 1; i >= 0; i-- { + fn = hooks[i](fn) + } + return fn.Rollback(tx.ctx, tx) +} + +// OnRollback adds a hook to call on rollback. +func (tx *Tx) OnRollback(f RollbackHook) { + tx.mu.Lock() + defer tx.mu.Unlock() + tx.onRollback = append(tx.onRollback, f) +} + +// Client returns a Client that binds to current transaction. +func (tx *Tx) Client() *Client { + tx.clientOnce.Do(func() { + tx.client = &Client{config: tx.config} + tx.client.init() + }) + return tx.client +} + +func (tx *Tx) init() { + tx.DbPackage = NewDbPackageClient(tx.config) +} + +// txDriver wraps the given dialect.Tx with a nop dialect.Driver implementation. +// The idea is to support transactions without adding any extra code to the builders. +// When a builder calls to driver.Tx(), it gets the same dialect.Tx instance. +// Commit and Rollback are nop for the internal builders and the user must call one +// of them in order to commit or rollback the transaction. +// +// If a closed transaction is embedded in one of the generated entities, and the entity +// applies a query, for example: DbPackage.QueryXXX(), the query will be executed +// through the driver which created this transaction. +// +// Note that txDriver is not goroutine safe. +type txDriver struct { + // the driver we started the transaction from. + drv dialect.Driver + // tx is the underlying transaction. + tx dialect.Tx +} + +// newTx creates a new transactional driver. +func newTx(ctx context.Context, drv dialect.Driver) (*txDriver, error) { + tx, err := drv.Tx(ctx) + if err != nil { + return nil, err + } + return &txDriver{tx: tx, drv: drv}, nil +} + +// Tx returns the transaction wrapper (txDriver) to avoid Commit or Rollback calls +// from the internal builders. Should be called only by the internal builders. +func (tx *txDriver) Tx(context.Context) (dialect.Tx, error) { return tx, nil } + +// Dialect returns the dialect of the driver we started the transaction from. +func (tx *txDriver) Dialect() string { return tx.drv.Dialect() } + +// Close is a nop close. +func (*txDriver) Close() error { return nil } + +// Commit is a nop commit for the internal builders. +// User must call `Tx.Commit` in order to commit the transaction. +func (*txDriver) Commit() error { return nil } + +// Rollback is a nop rollback for the internal builders. +// User must call `Tx.Rollback` in order to rollback the transaction. +func (*txDriver) Rollback() error { return nil } + +// Exec calls tx.Exec. +func (tx *txDriver) Exec(ctx context.Context, query string, args, v interface{}) error { + return tx.tx.Exec(ctx, query, args, v) +} + +// Query calls tx.Query. +func (tx *txDriver) Query(ctx context.Context, query string, args, v interface{}) error { + return tx.tx.Query(ctx, query, args, v) +} + +var _ dialect.Driver = (*txDriver)(nil) diff --git a/go.mod b/go.mod index 2c8e780..e1912a8 100644 --- a/go.mod +++ b/go.mod @@ -3,9 +3,11 @@ module ALHP.go go 1.16 require ( + entgo.io/ent v0.8.0 github.com/Jguer/go-alpm/v2 v2.0.5 github.com/Morganamilo/go-srcinfo v1.0.0 github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf // indirect + github.com/mattn/go-sqlite3 v1.14.6 github.com/sirupsen/logrus v1.8.1 github.com/wercker/journalhook v0.0.0-20180428041537-5d0a5ae867b3 github.com/yargevad/filepathx v1.0.0 diff --git a/go.sum b/go.sum index 3bdd55e..e29bc0b 100644 --- a/go.sum +++ b/go.sum @@ -1,24 +1,402 @@ +cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= +cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU= +cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= +cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc= +cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0= +cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= +cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= +cloud.google.com/go/firestore v1.1.0/go.mod h1:ulACoGHTpvq5r8rxGJ4ddJZBZqakUQqClKRT5SZwBmk= +cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= +cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw= +dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= +entgo.io/ent v0.8.0 h1:xirrW//1oda7pp0bz+XssSOv4/C3nmgYQOxjIfljFt8= +entgo.io/ent v0.8.0/go.mod h1:KNjsukat/NJi6zJh1utwRadsbGOZsBbAZNDxkW7tMCc= +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= +github.com/DATA-DOG/go-sqlmock v1.5.0 h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20OEh60= +github.com/DATA-DOG/go-sqlmock v1.5.0/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= github.com/Jguer/go-alpm/v2 v2.0.5 h1:1TZxkvCIfTOhjhxGy/Z1FNSeuY9DXBKF5qxUoj0IZ0A= github.com/Jguer/go-alpm/v2 v2.0.5/go.mod h1:zU4iKCtNkDARfj5BrKJXYAQ5nIjtZbySfa0paboSmTQ= github.com/Morganamilo/go-srcinfo v1.0.0 h1:Wh4nEF+HJWo+29hnxM18Q2hi+DUf0GejS13+Wg+dzmI= github.com/Morganamilo/go-srcinfo v1.0.0/go.mod h1:MP6VGY1NNpVUmYIEgoM9acix95KQqIRyqQ0hCLsyYUY= +github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= +github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= +github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= +github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= +github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= +github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= +github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= +github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= +github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= +github.com/bketelsen/crypt v0.0.3-0.20200106085610-5cbc8cc4026c/go.mod h1:MKsuJmJgSg28kpZDP6UIiPt0e0Oz0kqKNGyRaWEPv84= +github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= +github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= +github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= +github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= +github.com/coreos/etcd v3.3.13+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= +github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= +github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf h1:iW4rZ826su+pqaw19uhpSCzhj44qo35pNgKFGqzDKkU= github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= +github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= +github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= +github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= +github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= +github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= +github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= +github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= +github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= +github.com/go-bindata/go-bindata v1.0.1-0.20190711162640-ee3c2418e368/go.mod h1:7xCgX1lzlrXPHkfvn3EhumqHkmSlzt8at9q7v0ax19c= +github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= +github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= +github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= +github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= +github.com/go-openapi/inflect v0.19.0 h1:9jCH9scKIbHeV9m12SmPilScz6krDxKRasNNSNPXu/4= +github.com/go-openapi/inflect v0.19.0/go.mod h1:lHpZVlpIQqLyKwJ4N+YSc9hchQy/i12fJykb83CRBH4= +github.com/go-sql-driver/mysql v1.5.1-0.20200311113236-681ffa848bae/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= +github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= +github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= +github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= +github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= +github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= +github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= +github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= +github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= +github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= +github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= +github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= +github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= +github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= +github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.2.0 h1:qJYtXnJRWmpe7m/3XlyhrsLrEURqHRM2kxzoxXqyUDs= +github.com/google/uuid v1.2.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= +github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= +github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= +github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= +github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= +github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= +github.com/hashicorp/consul/api v1.1.0/go.mod h1:VmuI/Lkw1nC05EYQWNKwWGbkg+FbDBtguAZLlVdkD9Q= +github.com/hashicorp/consul/sdk v0.1.1/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8= +github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= +github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= +github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= +github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= +github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= +github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU= +github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU= +github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4= +github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= +github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= +github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90= +github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= +github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= +github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= +github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= +github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ= +github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I= +github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc= +github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= +github.com/jessevdk/go-flags v1.5.0/go.mod h1:Fw0T6WPc1dYxT4mKEZRfG5kJhaTDP9pj1c2EWnYs/m4= +github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E= +github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= +github.com/jinzhu/now v1.1.1 h1:g39TucaRWyV3dwDO++eEc6qf8TVIQ/Da48WmqjZ3i7E= +github.com/jinzhu/now v1.1.1/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= +github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= +github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= +github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= +github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= +github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= +github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= +github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= +github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= +github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/lib/pq v1.10.0/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= +github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= +github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= +github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= +github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0= +github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= +github.com/mattn/go-sqlite3 v1.14.5/go.mod h1:WVKg1VTActs4Qso6iwGbiFih2UIHo0ENGwNd0Lj+XmI= +github.com/mattn/go-sqlite3 v1.14.6 h1:dNPt6NO46WmLVt2DLNpwczCmdV5boIZ6g/tlDrlRUbg= +github.com/mattn/go-sqlite3 v1.14.6/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= +github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= +github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= +github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc= +github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= +github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= +github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= +github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg= +github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY= +github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= +github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= +github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= +github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= +github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= +github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= +github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= +github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= +github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= +github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= +github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= +github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso= +github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= +github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= +github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= +github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= +github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= +github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= +github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= +github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= +github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= +github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= +github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= +github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE= github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= -github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w= +github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= +github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= +github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= +github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= +github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= +github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= +github.com/spf13/cobra v1.1.3 h1:xghbfqPkxzxP3C/f3n5DdpAbdKLj4ZE4BWQI362l53M= +github.com/spf13/cobra v1.1.3/go.mod h1:pGADOWyqRD/YMrPZigI/zbliZ2wVD/23d+is3pSWzOo= +github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= +github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= +github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= +github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= +github.com/spf13/viper v1.7.0/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= +github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/wercker/journalhook v0.0.0-20180428041537-5d0a5ae867b3 h1:shC1HB1UogxN5Ech3Yqaaxj1X/P656PPCB4RbojIJqc= github.com/wercker/journalhook v0.0.0-20180428041537-5d0a5ae867b3/go.mod h1:XCsSkdKK4gwBMNrOCZWww0pX6AOt+2gYc5Z6jBRrNVg= +github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= github.com/yargevad/filepathx v1.0.0 h1:SYcT+N3tYGi+NvazubCNlvgIPbzAk7i7y2dwg3I5FYc= github.com/yargevad/filepathx v1.0.0/go.mod h1:BprfX/gpYNJHJfc35GjRRpVcwWXS89gGulUIU5tK3tA= -golang.org/x/sys v0.0.0-20191026070338-33540a1f6037 h1:YyJpGZS1sBuBCzLAR1VEpK193GlqGZbnPFnPV/5Rsb4= +github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= +go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= +go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= +go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= +go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= +go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= +go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= +golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= +golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek= +golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY= +golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= +golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= +golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= +golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= +golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= +golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= +golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= +golang.org/x/mod v0.3.0 h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4= +golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= +golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4 h1:EZ2mChiOa8udjfp6rRmswTbtZN/QzUQp4ptM4rnjHvc= +golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= +golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191112195655-aa38f8e97acc/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.1.0 h1:po9/4sTYwZU9lPhi1tOrb4hCv3qrhiQ77LZfGa2OjwY= +golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= +google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= +google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= +google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= +google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= +google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= +google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= +google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8= +google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= +google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= +google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= +google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= +google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= +google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= +google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= +google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= +google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= +google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= +google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= +google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= +gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= +gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= +gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= +gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= +gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gorm.io/driver/sqlite v1.1.4 h1:PDzwYE+sI6De2+mxAneV9Xs11+ZyKV6oxD3wDGkaNvM= +gorm.io/driver/sqlite v1.1.4/go.mod h1:mJCeTFr7+crvS+TRnWc5Z3UvwxUN1BGBLMrf5LA9DYw= +gorm.io/gorm v1.20.7 h1:rMS4CL3pNmYq1V5/X+nHHjh1Dx6dnf27+Cai5zabo+M= +gorm.io/gorm v1.20.7/go.mod h1:0HFTzE/SqkGTzK6TlDPPQbAYCluiVvhzoA1+aVyzenw= +honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= +rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= diff --git a/main.go b/main.go index 5ef6405..ea91abe 100644 --- a/main.go +++ b/main.go @@ -1,15 +1,20 @@ package main import ( + "ALHP.go/ent" + "ALHP.go/ent/dbpackage" "bufio" "bytes" + "context" "fmt" "github.com/Jguer/go-alpm/v2" "github.com/Morganamilo/go-srcinfo" + _ "github.com/mattn/go-sqlite3" log "github.com/sirupsen/logrus" "github.com/wercker/journalhook" "github.com/yargevad/filepathx" "gopkg.in/yaml.v2" + "html/template" "io" "math/rand" "os" @@ -33,6 +38,15 @@ const ( orgChrootName = "root" ) +const ( + SKIPPED = iota + FAILED = iota + BUILD = iota + QUEUED = iota + BUILDING = iota + LATEST = iota +) + var ( conf = Conf{} repos []string @@ -40,6 +54,8 @@ var ( rePkgRel = regexp.MustCompile(`(?m)^pkgrel\s*=\s*(.+)$`) rePkgFile = regexp.MustCompile(`^(.*)-.*-.*-(?:x86_64|any)\.pkg\.tar\.zst(?:\.sig)*$`) buildManager BuildManager + db *ent.Client + dbLock sync.RWMutex ) type BuildPackage struct { @@ -64,10 +80,6 @@ type BuildManager struct { failedMutex sync.RWMutex buildProcesses []*os.Process buildProcMutex sync.RWMutex - stats struct { - fullyBuild int - eligible int - } } type Conf struct { @@ -75,7 +87,7 @@ type Conf struct { Repos, March, Blacklist []string Svn2git map[string]string Basedir struct { - Repo, Chroot, Makepkg, Upstream string + Repo, Chroot, Makepkg, Upstream, Db string } Build struct { Worker int @@ -225,6 +237,15 @@ func importKeys(pkg *BuildPackage) { } } +func packages2string(pkgs []srcinfo.Package) []string { + var sPkgs []string + for _, p := range pkgs { + sPkgs = append(sPkgs, p.Pkgname) + } + + return sPkgs +} + func increasePkgRel(pkg *BuildPackage) { f, err := os.OpenFile(pkg.Pkgbuild, os.O_RDWR, os.ModePerm) check(err) @@ -275,6 +296,11 @@ func (b *BuildManager) buildWorker(id int) { log.Infof("[%s/%s] Build starting", pkg.FullRepo, pkg.Pkgbase) + dbPkg := getDbPackage(pkg) + dbLock.Lock() + dbPkg.Update().SetStatus(BUILDING).SaveX(context.Background()) + dbLock.Unlock() + importKeys(pkg) increasePkgRel(pkg) pkg.PkgFiles = []string{} @@ -292,7 +318,7 @@ func (b *BuildManager) buildWorker(id int) { b.buildProcesses = append(b.buildProcesses, cmd.Process) b.buildProcMutex.Unlock() - err := cmd.Wait() + err = cmd.Wait() b.buildProcMutex.Lock() for i := range b.buildProcesses { @@ -329,6 +355,11 @@ func (b *BuildManager) buildWorker(id int) { check(os.MkdirAll(filepath.Join(conf.Basedir.Repo, "logs"), os.ModePerm)) check(os.WriteFile(filepath.Join(conf.Basedir.Repo, "logs", pkg.Pkgbase+".log"), out.Bytes(), os.ModePerm)) + dbPkg := getDbPackage(pkg) + dbLock.Lock() + dbPkg.Update().SetStatus(FAILED).SetBuildTime(time.Now()).SetBuildDuration(uint64(time.Now().Sub(start).Milliseconds())).SaveX(context.Background()) + dbLock.Unlock() + gitClean(pkg) b.buildWG.Done() continue @@ -372,18 +403,35 @@ func (b *BuildManager) buildWorker(id int) { pkg.PkgFiles = append(pkg.PkgFiles, filepath.Join(conf.Basedir.Repo, pkg.FullRepo, "os", conf.Arch, filepath.Base(file))) } } - b.repoAdd[pkg.FullRepo] <- pkg if _, err := os.Stat(filepath.Join(conf.Basedir.Repo, "logs", pkg.Pkgbase+".log")); err == nil { check(os.Remove(filepath.Join(conf.Basedir.Repo, "logs", pkg.Pkgbase+".log"))) } - gitClean(pkg) + dbPkg = getDbPackage(pkg) + dbLock.Lock() + dbPkg.Update().SetStatus(BUILD).SetBuildTime(time.Now()).SetBuildDuration(uint64(time.Now().Sub(start).Milliseconds())).SaveX(context.Background()) + dbLock.Unlock() + log.Infof("[%s/%s] Build successful (%s)", pkg.FullRepo, pkg.Pkgbase, time.Now().Sub(start)) + b.repoAdd[pkg.FullRepo] <- pkg + + gitClean(pkg) } } } +func getDbPackage(pkg *BuildPackage) *ent.DbPackage { + dbLock.Lock() + dbPkg, err := db.DbPackage.Query().Where(dbpackage.Pkgbase(pkg.Pkgbase)).Only(context.Background()) + if err != nil { + dbPkg = db.DbPackage.Create().SetPkgbase(pkg.Pkgbase).SetMarch(pkg.March).SetPackages(packages2string(pkg.Srcinfo.Packages)).SetRepository(pkg.Repo).SaveX(context.Background()) + } + dbLock.Unlock() + + return dbPkg +} + func (b *BuildManager) parseWorker() { for { if b.exit { @@ -406,31 +454,6 @@ func (b *BuildManager) parseWorker() { continue } pkg.Srcinfo = info - - if contains(info.Arch, "any") || contains(conf.Blacklist, info.Pkgbase) { - log.Infof("Skipped %s: blacklisted or any-Package", info.Pkgbase) - b.repoPurge[pkg.FullRepo] <- pkg - b.parseWG.Done() - continue - } - - // Skip Haskell packages for now, as we are facing linking problems with them, - // most likely caused by not having a dependency tree implemented yet and building at random. - // https://git.harting.dev/anonfunc/ALHP.GO/issues/11 - if contains(info.MakeDepends, "ghc") || contains(info.MakeDepends, "haskell-ghc") || contains(info.Depends, "ghc") || contains(info.Depends, "haskell-ghc") { - log.Infof("Skipped %s: haskell package", info.Pkgbase) - b.repoPurge[pkg.FullRepo] <- pkg - b.parseWG.Done() - continue - } - - if isPkgFailed(pkg) { - log.Infof("Skipped %s: failed build", info.Pkgbase) - b.repoPurge[pkg.FullRepo] <- pkg - b.parseWG.Done() - continue - } - var pkgVer string if pkg.Srcinfo.Epoch == "" { pkgVer = pkg.Srcinfo.Pkgver + "-" + pkg.Srcinfo.Pkgrel @@ -438,16 +461,64 @@ func (b *BuildManager) parseWorker() { pkgVer = pkg.Srcinfo.Epoch + ":" + pkg.Srcinfo.Pkgver + "-" + pkg.Srcinfo.Pkgrel } - repoVer := getVersionFromRepo(pkg) - if repoVer != "" && alpm.VerCmp(repoVer, pkgVer) > 0 { - log.Debugf("Skipped %s: Version in repo higher than in PKGBUILD (%s < %s)", info.Pkgbase, pkgVer, repoVer) - b.stats.eligible++ - b.stats.fullyBuild++ + dbPkg := getDbPackage(pkg) + dbLock.Lock() + dbPkg = dbPkg.Update().SetUpdated(time.Now()).SetVersion(pkgVer).SaveX(context.Background()) + dbLock.Unlock() + + skipping := false + if contains(info.Arch, "any") { + log.Infof("Skipped %s: any-Package", info.Pkgbase) + dbLock.Lock() + dbPkg = dbPkg.Update().SetStatus(SKIPPED).SetSkipReason("arch = any").SaveX(context.Background()) + dbLock.Unlock() + skipping = true + } else if contains(conf.Blacklist, info.Pkgbase) { + log.Infof("Skipped %s: blacklisted package", info.Pkgbase) + dbLock.Lock() + dbPkg = dbPkg.Update().SetStatus(SKIPPED).SetSkipReason("blacklisted").SaveX(context.Background()) + dbLock.Unlock() + skipping = true + } else if contains(info.MakeDepends, "ghc") || contains(info.MakeDepends, "haskell-ghc") || contains(info.Depends, "ghc") || contains(info.Depends, "haskell-ghc") { + // Skip Haskell packages for now, as we are facing linking problems with them, + // most likely caused by not having a dependency tree implemented yet and building at random. + // https://git.harting.dev/anonfunc/ALHP.GO/issues/11 + log.Infof("Skipped %s: haskell package", info.Pkgbase) + dbLock.Lock() + dbPkg = dbPkg.Update().SetStatus(SKIPPED).SetSkipReason("blacklisted (haskell)").SaveX(context.Background()) + dbLock.Unlock() + skipping = true + } else if isPkgFailed(pkg) { + log.Infof("Skipped %s: failed build", info.Pkgbase) + dbLock.Lock() + dbPkg = dbPkg.Update().SetStatus(FAILED).SetSkipReason("").SaveX(context.Background()) + dbLock.Unlock() + skipping = true + } + + if skipping { + b.repoPurge[pkg.FullRepo] <- pkg b.parseWG.Done() continue } - b.stats.eligible++ + repoVer := getVersionFromRepo(pkg) + dbLock.Lock() + dbPkg = dbPkg.Update().SetRepoVersion(repoVer).SaveX(context.Background()) + dbLock.Unlock() + if repoVer != "" && alpm.VerCmp(repoVer, pkgVer) > 0 { + log.Debugf("Skipped %s: Version in repo higher than in PKGBUILD (%s < %s)", info.Pkgbase, pkgVer, repoVer) + dbLock.Lock() + dbPkg = dbPkg.Update().SetStatus(LATEST).SetSkipReason("").SaveX(context.Background()) + dbLock.Unlock() + b.parseWG.Done() + continue + } + + dbLock.Lock() + dbPkg = dbPkg.Update().SetStatus(QUEUED).SaveX(context.Background()) + dbLock.Unlock() + b.parseWG.Done() b.build <- pkg } @@ -537,6 +608,113 @@ func isPkgFailed(pkg *BuildPackage) bool { return failed } +func statusId2string(status int) (string, string) { + switch status { + case SKIPPED: + return "SKIPPED", "table-secondary" + case QUEUED: + return "QUEUED", "table-warning" + case LATEST: + return "LATEST", "table-primary" + case FAILED: + return "FAILED", "table-danger" + case BUILD: + return "SIGNING", "table-success" + case BUILDING: + return "BUILDING", "table-info" + default: + return "UNKNOWN", "table-dark" + } +} + +func (b *BuildManager) htmlWorker() { + type Pkg struct { + Pkgbase string + Status string + Class string + Skip string + Version string + Svn2GitVersion string + BuildDate string + BuildDuration time.Duration + Checked string + } + + type Repo struct { + Name string + Packages []Pkg + } + + type March struct { + Name string + Repos []Repo + } + + type tpl struct { + March []March + } + + for { + gen := &tpl{} + + for _, march := range conf.March { + addMarch := March{ + Name: march, + } + + for _, repo := range conf.Repos { + addRepo := Repo{ + Name: repo, + } + + dbLock.RLock() + pkgs := db.DbPackage.Query().Where(dbpackage.MarchEQ(march), dbpackage.RepositoryEQ(repo)).AllX(context.Background()) + dbLock.RUnlock() + + for _, pkg := range pkgs { + status, class := statusId2string(pkg.Status) + + addPkg := Pkg{ + Pkgbase: pkg.Pkgbase, + Status: status, + Class: class, + Skip: pkg.SkipReason, + Version: pkg.RepoVersion, + Svn2GitVersion: pkg.Version, + } + + if pkg.BuildDuration > 0 { + duration, err := time.ParseDuration(strconv.Itoa(int(pkg.BuildDuration)) + "ms") + check(err) + addPkg.BuildDuration = duration + } + + if !pkg.BuildTime.IsZero() { + addPkg.BuildDate = pkg.BuildTime.Format(time.RFC3339) + } + + if !pkg.Updated.IsZero() { + addPkg.Checked = pkg.Updated.Format(time.RFC3339) + } + + addRepo.Packages = append(addRepo.Packages, addPkg) + } + addMarch.Repos = append(addMarch.Repos, addRepo) + } + gen.March = append(gen.March, addMarch) + } + + statusTpl, err := template.ParseFiles("tpl/status.html") + check(err) + + f, err := os.OpenFile(filepath.Join(conf.Basedir.Repo, "status.html"), os.O_WRONLY|os.O_CREATE|os.O_TRUNC, os.ModePerm) + check(statusTpl.Execute(f, gen)) + check(f.Close()) + + time.Sleep(time.Minute) + } +} + func setupChroot() { if _, err := os.Stat(filepath.Join(conf.Basedir.Chroot, orgChrootName)); err == nil { //goland:noinspection SpellCheckingInspection @@ -570,6 +748,11 @@ func (b *BuildManager) repoWorker(repo string) { log.Panicf("%s while repo-add: %v", string(res), err) } + dbPkg := getDbPackage(pkg) + dbLock.Lock() + dbPkg = dbPkg.Update().SetStatus(LATEST).SetSkipReason("").SetRepoVersion(getVersionFromRepo(pkg)).SaveX(context.Background()) + dbLock.Unlock() + cmd = exec.Command("paccache", "-rc", filepath.Join(conf.Basedir.Repo, pkg.FullRepo, "os", conf.Arch), "-k", "1") @@ -687,11 +870,6 @@ func (b *BuildManager) syncWorker() { } b.parseWG.Wait() - if b.stats.eligible != 0 { - log.Infof("Processed source-repos. %d packages elegible to be build, %d already fully build. Covering %f%% of offical-repo (buildable) packages.", b.stats.eligible, b.stats.fullyBuild, float32(b.stats.fullyBuild)/float32(b.stats.eligible)*100.0) - } - b.stats.fullyBuild = 0 - b.stats.eligible = 0 time.Sleep(5 * time.Minute) } } @@ -716,6 +894,18 @@ func main() { log.Warningf("Failed to drop priority: %v", err) } + db, err = ent.Open("sqlite3", "file:"+conf.Basedir.Db+"?_fk=1&cache=shared") + if err != nil { + log.Panicf("Failed to open database %s: %v", conf.Basedir.Db, err) + } + defer func(dbSQLite *ent.Client) { + check(dbSQLite.Close()) + }(db) + + if err := db.Schema.Create(context.Background()); err != nil { + log.Panicf("Automigrate failed: %v", err) + } + err = os.MkdirAll(conf.Basedir.Repo, os.ModePerm) check(err) @@ -731,6 +921,7 @@ func main() { syncMarchs() go buildManager.syncWorker() + go buildManager.htmlWorker() <-killSignals diff --git a/tpl/status.html b/tpl/status.html new file mode 100644 index 0000000..dd8feae --- /dev/null +++ b/tpl/status.html @@ -0,0 +1,72 @@ + + + + + + + + + + ALHP Status + + + +
+ {{range $march := .March}}

{{$march.Name}}

+
+ {{range $repo := $march.Repos}} +
+

+ +

+
+
+ + + + + + + + + + + + + + + {{range $pkg := $repo.Packages}} + + + + + + + + + + + {{end}} + +
PkgbaseStatusSkippedSVN2GIT VersionVersionBuild DateBuild DurationCheck date
{{$pkg.Pkgbase}}{{$pkg.Status}}{{$pkg.Skip}}{{$pkg.Svn2GitVersion}}{{$pkg.Version}}{{$pkg.BuildDate}}{{if $pkg.BuildDuration}}{{$pkg.BuildDuration}}{{end}}{{$pkg.Checked}}
+
+
+
+ {{end}} +
+ {{end}} +
+ + + + + \ No newline at end of file