1
0
forked from ALHP/ALHP.GO

added debuginfod support

This commit is contained in:
2022-02-13 22:33:57 +01:00
parent 45672e3459
commit c7ba7340a5
13 changed files with 372 additions and 22 deletions

View File

@@ -47,6 +47,8 @@ type DbPackage struct {
LastVersionBuild string `json:"last_version_build,omitempty"`
// LastVerified holds the value of the "last_verified" field.
LastVerified time.Time `json:"last_verified,omitempty"`
// DebugSymbols holds the value of the "debug_symbols" field.
DebugSymbols dbpackage.DebugSymbols `json:"debug_symbols,omitempty"`
}
// scanValues returns the types for scanning values from sql.Rows.
@@ -58,7 +60,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, dbpackage.FieldLto, dbpackage.FieldLastVersionBuild:
case dbpackage.FieldPkgbase, dbpackage.FieldStatus, dbpackage.FieldSkipReason, dbpackage.FieldRepository, dbpackage.FieldMarch, dbpackage.FieldVersion, dbpackage.FieldRepoVersion, dbpackage.FieldHash, dbpackage.FieldLto, dbpackage.FieldLastVersionBuild, dbpackage.FieldDebugSymbols:
values[i] = new(sql.NullString)
case dbpackage.FieldBuildTimeStart, dbpackage.FieldBuildTimeEnd, dbpackage.FieldUpdated, dbpackage.FieldLastVerified:
values[i] = new(sql.NullTime)
@@ -175,6 +177,12 @@ func (dp *DbPackage) assignValues(columns []string, values []interface{}) error
} else if value.Valid {
dp.LastVerified = value.Time
}
case dbpackage.FieldDebugSymbols:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field debug_symbols", values[i])
} else if value.Valid {
dp.DebugSymbols = dbpackage.DebugSymbols(value.String)
}
}
}
return nil
@@ -233,6 +241,8 @@ func (dp *DbPackage) String() string {
builder.WriteString(dp.LastVersionBuild)
builder.WriteString(", last_verified=")
builder.WriteString(dp.LastVerified.Format(time.ANSIC))
builder.WriteString(", debug_symbols=")
builder.WriteString(fmt.Sprintf("%v", dp.DebugSymbols))
builder.WriteByte(')')
return builder.String()
}

View File

@@ -41,6 +41,8 @@ const (
FieldLastVersionBuild = "last_version_build"
// FieldLastVerified holds the string denoting the last_verified field in the database.
FieldLastVerified = "last_verified"
// FieldDebugSymbols holds the string denoting the debug_symbols field in the database.
FieldDebugSymbols = "debug_symbols"
// Table holds the table name of the dbpackage in the database.
Table = "db_packages"
)
@@ -63,6 +65,7 @@ var Columns = []string{
FieldLto,
FieldLastVersionBuild,
FieldLastVerified,
FieldDebugSymbols,
}
// ValidColumn reports if the column name is valid (part of the table columns).
@@ -165,3 +168,30 @@ func LtoValidator(l Lto) error {
return fmt.Errorf("dbpackage: invalid enum value for lto field: %q", l)
}
}
// DebugSymbols defines the type for the "debug_symbols" enum field.
type DebugSymbols string
// DebugSymbolsUnknown is the default value of the DebugSymbols enum.
const DefaultDebugSymbols = DebugSymbolsUnknown
// DebugSymbols values.
const (
DebugSymbolsAvailable DebugSymbols = "available"
DebugSymbolsUnknown DebugSymbols = "unknown"
DebugSymbolsNotAvailable DebugSymbols = "not_available"
)
func (ds DebugSymbols) String() string {
return string(ds)
}
// DebugSymbolsValidator is a validator for the "debug_symbols" field enum values. It is called by the builders before save.
func DebugSymbolsValidator(ds DebugSymbols) error {
switch ds {
case DebugSymbolsAvailable, DebugSymbolsUnknown, DebugSymbolsNotAvailable:
return nil
default:
return fmt.Errorf("dbpackage: invalid enum value for debug_symbols field: %q", ds)
}
}

View File

@@ -1562,6 +1562,68 @@ func LastVerifiedNotNil() predicate.DbPackage {
})
}
// DebugSymbolsEQ applies the EQ predicate on the "debug_symbols" field.
func DebugSymbolsEQ(v DebugSymbols) predicate.DbPackage {
return predicate.DbPackage(func(s *sql.Selector) {
s.Where(sql.EQ(s.C(FieldDebugSymbols), v))
})
}
// DebugSymbolsNEQ applies the NEQ predicate on the "debug_symbols" field.
func DebugSymbolsNEQ(v DebugSymbols) predicate.DbPackage {
return predicate.DbPackage(func(s *sql.Selector) {
s.Where(sql.NEQ(s.C(FieldDebugSymbols), v))
})
}
// DebugSymbolsIn applies the In predicate on the "debug_symbols" field.
func DebugSymbolsIn(vs ...DebugSymbols) 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(FieldDebugSymbols), v...))
})
}
// DebugSymbolsNotIn applies the NotIn predicate on the "debug_symbols" field.
func DebugSymbolsNotIn(vs ...DebugSymbols) 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(FieldDebugSymbols), v...))
})
}
// DebugSymbolsIsNil applies the IsNil predicate on the "debug_symbols" field.
func DebugSymbolsIsNil() predicate.DbPackage {
return predicate.DbPackage(func(s *sql.Selector) {
s.Where(sql.IsNull(s.C(FieldDebugSymbols)))
})
}
// DebugSymbolsNotNil applies the NotNil predicate on the "debug_symbols" field.
func DebugSymbolsNotNil() predicate.DbPackage {
return predicate.DbPackage(func(s *sql.Selector) {
s.Where(sql.NotNull(s.C(FieldDebugSymbols)))
})
}
// 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

@@ -198,6 +198,20 @@ func (dpc *DbPackageCreate) SetNillableLastVerified(t *time.Time) *DbPackageCrea
return dpc
}
// SetDebugSymbols sets the "debug_symbols" field.
func (dpc *DbPackageCreate) SetDebugSymbols(ds dbpackage.DebugSymbols) *DbPackageCreate {
dpc.mutation.SetDebugSymbols(ds)
return dpc
}
// SetNillableDebugSymbols sets the "debug_symbols" field if the given value is not nil.
func (dpc *DbPackageCreate) SetNillableDebugSymbols(ds *dbpackage.DebugSymbols) *DbPackageCreate {
if ds != nil {
dpc.SetDebugSymbols(*ds)
}
return dpc
}
// Mutation returns the DbPackageMutation object of the builder.
func (dpc *DbPackageCreate) Mutation() *DbPackageMutation {
return dpc.mutation
@@ -277,6 +291,10 @@ func (dpc *DbPackageCreate) defaults() {
v := dbpackage.DefaultLto
dpc.mutation.SetLto(v)
}
if _, ok := dpc.mutation.DebugSymbols(); !ok {
v := dbpackage.DefaultDebugSymbols
dpc.mutation.SetDebugSymbols(v)
}
}
// check runs all checks and user-defined validators on the builder.
@@ -315,6 +333,11 @@ func (dpc *DbPackageCreate) check() error {
return &ValidationError{Name: "lto", err: fmt.Errorf(`ent: validator failed for field "DbPackage.lto": %w`, err)}
}
}
if v, ok := dpc.mutation.DebugSymbols(); ok {
if err := dbpackage.DebugSymbolsValidator(v); err != nil {
return &ValidationError{Name: "debug_symbols", err: fmt.Errorf(`ent: validator failed for field "DbPackage.debug_symbols": %w`, err)}
}
}
return nil
}
@@ -462,6 +485,14 @@ func (dpc *DbPackageCreate) createSpec() (*DbPackage, *sqlgraph.CreateSpec) {
})
_node.LastVerified = value
}
if value, ok := dpc.mutation.DebugSymbols(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeEnum,
Value: value,
Column: dbpackage.FieldDebugSymbols,
})
_node.DebugSymbols = value
}
return _node, _spec
}

View File

@@ -266,6 +266,26 @@ func (dpu *DbPackageUpdate) ClearLastVerified() *DbPackageUpdate {
return dpu
}
// SetDebugSymbols sets the "debug_symbols" field.
func (dpu *DbPackageUpdate) SetDebugSymbols(ds dbpackage.DebugSymbols) *DbPackageUpdate {
dpu.mutation.SetDebugSymbols(ds)
return dpu
}
// SetNillableDebugSymbols sets the "debug_symbols" field if the given value is not nil.
func (dpu *DbPackageUpdate) SetNillableDebugSymbols(ds *dbpackage.DebugSymbols) *DbPackageUpdate {
if ds != nil {
dpu.SetDebugSymbols(*ds)
}
return dpu
}
// ClearDebugSymbols clears the value of the "debug_symbols" field.
func (dpu *DbPackageUpdate) ClearDebugSymbols() *DbPackageUpdate {
dpu.mutation.ClearDebugSymbols()
return dpu
}
// Mutation returns the DbPackageMutation object of the builder.
func (dpu *DbPackageUpdate) Mutation() *DbPackageMutation {
return dpu.mutation
@@ -348,6 +368,11 @@ func (dpu *DbPackageUpdate) check() error {
return &ValidationError{Name: "lto", err: fmt.Errorf(`ent: validator failed for field "DbPackage.lto": %w`, err)}
}
}
if v, ok := dpu.mutation.DebugSymbols(); ok {
if err := dbpackage.DebugSymbolsValidator(v); err != nil {
return &ValidationError{Name: "debug_symbols", err: fmt.Errorf(`ent: validator failed for field "DbPackage.debug_symbols": %w`, err)}
}
}
return nil
}
@@ -532,6 +557,19 @@ func (dpu *DbPackageUpdate) sqlSave(ctx context.Context) (n int, err error) {
Column: dbpackage.FieldLastVerified,
})
}
if value, ok := dpu.mutation.DebugSymbols(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeEnum,
Value: value,
Column: dbpackage.FieldDebugSymbols,
})
}
if dpu.mutation.DebugSymbolsCleared() {
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
Type: field.TypeEnum,
Column: dbpackage.FieldDebugSymbols,
})
}
if n, err = sqlgraph.UpdateNodes(ctx, dpu.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{dbpackage.Label}
@@ -789,6 +827,26 @@ func (dpuo *DbPackageUpdateOne) ClearLastVerified() *DbPackageUpdateOne {
return dpuo
}
// SetDebugSymbols sets the "debug_symbols" field.
func (dpuo *DbPackageUpdateOne) SetDebugSymbols(ds dbpackage.DebugSymbols) *DbPackageUpdateOne {
dpuo.mutation.SetDebugSymbols(ds)
return dpuo
}
// SetNillableDebugSymbols sets the "debug_symbols" field if the given value is not nil.
func (dpuo *DbPackageUpdateOne) SetNillableDebugSymbols(ds *dbpackage.DebugSymbols) *DbPackageUpdateOne {
if ds != nil {
dpuo.SetDebugSymbols(*ds)
}
return dpuo
}
// ClearDebugSymbols clears the value of the "debug_symbols" field.
func (dpuo *DbPackageUpdateOne) ClearDebugSymbols() *DbPackageUpdateOne {
dpuo.mutation.ClearDebugSymbols()
return dpuo
}
// Mutation returns the DbPackageMutation object of the builder.
func (dpuo *DbPackageUpdateOne) Mutation() *DbPackageMutation {
return dpuo.mutation
@@ -878,6 +936,11 @@ func (dpuo *DbPackageUpdateOne) check() error {
return &ValidationError{Name: "lto", err: fmt.Errorf(`ent: validator failed for field "DbPackage.lto": %w`, err)}
}
}
if v, ok := dpuo.mutation.DebugSymbols(); ok {
if err := dbpackage.DebugSymbolsValidator(v); err != nil {
return &ValidationError{Name: "debug_symbols", err: fmt.Errorf(`ent: validator failed for field "DbPackage.debug_symbols": %w`, err)}
}
}
return nil
}
@@ -1079,6 +1142,19 @@ func (dpuo *DbPackageUpdateOne) sqlSave(ctx context.Context) (_node *DbPackage,
Column: dbpackage.FieldLastVerified,
})
}
if value, ok := dpuo.mutation.DebugSymbols(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeEnum,
Value: value,
Column: dbpackage.FieldDebugSymbols,
})
}
if dpuo.mutation.DebugSymbolsCleared() {
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
Type: field.TypeEnum,
Column: dbpackage.FieldDebugSymbols,
})
}
_node = &DbPackage{config: dpuo.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues

View File

@@ -26,6 +26,7 @@ var (
{Name: "lto", Type: field.TypeEnum, Nullable: true, Enums: []string{"enabled", "unknown", "disabled", "auto_disabled"}, Default: "unknown"},
{Name: "last_version_build", Type: field.TypeString, Nullable: true},
{Name: "last_verified", Type: field.TypeTime, Nullable: true},
{Name: "debug_symbols", Type: field.TypeEnum, Nullable: true, Enums: []string{"available", "unknown", "not_available"}, Default: "unknown"},
}
// DbPackagesTable holds the schema information for the "db_packages" table.
DbPackagesTable = &schema.Table{

View File

@@ -48,6 +48,7 @@ type DbPackageMutation struct {
lto *dbpackage.Lto
last_version_build *string
last_verified *time.Time
debug_symbols *dbpackage.DebugSymbols
clearedFields map[string]struct{}
done bool
oldValue func(context.Context) (*DbPackage, error)
@@ -848,6 +849,55 @@ func (m *DbPackageMutation) ResetLastVerified() {
delete(m.clearedFields, dbpackage.FieldLastVerified)
}
// SetDebugSymbols sets the "debug_symbols" field.
func (m *DbPackageMutation) SetDebugSymbols(ds dbpackage.DebugSymbols) {
m.debug_symbols = &ds
}
// DebugSymbols returns the value of the "debug_symbols" field in the mutation.
func (m *DbPackageMutation) DebugSymbols() (r dbpackage.DebugSymbols, exists bool) {
v := m.debug_symbols
if v == nil {
return
}
return *v, true
}
// OldDebugSymbols returns the old "debug_symbols" 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) OldDebugSymbols(ctx context.Context) (v dbpackage.DebugSymbols, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldDebugSymbols is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldDebugSymbols requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldDebugSymbols: %w", err)
}
return oldValue.DebugSymbols, nil
}
// ClearDebugSymbols clears the value of the "debug_symbols" field.
func (m *DbPackageMutation) ClearDebugSymbols() {
m.debug_symbols = nil
m.clearedFields[dbpackage.FieldDebugSymbols] = struct{}{}
}
// DebugSymbolsCleared returns if the "debug_symbols" field was cleared in this mutation.
func (m *DbPackageMutation) DebugSymbolsCleared() bool {
_, ok := m.clearedFields[dbpackage.FieldDebugSymbols]
return ok
}
// ResetDebugSymbols resets all changes to the "debug_symbols" field.
func (m *DbPackageMutation) ResetDebugSymbols() {
m.debug_symbols = nil
delete(m.clearedFields, dbpackage.FieldDebugSymbols)
}
// Where appends a list predicates to the DbPackageMutation builder.
func (m *DbPackageMutation) Where(ps ...predicate.DbPackage) {
m.predicates = append(m.predicates, ps...)
@@ -867,7 +917,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, 15)
fields := make([]string, 0, 16)
if m.pkgbase != nil {
fields = append(fields, dbpackage.FieldPkgbase)
}
@@ -913,6 +963,9 @@ func (m *DbPackageMutation) Fields() []string {
if m.last_verified != nil {
fields = append(fields, dbpackage.FieldLastVerified)
}
if m.debug_symbols != nil {
fields = append(fields, dbpackage.FieldDebugSymbols)
}
return fields
}
@@ -951,6 +1004,8 @@ func (m *DbPackageMutation) Field(name string) (ent.Value, bool) {
return m.LastVersionBuild()
case dbpackage.FieldLastVerified:
return m.LastVerified()
case dbpackage.FieldDebugSymbols:
return m.DebugSymbols()
}
return nil, false
}
@@ -990,6 +1045,8 @@ func (m *DbPackageMutation) OldField(ctx context.Context, name string) (ent.Valu
return m.OldLastVersionBuild(ctx)
case dbpackage.FieldLastVerified:
return m.OldLastVerified(ctx)
case dbpackage.FieldDebugSymbols:
return m.OldDebugSymbols(ctx)
}
return nil, fmt.Errorf("unknown DbPackage field %s", name)
}
@@ -1104,6 +1161,13 @@ func (m *DbPackageMutation) SetField(name string, value ent.Value) error {
}
m.SetLastVerified(v)
return nil
case dbpackage.FieldDebugSymbols:
v, ok := value.(dbpackage.DebugSymbols)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetDebugSymbols(v)
return nil
}
return fmt.Errorf("unknown DbPackage field %s", name)
}
@@ -1170,6 +1234,9 @@ func (m *DbPackageMutation) ClearedFields() []string {
if m.FieldCleared(dbpackage.FieldLastVerified) {
fields = append(fields, dbpackage.FieldLastVerified)
}
if m.FieldCleared(dbpackage.FieldDebugSymbols) {
fields = append(fields, dbpackage.FieldDebugSymbols)
}
return fields
}
@@ -1220,6 +1287,9 @@ func (m *DbPackageMutation) ClearField(name string) error {
case dbpackage.FieldLastVerified:
m.ClearLastVerified()
return nil
case dbpackage.FieldDebugSymbols:
m.ClearDebugSymbols()
return nil
}
return fmt.Errorf("unknown DbPackage nullable field %s", name)
}
@@ -1273,6 +1343,9 @@ func (m *DbPackageMutation) ResetField(name string) error {
case dbpackage.FieldLastVerified:
m.ResetLastVerified()
return nil
case dbpackage.FieldDebugSymbols:
m.ResetDebugSymbols()
return nil
}
return fmt.Errorf("unknown DbPackage field %s", name)
}

View File

@@ -28,6 +28,7 @@ func (DbPackage) Fields() []ent.Field {
field.Enum("lto").Values("enabled", "unknown", "disabled", "auto_disabled").Default("unknown").Optional(),
field.String("last_version_build").Optional(),
field.Time("last_verified").Optional(),
field.Enum("debug_symbols").Values("available", "unknown", "not_available").Default("unknown").Optional(),
}
}