added LTO status to db and status page

This commit is contained in:
2021-11-16 23:30:31 +01:00
parent e6ac0a1a6e
commit c77ec6d140
12 changed files with 320 additions and 7 deletions

View File

@@ -41,6 +41,8 @@ type DbPackage struct {
Updated time.Time `json:"updated,omitempty"`
// Hash holds the value of the "hash" field.
Hash string `json:"hash,omitempty"`
// Lto holds the value of the "lto" field.
Lto dbpackage.Lto `json:"lto,omitempty"`
}
// scanValues returns the types for scanning values from sql.Rows.
@@ -52,7 +54,7 @@ func (*DbPackage) scanValues(columns []string) ([]interface{}, error) {
values[i] = new([]byte)
case dbpackage.FieldID:
values[i] = new(sql.NullInt64)
case dbpackage.FieldPkgbase, dbpackage.FieldStatus, dbpackage.FieldSkipReason, dbpackage.FieldRepository, dbpackage.FieldMarch, dbpackage.FieldVersion, dbpackage.FieldRepoVersion, dbpackage.FieldHash:
case dbpackage.FieldPkgbase, dbpackage.FieldStatus, dbpackage.FieldSkipReason, dbpackage.FieldRepository, dbpackage.FieldMarch, dbpackage.FieldVersion, dbpackage.FieldRepoVersion, dbpackage.FieldHash, dbpackage.FieldLto:
values[i] = new(sql.NullString)
case dbpackage.FieldBuildTimeStart, dbpackage.FieldBuildTimeEnd, dbpackage.FieldUpdated:
values[i] = new(sql.NullTime)
@@ -151,6 +153,12 @@ func (dp *DbPackage) assignValues(columns []string, values []interface{}) error
} else if value.Valid {
dp.Hash = value.String
}
case dbpackage.FieldLto:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field lto", values[i])
} else if value.Valid {
dp.Lto = dbpackage.Lto(value.String)
}
}
}
return nil
@@ -203,6 +211,8 @@ func (dp *DbPackage) String() string {
builder.WriteString(dp.Updated.Format(time.ANSIC))
builder.WriteString(", hash=")
builder.WriteString(dp.Hash)
builder.WriteString(", lto=")
builder.WriteString(fmt.Sprintf("%v", dp.Lto))
builder.WriteByte(')')
return builder.String()
}

View File

@@ -35,6 +35,8 @@ const (
FieldUpdated = "updated"
// FieldHash holds the string denoting the hash field in the database.
FieldHash = "hash"
// FieldLto holds the string denoting the lto field in the database.
FieldLto = "lto"
// Table holds the table name of the dbpackage in the database.
Table = "db_packages"
)
@@ -54,6 +56,7 @@ var Columns = []string{
FieldBuildTimeEnd,
FieldUpdated,
FieldHash,
FieldLto,
}
// ValidColumn reports if the column name is valid (part of the table columns).
@@ -128,3 +131,30 @@ func RepositoryValidator(r Repository) error {
return fmt.Errorf("dbpackage: invalid enum value for repository field: %q", r)
}
}
// Lto defines the type for the "lto" enum field.
type Lto string
// LtoUnknown is the default value of the Lto enum.
const DefaultLto = LtoUnknown
// Lto values.
const (
LtoEnabled Lto = "enabled"
LtoUnknown Lto = "unknown"
LtoDisabled Lto = "disabled"
)
func (l Lto) String() string {
return string(l)
}
// LtoValidator is a validator for the "lto" field enum values. It is called by the builders before save.
func LtoValidator(l Lto) error {
switch l {
case LtoEnabled, LtoUnknown, LtoDisabled:
return nil
default:
return fmt.Errorf("dbpackage: invalid enum value for lto field: %q", l)
}
}

View File

@@ -1271,6 +1271,68 @@ func HashContainsFold(v string) predicate.DbPackage {
})
}
// LtoEQ applies the EQ predicate on the "lto" field.
func LtoEQ(v Lto) predicate.DbPackage {
return predicate.DbPackage(func(s *sql.Selector) {
s.Where(sql.EQ(s.C(FieldLto), v))
})
}
// LtoNEQ applies the NEQ predicate on the "lto" field.
func LtoNEQ(v Lto) predicate.DbPackage {
return predicate.DbPackage(func(s *sql.Selector) {
s.Where(sql.NEQ(s.C(FieldLto), v))
})
}
// LtoIn applies the In predicate on the "lto" field.
func LtoIn(vs ...Lto) 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(FieldLto), v...))
})
}
// LtoNotIn applies the NotIn predicate on the "lto" field.
func LtoNotIn(vs ...Lto) 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(FieldLto), v...))
})
}
// LtoIsNil applies the IsNil predicate on the "lto" field.
func LtoIsNil() predicate.DbPackage {
return predicate.DbPackage(func(s *sql.Selector) {
s.Where(sql.IsNull(s.C(FieldLto)))
})
}
// LtoNotNil applies the NotNil predicate on the "lto" field.
func LtoNotNil() predicate.DbPackage {
return predicate.DbPackage(func(s *sql.Selector) {
s.Where(sql.NotNull(s.C(FieldLto)))
})
}
// And groups predicates with the AND operator between them.
func And(predicates ...predicate.DbPackage) predicate.DbPackage {
return predicate.DbPackage(func(s *sql.Selector) {

View File

@@ -156,6 +156,20 @@ func (dpc *DbPackageCreate) SetNillableHash(s *string) *DbPackageCreate {
return dpc
}
// SetLto sets the "lto" field.
func (dpc *DbPackageCreate) SetLto(d dbpackage.Lto) *DbPackageCreate {
dpc.mutation.SetLto(d)
return dpc
}
// SetNillableLto sets the "lto" field if the given value is not nil.
func (dpc *DbPackageCreate) SetNillableLto(d *dbpackage.Lto) *DbPackageCreate {
if d != nil {
dpc.SetLto(*d)
}
return dpc
}
// Mutation returns the DbPackageMutation object of the builder.
func (dpc *DbPackageCreate) Mutation() *DbPackageMutation {
return dpc.mutation
@@ -231,6 +245,10 @@ func (dpc *DbPackageCreate) defaults() {
v := dbpackage.DefaultStatus
dpc.mutation.SetStatus(v)
}
if _, ok := dpc.mutation.Lto(); !ok {
v := dbpackage.DefaultLto
dpc.mutation.SetLto(v)
}
}
// check runs all checks and user-defined validators on the builder.
@@ -264,6 +282,11 @@ func (dpc *DbPackageCreate) check() error {
return &ValidationError{Name: "march", err: fmt.Errorf(`ent: validator failed for field "march": %w`, err)}
}
}
if v, ok := dpc.mutation.Lto(); ok {
if err := dbpackage.LtoValidator(v); err != nil {
return &ValidationError{Name: "lto", err: fmt.Errorf(`ent: validator failed for field "lto": %w`, err)}
}
}
return nil
}
@@ -387,6 +410,14 @@ func (dpc *DbPackageCreate) createSpec() (*DbPackage, *sqlgraph.CreateSpec) {
})
_node.Hash = value
}
if value, ok := dpc.mutation.Lto(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeEnum,
Value: value,
Column: dbpackage.FieldLto,
})
_node.Lto = value
}
return _node, _spec
}

View File

@@ -211,6 +211,26 @@ func (dpu *DbPackageUpdate) ClearHash() *DbPackageUpdate {
return dpu
}
// SetLto sets the "lto" field.
func (dpu *DbPackageUpdate) SetLto(d dbpackage.Lto) *DbPackageUpdate {
dpu.mutation.SetLto(d)
return dpu
}
// SetNillableLto sets the "lto" field if the given value is not nil.
func (dpu *DbPackageUpdate) SetNillableLto(d *dbpackage.Lto) *DbPackageUpdate {
if d != nil {
dpu.SetLto(*d)
}
return dpu
}
// ClearLto clears the value of the "lto" field.
func (dpu *DbPackageUpdate) ClearLto() *DbPackageUpdate {
dpu.mutation.ClearLto()
return dpu
}
// Mutation returns the DbPackageMutation object of the builder.
func (dpu *DbPackageUpdate) Mutation() *DbPackageMutation {
return dpu.mutation
@@ -293,6 +313,11 @@ func (dpu *DbPackageUpdate) check() error {
return &ValidationError{Name: "march", err: fmt.Errorf("ent: validator failed for field \"march\": %w", err)}
}
}
if v, ok := dpu.mutation.Lto(); ok {
if err := dbpackage.LtoValidator(v); err != nil {
return &ValidationError{Name: "lto", err: fmt.Errorf("ent: validator failed for field \"lto\": %w", err)}
}
}
return nil
}
@@ -445,6 +470,19 @@ func (dpu *DbPackageUpdate) sqlSave(ctx context.Context) (n int, err error) {
Column: dbpackage.FieldHash,
})
}
if value, ok := dpu.mutation.Lto(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeEnum,
Value: value,
Column: dbpackage.FieldLto,
})
}
if dpu.mutation.LtoCleared() {
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
Type: field.TypeEnum,
Column: dbpackage.FieldLto,
})
}
if n, err = sqlgraph.UpdateNodes(ctx, dpu.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{dbpackage.Label}
@@ -648,6 +686,26 @@ func (dpuo *DbPackageUpdateOne) ClearHash() *DbPackageUpdateOne {
return dpuo
}
// SetLto sets the "lto" field.
func (dpuo *DbPackageUpdateOne) SetLto(d dbpackage.Lto) *DbPackageUpdateOne {
dpuo.mutation.SetLto(d)
return dpuo
}
// SetNillableLto sets the "lto" field if the given value is not nil.
func (dpuo *DbPackageUpdateOne) SetNillableLto(d *dbpackage.Lto) *DbPackageUpdateOne {
if d != nil {
dpuo.SetLto(*d)
}
return dpuo
}
// ClearLto clears the value of the "lto" field.
func (dpuo *DbPackageUpdateOne) ClearLto() *DbPackageUpdateOne {
dpuo.mutation.ClearLto()
return dpuo
}
// Mutation returns the DbPackageMutation object of the builder.
func (dpuo *DbPackageUpdateOne) Mutation() *DbPackageMutation {
return dpuo.mutation
@@ -737,6 +795,11 @@ func (dpuo *DbPackageUpdateOne) check() error {
return &ValidationError{Name: "march", err: fmt.Errorf("ent: validator failed for field \"march\": %w", err)}
}
}
if v, ok := dpuo.mutation.Lto(); ok {
if err := dbpackage.LtoValidator(v); err != nil {
return &ValidationError{Name: "lto", err: fmt.Errorf("ent: validator failed for field \"lto\": %w", err)}
}
}
return nil
}
@@ -906,6 +969,19 @@ func (dpuo *DbPackageUpdateOne) sqlSave(ctx context.Context) (_node *DbPackage,
Column: dbpackage.FieldHash,
})
}
if value, ok := dpuo.mutation.Lto(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeEnum,
Value: value,
Column: dbpackage.FieldLto,
})
}
if dpuo.mutation.LtoCleared() {
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
Type: field.TypeEnum,
Column: dbpackage.FieldLto,
})
}
_node = &DbPackage{config: dpuo.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues

View File

@@ -23,6 +23,7 @@ var (
{Name: "build_time_end", Type: field.TypeTime, Nullable: true},
{Name: "updated", Type: field.TypeTime, Nullable: true},
{Name: "hash", Type: field.TypeString, Nullable: true},
{Name: "lto", Type: field.TypeEnum, Nullable: true, Enums: []string{"enabled", "unknown", "disabled"}, Default: "unknown"},
}
// DbPackagesTable holds the schema information for the "db_packages" table.
DbPackagesTable = &schema.Table{

View File

@@ -44,6 +44,7 @@ type DbPackageMutation struct {
build_time_end *time.Time
updated *time.Time
hash *string
lto *dbpackage.Lto
clearedFields map[string]struct{}
done bool
oldValue func(context.Context) (*DbPackage, error)
@@ -678,6 +679,55 @@ func (m *DbPackageMutation) ResetHash() {
delete(m.clearedFields, dbpackage.FieldHash)
}
// SetLto sets the "lto" field.
func (m *DbPackageMutation) SetLto(d dbpackage.Lto) {
m.lto = &d
}
// Lto returns the value of the "lto" field in the mutation.
func (m *DbPackageMutation) Lto() (r dbpackage.Lto, exists bool) {
v := m.lto
if v == nil {
return
}
return *v, true
}
// OldLto returns the old "lto" 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) OldLto(ctx context.Context) (v dbpackage.Lto, err error) {
if !m.op.Is(OpUpdateOne) {
return v, fmt.Errorf("OldLto is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, fmt.Errorf("OldLto requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldLto: %w", err)
}
return oldValue.Lto, nil
}
// ClearLto clears the value of the "lto" field.
func (m *DbPackageMutation) ClearLto() {
m.lto = nil
m.clearedFields[dbpackage.FieldLto] = struct{}{}
}
// LtoCleared returns if the "lto" field was cleared in this mutation.
func (m *DbPackageMutation) LtoCleared() bool {
_, ok := m.clearedFields[dbpackage.FieldLto]
return ok
}
// ResetLto resets all changes to the "lto" field.
func (m *DbPackageMutation) ResetLto() {
m.lto = nil
delete(m.clearedFields, dbpackage.FieldLto)
}
// Where appends a list predicates to the DbPackageMutation builder.
func (m *DbPackageMutation) Where(ps ...predicate.DbPackage) {
m.predicates = append(m.predicates, ps...)
@@ -697,7 +747,7 @@ func (m *DbPackageMutation) Type() string {
// order to get all numeric fields that were incremented/decremented, call
// AddedFields().
func (m *DbPackageMutation) Fields() []string {
fields := make([]string, 0, 12)
fields := make([]string, 0, 13)
if m.pkgbase != nil {
fields = append(fields, dbpackage.FieldPkgbase)
}
@@ -734,6 +784,9 @@ func (m *DbPackageMutation) Fields() []string {
if m.hash != nil {
fields = append(fields, dbpackage.FieldHash)
}
if m.lto != nil {
fields = append(fields, dbpackage.FieldLto)
}
return fields
}
@@ -766,6 +819,8 @@ func (m *DbPackageMutation) Field(name string) (ent.Value, bool) {
return m.Updated()
case dbpackage.FieldHash:
return m.Hash()
case dbpackage.FieldLto:
return m.Lto()
}
return nil, false
}
@@ -799,6 +854,8 @@ func (m *DbPackageMutation) OldField(ctx context.Context, name string) (ent.Valu
return m.OldUpdated(ctx)
case dbpackage.FieldHash:
return m.OldHash(ctx)
case dbpackage.FieldLto:
return m.OldLto(ctx)
}
return nil, fmt.Errorf("unknown DbPackage field %s", name)
}
@@ -892,6 +949,13 @@ func (m *DbPackageMutation) SetField(name string, value ent.Value) error {
}
m.SetHash(v)
return nil
case dbpackage.FieldLto:
v, ok := value.(dbpackage.Lto)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetLto(v)
return nil
}
return fmt.Errorf("unknown DbPackage field %s", name)
}
@@ -949,6 +1013,9 @@ func (m *DbPackageMutation) ClearedFields() []string {
if m.FieldCleared(dbpackage.FieldHash) {
fields = append(fields, dbpackage.FieldHash)
}
if m.FieldCleared(dbpackage.FieldLto) {
fields = append(fields, dbpackage.FieldLto)
}
return fields
}
@@ -990,6 +1057,9 @@ func (m *DbPackageMutation) ClearField(name string) error {
case dbpackage.FieldHash:
m.ClearHash()
return nil
case dbpackage.FieldLto:
m.ClearLto()
return nil
}
return fmt.Errorf("unknown DbPackage nullable field %s", name)
}
@@ -1034,6 +1104,9 @@ func (m *DbPackageMutation) ResetField(name string) error {
case dbpackage.FieldHash:
m.ResetHash()
return nil
case dbpackage.FieldLto:
m.ResetLto()
return nil
}
return fmt.Errorf("unknown DbPackage field %s", name)
}

View File

@@ -25,6 +25,7 @@ func (DbPackage) Fields() []ent.Field {
field.Time("build_time_end").Optional(),
field.Time("updated").Optional(),
field.String("hash").Optional(),
field.Enum("lto").Values("enabled", "unknown", "disabled").Default("unknown").Optional(),
}
}