mirror of
https://github.com/safedep/vet.git
synced 2025-12-10 13:43:01 -06:00
* Implemented code scan command for building sqlite storage with code analysis data Signed-off-by: Omkar Phansopkar <omkarphansopkar@gmail.com> * Added E2E test for code scan command Signed-off-by: Omkar Phansopkar <omkarphansopkar@gmail.com> * refactor: Migrate pkg/command to internal/command since we use pkg as a independent concern --------- Signed-off-by: Omkar Phansopkar <omkarphansopkar@gmail.com> Co-authored-by: abhisek <abhisek.datta@gmail.com>
130 lines
4.3 KiB
Go
130 lines
4.3 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package ent
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
|
|
"entgo.io/ent"
|
|
"entgo.io/ent/dialect/sql"
|
|
"github.com/safedep/vet/ent/codesourcefile"
|
|
)
|
|
|
|
// CodeSourceFile is the model entity for the CodeSourceFile schema.
|
|
type CodeSourceFile struct {
|
|
config `json:"-"`
|
|
// ID of the ent.
|
|
ID int `json:"id,omitempty"`
|
|
// Path holds the value of the "path" field.
|
|
Path string `json:"path,omitempty"`
|
|
// Edges holds the relations/edges for other nodes in the graph.
|
|
// The values are being populated by the CodeSourceFileQuery when eager-loading is set.
|
|
Edges CodeSourceFileEdges `json:"edges"`
|
|
selectValues sql.SelectValues
|
|
}
|
|
|
|
// CodeSourceFileEdges holds the relations/edges for other nodes in the graph.
|
|
type CodeSourceFileEdges struct {
|
|
// DepsUsageEvidences holds the value of the deps_usage_evidences edge.
|
|
DepsUsageEvidences []*DepsUsageEvidence `json:"deps_usage_evidences,omitempty"`
|
|
// loadedTypes holds the information for reporting if a
|
|
// type was loaded (or requested) in eager-loading or not.
|
|
loadedTypes [1]bool
|
|
}
|
|
|
|
// DepsUsageEvidencesOrErr returns the DepsUsageEvidences value or an error if the edge
|
|
// was not loaded in eager-loading.
|
|
func (e CodeSourceFileEdges) DepsUsageEvidencesOrErr() ([]*DepsUsageEvidence, error) {
|
|
if e.loadedTypes[0] {
|
|
return e.DepsUsageEvidences, nil
|
|
}
|
|
return nil, &NotLoadedError{edge: "deps_usage_evidences"}
|
|
}
|
|
|
|
// scanValues returns the types for scanning values from sql.Rows.
|
|
func (*CodeSourceFile) scanValues(columns []string) ([]any, error) {
|
|
values := make([]any, len(columns))
|
|
for i := range columns {
|
|
switch columns[i] {
|
|
case codesourcefile.FieldID:
|
|
values[i] = new(sql.NullInt64)
|
|
case codesourcefile.FieldPath:
|
|
values[i] = new(sql.NullString)
|
|
default:
|
|
values[i] = new(sql.UnknownType)
|
|
}
|
|
}
|
|
return values, nil
|
|
}
|
|
|
|
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
|
// to the CodeSourceFile fields.
|
|
func (csf *CodeSourceFile) assignValues(columns []string, values []any) 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 codesourcefile.FieldID:
|
|
value, ok := values[i].(*sql.NullInt64)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field id", value)
|
|
}
|
|
csf.ID = int(value.Int64)
|
|
case codesourcefile.FieldPath:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field path", values[i])
|
|
} else if value.Valid {
|
|
csf.Path = value.String
|
|
}
|
|
default:
|
|
csf.selectValues.Set(columns[i], values[i])
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Value returns the ent.Value that was dynamically selected and assigned to the CodeSourceFile.
|
|
// This includes values selected through modifiers, order, etc.
|
|
func (csf *CodeSourceFile) Value(name string) (ent.Value, error) {
|
|
return csf.selectValues.Get(name)
|
|
}
|
|
|
|
// QueryDepsUsageEvidences queries the "deps_usage_evidences" edge of the CodeSourceFile entity.
|
|
func (csf *CodeSourceFile) QueryDepsUsageEvidences() *DepsUsageEvidenceQuery {
|
|
return NewCodeSourceFileClient(csf.config).QueryDepsUsageEvidences(csf)
|
|
}
|
|
|
|
// Update returns a builder for updating this CodeSourceFile.
|
|
// Note that you need to call CodeSourceFile.Unwrap() before calling this method if this CodeSourceFile
|
|
// was returned from a transaction, and the transaction was committed or rolled back.
|
|
func (csf *CodeSourceFile) Update() *CodeSourceFileUpdateOne {
|
|
return NewCodeSourceFileClient(csf.config).UpdateOne(csf)
|
|
}
|
|
|
|
// Unwrap unwraps the CodeSourceFile 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 (csf *CodeSourceFile) Unwrap() *CodeSourceFile {
|
|
_tx, ok := csf.config.driver.(*txDriver)
|
|
if !ok {
|
|
panic("ent: CodeSourceFile is not a transactional entity")
|
|
}
|
|
csf.config.driver = _tx.drv
|
|
return csf
|
|
}
|
|
|
|
// String implements the fmt.Stringer.
|
|
func (csf *CodeSourceFile) String() string {
|
|
var builder strings.Builder
|
|
builder.WriteString("CodeSourceFile(")
|
|
builder.WriteString(fmt.Sprintf("id=%v, ", csf.ID))
|
|
builder.WriteString("path=")
|
|
builder.WriteString(csf.Path)
|
|
builder.WriteByte(')')
|
|
return builder.String()
|
|
}
|
|
|
|
// CodeSourceFiles is a parsable slice of CodeSourceFile.
|
|
type CodeSourceFiles []*CodeSourceFile
|