diff --git a/.gitignore b/.gitignore index 2ef16a64..513228d7 100644 --- a/.gitignore +++ b/.gitignore @@ -24,3 +24,4 @@ ./archivista ./archivistctl .witness.yaml +.aider* diff --git a/compose-dev.yml b/compose-dev.yml index 69799acc..31041d04 100644 --- a/compose-dev.yml +++ b/compose-dev.yml @@ -26,33 +26,33 @@ services: volumes: - mysqldata:/var/lib/mysql - archivista: - build: - context: . - dockerfile: ./Dockerfile-dev - restart: unless-stopped - environment: - ARCHIVISTA_LISTEN_ON: tcp://0.0.0.0:8082 - ARCHIVISTA_ENABLE_SPIFFE: "false" - ARCHIVISTA_STORAGE_BACKEND: BLOB - ARCHIVISTA_FILE_DIR: /tmp/archivista/ - ARCHIVISTA_FILE_SERVE_ON: :8081 - ARCHIVISTA_BLOB_STORE_USE_TLS: "false" - ARCHIVISTA_BLOB_STORE_CREDENTIAL_TYPE: ACCESS_KEY - ARCHIVISTA_BLOB_STORE_ACCESS_KEY_ID: testifytestifytestify - ARCHIVISTA_BLOB_STORE_SECRET_ACCESS_KEY_ID: exampleexampleexample - ARCHIVISTA_BLOB_STORE_BUCKET_NAME: attestations - ARCHIVISTA_BLOB_STORE_ENDPOINT: minio:9000 - ARCHIVISTA_ENABLE_GRAPHQL: "true" - ARCHIVISTA_GRAPHQL_WEB_CLIENT_ENABLE: "true" - ARCHIVISTA_CORS_ALLOW_ORIGINS: "http://localhost:1234" - - ports: - - 8081:8081 - - 8082:8082 - volumes: - - fileserver:/tmp/archivista - - ./:/src +# archivista: +# build: +# context: . +# dockerfile: ./Dockerfile-dev +# restart: unless-stopped +# environment: +# ARCHIVISTA_LISTEN_ON: tcp://0.0.0.0:8082 +# ARCHIVISTA_ENABLE_SPIFFE: "false" +# ARCHIVISTA_STORAGE_BACKEND: BLOB +# ARCHIVISTA_FILE_DIR: /tmp/archivista/ +# ARCHIVISTA_FILE_SERVE_ON: :8081 +# ARCHIVISTA_BLOB_STORE_USE_TLS: "false" +# ARCHIVISTA_BLOB_STORE_CREDENTIAL_TYPE: ACCESS_KEY +# ARCHIVISTA_BLOB_STORE_ACCESS_KEY_ID: testifytestifytestify +# ARCHIVISTA_BLOB_STORE_SECRET_ACCESS_KEY_ID: exampleexampleexample +# ARCHIVISTA_BLOB_STORE_BUCKET_NAME: attestations +# ARCHIVISTA_BLOB_STORE_ENDPOINT: minio:9000 +# ARCHIVISTA_ENABLE_GRAPHQL: "true" +# ARCHIVISTA_GRAPHQL_WEB_CLIENT_ENABLE: "true" +# ARCHIVISTA_CORS_ALLOW_ORIGINS: "http://localhost:1234" +# +# ports: +# - 8081:8081 +# - 8082:8082 +# volumes: +# - fileserver:/tmp/archivista +# - ./:/src minio: image: quay.io/minio/minio diff --git a/ent.graphql b/ent.graphql index bc06dfc8..8bb8b3cc 100644 --- a/ent.graphql +++ b/ent.graphql @@ -1,8 +1,9 @@ -directive @goField(forceResolver: Boolean, name: String) on FIELD_DEFINITION | INPUT_FIELD_DEFINITION -directive @goModel(model: String, models: [String!]) on OBJECT | INPUT_OBJECT | SCALAR | ENUM | INTERFACE | UNION +directive @goField(forceResolver: Boolean, name: String, omittable: Boolean) on FIELD_DEFINITION | INPUT_FIELD_DEFINITION +directive @goModel(model: String, models: [String!], forceGenerate: Boolean) on OBJECT | INPUT_OBJECT | SCALAR | ENUM | INTERFACE | UNION type Attestation implements Node { id: ID! type: String! + omnitrail: Omnitrail attestationCollection: AttestationCollection! } type AttestationCollection implements Node { @@ -169,6 +170,11 @@ input AttestationWhereInput { typeEqualFold: String typeContainsFold: String """ + omnitrail edge predicates + """ + hasOmnitrail: Boolean + hasOmnitrailWith: [OmnitrailWhereInput!] + """ attestation_collection edge predicates """ hasAttestationCollection: Boolean @@ -284,6 +290,143 @@ input DsseWhereInput { hasPayloadDigests: Boolean hasPayloadDigestsWith: [PayloadDigestWhereInput!] } +type Mapping implements Node { + id: ID! + path: String! + type: String! + sha1: String! + sha256: String! + gitoidsha1: String! @goField(name: "GitoidSha1", forceResolver: false) + gitoidsha256: String! @goField(name: "GitoidSha256", forceResolver: false) + posix: [Posix!] + omnitrail: Omnitrail! +} +""" +MappingWhereInput is used for filtering Mapping objects. +Input was generated by ent. +""" +input MappingWhereInput { + not: MappingWhereInput + and: [MappingWhereInput!] + or: [MappingWhereInput!] + """ + id field predicates + """ + id: ID + idNEQ: ID + idIn: [ID!] + idNotIn: [ID!] + idGT: ID + idGTE: ID + idLT: ID + idLTE: ID + """ + path field predicates + """ + path: String + pathNEQ: String + pathIn: [String!] + pathNotIn: [String!] + pathGT: String + pathGTE: String + pathLT: String + pathLTE: String + pathContains: String + pathHasPrefix: String + pathHasSuffix: String + pathEqualFold: String + pathContainsFold: String + """ + type field predicates + """ + type: String + typeNEQ: String + typeIn: [String!] + typeNotIn: [String!] + typeGT: String + typeGTE: String + typeLT: String + typeLTE: String + typeContains: String + typeHasPrefix: String + typeHasSuffix: String + typeEqualFold: String + typeContainsFold: String + """ + sha1 field predicates + """ + sha1: String + sha1NEQ: String + sha1In: [String!] + sha1NotIn: [String!] + sha1GT: String + sha1GTE: String + sha1LT: String + sha1LTE: String + sha1Contains: String + sha1HasPrefix: String + sha1HasSuffix: String + sha1EqualFold: String + sha1ContainsFold: String + """ + sha256 field predicates + """ + sha256: String + sha256NEQ: String + sha256In: [String!] + sha256NotIn: [String!] + sha256GT: String + sha256GTE: String + sha256LT: String + sha256LTE: String + sha256Contains: String + sha256HasPrefix: String + sha256HasSuffix: String + sha256EqualFold: String + sha256ContainsFold: String + """ + gitoidSha1 field predicates + """ + gitoidsha1: String + gitoidsha1NEQ: String + gitoidsha1In: [String!] + gitoidsha1NotIn: [String!] + gitoidsha1GT: String + gitoidsha1GTE: String + gitoidsha1LT: String + gitoidsha1LTE: String + gitoidsha1Contains: String + gitoidsha1HasPrefix: String + gitoidsha1HasSuffix: String + gitoidsha1EqualFold: String + gitoidsha1ContainsFold: String + """ + gitoidSha256 field predicates + """ + gitoidsha256: String + gitoidsha256NEQ: String + gitoidsha256In: [String!] + gitoidsha256NotIn: [String!] + gitoidsha256GT: String + gitoidsha256GTE: String + gitoidsha256LT: String + gitoidsha256LTE: String + gitoidsha256Contains: String + gitoidsha256HasPrefix: String + gitoidsha256HasSuffix: String + gitoidsha256EqualFold: String + gitoidsha256ContainsFold: String + """ + posix edge predicates + """ + hasPosix: Boolean + hasPosixWith: [PosixWhereInput!] + """ + omnitrail edge predicates + """ + hasOmnitrail: Boolean + hasOmnitrailWith: [OmnitrailWhereInput!] +} """ An object with an ID. Follows the [Relay Global Object Identification Specification](https://relay.dev/graphql/objectidentification.htm) @@ -294,6 +437,41 @@ interface Node @goModel(model: "github.com/in-toto/archivista/ent.Noder") { """ id: ID! } +type Omnitrail implements Node { + id: ID! + mappings: [Mapping!] + attestation: Attestation! +} +""" +OmnitrailWhereInput is used for filtering Omnitrail objects. +Input was generated by ent. +""" +input OmnitrailWhereInput { + not: OmnitrailWhereInput + and: [OmnitrailWhereInput!] + or: [OmnitrailWhereInput!] + """ + id field predicates + """ + id: ID + idNEQ: ID + idIn: [ID!] + idNotIn: [ID!] + idGT: ID + idGTE: ID + idLT: ID + idLTE: ID + """ + mappings edge predicates + """ + hasMappings: Boolean + hasMappingsWith: [MappingWhereInput!] + """ + attestation edge predicates + """ + hasAttestation: Boolean + hasAttestationWith: [AttestationWhereInput!] +} """ Possible directions in which to order a list of items when provided an `orderBy` argument. """ @@ -392,6 +570,307 @@ input PayloadDigestWhereInput { hasDsse: Boolean hasDsseWith: [DsseWhereInput!] } +type Posix implements Node { + id: ID! + atime: String! + ctime: String! + creationTime: String! + extendedAttributes: String! + fileDeviceID: String! + fileFlags: String! + fileInode: String! + fileSystemID: String! + fileType: String! + hardLinkCount: String! + mtime: String! + metadataCtime: String! + ownerGid: String! + ownerUID: String! + permissions: String! + size: String! + mapping: Mapping! +} +""" +PosixWhereInput is used for filtering Posix objects. +Input was generated by ent. +""" +input PosixWhereInput { + not: PosixWhereInput + and: [PosixWhereInput!] + or: [PosixWhereInput!] + """ + id field predicates + """ + id: ID + idNEQ: ID + idIn: [ID!] + idNotIn: [ID!] + idGT: ID + idGTE: ID + idLT: ID + idLTE: ID + """ + atime field predicates + """ + atime: String + atimeNEQ: String + atimeIn: [String!] + atimeNotIn: [String!] + atimeGT: String + atimeGTE: String + atimeLT: String + atimeLTE: String + atimeContains: String + atimeHasPrefix: String + atimeHasSuffix: String + atimeEqualFold: String + atimeContainsFold: String + """ + ctime field predicates + """ + ctime: String + ctimeNEQ: String + ctimeIn: [String!] + ctimeNotIn: [String!] + ctimeGT: String + ctimeGTE: String + ctimeLT: String + ctimeLTE: String + ctimeContains: String + ctimeHasPrefix: String + ctimeHasSuffix: String + ctimeEqualFold: String + ctimeContainsFold: String + """ + creation_time field predicates + """ + creationTime: String + creationTimeNEQ: String + creationTimeIn: [String!] + creationTimeNotIn: [String!] + creationTimeGT: String + creationTimeGTE: String + creationTimeLT: String + creationTimeLTE: String + creationTimeContains: String + creationTimeHasPrefix: String + creationTimeHasSuffix: String + creationTimeEqualFold: String + creationTimeContainsFold: String + """ + extended_attributes field predicates + """ + extendedAttributes: String + extendedAttributesNEQ: String + extendedAttributesIn: [String!] + extendedAttributesNotIn: [String!] + extendedAttributesGT: String + extendedAttributesGTE: String + extendedAttributesLT: String + extendedAttributesLTE: String + extendedAttributesContains: String + extendedAttributesHasPrefix: String + extendedAttributesHasSuffix: String + extendedAttributesEqualFold: String + extendedAttributesContainsFold: String + """ + file_device_id field predicates + """ + fileDeviceID: String + fileDeviceIDNEQ: String + fileDeviceIDIn: [String!] + fileDeviceIDNotIn: [String!] + fileDeviceIDGT: String + fileDeviceIDGTE: String + fileDeviceIDLT: String + fileDeviceIDLTE: String + fileDeviceIDContains: String + fileDeviceIDHasPrefix: String + fileDeviceIDHasSuffix: String + fileDeviceIDEqualFold: String + fileDeviceIDContainsFold: String + """ + file_flags field predicates + """ + fileFlags: String + fileFlagsNEQ: String + fileFlagsIn: [String!] + fileFlagsNotIn: [String!] + fileFlagsGT: String + fileFlagsGTE: String + fileFlagsLT: String + fileFlagsLTE: String + fileFlagsContains: String + fileFlagsHasPrefix: String + fileFlagsHasSuffix: String + fileFlagsEqualFold: String + fileFlagsContainsFold: String + """ + file_inode field predicates + """ + fileInode: String + fileInodeNEQ: String + fileInodeIn: [String!] + fileInodeNotIn: [String!] + fileInodeGT: String + fileInodeGTE: String + fileInodeLT: String + fileInodeLTE: String + fileInodeContains: String + fileInodeHasPrefix: String + fileInodeHasSuffix: String + fileInodeEqualFold: String + fileInodeContainsFold: String + """ + file_system_id field predicates + """ + fileSystemID: String + fileSystemIDNEQ: String + fileSystemIDIn: [String!] + fileSystemIDNotIn: [String!] + fileSystemIDGT: String + fileSystemIDGTE: String + fileSystemIDLT: String + fileSystemIDLTE: String + fileSystemIDContains: String + fileSystemIDHasPrefix: String + fileSystemIDHasSuffix: String + fileSystemIDEqualFold: String + fileSystemIDContainsFold: String + """ + file_type field predicates + """ + fileType: String + fileTypeNEQ: String + fileTypeIn: [String!] + fileTypeNotIn: [String!] + fileTypeGT: String + fileTypeGTE: String + fileTypeLT: String + fileTypeLTE: String + fileTypeContains: String + fileTypeHasPrefix: String + fileTypeHasSuffix: String + fileTypeEqualFold: String + fileTypeContainsFold: String + """ + hard_link_count field predicates + """ + hardLinkCount: String + hardLinkCountNEQ: String + hardLinkCountIn: [String!] + hardLinkCountNotIn: [String!] + hardLinkCountGT: String + hardLinkCountGTE: String + hardLinkCountLT: String + hardLinkCountLTE: String + hardLinkCountContains: String + hardLinkCountHasPrefix: String + hardLinkCountHasSuffix: String + hardLinkCountEqualFold: String + hardLinkCountContainsFold: String + """ + mtime field predicates + """ + mtime: String + mtimeNEQ: String + mtimeIn: [String!] + mtimeNotIn: [String!] + mtimeGT: String + mtimeGTE: String + mtimeLT: String + mtimeLTE: String + mtimeContains: String + mtimeHasPrefix: String + mtimeHasSuffix: String + mtimeEqualFold: String + mtimeContainsFold: String + """ + metadata_ctime field predicates + """ + metadataCtime: String + metadataCtimeNEQ: String + metadataCtimeIn: [String!] + metadataCtimeNotIn: [String!] + metadataCtimeGT: String + metadataCtimeGTE: String + metadataCtimeLT: String + metadataCtimeLTE: String + metadataCtimeContains: String + metadataCtimeHasPrefix: String + metadataCtimeHasSuffix: String + metadataCtimeEqualFold: String + metadataCtimeContainsFold: String + """ + owner_gid field predicates + """ + ownerGid: String + ownerGidNEQ: String + ownerGidIn: [String!] + ownerGidNotIn: [String!] + ownerGidGT: String + ownerGidGTE: String + ownerGidLT: String + ownerGidLTE: String + ownerGidContains: String + ownerGidHasPrefix: String + ownerGidHasSuffix: String + ownerGidEqualFold: String + ownerGidContainsFold: String + """ + owner_uid field predicates + """ + ownerUID: String + ownerUIDNEQ: String + ownerUIDIn: [String!] + ownerUIDNotIn: [String!] + ownerUIDGT: String + ownerUIDGTE: String + ownerUIDLT: String + ownerUIDLTE: String + ownerUIDContains: String + ownerUIDHasPrefix: String + ownerUIDHasSuffix: String + ownerUIDEqualFold: String + ownerUIDContainsFold: String + """ + permissions field predicates + """ + permissions: String + permissionsNEQ: String + permissionsIn: [String!] + permissionsNotIn: [String!] + permissionsGT: String + permissionsGTE: String + permissionsLT: String + permissionsLTE: String + permissionsContains: String + permissionsHasPrefix: String + permissionsHasSuffix: String + permissionsEqualFold: String + permissionsContainsFold: String + """ + size field predicates + """ + size: String + sizeNEQ: String + sizeIn: [String!] + sizeNotIn: [String!] + sizeGT: String + sizeGTE: String + sizeLT: String + sizeLTE: String + sizeContains: String + sizeHasPrefix: String + sizeHasSuffix: String + sizeEqualFold: String + sizeContainsFold: String + """ + mapping edge predicates + """ + hasMapping: Boolean + hasMappingWith: [MappingWhereInput!] +} type Query { """ Fetches an object given its ID. diff --git a/ent.resolvers.go b/ent.resolvers.go index 033399fa..5ddc16b0 100644 --- a/ent.resolvers.go +++ b/ent.resolvers.go @@ -16,7 +16,7 @@ package archivista // This file will be automatically regenerated based on the schema, any resolver implementations // will be copied through when generating and any unknown code will be moved to the end. -// Code generated by github.com/99designs/gqlgen version v0.17.45 +// Code generated by github.com/99designs/gqlgen version v0.17.47 import ( "context" diff --git a/ent/attestation.go b/ent/attestation.go index 8be2f157..f4f54058 100644 --- a/ent/attestation.go +++ b/ent/attestation.go @@ -10,6 +10,7 @@ import ( "entgo.io/ent/dialect/sql" "github.com/in-toto/archivista/ent/attestation" "github.com/in-toto/archivista/ent/attestationcollection" + "github.com/in-toto/archivista/ent/omnitrail" ) // Attestation is the model entity for the Attestation schema. @@ -28,13 +29,26 @@ type Attestation struct { // AttestationEdges holds the relations/edges for other nodes in the graph. type AttestationEdges struct { + // Omnitrail holds the value of the omnitrail edge. + Omnitrail *Omnitrail `json:"omnitrail,omitempty"` // AttestationCollection holds the value of the attestation_collection edge. AttestationCollection *AttestationCollection `json:"attestation_collection,omitempty"` // loadedTypes holds the information for reporting if a // type was loaded (or requested) in eager-loading or not. - loadedTypes [1]bool + loadedTypes [2]bool // totalCount holds the count of the edges above. - totalCount [1]map[string]int + totalCount [2]map[string]int +} + +// OmnitrailOrErr returns the Omnitrail value or an error if the edge +// was not loaded in eager-loading, or loaded but was not found. +func (e AttestationEdges) OmnitrailOrErr() (*Omnitrail, error) { + if e.Omnitrail != nil { + return e.Omnitrail, nil + } else if e.loadedTypes[0] { + return nil, &NotFoundError{label: omnitrail.Label} + } + return nil, &NotLoadedError{edge: "omnitrail"} } // AttestationCollectionOrErr returns the AttestationCollection value or an error if the edge @@ -42,7 +56,7 @@ type AttestationEdges struct { func (e AttestationEdges) AttestationCollectionOrErr() (*AttestationCollection, error) { if e.AttestationCollection != nil { return e.AttestationCollection, nil - } else if e.loadedTypes[0] { + } else if e.loadedTypes[1] { return nil, &NotFoundError{label: attestationcollection.Label} } return nil, &NotLoadedError{edge: "attestation_collection"} @@ -106,6 +120,11 @@ func (a *Attestation) Value(name string) (ent.Value, error) { return a.selectValues.Get(name) } +// QueryOmnitrail queries the "omnitrail" edge of the Attestation entity. +func (a *Attestation) QueryOmnitrail() *OmnitrailQuery { + return NewAttestationClient(a.config).QueryOmnitrail(a) +} + // QueryAttestationCollection queries the "attestation_collection" edge of the Attestation entity. func (a *Attestation) QueryAttestationCollection() *AttestationCollectionQuery { return NewAttestationClient(a.config).QueryAttestationCollection(a) diff --git a/ent/attestation/attestation.go b/ent/attestation/attestation.go index ad3226ba..dd882ac3 100644 --- a/ent/attestation/attestation.go +++ b/ent/attestation/attestation.go @@ -14,10 +14,19 @@ const ( FieldID = "id" // FieldType holds the string denoting the type field in the database. FieldType = "type" + // EdgeOmnitrail holds the string denoting the omnitrail edge name in mutations. + EdgeOmnitrail = "omnitrail" // EdgeAttestationCollection holds the string denoting the attestation_collection edge name in mutations. EdgeAttestationCollection = "attestation_collection" // Table holds the table name of the attestation in the database. Table = "attestations" + // OmnitrailTable is the table that holds the omnitrail relation/edge. + OmnitrailTable = "omnitrails" + // OmnitrailInverseTable is the table name for the Omnitrail entity. + // It exists in this package in order to avoid circular dependency with the "omnitrail" package. + OmnitrailInverseTable = "omnitrails" + // OmnitrailColumn is the table column denoting the omnitrail relation/edge. + OmnitrailColumn = "attestation_omnitrail" // AttestationCollectionTable is the table that holds the attestation_collection relation/edge. AttestationCollectionTable = "attestations" // AttestationCollectionInverseTable is the table name for the AttestationCollection entity. @@ -72,12 +81,26 @@ func ByType(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldType, opts...).ToFunc() } +// ByOmnitrailField orders the results by omnitrail field. +func ByOmnitrailField(field string, opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newOmnitrailStep(), sql.OrderByField(field, opts...)) + } +} + // ByAttestationCollectionField orders the results by attestation_collection field. func ByAttestationCollectionField(field string, opts ...sql.OrderTermOption) OrderOption { return func(s *sql.Selector) { sqlgraph.OrderByNeighborTerms(s, newAttestationCollectionStep(), sql.OrderByField(field, opts...)) } } +func newOmnitrailStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(OmnitrailInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.O2O, false, OmnitrailTable, OmnitrailColumn), + ) +} func newAttestationCollectionStep() *sqlgraph.Step { return sqlgraph.NewStep( sqlgraph.From(Table, FieldID), diff --git a/ent/attestation/where.go b/ent/attestation/where.go index 5f3a1172..aaea68c5 100644 --- a/ent/attestation/where.go +++ b/ent/attestation/where.go @@ -123,6 +123,29 @@ func TypeContainsFold(v string) predicate.Attestation { return predicate.Attestation(sql.FieldContainsFold(FieldType, v)) } +// HasOmnitrail applies the HasEdge predicate on the "omnitrail" edge. +func HasOmnitrail() predicate.Attestation { + return predicate.Attestation(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2O, false, OmnitrailTable, OmnitrailColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasOmnitrailWith applies the HasEdge predicate on the "omnitrail" edge with a given conditions (other predicates). +func HasOmnitrailWith(preds ...predicate.Omnitrail) predicate.Attestation { + return predicate.Attestation(func(s *sql.Selector) { + step := newOmnitrailStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + // HasAttestationCollection applies the HasEdge predicate on the "attestation_collection" edge. func HasAttestationCollection() predicate.Attestation { return predicate.Attestation(func(s *sql.Selector) { diff --git a/ent/attestation_create.go b/ent/attestation_create.go index f38aa1ff..58cccec8 100644 --- a/ent/attestation_create.go +++ b/ent/attestation_create.go @@ -11,6 +11,7 @@ import ( "entgo.io/ent/schema/field" "github.com/in-toto/archivista/ent/attestation" "github.com/in-toto/archivista/ent/attestationcollection" + "github.com/in-toto/archivista/ent/omnitrail" ) // AttestationCreate is the builder for creating a Attestation entity. @@ -26,6 +27,25 @@ func (ac *AttestationCreate) SetType(s string) *AttestationCreate { return ac } +// SetOmnitrailID sets the "omnitrail" edge to the Omnitrail entity by ID. +func (ac *AttestationCreate) SetOmnitrailID(id int) *AttestationCreate { + ac.mutation.SetOmnitrailID(id) + return ac +} + +// SetNillableOmnitrailID sets the "omnitrail" edge to the Omnitrail entity by ID if the given value is not nil. +func (ac *AttestationCreate) SetNillableOmnitrailID(id *int) *AttestationCreate { + if id != nil { + ac = ac.SetOmnitrailID(*id) + } + return ac +} + +// SetOmnitrail sets the "omnitrail" edge to the Omnitrail entity. +func (ac *AttestationCreate) SetOmnitrail(o *Omnitrail) *AttestationCreate { + return ac.SetOmnitrailID(o.ID) +} + // SetAttestationCollectionID sets the "attestation_collection" edge to the AttestationCollection entity by ID. func (ac *AttestationCreate) SetAttestationCollectionID(id int) *AttestationCreate { ac.mutation.SetAttestationCollectionID(id) @@ -112,6 +132,22 @@ func (ac *AttestationCreate) createSpec() (*Attestation, *sqlgraph.CreateSpec) { _spec.SetField(attestation.FieldType, field.TypeString, value) _node.Type = value } + if nodes := ac.mutation.OmnitrailIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2O, + Inverse: false, + Table: attestation.OmnitrailTable, + Columns: []string{attestation.OmnitrailColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(omnitrail.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } if nodes := ac.mutation.AttestationCollectionIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, diff --git a/ent/attestation_query.go b/ent/attestation_query.go index 765b8981..06089362 100644 --- a/ent/attestation_query.go +++ b/ent/attestation_query.go @@ -4,6 +4,7 @@ package ent import ( "context" + "database/sql/driver" "fmt" "math" @@ -12,6 +13,7 @@ import ( "entgo.io/ent/schema/field" "github.com/in-toto/archivista/ent/attestation" "github.com/in-toto/archivista/ent/attestationcollection" + "github.com/in-toto/archivista/ent/omnitrail" "github.com/in-toto/archivista/ent/predicate" ) @@ -22,6 +24,7 @@ type AttestationQuery struct { order []attestation.OrderOption inters []Interceptor predicates []predicate.Attestation + withOmnitrail *OmnitrailQuery withAttestationCollection *AttestationCollectionQuery withFKs bool modifiers []func(*sql.Selector) @@ -62,6 +65,28 @@ func (aq *AttestationQuery) Order(o ...attestation.OrderOption) *AttestationQuer return aq } +// QueryOmnitrail chains the current query on the "omnitrail" edge. +func (aq *AttestationQuery) QueryOmnitrail() *OmnitrailQuery { + query := (&OmnitrailClient{config: aq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := aq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := aq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(attestation.Table, attestation.FieldID, selector), + sqlgraph.To(omnitrail.Table, omnitrail.FieldID), + sqlgraph.Edge(sqlgraph.O2O, false, attestation.OmnitrailTable, attestation.OmnitrailColumn), + ) + fromU = sqlgraph.SetNeighbors(aq.driver.Dialect(), step) + return fromU, nil + } + return query +} + // QueryAttestationCollection chains the current query on the "attestation_collection" edge. func (aq *AttestationQuery) QueryAttestationCollection() *AttestationCollectionQuery { query := (&AttestationCollectionClient{config: aq.config}).Query() @@ -276,6 +301,7 @@ func (aq *AttestationQuery) Clone() *AttestationQuery { order: append([]attestation.OrderOption{}, aq.order...), inters: append([]Interceptor{}, aq.inters...), predicates: append([]predicate.Attestation{}, aq.predicates...), + withOmnitrail: aq.withOmnitrail.Clone(), withAttestationCollection: aq.withAttestationCollection.Clone(), // clone intermediate query. sql: aq.sql.Clone(), @@ -283,6 +309,17 @@ func (aq *AttestationQuery) Clone() *AttestationQuery { } } +// WithOmnitrail tells the query-builder to eager-load the nodes that are connected to +// the "omnitrail" edge. The optional arguments are used to configure the query builder of the edge. +func (aq *AttestationQuery) WithOmnitrail(opts ...func(*OmnitrailQuery)) *AttestationQuery { + query := (&OmnitrailClient{config: aq.config}).Query() + for _, opt := range opts { + opt(query) + } + aq.withOmnitrail = query + return aq +} + // WithAttestationCollection tells the query-builder to eager-load the nodes that are connected to // the "attestation_collection" edge. The optional arguments are used to configure the query builder of the edge. func (aq *AttestationQuery) WithAttestationCollection(opts ...func(*AttestationCollectionQuery)) *AttestationQuery { @@ -373,7 +410,8 @@ func (aq *AttestationQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]* nodes = []*Attestation{} withFKs = aq.withFKs _spec = aq.querySpec() - loadedTypes = [1]bool{ + loadedTypes = [2]bool{ + aq.withOmnitrail != nil, aq.withAttestationCollection != nil, } ) @@ -404,6 +442,12 @@ func (aq *AttestationQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]* if len(nodes) == 0 { return nodes, nil } + if query := aq.withOmnitrail; query != nil { + if err := aq.loadOmnitrail(ctx, query, nodes, nil, + func(n *Attestation, e *Omnitrail) { n.Edges.Omnitrail = e }); err != nil { + return nil, err + } + } if query := aq.withAttestationCollection; query != nil { if err := aq.loadAttestationCollection(ctx, query, nodes, nil, func(n *Attestation, e *AttestationCollection) { n.Edges.AttestationCollection = e }); err != nil { @@ -418,6 +462,34 @@ func (aq *AttestationQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]* return nodes, nil } +func (aq *AttestationQuery) loadOmnitrail(ctx context.Context, query *OmnitrailQuery, nodes []*Attestation, init func(*Attestation), assign func(*Attestation, *Omnitrail)) error { + fks := make([]driver.Value, 0, len(nodes)) + nodeids := make(map[int]*Attestation) + for i := range nodes { + fks = append(fks, nodes[i].ID) + nodeids[nodes[i].ID] = nodes[i] + } + query.withFKs = true + query.Where(predicate.Omnitrail(func(s *sql.Selector) { + s.Where(sql.InValues(s.C(attestation.OmnitrailColumn), fks...)) + })) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + fk := n.attestation_omnitrail + if fk == nil { + return fmt.Errorf(`foreign-key "attestation_omnitrail" is nil for node %v`, n.ID) + } + node, ok := nodeids[*fk] + if !ok { + return fmt.Errorf(`unexpected referenced foreign-key "attestation_omnitrail" returned %v for node %v`, *fk, n.ID) + } + assign(node, n) + } + return nil +} func (aq *AttestationQuery) loadAttestationCollection(ctx context.Context, query *AttestationCollectionQuery, nodes []*Attestation, init func(*Attestation), assign func(*Attestation, *AttestationCollection)) error { ids := make([]int, 0, len(nodes)) nodeids := make(map[int][]*Attestation) diff --git a/ent/attestation_update.go b/ent/attestation_update.go index 821ad10a..dcc732c4 100644 --- a/ent/attestation_update.go +++ b/ent/attestation_update.go @@ -12,6 +12,7 @@ import ( "entgo.io/ent/schema/field" "github.com/in-toto/archivista/ent/attestation" "github.com/in-toto/archivista/ent/attestationcollection" + "github.com/in-toto/archivista/ent/omnitrail" "github.com/in-toto/archivista/ent/predicate" ) @@ -42,6 +43,25 @@ func (au *AttestationUpdate) SetNillableType(s *string) *AttestationUpdate { return au } +// SetOmnitrailID sets the "omnitrail" edge to the Omnitrail entity by ID. +func (au *AttestationUpdate) SetOmnitrailID(id int) *AttestationUpdate { + au.mutation.SetOmnitrailID(id) + return au +} + +// SetNillableOmnitrailID sets the "omnitrail" edge to the Omnitrail entity by ID if the given value is not nil. +func (au *AttestationUpdate) SetNillableOmnitrailID(id *int) *AttestationUpdate { + if id != nil { + au = au.SetOmnitrailID(*id) + } + return au +} + +// SetOmnitrail sets the "omnitrail" edge to the Omnitrail entity. +func (au *AttestationUpdate) SetOmnitrail(o *Omnitrail) *AttestationUpdate { + return au.SetOmnitrailID(o.ID) +} + // SetAttestationCollectionID sets the "attestation_collection" edge to the AttestationCollection entity by ID. func (au *AttestationUpdate) SetAttestationCollectionID(id int) *AttestationUpdate { au.mutation.SetAttestationCollectionID(id) @@ -58,6 +78,12 @@ func (au *AttestationUpdate) Mutation() *AttestationMutation { return au.mutation } +// ClearOmnitrail clears the "omnitrail" edge to the Omnitrail entity. +func (au *AttestationUpdate) ClearOmnitrail() *AttestationUpdate { + au.mutation.ClearOmnitrail() + return au +} + // ClearAttestationCollection clears the "attestation_collection" edge to the AttestationCollection entity. func (au *AttestationUpdate) ClearAttestationCollection() *AttestationUpdate { au.mutation.ClearAttestationCollection() @@ -119,6 +145,35 @@ func (au *AttestationUpdate) sqlSave(ctx context.Context) (n int, err error) { if value, ok := au.mutation.GetType(); ok { _spec.SetField(attestation.FieldType, field.TypeString, value) } + if au.mutation.OmnitrailCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2O, + Inverse: false, + Table: attestation.OmnitrailTable, + Columns: []string{attestation.OmnitrailColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(omnitrail.FieldID, field.TypeInt), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := au.mutation.OmnitrailIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2O, + Inverse: false, + Table: attestation.OmnitrailTable, + Columns: []string{attestation.OmnitrailColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(omnitrail.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } if au.mutation.AttestationCollectionCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, @@ -182,6 +237,25 @@ func (auo *AttestationUpdateOne) SetNillableType(s *string) *AttestationUpdateOn return auo } +// SetOmnitrailID sets the "omnitrail" edge to the Omnitrail entity by ID. +func (auo *AttestationUpdateOne) SetOmnitrailID(id int) *AttestationUpdateOne { + auo.mutation.SetOmnitrailID(id) + return auo +} + +// SetNillableOmnitrailID sets the "omnitrail" edge to the Omnitrail entity by ID if the given value is not nil. +func (auo *AttestationUpdateOne) SetNillableOmnitrailID(id *int) *AttestationUpdateOne { + if id != nil { + auo = auo.SetOmnitrailID(*id) + } + return auo +} + +// SetOmnitrail sets the "omnitrail" edge to the Omnitrail entity. +func (auo *AttestationUpdateOne) SetOmnitrail(o *Omnitrail) *AttestationUpdateOne { + return auo.SetOmnitrailID(o.ID) +} + // SetAttestationCollectionID sets the "attestation_collection" edge to the AttestationCollection entity by ID. func (auo *AttestationUpdateOne) SetAttestationCollectionID(id int) *AttestationUpdateOne { auo.mutation.SetAttestationCollectionID(id) @@ -198,6 +272,12 @@ func (auo *AttestationUpdateOne) Mutation() *AttestationMutation { return auo.mutation } +// ClearOmnitrail clears the "omnitrail" edge to the Omnitrail entity. +func (auo *AttestationUpdateOne) ClearOmnitrail() *AttestationUpdateOne { + auo.mutation.ClearOmnitrail() + return auo +} + // ClearAttestationCollection clears the "attestation_collection" edge to the AttestationCollection entity. func (auo *AttestationUpdateOne) ClearAttestationCollection() *AttestationUpdateOne { auo.mutation.ClearAttestationCollection() @@ -289,6 +369,35 @@ func (auo *AttestationUpdateOne) sqlSave(ctx context.Context) (_node *Attestatio if value, ok := auo.mutation.GetType(); ok { _spec.SetField(attestation.FieldType, field.TypeString, value) } + if auo.mutation.OmnitrailCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2O, + Inverse: false, + Table: attestation.OmnitrailTable, + Columns: []string{attestation.OmnitrailColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(omnitrail.FieldID, field.TypeInt), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := auo.mutation.OmnitrailIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2O, + Inverse: false, + Table: attestation.OmnitrailTable, + Columns: []string{attestation.OmnitrailColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(omnitrail.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } if auo.mutation.AttestationCollectionCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, diff --git a/ent/client.go b/ent/client.go index 81c42fdf..99215c19 100644 --- a/ent/client.go +++ b/ent/client.go @@ -19,7 +19,10 @@ import ( "github.com/in-toto/archivista/ent/attestationcollection" "github.com/in-toto/archivista/ent/attestationpolicy" "github.com/in-toto/archivista/ent/dsse" + "github.com/in-toto/archivista/ent/mapping" + "github.com/in-toto/archivista/ent/omnitrail" "github.com/in-toto/archivista/ent/payloaddigest" + "github.com/in-toto/archivista/ent/posix" "github.com/in-toto/archivista/ent/signature" "github.com/in-toto/archivista/ent/statement" "github.com/in-toto/archivista/ent/subject" @@ -40,8 +43,14 @@ type Client struct { AttestationPolicy *AttestationPolicyClient // Dsse is the client for interacting with the Dsse builders. Dsse *DsseClient + // Mapping is the client for interacting with the Mapping builders. + Mapping *MappingClient + // Omnitrail is the client for interacting with the Omnitrail builders. + Omnitrail *OmnitrailClient // PayloadDigest is the client for interacting with the PayloadDigest builders. PayloadDigest *PayloadDigestClient + // Posix is the client for interacting with the Posix builders. + Posix *PosixClient // Signature is the client for interacting with the Signature builders. Signature *SignatureClient // Statement is the client for interacting with the Statement builders. @@ -69,7 +78,10 @@ func (c *Client) init() { c.AttestationCollection = NewAttestationCollectionClient(c.config) c.AttestationPolicy = NewAttestationPolicyClient(c.config) c.Dsse = NewDsseClient(c.config) + c.Mapping = NewMappingClient(c.config) + c.Omnitrail = NewOmnitrailClient(c.config) c.PayloadDigest = NewPayloadDigestClient(c.config) + c.Posix = NewPosixClient(c.config) c.Signature = NewSignatureClient(c.config) c.Statement = NewStatementClient(c.config) c.Subject = NewSubjectClient(c.config) @@ -171,7 +183,10 @@ func (c *Client) Tx(ctx context.Context) (*Tx, error) { AttestationCollection: NewAttestationCollectionClient(cfg), AttestationPolicy: NewAttestationPolicyClient(cfg), Dsse: NewDsseClient(cfg), + Mapping: NewMappingClient(cfg), + Omnitrail: NewOmnitrailClient(cfg), PayloadDigest: NewPayloadDigestClient(cfg), + Posix: NewPosixClient(cfg), Signature: NewSignatureClient(cfg), Statement: NewStatementClient(cfg), Subject: NewSubjectClient(cfg), @@ -200,7 +215,10 @@ func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error) AttestationCollection: NewAttestationCollectionClient(cfg), AttestationPolicy: NewAttestationPolicyClient(cfg), Dsse: NewDsseClient(cfg), + Mapping: NewMappingClient(cfg), + Omnitrail: NewOmnitrailClient(cfg), PayloadDigest: NewPayloadDigestClient(cfg), + Posix: NewPosixClient(cfg), Signature: NewSignatureClient(cfg), Statement: NewStatementClient(cfg), Subject: NewSubjectClient(cfg), @@ -235,9 +253,9 @@ func (c *Client) Close() error { // In order to add hooks to a specific client, call: `client.Node.Use(...)`. func (c *Client) Use(hooks ...Hook) { for _, n := range []interface{ Use(...Hook) }{ - c.Attestation, c.AttestationCollection, c.AttestationPolicy, c.Dsse, - c.PayloadDigest, c.Signature, c.Statement, c.Subject, c.SubjectDigest, - c.Timestamp, + c.Attestation, c.AttestationCollection, c.AttestationPolicy, c.Dsse, c.Mapping, + c.Omnitrail, c.PayloadDigest, c.Posix, c.Signature, c.Statement, c.Subject, + c.SubjectDigest, c.Timestamp, } { n.Use(hooks...) } @@ -247,9 +265,9 @@ func (c *Client) Use(hooks ...Hook) { // In order to add interceptors to a specific client, call: `client.Node.Intercept(...)`. func (c *Client) Intercept(interceptors ...Interceptor) { for _, n := range []interface{ Intercept(...Interceptor) }{ - c.Attestation, c.AttestationCollection, c.AttestationPolicy, c.Dsse, - c.PayloadDigest, c.Signature, c.Statement, c.Subject, c.SubjectDigest, - c.Timestamp, + c.Attestation, c.AttestationCollection, c.AttestationPolicy, c.Dsse, c.Mapping, + c.Omnitrail, c.PayloadDigest, c.Posix, c.Signature, c.Statement, c.Subject, + c.SubjectDigest, c.Timestamp, } { n.Intercept(interceptors...) } @@ -266,8 +284,14 @@ func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) { return c.AttestationPolicy.mutate(ctx, m) case *DsseMutation: return c.Dsse.mutate(ctx, m) + case *MappingMutation: + return c.Mapping.mutate(ctx, m) + case *OmnitrailMutation: + return c.Omnitrail.mutate(ctx, m) case *PayloadDigestMutation: return c.PayloadDigest.mutate(ctx, m) + case *PosixMutation: + return c.Posix.mutate(ctx, m) case *SignatureMutation: return c.Signature.mutate(ctx, m) case *StatementMutation: @@ -391,6 +415,22 @@ func (c *AttestationClient) GetX(ctx context.Context, id int) *Attestation { return obj } +// QueryOmnitrail queries the omnitrail edge of a Attestation. +func (c *AttestationClient) QueryOmnitrail(a *Attestation) *OmnitrailQuery { + query := (&OmnitrailClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := a.ID + step := sqlgraph.NewStep( + sqlgraph.From(attestation.Table, attestation.FieldID, id), + sqlgraph.To(omnitrail.Table, omnitrail.FieldID), + sqlgraph.Edge(sqlgraph.O2O, false, attestation.OmnitrailTable, attestation.OmnitrailColumn), + ) + fromV = sqlgraph.Neighbors(a.driver.Dialect(), step) + return fromV, nil + } + return query +} + // QueryAttestationCollection queries the attestation_collection edge of a Attestation. func (c *AttestationClient) QueryAttestationCollection(a *Attestation) *AttestationCollectionQuery { query := (&AttestationCollectionClient{config: c.config}).Query() @@ -927,6 +967,336 @@ func (c *DsseClient) mutate(ctx context.Context, m *DsseMutation) (Value, error) } } +// MappingClient is a client for the Mapping schema. +type MappingClient struct { + config +} + +// NewMappingClient returns a client for the Mapping from the given config. +func NewMappingClient(c config) *MappingClient { + return &MappingClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `mapping.Hooks(f(g(h())))`. +func (c *MappingClient) Use(hooks ...Hook) { + c.hooks.Mapping = append(c.hooks.Mapping, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `mapping.Intercept(f(g(h())))`. +func (c *MappingClient) Intercept(interceptors ...Interceptor) { + c.inters.Mapping = append(c.inters.Mapping, interceptors...) +} + +// Create returns a builder for creating a Mapping entity. +func (c *MappingClient) Create() *MappingCreate { + mutation := newMappingMutation(c.config, OpCreate) + return &MappingCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of Mapping entities. +func (c *MappingClient) CreateBulk(builders ...*MappingCreate) *MappingCreateBulk { + return &MappingCreateBulk{config: c.config, builders: builders} +} + +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *MappingClient) MapCreateBulk(slice any, setFunc func(*MappingCreate, int)) *MappingCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &MappingCreateBulk{err: fmt.Errorf("calling to MappingClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*MappingCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &MappingCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for Mapping. +func (c *MappingClient) Update() *MappingUpdate { + mutation := newMappingMutation(c.config, OpUpdate) + return &MappingUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *MappingClient) UpdateOne(m *Mapping) *MappingUpdateOne { + mutation := newMappingMutation(c.config, OpUpdateOne, withMapping(m)) + return &MappingUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *MappingClient) UpdateOneID(id int) *MappingUpdateOne { + mutation := newMappingMutation(c.config, OpUpdateOne, withMappingID(id)) + return &MappingUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for Mapping. +func (c *MappingClient) Delete() *MappingDelete { + mutation := newMappingMutation(c.config, OpDelete) + return &MappingDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *MappingClient) DeleteOne(m *Mapping) *MappingDeleteOne { + return c.DeleteOneID(m.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *MappingClient) DeleteOneID(id int) *MappingDeleteOne { + builder := c.Delete().Where(mapping.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &MappingDeleteOne{builder} +} + +// Query returns a query builder for Mapping. +func (c *MappingClient) Query() *MappingQuery { + return &MappingQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeMapping}, + inters: c.Interceptors(), + } +} + +// Get returns a Mapping entity by its id. +func (c *MappingClient) Get(ctx context.Context, id int) (*Mapping, error) { + return c.Query().Where(mapping.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *MappingClient) GetX(ctx context.Context, id int) *Mapping { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// QueryPosix queries the posix edge of a Mapping. +func (c *MappingClient) QueryPosix(m *Mapping) *PosixQuery { + query := (&PosixClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := m.ID + step := sqlgraph.NewStep( + sqlgraph.From(mapping.Table, mapping.FieldID, id), + sqlgraph.To(posix.Table, posix.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, mapping.PosixTable, mapping.PosixColumn), + ) + fromV = sqlgraph.Neighbors(m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryOmnitrail queries the omnitrail edge of a Mapping. +func (c *MappingClient) QueryOmnitrail(m *Mapping) *OmnitrailQuery { + query := (&OmnitrailClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := m.ID + step := sqlgraph.NewStep( + sqlgraph.From(mapping.Table, mapping.FieldID, id), + sqlgraph.To(omnitrail.Table, omnitrail.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, mapping.OmnitrailTable, mapping.OmnitrailColumn), + ) + fromV = sqlgraph.Neighbors(m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// Hooks returns the client hooks. +func (c *MappingClient) Hooks() []Hook { + return c.hooks.Mapping +} + +// Interceptors returns the client interceptors. +func (c *MappingClient) Interceptors() []Interceptor { + return c.inters.Mapping +} + +func (c *MappingClient) mutate(ctx context.Context, m *MappingMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&MappingCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&MappingUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&MappingUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&MappingDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown Mapping mutation op: %q", m.Op()) + } +} + +// OmnitrailClient is a client for the Omnitrail schema. +type OmnitrailClient struct { + config +} + +// NewOmnitrailClient returns a client for the Omnitrail from the given config. +func NewOmnitrailClient(c config) *OmnitrailClient { + return &OmnitrailClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `omnitrail.Hooks(f(g(h())))`. +func (c *OmnitrailClient) Use(hooks ...Hook) { + c.hooks.Omnitrail = append(c.hooks.Omnitrail, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `omnitrail.Intercept(f(g(h())))`. +func (c *OmnitrailClient) Intercept(interceptors ...Interceptor) { + c.inters.Omnitrail = append(c.inters.Omnitrail, interceptors...) +} + +// Create returns a builder for creating a Omnitrail entity. +func (c *OmnitrailClient) Create() *OmnitrailCreate { + mutation := newOmnitrailMutation(c.config, OpCreate) + return &OmnitrailCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of Omnitrail entities. +func (c *OmnitrailClient) CreateBulk(builders ...*OmnitrailCreate) *OmnitrailCreateBulk { + return &OmnitrailCreateBulk{config: c.config, builders: builders} +} + +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *OmnitrailClient) MapCreateBulk(slice any, setFunc func(*OmnitrailCreate, int)) *OmnitrailCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &OmnitrailCreateBulk{err: fmt.Errorf("calling to OmnitrailClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*OmnitrailCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &OmnitrailCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for Omnitrail. +func (c *OmnitrailClient) Update() *OmnitrailUpdate { + mutation := newOmnitrailMutation(c.config, OpUpdate) + return &OmnitrailUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *OmnitrailClient) UpdateOne(o *Omnitrail) *OmnitrailUpdateOne { + mutation := newOmnitrailMutation(c.config, OpUpdateOne, withOmnitrail(o)) + return &OmnitrailUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *OmnitrailClient) UpdateOneID(id int) *OmnitrailUpdateOne { + mutation := newOmnitrailMutation(c.config, OpUpdateOne, withOmnitrailID(id)) + return &OmnitrailUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for Omnitrail. +func (c *OmnitrailClient) Delete() *OmnitrailDelete { + mutation := newOmnitrailMutation(c.config, OpDelete) + return &OmnitrailDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *OmnitrailClient) DeleteOne(o *Omnitrail) *OmnitrailDeleteOne { + return c.DeleteOneID(o.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *OmnitrailClient) DeleteOneID(id int) *OmnitrailDeleteOne { + builder := c.Delete().Where(omnitrail.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &OmnitrailDeleteOne{builder} +} + +// Query returns a query builder for Omnitrail. +func (c *OmnitrailClient) Query() *OmnitrailQuery { + return &OmnitrailQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeOmnitrail}, + inters: c.Interceptors(), + } +} + +// Get returns a Omnitrail entity by its id. +func (c *OmnitrailClient) Get(ctx context.Context, id int) (*Omnitrail, error) { + return c.Query().Where(omnitrail.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *OmnitrailClient) GetX(ctx context.Context, id int) *Omnitrail { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// QueryMappings queries the mappings edge of a Omnitrail. +func (c *OmnitrailClient) QueryMappings(o *Omnitrail) *MappingQuery { + query := (&MappingClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := o.ID + step := sqlgraph.NewStep( + sqlgraph.From(omnitrail.Table, omnitrail.FieldID, id), + sqlgraph.To(mapping.Table, mapping.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, omnitrail.MappingsTable, omnitrail.MappingsColumn), + ) + fromV = sqlgraph.Neighbors(o.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryAttestation queries the attestation edge of a Omnitrail. +func (c *OmnitrailClient) QueryAttestation(o *Omnitrail) *AttestationQuery { + query := (&AttestationClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := o.ID + step := sqlgraph.NewStep( + sqlgraph.From(omnitrail.Table, omnitrail.FieldID, id), + sqlgraph.To(attestation.Table, attestation.FieldID), + sqlgraph.Edge(sqlgraph.O2O, true, omnitrail.AttestationTable, omnitrail.AttestationColumn), + ) + fromV = sqlgraph.Neighbors(o.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// Hooks returns the client hooks. +func (c *OmnitrailClient) Hooks() []Hook { + return c.hooks.Omnitrail +} + +// Interceptors returns the client interceptors. +func (c *OmnitrailClient) Interceptors() []Interceptor { + return c.inters.Omnitrail +} + +func (c *OmnitrailClient) mutate(ctx context.Context, m *OmnitrailMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&OmnitrailCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&OmnitrailUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&OmnitrailUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&OmnitrailDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown Omnitrail mutation op: %q", m.Op()) + } +} + // PayloadDigestClient is a client for the PayloadDigest schema. type PayloadDigestClient struct { config @@ -1076,6 +1446,155 @@ func (c *PayloadDigestClient) mutate(ctx context.Context, m *PayloadDigestMutati } } +// PosixClient is a client for the Posix schema. +type PosixClient struct { + config +} + +// NewPosixClient returns a client for the Posix from the given config. +func NewPosixClient(c config) *PosixClient { + return &PosixClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `posix.Hooks(f(g(h())))`. +func (c *PosixClient) Use(hooks ...Hook) { + c.hooks.Posix = append(c.hooks.Posix, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `posix.Intercept(f(g(h())))`. +func (c *PosixClient) Intercept(interceptors ...Interceptor) { + c.inters.Posix = append(c.inters.Posix, interceptors...) +} + +// Create returns a builder for creating a Posix entity. +func (c *PosixClient) Create() *PosixCreate { + mutation := newPosixMutation(c.config, OpCreate) + return &PosixCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of Posix entities. +func (c *PosixClient) CreateBulk(builders ...*PosixCreate) *PosixCreateBulk { + return &PosixCreateBulk{config: c.config, builders: builders} +} + +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *PosixClient) MapCreateBulk(slice any, setFunc func(*PosixCreate, int)) *PosixCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &PosixCreateBulk{err: fmt.Errorf("calling to PosixClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*PosixCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &PosixCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for Posix. +func (c *PosixClient) Update() *PosixUpdate { + mutation := newPosixMutation(c.config, OpUpdate) + return &PosixUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *PosixClient) UpdateOne(po *Posix) *PosixUpdateOne { + mutation := newPosixMutation(c.config, OpUpdateOne, withPosix(po)) + return &PosixUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *PosixClient) UpdateOneID(id int) *PosixUpdateOne { + mutation := newPosixMutation(c.config, OpUpdateOne, withPosixID(id)) + return &PosixUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for Posix. +func (c *PosixClient) Delete() *PosixDelete { + mutation := newPosixMutation(c.config, OpDelete) + return &PosixDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *PosixClient) DeleteOne(po *Posix) *PosixDeleteOne { + return c.DeleteOneID(po.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *PosixClient) DeleteOneID(id int) *PosixDeleteOne { + builder := c.Delete().Where(posix.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &PosixDeleteOne{builder} +} + +// Query returns a query builder for Posix. +func (c *PosixClient) Query() *PosixQuery { + return &PosixQuery{ + config: c.config, + ctx: &QueryContext{Type: TypePosix}, + inters: c.Interceptors(), + } +} + +// Get returns a Posix entity by its id. +func (c *PosixClient) Get(ctx context.Context, id int) (*Posix, error) { + return c.Query().Where(posix.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *PosixClient) GetX(ctx context.Context, id int) *Posix { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// QueryMapping queries the mapping edge of a Posix. +func (c *PosixClient) QueryMapping(po *Posix) *MappingQuery { + query := (&MappingClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := po.ID + step := sqlgraph.NewStep( + sqlgraph.From(posix.Table, posix.FieldID, id), + sqlgraph.To(mapping.Table, mapping.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, posix.MappingTable, posix.MappingColumn), + ) + fromV = sqlgraph.Neighbors(po.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// Hooks returns the client hooks. +func (c *PosixClient) Hooks() []Hook { + return c.hooks.Posix +} + +// Interceptors returns the client interceptors. +func (c *PosixClient) Interceptors() []Interceptor { + return c.inters.Posix +} + +func (c *PosixClient) mutate(ctx context.Context, m *PosixMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&PosixCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&PosixUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&PosixUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&PosixDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown Posix mutation op: %q", m.Op()) + } +} + // SignatureClient is a client for the Signature schema. type SignatureClient struct { config @@ -1904,11 +2423,13 @@ func (c *TimestampClient) mutate(ctx context.Context, m *TimestampMutation) (Val // hooks and interceptors per client, for fast access. type ( hooks struct { - Attestation, AttestationCollection, AttestationPolicy, Dsse, PayloadDigest, - Signature, Statement, Subject, SubjectDigest, Timestamp []ent.Hook + Attestation, AttestationCollection, AttestationPolicy, Dsse, Mapping, Omnitrail, + PayloadDigest, Posix, Signature, Statement, Subject, SubjectDigest, + Timestamp []ent.Hook } inters struct { - Attestation, AttestationCollection, AttestationPolicy, Dsse, PayloadDigest, - Signature, Statement, Subject, SubjectDigest, Timestamp []ent.Interceptor + Attestation, AttestationCollection, AttestationPolicy, Dsse, Mapping, Omnitrail, + PayloadDigest, Posix, Signature, Statement, Subject, SubjectDigest, + Timestamp []ent.Interceptor } ) diff --git a/ent/ent.go b/ent/ent.go index a84a145b..dbf4940f 100644 --- a/ent/ent.go +++ b/ent/ent.go @@ -16,7 +16,10 @@ import ( "github.com/in-toto/archivista/ent/attestationcollection" "github.com/in-toto/archivista/ent/attestationpolicy" "github.com/in-toto/archivista/ent/dsse" + "github.com/in-toto/archivista/ent/mapping" + "github.com/in-toto/archivista/ent/omnitrail" "github.com/in-toto/archivista/ent/payloaddigest" + "github.com/in-toto/archivista/ent/posix" "github.com/in-toto/archivista/ent/signature" "github.com/in-toto/archivista/ent/statement" "github.com/in-toto/archivista/ent/subject" @@ -86,7 +89,10 @@ func checkColumn(table, column string) error { attestationcollection.Table: attestationcollection.ValidColumn, attestationpolicy.Table: attestationpolicy.ValidColumn, dsse.Table: dsse.ValidColumn, + mapping.Table: mapping.ValidColumn, + omnitrail.Table: omnitrail.ValidColumn, payloaddigest.Table: payloaddigest.ValidColumn, + posix.Table: posix.ValidColumn, signature.Table: signature.ValidColumn, statement.Table: statement.ValidColumn, subject.Table: subject.ValidColumn, diff --git a/ent/gql_collection.go b/ent/gql_collection.go index 282c69f5..b51b66f4 100644 --- a/ent/gql_collection.go +++ b/ent/gql_collection.go @@ -7,13 +7,16 @@ import ( "database/sql/driver" "fmt" + "entgo.io/contrib/entgql" "entgo.io/ent/dialect/sql" "github.com/99designs/gqlgen/graphql" "github.com/in-toto/archivista/ent/attestation" "github.com/in-toto/archivista/ent/attestationcollection" "github.com/in-toto/archivista/ent/attestationpolicy" "github.com/in-toto/archivista/ent/dsse" + "github.com/in-toto/archivista/ent/mapping" "github.com/in-toto/archivista/ent/payloaddigest" + "github.com/in-toto/archivista/ent/posix" "github.com/in-toto/archivista/ent/signature" "github.com/in-toto/archivista/ent/statement" "github.com/in-toto/archivista/ent/subject" @@ -27,13 +30,13 @@ func (a *AttestationQuery) CollectFields(ctx context.Context, satisfies ...strin if fc == nil { return a, nil } - if err := a.collectField(ctx, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { + if err := a.collectField(ctx, false, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { return nil, err } return a, nil } -func (a *AttestationQuery) collectField(ctx context.Context, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { +func (a *AttestationQuery) collectField(ctx context.Context, oneNode bool, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { path = append([]string(nil), path...) var ( unknownSeen bool @@ -42,13 +45,25 @@ func (a *AttestationQuery) collectField(ctx context.Context, opCtx *graphql.Oper ) for _, field := range graphql.CollectFields(opCtx, collected.Selections, satisfies) { switch field.Name { + + case "omnitrail": + var ( + alias = field.Alias + path = append(path, alias) + query = (&OmnitrailClient{config: a.config}).Query() + ) + if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, omnitrailImplementors)...); err != nil { + return err + } + a.withOmnitrail = query + case "attestationCollection": var ( alias = field.Alias path = append(path, alias) query = (&AttestationCollectionClient{config: a.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, attestationcollectionImplementors)...); err != nil { return err } a.withAttestationCollection = query @@ -104,13 +119,13 @@ func (ac *AttestationCollectionQuery) CollectFields(ctx context.Context, satisfi if fc == nil { return ac, nil } - if err := ac.collectField(ctx, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { + if err := ac.collectField(ctx, false, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { return nil, err } return ac, nil } -func (ac *AttestationCollectionQuery) collectField(ctx context.Context, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { +func (ac *AttestationCollectionQuery) collectField(ctx context.Context, oneNode bool, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { path = append([]string(nil), path...) var ( unknownSeen bool @@ -119,25 +134,27 @@ func (ac *AttestationCollectionQuery) collectField(ctx context.Context, opCtx *g ) for _, field := range graphql.CollectFields(opCtx, collected.Selections, satisfies) { switch field.Name { + case "attestations": var ( alias = field.Alias path = append(path, alias) query = (&AttestationClient{config: ac.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, false, opCtx, field, path, mayAddCondition(satisfies, attestationImplementors)...); err != nil { return err } ac.WithNamedAttestations(alias, func(wq *AttestationQuery) { *wq = *query }) + case "statement": var ( alias = field.Alias path = append(path, alias) query = (&StatementClient{config: ac.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, statementImplementors)...); err != nil { return err } ac.withStatement = query @@ -193,13 +210,13 @@ func (ap *AttestationPolicyQuery) CollectFields(ctx context.Context, satisfies . if fc == nil { return ap, nil } - if err := ap.collectField(ctx, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { + if err := ap.collectField(ctx, false, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { return nil, err } return ap, nil } -func (ap *AttestationPolicyQuery) collectField(ctx context.Context, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { +func (ap *AttestationPolicyQuery) collectField(ctx context.Context, oneNode bool, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { path = append([]string(nil), path...) var ( unknownSeen bool @@ -208,13 +225,14 @@ func (ap *AttestationPolicyQuery) collectField(ctx context.Context, opCtx *graph ) for _, field := range graphql.CollectFields(opCtx, collected.Selections, satisfies) { switch field.Name { + case "statement": var ( alias = field.Alias path = append(path, alias) query = (&StatementClient{config: ap.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, statementImplementors)...); err != nil { return err } ap.withStatement = query @@ -270,13 +288,13 @@ func (d *DsseQuery) CollectFields(ctx context.Context, satisfies ...string) (*Ds if fc == nil { return d, nil } - if err := d.collectField(ctx, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { + if err := d.collectField(ctx, false, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { return nil, err } return d, nil } -func (d *DsseQuery) collectField(ctx context.Context, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { +func (d *DsseQuery) collectField(ctx context.Context, oneNode bool, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { path = append([]string(nil), path...) var ( unknownSeen bool @@ -285,35 +303,38 @@ func (d *DsseQuery) collectField(ctx context.Context, opCtx *graphql.OperationCo ) for _, field := range graphql.CollectFields(opCtx, collected.Selections, satisfies) { switch field.Name { + case "statement": var ( alias = field.Alias path = append(path, alias) query = (&StatementClient{config: d.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, statementImplementors)...); err != nil { return err } d.withStatement = query + case "signatures": var ( alias = field.Alias path = append(path, alias) query = (&SignatureClient{config: d.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, false, opCtx, field, path, mayAddCondition(satisfies, signatureImplementors)...); err != nil { return err } d.WithNamedSignatures(alias, func(wq *SignatureQuery) { *wq = *query }) + case "payloadDigests": var ( alias = field.Alias path = append(path, alias) query = (&PayloadDigestClient{config: d.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, false, opCtx, field, path, mayAddCondition(satisfies, payloaddigestImplementors)...); err != nil { return err } d.WithNamedPayloadDigests(alias, func(wq *PayloadDigestQuery) { @@ -370,19 +391,209 @@ func newDssePaginateArgs(rv map[string]any) *dssePaginateArgs { return args } +// CollectFields tells the query-builder to eagerly load connected nodes by resolver context. +func (m *MappingQuery) CollectFields(ctx context.Context, satisfies ...string) (*MappingQuery, error) { + fc := graphql.GetFieldContext(ctx) + if fc == nil { + return m, nil + } + if err := m.collectField(ctx, false, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { + return nil, err + } + return m, nil +} + +func (m *MappingQuery) collectField(ctx context.Context, oneNode bool, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { + path = append([]string(nil), path...) + var ( + unknownSeen bool + fieldSeen = make(map[string]struct{}, len(mapping.Columns)) + selectedFields = []string{mapping.FieldID} + ) + for _, field := range graphql.CollectFields(opCtx, collected.Selections, satisfies) { + switch field.Name { + + case "posix": + var ( + alias = field.Alias + path = append(path, alias) + query = (&PosixClient{config: m.config}).Query() + ) + if err := query.collectField(ctx, false, opCtx, field, path, mayAddCondition(satisfies, posixImplementors)...); err != nil { + return err + } + m.WithNamedPosix(alias, func(wq *PosixQuery) { + *wq = *query + }) + + case "omnitrail": + var ( + alias = field.Alias + path = append(path, alias) + query = (&OmnitrailClient{config: m.config}).Query() + ) + if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, omnitrailImplementors)...); err != nil { + return err + } + m.withOmnitrail = query + case "path": + if _, ok := fieldSeen[mapping.FieldPath]; !ok { + selectedFields = append(selectedFields, mapping.FieldPath) + fieldSeen[mapping.FieldPath] = struct{}{} + } + case "type": + if _, ok := fieldSeen[mapping.FieldType]; !ok { + selectedFields = append(selectedFields, mapping.FieldType) + fieldSeen[mapping.FieldType] = struct{}{} + } + case "sha1": + if _, ok := fieldSeen[mapping.FieldSha1]; !ok { + selectedFields = append(selectedFields, mapping.FieldSha1) + fieldSeen[mapping.FieldSha1] = struct{}{} + } + case "sha256": + if _, ok := fieldSeen[mapping.FieldSha256]; !ok { + selectedFields = append(selectedFields, mapping.FieldSha256) + fieldSeen[mapping.FieldSha256] = struct{}{} + } + case "gitoidsha1": + if _, ok := fieldSeen[mapping.FieldGitoidSha1]; !ok { + selectedFields = append(selectedFields, mapping.FieldGitoidSha1) + fieldSeen[mapping.FieldGitoidSha1] = struct{}{} + } + case "gitoidsha256": + if _, ok := fieldSeen[mapping.FieldGitoidSha256]; !ok { + selectedFields = append(selectedFields, mapping.FieldGitoidSha256) + fieldSeen[mapping.FieldGitoidSha256] = struct{}{} + } + case "id": + case "__typename": + default: + unknownSeen = true + } + } + if !unknownSeen { + m.Select(selectedFields...) + } + return nil +} + +type mappingPaginateArgs struct { + first, last *int + after, before *Cursor + opts []MappingPaginateOption +} + +func newMappingPaginateArgs(rv map[string]any) *mappingPaginateArgs { + args := &mappingPaginateArgs{} + if rv == nil { + return args + } + if v := rv[firstField]; v != nil { + args.first = v.(*int) + } + if v := rv[lastField]; v != nil { + args.last = v.(*int) + } + if v := rv[afterField]; v != nil { + args.after = v.(*Cursor) + } + if v := rv[beforeField]; v != nil { + args.before = v.(*Cursor) + } + if v, ok := rv[whereField].(*MappingWhereInput); ok { + args.opts = append(args.opts, WithMappingFilter(v.Filter)) + } + return args +} + +// CollectFields tells the query-builder to eagerly load connected nodes by resolver context. +func (o *OmnitrailQuery) CollectFields(ctx context.Context, satisfies ...string) (*OmnitrailQuery, error) { + fc := graphql.GetFieldContext(ctx) + if fc == nil { + return o, nil + } + if err := o.collectField(ctx, false, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { + return nil, err + } + return o, nil +} + +func (o *OmnitrailQuery) collectField(ctx context.Context, oneNode bool, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { + path = append([]string(nil), path...) + for _, field := range graphql.CollectFields(opCtx, collected.Selections, satisfies) { + switch field.Name { + + case "mappings": + var ( + alias = field.Alias + path = append(path, alias) + query = (&MappingClient{config: o.config}).Query() + ) + if err := query.collectField(ctx, false, opCtx, field, path, mayAddCondition(satisfies, mappingImplementors)...); err != nil { + return err + } + o.WithNamedMappings(alias, func(wq *MappingQuery) { + *wq = *query + }) + + case "attestation": + var ( + alias = field.Alias + path = append(path, alias) + query = (&AttestationClient{config: o.config}).Query() + ) + if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, attestationImplementors)...); err != nil { + return err + } + o.withAttestation = query + } + } + return nil +} + +type omnitrailPaginateArgs struct { + first, last *int + after, before *Cursor + opts []OmnitrailPaginateOption +} + +func newOmnitrailPaginateArgs(rv map[string]any) *omnitrailPaginateArgs { + args := &omnitrailPaginateArgs{} + if rv == nil { + return args + } + if v := rv[firstField]; v != nil { + args.first = v.(*int) + } + if v := rv[lastField]; v != nil { + args.last = v.(*int) + } + if v := rv[afterField]; v != nil { + args.after = v.(*Cursor) + } + if v := rv[beforeField]; v != nil { + args.before = v.(*Cursor) + } + if v, ok := rv[whereField].(*OmnitrailWhereInput); ok { + args.opts = append(args.opts, WithOmnitrailFilter(v.Filter)) + } + return args +} + // CollectFields tells the query-builder to eagerly load connected nodes by resolver context. func (pd *PayloadDigestQuery) CollectFields(ctx context.Context, satisfies ...string) (*PayloadDigestQuery, error) { fc := graphql.GetFieldContext(ctx) if fc == nil { return pd, nil } - if err := pd.collectField(ctx, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { + if err := pd.collectField(ctx, false, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { return nil, err } return pd, nil } -func (pd *PayloadDigestQuery) collectField(ctx context.Context, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { +func (pd *PayloadDigestQuery) collectField(ctx context.Context, oneNode bool, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { path = append([]string(nil), path...) var ( unknownSeen bool @@ -391,13 +602,14 @@ func (pd *PayloadDigestQuery) collectField(ctx context.Context, opCtx *graphql.O ) for _, field := range graphql.CollectFields(opCtx, collected.Selections, satisfies) { switch field.Name { + case "dsse": var ( alias = field.Alias path = append(path, alias) query = (&DsseClient{config: pd.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, dsseImplementors)...); err != nil { return err } pd.withDsse = query @@ -452,19 +664,172 @@ func newPayloadDigestPaginateArgs(rv map[string]any) *payloaddigestPaginateArgs return args } +// CollectFields tells the query-builder to eagerly load connected nodes by resolver context. +func (po *PosixQuery) CollectFields(ctx context.Context, satisfies ...string) (*PosixQuery, error) { + fc := graphql.GetFieldContext(ctx) + if fc == nil { + return po, nil + } + if err := po.collectField(ctx, false, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { + return nil, err + } + return po, nil +} + +func (po *PosixQuery) collectField(ctx context.Context, oneNode bool, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { + path = append([]string(nil), path...) + var ( + unknownSeen bool + fieldSeen = make(map[string]struct{}, len(posix.Columns)) + selectedFields = []string{posix.FieldID} + ) + for _, field := range graphql.CollectFields(opCtx, collected.Selections, satisfies) { + switch field.Name { + + case "mapping": + var ( + alias = field.Alias + path = append(path, alias) + query = (&MappingClient{config: po.config}).Query() + ) + if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, mappingImplementors)...); err != nil { + return err + } + po.withMapping = query + case "atime": + if _, ok := fieldSeen[posix.FieldAtime]; !ok { + selectedFields = append(selectedFields, posix.FieldAtime) + fieldSeen[posix.FieldAtime] = struct{}{} + } + case "ctime": + if _, ok := fieldSeen[posix.FieldCtime]; !ok { + selectedFields = append(selectedFields, posix.FieldCtime) + fieldSeen[posix.FieldCtime] = struct{}{} + } + case "creationTime": + if _, ok := fieldSeen[posix.FieldCreationTime]; !ok { + selectedFields = append(selectedFields, posix.FieldCreationTime) + fieldSeen[posix.FieldCreationTime] = struct{}{} + } + case "extendedAttributes": + if _, ok := fieldSeen[posix.FieldExtendedAttributes]; !ok { + selectedFields = append(selectedFields, posix.FieldExtendedAttributes) + fieldSeen[posix.FieldExtendedAttributes] = struct{}{} + } + case "fileDeviceID": + if _, ok := fieldSeen[posix.FieldFileDeviceID]; !ok { + selectedFields = append(selectedFields, posix.FieldFileDeviceID) + fieldSeen[posix.FieldFileDeviceID] = struct{}{} + } + case "fileFlags": + if _, ok := fieldSeen[posix.FieldFileFlags]; !ok { + selectedFields = append(selectedFields, posix.FieldFileFlags) + fieldSeen[posix.FieldFileFlags] = struct{}{} + } + case "fileInode": + if _, ok := fieldSeen[posix.FieldFileInode]; !ok { + selectedFields = append(selectedFields, posix.FieldFileInode) + fieldSeen[posix.FieldFileInode] = struct{}{} + } + case "fileSystemID": + if _, ok := fieldSeen[posix.FieldFileSystemID]; !ok { + selectedFields = append(selectedFields, posix.FieldFileSystemID) + fieldSeen[posix.FieldFileSystemID] = struct{}{} + } + case "fileType": + if _, ok := fieldSeen[posix.FieldFileType]; !ok { + selectedFields = append(selectedFields, posix.FieldFileType) + fieldSeen[posix.FieldFileType] = struct{}{} + } + case "hardLinkCount": + if _, ok := fieldSeen[posix.FieldHardLinkCount]; !ok { + selectedFields = append(selectedFields, posix.FieldHardLinkCount) + fieldSeen[posix.FieldHardLinkCount] = struct{}{} + } + case "mtime": + if _, ok := fieldSeen[posix.FieldMtime]; !ok { + selectedFields = append(selectedFields, posix.FieldMtime) + fieldSeen[posix.FieldMtime] = struct{}{} + } + case "metadataCtime": + if _, ok := fieldSeen[posix.FieldMetadataCtime]; !ok { + selectedFields = append(selectedFields, posix.FieldMetadataCtime) + fieldSeen[posix.FieldMetadataCtime] = struct{}{} + } + case "ownerGid": + if _, ok := fieldSeen[posix.FieldOwnerGid]; !ok { + selectedFields = append(selectedFields, posix.FieldOwnerGid) + fieldSeen[posix.FieldOwnerGid] = struct{}{} + } + case "ownerUID": + if _, ok := fieldSeen[posix.FieldOwnerUID]; !ok { + selectedFields = append(selectedFields, posix.FieldOwnerUID) + fieldSeen[posix.FieldOwnerUID] = struct{}{} + } + case "permissions": + if _, ok := fieldSeen[posix.FieldPermissions]; !ok { + selectedFields = append(selectedFields, posix.FieldPermissions) + fieldSeen[posix.FieldPermissions] = struct{}{} + } + case "size": + if _, ok := fieldSeen[posix.FieldSize]; !ok { + selectedFields = append(selectedFields, posix.FieldSize) + fieldSeen[posix.FieldSize] = struct{}{} + } + case "id": + case "__typename": + default: + unknownSeen = true + } + } + if !unknownSeen { + po.Select(selectedFields...) + } + return nil +} + +type posixPaginateArgs struct { + first, last *int + after, before *Cursor + opts []PosixPaginateOption +} + +func newPosixPaginateArgs(rv map[string]any) *posixPaginateArgs { + args := &posixPaginateArgs{} + if rv == nil { + return args + } + if v := rv[firstField]; v != nil { + args.first = v.(*int) + } + if v := rv[lastField]; v != nil { + args.last = v.(*int) + } + if v := rv[afterField]; v != nil { + args.after = v.(*Cursor) + } + if v := rv[beforeField]; v != nil { + args.before = v.(*Cursor) + } + if v, ok := rv[whereField].(*PosixWhereInput); ok { + args.opts = append(args.opts, WithPosixFilter(v.Filter)) + } + return args +} + // CollectFields tells the query-builder to eagerly load connected nodes by resolver context. func (s *SignatureQuery) CollectFields(ctx context.Context, satisfies ...string) (*SignatureQuery, error) { fc := graphql.GetFieldContext(ctx) if fc == nil { return s, nil } - if err := s.collectField(ctx, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { + if err := s.collectField(ctx, false, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { return nil, err } return s, nil } -func (s *SignatureQuery) collectField(ctx context.Context, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { +func (s *SignatureQuery) collectField(ctx context.Context, oneNode bool, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { path = append([]string(nil), path...) var ( unknownSeen bool @@ -473,23 +838,25 @@ func (s *SignatureQuery) collectField(ctx context.Context, opCtx *graphql.Operat ) for _, field := range graphql.CollectFields(opCtx, collected.Selections, satisfies) { switch field.Name { + case "dsse": var ( alias = field.Alias path = append(path, alias) query = (&DsseClient{config: s.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, dsseImplementors)...); err != nil { return err } s.withDsse = query + case "timestamps": var ( alias = field.Alias path = append(path, alias) query = (&TimestampClient{config: s.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, false, opCtx, field, path, mayAddCondition(satisfies, timestampImplementors)...); err != nil { return err } s.WithNamedTimestamps(alias, func(wq *TimestampQuery) { @@ -552,13 +919,13 @@ func (s *StatementQuery) CollectFields(ctx context.Context, satisfies ...string) if fc == nil { return s, nil } - if err := s.collectField(ctx, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { + if err := s.collectField(ctx, false, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { return nil, err } return s, nil } -func (s *StatementQuery) collectField(ctx context.Context, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { +func (s *StatementQuery) collectField(ctx context.Context, oneNode bool, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { path = append([]string(nil), path...) var ( unknownSeen bool @@ -567,6 +934,7 @@ func (s *StatementQuery) collectField(ctx context.Context, opCtx *graphql.Operat ) for _, field := range graphql.CollectFields(opCtx, collected.Selections, satisfies) { switch field.Name { + case "subjects": var ( alias = field.Alias @@ -638,46 +1006,53 @@ func (s *StatementQuery) collectField(ctx context.Context, opCtx *graphql.Operat } path = append(path, edgesField, nodeField) if field := collectedField(ctx, path...); field != nil { - if err := query.collectField(ctx, opCtx, *field, path, mayAddCondition(satisfies, "Subject")...); err != nil { + if err := query.collectField(ctx, false, opCtx, *field, path, mayAddCondition(satisfies, subjectImplementors)...); err != nil { return err } } if limit := paginateLimit(args.first, args.last); limit > 0 { - modify := limitRows(statement.SubjectsColumn, limit, pager.orderExpr(query)) - query.modifiers = append(query.modifiers, modify) + if oneNode { + pager.applyOrder(query.Limit(limit)) + } else { + modify := entgql.LimitPerRow(statement.SubjectsColumn, limit, pager.orderExpr(query)) + query.modifiers = append(query.modifiers, modify) + } } else { query = pager.applyOrder(query) } s.WithNamedSubjects(alias, func(wq *SubjectQuery) { *wq = *query }) + case "policy": var ( alias = field.Alias path = append(path, alias) query = (&AttestationPolicyClient{config: s.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, attestationpolicyImplementors)...); err != nil { return err } s.withPolicy = query + case "attestationCollections": var ( alias = field.Alias path = append(path, alias) query = (&AttestationCollectionClient{config: s.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, attestationcollectionImplementors)...); err != nil { return err } s.withAttestationCollections = query + case "dsse": var ( alias = field.Alias path = append(path, alias) query = (&DsseClient{config: s.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, false, opCtx, field, path, mayAddCondition(satisfies, dsseImplementors)...); err != nil { return err } s.WithNamedDsse(alias, func(wq *DsseQuery) { @@ -735,13 +1110,13 @@ func (s *SubjectQuery) CollectFields(ctx context.Context, satisfies ...string) ( if fc == nil { return s, nil } - if err := s.collectField(ctx, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { + if err := s.collectField(ctx, false, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { return nil, err } return s, nil } -func (s *SubjectQuery) collectField(ctx context.Context, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { +func (s *SubjectQuery) collectField(ctx context.Context, oneNode bool, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { path = append([]string(nil), path...) var ( unknownSeen bool @@ -750,25 +1125,27 @@ func (s *SubjectQuery) collectField(ctx context.Context, opCtx *graphql.Operatio ) for _, field := range graphql.CollectFields(opCtx, collected.Selections, satisfies) { switch field.Name { + case "subjectDigests": var ( alias = field.Alias path = append(path, alias) query = (&SubjectDigestClient{config: s.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, false, opCtx, field, path, mayAddCondition(satisfies, subjectdigestImplementors)...); err != nil { return err } s.WithNamedSubjectDigests(alias, func(wq *SubjectDigestQuery) { *wq = *query }) + case "statement": var ( alias = field.Alias path = append(path, alias) query = (&StatementClient{config: s.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, statementImplementors)...); err != nil { return err } s.withStatement = query @@ -824,13 +1201,13 @@ func (sd *SubjectDigestQuery) CollectFields(ctx context.Context, satisfies ...st if fc == nil { return sd, nil } - if err := sd.collectField(ctx, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { + if err := sd.collectField(ctx, false, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { return nil, err } return sd, nil } -func (sd *SubjectDigestQuery) collectField(ctx context.Context, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { +func (sd *SubjectDigestQuery) collectField(ctx context.Context, oneNode bool, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { path = append([]string(nil), path...) var ( unknownSeen bool @@ -839,13 +1216,14 @@ func (sd *SubjectDigestQuery) collectField(ctx context.Context, opCtx *graphql.O ) for _, field := range graphql.CollectFields(opCtx, collected.Selections, satisfies) { switch field.Name { + case "subject": var ( alias = field.Alias path = append(path, alias) query = (&SubjectClient{config: sd.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, subjectImplementors)...); err != nil { return err } sd.withSubject = query @@ -906,13 +1284,13 @@ func (t *TimestampQuery) CollectFields(ctx context.Context, satisfies ...string) if fc == nil { return t, nil } - if err := t.collectField(ctx, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { + if err := t.collectField(ctx, false, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { return nil, err } return t, nil } -func (t *TimestampQuery) collectField(ctx context.Context, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { +func (t *TimestampQuery) collectField(ctx context.Context, oneNode bool, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { path = append([]string(nil), path...) var ( unknownSeen bool @@ -921,13 +1299,14 @@ func (t *TimestampQuery) collectField(ctx context.Context, opCtx *graphql.Operat ) for _, field := range graphql.CollectFields(opCtx, collected.Selections, satisfies) { switch field.Name { + case "signature": var ( alias = field.Alias path = append(path, alias) query = (&SignatureClient{config: t.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, signatureImplementors)...); err != nil { return err } t.withSignature = query @@ -1034,39 +1413,17 @@ func unmarshalArgs(ctx context.Context, whereInput any, args map[string]any) map return args } -func limitRows(partitionBy string, limit int, orderBy ...sql.Querier) func(s *sql.Selector) { - return func(s *sql.Selector) { - d := sql.Dialect(s.Dialect()) - s.SetDistinct(false) - with := d.With("src_query"). - As(s.Clone()). - With("limited_query"). - As( - d.Select("*"). - AppendSelectExprAs( - sql.RowNumber().PartitionBy(partitionBy).OrderExpr(orderBy...), - "row_number", - ). - From(d.Table("src_query")), - ) - t := d.Table("limited_query").As(s.TableName()) - *s = *d.Select(s.UnqualifiedColumns()...). - From(t). - Where(sql.LTE(t.C("row_number"), limit)). - Prefix(with) - } -} - // mayAddCondition appends another type condition to the satisfies list -// if condition is enabled (Node/Nodes) and it does not exist in the list. -func mayAddCondition(satisfies []string, typeCond string) []string { - if len(satisfies) == 0 { - return satisfies - } - for _, s := range satisfies { - if typeCond == s { - return satisfies +// if it does not exist in the list. +func mayAddCondition(satisfies []string, typeCond []string) []string { +Cond: + for _, c := range typeCond { + for _, s := range satisfies { + if c == s { + continue Cond + } } + satisfies = append(satisfies, c) } - return append(satisfies, typeCond) + return satisfies } diff --git a/ent/gql_edge.go b/ent/gql_edge.go index 19957b71..205e68c3 100644 --- a/ent/gql_edge.go +++ b/ent/gql_edge.go @@ -8,6 +8,14 @@ import ( "github.com/99designs/gqlgen/graphql" ) +func (a *Attestation) Omnitrail(ctx context.Context) (*Omnitrail, error) { + result, err := a.Edges.OmnitrailOrErr() + if IsNotLoaded(err) { + result, err = a.QueryOmnitrail().Only(ctx) + } + return result, MaskNotFound(err) +} + func (a *Attestation) AttestationCollection(ctx context.Context) (*AttestationCollection, error) { result, err := a.Edges.AttestationCollectionOrErr() if IsNotLoaded(err) { @@ -76,6 +84,46 @@ func (d *Dsse) PayloadDigests(ctx context.Context) (result []*PayloadDigest, err return result, err } +func (m *Mapping) Posix(ctx context.Context) (result []*Posix, err error) { + if fc := graphql.GetFieldContext(ctx); fc != nil && fc.Field.Alias != "" { + result, err = m.NamedPosix(graphql.GetFieldContext(ctx).Field.Alias) + } else { + result, err = m.Edges.PosixOrErr() + } + if IsNotLoaded(err) { + result, err = m.QueryPosix().All(ctx) + } + return result, err +} + +func (m *Mapping) Omnitrail(ctx context.Context) (*Omnitrail, error) { + result, err := m.Edges.OmnitrailOrErr() + if IsNotLoaded(err) { + result, err = m.QueryOmnitrail().Only(ctx) + } + return result, err +} + +func (o *Omnitrail) Mappings(ctx context.Context) (result []*Mapping, err error) { + if fc := graphql.GetFieldContext(ctx); fc != nil && fc.Field.Alias != "" { + result, err = o.NamedMappings(graphql.GetFieldContext(ctx).Field.Alias) + } else { + result, err = o.Edges.MappingsOrErr() + } + if IsNotLoaded(err) { + result, err = o.QueryMappings().All(ctx) + } + return result, err +} + +func (o *Omnitrail) Attestation(ctx context.Context) (*Attestation, error) { + result, err := o.Edges.AttestationOrErr() + if IsNotLoaded(err) { + result, err = o.QueryAttestation().Only(ctx) + } + return result, err +} + func (pd *PayloadDigest) Dsse(ctx context.Context) (*Dsse, error) { result, err := pd.Edges.DsseOrErr() if IsNotLoaded(err) { @@ -84,6 +132,14 @@ func (pd *PayloadDigest) Dsse(ctx context.Context) (*Dsse, error) { return result, MaskNotFound(err) } +func (po *Posix) Mapping(ctx context.Context) (*Mapping, error) { + result, err := po.Edges.MappingOrErr() + if IsNotLoaded(err) { + result, err = po.QueryMapping().Only(ctx) + } + return result, err +} + func (s *Signature) Dsse(ctx context.Context) (*Dsse, error) { result, err := s.Edges.DsseOrErr() if IsNotLoaded(err) { diff --git a/ent/gql_node.go b/ent/gql_node.go index fa4943fa..ad9d1eaa 100644 --- a/ent/gql_node.go +++ b/ent/gql_node.go @@ -18,7 +18,10 @@ import ( "github.com/in-toto/archivista/ent/attestationcollection" "github.com/in-toto/archivista/ent/attestationpolicy" "github.com/in-toto/archivista/ent/dsse" + "github.com/in-toto/archivista/ent/mapping" + "github.com/in-toto/archivista/ent/omnitrail" "github.com/in-toto/archivista/ent/payloaddigest" + "github.com/in-toto/archivista/ent/posix" "github.com/in-toto/archivista/ent/signature" "github.com/in-toto/archivista/ent/statement" "github.com/in-toto/archivista/ent/subject" @@ -32,35 +35,70 @@ type Noder interface { IsNode() } +var attestationImplementors = []string{"Attestation", "Node"} + +// IsNode implements the Node interface check for GQLGen. +func (*Attestation) IsNode() {} + +var attestationcollectionImplementors = []string{"AttestationCollection", "Node"} + // IsNode implements the Node interface check for GQLGen. -func (n *Attestation) IsNode() {} +func (*AttestationCollection) IsNode() {} + +var attestationpolicyImplementors = []string{"AttestationPolicy", "Node"} // IsNode implements the Node interface check for GQLGen. -func (n *AttestationCollection) IsNode() {} +func (*AttestationPolicy) IsNode() {} + +var dsseImplementors = []string{"Dsse", "Node"} // IsNode implements the Node interface check for GQLGen. -func (n *AttestationPolicy) IsNode() {} +func (*Dsse) IsNode() {} + +var mappingImplementors = []string{"Mapping", "Node"} // IsNode implements the Node interface check for GQLGen. -func (n *Dsse) IsNode() {} +func (*Mapping) IsNode() {} + +var omnitrailImplementors = []string{"Omnitrail", "Node"} // IsNode implements the Node interface check for GQLGen. -func (n *PayloadDigest) IsNode() {} +func (*Omnitrail) IsNode() {} + +var payloaddigestImplementors = []string{"PayloadDigest", "Node"} + +// IsNode implements the Node interface check for GQLGen. +func (*PayloadDigest) IsNode() {} + +var posixImplementors = []string{"Posix", "Node"} + +// IsNode implements the Node interface check for GQLGen. +func (*Posix) IsNode() {} + +var signatureImplementors = []string{"Signature", "Node"} // IsNode implements the Node interface check for GQLGen. -func (n *Signature) IsNode() {} +func (*Signature) IsNode() {} + +var statementImplementors = []string{"Statement", "Node"} // IsNode implements the Node interface check for GQLGen. -func (n *Statement) IsNode() {} +func (*Statement) IsNode() {} + +var subjectImplementors = []string{"Subject", "Node"} // IsNode implements the Node interface check for GQLGen. -func (n *Subject) IsNode() {} +func (*Subject) IsNode() {} + +var subjectdigestImplementors = []string{"SubjectDigest", "Node"} // IsNode implements the Node interface check for GQLGen. -func (n *SubjectDigest) IsNode() {} +func (*SubjectDigest) IsNode() {} + +var timestampImplementors = []string{"Timestamp", "Node"} // IsNode implements the Node interface check for GQLGen. -func (n *Timestamp) IsNode() {} +func (*Timestamp) IsNode() {} var errNodeInvalidID = &NotFoundError{"node"} @@ -123,123 +161,120 @@ func (c *Client) noder(ctx context.Context, table string, id int) (Noder, error) case attestation.Table: query := c.Attestation.Query(). Where(attestation.ID(id)) - query, err := query.CollectFields(ctx, "Attestation") - if err != nil { - return nil, err - } - n, err := query.Only(ctx) - if err != nil { - return nil, err + if fc := graphql.GetFieldContext(ctx); fc != nil { + if err := query.collectField(ctx, true, graphql.GetOperationContext(ctx), fc.Field, nil, attestationImplementors...); err != nil { + return nil, err + } } - return n, nil + return query.Only(ctx) case attestationcollection.Table: query := c.AttestationCollection.Query(). Where(attestationcollection.ID(id)) - query, err := query.CollectFields(ctx, "AttestationCollection") - if err != nil { - return nil, err - } - n, err := query.Only(ctx) - if err != nil { - return nil, err + if fc := graphql.GetFieldContext(ctx); fc != nil { + if err := query.collectField(ctx, true, graphql.GetOperationContext(ctx), fc.Field, nil, attestationcollectionImplementors...); err != nil { + return nil, err + } } - return n, nil + return query.Only(ctx) case attestationpolicy.Table: query := c.AttestationPolicy.Query(). Where(attestationpolicy.ID(id)) - query, err := query.CollectFields(ctx, "AttestationPolicy") - if err != nil { - return nil, err - } - n, err := query.Only(ctx) - if err != nil { - return nil, err + if fc := graphql.GetFieldContext(ctx); fc != nil { + if err := query.collectField(ctx, true, graphql.GetOperationContext(ctx), fc.Field, nil, attestationpolicyImplementors...); err != nil { + return nil, err + } } - return n, nil + return query.Only(ctx) case dsse.Table: query := c.Dsse.Query(). Where(dsse.ID(id)) - query, err := query.CollectFields(ctx, "Dsse") - if err != nil { - return nil, err + if fc := graphql.GetFieldContext(ctx); fc != nil { + if err := query.collectField(ctx, true, graphql.GetOperationContext(ctx), fc.Field, nil, dsseImplementors...); err != nil { + return nil, err + } } - n, err := query.Only(ctx) - if err != nil { - return nil, err + return query.Only(ctx) + case mapping.Table: + query := c.Mapping.Query(). + Where(mapping.ID(id)) + if fc := graphql.GetFieldContext(ctx); fc != nil { + if err := query.collectField(ctx, true, graphql.GetOperationContext(ctx), fc.Field, nil, mappingImplementors...); err != nil { + return nil, err + } + } + return query.Only(ctx) + case omnitrail.Table: + query := c.Omnitrail.Query(). + Where(omnitrail.ID(id)) + if fc := graphql.GetFieldContext(ctx); fc != nil { + if err := query.collectField(ctx, true, graphql.GetOperationContext(ctx), fc.Field, nil, omnitrailImplementors...); err != nil { + return nil, err + } } - return n, nil + return query.Only(ctx) case payloaddigest.Table: query := c.PayloadDigest.Query(). Where(payloaddigest.ID(id)) - query, err := query.CollectFields(ctx, "PayloadDigest") - if err != nil { - return nil, err + if fc := graphql.GetFieldContext(ctx); fc != nil { + if err := query.collectField(ctx, true, graphql.GetOperationContext(ctx), fc.Field, nil, payloaddigestImplementors...); err != nil { + return nil, err + } } - n, err := query.Only(ctx) - if err != nil { - return nil, err + return query.Only(ctx) + case posix.Table: + query := c.Posix.Query(). + Where(posix.ID(id)) + if fc := graphql.GetFieldContext(ctx); fc != nil { + if err := query.collectField(ctx, true, graphql.GetOperationContext(ctx), fc.Field, nil, posixImplementors...); err != nil { + return nil, err + } } - return n, nil + return query.Only(ctx) case signature.Table: query := c.Signature.Query(). Where(signature.ID(id)) - query, err := query.CollectFields(ctx, "Signature") - if err != nil { - return nil, err - } - n, err := query.Only(ctx) - if err != nil { - return nil, err + if fc := graphql.GetFieldContext(ctx); fc != nil { + if err := query.collectField(ctx, true, graphql.GetOperationContext(ctx), fc.Field, nil, signatureImplementors...); err != nil { + return nil, err + } } - return n, nil + return query.Only(ctx) case statement.Table: query := c.Statement.Query(). Where(statement.ID(id)) - query, err := query.CollectFields(ctx, "Statement") - if err != nil { - return nil, err - } - n, err := query.Only(ctx) - if err != nil { - return nil, err + if fc := graphql.GetFieldContext(ctx); fc != nil { + if err := query.collectField(ctx, true, graphql.GetOperationContext(ctx), fc.Field, nil, statementImplementors...); err != nil { + return nil, err + } } - return n, nil + return query.Only(ctx) case subject.Table: query := c.Subject.Query(). Where(subject.ID(id)) - query, err := query.CollectFields(ctx, "Subject") - if err != nil { - return nil, err - } - n, err := query.Only(ctx) - if err != nil { - return nil, err + if fc := graphql.GetFieldContext(ctx); fc != nil { + if err := query.collectField(ctx, true, graphql.GetOperationContext(ctx), fc.Field, nil, subjectImplementors...); err != nil { + return nil, err + } } - return n, nil + return query.Only(ctx) case subjectdigest.Table: query := c.SubjectDigest.Query(). Where(subjectdigest.ID(id)) - query, err := query.CollectFields(ctx, "SubjectDigest") - if err != nil { - return nil, err - } - n, err := query.Only(ctx) - if err != nil { - return nil, err + if fc := graphql.GetFieldContext(ctx); fc != nil { + if err := query.collectField(ctx, true, graphql.GetOperationContext(ctx), fc.Field, nil, subjectdigestImplementors...); err != nil { + return nil, err + } } - return n, nil + return query.Only(ctx) case timestamp.Table: query := c.Timestamp.Query(). Where(timestamp.ID(id)) - query, err := query.CollectFields(ctx, "Timestamp") - if err != nil { - return nil, err - } - n, err := query.Only(ctx) - if err != nil { - return nil, err + if fc := graphql.GetFieldContext(ctx); fc != nil { + if err := query.collectField(ctx, true, graphql.GetOperationContext(ctx), fc.Field, nil, timestampImplementors...); err != nil { + return nil, err + } } - return n, nil + return query.Only(ctx) default: return nil, fmt.Errorf("cannot resolve noder from table %q: %w", table, errNodeInvalidID) } @@ -316,7 +351,7 @@ func (c *Client) noders(ctx context.Context, table string, ids []int) ([]Noder, case attestation.Table: query := c.Attestation.Query(). Where(attestation.IDIn(ids...)) - query, err := query.CollectFields(ctx, "Attestation") + query, err := query.CollectFields(ctx, attestationImplementors...) if err != nil { return nil, err } @@ -332,7 +367,7 @@ func (c *Client) noders(ctx context.Context, table string, ids []int) ([]Noder, case attestationcollection.Table: query := c.AttestationCollection.Query(). Where(attestationcollection.IDIn(ids...)) - query, err := query.CollectFields(ctx, "AttestationCollection") + query, err := query.CollectFields(ctx, attestationcollectionImplementors...) if err != nil { return nil, err } @@ -348,7 +383,7 @@ func (c *Client) noders(ctx context.Context, table string, ids []int) ([]Noder, case attestationpolicy.Table: query := c.AttestationPolicy.Query(). Where(attestationpolicy.IDIn(ids...)) - query, err := query.CollectFields(ctx, "AttestationPolicy") + query, err := query.CollectFields(ctx, attestationpolicyImplementors...) if err != nil { return nil, err } @@ -364,7 +399,39 @@ func (c *Client) noders(ctx context.Context, table string, ids []int) ([]Noder, case dsse.Table: query := c.Dsse.Query(). Where(dsse.IDIn(ids...)) - query, err := query.CollectFields(ctx, "Dsse") + query, err := query.CollectFields(ctx, dsseImplementors...) + if err != nil { + return nil, err + } + nodes, err := query.All(ctx) + if err != nil { + return nil, err + } + for _, node := range nodes { + for _, noder := range idmap[node.ID] { + *noder = node + } + } + case mapping.Table: + query := c.Mapping.Query(). + Where(mapping.IDIn(ids...)) + query, err := query.CollectFields(ctx, mappingImplementors...) + if err != nil { + return nil, err + } + nodes, err := query.All(ctx) + if err != nil { + return nil, err + } + for _, node := range nodes { + for _, noder := range idmap[node.ID] { + *noder = node + } + } + case omnitrail.Table: + query := c.Omnitrail.Query(). + Where(omnitrail.IDIn(ids...)) + query, err := query.CollectFields(ctx, omnitrailImplementors...) if err != nil { return nil, err } @@ -380,7 +447,23 @@ func (c *Client) noders(ctx context.Context, table string, ids []int) ([]Noder, case payloaddigest.Table: query := c.PayloadDigest.Query(). Where(payloaddigest.IDIn(ids...)) - query, err := query.CollectFields(ctx, "PayloadDigest") + query, err := query.CollectFields(ctx, payloaddigestImplementors...) + if err != nil { + return nil, err + } + nodes, err := query.All(ctx) + if err != nil { + return nil, err + } + for _, node := range nodes { + for _, noder := range idmap[node.ID] { + *noder = node + } + } + case posix.Table: + query := c.Posix.Query(). + Where(posix.IDIn(ids...)) + query, err := query.CollectFields(ctx, posixImplementors...) if err != nil { return nil, err } @@ -396,7 +479,7 @@ func (c *Client) noders(ctx context.Context, table string, ids []int) ([]Noder, case signature.Table: query := c.Signature.Query(). Where(signature.IDIn(ids...)) - query, err := query.CollectFields(ctx, "Signature") + query, err := query.CollectFields(ctx, signatureImplementors...) if err != nil { return nil, err } @@ -412,7 +495,7 @@ func (c *Client) noders(ctx context.Context, table string, ids []int) ([]Noder, case statement.Table: query := c.Statement.Query(). Where(statement.IDIn(ids...)) - query, err := query.CollectFields(ctx, "Statement") + query, err := query.CollectFields(ctx, statementImplementors...) if err != nil { return nil, err } @@ -428,7 +511,7 @@ func (c *Client) noders(ctx context.Context, table string, ids []int) ([]Noder, case subject.Table: query := c.Subject.Query(). Where(subject.IDIn(ids...)) - query, err := query.CollectFields(ctx, "Subject") + query, err := query.CollectFields(ctx, subjectImplementors...) if err != nil { return nil, err } @@ -444,7 +527,7 @@ func (c *Client) noders(ctx context.Context, table string, ids []int) ([]Noder, case subjectdigest.Table: query := c.SubjectDigest.Query(). Where(subjectdigest.IDIn(ids...)) - query, err := query.CollectFields(ctx, "SubjectDigest") + query, err := query.CollectFields(ctx, subjectdigestImplementors...) if err != nil { return nil, err } @@ -460,7 +543,7 @@ func (c *Client) noders(ctx context.Context, table string, ids []int) ([]Noder, case timestamp.Table: query := c.Timestamp.Query(). Where(timestamp.IDIn(ids...)) - query, err := query.CollectFields(ctx, "Timestamp") + query, err := query.CollectFields(ctx, timestampImplementors...) if err != nil { return nil, err } diff --git a/ent/gql_pagination.go b/ent/gql_pagination.go index 28104ef8..397f1759 100644 --- a/ent/gql_pagination.go +++ b/ent/gql_pagination.go @@ -15,7 +15,10 @@ import ( "github.com/in-toto/archivista/ent/attestationcollection" "github.com/in-toto/archivista/ent/attestationpolicy" "github.com/in-toto/archivista/ent/dsse" + "github.com/in-toto/archivista/ent/mapping" + "github.com/in-toto/archivista/ent/omnitrail" "github.com/in-toto/archivista/ent/payloaddigest" + "github.com/in-toto/archivista/ent/posix" "github.com/in-toto/archivista/ent/signature" "github.com/in-toto/archivista/ent/statement" "github.com/in-toto/archivista/ent/subject" @@ -279,7 +282,9 @@ func (a *AttestationQuery) Paginate( if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { - if conn.TotalCount, err = a.Clone().Count(ctx); err != nil { + c := a.Clone() + c.ctx.Fields = nil + if conn.TotalCount, err = c.Count(ctx); err != nil { return nil, err } conn.PageInfo.HasNextPage = first != nil && conn.TotalCount > 0 @@ -292,11 +297,12 @@ func (a *AttestationQuery) Paginate( if a, err = pager.applyCursors(a, after, before); err != nil { return nil, err } - if limit := paginateLimit(first, last); limit != 0 { + limit := paginateLimit(first, last) + if limit != 0 { a.Limit(limit) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := a.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := a.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } @@ -525,7 +531,9 @@ func (ac *AttestationCollectionQuery) Paginate( if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { - if conn.TotalCount, err = ac.Clone().Count(ctx); err != nil { + c := ac.Clone() + c.ctx.Fields = nil + if conn.TotalCount, err = c.Count(ctx); err != nil { return nil, err } conn.PageInfo.HasNextPage = first != nil && conn.TotalCount > 0 @@ -538,11 +546,12 @@ func (ac *AttestationCollectionQuery) Paginate( if ac, err = pager.applyCursors(ac, after, before); err != nil { return nil, err } - if limit := paginateLimit(first, last); limit != 0 { + limit := paginateLimit(first, last) + if limit != 0 { ac.Limit(limit) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := ac.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := ac.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } @@ -771,7 +780,9 @@ func (ap *AttestationPolicyQuery) Paginate( if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { - if conn.TotalCount, err = ap.Clone().Count(ctx); err != nil { + c := ap.Clone() + c.ctx.Fields = nil + if conn.TotalCount, err = c.Count(ctx); err != nil { return nil, err } conn.PageInfo.HasNextPage = first != nil && conn.TotalCount > 0 @@ -784,11 +795,12 @@ func (ap *AttestationPolicyQuery) Paginate( if ap, err = pager.applyCursors(ap, after, before); err != nil { return nil, err } - if limit := paginateLimit(first, last); limit != 0 { + limit := paginateLimit(first, last) + if limit != 0 { ap.Limit(limit) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := ap.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := ap.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } @@ -1017,7 +1029,9 @@ func (d *DsseQuery) Paginate( if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { - if conn.TotalCount, err = d.Clone().Count(ctx); err != nil { + c := d.Clone() + c.ctx.Fields = nil + if conn.TotalCount, err = c.Count(ctx); err != nil { return nil, err } conn.PageInfo.HasNextPage = first != nil && conn.TotalCount > 0 @@ -1030,11 +1044,12 @@ func (d *DsseQuery) Paginate( if d, err = pager.applyCursors(d, after, before); err != nil { return nil, err } - if limit := paginateLimit(first, last); limit != 0 { + limit := paginateLimit(first, last) + if limit != 0 { d.Limit(limit) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := d.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := d.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } @@ -1088,6 +1103,504 @@ func (d *Dsse) ToEdge(order *DsseOrder) *DsseEdge { } } +// MappingEdge is the edge representation of Mapping. +type MappingEdge struct { + Node *Mapping `json:"node"` + Cursor Cursor `json:"cursor"` +} + +// MappingConnection is the connection containing edges to Mapping. +type MappingConnection struct { + Edges []*MappingEdge `json:"edges"` + PageInfo PageInfo `json:"pageInfo"` + TotalCount int `json:"totalCount"` +} + +func (c *MappingConnection) build(nodes []*Mapping, pager *mappingPager, after *Cursor, first *int, before *Cursor, last *int) { + c.PageInfo.HasNextPage = before != nil + c.PageInfo.HasPreviousPage = after != nil + if first != nil && *first+1 == len(nodes) { + c.PageInfo.HasNextPage = true + nodes = nodes[:len(nodes)-1] + } else if last != nil && *last+1 == len(nodes) { + c.PageInfo.HasPreviousPage = true + nodes = nodes[:len(nodes)-1] + } + var nodeAt func(int) *Mapping + if last != nil { + n := len(nodes) - 1 + nodeAt = func(i int) *Mapping { + return nodes[n-i] + } + } else { + nodeAt = func(i int) *Mapping { + return nodes[i] + } + } + c.Edges = make([]*MappingEdge, len(nodes)) + for i := range nodes { + node := nodeAt(i) + c.Edges[i] = &MappingEdge{ + Node: node, + Cursor: pager.toCursor(node), + } + } + if l := len(c.Edges); l > 0 { + c.PageInfo.StartCursor = &c.Edges[0].Cursor + c.PageInfo.EndCursor = &c.Edges[l-1].Cursor + } + if c.TotalCount == 0 { + c.TotalCount = len(nodes) + } +} + +// MappingPaginateOption enables pagination customization. +type MappingPaginateOption func(*mappingPager) error + +// WithMappingOrder configures pagination ordering. +func WithMappingOrder(order *MappingOrder) MappingPaginateOption { + if order == nil { + order = DefaultMappingOrder + } + o := *order + return func(pager *mappingPager) error { + if err := o.Direction.Validate(); err != nil { + return err + } + if o.Field == nil { + o.Field = DefaultMappingOrder.Field + } + pager.order = &o + return nil + } +} + +// WithMappingFilter configures pagination filter. +func WithMappingFilter(filter func(*MappingQuery) (*MappingQuery, error)) MappingPaginateOption { + return func(pager *mappingPager) error { + if filter == nil { + return errors.New("MappingQuery filter cannot be nil") + } + pager.filter = filter + return nil + } +} + +type mappingPager struct { + reverse bool + order *MappingOrder + filter func(*MappingQuery) (*MappingQuery, error) +} + +func newMappingPager(opts []MappingPaginateOption, reverse bool) (*mappingPager, error) { + pager := &mappingPager{reverse: reverse} + for _, opt := range opts { + if err := opt(pager); err != nil { + return nil, err + } + } + if pager.order == nil { + pager.order = DefaultMappingOrder + } + return pager, nil +} + +func (p *mappingPager) applyFilter(query *MappingQuery) (*MappingQuery, error) { + if p.filter != nil { + return p.filter(query) + } + return query, nil +} + +func (p *mappingPager) toCursor(m *Mapping) Cursor { + return p.order.Field.toCursor(m) +} + +func (p *mappingPager) applyCursors(query *MappingQuery, after, before *Cursor) (*MappingQuery, error) { + direction := p.order.Direction + if p.reverse { + direction = direction.Reverse() + } + for _, predicate := range entgql.CursorsPredicate(after, before, DefaultMappingOrder.Field.column, p.order.Field.column, direction) { + query = query.Where(predicate) + } + return query, nil +} + +func (p *mappingPager) applyOrder(query *MappingQuery) *MappingQuery { + direction := p.order.Direction + if p.reverse { + direction = direction.Reverse() + } + query = query.Order(p.order.Field.toTerm(direction.OrderTermOption())) + if p.order.Field != DefaultMappingOrder.Field { + query = query.Order(DefaultMappingOrder.Field.toTerm(direction.OrderTermOption())) + } + if len(query.ctx.Fields) > 0 { + query.ctx.AppendFieldOnce(p.order.Field.column) + } + return query +} + +func (p *mappingPager) orderExpr(query *MappingQuery) sql.Querier { + direction := p.order.Direction + if p.reverse { + direction = direction.Reverse() + } + if len(query.ctx.Fields) > 0 { + query.ctx.AppendFieldOnce(p.order.Field.column) + } + return sql.ExprFunc(func(b *sql.Builder) { + b.Ident(p.order.Field.column).Pad().WriteString(string(direction)) + if p.order.Field != DefaultMappingOrder.Field { + b.Comma().Ident(DefaultMappingOrder.Field.column).Pad().WriteString(string(direction)) + } + }) +} + +// Paginate executes the query and returns a relay based cursor connection to Mapping. +func (m *MappingQuery) Paginate( + ctx context.Context, after *Cursor, first *int, + before *Cursor, last *int, opts ...MappingPaginateOption, +) (*MappingConnection, error) { + if err := validateFirstLast(first, last); err != nil { + return nil, err + } + pager, err := newMappingPager(opts, last != nil) + if err != nil { + return nil, err + } + if m, err = pager.applyFilter(m); err != nil { + return nil, err + } + conn := &MappingConnection{Edges: []*MappingEdge{}} + ignoredEdges := !hasCollectedField(ctx, edgesField) + if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { + hasPagination := after != nil || first != nil || before != nil || last != nil + if hasPagination || ignoredEdges { + c := m.Clone() + c.ctx.Fields = nil + if conn.TotalCount, err = c.Count(ctx); err != nil { + return nil, err + } + conn.PageInfo.HasNextPage = first != nil && conn.TotalCount > 0 + conn.PageInfo.HasPreviousPage = last != nil && conn.TotalCount > 0 + } + } + if ignoredEdges || (first != nil && *first == 0) || (last != nil && *last == 0) { + return conn, nil + } + if m, err = pager.applyCursors(m, after, before); err != nil { + return nil, err + } + limit := paginateLimit(first, last) + if limit != 0 { + m.Limit(limit) + } + if field := collectedField(ctx, edgesField, nodeField); field != nil { + if err := m.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + return nil, err + } + } + m = pager.applyOrder(m) + nodes, err := m.All(ctx) + if err != nil { + return nil, err + } + conn.build(nodes, pager, after, first, before, last) + return conn, nil +} + +// MappingOrderField defines the ordering field of Mapping. +type MappingOrderField struct { + // Value extracts the ordering value from the given Mapping. + Value func(*Mapping) (ent.Value, error) + column string // field or computed. + toTerm func(...sql.OrderTermOption) mapping.OrderOption + toCursor func(*Mapping) Cursor +} + +// MappingOrder defines the ordering of Mapping. +type MappingOrder struct { + Direction OrderDirection `json:"direction"` + Field *MappingOrderField `json:"field"` +} + +// DefaultMappingOrder is the default ordering of Mapping. +var DefaultMappingOrder = &MappingOrder{ + Direction: entgql.OrderDirectionAsc, + Field: &MappingOrderField{ + Value: func(m *Mapping) (ent.Value, error) { + return m.ID, nil + }, + column: mapping.FieldID, + toTerm: mapping.ByID, + toCursor: func(m *Mapping) Cursor { + return Cursor{ID: m.ID} + }, + }, +} + +// ToEdge converts Mapping into MappingEdge. +func (m *Mapping) ToEdge(order *MappingOrder) *MappingEdge { + if order == nil { + order = DefaultMappingOrder + } + return &MappingEdge{ + Node: m, + Cursor: order.Field.toCursor(m), + } +} + +// OmnitrailEdge is the edge representation of Omnitrail. +type OmnitrailEdge struct { + Node *Omnitrail `json:"node"` + Cursor Cursor `json:"cursor"` +} + +// OmnitrailConnection is the connection containing edges to Omnitrail. +type OmnitrailConnection struct { + Edges []*OmnitrailEdge `json:"edges"` + PageInfo PageInfo `json:"pageInfo"` + TotalCount int `json:"totalCount"` +} + +func (c *OmnitrailConnection) build(nodes []*Omnitrail, pager *omnitrailPager, after *Cursor, first *int, before *Cursor, last *int) { + c.PageInfo.HasNextPage = before != nil + c.PageInfo.HasPreviousPage = after != nil + if first != nil && *first+1 == len(nodes) { + c.PageInfo.HasNextPage = true + nodes = nodes[:len(nodes)-1] + } else if last != nil && *last+1 == len(nodes) { + c.PageInfo.HasPreviousPage = true + nodes = nodes[:len(nodes)-1] + } + var nodeAt func(int) *Omnitrail + if last != nil { + n := len(nodes) - 1 + nodeAt = func(i int) *Omnitrail { + return nodes[n-i] + } + } else { + nodeAt = func(i int) *Omnitrail { + return nodes[i] + } + } + c.Edges = make([]*OmnitrailEdge, len(nodes)) + for i := range nodes { + node := nodeAt(i) + c.Edges[i] = &OmnitrailEdge{ + Node: node, + Cursor: pager.toCursor(node), + } + } + if l := len(c.Edges); l > 0 { + c.PageInfo.StartCursor = &c.Edges[0].Cursor + c.PageInfo.EndCursor = &c.Edges[l-1].Cursor + } + if c.TotalCount == 0 { + c.TotalCount = len(nodes) + } +} + +// OmnitrailPaginateOption enables pagination customization. +type OmnitrailPaginateOption func(*omnitrailPager) error + +// WithOmnitrailOrder configures pagination ordering. +func WithOmnitrailOrder(order *OmnitrailOrder) OmnitrailPaginateOption { + if order == nil { + order = DefaultOmnitrailOrder + } + o := *order + return func(pager *omnitrailPager) error { + if err := o.Direction.Validate(); err != nil { + return err + } + if o.Field == nil { + o.Field = DefaultOmnitrailOrder.Field + } + pager.order = &o + return nil + } +} + +// WithOmnitrailFilter configures pagination filter. +func WithOmnitrailFilter(filter func(*OmnitrailQuery) (*OmnitrailQuery, error)) OmnitrailPaginateOption { + return func(pager *omnitrailPager) error { + if filter == nil { + return errors.New("OmnitrailQuery filter cannot be nil") + } + pager.filter = filter + return nil + } +} + +type omnitrailPager struct { + reverse bool + order *OmnitrailOrder + filter func(*OmnitrailQuery) (*OmnitrailQuery, error) +} + +func newOmnitrailPager(opts []OmnitrailPaginateOption, reverse bool) (*omnitrailPager, error) { + pager := &omnitrailPager{reverse: reverse} + for _, opt := range opts { + if err := opt(pager); err != nil { + return nil, err + } + } + if pager.order == nil { + pager.order = DefaultOmnitrailOrder + } + return pager, nil +} + +func (p *omnitrailPager) applyFilter(query *OmnitrailQuery) (*OmnitrailQuery, error) { + if p.filter != nil { + return p.filter(query) + } + return query, nil +} + +func (p *omnitrailPager) toCursor(o *Omnitrail) Cursor { + return p.order.Field.toCursor(o) +} + +func (p *omnitrailPager) applyCursors(query *OmnitrailQuery, after, before *Cursor) (*OmnitrailQuery, error) { + direction := p.order.Direction + if p.reverse { + direction = direction.Reverse() + } + for _, predicate := range entgql.CursorsPredicate(after, before, DefaultOmnitrailOrder.Field.column, p.order.Field.column, direction) { + query = query.Where(predicate) + } + return query, nil +} + +func (p *omnitrailPager) applyOrder(query *OmnitrailQuery) *OmnitrailQuery { + direction := p.order.Direction + if p.reverse { + direction = direction.Reverse() + } + query = query.Order(p.order.Field.toTerm(direction.OrderTermOption())) + if p.order.Field != DefaultOmnitrailOrder.Field { + query = query.Order(DefaultOmnitrailOrder.Field.toTerm(direction.OrderTermOption())) + } + if len(query.ctx.Fields) > 0 { + query.ctx.AppendFieldOnce(p.order.Field.column) + } + return query +} + +func (p *omnitrailPager) orderExpr(query *OmnitrailQuery) sql.Querier { + direction := p.order.Direction + if p.reverse { + direction = direction.Reverse() + } + if len(query.ctx.Fields) > 0 { + query.ctx.AppendFieldOnce(p.order.Field.column) + } + return sql.ExprFunc(func(b *sql.Builder) { + b.Ident(p.order.Field.column).Pad().WriteString(string(direction)) + if p.order.Field != DefaultOmnitrailOrder.Field { + b.Comma().Ident(DefaultOmnitrailOrder.Field.column).Pad().WriteString(string(direction)) + } + }) +} + +// Paginate executes the query and returns a relay based cursor connection to Omnitrail. +func (o *OmnitrailQuery) Paginate( + ctx context.Context, after *Cursor, first *int, + before *Cursor, last *int, opts ...OmnitrailPaginateOption, +) (*OmnitrailConnection, error) { + if err := validateFirstLast(first, last); err != nil { + return nil, err + } + pager, err := newOmnitrailPager(opts, last != nil) + if err != nil { + return nil, err + } + if o, err = pager.applyFilter(o); err != nil { + return nil, err + } + conn := &OmnitrailConnection{Edges: []*OmnitrailEdge{}} + ignoredEdges := !hasCollectedField(ctx, edgesField) + if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { + hasPagination := after != nil || first != nil || before != nil || last != nil + if hasPagination || ignoredEdges { + c := o.Clone() + c.ctx.Fields = nil + if conn.TotalCount, err = c.Count(ctx); err != nil { + return nil, err + } + conn.PageInfo.HasNextPage = first != nil && conn.TotalCount > 0 + conn.PageInfo.HasPreviousPage = last != nil && conn.TotalCount > 0 + } + } + if ignoredEdges || (first != nil && *first == 0) || (last != nil && *last == 0) { + return conn, nil + } + if o, err = pager.applyCursors(o, after, before); err != nil { + return nil, err + } + limit := paginateLimit(first, last) + if limit != 0 { + o.Limit(limit) + } + if field := collectedField(ctx, edgesField, nodeField); field != nil { + if err := o.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + return nil, err + } + } + o = pager.applyOrder(o) + nodes, err := o.All(ctx) + if err != nil { + return nil, err + } + conn.build(nodes, pager, after, first, before, last) + return conn, nil +} + +// OmnitrailOrderField defines the ordering field of Omnitrail. +type OmnitrailOrderField struct { + // Value extracts the ordering value from the given Omnitrail. + Value func(*Omnitrail) (ent.Value, error) + column string // field or computed. + toTerm func(...sql.OrderTermOption) omnitrail.OrderOption + toCursor func(*Omnitrail) Cursor +} + +// OmnitrailOrder defines the ordering of Omnitrail. +type OmnitrailOrder struct { + Direction OrderDirection `json:"direction"` + Field *OmnitrailOrderField `json:"field"` +} + +// DefaultOmnitrailOrder is the default ordering of Omnitrail. +var DefaultOmnitrailOrder = &OmnitrailOrder{ + Direction: entgql.OrderDirectionAsc, + Field: &OmnitrailOrderField{ + Value: func(o *Omnitrail) (ent.Value, error) { + return o.ID, nil + }, + column: omnitrail.FieldID, + toTerm: omnitrail.ByID, + toCursor: func(o *Omnitrail) Cursor { + return Cursor{ID: o.ID} + }, + }, +} + +// ToEdge converts Omnitrail into OmnitrailEdge. +func (o *Omnitrail) ToEdge(order *OmnitrailOrder) *OmnitrailEdge { + if order == nil { + order = DefaultOmnitrailOrder + } + return &OmnitrailEdge{ + Node: o, + Cursor: order.Field.toCursor(o), + } +} + // PayloadDigestEdge is the edge representation of PayloadDigest. type PayloadDigestEdge struct { Node *PayloadDigest `json:"node"` @@ -1263,7 +1776,9 @@ func (pd *PayloadDigestQuery) Paginate( if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { - if conn.TotalCount, err = pd.Clone().Count(ctx); err != nil { + c := pd.Clone() + c.ctx.Fields = nil + if conn.TotalCount, err = c.Count(ctx); err != nil { return nil, err } conn.PageInfo.HasNextPage = first != nil && conn.TotalCount > 0 @@ -1276,11 +1791,12 @@ func (pd *PayloadDigestQuery) Paginate( if pd, err = pager.applyCursors(pd, after, before); err != nil { return nil, err } - if limit := paginateLimit(first, last); limit != 0 { + limit := paginateLimit(first, last) + if limit != 0 { pd.Limit(limit) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := pd.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := pd.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } @@ -1334,6 +1850,255 @@ func (pd *PayloadDigest) ToEdge(order *PayloadDigestOrder) *PayloadDigestEdge { } } +// PosixEdge is the edge representation of Posix. +type PosixEdge struct { + Node *Posix `json:"node"` + Cursor Cursor `json:"cursor"` +} + +// PosixConnection is the connection containing edges to Posix. +type PosixConnection struct { + Edges []*PosixEdge `json:"edges"` + PageInfo PageInfo `json:"pageInfo"` + TotalCount int `json:"totalCount"` +} + +func (c *PosixConnection) build(nodes []*Posix, pager *posixPager, after *Cursor, first *int, before *Cursor, last *int) { + c.PageInfo.HasNextPage = before != nil + c.PageInfo.HasPreviousPage = after != nil + if first != nil && *first+1 == len(nodes) { + c.PageInfo.HasNextPage = true + nodes = nodes[:len(nodes)-1] + } else if last != nil && *last+1 == len(nodes) { + c.PageInfo.HasPreviousPage = true + nodes = nodes[:len(nodes)-1] + } + var nodeAt func(int) *Posix + if last != nil { + n := len(nodes) - 1 + nodeAt = func(i int) *Posix { + return nodes[n-i] + } + } else { + nodeAt = func(i int) *Posix { + return nodes[i] + } + } + c.Edges = make([]*PosixEdge, len(nodes)) + for i := range nodes { + node := nodeAt(i) + c.Edges[i] = &PosixEdge{ + Node: node, + Cursor: pager.toCursor(node), + } + } + if l := len(c.Edges); l > 0 { + c.PageInfo.StartCursor = &c.Edges[0].Cursor + c.PageInfo.EndCursor = &c.Edges[l-1].Cursor + } + if c.TotalCount == 0 { + c.TotalCount = len(nodes) + } +} + +// PosixPaginateOption enables pagination customization. +type PosixPaginateOption func(*posixPager) error + +// WithPosixOrder configures pagination ordering. +func WithPosixOrder(order *PosixOrder) PosixPaginateOption { + if order == nil { + order = DefaultPosixOrder + } + o := *order + return func(pager *posixPager) error { + if err := o.Direction.Validate(); err != nil { + return err + } + if o.Field == nil { + o.Field = DefaultPosixOrder.Field + } + pager.order = &o + return nil + } +} + +// WithPosixFilter configures pagination filter. +func WithPosixFilter(filter func(*PosixQuery) (*PosixQuery, error)) PosixPaginateOption { + return func(pager *posixPager) error { + if filter == nil { + return errors.New("PosixQuery filter cannot be nil") + } + pager.filter = filter + return nil + } +} + +type posixPager struct { + reverse bool + order *PosixOrder + filter func(*PosixQuery) (*PosixQuery, error) +} + +func newPosixPager(opts []PosixPaginateOption, reverse bool) (*posixPager, error) { + pager := &posixPager{reverse: reverse} + for _, opt := range opts { + if err := opt(pager); err != nil { + return nil, err + } + } + if pager.order == nil { + pager.order = DefaultPosixOrder + } + return pager, nil +} + +func (p *posixPager) applyFilter(query *PosixQuery) (*PosixQuery, error) { + if p.filter != nil { + return p.filter(query) + } + return query, nil +} + +func (p *posixPager) toCursor(po *Posix) Cursor { + return p.order.Field.toCursor(po) +} + +func (p *posixPager) applyCursors(query *PosixQuery, after, before *Cursor) (*PosixQuery, error) { + direction := p.order.Direction + if p.reverse { + direction = direction.Reverse() + } + for _, predicate := range entgql.CursorsPredicate(after, before, DefaultPosixOrder.Field.column, p.order.Field.column, direction) { + query = query.Where(predicate) + } + return query, nil +} + +func (p *posixPager) applyOrder(query *PosixQuery) *PosixQuery { + direction := p.order.Direction + if p.reverse { + direction = direction.Reverse() + } + query = query.Order(p.order.Field.toTerm(direction.OrderTermOption())) + if p.order.Field != DefaultPosixOrder.Field { + query = query.Order(DefaultPosixOrder.Field.toTerm(direction.OrderTermOption())) + } + if len(query.ctx.Fields) > 0 { + query.ctx.AppendFieldOnce(p.order.Field.column) + } + return query +} + +func (p *posixPager) orderExpr(query *PosixQuery) sql.Querier { + direction := p.order.Direction + if p.reverse { + direction = direction.Reverse() + } + if len(query.ctx.Fields) > 0 { + query.ctx.AppendFieldOnce(p.order.Field.column) + } + return sql.ExprFunc(func(b *sql.Builder) { + b.Ident(p.order.Field.column).Pad().WriteString(string(direction)) + if p.order.Field != DefaultPosixOrder.Field { + b.Comma().Ident(DefaultPosixOrder.Field.column).Pad().WriteString(string(direction)) + } + }) +} + +// Paginate executes the query and returns a relay based cursor connection to Posix. +func (po *PosixQuery) Paginate( + ctx context.Context, after *Cursor, first *int, + before *Cursor, last *int, opts ...PosixPaginateOption, +) (*PosixConnection, error) { + if err := validateFirstLast(first, last); err != nil { + return nil, err + } + pager, err := newPosixPager(opts, last != nil) + if err != nil { + return nil, err + } + if po, err = pager.applyFilter(po); err != nil { + return nil, err + } + conn := &PosixConnection{Edges: []*PosixEdge{}} + ignoredEdges := !hasCollectedField(ctx, edgesField) + if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { + hasPagination := after != nil || first != nil || before != nil || last != nil + if hasPagination || ignoredEdges { + c := po.Clone() + c.ctx.Fields = nil + if conn.TotalCount, err = c.Count(ctx); err != nil { + return nil, err + } + conn.PageInfo.HasNextPage = first != nil && conn.TotalCount > 0 + conn.PageInfo.HasPreviousPage = last != nil && conn.TotalCount > 0 + } + } + if ignoredEdges || (first != nil && *first == 0) || (last != nil && *last == 0) { + return conn, nil + } + if po, err = pager.applyCursors(po, after, before); err != nil { + return nil, err + } + limit := paginateLimit(first, last) + if limit != 0 { + po.Limit(limit) + } + if field := collectedField(ctx, edgesField, nodeField); field != nil { + if err := po.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + return nil, err + } + } + po = pager.applyOrder(po) + nodes, err := po.All(ctx) + if err != nil { + return nil, err + } + conn.build(nodes, pager, after, first, before, last) + return conn, nil +} + +// PosixOrderField defines the ordering field of Posix. +type PosixOrderField struct { + // Value extracts the ordering value from the given Posix. + Value func(*Posix) (ent.Value, error) + column string // field or computed. + toTerm func(...sql.OrderTermOption) posix.OrderOption + toCursor func(*Posix) Cursor +} + +// PosixOrder defines the ordering of Posix. +type PosixOrder struct { + Direction OrderDirection `json:"direction"` + Field *PosixOrderField `json:"field"` +} + +// DefaultPosixOrder is the default ordering of Posix. +var DefaultPosixOrder = &PosixOrder{ + Direction: entgql.OrderDirectionAsc, + Field: &PosixOrderField{ + Value: func(po *Posix) (ent.Value, error) { + return po.ID, nil + }, + column: posix.FieldID, + toTerm: posix.ByID, + toCursor: func(po *Posix) Cursor { + return Cursor{ID: po.ID} + }, + }, +} + +// ToEdge converts Posix into PosixEdge. +func (po *Posix) ToEdge(order *PosixOrder) *PosixEdge { + if order == nil { + order = DefaultPosixOrder + } + return &PosixEdge{ + Node: po, + Cursor: order.Field.toCursor(po), + } +} + // SignatureEdge is the edge representation of Signature. type SignatureEdge struct { Node *Signature `json:"node"` @@ -1509,7 +2274,9 @@ func (s *SignatureQuery) Paginate( if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { - if conn.TotalCount, err = s.Clone().Count(ctx); err != nil { + c := s.Clone() + c.ctx.Fields = nil + if conn.TotalCount, err = c.Count(ctx); err != nil { return nil, err } conn.PageInfo.HasNextPage = first != nil && conn.TotalCount > 0 @@ -1522,11 +2289,12 @@ func (s *SignatureQuery) Paginate( if s, err = pager.applyCursors(s, after, before); err != nil { return nil, err } - if limit := paginateLimit(first, last); limit != 0 { + limit := paginateLimit(first, last) + if limit != 0 { s.Limit(limit) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := s.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := s.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } @@ -1755,7 +2523,9 @@ func (s *StatementQuery) Paginate( if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { - if conn.TotalCount, err = s.Clone().Count(ctx); err != nil { + c := s.Clone() + c.ctx.Fields = nil + if conn.TotalCount, err = c.Count(ctx); err != nil { return nil, err } conn.PageInfo.HasNextPage = first != nil && conn.TotalCount > 0 @@ -1768,11 +2538,12 @@ func (s *StatementQuery) Paginate( if s, err = pager.applyCursors(s, after, before); err != nil { return nil, err } - if limit := paginateLimit(first, last); limit != 0 { + limit := paginateLimit(first, last) + if limit != 0 { s.Limit(limit) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := s.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := s.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } @@ -2001,7 +2772,9 @@ func (s *SubjectQuery) Paginate( if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { - if conn.TotalCount, err = s.Clone().Count(ctx); err != nil { + c := s.Clone() + c.ctx.Fields = nil + if conn.TotalCount, err = c.Count(ctx); err != nil { return nil, err } conn.PageInfo.HasNextPage = first != nil && conn.TotalCount > 0 @@ -2014,11 +2787,12 @@ func (s *SubjectQuery) Paginate( if s, err = pager.applyCursors(s, after, before); err != nil { return nil, err } - if limit := paginateLimit(first, last); limit != 0 { + limit := paginateLimit(first, last) + if limit != 0 { s.Limit(limit) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := s.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := s.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } @@ -2247,7 +3021,9 @@ func (sd *SubjectDigestQuery) Paginate( if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { - if conn.TotalCount, err = sd.Clone().Count(ctx); err != nil { + c := sd.Clone() + c.ctx.Fields = nil + if conn.TotalCount, err = c.Count(ctx); err != nil { return nil, err } conn.PageInfo.HasNextPage = first != nil && conn.TotalCount > 0 @@ -2260,11 +3036,12 @@ func (sd *SubjectDigestQuery) Paginate( if sd, err = pager.applyCursors(sd, after, before); err != nil { return nil, err } - if limit := paginateLimit(first, last); limit != 0 { + limit := paginateLimit(first, last) + if limit != 0 { sd.Limit(limit) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := sd.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := sd.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } @@ -2493,7 +3270,9 @@ func (t *TimestampQuery) Paginate( if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { - if conn.TotalCount, err = t.Clone().Count(ctx); err != nil { + c := t.Clone() + c.ctx.Fields = nil + if conn.TotalCount, err = c.Count(ctx); err != nil { return nil, err } conn.PageInfo.HasNextPage = first != nil && conn.TotalCount > 0 @@ -2506,11 +3285,12 @@ func (t *TimestampQuery) Paginate( if t, err = pager.applyCursors(t, after, before); err != nil { return nil, err } - if limit := paginateLimit(first, last); limit != 0 { + limit := paginateLimit(first, last) + if limit != 0 { t.Limit(limit) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := t.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := t.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } diff --git a/ent/gql_where_input.go b/ent/gql_where_input.go index 4e511031..e31aee05 100644 --- a/ent/gql_where_input.go +++ b/ent/gql_where_input.go @@ -11,7 +11,10 @@ import ( "github.com/in-toto/archivista/ent/attestationcollection" "github.com/in-toto/archivista/ent/attestationpolicy" "github.com/in-toto/archivista/ent/dsse" + "github.com/in-toto/archivista/ent/mapping" + "github.com/in-toto/archivista/ent/omnitrail" "github.com/in-toto/archivista/ent/payloaddigest" + "github.com/in-toto/archivista/ent/posix" "github.com/in-toto/archivista/ent/predicate" "github.com/in-toto/archivista/ent/signature" "github.com/in-toto/archivista/ent/statement" @@ -52,6 +55,10 @@ type AttestationWhereInput struct { TypeEqualFold *string `json:"typeEqualFold,omitempty"` TypeContainsFold *string `json:"typeContainsFold,omitempty"` + // "omnitrail" edge predicates. + HasOmnitrail *bool `json:"hasOmnitrail,omitempty"` + HasOmnitrailWith []*OmnitrailWhereInput `json:"hasOmnitrailWith,omitempty"` + // "attestation_collection" edge predicates. HasAttestationCollection *bool `json:"hasAttestationCollection,omitempty"` HasAttestationCollectionWith []*AttestationCollectionWhereInput `json:"hasAttestationCollectionWith,omitempty"` @@ -192,6 +199,24 @@ func (i *AttestationWhereInput) P() (predicate.Attestation, error) { predicates = append(predicates, attestation.TypeContainsFold(*i.TypeContainsFold)) } + if i.HasOmnitrail != nil { + p := attestation.HasOmnitrail() + if !*i.HasOmnitrail { + p = attestation.Not(p) + } + predicates = append(predicates, p) + } + if len(i.HasOmnitrailWith) > 0 { + with := make([]predicate.Omnitrail, 0, len(i.HasOmnitrailWith)) + for _, w := range i.HasOmnitrailWith { + p, err := w.P() + if err != nil { + return nil, fmt.Errorf("%w: field 'HasOmnitrailWith'", err) + } + with = append(with, p) + } + predicates = append(predicates, attestation.HasOmnitrailWith(with...)) + } if i.HasAttestationCollection != nil { p := attestation.HasAttestationCollection() if !*i.HasAttestationCollection { @@ -940,12 +965,12 @@ func (i *DsseWhereInput) P() (predicate.Dsse, error) { } } -// PayloadDigestWhereInput represents a where input for filtering PayloadDigest queries. -type PayloadDigestWhereInput struct { - Predicates []predicate.PayloadDigest `json:"-"` - Not *PayloadDigestWhereInput `json:"not,omitempty"` - Or []*PayloadDigestWhereInput `json:"or,omitempty"` - And []*PayloadDigestWhereInput `json:"and,omitempty"` +// MappingWhereInput represents a where input for filtering Mapping queries. +type MappingWhereInput struct { + Predicates []predicate.Mapping `json:"-"` + Not *MappingWhereInput `json:"not,omitempty"` + Or []*MappingWhereInput `json:"or,omitempty"` + And []*MappingWhereInput `json:"and,omitempty"` // "id" field predicates. ID *int `json:"id,omitempty"` @@ -957,54 +982,118 @@ type PayloadDigestWhereInput struct { IDLT *int `json:"idLT,omitempty"` IDLTE *int `json:"idLTE,omitempty"` - // "algorithm" field predicates. - Algorithm *string `json:"algorithm,omitempty"` - AlgorithmNEQ *string `json:"algorithmNEQ,omitempty"` - AlgorithmIn []string `json:"algorithmIn,omitempty"` - AlgorithmNotIn []string `json:"algorithmNotIn,omitempty"` - AlgorithmGT *string `json:"algorithmGT,omitempty"` - AlgorithmGTE *string `json:"algorithmGTE,omitempty"` - AlgorithmLT *string `json:"algorithmLT,omitempty"` - AlgorithmLTE *string `json:"algorithmLTE,omitempty"` - AlgorithmContains *string `json:"algorithmContains,omitempty"` - AlgorithmHasPrefix *string `json:"algorithmHasPrefix,omitempty"` - AlgorithmHasSuffix *string `json:"algorithmHasSuffix,omitempty"` - AlgorithmEqualFold *string `json:"algorithmEqualFold,omitempty"` - AlgorithmContainsFold *string `json:"algorithmContainsFold,omitempty"` + // "path" field predicates. + Path *string `json:"path,omitempty"` + PathNEQ *string `json:"pathNEQ,omitempty"` + PathIn []string `json:"pathIn,omitempty"` + PathNotIn []string `json:"pathNotIn,omitempty"` + PathGT *string `json:"pathGT,omitempty"` + PathGTE *string `json:"pathGTE,omitempty"` + PathLT *string `json:"pathLT,omitempty"` + PathLTE *string `json:"pathLTE,omitempty"` + PathContains *string `json:"pathContains,omitempty"` + PathHasPrefix *string `json:"pathHasPrefix,omitempty"` + PathHasSuffix *string `json:"pathHasSuffix,omitempty"` + PathEqualFold *string `json:"pathEqualFold,omitempty"` + PathContainsFold *string `json:"pathContainsFold,omitempty"` - // "value" field predicates. - Value *string `json:"value,omitempty"` - ValueNEQ *string `json:"valueNEQ,omitempty"` - ValueIn []string `json:"valueIn,omitempty"` - ValueNotIn []string `json:"valueNotIn,omitempty"` - ValueGT *string `json:"valueGT,omitempty"` - ValueGTE *string `json:"valueGTE,omitempty"` - ValueLT *string `json:"valueLT,omitempty"` - ValueLTE *string `json:"valueLTE,omitempty"` - ValueContains *string `json:"valueContains,omitempty"` - ValueHasPrefix *string `json:"valueHasPrefix,omitempty"` - ValueHasSuffix *string `json:"valueHasSuffix,omitempty"` - ValueEqualFold *string `json:"valueEqualFold,omitempty"` - ValueContainsFold *string `json:"valueContainsFold,omitempty"` + // "type" field predicates. + Type *string `json:"type,omitempty"` + TypeNEQ *string `json:"typeNEQ,omitempty"` + TypeIn []string `json:"typeIn,omitempty"` + TypeNotIn []string `json:"typeNotIn,omitempty"` + TypeGT *string `json:"typeGT,omitempty"` + TypeGTE *string `json:"typeGTE,omitempty"` + TypeLT *string `json:"typeLT,omitempty"` + TypeLTE *string `json:"typeLTE,omitempty"` + TypeContains *string `json:"typeContains,omitempty"` + TypeHasPrefix *string `json:"typeHasPrefix,omitempty"` + TypeHasSuffix *string `json:"typeHasSuffix,omitempty"` + TypeEqualFold *string `json:"typeEqualFold,omitempty"` + TypeContainsFold *string `json:"typeContainsFold,omitempty"` - // "dsse" edge predicates. - HasDsse *bool `json:"hasDsse,omitempty"` - HasDsseWith []*DsseWhereInput `json:"hasDsseWith,omitempty"` + // "sha1" field predicates. + Sha1 *string `json:"sha1,omitempty"` + Sha1NEQ *string `json:"sha1NEQ,omitempty"` + Sha1In []string `json:"sha1In,omitempty"` + Sha1NotIn []string `json:"sha1NotIn,omitempty"` + Sha1GT *string `json:"sha1GT,omitempty"` + Sha1GTE *string `json:"sha1GTE,omitempty"` + Sha1LT *string `json:"sha1LT,omitempty"` + Sha1LTE *string `json:"sha1LTE,omitempty"` + Sha1Contains *string `json:"sha1Contains,omitempty"` + Sha1HasPrefix *string `json:"sha1HasPrefix,omitempty"` + Sha1HasSuffix *string `json:"sha1HasSuffix,omitempty"` + Sha1EqualFold *string `json:"sha1EqualFold,omitempty"` + Sha1ContainsFold *string `json:"sha1ContainsFold,omitempty"` + + // "sha256" field predicates. + Sha256 *string `json:"sha256,omitempty"` + Sha256NEQ *string `json:"sha256NEQ,omitempty"` + Sha256In []string `json:"sha256In,omitempty"` + Sha256NotIn []string `json:"sha256NotIn,omitempty"` + Sha256GT *string `json:"sha256GT,omitempty"` + Sha256GTE *string `json:"sha256GTE,omitempty"` + Sha256LT *string `json:"sha256LT,omitempty"` + Sha256LTE *string `json:"sha256LTE,omitempty"` + Sha256Contains *string `json:"sha256Contains,omitempty"` + Sha256HasPrefix *string `json:"sha256HasPrefix,omitempty"` + Sha256HasSuffix *string `json:"sha256HasSuffix,omitempty"` + Sha256EqualFold *string `json:"sha256EqualFold,omitempty"` + Sha256ContainsFold *string `json:"sha256ContainsFold,omitempty"` + + // "gitoidSha1" field predicates. + GitoidSha1 *string `json:"gitoidsha1,omitempty"` + GitoidSha1NEQ *string `json:"gitoidsha1NEQ,omitempty"` + GitoidSha1In []string `json:"gitoidsha1In,omitempty"` + GitoidSha1NotIn []string `json:"gitoidsha1NotIn,omitempty"` + GitoidSha1GT *string `json:"gitoidsha1GT,omitempty"` + GitoidSha1GTE *string `json:"gitoidsha1GTE,omitempty"` + GitoidSha1LT *string `json:"gitoidsha1LT,omitempty"` + GitoidSha1LTE *string `json:"gitoidsha1LTE,omitempty"` + GitoidSha1Contains *string `json:"gitoidsha1Contains,omitempty"` + GitoidSha1HasPrefix *string `json:"gitoidsha1HasPrefix,omitempty"` + GitoidSha1HasSuffix *string `json:"gitoidsha1HasSuffix,omitempty"` + GitoidSha1EqualFold *string `json:"gitoidsha1EqualFold,omitempty"` + GitoidSha1ContainsFold *string `json:"gitoidsha1ContainsFold,omitempty"` + + // "gitoidSha256" field predicates. + GitoidSha256 *string `json:"gitoidsha256,omitempty"` + GitoidSha256NEQ *string `json:"gitoidsha256NEQ,omitempty"` + GitoidSha256In []string `json:"gitoidsha256In,omitempty"` + GitoidSha256NotIn []string `json:"gitoidsha256NotIn,omitempty"` + GitoidSha256GT *string `json:"gitoidsha256GT,omitempty"` + GitoidSha256GTE *string `json:"gitoidsha256GTE,omitempty"` + GitoidSha256LT *string `json:"gitoidsha256LT,omitempty"` + GitoidSha256LTE *string `json:"gitoidsha256LTE,omitempty"` + GitoidSha256Contains *string `json:"gitoidsha256Contains,omitempty"` + GitoidSha256HasPrefix *string `json:"gitoidsha256HasPrefix,omitempty"` + GitoidSha256HasSuffix *string `json:"gitoidsha256HasSuffix,omitempty"` + GitoidSha256EqualFold *string `json:"gitoidsha256EqualFold,omitempty"` + GitoidSha256ContainsFold *string `json:"gitoidsha256ContainsFold,omitempty"` + + // "posix" edge predicates. + HasPosix *bool `json:"hasPosix,omitempty"` + HasPosixWith []*PosixWhereInput `json:"hasPosixWith,omitempty"` + + // "omnitrail" edge predicates. + HasOmnitrail *bool `json:"hasOmnitrail,omitempty"` + HasOmnitrailWith []*OmnitrailWhereInput `json:"hasOmnitrailWith,omitempty"` } // AddPredicates adds custom predicates to the where input to be used during the filtering phase. -func (i *PayloadDigestWhereInput) AddPredicates(predicates ...predicate.PayloadDigest) { +func (i *MappingWhereInput) AddPredicates(predicates ...predicate.Mapping) { i.Predicates = append(i.Predicates, predicates...) } -// Filter applies the PayloadDigestWhereInput filter on the PayloadDigestQuery builder. -func (i *PayloadDigestWhereInput) Filter(q *PayloadDigestQuery) (*PayloadDigestQuery, error) { +// Filter applies the MappingWhereInput filter on the MappingQuery builder. +func (i *MappingWhereInput) Filter(q *MappingQuery) (*MappingQuery, error) { if i == nil { return q, nil } p, err := i.P() if err != nil { - if err == ErrEmptyPayloadDigestWhereInput { + if err == ErrEmptyMappingWhereInput { return q, nil } return nil, err @@ -1012,19 +1101,19 @@ func (i *PayloadDigestWhereInput) Filter(q *PayloadDigestQuery) (*PayloadDigestQ return q.Where(p), nil } -// ErrEmptyPayloadDigestWhereInput is returned in case the PayloadDigestWhereInput is empty. -var ErrEmptyPayloadDigestWhereInput = errors.New("ent: empty predicate PayloadDigestWhereInput") +// ErrEmptyMappingWhereInput is returned in case the MappingWhereInput is empty. +var ErrEmptyMappingWhereInput = errors.New("ent: empty predicate MappingWhereInput") -// P returns a predicate for filtering payloaddigests. +// P returns a predicate for filtering mappings. // An error is returned if the input is empty or invalid. -func (i *PayloadDigestWhereInput) P() (predicate.PayloadDigest, error) { - var predicates []predicate.PayloadDigest +func (i *MappingWhereInput) P() (predicate.Mapping, error) { + var predicates []predicate.Mapping if i.Not != nil { p, err := i.Not.P() if err != nil { return nil, fmt.Errorf("%w: field 'not'", err) } - predicates = append(predicates, payloaddigest.Not(p)) + predicates = append(predicates, mapping.Not(p)) } switch n := len(i.Or); { case n == 1: @@ -1034,7 +1123,7 @@ func (i *PayloadDigestWhereInput) P() (predicate.PayloadDigest, error) { } predicates = append(predicates, p) case n > 1: - or := make([]predicate.PayloadDigest, 0, n) + or := make([]predicate.Mapping, 0, n) for _, w := range i.Or { p, err := w.P() if err != nil { @@ -1042,7 +1131,7 @@ func (i *PayloadDigestWhereInput) P() (predicate.PayloadDigest, error) { } or = append(or, p) } - predicates = append(predicates, payloaddigest.Or(or...)) + predicates = append(predicates, mapping.Or(or...)) } switch n := len(i.And); { case n == 1: @@ -1052,7 +1141,7 @@ func (i *PayloadDigestWhereInput) P() (predicate.PayloadDigest, error) { } predicates = append(predicates, p) case n > 1: - and := make([]predicate.PayloadDigest, 0, n) + and := make([]predicate.Mapping, 0, n) for _, w := range i.And { p, err := w.P() if err != nil { @@ -1060,137 +1149,1743 @@ func (i *PayloadDigestWhereInput) P() (predicate.PayloadDigest, error) { } and = append(and, p) } - predicates = append(predicates, payloaddigest.And(and...)) + predicates = append(predicates, mapping.And(and...)) } predicates = append(predicates, i.Predicates...) if i.ID != nil { - predicates = append(predicates, payloaddigest.IDEQ(*i.ID)) + predicates = append(predicates, mapping.IDEQ(*i.ID)) } if i.IDNEQ != nil { - predicates = append(predicates, payloaddigest.IDNEQ(*i.IDNEQ)) + predicates = append(predicates, mapping.IDNEQ(*i.IDNEQ)) } if len(i.IDIn) > 0 { - predicates = append(predicates, payloaddigest.IDIn(i.IDIn...)) + predicates = append(predicates, mapping.IDIn(i.IDIn...)) } if len(i.IDNotIn) > 0 { - predicates = append(predicates, payloaddigest.IDNotIn(i.IDNotIn...)) + predicates = append(predicates, mapping.IDNotIn(i.IDNotIn...)) } if i.IDGT != nil { - predicates = append(predicates, payloaddigest.IDGT(*i.IDGT)) + predicates = append(predicates, mapping.IDGT(*i.IDGT)) } if i.IDGTE != nil { - predicates = append(predicates, payloaddigest.IDGTE(*i.IDGTE)) + predicates = append(predicates, mapping.IDGTE(*i.IDGTE)) } if i.IDLT != nil { - predicates = append(predicates, payloaddigest.IDLT(*i.IDLT)) + predicates = append(predicates, mapping.IDLT(*i.IDLT)) } if i.IDLTE != nil { - predicates = append(predicates, payloaddigest.IDLTE(*i.IDLTE)) + predicates = append(predicates, mapping.IDLTE(*i.IDLTE)) } - if i.Algorithm != nil { - predicates = append(predicates, payloaddigest.AlgorithmEQ(*i.Algorithm)) + if i.Path != nil { + predicates = append(predicates, mapping.PathEQ(*i.Path)) } - if i.AlgorithmNEQ != nil { - predicates = append(predicates, payloaddigest.AlgorithmNEQ(*i.AlgorithmNEQ)) + if i.PathNEQ != nil { + predicates = append(predicates, mapping.PathNEQ(*i.PathNEQ)) } - if len(i.AlgorithmIn) > 0 { - predicates = append(predicates, payloaddigest.AlgorithmIn(i.AlgorithmIn...)) + if len(i.PathIn) > 0 { + predicates = append(predicates, mapping.PathIn(i.PathIn...)) } - if len(i.AlgorithmNotIn) > 0 { - predicates = append(predicates, payloaddigest.AlgorithmNotIn(i.AlgorithmNotIn...)) + if len(i.PathNotIn) > 0 { + predicates = append(predicates, mapping.PathNotIn(i.PathNotIn...)) } - if i.AlgorithmGT != nil { - predicates = append(predicates, payloaddigest.AlgorithmGT(*i.AlgorithmGT)) + if i.PathGT != nil { + predicates = append(predicates, mapping.PathGT(*i.PathGT)) } - if i.AlgorithmGTE != nil { - predicates = append(predicates, payloaddigest.AlgorithmGTE(*i.AlgorithmGTE)) + if i.PathGTE != nil { + predicates = append(predicates, mapping.PathGTE(*i.PathGTE)) } - if i.AlgorithmLT != nil { - predicates = append(predicates, payloaddigest.AlgorithmLT(*i.AlgorithmLT)) + if i.PathLT != nil { + predicates = append(predicates, mapping.PathLT(*i.PathLT)) } - if i.AlgorithmLTE != nil { - predicates = append(predicates, payloaddigest.AlgorithmLTE(*i.AlgorithmLTE)) + if i.PathLTE != nil { + predicates = append(predicates, mapping.PathLTE(*i.PathLTE)) } - if i.AlgorithmContains != nil { - predicates = append(predicates, payloaddigest.AlgorithmContains(*i.AlgorithmContains)) + if i.PathContains != nil { + predicates = append(predicates, mapping.PathContains(*i.PathContains)) } - if i.AlgorithmHasPrefix != nil { - predicates = append(predicates, payloaddigest.AlgorithmHasPrefix(*i.AlgorithmHasPrefix)) + if i.PathHasPrefix != nil { + predicates = append(predicates, mapping.PathHasPrefix(*i.PathHasPrefix)) } - if i.AlgorithmHasSuffix != nil { - predicates = append(predicates, payloaddigest.AlgorithmHasSuffix(*i.AlgorithmHasSuffix)) + if i.PathHasSuffix != nil { + predicates = append(predicates, mapping.PathHasSuffix(*i.PathHasSuffix)) } - if i.AlgorithmEqualFold != nil { - predicates = append(predicates, payloaddigest.AlgorithmEqualFold(*i.AlgorithmEqualFold)) + if i.PathEqualFold != nil { + predicates = append(predicates, mapping.PathEqualFold(*i.PathEqualFold)) } - if i.AlgorithmContainsFold != nil { - predicates = append(predicates, payloaddigest.AlgorithmContainsFold(*i.AlgorithmContainsFold)) + if i.PathContainsFold != nil { + predicates = append(predicates, mapping.PathContainsFold(*i.PathContainsFold)) } - if i.Value != nil { - predicates = append(predicates, payloaddigest.ValueEQ(*i.Value)) + if i.Type != nil { + predicates = append(predicates, mapping.TypeEQ(*i.Type)) } - if i.ValueNEQ != nil { - predicates = append(predicates, payloaddigest.ValueNEQ(*i.ValueNEQ)) + if i.TypeNEQ != nil { + predicates = append(predicates, mapping.TypeNEQ(*i.TypeNEQ)) } - if len(i.ValueIn) > 0 { - predicates = append(predicates, payloaddigest.ValueIn(i.ValueIn...)) + if len(i.TypeIn) > 0 { + predicates = append(predicates, mapping.TypeIn(i.TypeIn...)) } - if len(i.ValueNotIn) > 0 { - predicates = append(predicates, payloaddigest.ValueNotIn(i.ValueNotIn...)) + if len(i.TypeNotIn) > 0 { + predicates = append(predicates, mapping.TypeNotIn(i.TypeNotIn...)) } - if i.ValueGT != nil { - predicates = append(predicates, payloaddigest.ValueGT(*i.ValueGT)) + if i.TypeGT != nil { + predicates = append(predicates, mapping.TypeGT(*i.TypeGT)) } - if i.ValueGTE != nil { - predicates = append(predicates, payloaddigest.ValueGTE(*i.ValueGTE)) + if i.TypeGTE != nil { + predicates = append(predicates, mapping.TypeGTE(*i.TypeGTE)) } - if i.ValueLT != nil { - predicates = append(predicates, payloaddigest.ValueLT(*i.ValueLT)) + if i.TypeLT != nil { + predicates = append(predicates, mapping.TypeLT(*i.TypeLT)) } - if i.ValueLTE != nil { - predicates = append(predicates, payloaddigest.ValueLTE(*i.ValueLTE)) + if i.TypeLTE != nil { + predicates = append(predicates, mapping.TypeLTE(*i.TypeLTE)) } - if i.ValueContains != nil { - predicates = append(predicates, payloaddigest.ValueContains(*i.ValueContains)) + if i.TypeContains != nil { + predicates = append(predicates, mapping.TypeContains(*i.TypeContains)) } - if i.ValueHasPrefix != nil { - predicates = append(predicates, payloaddigest.ValueHasPrefix(*i.ValueHasPrefix)) + if i.TypeHasPrefix != nil { + predicates = append(predicates, mapping.TypeHasPrefix(*i.TypeHasPrefix)) } - if i.ValueHasSuffix != nil { - predicates = append(predicates, payloaddigest.ValueHasSuffix(*i.ValueHasSuffix)) + if i.TypeHasSuffix != nil { + predicates = append(predicates, mapping.TypeHasSuffix(*i.TypeHasSuffix)) } - if i.ValueEqualFold != nil { - predicates = append(predicates, payloaddigest.ValueEqualFold(*i.ValueEqualFold)) + if i.TypeEqualFold != nil { + predicates = append(predicates, mapping.TypeEqualFold(*i.TypeEqualFold)) } - if i.ValueContainsFold != nil { - predicates = append(predicates, payloaddigest.ValueContainsFold(*i.ValueContainsFold)) + if i.TypeContainsFold != nil { + predicates = append(predicates, mapping.TypeContainsFold(*i.TypeContainsFold)) + } + if i.Sha1 != nil { + predicates = append(predicates, mapping.Sha1EQ(*i.Sha1)) + } + if i.Sha1NEQ != nil { + predicates = append(predicates, mapping.Sha1NEQ(*i.Sha1NEQ)) + } + if len(i.Sha1In) > 0 { + predicates = append(predicates, mapping.Sha1In(i.Sha1In...)) + } + if len(i.Sha1NotIn) > 0 { + predicates = append(predicates, mapping.Sha1NotIn(i.Sha1NotIn...)) + } + if i.Sha1GT != nil { + predicates = append(predicates, mapping.Sha1GT(*i.Sha1GT)) + } + if i.Sha1GTE != nil { + predicates = append(predicates, mapping.Sha1GTE(*i.Sha1GTE)) + } + if i.Sha1LT != nil { + predicates = append(predicates, mapping.Sha1LT(*i.Sha1LT)) + } + if i.Sha1LTE != nil { + predicates = append(predicates, mapping.Sha1LTE(*i.Sha1LTE)) + } + if i.Sha1Contains != nil { + predicates = append(predicates, mapping.Sha1Contains(*i.Sha1Contains)) + } + if i.Sha1HasPrefix != nil { + predicates = append(predicates, mapping.Sha1HasPrefix(*i.Sha1HasPrefix)) + } + if i.Sha1HasSuffix != nil { + predicates = append(predicates, mapping.Sha1HasSuffix(*i.Sha1HasSuffix)) + } + if i.Sha1EqualFold != nil { + predicates = append(predicates, mapping.Sha1EqualFold(*i.Sha1EqualFold)) + } + if i.Sha1ContainsFold != nil { + predicates = append(predicates, mapping.Sha1ContainsFold(*i.Sha1ContainsFold)) + } + if i.Sha256 != nil { + predicates = append(predicates, mapping.Sha256EQ(*i.Sha256)) + } + if i.Sha256NEQ != nil { + predicates = append(predicates, mapping.Sha256NEQ(*i.Sha256NEQ)) + } + if len(i.Sha256In) > 0 { + predicates = append(predicates, mapping.Sha256In(i.Sha256In...)) + } + if len(i.Sha256NotIn) > 0 { + predicates = append(predicates, mapping.Sha256NotIn(i.Sha256NotIn...)) + } + if i.Sha256GT != nil { + predicates = append(predicates, mapping.Sha256GT(*i.Sha256GT)) + } + if i.Sha256GTE != nil { + predicates = append(predicates, mapping.Sha256GTE(*i.Sha256GTE)) + } + if i.Sha256LT != nil { + predicates = append(predicates, mapping.Sha256LT(*i.Sha256LT)) + } + if i.Sha256LTE != nil { + predicates = append(predicates, mapping.Sha256LTE(*i.Sha256LTE)) + } + if i.Sha256Contains != nil { + predicates = append(predicates, mapping.Sha256Contains(*i.Sha256Contains)) + } + if i.Sha256HasPrefix != nil { + predicates = append(predicates, mapping.Sha256HasPrefix(*i.Sha256HasPrefix)) + } + if i.Sha256HasSuffix != nil { + predicates = append(predicates, mapping.Sha256HasSuffix(*i.Sha256HasSuffix)) + } + if i.Sha256EqualFold != nil { + predicates = append(predicates, mapping.Sha256EqualFold(*i.Sha256EqualFold)) + } + if i.Sha256ContainsFold != nil { + predicates = append(predicates, mapping.Sha256ContainsFold(*i.Sha256ContainsFold)) + } + if i.GitoidSha1 != nil { + predicates = append(predicates, mapping.GitoidSha1EQ(*i.GitoidSha1)) + } + if i.GitoidSha1NEQ != nil { + predicates = append(predicates, mapping.GitoidSha1NEQ(*i.GitoidSha1NEQ)) + } + if len(i.GitoidSha1In) > 0 { + predicates = append(predicates, mapping.GitoidSha1In(i.GitoidSha1In...)) + } + if len(i.GitoidSha1NotIn) > 0 { + predicates = append(predicates, mapping.GitoidSha1NotIn(i.GitoidSha1NotIn...)) + } + if i.GitoidSha1GT != nil { + predicates = append(predicates, mapping.GitoidSha1GT(*i.GitoidSha1GT)) + } + if i.GitoidSha1GTE != nil { + predicates = append(predicates, mapping.GitoidSha1GTE(*i.GitoidSha1GTE)) + } + if i.GitoidSha1LT != nil { + predicates = append(predicates, mapping.GitoidSha1LT(*i.GitoidSha1LT)) + } + if i.GitoidSha1LTE != nil { + predicates = append(predicates, mapping.GitoidSha1LTE(*i.GitoidSha1LTE)) + } + if i.GitoidSha1Contains != nil { + predicates = append(predicates, mapping.GitoidSha1Contains(*i.GitoidSha1Contains)) + } + if i.GitoidSha1HasPrefix != nil { + predicates = append(predicates, mapping.GitoidSha1HasPrefix(*i.GitoidSha1HasPrefix)) + } + if i.GitoidSha1HasSuffix != nil { + predicates = append(predicates, mapping.GitoidSha1HasSuffix(*i.GitoidSha1HasSuffix)) + } + if i.GitoidSha1EqualFold != nil { + predicates = append(predicates, mapping.GitoidSha1EqualFold(*i.GitoidSha1EqualFold)) + } + if i.GitoidSha1ContainsFold != nil { + predicates = append(predicates, mapping.GitoidSha1ContainsFold(*i.GitoidSha1ContainsFold)) + } + if i.GitoidSha256 != nil { + predicates = append(predicates, mapping.GitoidSha256EQ(*i.GitoidSha256)) + } + if i.GitoidSha256NEQ != nil { + predicates = append(predicates, mapping.GitoidSha256NEQ(*i.GitoidSha256NEQ)) + } + if len(i.GitoidSha256In) > 0 { + predicates = append(predicates, mapping.GitoidSha256In(i.GitoidSha256In...)) + } + if len(i.GitoidSha256NotIn) > 0 { + predicates = append(predicates, mapping.GitoidSha256NotIn(i.GitoidSha256NotIn...)) + } + if i.GitoidSha256GT != nil { + predicates = append(predicates, mapping.GitoidSha256GT(*i.GitoidSha256GT)) + } + if i.GitoidSha256GTE != nil { + predicates = append(predicates, mapping.GitoidSha256GTE(*i.GitoidSha256GTE)) + } + if i.GitoidSha256LT != nil { + predicates = append(predicates, mapping.GitoidSha256LT(*i.GitoidSha256LT)) + } + if i.GitoidSha256LTE != nil { + predicates = append(predicates, mapping.GitoidSha256LTE(*i.GitoidSha256LTE)) + } + if i.GitoidSha256Contains != nil { + predicates = append(predicates, mapping.GitoidSha256Contains(*i.GitoidSha256Contains)) + } + if i.GitoidSha256HasPrefix != nil { + predicates = append(predicates, mapping.GitoidSha256HasPrefix(*i.GitoidSha256HasPrefix)) + } + if i.GitoidSha256HasSuffix != nil { + predicates = append(predicates, mapping.GitoidSha256HasSuffix(*i.GitoidSha256HasSuffix)) + } + if i.GitoidSha256EqualFold != nil { + predicates = append(predicates, mapping.GitoidSha256EqualFold(*i.GitoidSha256EqualFold)) + } + if i.GitoidSha256ContainsFold != nil { + predicates = append(predicates, mapping.GitoidSha256ContainsFold(*i.GitoidSha256ContainsFold)) } - if i.HasDsse != nil { - p := payloaddigest.HasDsse() - if !*i.HasDsse { - p = payloaddigest.Not(p) + if i.HasPosix != nil { + p := mapping.HasPosix() + if !*i.HasPosix { + p = mapping.Not(p) } predicates = append(predicates, p) } - if len(i.HasDsseWith) > 0 { - with := make([]predicate.Dsse, 0, len(i.HasDsseWith)) - for _, w := range i.HasDsseWith { + if len(i.HasPosixWith) > 0 { + with := make([]predicate.Posix, 0, len(i.HasPosixWith)) + for _, w := range i.HasPosixWith { p, err := w.P() if err != nil { - return nil, fmt.Errorf("%w: field 'HasDsseWith'", err) + return nil, fmt.Errorf("%w: field 'HasPosixWith'", err) } with = append(with, p) } - predicates = append(predicates, payloaddigest.HasDsseWith(with...)) + predicates = append(predicates, mapping.HasPosixWith(with...)) + } + if i.HasOmnitrail != nil { + p := mapping.HasOmnitrail() + if !*i.HasOmnitrail { + p = mapping.Not(p) + } + predicates = append(predicates, p) + } + if len(i.HasOmnitrailWith) > 0 { + with := make([]predicate.Omnitrail, 0, len(i.HasOmnitrailWith)) + for _, w := range i.HasOmnitrailWith { + p, err := w.P() + if err != nil { + return nil, fmt.Errorf("%w: field 'HasOmnitrailWith'", err) + } + with = append(with, p) + } + predicates = append(predicates, mapping.HasOmnitrailWith(with...)) } switch len(predicates) { case 0: - return nil, ErrEmptyPayloadDigestWhereInput + return nil, ErrEmptyMappingWhereInput case 1: return predicates[0], nil default: - return payloaddigest.And(predicates...), nil + return mapping.And(predicates...), nil + } +} + +// OmnitrailWhereInput represents a where input for filtering Omnitrail queries. +type OmnitrailWhereInput struct { + Predicates []predicate.Omnitrail `json:"-"` + Not *OmnitrailWhereInput `json:"not,omitempty"` + Or []*OmnitrailWhereInput `json:"or,omitempty"` + And []*OmnitrailWhereInput `json:"and,omitempty"` + + // "id" field predicates. + ID *int `json:"id,omitempty"` + IDNEQ *int `json:"idNEQ,omitempty"` + IDIn []int `json:"idIn,omitempty"` + IDNotIn []int `json:"idNotIn,omitempty"` + IDGT *int `json:"idGT,omitempty"` + IDGTE *int `json:"idGTE,omitempty"` + IDLT *int `json:"idLT,omitempty"` + IDLTE *int `json:"idLTE,omitempty"` + + // "mappings" edge predicates. + HasMappings *bool `json:"hasMappings,omitempty"` + HasMappingsWith []*MappingWhereInput `json:"hasMappingsWith,omitempty"` + + // "attestation" edge predicates. + HasAttestation *bool `json:"hasAttestation,omitempty"` + HasAttestationWith []*AttestationWhereInput `json:"hasAttestationWith,omitempty"` +} + +// AddPredicates adds custom predicates to the where input to be used during the filtering phase. +func (i *OmnitrailWhereInput) AddPredicates(predicates ...predicate.Omnitrail) { + i.Predicates = append(i.Predicates, predicates...) +} + +// Filter applies the OmnitrailWhereInput filter on the OmnitrailQuery builder. +func (i *OmnitrailWhereInput) Filter(q *OmnitrailQuery) (*OmnitrailQuery, error) { + if i == nil { + return q, nil + } + p, err := i.P() + if err != nil { + if err == ErrEmptyOmnitrailWhereInput { + return q, nil + } + return nil, err + } + return q.Where(p), nil +} + +// ErrEmptyOmnitrailWhereInput is returned in case the OmnitrailWhereInput is empty. +var ErrEmptyOmnitrailWhereInput = errors.New("ent: empty predicate OmnitrailWhereInput") + +// P returns a predicate for filtering omnitrails. +// An error is returned if the input is empty or invalid. +func (i *OmnitrailWhereInput) P() (predicate.Omnitrail, error) { + var predicates []predicate.Omnitrail + if i.Not != nil { + p, err := i.Not.P() + if err != nil { + return nil, fmt.Errorf("%w: field 'not'", err) + } + predicates = append(predicates, omnitrail.Not(p)) + } + switch n := len(i.Or); { + case n == 1: + p, err := i.Or[0].P() + if err != nil { + return nil, fmt.Errorf("%w: field 'or'", err) + } + predicates = append(predicates, p) + case n > 1: + or := make([]predicate.Omnitrail, 0, n) + for _, w := range i.Or { + p, err := w.P() + if err != nil { + return nil, fmt.Errorf("%w: field 'or'", err) + } + or = append(or, p) + } + predicates = append(predicates, omnitrail.Or(or...)) + } + switch n := len(i.And); { + case n == 1: + p, err := i.And[0].P() + if err != nil { + return nil, fmt.Errorf("%w: field 'and'", err) + } + predicates = append(predicates, p) + case n > 1: + and := make([]predicate.Omnitrail, 0, n) + for _, w := range i.And { + p, err := w.P() + if err != nil { + return nil, fmt.Errorf("%w: field 'and'", err) + } + and = append(and, p) + } + predicates = append(predicates, omnitrail.And(and...)) + } + predicates = append(predicates, i.Predicates...) + if i.ID != nil { + predicates = append(predicates, omnitrail.IDEQ(*i.ID)) + } + if i.IDNEQ != nil { + predicates = append(predicates, omnitrail.IDNEQ(*i.IDNEQ)) + } + if len(i.IDIn) > 0 { + predicates = append(predicates, omnitrail.IDIn(i.IDIn...)) + } + if len(i.IDNotIn) > 0 { + predicates = append(predicates, omnitrail.IDNotIn(i.IDNotIn...)) + } + if i.IDGT != nil { + predicates = append(predicates, omnitrail.IDGT(*i.IDGT)) + } + if i.IDGTE != nil { + predicates = append(predicates, omnitrail.IDGTE(*i.IDGTE)) + } + if i.IDLT != nil { + predicates = append(predicates, omnitrail.IDLT(*i.IDLT)) + } + if i.IDLTE != nil { + predicates = append(predicates, omnitrail.IDLTE(*i.IDLTE)) + } + + if i.HasMappings != nil { + p := omnitrail.HasMappings() + if !*i.HasMappings { + p = omnitrail.Not(p) + } + predicates = append(predicates, p) + } + if len(i.HasMappingsWith) > 0 { + with := make([]predicate.Mapping, 0, len(i.HasMappingsWith)) + for _, w := range i.HasMappingsWith { + p, err := w.P() + if err != nil { + return nil, fmt.Errorf("%w: field 'HasMappingsWith'", err) + } + with = append(with, p) + } + predicates = append(predicates, omnitrail.HasMappingsWith(with...)) + } + if i.HasAttestation != nil { + p := omnitrail.HasAttestation() + if !*i.HasAttestation { + p = omnitrail.Not(p) + } + predicates = append(predicates, p) + } + if len(i.HasAttestationWith) > 0 { + with := make([]predicate.Attestation, 0, len(i.HasAttestationWith)) + for _, w := range i.HasAttestationWith { + p, err := w.P() + if err != nil { + return nil, fmt.Errorf("%w: field 'HasAttestationWith'", err) + } + with = append(with, p) + } + predicates = append(predicates, omnitrail.HasAttestationWith(with...)) + } + switch len(predicates) { + case 0: + return nil, ErrEmptyOmnitrailWhereInput + case 1: + return predicates[0], nil + default: + return omnitrail.And(predicates...), nil + } +} + +// PayloadDigestWhereInput represents a where input for filtering PayloadDigest queries. +type PayloadDigestWhereInput struct { + Predicates []predicate.PayloadDigest `json:"-"` + Not *PayloadDigestWhereInput `json:"not,omitempty"` + Or []*PayloadDigestWhereInput `json:"or,omitempty"` + And []*PayloadDigestWhereInput `json:"and,omitempty"` + + // "id" field predicates. + ID *int `json:"id,omitempty"` + IDNEQ *int `json:"idNEQ,omitempty"` + IDIn []int `json:"idIn,omitempty"` + IDNotIn []int `json:"idNotIn,omitempty"` + IDGT *int `json:"idGT,omitempty"` + IDGTE *int `json:"idGTE,omitempty"` + IDLT *int `json:"idLT,omitempty"` + IDLTE *int `json:"idLTE,omitempty"` + + // "algorithm" field predicates. + Algorithm *string `json:"algorithm,omitempty"` + AlgorithmNEQ *string `json:"algorithmNEQ,omitempty"` + AlgorithmIn []string `json:"algorithmIn,omitempty"` + AlgorithmNotIn []string `json:"algorithmNotIn,omitempty"` + AlgorithmGT *string `json:"algorithmGT,omitempty"` + AlgorithmGTE *string `json:"algorithmGTE,omitempty"` + AlgorithmLT *string `json:"algorithmLT,omitempty"` + AlgorithmLTE *string `json:"algorithmLTE,omitempty"` + AlgorithmContains *string `json:"algorithmContains,omitempty"` + AlgorithmHasPrefix *string `json:"algorithmHasPrefix,omitempty"` + AlgorithmHasSuffix *string `json:"algorithmHasSuffix,omitempty"` + AlgorithmEqualFold *string `json:"algorithmEqualFold,omitempty"` + AlgorithmContainsFold *string `json:"algorithmContainsFold,omitempty"` + + // "value" field predicates. + Value *string `json:"value,omitempty"` + ValueNEQ *string `json:"valueNEQ,omitempty"` + ValueIn []string `json:"valueIn,omitempty"` + ValueNotIn []string `json:"valueNotIn,omitempty"` + ValueGT *string `json:"valueGT,omitempty"` + ValueGTE *string `json:"valueGTE,omitempty"` + ValueLT *string `json:"valueLT,omitempty"` + ValueLTE *string `json:"valueLTE,omitempty"` + ValueContains *string `json:"valueContains,omitempty"` + ValueHasPrefix *string `json:"valueHasPrefix,omitempty"` + ValueHasSuffix *string `json:"valueHasSuffix,omitempty"` + ValueEqualFold *string `json:"valueEqualFold,omitempty"` + ValueContainsFold *string `json:"valueContainsFold,omitempty"` + + // "dsse" edge predicates. + HasDsse *bool `json:"hasDsse,omitempty"` + HasDsseWith []*DsseWhereInput `json:"hasDsseWith,omitempty"` +} + +// AddPredicates adds custom predicates to the where input to be used during the filtering phase. +func (i *PayloadDigestWhereInput) AddPredicates(predicates ...predicate.PayloadDigest) { + i.Predicates = append(i.Predicates, predicates...) +} + +// Filter applies the PayloadDigestWhereInput filter on the PayloadDigestQuery builder. +func (i *PayloadDigestWhereInput) Filter(q *PayloadDigestQuery) (*PayloadDigestQuery, error) { + if i == nil { + return q, nil + } + p, err := i.P() + if err != nil { + if err == ErrEmptyPayloadDigestWhereInput { + return q, nil + } + return nil, err + } + return q.Where(p), nil +} + +// ErrEmptyPayloadDigestWhereInput is returned in case the PayloadDigestWhereInput is empty. +var ErrEmptyPayloadDigestWhereInput = errors.New("ent: empty predicate PayloadDigestWhereInput") + +// P returns a predicate for filtering payloaddigests. +// An error is returned if the input is empty or invalid. +func (i *PayloadDigestWhereInput) P() (predicate.PayloadDigest, error) { + var predicates []predicate.PayloadDigest + if i.Not != nil { + p, err := i.Not.P() + if err != nil { + return nil, fmt.Errorf("%w: field 'not'", err) + } + predicates = append(predicates, payloaddigest.Not(p)) + } + switch n := len(i.Or); { + case n == 1: + p, err := i.Or[0].P() + if err != nil { + return nil, fmt.Errorf("%w: field 'or'", err) + } + predicates = append(predicates, p) + case n > 1: + or := make([]predicate.PayloadDigest, 0, n) + for _, w := range i.Or { + p, err := w.P() + if err != nil { + return nil, fmt.Errorf("%w: field 'or'", err) + } + or = append(or, p) + } + predicates = append(predicates, payloaddigest.Or(or...)) + } + switch n := len(i.And); { + case n == 1: + p, err := i.And[0].P() + if err != nil { + return nil, fmt.Errorf("%w: field 'and'", err) + } + predicates = append(predicates, p) + case n > 1: + and := make([]predicate.PayloadDigest, 0, n) + for _, w := range i.And { + p, err := w.P() + if err != nil { + return nil, fmt.Errorf("%w: field 'and'", err) + } + and = append(and, p) + } + predicates = append(predicates, payloaddigest.And(and...)) + } + predicates = append(predicates, i.Predicates...) + if i.ID != nil { + predicates = append(predicates, payloaddigest.IDEQ(*i.ID)) + } + if i.IDNEQ != nil { + predicates = append(predicates, payloaddigest.IDNEQ(*i.IDNEQ)) + } + if len(i.IDIn) > 0 { + predicates = append(predicates, payloaddigest.IDIn(i.IDIn...)) + } + if len(i.IDNotIn) > 0 { + predicates = append(predicates, payloaddigest.IDNotIn(i.IDNotIn...)) + } + if i.IDGT != nil { + predicates = append(predicates, payloaddigest.IDGT(*i.IDGT)) + } + if i.IDGTE != nil { + predicates = append(predicates, payloaddigest.IDGTE(*i.IDGTE)) + } + if i.IDLT != nil { + predicates = append(predicates, payloaddigest.IDLT(*i.IDLT)) + } + if i.IDLTE != nil { + predicates = append(predicates, payloaddigest.IDLTE(*i.IDLTE)) + } + if i.Algorithm != nil { + predicates = append(predicates, payloaddigest.AlgorithmEQ(*i.Algorithm)) + } + if i.AlgorithmNEQ != nil { + predicates = append(predicates, payloaddigest.AlgorithmNEQ(*i.AlgorithmNEQ)) + } + if len(i.AlgorithmIn) > 0 { + predicates = append(predicates, payloaddigest.AlgorithmIn(i.AlgorithmIn...)) + } + if len(i.AlgorithmNotIn) > 0 { + predicates = append(predicates, payloaddigest.AlgorithmNotIn(i.AlgorithmNotIn...)) + } + if i.AlgorithmGT != nil { + predicates = append(predicates, payloaddigest.AlgorithmGT(*i.AlgorithmGT)) + } + if i.AlgorithmGTE != nil { + predicates = append(predicates, payloaddigest.AlgorithmGTE(*i.AlgorithmGTE)) + } + if i.AlgorithmLT != nil { + predicates = append(predicates, payloaddigest.AlgorithmLT(*i.AlgorithmLT)) + } + if i.AlgorithmLTE != nil { + predicates = append(predicates, payloaddigest.AlgorithmLTE(*i.AlgorithmLTE)) + } + if i.AlgorithmContains != nil { + predicates = append(predicates, payloaddigest.AlgorithmContains(*i.AlgorithmContains)) + } + if i.AlgorithmHasPrefix != nil { + predicates = append(predicates, payloaddigest.AlgorithmHasPrefix(*i.AlgorithmHasPrefix)) + } + if i.AlgorithmHasSuffix != nil { + predicates = append(predicates, payloaddigest.AlgorithmHasSuffix(*i.AlgorithmHasSuffix)) + } + if i.AlgorithmEqualFold != nil { + predicates = append(predicates, payloaddigest.AlgorithmEqualFold(*i.AlgorithmEqualFold)) + } + if i.AlgorithmContainsFold != nil { + predicates = append(predicates, payloaddigest.AlgorithmContainsFold(*i.AlgorithmContainsFold)) + } + if i.Value != nil { + predicates = append(predicates, payloaddigest.ValueEQ(*i.Value)) + } + if i.ValueNEQ != nil { + predicates = append(predicates, payloaddigest.ValueNEQ(*i.ValueNEQ)) + } + if len(i.ValueIn) > 0 { + predicates = append(predicates, payloaddigest.ValueIn(i.ValueIn...)) + } + if len(i.ValueNotIn) > 0 { + predicates = append(predicates, payloaddigest.ValueNotIn(i.ValueNotIn...)) + } + if i.ValueGT != nil { + predicates = append(predicates, payloaddigest.ValueGT(*i.ValueGT)) + } + if i.ValueGTE != nil { + predicates = append(predicates, payloaddigest.ValueGTE(*i.ValueGTE)) + } + if i.ValueLT != nil { + predicates = append(predicates, payloaddigest.ValueLT(*i.ValueLT)) + } + if i.ValueLTE != nil { + predicates = append(predicates, payloaddigest.ValueLTE(*i.ValueLTE)) + } + if i.ValueContains != nil { + predicates = append(predicates, payloaddigest.ValueContains(*i.ValueContains)) + } + if i.ValueHasPrefix != nil { + predicates = append(predicates, payloaddigest.ValueHasPrefix(*i.ValueHasPrefix)) + } + if i.ValueHasSuffix != nil { + predicates = append(predicates, payloaddigest.ValueHasSuffix(*i.ValueHasSuffix)) + } + if i.ValueEqualFold != nil { + predicates = append(predicates, payloaddigest.ValueEqualFold(*i.ValueEqualFold)) + } + if i.ValueContainsFold != nil { + predicates = append(predicates, payloaddigest.ValueContainsFold(*i.ValueContainsFold)) + } + + if i.HasDsse != nil { + p := payloaddigest.HasDsse() + if !*i.HasDsse { + p = payloaddigest.Not(p) + } + predicates = append(predicates, p) + } + if len(i.HasDsseWith) > 0 { + with := make([]predicate.Dsse, 0, len(i.HasDsseWith)) + for _, w := range i.HasDsseWith { + p, err := w.P() + if err != nil { + return nil, fmt.Errorf("%w: field 'HasDsseWith'", err) + } + with = append(with, p) + } + predicates = append(predicates, payloaddigest.HasDsseWith(with...)) + } + switch len(predicates) { + case 0: + return nil, ErrEmptyPayloadDigestWhereInput + case 1: + return predicates[0], nil + default: + return payloaddigest.And(predicates...), nil + } +} + +// PosixWhereInput represents a where input for filtering Posix queries. +type PosixWhereInput struct { + Predicates []predicate.Posix `json:"-"` + Not *PosixWhereInput `json:"not,omitempty"` + Or []*PosixWhereInput `json:"or,omitempty"` + And []*PosixWhereInput `json:"and,omitempty"` + + // "id" field predicates. + ID *int `json:"id,omitempty"` + IDNEQ *int `json:"idNEQ,omitempty"` + IDIn []int `json:"idIn,omitempty"` + IDNotIn []int `json:"idNotIn,omitempty"` + IDGT *int `json:"idGT,omitempty"` + IDGTE *int `json:"idGTE,omitempty"` + IDLT *int `json:"idLT,omitempty"` + IDLTE *int `json:"idLTE,omitempty"` + + // "atime" field predicates. + Atime *string `json:"atime,omitempty"` + AtimeNEQ *string `json:"atimeNEQ,omitempty"` + AtimeIn []string `json:"atimeIn,omitempty"` + AtimeNotIn []string `json:"atimeNotIn,omitempty"` + AtimeGT *string `json:"atimeGT,omitempty"` + AtimeGTE *string `json:"atimeGTE,omitempty"` + AtimeLT *string `json:"atimeLT,omitempty"` + AtimeLTE *string `json:"atimeLTE,omitempty"` + AtimeContains *string `json:"atimeContains,omitempty"` + AtimeHasPrefix *string `json:"atimeHasPrefix,omitempty"` + AtimeHasSuffix *string `json:"atimeHasSuffix,omitempty"` + AtimeEqualFold *string `json:"atimeEqualFold,omitempty"` + AtimeContainsFold *string `json:"atimeContainsFold,omitempty"` + + // "ctime" field predicates. + Ctime *string `json:"ctime,omitempty"` + CtimeNEQ *string `json:"ctimeNEQ,omitempty"` + CtimeIn []string `json:"ctimeIn,omitempty"` + CtimeNotIn []string `json:"ctimeNotIn,omitempty"` + CtimeGT *string `json:"ctimeGT,omitempty"` + CtimeGTE *string `json:"ctimeGTE,omitempty"` + CtimeLT *string `json:"ctimeLT,omitempty"` + CtimeLTE *string `json:"ctimeLTE,omitempty"` + CtimeContains *string `json:"ctimeContains,omitempty"` + CtimeHasPrefix *string `json:"ctimeHasPrefix,omitempty"` + CtimeHasSuffix *string `json:"ctimeHasSuffix,omitempty"` + CtimeEqualFold *string `json:"ctimeEqualFold,omitempty"` + CtimeContainsFold *string `json:"ctimeContainsFold,omitempty"` + + // "creation_time" field predicates. + CreationTime *string `json:"creationTime,omitempty"` + CreationTimeNEQ *string `json:"creationTimeNEQ,omitempty"` + CreationTimeIn []string `json:"creationTimeIn,omitempty"` + CreationTimeNotIn []string `json:"creationTimeNotIn,omitempty"` + CreationTimeGT *string `json:"creationTimeGT,omitempty"` + CreationTimeGTE *string `json:"creationTimeGTE,omitempty"` + CreationTimeLT *string `json:"creationTimeLT,omitempty"` + CreationTimeLTE *string `json:"creationTimeLTE,omitempty"` + CreationTimeContains *string `json:"creationTimeContains,omitempty"` + CreationTimeHasPrefix *string `json:"creationTimeHasPrefix,omitempty"` + CreationTimeHasSuffix *string `json:"creationTimeHasSuffix,omitempty"` + CreationTimeEqualFold *string `json:"creationTimeEqualFold,omitempty"` + CreationTimeContainsFold *string `json:"creationTimeContainsFold,omitempty"` + + // "extended_attributes" field predicates. + ExtendedAttributes *string `json:"extendedAttributes,omitempty"` + ExtendedAttributesNEQ *string `json:"extendedAttributesNEQ,omitempty"` + ExtendedAttributesIn []string `json:"extendedAttributesIn,omitempty"` + ExtendedAttributesNotIn []string `json:"extendedAttributesNotIn,omitempty"` + ExtendedAttributesGT *string `json:"extendedAttributesGT,omitempty"` + ExtendedAttributesGTE *string `json:"extendedAttributesGTE,omitempty"` + ExtendedAttributesLT *string `json:"extendedAttributesLT,omitempty"` + ExtendedAttributesLTE *string `json:"extendedAttributesLTE,omitempty"` + ExtendedAttributesContains *string `json:"extendedAttributesContains,omitempty"` + ExtendedAttributesHasPrefix *string `json:"extendedAttributesHasPrefix,omitempty"` + ExtendedAttributesHasSuffix *string `json:"extendedAttributesHasSuffix,omitempty"` + ExtendedAttributesEqualFold *string `json:"extendedAttributesEqualFold,omitempty"` + ExtendedAttributesContainsFold *string `json:"extendedAttributesContainsFold,omitempty"` + + // "file_device_id" field predicates. + FileDeviceID *string `json:"fileDeviceID,omitempty"` + FileDeviceIDNEQ *string `json:"fileDeviceIDNEQ,omitempty"` + FileDeviceIDIn []string `json:"fileDeviceIDIn,omitempty"` + FileDeviceIDNotIn []string `json:"fileDeviceIDNotIn,omitempty"` + FileDeviceIDGT *string `json:"fileDeviceIDGT,omitempty"` + FileDeviceIDGTE *string `json:"fileDeviceIDGTE,omitempty"` + FileDeviceIDLT *string `json:"fileDeviceIDLT,omitempty"` + FileDeviceIDLTE *string `json:"fileDeviceIDLTE,omitempty"` + FileDeviceIDContains *string `json:"fileDeviceIDContains,omitempty"` + FileDeviceIDHasPrefix *string `json:"fileDeviceIDHasPrefix,omitempty"` + FileDeviceIDHasSuffix *string `json:"fileDeviceIDHasSuffix,omitempty"` + FileDeviceIDEqualFold *string `json:"fileDeviceIDEqualFold,omitempty"` + FileDeviceIDContainsFold *string `json:"fileDeviceIDContainsFold,omitempty"` + + // "file_flags" field predicates. + FileFlags *string `json:"fileFlags,omitempty"` + FileFlagsNEQ *string `json:"fileFlagsNEQ,omitempty"` + FileFlagsIn []string `json:"fileFlagsIn,omitempty"` + FileFlagsNotIn []string `json:"fileFlagsNotIn,omitempty"` + FileFlagsGT *string `json:"fileFlagsGT,omitempty"` + FileFlagsGTE *string `json:"fileFlagsGTE,omitempty"` + FileFlagsLT *string `json:"fileFlagsLT,omitempty"` + FileFlagsLTE *string `json:"fileFlagsLTE,omitempty"` + FileFlagsContains *string `json:"fileFlagsContains,omitempty"` + FileFlagsHasPrefix *string `json:"fileFlagsHasPrefix,omitempty"` + FileFlagsHasSuffix *string `json:"fileFlagsHasSuffix,omitempty"` + FileFlagsEqualFold *string `json:"fileFlagsEqualFold,omitempty"` + FileFlagsContainsFold *string `json:"fileFlagsContainsFold,omitempty"` + + // "file_inode" field predicates. + FileInode *string `json:"fileInode,omitempty"` + FileInodeNEQ *string `json:"fileInodeNEQ,omitempty"` + FileInodeIn []string `json:"fileInodeIn,omitempty"` + FileInodeNotIn []string `json:"fileInodeNotIn,omitempty"` + FileInodeGT *string `json:"fileInodeGT,omitempty"` + FileInodeGTE *string `json:"fileInodeGTE,omitempty"` + FileInodeLT *string `json:"fileInodeLT,omitempty"` + FileInodeLTE *string `json:"fileInodeLTE,omitempty"` + FileInodeContains *string `json:"fileInodeContains,omitempty"` + FileInodeHasPrefix *string `json:"fileInodeHasPrefix,omitempty"` + FileInodeHasSuffix *string `json:"fileInodeHasSuffix,omitempty"` + FileInodeEqualFold *string `json:"fileInodeEqualFold,omitempty"` + FileInodeContainsFold *string `json:"fileInodeContainsFold,omitempty"` + + // "file_system_id" field predicates. + FileSystemID *string `json:"fileSystemID,omitempty"` + FileSystemIDNEQ *string `json:"fileSystemIDNEQ,omitempty"` + FileSystemIDIn []string `json:"fileSystemIDIn,omitempty"` + FileSystemIDNotIn []string `json:"fileSystemIDNotIn,omitempty"` + FileSystemIDGT *string `json:"fileSystemIDGT,omitempty"` + FileSystemIDGTE *string `json:"fileSystemIDGTE,omitempty"` + FileSystemIDLT *string `json:"fileSystemIDLT,omitempty"` + FileSystemIDLTE *string `json:"fileSystemIDLTE,omitempty"` + FileSystemIDContains *string `json:"fileSystemIDContains,omitempty"` + FileSystemIDHasPrefix *string `json:"fileSystemIDHasPrefix,omitempty"` + FileSystemIDHasSuffix *string `json:"fileSystemIDHasSuffix,omitempty"` + FileSystemIDEqualFold *string `json:"fileSystemIDEqualFold,omitempty"` + FileSystemIDContainsFold *string `json:"fileSystemIDContainsFold,omitempty"` + + // "file_type" field predicates. + FileType *string `json:"fileType,omitempty"` + FileTypeNEQ *string `json:"fileTypeNEQ,omitempty"` + FileTypeIn []string `json:"fileTypeIn,omitempty"` + FileTypeNotIn []string `json:"fileTypeNotIn,omitempty"` + FileTypeGT *string `json:"fileTypeGT,omitempty"` + FileTypeGTE *string `json:"fileTypeGTE,omitempty"` + FileTypeLT *string `json:"fileTypeLT,omitempty"` + FileTypeLTE *string `json:"fileTypeLTE,omitempty"` + FileTypeContains *string `json:"fileTypeContains,omitempty"` + FileTypeHasPrefix *string `json:"fileTypeHasPrefix,omitempty"` + FileTypeHasSuffix *string `json:"fileTypeHasSuffix,omitempty"` + FileTypeEqualFold *string `json:"fileTypeEqualFold,omitempty"` + FileTypeContainsFold *string `json:"fileTypeContainsFold,omitempty"` + + // "hard_link_count" field predicates. + HardLinkCount *string `json:"hardLinkCount,omitempty"` + HardLinkCountNEQ *string `json:"hardLinkCountNEQ,omitempty"` + HardLinkCountIn []string `json:"hardLinkCountIn,omitempty"` + HardLinkCountNotIn []string `json:"hardLinkCountNotIn,omitempty"` + HardLinkCountGT *string `json:"hardLinkCountGT,omitempty"` + HardLinkCountGTE *string `json:"hardLinkCountGTE,omitempty"` + HardLinkCountLT *string `json:"hardLinkCountLT,omitempty"` + HardLinkCountLTE *string `json:"hardLinkCountLTE,omitempty"` + HardLinkCountContains *string `json:"hardLinkCountContains,omitempty"` + HardLinkCountHasPrefix *string `json:"hardLinkCountHasPrefix,omitempty"` + HardLinkCountHasSuffix *string `json:"hardLinkCountHasSuffix,omitempty"` + HardLinkCountEqualFold *string `json:"hardLinkCountEqualFold,omitempty"` + HardLinkCountContainsFold *string `json:"hardLinkCountContainsFold,omitempty"` + + // "mtime" field predicates. + Mtime *string `json:"mtime,omitempty"` + MtimeNEQ *string `json:"mtimeNEQ,omitempty"` + MtimeIn []string `json:"mtimeIn,omitempty"` + MtimeNotIn []string `json:"mtimeNotIn,omitempty"` + MtimeGT *string `json:"mtimeGT,omitempty"` + MtimeGTE *string `json:"mtimeGTE,omitempty"` + MtimeLT *string `json:"mtimeLT,omitempty"` + MtimeLTE *string `json:"mtimeLTE,omitempty"` + MtimeContains *string `json:"mtimeContains,omitempty"` + MtimeHasPrefix *string `json:"mtimeHasPrefix,omitempty"` + MtimeHasSuffix *string `json:"mtimeHasSuffix,omitempty"` + MtimeEqualFold *string `json:"mtimeEqualFold,omitempty"` + MtimeContainsFold *string `json:"mtimeContainsFold,omitempty"` + + // "metadata_ctime" field predicates. + MetadataCtime *string `json:"metadataCtime,omitempty"` + MetadataCtimeNEQ *string `json:"metadataCtimeNEQ,omitempty"` + MetadataCtimeIn []string `json:"metadataCtimeIn,omitempty"` + MetadataCtimeNotIn []string `json:"metadataCtimeNotIn,omitempty"` + MetadataCtimeGT *string `json:"metadataCtimeGT,omitempty"` + MetadataCtimeGTE *string `json:"metadataCtimeGTE,omitempty"` + MetadataCtimeLT *string `json:"metadataCtimeLT,omitempty"` + MetadataCtimeLTE *string `json:"metadataCtimeLTE,omitempty"` + MetadataCtimeContains *string `json:"metadataCtimeContains,omitempty"` + MetadataCtimeHasPrefix *string `json:"metadataCtimeHasPrefix,omitempty"` + MetadataCtimeHasSuffix *string `json:"metadataCtimeHasSuffix,omitempty"` + MetadataCtimeEqualFold *string `json:"metadataCtimeEqualFold,omitempty"` + MetadataCtimeContainsFold *string `json:"metadataCtimeContainsFold,omitempty"` + + // "owner_gid" field predicates. + OwnerGid *string `json:"ownerGid,omitempty"` + OwnerGidNEQ *string `json:"ownerGidNEQ,omitempty"` + OwnerGidIn []string `json:"ownerGidIn,omitempty"` + OwnerGidNotIn []string `json:"ownerGidNotIn,omitempty"` + OwnerGidGT *string `json:"ownerGidGT,omitempty"` + OwnerGidGTE *string `json:"ownerGidGTE,omitempty"` + OwnerGidLT *string `json:"ownerGidLT,omitempty"` + OwnerGidLTE *string `json:"ownerGidLTE,omitempty"` + OwnerGidContains *string `json:"ownerGidContains,omitempty"` + OwnerGidHasPrefix *string `json:"ownerGidHasPrefix,omitempty"` + OwnerGidHasSuffix *string `json:"ownerGidHasSuffix,omitempty"` + OwnerGidEqualFold *string `json:"ownerGidEqualFold,omitempty"` + OwnerGidContainsFold *string `json:"ownerGidContainsFold,omitempty"` + + // "owner_uid" field predicates. + OwnerUID *string `json:"ownerUID,omitempty"` + OwnerUIDNEQ *string `json:"ownerUIDNEQ,omitempty"` + OwnerUIDIn []string `json:"ownerUIDIn,omitempty"` + OwnerUIDNotIn []string `json:"ownerUIDNotIn,omitempty"` + OwnerUIDGT *string `json:"ownerUIDGT,omitempty"` + OwnerUIDGTE *string `json:"ownerUIDGTE,omitempty"` + OwnerUIDLT *string `json:"ownerUIDLT,omitempty"` + OwnerUIDLTE *string `json:"ownerUIDLTE,omitempty"` + OwnerUIDContains *string `json:"ownerUIDContains,omitempty"` + OwnerUIDHasPrefix *string `json:"ownerUIDHasPrefix,omitempty"` + OwnerUIDHasSuffix *string `json:"ownerUIDHasSuffix,omitempty"` + OwnerUIDEqualFold *string `json:"ownerUIDEqualFold,omitempty"` + OwnerUIDContainsFold *string `json:"ownerUIDContainsFold,omitempty"` + + // "permissions" field predicates. + Permissions *string `json:"permissions,omitempty"` + PermissionsNEQ *string `json:"permissionsNEQ,omitempty"` + PermissionsIn []string `json:"permissionsIn,omitempty"` + PermissionsNotIn []string `json:"permissionsNotIn,omitempty"` + PermissionsGT *string `json:"permissionsGT,omitempty"` + PermissionsGTE *string `json:"permissionsGTE,omitempty"` + PermissionsLT *string `json:"permissionsLT,omitempty"` + PermissionsLTE *string `json:"permissionsLTE,omitempty"` + PermissionsContains *string `json:"permissionsContains,omitempty"` + PermissionsHasPrefix *string `json:"permissionsHasPrefix,omitempty"` + PermissionsHasSuffix *string `json:"permissionsHasSuffix,omitempty"` + PermissionsEqualFold *string `json:"permissionsEqualFold,omitempty"` + PermissionsContainsFold *string `json:"permissionsContainsFold,omitempty"` + + // "size" field predicates. + Size *string `json:"size,omitempty"` + SizeNEQ *string `json:"sizeNEQ,omitempty"` + SizeIn []string `json:"sizeIn,omitempty"` + SizeNotIn []string `json:"sizeNotIn,omitempty"` + SizeGT *string `json:"sizeGT,omitempty"` + SizeGTE *string `json:"sizeGTE,omitempty"` + SizeLT *string `json:"sizeLT,omitempty"` + SizeLTE *string `json:"sizeLTE,omitempty"` + SizeContains *string `json:"sizeContains,omitempty"` + SizeHasPrefix *string `json:"sizeHasPrefix,omitempty"` + SizeHasSuffix *string `json:"sizeHasSuffix,omitempty"` + SizeEqualFold *string `json:"sizeEqualFold,omitempty"` + SizeContainsFold *string `json:"sizeContainsFold,omitempty"` + + // "mapping" edge predicates. + HasMapping *bool `json:"hasMapping,omitempty"` + HasMappingWith []*MappingWhereInput `json:"hasMappingWith,omitempty"` +} + +// AddPredicates adds custom predicates to the where input to be used during the filtering phase. +func (i *PosixWhereInput) AddPredicates(predicates ...predicate.Posix) { + i.Predicates = append(i.Predicates, predicates...) +} + +// Filter applies the PosixWhereInput filter on the PosixQuery builder. +func (i *PosixWhereInput) Filter(q *PosixQuery) (*PosixQuery, error) { + if i == nil { + return q, nil + } + p, err := i.P() + if err != nil { + if err == ErrEmptyPosixWhereInput { + return q, nil + } + return nil, err + } + return q.Where(p), nil +} + +// ErrEmptyPosixWhereInput is returned in case the PosixWhereInput is empty. +var ErrEmptyPosixWhereInput = errors.New("ent: empty predicate PosixWhereInput") + +// P returns a predicate for filtering posixes. +// An error is returned if the input is empty or invalid. +func (i *PosixWhereInput) P() (predicate.Posix, error) { + var predicates []predicate.Posix + if i.Not != nil { + p, err := i.Not.P() + if err != nil { + return nil, fmt.Errorf("%w: field 'not'", err) + } + predicates = append(predicates, posix.Not(p)) + } + switch n := len(i.Or); { + case n == 1: + p, err := i.Or[0].P() + if err != nil { + return nil, fmt.Errorf("%w: field 'or'", err) + } + predicates = append(predicates, p) + case n > 1: + or := make([]predicate.Posix, 0, n) + for _, w := range i.Or { + p, err := w.P() + if err != nil { + return nil, fmt.Errorf("%w: field 'or'", err) + } + or = append(or, p) + } + predicates = append(predicates, posix.Or(or...)) + } + switch n := len(i.And); { + case n == 1: + p, err := i.And[0].P() + if err != nil { + return nil, fmt.Errorf("%w: field 'and'", err) + } + predicates = append(predicates, p) + case n > 1: + and := make([]predicate.Posix, 0, n) + for _, w := range i.And { + p, err := w.P() + if err != nil { + return nil, fmt.Errorf("%w: field 'and'", err) + } + and = append(and, p) + } + predicates = append(predicates, posix.And(and...)) + } + predicates = append(predicates, i.Predicates...) + if i.ID != nil { + predicates = append(predicates, posix.IDEQ(*i.ID)) + } + if i.IDNEQ != nil { + predicates = append(predicates, posix.IDNEQ(*i.IDNEQ)) + } + if len(i.IDIn) > 0 { + predicates = append(predicates, posix.IDIn(i.IDIn...)) + } + if len(i.IDNotIn) > 0 { + predicates = append(predicates, posix.IDNotIn(i.IDNotIn...)) + } + if i.IDGT != nil { + predicates = append(predicates, posix.IDGT(*i.IDGT)) + } + if i.IDGTE != nil { + predicates = append(predicates, posix.IDGTE(*i.IDGTE)) + } + if i.IDLT != nil { + predicates = append(predicates, posix.IDLT(*i.IDLT)) + } + if i.IDLTE != nil { + predicates = append(predicates, posix.IDLTE(*i.IDLTE)) + } + if i.Atime != nil { + predicates = append(predicates, posix.AtimeEQ(*i.Atime)) + } + if i.AtimeNEQ != nil { + predicates = append(predicates, posix.AtimeNEQ(*i.AtimeNEQ)) + } + if len(i.AtimeIn) > 0 { + predicates = append(predicates, posix.AtimeIn(i.AtimeIn...)) + } + if len(i.AtimeNotIn) > 0 { + predicates = append(predicates, posix.AtimeNotIn(i.AtimeNotIn...)) + } + if i.AtimeGT != nil { + predicates = append(predicates, posix.AtimeGT(*i.AtimeGT)) + } + if i.AtimeGTE != nil { + predicates = append(predicates, posix.AtimeGTE(*i.AtimeGTE)) + } + if i.AtimeLT != nil { + predicates = append(predicates, posix.AtimeLT(*i.AtimeLT)) + } + if i.AtimeLTE != nil { + predicates = append(predicates, posix.AtimeLTE(*i.AtimeLTE)) + } + if i.AtimeContains != nil { + predicates = append(predicates, posix.AtimeContains(*i.AtimeContains)) + } + if i.AtimeHasPrefix != nil { + predicates = append(predicates, posix.AtimeHasPrefix(*i.AtimeHasPrefix)) + } + if i.AtimeHasSuffix != nil { + predicates = append(predicates, posix.AtimeHasSuffix(*i.AtimeHasSuffix)) + } + if i.AtimeEqualFold != nil { + predicates = append(predicates, posix.AtimeEqualFold(*i.AtimeEqualFold)) + } + if i.AtimeContainsFold != nil { + predicates = append(predicates, posix.AtimeContainsFold(*i.AtimeContainsFold)) + } + if i.Ctime != nil { + predicates = append(predicates, posix.CtimeEQ(*i.Ctime)) + } + if i.CtimeNEQ != nil { + predicates = append(predicates, posix.CtimeNEQ(*i.CtimeNEQ)) + } + if len(i.CtimeIn) > 0 { + predicates = append(predicates, posix.CtimeIn(i.CtimeIn...)) + } + if len(i.CtimeNotIn) > 0 { + predicates = append(predicates, posix.CtimeNotIn(i.CtimeNotIn...)) + } + if i.CtimeGT != nil { + predicates = append(predicates, posix.CtimeGT(*i.CtimeGT)) + } + if i.CtimeGTE != nil { + predicates = append(predicates, posix.CtimeGTE(*i.CtimeGTE)) + } + if i.CtimeLT != nil { + predicates = append(predicates, posix.CtimeLT(*i.CtimeLT)) + } + if i.CtimeLTE != nil { + predicates = append(predicates, posix.CtimeLTE(*i.CtimeLTE)) + } + if i.CtimeContains != nil { + predicates = append(predicates, posix.CtimeContains(*i.CtimeContains)) + } + if i.CtimeHasPrefix != nil { + predicates = append(predicates, posix.CtimeHasPrefix(*i.CtimeHasPrefix)) + } + if i.CtimeHasSuffix != nil { + predicates = append(predicates, posix.CtimeHasSuffix(*i.CtimeHasSuffix)) + } + if i.CtimeEqualFold != nil { + predicates = append(predicates, posix.CtimeEqualFold(*i.CtimeEqualFold)) + } + if i.CtimeContainsFold != nil { + predicates = append(predicates, posix.CtimeContainsFold(*i.CtimeContainsFold)) + } + if i.CreationTime != nil { + predicates = append(predicates, posix.CreationTimeEQ(*i.CreationTime)) + } + if i.CreationTimeNEQ != nil { + predicates = append(predicates, posix.CreationTimeNEQ(*i.CreationTimeNEQ)) + } + if len(i.CreationTimeIn) > 0 { + predicates = append(predicates, posix.CreationTimeIn(i.CreationTimeIn...)) + } + if len(i.CreationTimeNotIn) > 0 { + predicates = append(predicates, posix.CreationTimeNotIn(i.CreationTimeNotIn...)) + } + if i.CreationTimeGT != nil { + predicates = append(predicates, posix.CreationTimeGT(*i.CreationTimeGT)) + } + if i.CreationTimeGTE != nil { + predicates = append(predicates, posix.CreationTimeGTE(*i.CreationTimeGTE)) + } + if i.CreationTimeLT != nil { + predicates = append(predicates, posix.CreationTimeLT(*i.CreationTimeLT)) + } + if i.CreationTimeLTE != nil { + predicates = append(predicates, posix.CreationTimeLTE(*i.CreationTimeLTE)) + } + if i.CreationTimeContains != nil { + predicates = append(predicates, posix.CreationTimeContains(*i.CreationTimeContains)) + } + if i.CreationTimeHasPrefix != nil { + predicates = append(predicates, posix.CreationTimeHasPrefix(*i.CreationTimeHasPrefix)) + } + if i.CreationTimeHasSuffix != nil { + predicates = append(predicates, posix.CreationTimeHasSuffix(*i.CreationTimeHasSuffix)) + } + if i.CreationTimeEqualFold != nil { + predicates = append(predicates, posix.CreationTimeEqualFold(*i.CreationTimeEqualFold)) + } + if i.CreationTimeContainsFold != nil { + predicates = append(predicates, posix.CreationTimeContainsFold(*i.CreationTimeContainsFold)) + } + if i.ExtendedAttributes != nil { + predicates = append(predicates, posix.ExtendedAttributesEQ(*i.ExtendedAttributes)) + } + if i.ExtendedAttributesNEQ != nil { + predicates = append(predicates, posix.ExtendedAttributesNEQ(*i.ExtendedAttributesNEQ)) + } + if len(i.ExtendedAttributesIn) > 0 { + predicates = append(predicates, posix.ExtendedAttributesIn(i.ExtendedAttributesIn...)) + } + if len(i.ExtendedAttributesNotIn) > 0 { + predicates = append(predicates, posix.ExtendedAttributesNotIn(i.ExtendedAttributesNotIn...)) + } + if i.ExtendedAttributesGT != nil { + predicates = append(predicates, posix.ExtendedAttributesGT(*i.ExtendedAttributesGT)) + } + if i.ExtendedAttributesGTE != nil { + predicates = append(predicates, posix.ExtendedAttributesGTE(*i.ExtendedAttributesGTE)) + } + if i.ExtendedAttributesLT != nil { + predicates = append(predicates, posix.ExtendedAttributesLT(*i.ExtendedAttributesLT)) + } + if i.ExtendedAttributesLTE != nil { + predicates = append(predicates, posix.ExtendedAttributesLTE(*i.ExtendedAttributesLTE)) + } + if i.ExtendedAttributesContains != nil { + predicates = append(predicates, posix.ExtendedAttributesContains(*i.ExtendedAttributesContains)) + } + if i.ExtendedAttributesHasPrefix != nil { + predicates = append(predicates, posix.ExtendedAttributesHasPrefix(*i.ExtendedAttributesHasPrefix)) + } + if i.ExtendedAttributesHasSuffix != nil { + predicates = append(predicates, posix.ExtendedAttributesHasSuffix(*i.ExtendedAttributesHasSuffix)) + } + if i.ExtendedAttributesEqualFold != nil { + predicates = append(predicates, posix.ExtendedAttributesEqualFold(*i.ExtendedAttributesEqualFold)) + } + if i.ExtendedAttributesContainsFold != nil { + predicates = append(predicates, posix.ExtendedAttributesContainsFold(*i.ExtendedAttributesContainsFold)) + } + if i.FileDeviceID != nil { + predicates = append(predicates, posix.FileDeviceIDEQ(*i.FileDeviceID)) + } + if i.FileDeviceIDNEQ != nil { + predicates = append(predicates, posix.FileDeviceIDNEQ(*i.FileDeviceIDNEQ)) + } + if len(i.FileDeviceIDIn) > 0 { + predicates = append(predicates, posix.FileDeviceIDIn(i.FileDeviceIDIn...)) + } + if len(i.FileDeviceIDNotIn) > 0 { + predicates = append(predicates, posix.FileDeviceIDNotIn(i.FileDeviceIDNotIn...)) + } + if i.FileDeviceIDGT != nil { + predicates = append(predicates, posix.FileDeviceIDGT(*i.FileDeviceIDGT)) + } + if i.FileDeviceIDGTE != nil { + predicates = append(predicates, posix.FileDeviceIDGTE(*i.FileDeviceIDGTE)) + } + if i.FileDeviceIDLT != nil { + predicates = append(predicates, posix.FileDeviceIDLT(*i.FileDeviceIDLT)) + } + if i.FileDeviceIDLTE != nil { + predicates = append(predicates, posix.FileDeviceIDLTE(*i.FileDeviceIDLTE)) + } + if i.FileDeviceIDContains != nil { + predicates = append(predicates, posix.FileDeviceIDContains(*i.FileDeviceIDContains)) + } + if i.FileDeviceIDHasPrefix != nil { + predicates = append(predicates, posix.FileDeviceIDHasPrefix(*i.FileDeviceIDHasPrefix)) + } + if i.FileDeviceIDHasSuffix != nil { + predicates = append(predicates, posix.FileDeviceIDHasSuffix(*i.FileDeviceIDHasSuffix)) + } + if i.FileDeviceIDEqualFold != nil { + predicates = append(predicates, posix.FileDeviceIDEqualFold(*i.FileDeviceIDEqualFold)) + } + if i.FileDeviceIDContainsFold != nil { + predicates = append(predicates, posix.FileDeviceIDContainsFold(*i.FileDeviceIDContainsFold)) + } + if i.FileFlags != nil { + predicates = append(predicates, posix.FileFlagsEQ(*i.FileFlags)) + } + if i.FileFlagsNEQ != nil { + predicates = append(predicates, posix.FileFlagsNEQ(*i.FileFlagsNEQ)) + } + if len(i.FileFlagsIn) > 0 { + predicates = append(predicates, posix.FileFlagsIn(i.FileFlagsIn...)) + } + if len(i.FileFlagsNotIn) > 0 { + predicates = append(predicates, posix.FileFlagsNotIn(i.FileFlagsNotIn...)) + } + if i.FileFlagsGT != nil { + predicates = append(predicates, posix.FileFlagsGT(*i.FileFlagsGT)) + } + if i.FileFlagsGTE != nil { + predicates = append(predicates, posix.FileFlagsGTE(*i.FileFlagsGTE)) + } + if i.FileFlagsLT != nil { + predicates = append(predicates, posix.FileFlagsLT(*i.FileFlagsLT)) + } + if i.FileFlagsLTE != nil { + predicates = append(predicates, posix.FileFlagsLTE(*i.FileFlagsLTE)) + } + if i.FileFlagsContains != nil { + predicates = append(predicates, posix.FileFlagsContains(*i.FileFlagsContains)) + } + if i.FileFlagsHasPrefix != nil { + predicates = append(predicates, posix.FileFlagsHasPrefix(*i.FileFlagsHasPrefix)) + } + if i.FileFlagsHasSuffix != nil { + predicates = append(predicates, posix.FileFlagsHasSuffix(*i.FileFlagsHasSuffix)) + } + if i.FileFlagsEqualFold != nil { + predicates = append(predicates, posix.FileFlagsEqualFold(*i.FileFlagsEqualFold)) + } + if i.FileFlagsContainsFold != nil { + predicates = append(predicates, posix.FileFlagsContainsFold(*i.FileFlagsContainsFold)) + } + if i.FileInode != nil { + predicates = append(predicates, posix.FileInodeEQ(*i.FileInode)) + } + if i.FileInodeNEQ != nil { + predicates = append(predicates, posix.FileInodeNEQ(*i.FileInodeNEQ)) + } + if len(i.FileInodeIn) > 0 { + predicates = append(predicates, posix.FileInodeIn(i.FileInodeIn...)) + } + if len(i.FileInodeNotIn) > 0 { + predicates = append(predicates, posix.FileInodeNotIn(i.FileInodeNotIn...)) + } + if i.FileInodeGT != nil { + predicates = append(predicates, posix.FileInodeGT(*i.FileInodeGT)) + } + if i.FileInodeGTE != nil { + predicates = append(predicates, posix.FileInodeGTE(*i.FileInodeGTE)) + } + if i.FileInodeLT != nil { + predicates = append(predicates, posix.FileInodeLT(*i.FileInodeLT)) + } + if i.FileInodeLTE != nil { + predicates = append(predicates, posix.FileInodeLTE(*i.FileInodeLTE)) + } + if i.FileInodeContains != nil { + predicates = append(predicates, posix.FileInodeContains(*i.FileInodeContains)) + } + if i.FileInodeHasPrefix != nil { + predicates = append(predicates, posix.FileInodeHasPrefix(*i.FileInodeHasPrefix)) + } + if i.FileInodeHasSuffix != nil { + predicates = append(predicates, posix.FileInodeHasSuffix(*i.FileInodeHasSuffix)) + } + if i.FileInodeEqualFold != nil { + predicates = append(predicates, posix.FileInodeEqualFold(*i.FileInodeEqualFold)) + } + if i.FileInodeContainsFold != nil { + predicates = append(predicates, posix.FileInodeContainsFold(*i.FileInodeContainsFold)) + } + if i.FileSystemID != nil { + predicates = append(predicates, posix.FileSystemIDEQ(*i.FileSystemID)) + } + if i.FileSystemIDNEQ != nil { + predicates = append(predicates, posix.FileSystemIDNEQ(*i.FileSystemIDNEQ)) + } + if len(i.FileSystemIDIn) > 0 { + predicates = append(predicates, posix.FileSystemIDIn(i.FileSystemIDIn...)) + } + if len(i.FileSystemIDNotIn) > 0 { + predicates = append(predicates, posix.FileSystemIDNotIn(i.FileSystemIDNotIn...)) + } + if i.FileSystemIDGT != nil { + predicates = append(predicates, posix.FileSystemIDGT(*i.FileSystemIDGT)) + } + if i.FileSystemIDGTE != nil { + predicates = append(predicates, posix.FileSystemIDGTE(*i.FileSystemIDGTE)) + } + if i.FileSystemIDLT != nil { + predicates = append(predicates, posix.FileSystemIDLT(*i.FileSystemIDLT)) + } + if i.FileSystemIDLTE != nil { + predicates = append(predicates, posix.FileSystemIDLTE(*i.FileSystemIDLTE)) + } + if i.FileSystemIDContains != nil { + predicates = append(predicates, posix.FileSystemIDContains(*i.FileSystemIDContains)) + } + if i.FileSystemIDHasPrefix != nil { + predicates = append(predicates, posix.FileSystemIDHasPrefix(*i.FileSystemIDHasPrefix)) + } + if i.FileSystemIDHasSuffix != nil { + predicates = append(predicates, posix.FileSystemIDHasSuffix(*i.FileSystemIDHasSuffix)) + } + if i.FileSystemIDEqualFold != nil { + predicates = append(predicates, posix.FileSystemIDEqualFold(*i.FileSystemIDEqualFold)) + } + if i.FileSystemIDContainsFold != nil { + predicates = append(predicates, posix.FileSystemIDContainsFold(*i.FileSystemIDContainsFold)) + } + if i.FileType != nil { + predicates = append(predicates, posix.FileTypeEQ(*i.FileType)) + } + if i.FileTypeNEQ != nil { + predicates = append(predicates, posix.FileTypeNEQ(*i.FileTypeNEQ)) + } + if len(i.FileTypeIn) > 0 { + predicates = append(predicates, posix.FileTypeIn(i.FileTypeIn...)) + } + if len(i.FileTypeNotIn) > 0 { + predicates = append(predicates, posix.FileTypeNotIn(i.FileTypeNotIn...)) + } + if i.FileTypeGT != nil { + predicates = append(predicates, posix.FileTypeGT(*i.FileTypeGT)) + } + if i.FileTypeGTE != nil { + predicates = append(predicates, posix.FileTypeGTE(*i.FileTypeGTE)) + } + if i.FileTypeLT != nil { + predicates = append(predicates, posix.FileTypeLT(*i.FileTypeLT)) + } + if i.FileTypeLTE != nil { + predicates = append(predicates, posix.FileTypeLTE(*i.FileTypeLTE)) + } + if i.FileTypeContains != nil { + predicates = append(predicates, posix.FileTypeContains(*i.FileTypeContains)) + } + if i.FileTypeHasPrefix != nil { + predicates = append(predicates, posix.FileTypeHasPrefix(*i.FileTypeHasPrefix)) + } + if i.FileTypeHasSuffix != nil { + predicates = append(predicates, posix.FileTypeHasSuffix(*i.FileTypeHasSuffix)) + } + if i.FileTypeEqualFold != nil { + predicates = append(predicates, posix.FileTypeEqualFold(*i.FileTypeEqualFold)) + } + if i.FileTypeContainsFold != nil { + predicates = append(predicates, posix.FileTypeContainsFold(*i.FileTypeContainsFold)) + } + if i.HardLinkCount != nil { + predicates = append(predicates, posix.HardLinkCountEQ(*i.HardLinkCount)) + } + if i.HardLinkCountNEQ != nil { + predicates = append(predicates, posix.HardLinkCountNEQ(*i.HardLinkCountNEQ)) + } + if len(i.HardLinkCountIn) > 0 { + predicates = append(predicates, posix.HardLinkCountIn(i.HardLinkCountIn...)) + } + if len(i.HardLinkCountNotIn) > 0 { + predicates = append(predicates, posix.HardLinkCountNotIn(i.HardLinkCountNotIn...)) + } + if i.HardLinkCountGT != nil { + predicates = append(predicates, posix.HardLinkCountGT(*i.HardLinkCountGT)) + } + if i.HardLinkCountGTE != nil { + predicates = append(predicates, posix.HardLinkCountGTE(*i.HardLinkCountGTE)) + } + if i.HardLinkCountLT != nil { + predicates = append(predicates, posix.HardLinkCountLT(*i.HardLinkCountLT)) + } + if i.HardLinkCountLTE != nil { + predicates = append(predicates, posix.HardLinkCountLTE(*i.HardLinkCountLTE)) + } + if i.HardLinkCountContains != nil { + predicates = append(predicates, posix.HardLinkCountContains(*i.HardLinkCountContains)) + } + if i.HardLinkCountHasPrefix != nil { + predicates = append(predicates, posix.HardLinkCountHasPrefix(*i.HardLinkCountHasPrefix)) + } + if i.HardLinkCountHasSuffix != nil { + predicates = append(predicates, posix.HardLinkCountHasSuffix(*i.HardLinkCountHasSuffix)) + } + if i.HardLinkCountEqualFold != nil { + predicates = append(predicates, posix.HardLinkCountEqualFold(*i.HardLinkCountEqualFold)) + } + if i.HardLinkCountContainsFold != nil { + predicates = append(predicates, posix.HardLinkCountContainsFold(*i.HardLinkCountContainsFold)) + } + if i.Mtime != nil { + predicates = append(predicates, posix.MtimeEQ(*i.Mtime)) + } + if i.MtimeNEQ != nil { + predicates = append(predicates, posix.MtimeNEQ(*i.MtimeNEQ)) + } + if len(i.MtimeIn) > 0 { + predicates = append(predicates, posix.MtimeIn(i.MtimeIn...)) + } + if len(i.MtimeNotIn) > 0 { + predicates = append(predicates, posix.MtimeNotIn(i.MtimeNotIn...)) + } + if i.MtimeGT != nil { + predicates = append(predicates, posix.MtimeGT(*i.MtimeGT)) + } + if i.MtimeGTE != nil { + predicates = append(predicates, posix.MtimeGTE(*i.MtimeGTE)) + } + if i.MtimeLT != nil { + predicates = append(predicates, posix.MtimeLT(*i.MtimeLT)) + } + if i.MtimeLTE != nil { + predicates = append(predicates, posix.MtimeLTE(*i.MtimeLTE)) + } + if i.MtimeContains != nil { + predicates = append(predicates, posix.MtimeContains(*i.MtimeContains)) + } + if i.MtimeHasPrefix != nil { + predicates = append(predicates, posix.MtimeHasPrefix(*i.MtimeHasPrefix)) + } + if i.MtimeHasSuffix != nil { + predicates = append(predicates, posix.MtimeHasSuffix(*i.MtimeHasSuffix)) + } + if i.MtimeEqualFold != nil { + predicates = append(predicates, posix.MtimeEqualFold(*i.MtimeEqualFold)) + } + if i.MtimeContainsFold != nil { + predicates = append(predicates, posix.MtimeContainsFold(*i.MtimeContainsFold)) + } + if i.MetadataCtime != nil { + predicates = append(predicates, posix.MetadataCtimeEQ(*i.MetadataCtime)) + } + if i.MetadataCtimeNEQ != nil { + predicates = append(predicates, posix.MetadataCtimeNEQ(*i.MetadataCtimeNEQ)) + } + if len(i.MetadataCtimeIn) > 0 { + predicates = append(predicates, posix.MetadataCtimeIn(i.MetadataCtimeIn...)) + } + if len(i.MetadataCtimeNotIn) > 0 { + predicates = append(predicates, posix.MetadataCtimeNotIn(i.MetadataCtimeNotIn...)) + } + if i.MetadataCtimeGT != nil { + predicates = append(predicates, posix.MetadataCtimeGT(*i.MetadataCtimeGT)) + } + if i.MetadataCtimeGTE != nil { + predicates = append(predicates, posix.MetadataCtimeGTE(*i.MetadataCtimeGTE)) + } + if i.MetadataCtimeLT != nil { + predicates = append(predicates, posix.MetadataCtimeLT(*i.MetadataCtimeLT)) + } + if i.MetadataCtimeLTE != nil { + predicates = append(predicates, posix.MetadataCtimeLTE(*i.MetadataCtimeLTE)) + } + if i.MetadataCtimeContains != nil { + predicates = append(predicates, posix.MetadataCtimeContains(*i.MetadataCtimeContains)) + } + if i.MetadataCtimeHasPrefix != nil { + predicates = append(predicates, posix.MetadataCtimeHasPrefix(*i.MetadataCtimeHasPrefix)) + } + if i.MetadataCtimeHasSuffix != nil { + predicates = append(predicates, posix.MetadataCtimeHasSuffix(*i.MetadataCtimeHasSuffix)) + } + if i.MetadataCtimeEqualFold != nil { + predicates = append(predicates, posix.MetadataCtimeEqualFold(*i.MetadataCtimeEqualFold)) + } + if i.MetadataCtimeContainsFold != nil { + predicates = append(predicates, posix.MetadataCtimeContainsFold(*i.MetadataCtimeContainsFold)) + } + if i.OwnerGid != nil { + predicates = append(predicates, posix.OwnerGidEQ(*i.OwnerGid)) + } + if i.OwnerGidNEQ != nil { + predicates = append(predicates, posix.OwnerGidNEQ(*i.OwnerGidNEQ)) + } + if len(i.OwnerGidIn) > 0 { + predicates = append(predicates, posix.OwnerGidIn(i.OwnerGidIn...)) + } + if len(i.OwnerGidNotIn) > 0 { + predicates = append(predicates, posix.OwnerGidNotIn(i.OwnerGidNotIn...)) + } + if i.OwnerGidGT != nil { + predicates = append(predicates, posix.OwnerGidGT(*i.OwnerGidGT)) + } + if i.OwnerGidGTE != nil { + predicates = append(predicates, posix.OwnerGidGTE(*i.OwnerGidGTE)) + } + if i.OwnerGidLT != nil { + predicates = append(predicates, posix.OwnerGidLT(*i.OwnerGidLT)) + } + if i.OwnerGidLTE != nil { + predicates = append(predicates, posix.OwnerGidLTE(*i.OwnerGidLTE)) + } + if i.OwnerGidContains != nil { + predicates = append(predicates, posix.OwnerGidContains(*i.OwnerGidContains)) + } + if i.OwnerGidHasPrefix != nil { + predicates = append(predicates, posix.OwnerGidHasPrefix(*i.OwnerGidHasPrefix)) + } + if i.OwnerGidHasSuffix != nil { + predicates = append(predicates, posix.OwnerGidHasSuffix(*i.OwnerGidHasSuffix)) + } + if i.OwnerGidEqualFold != nil { + predicates = append(predicates, posix.OwnerGidEqualFold(*i.OwnerGidEqualFold)) + } + if i.OwnerGidContainsFold != nil { + predicates = append(predicates, posix.OwnerGidContainsFold(*i.OwnerGidContainsFold)) + } + if i.OwnerUID != nil { + predicates = append(predicates, posix.OwnerUIDEQ(*i.OwnerUID)) + } + if i.OwnerUIDNEQ != nil { + predicates = append(predicates, posix.OwnerUIDNEQ(*i.OwnerUIDNEQ)) + } + if len(i.OwnerUIDIn) > 0 { + predicates = append(predicates, posix.OwnerUIDIn(i.OwnerUIDIn...)) + } + if len(i.OwnerUIDNotIn) > 0 { + predicates = append(predicates, posix.OwnerUIDNotIn(i.OwnerUIDNotIn...)) + } + if i.OwnerUIDGT != nil { + predicates = append(predicates, posix.OwnerUIDGT(*i.OwnerUIDGT)) + } + if i.OwnerUIDGTE != nil { + predicates = append(predicates, posix.OwnerUIDGTE(*i.OwnerUIDGTE)) + } + if i.OwnerUIDLT != nil { + predicates = append(predicates, posix.OwnerUIDLT(*i.OwnerUIDLT)) + } + if i.OwnerUIDLTE != nil { + predicates = append(predicates, posix.OwnerUIDLTE(*i.OwnerUIDLTE)) + } + if i.OwnerUIDContains != nil { + predicates = append(predicates, posix.OwnerUIDContains(*i.OwnerUIDContains)) + } + if i.OwnerUIDHasPrefix != nil { + predicates = append(predicates, posix.OwnerUIDHasPrefix(*i.OwnerUIDHasPrefix)) + } + if i.OwnerUIDHasSuffix != nil { + predicates = append(predicates, posix.OwnerUIDHasSuffix(*i.OwnerUIDHasSuffix)) + } + if i.OwnerUIDEqualFold != nil { + predicates = append(predicates, posix.OwnerUIDEqualFold(*i.OwnerUIDEqualFold)) + } + if i.OwnerUIDContainsFold != nil { + predicates = append(predicates, posix.OwnerUIDContainsFold(*i.OwnerUIDContainsFold)) + } + if i.Permissions != nil { + predicates = append(predicates, posix.PermissionsEQ(*i.Permissions)) + } + if i.PermissionsNEQ != nil { + predicates = append(predicates, posix.PermissionsNEQ(*i.PermissionsNEQ)) + } + if len(i.PermissionsIn) > 0 { + predicates = append(predicates, posix.PermissionsIn(i.PermissionsIn...)) + } + if len(i.PermissionsNotIn) > 0 { + predicates = append(predicates, posix.PermissionsNotIn(i.PermissionsNotIn...)) + } + if i.PermissionsGT != nil { + predicates = append(predicates, posix.PermissionsGT(*i.PermissionsGT)) + } + if i.PermissionsGTE != nil { + predicates = append(predicates, posix.PermissionsGTE(*i.PermissionsGTE)) + } + if i.PermissionsLT != nil { + predicates = append(predicates, posix.PermissionsLT(*i.PermissionsLT)) + } + if i.PermissionsLTE != nil { + predicates = append(predicates, posix.PermissionsLTE(*i.PermissionsLTE)) + } + if i.PermissionsContains != nil { + predicates = append(predicates, posix.PermissionsContains(*i.PermissionsContains)) + } + if i.PermissionsHasPrefix != nil { + predicates = append(predicates, posix.PermissionsHasPrefix(*i.PermissionsHasPrefix)) + } + if i.PermissionsHasSuffix != nil { + predicates = append(predicates, posix.PermissionsHasSuffix(*i.PermissionsHasSuffix)) + } + if i.PermissionsEqualFold != nil { + predicates = append(predicates, posix.PermissionsEqualFold(*i.PermissionsEqualFold)) + } + if i.PermissionsContainsFold != nil { + predicates = append(predicates, posix.PermissionsContainsFold(*i.PermissionsContainsFold)) + } + if i.Size != nil { + predicates = append(predicates, posix.SizeEQ(*i.Size)) + } + if i.SizeNEQ != nil { + predicates = append(predicates, posix.SizeNEQ(*i.SizeNEQ)) + } + if len(i.SizeIn) > 0 { + predicates = append(predicates, posix.SizeIn(i.SizeIn...)) + } + if len(i.SizeNotIn) > 0 { + predicates = append(predicates, posix.SizeNotIn(i.SizeNotIn...)) + } + if i.SizeGT != nil { + predicates = append(predicates, posix.SizeGT(*i.SizeGT)) + } + if i.SizeGTE != nil { + predicates = append(predicates, posix.SizeGTE(*i.SizeGTE)) + } + if i.SizeLT != nil { + predicates = append(predicates, posix.SizeLT(*i.SizeLT)) + } + if i.SizeLTE != nil { + predicates = append(predicates, posix.SizeLTE(*i.SizeLTE)) + } + if i.SizeContains != nil { + predicates = append(predicates, posix.SizeContains(*i.SizeContains)) + } + if i.SizeHasPrefix != nil { + predicates = append(predicates, posix.SizeHasPrefix(*i.SizeHasPrefix)) + } + if i.SizeHasSuffix != nil { + predicates = append(predicates, posix.SizeHasSuffix(*i.SizeHasSuffix)) + } + if i.SizeEqualFold != nil { + predicates = append(predicates, posix.SizeEqualFold(*i.SizeEqualFold)) + } + if i.SizeContainsFold != nil { + predicates = append(predicates, posix.SizeContainsFold(*i.SizeContainsFold)) + } + + if i.HasMapping != nil { + p := posix.HasMapping() + if !*i.HasMapping { + p = posix.Not(p) + } + predicates = append(predicates, p) + } + if len(i.HasMappingWith) > 0 { + with := make([]predicate.Mapping, 0, len(i.HasMappingWith)) + for _, w := range i.HasMappingWith { + p, err := w.P() + if err != nil { + return nil, fmt.Errorf("%w: field 'HasMappingWith'", err) + } + with = append(with, p) + } + predicates = append(predicates, posix.HasMappingWith(with...)) + } + switch len(predicates) { + case 0: + return nil, ErrEmptyPosixWhereInput + case 1: + return predicates[0], nil + default: + return posix.And(predicates...), nil } } diff --git a/ent/hook/hook.go b/ent/hook/hook.go index a4f9b6f4..6d25cd55 100644 --- a/ent/hook/hook.go +++ b/ent/hook/hook.go @@ -57,6 +57,30 @@ func (f DsseFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.DsseMutation", m) } +// The MappingFunc type is an adapter to allow the use of ordinary +// function as Mapping mutator. +type MappingFunc func(context.Context, *ent.MappingMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f MappingFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.MappingMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.MappingMutation", m) +} + +// The OmnitrailFunc type is an adapter to allow the use of ordinary +// function as Omnitrail mutator. +type OmnitrailFunc func(context.Context, *ent.OmnitrailMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f OmnitrailFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.OmnitrailMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.OmnitrailMutation", m) +} + // The PayloadDigestFunc type is an adapter to allow the use of ordinary // function as PayloadDigest mutator. type PayloadDigestFunc func(context.Context, *ent.PayloadDigestMutation) (ent.Value, error) @@ -69,6 +93,18 @@ func (f PayloadDigestFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Valu return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.PayloadDigestMutation", m) } +// The PosixFunc type is an adapter to allow the use of ordinary +// function as Posix mutator. +type PosixFunc func(context.Context, *ent.PosixMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f PosixFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.PosixMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.PosixMutation", m) +} + // The SignatureFunc type is an adapter to allow the use of ordinary // function as Signature mutator. type SignatureFunc func(context.Context, *ent.SignatureMutation) (ent.Value, error) diff --git a/ent/mapping.go b/ent/mapping.go new file mode 100644 index 00000000..9d93d5d3 --- /dev/null +++ b/ent/mapping.go @@ -0,0 +1,241 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "fmt" + "strings" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "github.com/in-toto/archivista/ent/mapping" + "github.com/in-toto/archivista/ent/omnitrail" +) + +// Mapping is the model entity for the Mapping schema. +type Mapping 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"` + // Type holds the value of the "type" field. + Type string `json:"type,omitempty"` + // Sha1 holds the value of the "sha1" field. + Sha1 string `json:"sha1,omitempty"` + // Sha256 holds the value of the "sha256" field. + Sha256 string `json:"sha256,omitempty"` + // GitoidSha1 holds the value of the "gitoidSha1" field. + GitoidSha1 string `json:"gitoidSha1,omitempty"` + // GitoidSha256 holds the value of the "gitoidSha256" field. + GitoidSha256 string `json:"gitoidSha256,omitempty"` + // Edges holds the relations/edges for other nodes in the graph. + // The values are being populated by the MappingQuery when eager-loading is set. + Edges MappingEdges `json:"edges"` + omnitrail_mappings *int + selectValues sql.SelectValues +} + +// MappingEdges holds the relations/edges for other nodes in the graph. +type MappingEdges struct { + // Posix holds the value of the posix edge. + Posix []*Posix `json:"posix,omitempty"` + // Omnitrail holds the value of the omnitrail edge. + Omnitrail *Omnitrail `json:"omnitrail,omitempty"` + // loadedTypes holds the information for reporting if a + // type was loaded (or requested) in eager-loading or not. + loadedTypes [2]bool + // totalCount holds the count of the edges above. + totalCount [2]map[string]int + + namedPosix map[string][]*Posix +} + +// PosixOrErr returns the Posix value or an error if the edge +// was not loaded in eager-loading. +func (e MappingEdges) PosixOrErr() ([]*Posix, error) { + if e.loadedTypes[0] { + return e.Posix, nil + } + return nil, &NotLoadedError{edge: "posix"} +} + +// OmnitrailOrErr returns the Omnitrail value or an error if the edge +// was not loaded in eager-loading, or loaded but was not found. +func (e MappingEdges) OmnitrailOrErr() (*Omnitrail, error) { + if e.Omnitrail != nil { + return e.Omnitrail, nil + } else if e.loadedTypes[1] { + return nil, &NotFoundError{label: omnitrail.Label} + } + return nil, &NotLoadedError{edge: "omnitrail"} +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*Mapping) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case mapping.FieldID: + values[i] = new(sql.NullInt64) + case mapping.FieldPath, mapping.FieldType, mapping.FieldSha1, mapping.FieldSha256, mapping.FieldGitoidSha1, mapping.FieldGitoidSha256: + values[i] = new(sql.NullString) + case mapping.ForeignKeys[0]: // omnitrail_mappings + values[i] = new(sql.NullInt64) + default: + values[i] = new(sql.UnknownType) + } + } + return values, nil +} + +// assignValues assigns the values that were returned from sql.Rows (after scanning) +// to the Mapping fields. +func (m *Mapping) 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 mapping.FieldID: + value, ok := values[i].(*sql.NullInt64) + if !ok { + return fmt.Errorf("unexpected type %T for field id", value) + } + m.ID = int(value.Int64) + case mapping.FieldPath: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field path", values[i]) + } else if value.Valid { + m.Path = value.String + } + case mapping.FieldType: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field type", values[i]) + } else if value.Valid { + m.Type = value.String + } + case mapping.FieldSha1: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field sha1", values[i]) + } else if value.Valid { + m.Sha1 = value.String + } + case mapping.FieldSha256: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field sha256", values[i]) + } else if value.Valid { + m.Sha256 = value.String + } + case mapping.FieldGitoidSha1: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field gitoidSha1", values[i]) + } else if value.Valid { + m.GitoidSha1 = value.String + } + case mapping.FieldGitoidSha256: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field gitoidSha256", values[i]) + } else if value.Valid { + m.GitoidSha256 = value.String + } + case mapping.ForeignKeys[0]: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for edge-field omnitrail_mappings", value) + } else if value.Valid { + m.omnitrail_mappings = new(int) + *m.omnitrail_mappings = int(value.Int64) + } + default: + m.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the Mapping. +// This includes values selected through modifiers, order, etc. +func (m *Mapping) Value(name string) (ent.Value, error) { + return m.selectValues.Get(name) +} + +// QueryPosix queries the "posix" edge of the Mapping entity. +func (m *Mapping) QueryPosix() *PosixQuery { + return NewMappingClient(m.config).QueryPosix(m) +} + +// QueryOmnitrail queries the "omnitrail" edge of the Mapping entity. +func (m *Mapping) QueryOmnitrail() *OmnitrailQuery { + return NewMappingClient(m.config).QueryOmnitrail(m) +} + +// Update returns a builder for updating this Mapping. +// Note that you need to call Mapping.Unwrap() before calling this method if this Mapping +// was returned from a transaction, and the transaction was committed or rolled back. +func (m *Mapping) Update() *MappingUpdateOne { + return NewMappingClient(m.config).UpdateOne(m) +} + +// Unwrap unwraps the Mapping 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 (m *Mapping) Unwrap() *Mapping { + _tx, ok := m.config.driver.(*txDriver) + if !ok { + panic("ent: Mapping is not a transactional entity") + } + m.config.driver = _tx.drv + return m +} + +// String implements the fmt.Stringer. +func (m *Mapping) String() string { + var builder strings.Builder + builder.WriteString("Mapping(") + builder.WriteString(fmt.Sprintf("id=%v, ", m.ID)) + builder.WriteString("path=") + builder.WriteString(m.Path) + builder.WriteString(", ") + builder.WriteString("type=") + builder.WriteString(m.Type) + builder.WriteString(", ") + builder.WriteString("sha1=") + builder.WriteString(m.Sha1) + builder.WriteString(", ") + builder.WriteString("sha256=") + builder.WriteString(m.Sha256) + builder.WriteString(", ") + builder.WriteString("gitoidSha1=") + builder.WriteString(m.GitoidSha1) + builder.WriteString(", ") + builder.WriteString("gitoidSha256=") + builder.WriteString(m.GitoidSha256) + builder.WriteByte(')') + return builder.String() +} + +// NamedPosix returns the Posix named value or an error if the edge was not +// loaded in eager-loading with this name. +func (m *Mapping) NamedPosix(name string) ([]*Posix, error) { + if m.Edges.namedPosix == nil { + return nil, &NotLoadedError{edge: name} + } + nodes, ok := m.Edges.namedPosix[name] + if !ok { + return nil, &NotLoadedError{edge: name} + } + return nodes, nil +} + +func (m *Mapping) appendNamedPosix(name string, edges ...*Posix) { + if m.Edges.namedPosix == nil { + m.Edges.namedPosix = make(map[string][]*Posix) + } + if len(edges) == 0 { + m.Edges.namedPosix[name] = []*Posix{} + } else { + m.Edges.namedPosix[name] = append(m.Edges.namedPosix[name], edges...) + } +} + +// Mappings is a parsable slice of Mapping. +type Mappings []*Mapping diff --git a/ent/mapping/mapping.go b/ent/mapping/mapping.go new file mode 100644 index 00000000..c3c8ae8e --- /dev/null +++ b/ent/mapping/mapping.go @@ -0,0 +1,163 @@ +// Code generated by ent, DO NOT EDIT. + +package mapping + +import ( + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +const ( + // Label holds the string label denoting the mapping type in the database. + Label = "mapping" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // FieldPath holds the string denoting the path field in the database. + FieldPath = "path" + // FieldType holds the string denoting the type field in the database. + FieldType = "type" + // FieldSha1 holds the string denoting the sha1 field in the database. + FieldSha1 = "sha1" + // FieldSha256 holds the string denoting the sha256 field in the database. + FieldSha256 = "sha256" + // FieldGitoidSha1 holds the string denoting the gitoidsha1 field in the database. + FieldGitoidSha1 = "gitoid_sha1" + // FieldGitoidSha256 holds the string denoting the gitoidsha256 field in the database. + FieldGitoidSha256 = "gitoid_sha256" + // EdgePosix holds the string denoting the posix edge name in mutations. + EdgePosix = "posix" + // EdgeOmnitrail holds the string denoting the omnitrail edge name in mutations. + EdgeOmnitrail = "omnitrail" + // Table holds the table name of the mapping in the database. + Table = "mappings" + // PosixTable is the table that holds the posix relation/edge. + PosixTable = "posixes" + // PosixInverseTable is the table name for the Posix entity. + // It exists in this package in order to avoid circular dependency with the "posix" package. + PosixInverseTable = "posixes" + // PosixColumn is the table column denoting the posix relation/edge. + PosixColumn = "mapping_posix" + // OmnitrailTable is the table that holds the omnitrail relation/edge. + OmnitrailTable = "mappings" + // OmnitrailInverseTable is the table name for the Omnitrail entity. + // It exists in this package in order to avoid circular dependency with the "omnitrail" package. + OmnitrailInverseTable = "omnitrails" + // OmnitrailColumn is the table column denoting the omnitrail relation/edge. + OmnitrailColumn = "omnitrail_mappings" +) + +// Columns holds all SQL columns for mapping fields. +var Columns = []string{ + FieldID, + FieldPath, + FieldType, + FieldSha1, + FieldSha256, + FieldGitoidSha1, + FieldGitoidSha256, +} + +// ForeignKeys holds the SQL foreign-keys that are owned by the "mappings" +// table and are not defined as standalone fields in the schema. +var ForeignKeys = []string{ + "omnitrail_mappings", +} + +// 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 + } + } + for i := range ForeignKeys { + if column == ForeignKeys[i] { + return true + } + } + return false +} + +var ( + // PathValidator is a validator for the "path" field. It is called by the builders before save. + PathValidator func(string) error + // TypeValidator is a validator for the "type" field. It is called by the builders before save. + TypeValidator func(string) error + // GitoidSha1Validator is a validator for the "gitoidSha1" field. It is called by the builders before save. + GitoidSha1Validator func(string) error + // GitoidSha256Validator is a validator for the "gitoidSha256" field. It is called by the builders before save. + GitoidSha256Validator func(string) error +) + +// OrderOption defines the ordering options for the Mapping queries. +type OrderOption func(*sql.Selector) + +// ByID orders the results by the id field. +func ByID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldID, opts...).ToFunc() +} + +// ByPath orders the results by the path field. +func ByPath(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldPath, opts...).ToFunc() +} + +// ByType orders the results by the type field. +func ByType(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldType, opts...).ToFunc() +} + +// BySha1 orders the results by the sha1 field. +func BySha1(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldSha1, opts...).ToFunc() +} + +// BySha256 orders the results by the sha256 field. +func BySha256(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldSha256, opts...).ToFunc() +} + +// ByGitoidSha1 orders the results by the gitoidSha1 field. +func ByGitoidSha1(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldGitoidSha1, opts...).ToFunc() +} + +// ByGitoidSha256 orders the results by the gitoidSha256 field. +func ByGitoidSha256(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldGitoidSha256, opts...).ToFunc() +} + +// ByPosixCount orders the results by posix count. +func ByPosixCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newPosixStep(), opts...) + } +} + +// ByPosix orders the results by posix terms. +func ByPosix(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newPosixStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} + +// ByOmnitrailField orders the results by omnitrail field. +func ByOmnitrailField(field string, opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newOmnitrailStep(), sql.OrderByField(field, opts...)) + } +} +func newPosixStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(PosixInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, PosixTable, PosixColumn), + ) +} +func newOmnitrailStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(OmnitrailInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, OmnitrailTable, OmnitrailColumn), + ) +} diff --git a/ent/mapping/where.go b/ent/mapping/where.go new file mode 100644 index 00000000..52addd63 --- /dev/null +++ b/ent/mapping/where.go @@ -0,0 +1,535 @@ +// Code generated by ent, DO NOT EDIT. + +package mapping + +import ( + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "github.com/in-toto/archivista/ent/predicate" +) + +// ID filters vertices based on their ID field. +func ID(id int) predicate.Mapping { + return predicate.Mapping(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id int) predicate.Mapping { + return predicate.Mapping(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id int) predicate.Mapping { + return predicate.Mapping(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...int) predicate.Mapping { + return predicate.Mapping(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...int) predicate.Mapping { + return predicate.Mapping(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id int) predicate.Mapping { + return predicate.Mapping(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id int) predicate.Mapping { + return predicate.Mapping(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id int) predicate.Mapping { + return predicate.Mapping(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id int) predicate.Mapping { + return predicate.Mapping(sql.FieldLTE(FieldID, id)) +} + +// Path applies equality check predicate on the "path" field. It's identical to PathEQ. +func Path(v string) predicate.Mapping { + return predicate.Mapping(sql.FieldEQ(FieldPath, v)) +} + +// Type applies equality check predicate on the "type" field. It's identical to TypeEQ. +func Type(v string) predicate.Mapping { + return predicate.Mapping(sql.FieldEQ(FieldType, v)) +} + +// Sha1 applies equality check predicate on the "sha1" field. It's identical to Sha1EQ. +func Sha1(v string) predicate.Mapping { + return predicate.Mapping(sql.FieldEQ(FieldSha1, v)) +} + +// Sha256 applies equality check predicate on the "sha256" field. It's identical to Sha256EQ. +func Sha256(v string) predicate.Mapping { + return predicate.Mapping(sql.FieldEQ(FieldSha256, v)) +} + +// GitoidSha1 applies equality check predicate on the "gitoidSha1" field. It's identical to GitoidSha1EQ. +func GitoidSha1(v string) predicate.Mapping { + return predicate.Mapping(sql.FieldEQ(FieldGitoidSha1, v)) +} + +// GitoidSha256 applies equality check predicate on the "gitoidSha256" field. It's identical to GitoidSha256EQ. +func GitoidSha256(v string) predicate.Mapping { + return predicate.Mapping(sql.FieldEQ(FieldGitoidSha256, v)) +} + +// PathEQ applies the EQ predicate on the "path" field. +func PathEQ(v string) predicate.Mapping { + return predicate.Mapping(sql.FieldEQ(FieldPath, v)) +} + +// PathNEQ applies the NEQ predicate on the "path" field. +func PathNEQ(v string) predicate.Mapping { + return predicate.Mapping(sql.FieldNEQ(FieldPath, v)) +} + +// PathIn applies the In predicate on the "path" field. +func PathIn(vs ...string) predicate.Mapping { + return predicate.Mapping(sql.FieldIn(FieldPath, vs...)) +} + +// PathNotIn applies the NotIn predicate on the "path" field. +func PathNotIn(vs ...string) predicate.Mapping { + return predicate.Mapping(sql.FieldNotIn(FieldPath, vs...)) +} + +// PathGT applies the GT predicate on the "path" field. +func PathGT(v string) predicate.Mapping { + return predicate.Mapping(sql.FieldGT(FieldPath, v)) +} + +// PathGTE applies the GTE predicate on the "path" field. +func PathGTE(v string) predicate.Mapping { + return predicate.Mapping(sql.FieldGTE(FieldPath, v)) +} + +// PathLT applies the LT predicate on the "path" field. +func PathLT(v string) predicate.Mapping { + return predicate.Mapping(sql.FieldLT(FieldPath, v)) +} + +// PathLTE applies the LTE predicate on the "path" field. +func PathLTE(v string) predicate.Mapping { + return predicate.Mapping(sql.FieldLTE(FieldPath, v)) +} + +// PathContains applies the Contains predicate on the "path" field. +func PathContains(v string) predicate.Mapping { + return predicate.Mapping(sql.FieldContains(FieldPath, v)) +} + +// PathHasPrefix applies the HasPrefix predicate on the "path" field. +func PathHasPrefix(v string) predicate.Mapping { + return predicate.Mapping(sql.FieldHasPrefix(FieldPath, v)) +} + +// PathHasSuffix applies the HasSuffix predicate on the "path" field. +func PathHasSuffix(v string) predicate.Mapping { + return predicate.Mapping(sql.FieldHasSuffix(FieldPath, v)) +} + +// PathEqualFold applies the EqualFold predicate on the "path" field. +func PathEqualFold(v string) predicate.Mapping { + return predicate.Mapping(sql.FieldEqualFold(FieldPath, v)) +} + +// PathContainsFold applies the ContainsFold predicate on the "path" field. +func PathContainsFold(v string) predicate.Mapping { + return predicate.Mapping(sql.FieldContainsFold(FieldPath, v)) +} + +// TypeEQ applies the EQ predicate on the "type" field. +func TypeEQ(v string) predicate.Mapping { + return predicate.Mapping(sql.FieldEQ(FieldType, v)) +} + +// TypeNEQ applies the NEQ predicate on the "type" field. +func TypeNEQ(v string) predicate.Mapping { + return predicate.Mapping(sql.FieldNEQ(FieldType, v)) +} + +// TypeIn applies the In predicate on the "type" field. +func TypeIn(vs ...string) predicate.Mapping { + return predicate.Mapping(sql.FieldIn(FieldType, vs...)) +} + +// TypeNotIn applies the NotIn predicate on the "type" field. +func TypeNotIn(vs ...string) predicate.Mapping { + return predicate.Mapping(sql.FieldNotIn(FieldType, vs...)) +} + +// TypeGT applies the GT predicate on the "type" field. +func TypeGT(v string) predicate.Mapping { + return predicate.Mapping(sql.FieldGT(FieldType, v)) +} + +// TypeGTE applies the GTE predicate on the "type" field. +func TypeGTE(v string) predicate.Mapping { + return predicate.Mapping(sql.FieldGTE(FieldType, v)) +} + +// TypeLT applies the LT predicate on the "type" field. +func TypeLT(v string) predicate.Mapping { + return predicate.Mapping(sql.FieldLT(FieldType, v)) +} + +// TypeLTE applies the LTE predicate on the "type" field. +func TypeLTE(v string) predicate.Mapping { + return predicate.Mapping(sql.FieldLTE(FieldType, v)) +} + +// TypeContains applies the Contains predicate on the "type" field. +func TypeContains(v string) predicate.Mapping { + return predicate.Mapping(sql.FieldContains(FieldType, v)) +} + +// TypeHasPrefix applies the HasPrefix predicate on the "type" field. +func TypeHasPrefix(v string) predicate.Mapping { + return predicate.Mapping(sql.FieldHasPrefix(FieldType, v)) +} + +// TypeHasSuffix applies the HasSuffix predicate on the "type" field. +func TypeHasSuffix(v string) predicate.Mapping { + return predicate.Mapping(sql.FieldHasSuffix(FieldType, v)) +} + +// TypeEqualFold applies the EqualFold predicate on the "type" field. +func TypeEqualFold(v string) predicate.Mapping { + return predicate.Mapping(sql.FieldEqualFold(FieldType, v)) +} + +// TypeContainsFold applies the ContainsFold predicate on the "type" field. +func TypeContainsFold(v string) predicate.Mapping { + return predicate.Mapping(sql.FieldContainsFold(FieldType, v)) +} + +// Sha1EQ applies the EQ predicate on the "sha1" field. +func Sha1EQ(v string) predicate.Mapping { + return predicate.Mapping(sql.FieldEQ(FieldSha1, v)) +} + +// Sha1NEQ applies the NEQ predicate on the "sha1" field. +func Sha1NEQ(v string) predicate.Mapping { + return predicate.Mapping(sql.FieldNEQ(FieldSha1, v)) +} + +// Sha1In applies the In predicate on the "sha1" field. +func Sha1In(vs ...string) predicate.Mapping { + return predicate.Mapping(sql.FieldIn(FieldSha1, vs...)) +} + +// Sha1NotIn applies the NotIn predicate on the "sha1" field. +func Sha1NotIn(vs ...string) predicate.Mapping { + return predicate.Mapping(sql.FieldNotIn(FieldSha1, vs...)) +} + +// Sha1GT applies the GT predicate on the "sha1" field. +func Sha1GT(v string) predicate.Mapping { + return predicate.Mapping(sql.FieldGT(FieldSha1, v)) +} + +// Sha1GTE applies the GTE predicate on the "sha1" field. +func Sha1GTE(v string) predicate.Mapping { + return predicate.Mapping(sql.FieldGTE(FieldSha1, v)) +} + +// Sha1LT applies the LT predicate on the "sha1" field. +func Sha1LT(v string) predicate.Mapping { + return predicate.Mapping(sql.FieldLT(FieldSha1, v)) +} + +// Sha1LTE applies the LTE predicate on the "sha1" field. +func Sha1LTE(v string) predicate.Mapping { + return predicate.Mapping(sql.FieldLTE(FieldSha1, v)) +} + +// Sha1Contains applies the Contains predicate on the "sha1" field. +func Sha1Contains(v string) predicate.Mapping { + return predicate.Mapping(sql.FieldContains(FieldSha1, v)) +} + +// Sha1HasPrefix applies the HasPrefix predicate on the "sha1" field. +func Sha1HasPrefix(v string) predicate.Mapping { + return predicate.Mapping(sql.FieldHasPrefix(FieldSha1, v)) +} + +// Sha1HasSuffix applies the HasSuffix predicate on the "sha1" field. +func Sha1HasSuffix(v string) predicate.Mapping { + return predicate.Mapping(sql.FieldHasSuffix(FieldSha1, v)) +} + +// Sha1EqualFold applies the EqualFold predicate on the "sha1" field. +func Sha1EqualFold(v string) predicate.Mapping { + return predicate.Mapping(sql.FieldEqualFold(FieldSha1, v)) +} + +// Sha1ContainsFold applies the ContainsFold predicate on the "sha1" field. +func Sha1ContainsFold(v string) predicate.Mapping { + return predicate.Mapping(sql.FieldContainsFold(FieldSha1, v)) +} + +// Sha256EQ applies the EQ predicate on the "sha256" field. +func Sha256EQ(v string) predicate.Mapping { + return predicate.Mapping(sql.FieldEQ(FieldSha256, v)) +} + +// Sha256NEQ applies the NEQ predicate on the "sha256" field. +func Sha256NEQ(v string) predicate.Mapping { + return predicate.Mapping(sql.FieldNEQ(FieldSha256, v)) +} + +// Sha256In applies the In predicate on the "sha256" field. +func Sha256In(vs ...string) predicate.Mapping { + return predicate.Mapping(sql.FieldIn(FieldSha256, vs...)) +} + +// Sha256NotIn applies the NotIn predicate on the "sha256" field. +func Sha256NotIn(vs ...string) predicate.Mapping { + return predicate.Mapping(sql.FieldNotIn(FieldSha256, vs...)) +} + +// Sha256GT applies the GT predicate on the "sha256" field. +func Sha256GT(v string) predicate.Mapping { + return predicate.Mapping(sql.FieldGT(FieldSha256, v)) +} + +// Sha256GTE applies the GTE predicate on the "sha256" field. +func Sha256GTE(v string) predicate.Mapping { + return predicate.Mapping(sql.FieldGTE(FieldSha256, v)) +} + +// Sha256LT applies the LT predicate on the "sha256" field. +func Sha256LT(v string) predicate.Mapping { + return predicate.Mapping(sql.FieldLT(FieldSha256, v)) +} + +// Sha256LTE applies the LTE predicate on the "sha256" field. +func Sha256LTE(v string) predicate.Mapping { + return predicate.Mapping(sql.FieldLTE(FieldSha256, v)) +} + +// Sha256Contains applies the Contains predicate on the "sha256" field. +func Sha256Contains(v string) predicate.Mapping { + return predicate.Mapping(sql.FieldContains(FieldSha256, v)) +} + +// Sha256HasPrefix applies the HasPrefix predicate on the "sha256" field. +func Sha256HasPrefix(v string) predicate.Mapping { + return predicate.Mapping(sql.FieldHasPrefix(FieldSha256, v)) +} + +// Sha256HasSuffix applies the HasSuffix predicate on the "sha256" field. +func Sha256HasSuffix(v string) predicate.Mapping { + return predicate.Mapping(sql.FieldHasSuffix(FieldSha256, v)) +} + +// Sha256EqualFold applies the EqualFold predicate on the "sha256" field. +func Sha256EqualFold(v string) predicate.Mapping { + return predicate.Mapping(sql.FieldEqualFold(FieldSha256, v)) +} + +// Sha256ContainsFold applies the ContainsFold predicate on the "sha256" field. +func Sha256ContainsFold(v string) predicate.Mapping { + return predicate.Mapping(sql.FieldContainsFold(FieldSha256, v)) +} + +// GitoidSha1EQ applies the EQ predicate on the "gitoidSha1" field. +func GitoidSha1EQ(v string) predicate.Mapping { + return predicate.Mapping(sql.FieldEQ(FieldGitoidSha1, v)) +} + +// GitoidSha1NEQ applies the NEQ predicate on the "gitoidSha1" field. +func GitoidSha1NEQ(v string) predicate.Mapping { + return predicate.Mapping(sql.FieldNEQ(FieldGitoidSha1, v)) +} + +// GitoidSha1In applies the In predicate on the "gitoidSha1" field. +func GitoidSha1In(vs ...string) predicate.Mapping { + return predicate.Mapping(sql.FieldIn(FieldGitoidSha1, vs...)) +} + +// GitoidSha1NotIn applies the NotIn predicate on the "gitoidSha1" field. +func GitoidSha1NotIn(vs ...string) predicate.Mapping { + return predicate.Mapping(sql.FieldNotIn(FieldGitoidSha1, vs...)) +} + +// GitoidSha1GT applies the GT predicate on the "gitoidSha1" field. +func GitoidSha1GT(v string) predicate.Mapping { + return predicate.Mapping(sql.FieldGT(FieldGitoidSha1, v)) +} + +// GitoidSha1GTE applies the GTE predicate on the "gitoidSha1" field. +func GitoidSha1GTE(v string) predicate.Mapping { + return predicate.Mapping(sql.FieldGTE(FieldGitoidSha1, v)) +} + +// GitoidSha1LT applies the LT predicate on the "gitoidSha1" field. +func GitoidSha1LT(v string) predicate.Mapping { + return predicate.Mapping(sql.FieldLT(FieldGitoidSha1, v)) +} + +// GitoidSha1LTE applies the LTE predicate on the "gitoidSha1" field. +func GitoidSha1LTE(v string) predicate.Mapping { + return predicate.Mapping(sql.FieldLTE(FieldGitoidSha1, v)) +} + +// GitoidSha1Contains applies the Contains predicate on the "gitoidSha1" field. +func GitoidSha1Contains(v string) predicate.Mapping { + return predicate.Mapping(sql.FieldContains(FieldGitoidSha1, v)) +} + +// GitoidSha1HasPrefix applies the HasPrefix predicate on the "gitoidSha1" field. +func GitoidSha1HasPrefix(v string) predicate.Mapping { + return predicate.Mapping(sql.FieldHasPrefix(FieldGitoidSha1, v)) +} + +// GitoidSha1HasSuffix applies the HasSuffix predicate on the "gitoidSha1" field. +func GitoidSha1HasSuffix(v string) predicate.Mapping { + return predicate.Mapping(sql.FieldHasSuffix(FieldGitoidSha1, v)) +} + +// GitoidSha1EqualFold applies the EqualFold predicate on the "gitoidSha1" field. +func GitoidSha1EqualFold(v string) predicate.Mapping { + return predicate.Mapping(sql.FieldEqualFold(FieldGitoidSha1, v)) +} + +// GitoidSha1ContainsFold applies the ContainsFold predicate on the "gitoidSha1" field. +func GitoidSha1ContainsFold(v string) predicate.Mapping { + return predicate.Mapping(sql.FieldContainsFold(FieldGitoidSha1, v)) +} + +// GitoidSha256EQ applies the EQ predicate on the "gitoidSha256" field. +func GitoidSha256EQ(v string) predicate.Mapping { + return predicate.Mapping(sql.FieldEQ(FieldGitoidSha256, v)) +} + +// GitoidSha256NEQ applies the NEQ predicate on the "gitoidSha256" field. +func GitoidSha256NEQ(v string) predicate.Mapping { + return predicate.Mapping(sql.FieldNEQ(FieldGitoidSha256, v)) +} + +// GitoidSha256In applies the In predicate on the "gitoidSha256" field. +func GitoidSha256In(vs ...string) predicate.Mapping { + return predicate.Mapping(sql.FieldIn(FieldGitoidSha256, vs...)) +} + +// GitoidSha256NotIn applies the NotIn predicate on the "gitoidSha256" field. +func GitoidSha256NotIn(vs ...string) predicate.Mapping { + return predicate.Mapping(sql.FieldNotIn(FieldGitoidSha256, vs...)) +} + +// GitoidSha256GT applies the GT predicate on the "gitoidSha256" field. +func GitoidSha256GT(v string) predicate.Mapping { + return predicate.Mapping(sql.FieldGT(FieldGitoidSha256, v)) +} + +// GitoidSha256GTE applies the GTE predicate on the "gitoidSha256" field. +func GitoidSha256GTE(v string) predicate.Mapping { + return predicate.Mapping(sql.FieldGTE(FieldGitoidSha256, v)) +} + +// GitoidSha256LT applies the LT predicate on the "gitoidSha256" field. +func GitoidSha256LT(v string) predicate.Mapping { + return predicate.Mapping(sql.FieldLT(FieldGitoidSha256, v)) +} + +// GitoidSha256LTE applies the LTE predicate on the "gitoidSha256" field. +func GitoidSha256LTE(v string) predicate.Mapping { + return predicate.Mapping(sql.FieldLTE(FieldGitoidSha256, v)) +} + +// GitoidSha256Contains applies the Contains predicate on the "gitoidSha256" field. +func GitoidSha256Contains(v string) predicate.Mapping { + return predicate.Mapping(sql.FieldContains(FieldGitoidSha256, v)) +} + +// GitoidSha256HasPrefix applies the HasPrefix predicate on the "gitoidSha256" field. +func GitoidSha256HasPrefix(v string) predicate.Mapping { + return predicate.Mapping(sql.FieldHasPrefix(FieldGitoidSha256, v)) +} + +// GitoidSha256HasSuffix applies the HasSuffix predicate on the "gitoidSha256" field. +func GitoidSha256HasSuffix(v string) predicate.Mapping { + return predicate.Mapping(sql.FieldHasSuffix(FieldGitoidSha256, v)) +} + +// GitoidSha256EqualFold applies the EqualFold predicate on the "gitoidSha256" field. +func GitoidSha256EqualFold(v string) predicate.Mapping { + return predicate.Mapping(sql.FieldEqualFold(FieldGitoidSha256, v)) +} + +// GitoidSha256ContainsFold applies the ContainsFold predicate on the "gitoidSha256" field. +func GitoidSha256ContainsFold(v string) predicate.Mapping { + return predicate.Mapping(sql.FieldContainsFold(FieldGitoidSha256, v)) +} + +// HasPosix applies the HasEdge predicate on the "posix" edge. +func HasPosix() predicate.Mapping { + return predicate.Mapping(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, PosixTable, PosixColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasPosixWith applies the HasEdge predicate on the "posix" edge with a given conditions (other predicates). +func HasPosixWith(preds ...predicate.Posix) predicate.Mapping { + return predicate.Mapping(func(s *sql.Selector) { + step := newPosixStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasOmnitrail applies the HasEdge predicate on the "omnitrail" edge. +func HasOmnitrail() predicate.Mapping { + return predicate.Mapping(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, OmnitrailTable, OmnitrailColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasOmnitrailWith applies the HasEdge predicate on the "omnitrail" edge with a given conditions (other predicates). +func HasOmnitrailWith(preds ...predicate.Omnitrail) predicate.Mapping { + return predicate.Mapping(func(s *sql.Selector) { + step := newOmnitrailStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.Mapping) predicate.Mapping { + return predicate.Mapping(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.Mapping) predicate.Mapping { + return predicate.Mapping(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.Mapping) predicate.Mapping { + return predicate.Mapping(sql.NotPredicates(p)) +} diff --git a/ent/mapping_create.go b/ent/mapping_create.go new file mode 100644 index 00000000..2ca9594c --- /dev/null +++ b/ent/mapping_create.go @@ -0,0 +1,332 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/in-toto/archivista/ent/mapping" + "github.com/in-toto/archivista/ent/omnitrail" + "github.com/in-toto/archivista/ent/posix" +) + +// MappingCreate is the builder for creating a Mapping entity. +type MappingCreate struct { + config + mutation *MappingMutation + hooks []Hook +} + +// SetPath sets the "path" field. +func (mc *MappingCreate) SetPath(s string) *MappingCreate { + mc.mutation.SetPath(s) + return mc +} + +// SetType sets the "type" field. +func (mc *MappingCreate) SetType(s string) *MappingCreate { + mc.mutation.SetType(s) + return mc +} + +// SetSha1 sets the "sha1" field. +func (mc *MappingCreate) SetSha1(s string) *MappingCreate { + mc.mutation.SetSha1(s) + return mc +} + +// SetSha256 sets the "sha256" field. +func (mc *MappingCreate) SetSha256(s string) *MappingCreate { + mc.mutation.SetSha256(s) + return mc +} + +// SetGitoidSha1 sets the "gitoidSha1" field. +func (mc *MappingCreate) SetGitoidSha1(s string) *MappingCreate { + mc.mutation.SetGitoidSha1(s) + return mc +} + +// SetGitoidSha256 sets the "gitoidSha256" field. +func (mc *MappingCreate) SetGitoidSha256(s string) *MappingCreate { + mc.mutation.SetGitoidSha256(s) + return mc +} + +// AddPosixIDs adds the "posix" edge to the Posix entity by IDs. +func (mc *MappingCreate) AddPosixIDs(ids ...int) *MappingCreate { + mc.mutation.AddPosixIDs(ids...) + return mc +} + +// AddPosix adds the "posix" edges to the Posix entity. +func (mc *MappingCreate) AddPosix(p ...*Posix) *MappingCreate { + ids := make([]int, len(p)) + for i := range p { + ids[i] = p[i].ID + } + return mc.AddPosixIDs(ids...) +} + +// SetOmnitrailID sets the "omnitrail" edge to the Omnitrail entity by ID. +func (mc *MappingCreate) SetOmnitrailID(id int) *MappingCreate { + mc.mutation.SetOmnitrailID(id) + return mc +} + +// SetOmnitrail sets the "omnitrail" edge to the Omnitrail entity. +func (mc *MappingCreate) SetOmnitrail(o *Omnitrail) *MappingCreate { + return mc.SetOmnitrailID(o.ID) +} + +// Mutation returns the MappingMutation object of the builder. +func (mc *MappingCreate) Mutation() *MappingMutation { + return mc.mutation +} + +// Save creates the Mapping in the database. +func (mc *MappingCreate) Save(ctx context.Context) (*Mapping, error) { + return withHooks(ctx, mc.sqlSave, mc.mutation, mc.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (mc *MappingCreate) SaveX(ctx context.Context) *Mapping { + v, err := mc.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (mc *MappingCreate) Exec(ctx context.Context) error { + _, err := mc.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (mc *MappingCreate) ExecX(ctx context.Context) { + if err := mc.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (mc *MappingCreate) check() error { + if _, ok := mc.mutation.Path(); !ok { + return &ValidationError{Name: "path", err: errors.New(`ent: missing required field "Mapping.path"`)} + } + if v, ok := mc.mutation.Path(); ok { + if err := mapping.PathValidator(v); err != nil { + return &ValidationError{Name: "path", err: fmt.Errorf(`ent: validator failed for field "Mapping.path": %w`, err)} + } + } + if _, ok := mc.mutation.GetType(); !ok { + return &ValidationError{Name: "type", err: errors.New(`ent: missing required field "Mapping.type"`)} + } + if v, ok := mc.mutation.GetType(); ok { + if err := mapping.TypeValidator(v); err != nil { + return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "Mapping.type": %w`, err)} + } + } + if _, ok := mc.mutation.Sha1(); !ok { + return &ValidationError{Name: "sha1", err: errors.New(`ent: missing required field "Mapping.sha1"`)} + } + if _, ok := mc.mutation.Sha256(); !ok { + return &ValidationError{Name: "sha256", err: errors.New(`ent: missing required field "Mapping.sha256"`)} + } + if _, ok := mc.mutation.GitoidSha1(); !ok { + return &ValidationError{Name: "gitoidSha1", err: errors.New(`ent: missing required field "Mapping.gitoidSha1"`)} + } + if v, ok := mc.mutation.GitoidSha1(); ok { + if err := mapping.GitoidSha1Validator(v); err != nil { + return &ValidationError{Name: "gitoidSha1", err: fmt.Errorf(`ent: validator failed for field "Mapping.gitoidSha1": %w`, err)} + } + } + if _, ok := mc.mutation.GitoidSha256(); !ok { + return &ValidationError{Name: "gitoidSha256", err: errors.New(`ent: missing required field "Mapping.gitoidSha256"`)} + } + if v, ok := mc.mutation.GitoidSha256(); ok { + if err := mapping.GitoidSha256Validator(v); err != nil { + return &ValidationError{Name: "gitoidSha256", err: fmt.Errorf(`ent: validator failed for field "Mapping.gitoidSha256": %w`, err)} + } + } + if _, ok := mc.mutation.OmnitrailID(); !ok { + return &ValidationError{Name: "omnitrail", err: errors.New(`ent: missing required edge "Mapping.omnitrail"`)} + } + return nil +} + +func (mc *MappingCreate) sqlSave(ctx context.Context) (*Mapping, error) { + if err := mc.check(); err != nil { + return nil, err + } + _node, _spec := mc.createSpec() + if err := sqlgraph.CreateNode(ctx, mc.driver, _spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + id := _spec.ID.Value.(int64) + _node.ID = int(id) + mc.mutation.id = &_node.ID + mc.mutation.done = true + return _node, nil +} + +func (mc *MappingCreate) createSpec() (*Mapping, *sqlgraph.CreateSpec) { + var ( + _node = &Mapping{config: mc.config} + _spec = sqlgraph.NewCreateSpec(mapping.Table, sqlgraph.NewFieldSpec(mapping.FieldID, field.TypeInt)) + ) + if value, ok := mc.mutation.Path(); ok { + _spec.SetField(mapping.FieldPath, field.TypeString, value) + _node.Path = value + } + if value, ok := mc.mutation.GetType(); ok { + _spec.SetField(mapping.FieldType, field.TypeString, value) + _node.Type = value + } + if value, ok := mc.mutation.Sha1(); ok { + _spec.SetField(mapping.FieldSha1, field.TypeString, value) + _node.Sha1 = value + } + if value, ok := mc.mutation.Sha256(); ok { + _spec.SetField(mapping.FieldSha256, field.TypeString, value) + _node.Sha256 = value + } + if value, ok := mc.mutation.GitoidSha1(); ok { + _spec.SetField(mapping.FieldGitoidSha1, field.TypeString, value) + _node.GitoidSha1 = value + } + if value, ok := mc.mutation.GitoidSha256(); ok { + _spec.SetField(mapping.FieldGitoidSha256, field.TypeString, value) + _node.GitoidSha256 = value + } + if nodes := mc.mutation.PosixIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: mapping.PosixTable, + Columns: []string{mapping.PosixColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(posix.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := mc.mutation.OmnitrailIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: mapping.OmnitrailTable, + Columns: []string{mapping.OmnitrailColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(omnitrail.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _node.omnitrail_mappings = &nodes[0] + _spec.Edges = append(_spec.Edges, edge) + } + return _node, _spec +} + +// MappingCreateBulk is the builder for creating many Mapping entities in bulk. +type MappingCreateBulk struct { + config + err error + builders []*MappingCreate +} + +// Save creates the Mapping entities in the database. +func (mcb *MappingCreateBulk) Save(ctx context.Context) ([]*Mapping, error) { + if mcb.err != nil { + return nil, mcb.err + } + specs := make([]*sqlgraph.CreateSpec, len(mcb.builders)) + nodes := make([]*Mapping, len(mcb.builders)) + mutators := make([]Mutator, len(mcb.builders)) + for i := range mcb.builders { + func(i int, root context.Context) { + builder := mcb.builders[i] + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*MappingMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + if err := builder.check(); err != nil { + return nil, err + } + builder.mutation = mutation + var err error + nodes[i], specs[i] = builder.createSpec() + if i < len(mutators)-1 { + _, err = mutators[i+1].Mutate(root, mcb.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, mcb.driver, spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + } + } + if err != nil { + return nil, err + } + mutation.id = &nodes[i].ID + if specs[i].ID.Value != nil { + id := specs[i].ID.Value.(int64) + nodes[i].ID = int(id) + } + mutation.done = true + 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, mcb.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (mcb *MappingCreateBulk) SaveX(ctx context.Context) []*Mapping { + v, err := mcb.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (mcb *MappingCreateBulk) Exec(ctx context.Context) error { + _, err := mcb.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (mcb *MappingCreateBulk) ExecX(ctx context.Context) { + if err := mcb.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/ent/mapping_delete.go b/ent/mapping_delete.go new file mode 100644 index 00000000..d5583f8c --- /dev/null +++ b/ent/mapping_delete.go @@ -0,0 +1,88 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/in-toto/archivista/ent/mapping" + "github.com/in-toto/archivista/ent/predicate" +) + +// MappingDelete is the builder for deleting a Mapping entity. +type MappingDelete struct { + config + hooks []Hook + mutation *MappingMutation +} + +// Where appends a list predicates to the MappingDelete builder. +func (md *MappingDelete) Where(ps ...predicate.Mapping) *MappingDelete { + md.mutation.Where(ps...) + return md +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (md *MappingDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, md.sqlExec, md.mutation, md.hooks) +} + +// ExecX is like Exec, but panics if an error occurs. +func (md *MappingDelete) ExecX(ctx context.Context) int { + n, err := md.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (md *MappingDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(mapping.Table, sqlgraph.NewFieldSpec(mapping.FieldID, field.TypeInt)) + if ps := md.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + affected, err := sqlgraph.DeleteNodes(ctx, md.driver, _spec) + if err != nil && sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + md.mutation.done = true + return affected, err +} + +// MappingDeleteOne is the builder for deleting a single Mapping entity. +type MappingDeleteOne struct { + md *MappingDelete +} + +// Where appends a list predicates to the MappingDelete builder. +func (mdo *MappingDeleteOne) Where(ps ...predicate.Mapping) *MappingDeleteOne { + mdo.md.mutation.Where(ps...) + return mdo +} + +// Exec executes the deletion query. +func (mdo *MappingDeleteOne) Exec(ctx context.Context) error { + n, err := mdo.md.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{mapping.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (mdo *MappingDeleteOne) ExecX(ctx context.Context) { + if err := mdo.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/ent/mapping_query.go b/ent/mapping_query.go new file mode 100644 index 00000000..70bbfd26 --- /dev/null +++ b/ent/mapping_query.go @@ -0,0 +1,724 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "database/sql/driver" + "fmt" + "math" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/in-toto/archivista/ent/mapping" + "github.com/in-toto/archivista/ent/omnitrail" + "github.com/in-toto/archivista/ent/posix" + "github.com/in-toto/archivista/ent/predicate" +) + +// MappingQuery is the builder for querying Mapping entities. +type MappingQuery struct { + config + ctx *QueryContext + order []mapping.OrderOption + inters []Interceptor + predicates []predicate.Mapping + withPosix *PosixQuery + withOmnitrail *OmnitrailQuery + withFKs bool + modifiers []func(*sql.Selector) + loadTotal []func(context.Context, []*Mapping) error + withNamedPosix map[string]*PosixQuery + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Where adds a new predicate for the MappingQuery builder. +func (mq *MappingQuery) Where(ps ...predicate.Mapping) *MappingQuery { + mq.predicates = append(mq.predicates, ps...) + return mq +} + +// Limit the number of records to be returned by this query. +func (mq *MappingQuery) Limit(limit int) *MappingQuery { + mq.ctx.Limit = &limit + return mq +} + +// Offset to start from. +func (mq *MappingQuery) Offset(offset int) *MappingQuery { + mq.ctx.Offset = &offset + return mq +} + +// 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 (mq *MappingQuery) Unique(unique bool) *MappingQuery { + mq.ctx.Unique = &unique + return mq +} + +// Order specifies how the records should be ordered. +func (mq *MappingQuery) Order(o ...mapping.OrderOption) *MappingQuery { + mq.order = append(mq.order, o...) + return mq +} + +// QueryPosix chains the current query on the "posix" edge. +func (mq *MappingQuery) QueryPosix() *PosixQuery { + query := (&PosixClient{config: mq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := mq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := mq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(mapping.Table, mapping.FieldID, selector), + sqlgraph.To(posix.Table, posix.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, mapping.PosixTable, mapping.PosixColumn), + ) + fromU = sqlgraph.SetNeighbors(mq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryOmnitrail chains the current query on the "omnitrail" edge. +func (mq *MappingQuery) QueryOmnitrail() *OmnitrailQuery { + query := (&OmnitrailClient{config: mq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := mq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := mq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(mapping.Table, mapping.FieldID, selector), + sqlgraph.To(omnitrail.Table, omnitrail.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, mapping.OmnitrailTable, mapping.OmnitrailColumn), + ) + fromU = sqlgraph.SetNeighbors(mq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// First returns the first Mapping entity from the query. +// Returns a *NotFoundError when no Mapping was found. +func (mq *MappingQuery) First(ctx context.Context) (*Mapping, error) { + nodes, err := mq.Limit(1).All(setContextOp(ctx, mq.ctx, "First")) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{mapping.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (mq *MappingQuery) FirstX(ctx context.Context) *Mapping { + node, err := mq.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first Mapping ID from the query. +// Returns a *NotFoundError when no Mapping ID was found. +func (mq *MappingQuery) FirstID(ctx context.Context) (id int, err error) { + var ids []int + if ids, err = mq.Limit(1).IDs(setContextOp(ctx, mq.ctx, "FirstID")); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{mapping.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (mq *MappingQuery) FirstIDX(ctx context.Context) int { + id, err := mq.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single Mapping entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one Mapping entity is found. +// Returns a *NotFoundError when no Mapping entities are found. +func (mq *MappingQuery) Only(ctx context.Context) (*Mapping, error) { + nodes, err := mq.Limit(2).All(setContextOp(ctx, mq.ctx, "Only")) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{mapping.Label} + default: + return nil, &NotSingularError{mapping.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (mq *MappingQuery) OnlyX(ctx context.Context) *Mapping { + node, err := mq.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only Mapping ID in the query. +// Returns a *NotSingularError when more than one Mapping ID is found. +// Returns a *NotFoundError when no entities are found. +func (mq *MappingQuery) OnlyID(ctx context.Context) (id int, err error) { + var ids []int + if ids, err = mq.Limit(2).IDs(setContextOp(ctx, mq.ctx, "OnlyID")); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{mapping.Label} + default: + err = &NotSingularError{mapping.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (mq *MappingQuery) OnlyIDX(ctx context.Context) int { + id, err := mq.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of Mappings. +func (mq *MappingQuery) All(ctx context.Context) ([]*Mapping, error) { + ctx = setContextOp(ctx, mq.ctx, "All") + if err := mq.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*Mapping, *MappingQuery]() + return withInterceptors[[]*Mapping](ctx, mq, qr, mq.inters) +} + +// AllX is like All, but panics if an error occurs. +func (mq *MappingQuery) AllX(ctx context.Context) []*Mapping { + nodes, err := mq.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of Mapping IDs. +func (mq *MappingQuery) IDs(ctx context.Context) (ids []int, err error) { + if mq.ctx.Unique == nil && mq.path != nil { + mq.Unique(true) + } + ctx = setContextOp(ctx, mq.ctx, "IDs") + if err = mq.Select(mapping.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (mq *MappingQuery) IDsX(ctx context.Context) []int { + ids, err := mq.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (mq *MappingQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, mq.ctx, "Count") + if err := mq.prepareQuery(ctx); err != nil { + return 0, err + } + return withInterceptors[int](ctx, mq, querierCount[*MappingQuery](), mq.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (mq *MappingQuery) CountX(ctx context.Context) int { + count, err := mq.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (mq *MappingQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, mq.ctx, "Exist") + switch _, err := mq.FirstID(ctx); { + case IsNotFound(err): + return false, nil + case err != nil: + return false, fmt.Errorf("ent: check existence: %w", err) + default: + return true, nil + } +} + +// ExistX is like Exist, but panics if an error occurs. +func (mq *MappingQuery) ExistX(ctx context.Context) bool { + exist, err := mq.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the MappingQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (mq *MappingQuery) Clone() *MappingQuery { + if mq == nil { + return nil + } + return &MappingQuery{ + config: mq.config, + ctx: mq.ctx.Clone(), + order: append([]mapping.OrderOption{}, mq.order...), + inters: append([]Interceptor{}, mq.inters...), + predicates: append([]predicate.Mapping{}, mq.predicates...), + withPosix: mq.withPosix.Clone(), + withOmnitrail: mq.withOmnitrail.Clone(), + // clone intermediate query. + sql: mq.sql.Clone(), + path: mq.path, + } +} + +// WithPosix tells the query-builder to eager-load the nodes that are connected to +// the "posix" edge. The optional arguments are used to configure the query builder of the edge. +func (mq *MappingQuery) WithPosix(opts ...func(*PosixQuery)) *MappingQuery { + query := (&PosixClient{config: mq.config}).Query() + for _, opt := range opts { + opt(query) + } + mq.withPosix = query + return mq +} + +// WithOmnitrail tells the query-builder to eager-load the nodes that are connected to +// the "omnitrail" edge. The optional arguments are used to configure the query builder of the edge. +func (mq *MappingQuery) WithOmnitrail(opts ...func(*OmnitrailQuery)) *MappingQuery { + query := (&OmnitrailClient{config: mq.config}).Query() + for _, opt := range opts { + opt(query) + } + mq.withOmnitrail = query + return mq +} + +// 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 { +// Path string `json:"path,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.Mapping.Query(). +// GroupBy(mapping.FieldPath). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +func (mq *MappingQuery) GroupBy(field string, fields ...string) *MappingGroupBy { + mq.ctx.Fields = append([]string{field}, fields...) + grbuild := &MappingGroupBy{build: mq} + grbuild.flds = &mq.ctx.Fields + grbuild.label = mapping.Label + grbuild.scan = grbuild.Scan + return grbuild +} + +// 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 { +// Path string `json:"path,omitempty"` +// } +// +// client.Mapping.Query(). +// Select(mapping.FieldPath). +// Scan(ctx, &v) +func (mq *MappingQuery) Select(fields ...string) *MappingSelect { + mq.ctx.Fields = append(mq.ctx.Fields, fields...) + sbuild := &MappingSelect{MappingQuery: mq} + sbuild.label = mapping.Label + sbuild.flds, sbuild.scan = &mq.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a MappingSelect configured with the given aggregations. +func (mq *MappingQuery) Aggregate(fns ...AggregateFunc) *MappingSelect { + return mq.Select().Aggregate(fns...) +} + +func (mq *MappingQuery) prepareQuery(ctx context.Context) error { + for _, inter := range mq.inters { + if inter == nil { + return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") + } + if trv, ok := inter.(Traverser); ok { + if err := trv.Traverse(ctx, mq); err != nil { + return err + } + } + } + for _, f := range mq.ctx.Fields { + if !mapping.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + } + if mq.path != nil { + prev, err := mq.path(ctx) + if err != nil { + return err + } + mq.sql = prev + } + return nil +} + +func (mq *MappingQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Mapping, error) { + var ( + nodes = []*Mapping{} + withFKs = mq.withFKs + _spec = mq.querySpec() + loadedTypes = [2]bool{ + mq.withPosix != nil, + mq.withOmnitrail != nil, + } + ) + if mq.withOmnitrail != nil { + withFKs = true + } + if withFKs { + _spec.Node.Columns = append(_spec.Node.Columns, mapping.ForeignKeys...) + } + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*Mapping).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &Mapping{config: mq.config} + nodes = append(nodes, node) + node.Edges.loadedTypes = loadedTypes + return node.assignValues(columns, values) + } + if len(mq.modifiers) > 0 { + _spec.Modifiers = mq.modifiers + } + for i := range hooks { + hooks[i](ctx, _spec) + } + if err := sqlgraph.QueryNodes(ctx, mq.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + if query := mq.withPosix; query != nil { + if err := mq.loadPosix(ctx, query, nodes, + func(n *Mapping) { n.Edges.Posix = []*Posix{} }, + func(n *Mapping, e *Posix) { n.Edges.Posix = append(n.Edges.Posix, e) }); err != nil { + return nil, err + } + } + if query := mq.withOmnitrail; query != nil { + if err := mq.loadOmnitrail(ctx, query, nodes, nil, + func(n *Mapping, e *Omnitrail) { n.Edges.Omnitrail = e }); err != nil { + return nil, err + } + } + for name, query := range mq.withNamedPosix { + if err := mq.loadPosix(ctx, query, nodes, + func(n *Mapping) { n.appendNamedPosix(name) }, + func(n *Mapping, e *Posix) { n.appendNamedPosix(name, e) }); err != nil { + return nil, err + } + } + for i := range mq.loadTotal { + if err := mq.loadTotal[i](ctx, nodes); err != nil { + return nil, err + } + } + return nodes, nil +} + +func (mq *MappingQuery) loadPosix(ctx context.Context, query *PosixQuery, nodes []*Mapping, init func(*Mapping), assign func(*Mapping, *Posix)) error { + fks := make([]driver.Value, 0, len(nodes)) + nodeids := make(map[int]*Mapping) + for i := range nodes { + fks = append(fks, nodes[i].ID) + nodeids[nodes[i].ID] = nodes[i] + if init != nil { + init(nodes[i]) + } + } + query.withFKs = true + query.Where(predicate.Posix(func(s *sql.Selector) { + s.Where(sql.InValues(s.C(mapping.PosixColumn), fks...)) + })) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + fk := n.mapping_posix + if fk == nil { + return fmt.Errorf(`foreign-key "mapping_posix" is nil for node %v`, n.ID) + } + node, ok := nodeids[*fk] + if !ok { + return fmt.Errorf(`unexpected referenced foreign-key "mapping_posix" returned %v for node %v`, *fk, n.ID) + } + assign(node, n) + } + return nil +} +func (mq *MappingQuery) loadOmnitrail(ctx context.Context, query *OmnitrailQuery, nodes []*Mapping, init func(*Mapping), assign func(*Mapping, *Omnitrail)) error { + ids := make([]int, 0, len(nodes)) + nodeids := make(map[int][]*Mapping) + for i := range nodes { + if nodes[i].omnitrail_mappings == nil { + continue + } + fk := *nodes[i].omnitrail_mappings + if _, ok := nodeids[fk]; !ok { + ids = append(ids, fk) + } + nodeids[fk] = append(nodeids[fk], nodes[i]) + } + if len(ids) == 0 { + return nil + } + query.Where(omnitrail.IDIn(ids...)) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nodeids[n.ID] + if !ok { + return fmt.Errorf(`unexpected foreign-key "omnitrail_mappings" returned %v`, n.ID) + } + for i := range nodes { + assign(nodes[i], n) + } + } + return nil +} + +func (mq *MappingQuery) sqlCount(ctx context.Context) (int, error) { + _spec := mq.querySpec() + if len(mq.modifiers) > 0 { + _spec.Modifiers = mq.modifiers + } + _spec.Node.Columns = mq.ctx.Fields + if len(mq.ctx.Fields) > 0 { + _spec.Unique = mq.ctx.Unique != nil && *mq.ctx.Unique + } + return sqlgraph.CountNodes(ctx, mq.driver, _spec) +} + +func (mq *MappingQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(mapping.Table, mapping.Columns, sqlgraph.NewFieldSpec(mapping.FieldID, field.TypeInt)) + _spec.From = mq.sql + if unique := mq.ctx.Unique; unique != nil { + _spec.Unique = *unique + } else if mq.path != nil { + _spec.Unique = true + } + if fields := mq.ctx.Fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, mapping.FieldID) + for i := range fields { + if fields[i] != mapping.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + } + if ps := mq.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := mq.ctx.Limit; limit != nil { + _spec.Limit = *limit + } + if offset := mq.ctx.Offset; offset != nil { + _spec.Offset = *offset + } + if ps := mq.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (mq *MappingQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(mq.driver.Dialect()) + t1 := builder.Table(mapping.Table) + columns := mq.ctx.Fields + if len(columns) == 0 { + columns = mapping.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if mq.sql != nil { + selector = mq.sql + selector.Select(selector.Columns(columns...)...) + } + if mq.ctx.Unique != nil && *mq.ctx.Unique { + selector.Distinct() + } + for _, p := range mq.predicates { + p(selector) + } + for _, p := range mq.order { + p(selector) + } + if offset := mq.ctx.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 := mq.ctx.Limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// WithNamedPosix tells the query-builder to eager-load the nodes that are connected to the "posix" +// edge with the given name. The optional arguments are used to configure the query builder of the edge. +func (mq *MappingQuery) WithNamedPosix(name string, opts ...func(*PosixQuery)) *MappingQuery { + query := (&PosixClient{config: mq.config}).Query() + for _, opt := range opts { + opt(query) + } + if mq.withNamedPosix == nil { + mq.withNamedPosix = make(map[string]*PosixQuery) + } + mq.withNamedPosix[name] = query + return mq +} + +// MappingGroupBy is the group-by builder for Mapping entities. +type MappingGroupBy struct { + selector + build *MappingQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (mgb *MappingGroupBy) Aggregate(fns ...AggregateFunc) *MappingGroupBy { + mgb.fns = append(mgb.fns, fns...) + return mgb +} + +// Scan applies the selector query and scans the result into the given value. +func (mgb *MappingGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, mgb.build.ctx, "GroupBy") + if err := mgb.build.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*MappingQuery, *MappingGroupBy](ctx, mgb.build, mgb, mgb.build.inters, v) +} + +func (mgb *MappingGroupBy) sqlScan(ctx context.Context, root *MappingQuery, v any) error { + selector := root.sqlQuery(ctx).Select() + aggregation := make([]string, 0, len(mgb.fns)) + for _, fn := range mgb.fns { + aggregation = append(aggregation, fn(selector)) + } + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*mgb.flds)+len(mgb.fns)) + for _, f := range *mgb.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*mgb.flds...)...) + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := mgb.build.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// MappingSelect is the builder for selecting fields of Mapping entities. +type MappingSelect struct { + *MappingQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (ms *MappingSelect) Aggregate(fns ...AggregateFunc) *MappingSelect { + ms.fns = append(ms.fns, fns...) + return ms +} + +// Scan applies the selector query and scans the result into the given value. +func (ms *MappingSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, ms.ctx, "Select") + if err := ms.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*MappingQuery, *MappingSelect](ctx, ms.MappingQuery, ms, ms.inters, v) +} + +func (ms *MappingSelect) sqlScan(ctx context.Context, root *MappingQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(ms.fns)) + for _, fn := range ms.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*ms.selector.flds); { + case n == 0 && len(aggregation) > 0: + selector.Select(aggregation...) + case n != 0 && len(aggregation) > 0: + selector.AppendSelect(aggregation...) + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := ms.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} diff --git a/ent/mapping_update.go b/ent/mapping_update.go new file mode 100644 index 00000000..a3936cb8 --- /dev/null +++ b/ent/mapping_update.go @@ -0,0 +1,697 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/in-toto/archivista/ent/mapping" + "github.com/in-toto/archivista/ent/omnitrail" + "github.com/in-toto/archivista/ent/posix" + "github.com/in-toto/archivista/ent/predicate" +) + +// MappingUpdate is the builder for updating Mapping entities. +type MappingUpdate struct { + config + hooks []Hook + mutation *MappingMutation +} + +// Where appends a list predicates to the MappingUpdate builder. +func (mu *MappingUpdate) Where(ps ...predicate.Mapping) *MappingUpdate { + mu.mutation.Where(ps...) + return mu +} + +// SetPath sets the "path" field. +func (mu *MappingUpdate) SetPath(s string) *MappingUpdate { + mu.mutation.SetPath(s) + return mu +} + +// SetNillablePath sets the "path" field if the given value is not nil. +func (mu *MappingUpdate) SetNillablePath(s *string) *MappingUpdate { + if s != nil { + mu.SetPath(*s) + } + return mu +} + +// SetType sets the "type" field. +func (mu *MappingUpdate) SetType(s string) *MappingUpdate { + mu.mutation.SetType(s) + return mu +} + +// SetNillableType sets the "type" field if the given value is not nil. +func (mu *MappingUpdate) SetNillableType(s *string) *MappingUpdate { + if s != nil { + mu.SetType(*s) + } + return mu +} + +// SetSha1 sets the "sha1" field. +func (mu *MappingUpdate) SetSha1(s string) *MappingUpdate { + mu.mutation.SetSha1(s) + return mu +} + +// SetNillableSha1 sets the "sha1" field if the given value is not nil. +func (mu *MappingUpdate) SetNillableSha1(s *string) *MappingUpdate { + if s != nil { + mu.SetSha1(*s) + } + return mu +} + +// SetSha256 sets the "sha256" field. +func (mu *MappingUpdate) SetSha256(s string) *MappingUpdate { + mu.mutation.SetSha256(s) + return mu +} + +// SetNillableSha256 sets the "sha256" field if the given value is not nil. +func (mu *MappingUpdate) SetNillableSha256(s *string) *MappingUpdate { + if s != nil { + mu.SetSha256(*s) + } + return mu +} + +// SetGitoidSha1 sets the "gitoidSha1" field. +func (mu *MappingUpdate) SetGitoidSha1(s string) *MappingUpdate { + mu.mutation.SetGitoidSha1(s) + return mu +} + +// SetNillableGitoidSha1 sets the "gitoidSha1" field if the given value is not nil. +func (mu *MappingUpdate) SetNillableGitoidSha1(s *string) *MappingUpdate { + if s != nil { + mu.SetGitoidSha1(*s) + } + return mu +} + +// SetGitoidSha256 sets the "gitoidSha256" field. +func (mu *MappingUpdate) SetGitoidSha256(s string) *MappingUpdate { + mu.mutation.SetGitoidSha256(s) + return mu +} + +// SetNillableGitoidSha256 sets the "gitoidSha256" field if the given value is not nil. +func (mu *MappingUpdate) SetNillableGitoidSha256(s *string) *MappingUpdate { + if s != nil { + mu.SetGitoidSha256(*s) + } + return mu +} + +// AddPosixIDs adds the "posix" edge to the Posix entity by IDs. +func (mu *MappingUpdate) AddPosixIDs(ids ...int) *MappingUpdate { + mu.mutation.AddPosixIDs(ids...) + return mu +} + +// AddPosix adds the "posix" edges to the Posix entity. +func (mu *MappingUpdate) AddPosix(p ...*Posix) *MappingUpdate { + ids := make([]int, len(p)) + for i := range p { + ids[i] = p[i].ID + } + return mu.AddPosixIDs(ids...) +} + +// SetOmnitrailID sets the "omnitrail" edge to the Omnitrail entity by ID. +func (mu *MappingUpdate) SetOmnitrailID(id int) *MappingUpdate { + mu.mutation.SetOmnitrailID(id) + return mu +} + +// SetOmnitrail sets the "omnitrail" edge to the Omnitrail entity. +func (mu *MappingUpdate) SetOmnitrail(o *Omnitrail) *MappingUpdate { + return mu.SetOmnitrailID(o.ID) +} + +// Mutation returns the MappingMutation object of the builder. +func (mu *MappingUpdate) Mutation() *MappingMutation { + return mu.mutation +} + +// ClearPosix clears all "posix" edges to the Posix entity. +func (mu *MappingUpdate) ClearPosix() *MappingUpdate { + mu.mutation.ClearPosix() + return mu +} + +// RemovePosixIDs removes the "posix" edge to Posix entities by IDs. +func (mu *MappingUpdate) RemovePosixIDs(ids ...int) *MappingUpdate { + mu.mutation.RemovePosixIDs(ids...) + return mu +} + +// RemovePosix removes "posix" edges to Posix entities. +func (mu *MappingUpdate) RemovePosix(p ...*Posix) *MappingUpdate { + ids := make([]int, len(p)) + for i := range p { + ids[i] = p[i].ID + } + return mu.RemovePosixIDs(ids...) +} + +// ClearOmnitrail clears the "omnitrail" edge to the Omnitrail entity. +func (mu *MappingUpdate) ClearOmnitrail() *MappingUpdate { + mu.mutation.ClearOmnitrail() + return mu +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (mu *MappingUpdate) Save(ctx context.Context) (int, error) { + return withHooks(ctx, mu.sqlSave, mu.mutation, mu.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (mu *MappingUpdate) SaveX(ctx context.Context) int { + affected, err := mu.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (mu *MappingUpdate) Exec(ctx context.Context) error { + _, err := mu.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (mu *MappingUpdate) ExecX(ctx context.Context) { + if err := mu.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (mu *MappingUpdate) check() error { + if v, ok := mu.mutation.Path(); ok { + if err := mapping.PathValidator(v); err != nil { + return &ValidationError{Name: "path", err: fmt.Errorf(`ent: validator failed for field "Mapping.path": %w`, err)} + } + } + if v, ok := mu.mutation.GetType(); ok { + if err := mapping.TypeValidator(v); err != nil { + return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "Mapping.type": %w`, err)} + } + } + if v, ok := mu.mutation.GitoidSha1(); ok { + if err := mapping.GitoidSha1Validator(v); err != nil { + return &ValidationError{Name: "gitoidSha1", err: fmt.Errorf(`ent: validator failed for field "Mapping.gitoidSha1": %w`, err)} + } + } + if v, ok := mu.mutation.GitoidSha256(); ok { + if err := mapping.GitoidSha256Validator(v); err != nil { + return &ValidationError{Name: "gitoidSha256", err: fmt.Errorf(`ent: validator failed for field "Mapping.gitoidSha256": %w`, err)} + } + } + if _, ok := mu.mutation.OmnitrailID(); mu.mutation.OmnitrailCleared() && !ok { + return errors.New(`ent: clearing a required unique edge "Mapping.omnitrail"`) + } + return nil +} + +func (mu *MappingUpdate) sqlSave(ctx context.Context) (n int, err error) { + if err := mu.check(); err != nil { + return n, err + } + _spec := sqlgraph.NewUpdateSpec(mapping.Table, mapping.Columns, sqlgraph.NewFieldSpec(mapping.FieldID, field.TypeInt)) + if ps := mu.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := mu.mutation.Path(); ok { + _spec.SetField(mapping.FieldPath, field.TypeString, value) + } + if value, ok := mu.mutation.GetType(); ok { + _spec.SetField(mapping.FieldType, field.TypeString, value) + } + if value, ok := mu.mutation.Sha1(); ok { + _spec.SetField(mapping.FieldSha1, field.TypeString, value) + } + if value, ok := mu.mutation.Sha256(); ok { + _spec.SetField(mapping.FieldSha256, field.TypeString, value) + } + if value, ok := mu.mutation.GitoidSha1(); ok { + _spec.SetField(mapping.FieldGitoidSha1, field.TypeString, value) + } + if value, ok := mu.mutation.GitoidSha256(); ok { + _spec.SetField(mapping.FieldGitoidSha256, field.TypeString, value) + } + if mu.mutation.PosixCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: mapping.PosixTable, + Columns: []string{mapping.PosixColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(posix.FieldID, field.TypeInt), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := mu.mutation.RemovedPosixIDs(); len(nodes) > 0 && !mu.mutation.PosixCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: mapping.PosixTable, + Columns: []string{mapping.PosixColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(posix.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := mu.mutation.PosixIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: mapping.PosixTable, + Columns: []string{mapping.PosixColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(posix.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if mu.mutation.OmnitrailCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: mapping.OmnitrailTable, + Columns: []string{mapping.OmnitrailColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(omnitrail.FieldID, field.TypeInt), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := mu.mutation.OmnitrailIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: mapping.OmnitrailTable, + Columns: []string{mapping.OmnitrailColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(omnitrail.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if n, err = sqlgraph.UpdateNodes(ctx, mu.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{mapping.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + mu.mutation.done = true + return n, nil +} + +// MappingUpdateOne is the builder for updating a single Mapping entity. +type MappingUpdateOne struct { + config + fields []string + hooks []Hook + mutation *MappingMutation +} + +// SetPath sets the "path" field. +func (muo *MappingUpdateOne) SetPath(s string) *MappingUpdateOne { + muo.mutation.SetPath(s) + return muo +} + +// SetNillablePath sets the "path" field if the given value is not nil. +func (muo *MappingUpdateOne) SetNillablePath(s *string) *MappingUpdateOne { + if s != nil { + muo.SetPath(*s) + } + return muo +} + +// SetType sets the "type" field. +func (muo *MappingUpdateOne) SetType(s string) *MappingUpdateOne { + muo.mutation.SetType(s) + return muo +} + +// SetNillableType sets the "type" field if the given value is not nil. +func (muo *MappingUpdateOne) SetNillableType(s *string) *MappingUpdateOne { + if s != nil { + muo.SetType(*s) + } + return muo +} + +// SetSha1 sets the "sha1" field. +func (muo *MappingUpdateOne) SetSha1(s string) *MappingUpdateOne { + muo.mutation.SetSha1(s) + return muo +} + +// SetNillableSha1 sets the "sha1" field if the given value is not nil. +func (muo *MappingUpdateOne) SetNillableSha1(s *string) *MappingUpdateOne { + if s != nil { + muo.SetSha1(*s) + } + return muo +} + +// SetSha256 sets the "sha256" field. +func (muo *MappingUpdateOne) SetSha256(s string) *MappingUpdateOne { + muo.mutation.SetSha256(s) + return muo +} + +// SetNillableSha256 sets the "sha256" field if the given value is not nil. +func (muo *MappingUpdateOne) SetNillableSha256(s *string) *MappingUpdateOne { + if s != nil { + muo.SetSha256(*s) + } + return muo +} + +// SetGitoidSha1 sets the "gitoidSha1" field. +func (muo *MappingUpdateOne) SetGitoidSha1(s string) *MappingUpdateOne { + muo.mutation.SetGitoidSha1(s) + return muo +} + +// SetNillableGitoidSha1 sets the "gitoidSha1" field if the given value is not nil. +func (muo *MappingUpdateOne) SetNillableGitoidSha1(s *string) *MappingUpdateOne { + if s != nil { + muo.SetGitoidSha1(*s) + } + return muo +} + +// SetGitoidSha256 sets the "gitoidSha256" field. +func (muo *MappingUpdateOne) SetGitoidSha256(s string) *MappingUpdateOne { + muo.mutation.SetGitoidSha256(s) + return muo +} + +// SetNillableGitoidSha256 sets the "gitoidSha256" field if the given value is not nil. +func (muo *MappingUpdateOne) SetNillableGitoidSha256(s *string) *MappingUpdateOne { + if s != nil { + muo.SetGitoidSha256(*s) + } + return muo +} + +// AddPosixIDs adds the "posix" edge to the Posix entity by IDs. +func (muo *MappingUpdateOne) AddPosixIDs(ids ...int) *MappingUpdateOne { + muo.mutation.AddPosixIDs(ids...) + return muo +} + +// AddPosix adds the "posix" edges to the Posix entity. +func (muo *MappingUpdateOne) AddPosix(p ...*Posix) *MappingUpdateOne { + ids := make([]int, len(p)) + for i := range p { + ids[i] = p[i].ID + } + return muo.AddPosixIDs(ids...) +} + +// SetOmnitrailID sets the "omnitrail" edge to the Omnitrail entity by ID. +func (muo *MappingUpdateOne) SetOmnitrailID(id int) *MappingUpdateOne { + muo.mutation.SetOmnitrailID(id) + return muo +} + +// SetOmnitrail sets the "omnitrail" edge to the Omnitrail entity. +func (muo *MappingUpdateOne) SetOmnitrail(o *Omnitrail) *MappingUpdateOne { + return muo.SetOmnitrailID(o.ID) +} + +// Mutation returns the MappingMutation object of the builder. +func (muo *MappingUpdateOne) Mutation() *MappingMutation { + return muo.mutation +} + +// ClearPosix clears all "posix" edges to the Posix entity. +func (muo *MappingUpdateOne) ClearPosix() *MappingUpdateOne { + muo.mutation.ClearPosix() + return muo +} + +// RemovePosixIDs removes the "posix" edge to Posix entities by IDs. +func (muo *MappingUpdateOne) RemovePosixIDs(ids ...int) *MappingUpdateOne { + muo.mutation.RemovePosixIDs(ids...) + return muo +} + +// RemovePosix removes "posix" edges to Posix entities. +func (muo *MappingUpdateOne) RemovePosix(p ...*Posix) *MappingUpdateOne { + ids := make([]int, len(p)) + for i := range p { + ids[i] = p[i].ID + } + return muo.RemovePosixIDs(ids...) +} + +// ClearOmnitrail clears the "omnitrail" edge to the Omnitrail entity. +func (muo *MappingUpdateOne) ClearOmnitrail() *MappingUpdateOne { + muo.mutation.ClearOmnitrail() + return muo +} + +// Where appends a list predicates to the MappingUpdate builder. +func (muo *MappingUpdateOne) Where(ps ...predicate.Mapping) *MappingUpdateOne { + muo.mutation.Where(ps...) + return muo +} + +// Select allows selecting one or more fields (columns) of the returned entity. +// The default is selecting all fields defined in the entity schema. +func (muo *MappingUpdateOne) Select(field string, fields ...string) *MappingUpdateOne { + muo.fields = append([]string{field}, fields...) + return muo +} + +// Save executes the query and returns the updated Mapping entity. +func (muo *MappingUpdateOne) Save(ctx context.Context) (*Mapping, error) { + return withHooks(ctx, muo.sqlSave, muo.mutation, muo.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (muo *MappingUpdateOne) SaveX(ctx context.Context) *Mapping { + node, err := muo.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (muo *MappingUpdateOne) Exec(ctx context.Context) error { + _, err := muo.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (muo *MappingUpdateOne) ExecX(ctx context.Context) { + if err := muo.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (muo *MappingUpdateOne) check() error { + if v, ok := muo.mutation.Path(); ok { + if err := mapping.PathValidator(v); err != nil { + return &ValidationError{Name: "path", err: fmt.Errorf(`ent: validator failed for field "Mapping.path": %w`, err)} + } + } + if v, ok := muo.mutation.GetType(); ok { + if err := mapping.TypeValidator(v); err != nil { + return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "Mapping.type": %w`, err)} + } + } + if v, ok := muo.mutation.GitoidSha1(); ok { + if err := mapping.GitoidSha1Validator(v); err != nil { + return &ValidationError{Name: "gitoidSha1", err: fmt.Errorf(`ent: validator failed for field "Mapping.gitoidSha1": %w`, err)} + } + } + if v, ok := muo.mutation.GitoidSha256(); ok { + if err := mapping.GitoidSha256Validator(v); err != nil { + return &ValidationError{Name: "gitoidSha256", err: fmt.Errorf(`ent: validator failed for field "Mapping.gitoidSha256": %w`, err)} + } + } + if _, ok := muo.mutation.OmnitrailID(); muo.mutation.OmnitrailCleared() && !ok { + return errors.New(`ent: clearing a required unique edge "Mapping.omnitrail"`) + } + return nil +} + +func (muo *MappingUpdateOne) sqlSave(ctx context.Context) (_node *Mapping, err error) { + if err := muo.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(mapping.Table, mapping.Columns, sqlgraph.NewFieldSpec(mapping.FieldID, field.TypeInt)) + id, ok := muo.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Mapping.id" for update`)} + } + _spec.Node.ID.Value = id + if fields := muo.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, mapping.FieldID) + for _, f := range fields { + if !mapping.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != mapping.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, f) + } + } + } + if ps := muo.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := muo.mutation.Path(); ok { + _spec.SetField(mapping.FieldPath, field.TypeString, value) + } + if value, ok := muo.mutation.GetType(); ok { + _spec.SetField(mapping.FieldType, field.TypeString, value) + } + if value, ok := muo.mutation.Sha1(); ok { + _spec.SetField(mapping.FieldSha1, field.TypeString, value) + } + if value, ok := muo.mutation.Sha256(); ok { + _spec.SetField(mapping.FieldSha256, field.TypeString, value) + } + if value, ok := muo.mutation.GitoidSha1(); ok { + _spec.SetField(mapping.FieldGitoidSha1, field.TypeString, value) + } + if value, ok := muo.mutation.GitoidSha256(); ok { + _spec.SetField(mapping.FieldGitoidSha256, field.TypeString, value) + } + if muo.mutation.PosixCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: mapping.PosixTable, + Columns: []string{mapping.PosixColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(posix.FieldID, field.TypeInt), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := muo.mutation.RemovedPosixIDs(); len(nodes) > 0 && !muo.mutation.PosixCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: mapping.PosixTable, + Columns: []string{mapping.PosixColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(posix.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := muo.mutation.PosixIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: mapping.PosixTable, + Columns: []string{mapping.PosixColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(posix.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if muo.mutation.OmnitrailCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: mapping.OmnitrailTable, + Columns: []string{mapping.OmnitrailColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(omnitrail.FieldID, field.TypeInt), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := muo.mutation.OmnitrailIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: mapping.OmnitrailTable, + Columns: []string{mapping.OmnitrailColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(omnitrail.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + _node = &Mapping{config: muo.config} + _spec.Assign = _node.assignValues + _spec.ScanValues = _node.scanValues + if err = sqlgraph.UpdateNode(ctx, muo.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{mapping.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + muo.mutation.done = true + return _node, nil +} diff --git a/ent/migrate/schema.go b/ent/migrate/schema.go index 20ab26cb..32db24cb 100644 --- a/ent/migrate/schema.go +++ b/ent/migrate/schema.go @@ -110,6 +110,50 @@ var ( }, }, } + // MappingsColumns holds the columns for the "mappings" table. + MappingsColumns = []*schema.Column{ + {Name: "id", Type: field.TypeInt, Increment: true}, + {Name: "path", Type: field.TypeString}, + {Name: "type", Type: field.TypeString}, + {Name: "sha1", Type: field.TypeString}, + {Name: "sha256", Type: field.TypeString}, + {Name: "gitoid_sha1", Type: field.TypeString}, + {Name: "gitoid_sha256", Type: field.TypeString}, + {Name: "omnitrail_mappings", Type: field.TypeInt}, + } + // MappingsTable holds the schema information for the "mappings" table. + MappingsTable = &schema.Table{ + Name: "mappings", + Columns: MappingsColumns, + PrimaryKey: []*schema.Column{MappingsColumns[0]}, + ForeignKeys: []*schema.ForeignKey{ + { + Symbol: "mappings_omnitrails_mappings", + Columns: []*schema.Column{MappingsColumns[7]}, + RefColumns: []*schema.Column{OmnitrailsColumns[0]}, + OnDelete: schema.NoAction, + }, + }, + } + // OmnitrailsColumns holds the columns for the "omnitrails" table. + OmnitrailsColumns = []*schema.Column{ + {Name: "id", Type: field.TypeInt, Increment: true}, + {Name: "attestation_omnitrail", Type: field.TypeInt, Unique: true}, + } + // OmnitrailsTable holds the schema information for the "omnitrails" table. + OmnitrailsTable = &schema.Table{ + Name: "omnitrails", + Columns: OmnitrailsColumns, + PrimaryKey: []*schema.Column{OmnitrailsColumns[0]}, + ForeignKeys: []*schema.ForeignKey{ + { + Symbol: "omnitrails_attestations_omnitrail", + Columns: []*schema.Column{OmnitrailsColumns[1]}, + RefColumns: []*schema.Column{AttestationsColumns[0]}, + OnDelete: schema.NoAction, + }, + }, + } // PayloadDigestsColumns holds the columns for the "payload_digests" table. PayloadDigestsColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, @@ -138,6 +182,41 @@ var ( }, }, } + // PosixesColumns holds the columns for the "posixes" table. + PosixesColumns = []*schema.Column{ + {Name: "id", Type: field.TypeInt, Increment: true}, + {Name: "atime", Type: field.TypeString}, + {Name: "ctime", Type: field.TypeString}, + {Name: "creation_time", Type: field.TypeString}, + {Name: "extended_attributes", Type: field.TypeString}, + {Name: "file_device_id", Type: field.TypeString}, + {Name: "file_flags", Type: field.TypeString}, + {Name: "file_inode", Type: field.TypeString}, + {Name: "file_system_id", Type: field.TypeString}, + {Name: "file_type", Type: field.TypeString}, + {Name: "hard_link_count", Type: field.TypeString}, + {Name: "mtime", Type: field.TypeString}, + {Name: "metadata_ctime", Type: field.TypeString}, + {Name: "owner_gid", Type: field.TypeString}, + {Name: "owner_uid", Type: field.TypeString}, + {Name: "permissions", Type: field.TypeString}, + {Name: "size", Type: field.TypeString}, + {Name: "mapping_posix", Type: field.TypeInt}, + } + // PosixesTable holds the schema information for the "posixes" table. + PosixesTable = &schema.Table{ + Name: "posixes", + Columns: PosixesColumns, + PrimaryKey: []*schema.Column{PosixesColumns[0]}, + ForeignKeys: []*schema.ForeignKey{ + { + Symbol: "posixes_mappings_posix", + Columns: []*schema.Column{PosixesColumns[17]}, + RefColumns: []*schema.Column{MappingsColumns[0]}, + OnDelete: schema.NoAction, + }, + }, + } // SignaturesColumns holds the columns for the "signatures" table. SignaturesColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, @@ -266,7 +345,10 @@ var ( AttestationCollectionsTable, AttestationPoliciesTable, DssesTable, + MappingsTable, + OmnitrailsTable, PayloadDigestsTable, + PosixesTable, SignaturesTable, StatementsTable, SubjectsTable, @@ -280,7 +362,10 @@ func init() { AttestationCollectionsTable.ForeignKeys[0].RefTable = StatementsTable AttestationPoliciesTable.ForeignKeys[0].RefTable = StatementsTable DssesTable.ForeignKeys[0].RefTable = StatementsTable + MappingsTable.ForeignKeys[0].RefTable = OmnitrailsTable + OmnitrailsTable.ForeignKeys[0].RefTable = AttestationsTable PayloadDigestsTable.ForeignKeys[0].RefTable = DssesTable + PosixesTable.ForeignKeys[0].RefTable = MappingsTable SignaturesTable.ForeignKeys[0].RefTable = DssesTable SubjectsTable.ForeignKeys[0].RefTable = StatementsTable SubjectDigestsTable.ForeignKeys[0].RefTable = SubjectsTable diff --git a/ent/mutation.go b/ent/mutation.go index 699c685d..44c7238f 100644 --- a/ent/mutation.go +++ b/ent/mutation.go @@ -15,7 +15,10 @@ import ( "github.com/in-toto/archivista/ent/attestationcollection" "github.com/in-toto/archivista/ent/attestationpolicy" "github.com/in-toto/archivista/ent/dsse" + "github.com/in-toto/archivista/ent/mapping" + "github.com/in-toto/archivista/ent/omnitrail" "github.com/in-toto/archivista/ent/payloaddigest" + "github.com/in-toto/archivista/ent/posix" "github.com/in-toto/archivista/ent/predicate" "github.com/in-toto/archivista/ent/signature" "github.com/in-toto/archivista/ent/statement" @@ -37,7 +40,10 @@ const ( TypeAttestationCollection = "AttestationCollection" TypeAttestationPolicy = "AttestationPolicy" TypeDsse = "Dsse" + TypeMapping = "Mapping" + TypeOmnitrail = "Omnitrail" TypePayloadDigest = "PayloadDigest" + TypePosix = "Posix" TypeSignature = "Signature" TypeStatement = "Statement" TypeSubject = "Subject" @@ -53,6 +59,8 @@ type AttestationMutation struct { id *int _type *string clearedFields map[string]struct{} + omnitrail *int + clearedomnitrail bool attestation_collection *int clearedattestation_collection bool done bool @@ -194,6 +202,45 @@ func (m *AttestationMutation) ResetType() { m._type = nil } +// SetOmnitrailID sets the "omnitrail" edge to the Omnitrail entity by id. +func (m *AttestationMutation) SetOmnitrailID(id int) { + m.omnitrail = &id +} + +// ClearOmnitrail clears the "omnitrail" edge to the Omnitrail entity. +func (m *AttestationMutation) ClearOmnitrail() { + m.clearedomnitrail = true +} + +// OmnitrailCleared reports if the "omnitrail" edge to the Omnitrail entity was cleared. +func (m *AttestationMutation) OmnitrailCleared() bool { + return m.clearedomnitrail +} + +// OmnitrailID returns the "omnitrail" edge ID in the mutation. +func (m *AttestationMutation) OmnitrailID() (id int, exists bool) { + if m.omnitrail != nil { + return *m.omnitrail, true + } + return +} + +// OmnitrailIDs returns the "omnitrail" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// OmnitrailID instead. It exists only for internal usage by the builders. +func (m *AttestationMutation) OmnitrailIDs() (ids []int) { + if id := m.omnitrail; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetOmnitrail resets all changes to the "omnitrail" edge. +func (m *AttestationMutation) ResetOmnitrail() { + m.omnitrail = nil + m.clearedomnitrail = false +} + // SetAttestationCollectionID sets the "attestation_collection" edge to the AttestationCollection entity by id. func (m *AttestationMutation) SetAttestationCollectionID(id int) { m.attestation_collection = &id @@ -366,7 +413,10 @@ func (m *AttestationMutation) ResetField(name string) error { // AddedEdges returns all edge names that were set/added in this mutation. func (m *AttestationMutation) AddedEdges() []string { - edges := make([]string, 0, 1) + edges := make([]string, 0, 2) + if m.omnitrail != nil { + edges = append(edges, attestation.EdgeOmnitrail) + } if m.attestation_collection != nil { edges = append(edges, attestation.EdgeAttestationCollection) } @@ -377,6 +427,10 @@ func (m *AttestationMutation) AddedEdges() []string { // name in this mutation. func (m *AttestationMutation) AddedIDs(name string) []ent.Value { switch name { + case attestation.EdgeOmnitrail: + if id := m.omnitrail; id != nil { + return []ent.Value{*id} + } case attestation.EdgeAttestationCollection: if id := m.attestation_collection; id != nil { return []ent.Value{*id} @@ -387,7 +441,7 @@ func (m *AttestationMutation) AddedIDs(name string) []ent.Value { // RemovedEdges returns all edge names that were removed in this mutation. func (m *AttestationMutation) RemovedEdges() []string { - edges := make([]string, 0, 1) + edges := make([]string, 0, 2) return edges } @@ -399,7 +453,10 @@ func (m *AttestationMutation) RemovedIDs(name string) []ent.Value { // ClearedEdges returns all edge names that were cleared in this mutation. func (m *AttestationMutation) ClearedEdges() []string { - edges := make([]string, 0, 1) + edges := make([]string, 0, 2) + if m.clearedomnitrail { + edges = append(edges, attestation.EdgeOmnitrail) + } if m.clearedattestation_collection { edges = append(edges, attestation.EdgeAttestationCollection) } @@ -410,6 +467,8 @@ func (m *AttestationMutation) ClearedEdges() []string { // was cleared in this mutation. func (m *AttestationMutation) EdgeCleared(name string) bool { switch name { + case attestation.EdgeOmnitrail: + return m.clearedomnitrail case attestation.EdgeAttestationCollection: return m.clearedattestation_collection } @@ -420,6 +479,9 @@ func (m *AttestationMutation) EdgeCleared(name string) bool { // if that edge is not defined in the schema. func (m *AttestationMutation) ClearEdge(name string) error { switch name { + case attestation.EdgeOmnitrail: + m.ClearOmnitrail() + return nil case attestation.EdgeAttestationCollection: m.ClearAttestationCollection() return nil @@ -431,6 +493,9 @@ func (m *AttestationMutation) ClearEdge(name string) error { // It returns an error if the edge is not defined in the schema. func (m *AttestationMutation) ResetEdge(name string) error { switch name { + case attestation.EdgeOmnitrail: + m.ResetOmnitrail() + return nil case attestation.EdgeAttestationCollection: m.ResetAttestationCollection() return nil @@ -1924,33 +1989,40 @@ func (m *DsseMutation) ResetEdge(name string) error { return fmt.Errorf("unknown Dsse edge %s", name) } -// PayloadDigestMutation represents an operation that mutates the PayloadDigest nodes in the graph. -type PayloadDigestMutation struct { +// MappingMutation represents an operation that mutates the Mapping nodes in the graph. +type MappingMutation struct { config - op Op - typ string - id *int - algorithm *string - value *string - clearedFields map[string]struct{} - dsse *int - cleareddsse bool - done bool - oldValue func(context.Context) (*PayloadDigest, error) - predicates []predicate.PayloadDigest + op Op + typ string + id *int + _path *string + _type *string + sha1 *string + sha256 *string + gitoidSha1 *string + gitoidSha256 *string + clearedFields map[string]struct{} + posix map[int]struct{} + removedposix map[int]struct{} + clearedposix bool + omnitrail *int + clearedomnitrail bool + done bool + oldValue func(context.Context) (*Mapping, error) + predicates []predicate.Mapping } -var _ ent.Mutation = (*PayloadDigestMutation)(nil) +var _ ent.Mutation = (*MappingMutation)(nil) -// payloaddigestOption allows management of the mutation configuration using functional options. -type payloaddigestOption func(*PayloadDigestMutation) +// mappingOption allows management of the mutation configuration using functional options. +type mappingOption func(*MappingMutation) -// newPayloadDigestMutation creates new mutation for the PayloadDigest entity. -func newPayloadDigestMutation(c config, op Op, opts ...payloaddigestOption) *PayloadDigestMutation { - m := &PayloadDigestMutation{ +// newMappingMutation creates new mutation for the Mapping entity. +func newMappingMutation(c config, op Op, opts ...mappingOption) *MappingMutation { + m := &MappingMutation{ config: c, op: op, - typ: TypePayloadDigest, + typ: TypeMapping, clearedFields: make(map[string]struct{}), } for _, opt := range opts { @@ -1959,20 +2031,20 @@ func newPayloadDigestMutation(c config, op Op, opts ...payloaddigestOption) *Pay return m } -// withPayloadDigestID sets the ID field of the mutation. -func withPayloadDigestID(id int) payloaddigestOption { - return func(m *PayloadDigestMutation) { +// withMappingID sets the ID field of the mutation. +func withMappingID(id int) mappingOption { + return func(m *MappingMutation) { var ( err error once sync.Once - value *PayloadDigest + value *Mapping ) - m.oldValue = func(ctx context.Context) (*PayloadDigest, error) { + m.oldValue = func(ctx context.Context) (*Mapping, error) { once.Do(func() { if m.done { err = errors.New("querying old values post mutation is not allowed") } else { - value, err = m.Client().PayloadDigest.Get(ctx, id) + value, err = m.Client().Mapping.Get(ctx, id) } }) return value, err @@ -1981,10 +2053,10 @@ func withPayloadDigestID(id int) payloaddigestOption { } } -// withPayloadDigest sets the old PayloadDigest of the mutation. -func withPayloadDigest(node *PayloadDigest) payloaddigestOption { - return func(m *PayloadDigestMutation) { - m.oldValue = func(context.Context) (*PayloadDigest, error) { +// withMapping sets the old Mapping of the mutation. +func withMapping(node *Mapping) mappingOption { + return func(m *MappingMutation) { + m.oldValue = func(context.Context) (*Mapping, error) { return node, nil } m.id = &node.ID @@ -1993,7 +2065,7 @@ func withPayloadDigest(node *PayloadDigest) payloaddigestOption { // 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 PayloadDigestMutation) Client() *Client { +func (m MappingMutation) Client() *Client { client := &Client{config: m.config} client.init() return client @@ -2001,7 +2073,7 @@ func (m PayloadDigestMutation) Client() *Client { // Tx returns an `ent.Tx` for mutations that were executed in transactions; // it returns an error otherwise. -func (m PayloadDigestMutation) Tx() (*Tx, error) { +func (m MappingMutation) Tx() (*Tx, error) { if _, ok := m.driver.(*txDriver); !ok { return nil, errors.New("ent: mutation is not running in a transaction") } @@ -2012,7 +2084,7 @@ func (m PayloadDigestMutation) Tx() (*Tx, error) { // ID returns the ID value in the mutation. Note that the ID is only available // if it was provided to the builder or after it was returned from the database. -func (m *PayloadDigestMutation) ID() (id int, exists bool) { +func (m *MappingMutation) ID() (id int, exists bool) { if m.id == nil { return } @@ -2023,7 +2095,7 @@ func (m *PayloadDigestMutation) ID() (id int, exists bool) { // That means, if the mutation is applied within a transaction with an isolation level such // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated // or updated by the mutation. -func (m *PayloadDigestMutation) IDs(ctx context.Context) ([]int, error) { +func (m *MappingMutation) IDs(ctx context.Context) ([]int, error) { switch { case m.op.Is(OpUpdateOne | OpDeleteOne): id, exists := m.ID() @@ -2032,132 +2104,330 @@ func (m *PayloadDigestMutation) IDs(ctx context.Context) ([]int, error) { } fallthrough case m.op.Is(OpUpdate | OpDelete): - return m.Client().PayloadDigest.Query().Where(m.predicates...).IDs(ctx) + return m.Client().Mapping.Query().Where(m.predicates...).IDs(ctx) default: return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) } } -// SetAlgorithm sets the "algorithm" field. -func (m *PayloadDigestMutation) SetAlgorithm(s string) { - m.algorithm = &s +// SetPath sets the "path" field. +func (m *MappingMutation) SetPath(s string) { + m._path = &s } -// Algorithm returns the value of the "algorithm" field in the mutation. -func (m *PayloadDigestMutation) Algorithm() (r string, exists bool) { - v := m.algorithm +// Path returns the value of the "path" field in the mutation. +func (m *MappingMutation) Path() (r string, exists bool) { + v := m._path if v == nil { return } return *v, true } -// OldAlgorithm returns the old "algorithm" field's value of the PayloadDigest entity. -// If the PayloadDigest object wasn't provided to the builder, the object is fetched from the database. +// OldPath returns the old "path" field's value of the Mapping entity. +// If the Mapping 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 *PayloadDigestMutation) OldAlgorithm(ctx context.Context) (v string, err error) { +func (m *MappingMutation) OldPath(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldAlgorithm is only allowed on UpdateOne operations") + return v, errors.New("OldPath is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldAlgorithm requires an ID field in the mutation") + return v, errors.New("OldPath requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldAlgorithm: %w", err) + return v, fmt.Errorf("querying old value for OldPath: %w", err) } - return oldValue.Algorithm, nil + return oldValue.Path, nil } -// ResetAlgorithm resets all changes to the "algorithm" field. -func (m *PayloadDigestMutation) ResetAlgorithm() { - m.algorithm = nil +// ResetPath resets all changes to the "path" field. +func (m *MappingMutation) ResetPath() { + m._path = nil } -// SetValue sets the "value" field. -func (m *PayloadDigestMutation) SetValue(s string) { - m.value = &s +// SetType sets the "type" field. +func (m *MappingMutation) SetType(s string) { + m._type = &s } -// Value returns the value of the "value" field in the mutation. -func (m *PayloadDigestMutation) Value() (r string, exists bool) { - v := m.value +// GetType returns the value of the "type" field in the mutation. +func (m *MappingMutation) GetType() (r string, exists bool) { + v := m._type if v == nil { return } return *v, true } -// OldValue returns the old "value" field's value of the PayloadDigest entity. -// If the PayloadDigest object wasn't provided to the builder, the object is fetched from the database. +// OldType returns the old "type" field's value of the Mapping entity. +// If the Mapping 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 *PayloadDigestMutation) OldValue(ctx context.Context) (v string, err error) { +func (m *MappingMutation) OldType(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldValue is only allowed on UpdateOne operations") + return v, errors.New("OldType is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldValue requires an ID field in the mutation") + return v, errors.New("OldType requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldValue: %w", err) + return v, fmt.Errorf("querying old value for OldType: %w", err) } - return oldValue.Value, nil + return oldValue.Type, nil } -// ResetValue resets all changes to the "value" field. -func (m *PayloadDigestMutation) ResetValue() { - m.value = nil +// ResetType resets all changes to the "type" field. +func (m *MappingMutation) ResetType() { + m._type = nil } -// SetDsseID sets the "dsse" edge to the Dsse entity by id. -func (m *PayloadDigestMutation) SetDsseID(id int) { - m.dsse = &id +// SetSha1 sets the "sha1" field. +func (m *MappingMutation) SetSha1(s string) { + m.sha1 = &s } -// ClearDsse clears the "dsse" edge to the Dsse entity. -func (m *PayloadDigestMutation) ClearDsse() { - m.cleareddsse = true +// Sha1 returns the value of the "sha1" field in the mutation. +func (m *MappingMutation) Sha1() (r string, exists bool) { + v := m.sha1 + if v == nil { + return + } + return *v, true } -// DsseCleared reports if the "dsse" edge to the Dsse entity was cleared. -func (m *PayloadDigestMutation) DsseCleared() bool { - return m.cleareddsse +// OldSha1 returns the old "sha1" field's value of the Mapping entity. +// If the Mapping 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 *MappingMutation) OldSha1(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldSha1 is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldSha1 requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldSha1: %w", err) + } + return oldValue.Sha1, nil } -// DsseID returns the "dsse" edge ID in the mutation. -func (m *PayloadDigestMutation) DsseID() (id int, exists bool) { - if m.dsse != nil { - return *m.dsse, true +// ResetSha1 resets all changes to the "sha1" field. +func (m *MappingMutation) ResetSha1() { + m.sha1 = nil +} + +// SetSha256 sets the "sha256" field. +func (m *MappingMutation) SetSha256(s string) { + m.sha256 = &s +} + +// Sha256 returns the value of the "sha256" field in the mutation. +func (m *MappingMutation) Sha256() (r string, exists bool) { + v := m.sha256 + if v == nil { + return + } + return *v, true +} + +// OldSha256 returns the old "sha256" field's value of the Mapping entity. +// If the Mapping 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 *MappingMutation) OldSha256(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldSha256 is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldSha256 requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldSha256: %w", err) + } + return oldValue.Sha256, nil +} + +// ResetSha256 resets all changes to the "sha256" field. +func (m *MappingMutation) ResetSha256() { + m.sha256 = nil +} + +// SetGitoidSha1 sets the "gitoidSha1" field. +func (m *MappingMutation) SetGitoidSha1(s string) { + m.gitoidSha1 = &s +} + +// GitoidSha1 returns the value of the "gitoidSha1" field in the mutation. +func (m *MappingMutation) GitoidSha1() (r string, exists bool) { + v := m.gitoidSha1 + if v == nil { + return + } + return *v, true +} + +// OldGitoidSha1 returns the old "gitoidSha1" field's value of the Mapping entity. +// If the Mapping 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 *MappingMutation) OldGitoidSha1(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldGitoidSha1 is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldGitoidSha1 requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldGitoidSha1: %w", err) + } + return oldValue.GitoidSha1, nil +} + +// ResetGitoidSha1 resets all changes to the "gitoidSha1" field. +func (m *MappingMutation) ResetGitoidSha1() { + m.gitoidSha1 = nil +} + +// SetGitoidSha256 sets the "gitoidSha256" field. +func (m *MappingMutation) SetGitoidSha256(s string) { + m.gitoidSha256 = &s +} + +// GitoidSha256 returns the value of the "gitoidSha256" field in the mutation. +func (m *MappingMutation) GitoidSha256() (r string, exists bool) { + v := m.gitoidSha256 + if v == nil { + return + } + return *v, true +} + +// OldGitoidSha256 returns the old "gitoidSha256" field's value of the Mapping entity. +// If the Mapping 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 *MappingMutation) OldGitoidSha256(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldGitoidSha256 is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldGitoidSha256 requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldGitoidSha256: %w", err) + } + return oldValue.GitoidSha256, nil +} + +// ResetGitoidSha256 resets all changes to the "gitoidSha256" field. +func (m *MappingMutation) ResetGitoidSha256() { + m.gitoidSha256 = nil +} + +// AddPosixIDs adds the "posix" edge to the Posix entity by ids. +func (m *MappingMutation) AddPosixIDs(ids ...int) { + if m.posix == nil { + m.posix = make(map[int]struct{}) + } + for i := range ids { + m.posix[ids[i]] = struct{}{} + } +} + +// ClearPosix clears the "posix" edge to the Posix entity. +func (m *MappingMutation) ClearPosix() { + m.clearedposix = true +} + +// PosixCleared reports if the "posix" edge to the Posix entity was cleared. +func (m *MappingMutation) PosixCleared() bool { + return m.clearedposix +} + +// RemovePosixIDs removes the "posix" edge to the Posix entity by IDs. +func (m *MappingMutation) RemovePosixIDs(ids ...int) { + if m.removedposix == nil { + m.removedposix = make(map[int]struct{}) + } + for i := range ids { + delete(m.posix, ids[i]) + m.removedposix[ids[i]] = struct{}{} + } +} + +// RemovedPosix returns the removed IDs of the "posix" edge to the Posix entity. +func (m *MappingMutation) RemovedPosixIDs() (ids []int) { + for id := range m.removedposix { + ids = append(ids, id) } return } -// DsseIDs returns the "dsse" edge IDs in the mutation. +// PosixIDs returns the "posix" edge IDs in the mutation. +func (m *MappingMutation) PosixIDs() (ids []int) { + for id := range m.posix { + ids = append(ids, id) + } + return +} + +// ResetPosix resets all changes to the "posix" edge. +func (m *MappingMutation) ResetPosix() { + m.posix = nil + m.clearedposix = false + m.removedposix = nil +} + +// SetOmnitrailID sets the "omnitrail" edge to the Omnitrail entity by id. +func (m *MappingMutation) SetOmnitrailID(id int) { + m.omnitrail = &id +} + +// ClearOmnitrail clears the "omnitrail" edge to the Omnitrail entity. +func (m *MappingMutation) ClearOmnitrail() { + m.clearedomnitrail = true +} + +// OmnitrailCleared reports if the "omnitrail" edge to the Omnitrail entity was cleared. +func (m *MappingMutation) OmnitrailCleared() bool { + return m.clearedomnitrail +} + +// OmnitrailID returns the "omnitrail" edge ID in the mutation. +func (m *MappingMutation) OmnitrailID() (id int, exists bool) { + if m.omnitrail != nil { + return *m.omnitrail, true + } + return +} + +// OmnitrailIDs returns the "omnitrail" edge IDs in the mutation. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// DsseID instead. It exists only for internal usage by the builders. -func (m *PayloadDigestMutation) DsseIDs() (ids []int) { - if id := m.dsse; id != nil { +// OmnitrailID instead. It exists only for internal usage by the builders. +func (m *MappingMutation) OmnitrailIDs() (ids []int) { + if id := m.omnitrail; id != nil { ids = append(ids, *id) } return } -// ResetDsse resets all changes to the "dsse" edge. -func (m *PayloadDigestMutation) ResetDsse() { - m.dsse = nil - m.cleareddsse = false +// ResetOmnitrail resets all changes to the "omnitrail" edge. +func (m *MappingMutation) ResetOmnitrail() { + m.omnitrail = nil + m.clearedomnitrail = false } -// Where appends a list predicates to the PayloadDigestMutation builder. -func (m *PayloadDigestMutation) Where(ps ...predicate.PayloadDigest) { +// Where appends a list predicates to the MappingMutation builder. +func (m *MappingMutation) Where(ps ...predicate.Mapping) { m.predicates = append(m.predicates, ps...) } -// WhereP appends storage-level predicates to the PayloadDigestMutation builder. Using this method, +// WhereP appends storage-level predicates to the MappingMutation builder. Using this method, // users can use type-assertion to append predicates that do not depend on any generated package. -func (m *PayloadDigestMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.PayloadDigest, len(ps)) +func (m *MappingMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.Mapping, len(ps)) for i := range ps { p[i] = ps[i] } @@ -2165,30 +2435,1996 @@ func (m *PayloadDigestMutation) WhereP(ps ...func(*sql.Selector)) { } // Op returns the operation name. -func (m *PayloadDigestMutation) Op() Op { +func (m *MappingMutation) Op() Op { return m.op } // SetOp allows setting the mutation operation. -func (m *PayloadDigestMutation) SetOp(op Op) { +func (m *MappingMutation) SetOp(op Op) { m.op = op } -// Type returns the node type of this mutation (PayloadDigest). -func (m *PayloadDigestMutation) Type() string { +// Type returns the node type of this mutation (Mapping). +func (m *MappingMutation) 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 *PayloadDigestMutation) Fields() []string { - fields := make([]string, 0, 2) - if m.algorithm != nil { +func (m *MappingMutation) Fields() []string { + fields := make([]string, 0, 6) + if m._path != nil { + fields = append(fields, mapping.FieldPath) + } + if m._type != nil { + fields = append(fields, mapping.FieldType) + } + if m.sha1 != nil { + fields = append(fields, mapping.FieldSha1) + } + if m.sha256 != nil { + fields = append(fields, mapping.FieldSha256) + } + if m.gitoidSha1 != nil { + fields = append(fields, mapping.FieldGitoidSha1) + } + if m.gitoidSha256 != nil { + fields = append(fields, mapping.FieldGitoidSha256) + } + 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 *MappingMutation) Field(name string) (ent.Value, bool) { + switch name { + case mapping.FieldPath: + return m.Path() + case mapping.FieldType: + return m.GetType() + case mapping.FieldSha1: + return m.Sha1() + case mapping.FieldSha256: + return m.Sha256() + case mapping.FieldGitoidSha1: + return m.GitoidSha1() + case mapping.FieldGitoidSha256: + return m.GitoidSha256() + } + 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 *MappingMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case mapping.FieldPath: + return m.OldPath(ctx) + case mapping.FieldType: + return m.OldType(ctx) + case mapping.FieldSha1: + return m.OldSha1(ctx) + case mapping.FieldSha256: + return m.OldSha256(ctx) + case mapping.FieldGitoidSha1: + return m.OldGitoidSha1(ctx) + case mapping.FieldGitoidSha256: + return m.OldGitoidSha256(ctx) + } + return nil, fmt.Errorf("unknown Mapping 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 *MappingMutation) SetField(name string, value ent.Value) error { + switch name { + case mapping.FieldPath: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetPath(v) + return nil + case mapping.FieldType: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetType(v) + return nil + case mapping.FieldSha1: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetSha1(v) + return nil + case mapping.FieldSha256: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetSha256(v) + return nil + case mapping.FieldGitoidSha1: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetGitoidSha1(v) + return nil + case mapping.FieldGitoidSha256: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetGitoidSha256(v) + return nil + } + return fmt.Errorf("unknown Mapping field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *MappingMutation) AddedFields() []string { + return nil +} + +// 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 *MappingMutation) AddedField(name string) (ent.Value, bool) { + 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 *MappingMutation) AddField(name string, value ent.Value) error { + switch name { + } + return fmt.Errorf("unknown Mapping numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *MappingMutation) ClearedFields() []string { + return nil +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *MappingMutation) 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 *MappingMutation) ClearField(name string) error { + return fmt.Errorf("unknown Mapping 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 *MappingMutation) ResetField(name string) error { + switch name { + case mapping.FieldPath: + m.ResetPath() + return nil + case mapping.FieldType: + m.ResetType() + return nil + case mapping.FieldSha1: + m.ResetSha1() + return nil + case mapping.FieldSha256: + m.ResetSha256() + return nil + case mapping.FieldGitoidSha1: + m.ResetGitoidSha1() + return nil + case mapping.FieldGitoidSha256: + m.ResetGitoidSha256() + return nil + } + return fmt.Errorf("unknown Mapping field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *MappingMutation) AddedEdges() []string { + edges := make([]string, 0, 2) + if m.posix != nil { + edges = append(edges, mapping.EdgePosix) + } + if m.omnitrail != nil { + edges = append(edges, mapping.EdgeOmnitrail) + } + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *MappingMutation) AddedIDs(name string) []ent.Value { + switch name { + case mapping.EdgePosix: + ids := make([]ent.Value, 0, len(m.posix)) + for id := range m.posix { + ids = append(ids, id) + } + return ids + case mapping.EdgeOmnitrail: + if id := m.omnitrail; id != nil { + return []ent.Value{*id} + } + } + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *MappingMutation) RemovedEdges() []string { + edges := make([]string, 0, 2) + if m.removedposix != nil { + edges = append(edges, mapping.EdgePosix) + } + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *MappingMutation) RemovedIDs(name string) []ent.Value { + switch name { + case mapping.EdgePosix: + ids := make([]ent.Value, 0, len(m.removedposix)) + for id := range m.removedposix { + ids = append(ids, id) + } + return ids + } + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *MappingMutation) ClearedEdges() []string { + edges := make([]string, 0, 2) + if m.clearedposix { + edges = append(edges, mapping.EdgePosix) + } + if m.clearedomnitrail { + edges = append(edges, mapping.EdgeOmnitrail) + } + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *MappingMutation) EdgeCleared(name string) bool { + switch name { + case mapping.EdgePosix: + return m.clearedposix + case mapping.EdgeOmnitrail: + return m.clearedomnitrail + } + 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 *MappingMutation) ClearEdge(name string) error { + switch name { + case mapping.EdgeOmnitrail: + m.ClearOmnitrail() + return nil + } + return fmt.Errorf("unknown Mapping 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 *MappingMutation) ResetEdge(name string) error { + switch name { + case mapping.EdgePosix: + m.ResetPosix() + return nil + case mapping.EdgeOmnitrail: + m.ResetOmnitrail() + return nil + } + return fmt.Errorf("unknown Mapping edge %s", name) +} + +// OmnitrailMutation represents an operation that mutates the Omnitrail nodes in the graph. +type OmnitrailMutation struct { + config + op Op + typ string + id *int + clearedFields map[string]struct{} + mappings map[int]struct{} + removedmappings map[int]struct{} + clearedmappings bool + attestation *int + clearedattestation bool + done bool + oldValue func(context.Context) (*Omnitrail, error) + predicates []predicate.Omnitrail +} + +var _ ent.Mutation = (*OmnitrailMutation)(nil) + +// omnitrailOption allows management of the mutation configuration using functional options. +type omnitrailOption func(*OmnitrailMutation) + +// newOmnitrailMutation creates new mutation for the Omnitrail entity. +func newOmnitrailMutation(c config, op Op, opts ...omnitrailOption) *OmnitrailMutation { + m := &OmnitrailMutation{ + config: c, + op: op, + typ: TypeOmnitrail, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withOmnitrailID sets the ID field of the mutation. +func withOmnitrailID(id int) omnitrailOption { + return func(m *OmnitrailMutation) { + var ( + err error + once sync.Once + value *Omnitrail + ) + m.oldValue = func(ctx context.Context) (*Omnitrail, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().Omnitrail.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withOmnitrail sets the old Omnitrail of the mutation. +func withOmnitrail(node *Omnitrail) omnitrailOption { + return func(m *OmnitrailMutation) { + m.oldValue = func(context.Context) (*Omnitrail, 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 OmnitrailMutation) 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 OmnitrailMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("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 or after it was returned from the database. +func (m *OmnitrailMutation) ID() (id int, exists bool) { + if m.id == nil { + return + } + return *m.id, true +} + +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *OmnitrailMutation) IDs(ctx context.Context) ([]int, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []int{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().Omnitrail.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// AddMappingIDs adds the "mappings" edge to the Mapping entity by ids. +func (m *OmnitrailMutation) AddMappingIDs(ids ...int) { + if m.mappings == nil { + m.mappings = make(map[int]struct{}) + } + for i := range ids { + m.mappings[ids[i]] = struct{}{} + } +} + +// ClearMappings clears the "mappings" edge to the Mapping entity. +func (m *OmnitrailMutation) ClearMappings() { + m.clearedmappings = true +} + +// MappingsCleared reports if the "mappings" edge to the Mapping entity was cleared. +func (m *OmnitrailMutation) MappingsCleared() bool { + return m.clearedmappings +} + +// RemoveMappingIDs removes the "mappings" edge to the Mapping entity by IDs. +func (m *OmnitrailMutation) RemoveMappingIDs(ids ...int) { + if m.removedmappings == nil { + m.removedmappings = make(map[int]struct{}) + } + for i := range ids { + delete(m.mappings, ids[i]) + m.removedmappings[ids[i]] = struct{}{} + } +} + +// RemovedMappings returns the removed IDs of the "mappings" edge to the Mapping entity. +func (m *OmnitrailMutation) RemovedMappingsIDs() (ids []int) { + for id := range m.removedmappings { + ids = append(ids, id) + } + return +} + +// MappingsIDs returns the "mappings" edge IDs in the mutation. +func (m *OmnitrailMutation) MappingsIDs() (ids []int) { + for id := range m.mappings { + ids = append(ids, id) + } + return +} + +// ResetMappings resets all changes to the "mappings" edge. +func (m *OmnitrailMutation) ResetMappings() { + m.mappings = nil + m.clearedmappings = false + m.removedmappings = nil +} + +// SetAttestationID sets the "attestation" edge to the Attestation entity by id. +func (m *OmnitrailMutation) SetAttestationID(id int) { + m.attestation = &id +} + +// ClearAttestation clears the "attestation" edge to the Attestation entity. +func (m *OmnitrailMutation) ClearAttestation() { + m.clearedattestation = true +} + +// AttestationCleared reports if the "attestation" edge to the Attestation entity was cleared. +func (m *OmnitrailMutation) AttestationCleared() bool { + return m.clearedattestation +} + +// AttestationID returns the "attestation" edge ID in the mutation. +func (m *OmnitrailMutation) AttestationID() (id int, exists bool) { + if m.attestation != nil { + return *m.attestation, true + } + return +} + +// AttestationIDs returns the "attestation" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// AttestationID instead. It exists only for internal usage by the builders. +func (m *OmnitrailMutation) AttestationIDs() (ids []int) { + if id := m.attestation; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetAttestation resets all changes to the "attestation" edge. +func (m *OmnitrailMutation) ResetAttestation() { + m.attestation = nil + m.clearedattestation = false +} + +// Where appends a list predicates to the OmnitrailMutation builder. +func (m *OmnitrailMutation) Where(ps ...predicate.Omnitrail) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the OmnitrailMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *OmnitrailMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.Omnitrail, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *OmnitrailMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *OmnitrailMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (Omnitrail). +func (m *OmnitrailMutation) 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 *OmnitrailMutation) Fields() []string { + fields := make([]string, 0, 0) + 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 *OmnitrailMutation) Field(name string) (ent.Value, bool) { + 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 *OmnitrailMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + return nil, fmt.Errorf("unknown Omnitrail 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 *OmnitrailMutation) SetField(name string, value ent.Value) error { + switch name { + } + return fmt.Errorf("unknown Omnitrail field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *OmnitrailMutation) AddedFields() []string { + return nil +} + +// 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 *OmnitrailMutation) AddedField(name string) (ent.Value, bool) { + 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 *OmnitrailMutation) AddField(name string, value ent.Value) error { + return fmt.Errorf("unknown Omnitrail numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *OmnitrailMutation) ClearedFields() []string { + return nil +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *OmnitrailMutation) 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 *OmnitrailMutation) ClearField(name string) error { + return fmt.Errorf("unknown Omnitrail 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 *OmnitrailMutation) ResetField(name string) error { + return fmt.Errorf("unknown Omnitrail field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *OmnitrailMutation) AddedEdges() []string { + edges := make([]string, 0, 2) + if m.mappings != nil { + edges = append(edges, omnitrail.EdgeMappings) + } + if m.attestation != nil { + edges = append(edges, omnitrail.EdgeAttestation) + } + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *OmnitrailMutation) AddedIDs(name string) []ent.Value { + switch name { + case omnitrail.EdgeMappings: + ids := make([]ent.Value, 0, len(m.mappings)) + for id := range m.mappings { + ids = append(ids, id) + } + return ids + case omnitrail.EdgeAttestation: + if id := m.attestation; id != nil { + return []ent.Value{*id} + } + } + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *OmnitrailMutation) RemovedEdges() []string { + edges := make([]string, 0, 2) + if m.removedmappings != nil { + edges = append(edges, omnitrail.EdgeMappings) + } + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *OmnitrailMutation) RemovedIDs(name string) []ent.Value { + switch name { + case omnitrail.EdgeMappings: + ids := make([]ent.Value, 0, len(m.removedmappings)) + for id := range m.removedmappings { + ids = append(ids, id) + } + return ids + } + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *OmnitrailMutation) ClearedEdges() []string { + edges := make([]string, 0, 2) + if m.clearedmappings { + edges = append(edges, omnitrail.EdgeMappings) + } + if m.clearedattestation { + edges = append(edges, omnitrail.EdgeAttestation) + } + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *OmnitrailMutation) EdgeCleared(name string) bool { + switch name { + case omnitrail.EdgeMappings: + return m.clearedmappings + case omnitrail.EdgeAttestation: + return m.clearedattestation + } + 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 *OmnitrailMutation) ClearEdge(name string) error { + switch name { + case omnitrail.EdgeAttestation: + m.ClearAttestation() + return nil + } + return fmt.Errorf("unknown Omnitrail 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 *OmnitrailMutation) ResetEdge(name string) error { + switch name { + case omnitrail.EdgeMappings: + m.ResetMappings() + return nil + case omnitrail.EdgeAttestation: + m.ResetAttestation() + return nil + } + return fmt.Errorf("unknown Omnitrail edge %s", name) +} + +// PayloadDigestMutation represents an operation that mutates the PayloadDigest nodes in the graph. +type PayloadDigestMutation struct { + config + op Op + typ string + id *int + algorithm *string + value *string + clearedFields map[string]struct{} + dsse *int + cleareddsse bool + done bool + oldValue func(context.Context) (*PayloadDigest, error) + predicates []predicate.PayloadDigest +} + +var _ ent.Mutation = (*PayloadDigestMutation)(nil) + +// payloaddigestOption allows management of the mutation configuration using functional options. +type payloaddigestOption func(*PayloadDigestMutation) + +// newPayloadDigestMutation creates new mutation for the PayloadDigest entity. +func newPayloadDigestMutation(c config, op Op, opts ...payloaddigestOption) *PayloadDigestMutation { + m := &PayloadDigestMutation{ + config: c, + op: op, + typ: TypePayloadDigest, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withPayloadDigestID sets the ID field of the mutation. +func withPayloadDigestID(id int) payloaddigestOption { + return func(m *PayloadDigestMutation) { + var ( + err error + once sync.Once + value *PayloadDigest + ) + m.oldValue = func(ctx context.Context) (*PayloadDigest, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().PayloadDigest.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withPayloadDigest sets the old PayloadDigest of the mutation. +func withPayloadDigest(node *PayloadDigest) payloaddigestOption { + return func(m *PayloadDigestMutation) { + m.oldValue = func(context.Context) (*PayloadDigest, 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 PayloadDigestMutation) 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 PayloadDigestMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("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 or after it was returned from the database. +func (m *PayloadDigestMutation) ID() (id int, exists bool) { + if m.id == nil { + return + } + return *m.id, true +} + +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *PayloadDigestMutation) IDs(ctx context.Context) ([]int, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []int{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().PayloadDigest.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetAlgorithm sets the "algorithm" field. +func (m *PayloadDigestMutation) SetAlgorithm(s string) { + m.algorithm = &s +} + +// Algorithm returns the value of the "algorithm" field in the mutation. +func (m *PayloadDigestMutation) Algorithm() (r string, exists bool) { + v := m.algorithm + if v == nil { + return + } + return *v, true +} + +// OldAlgorithm returns the old "algorithm" field's value of the PayloadDigest entity. +// If the PayloadDigest 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 *PayloadDigestMutation) OldAlgorithm(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldAlgorithm is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldAlgorithm requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldAlgorithm: %w", err) + } + return oldValue.Algorithm, nil +} + +// ResetAlgorithm resets all changes to the "algorithm" field. +func (m *PayloadDigestMutation) ResetAlgorithm() { + m.algorithm = nil +} + +// SetValue sets the "value" field. +func (m *PayloadDigestMutation) SetValue(s string) { + m.value = &s +} + +// Value returns the value of the "value" field in the mutation. +func (m *PayloadDigestMutation) Value() (r string, exists bool) { + v := m.value + if v == nil { + return + } + return *v, true +} + +// OldValue returns the old "value" field's value of the PayloadDigest entity. +// If the PayloadDigest 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 *PayloadDigestMutation) OldValue(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldValue is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldValue requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldValue: %w", err) + } + return oldValue.Value, nil +} + +// ResetValue resets all changes to the "value" field. +func (m *PayloadDigestMutation) ResetValue() { + m.value = nil +} + +// SetDsseID sets the "dsse" edge to the Dsse entity by id. +func (m *PayloadDigestMutation) SetDsseID(id int) { + m.dsse = &id +} + +// ClearDsse clears the "dsse" edge to the Dsse entity. +func (m *PayloadDigestMutation) ClearDsse() { + m.cleareddsse = true +} + +// DsseCleared reports if the "dsse" edge to the Dsse entity was cleared. +func (m *PayloadDigestMutation) DsseCleared() bool { + return m.cleareddsse +} + +// DsseID returns the "dsse" edge ID in the mutation. +func (m *PayloadDigestMutation) DsseID() (id int, exists bool) { + if m.dsse != nil { + return *m.dsse, true + } + return +} + +// DsseIDs returns the "dsse" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// DsseID instead. It exists only for internal usage by the builders. +func (m *PayloadDigestMutation) DsseIDs() (ids []int) { + if id := m.dsse; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetDsse resets all changes to the "dsse" edge. +func (m *PayloadDigestMutation) ResetDsse() { + m.dsse = nil + m.cleareddsse = false +} + +// Where appends a list predicates to the PayloadDigestMutation builder. +func (m *PayloadDigestMutation) Where(ps ...predicate.PayloadDigest) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the PayloadDigestMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *PayloadDigestMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.PayloadDigest, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *PayloadDigestMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *PayloadDigestMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (PayloadDigest). +func (m *PayloadDigestMutation) 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 *PayloadDigestMutation) Fields() []string { + fields := make([]string, 0, 2) + if m.algorithm != nil { fields = append(fields, payloaddigest.FieldAlgorithm) } - if m.value != nil { - fields = append(fields, payloaddigest.FieldValue) + if m.value != nil { + fields = append(fields, payloaddigest.FieldValue) + } + 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 *PayloadDigestMutation) Field(name string) (ent.Value, bool) { + switch name { + case payloaddigest.FieldAlgorithm: + return m.Algorithm() + case payloaddigest.FieldValue: + return m.Value() + } + 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 *PayloadDigestMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case payloaddigest.FieldAlgorithm: + return m.OldAlgorithm(ctx) + case payloaddigest.FieldValue: + return m.OldValue(ctx) + } + return nil, fmt.Errorf("unknown PayloadDigest 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 *PayloadDigestMutation) SetField(name string, value ent.Value) error { + switch name { + case payloaddigest.FieldAlgorithm: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetAlgorithm(v) + return nil + case payloaddigest.FieldValue: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetValue(v) + return nil + } + return fmt.Errorf("unknown PayloadDigest field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *PayloadDigestMutation) AddedFields() []string { + return nil +} + +// 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 *PayloadDigestMutation) AddedField(name string) (ent.Value, bool) { + 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 *PayloadDigestMutation) AddField(name string, value ent.Value) error { + switch name { + } + return fmt.Errorf("unknown PayloadDigest numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *PayloadDigestMutation) ClearedFields() []string { + return nil +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *PayloadDigestMutation) 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 *PayloadDigestMutation) ClearField(name string) error { + return fmt.Errorf("unknown PayloadDigest 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 *PayloadDigestMutation) ResetField(name string) error { + switch name { + case payloaddigest.FieldAlgorithm: + m.ResetAlgorithm() + return nil + case payloaddigest.FieldValue: + m.ResetValue() + return nil + } + return fmt.Errorf("unknown PayloadDigest field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *PayloadDigestMutation) AddedEdges() []string { + edges := make([]string, 0, 1) + if m.dsse != nil { + edges = append(edges, payloaddigest.EdgeDsse) + } + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *PayloadDigestMutation) AddedIDs(name string) []ent.Value { + switch name { + case payloaddigest.EdgeDsse: + if id := m.dsse; id != nil { + return []ent.Value{*id} + } + } + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *PayloadDigestMutation) RemovedEdges() []string { + edges := make([]string, 0, 1) + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *PayloadDigestMutation) RemovedIDs(name string) []ent.Value { + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *PayloadDigestMutation) ClearedEdges() []string { + edges := make([]string, 0, 1) + if m.cleareddsse { + edges = append(edges, payloaddigest.EdgeDsse) + } + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *PayloadDigestMutation) EdgeCleared(name string) bool { + switch name { + case payloaddigest.EdgeDsse: + return m.cleareddsse + } + 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 *PayloadDigestMutation) ClearEdge(name string) error { + switch name { + case payloaddigest.EdgeDsse: + m.ClearDsse() + return nil + } + return fmt.Errorf("unknown PayloadDigest 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 *PayloadDigestMutation) ResetEdge(name string) error { + switch name { + case payloaddigest.EdgeDsse: + m.ResetDsse() + return nil + } + return fmt.Errorf("unknown PayloadDigest edge %s", name) +} + +// PosixMutation represents an operation that mutates the Posix nodes in the graph. +type PosixMutation struct { + config + op Op + typ string + id *int + atime *string + ctime *string + creation_time *string + extended_attributes *string + file_device_id *string + file_flags *string + file_inode *string + file_system_id *string + file_type *string + hard_link_count *string + mtime *string + metadata_ctime *string + owner_gid *string + owner_uid *string + permissions *string + size *string + clearedFields map[string]struct{} + mapping *int + clearedmapping bool + done bool + oldValue func(context.Context) (*Posix, error) + predicates []predicate.Posix +} + +var _ ent.Mutation = (*PosixMutation)(nil) + +// posixOption allows management of the mutation configuration using functional options. +type posixOption func(*PosixMutation) + +// newPosixMutation creates new mutation for the Posix entity. +func newPosixMutation(c config, op Op, opts ...posixOption) *PosixMutation { + m := &PosixMutation{ + config: c, + op: op, + typ: TypePosix, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withPosixID sets the ID field of the mutation. +func withPosixID(id int) posixOption { + return func(m *PosixMutation) { + var ( + err error + once sync.Once + value *Posix + ) + m.oldValue = func(ctx context.Context) (*Posix, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().Posix.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withPosix sets the old Posix of the mutation. +func withPosix(node *Posix) posixOption { + return func(m *PosixMutation) { + m.oldValue = func(context.Context) (*Posix, 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 PosixMutation) 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 PosixMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("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 or after it was returned from the database. +func (m *PosixMutation) ID() (id int, exists bool) { + if m.id == nil { + return + } + return *m.id, true +} + +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *PosixMutation) IDs(ctx context.Context) ([]int, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []int{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().Posix.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetAtime sets the "atime" field. +func (m *PosixMutation) SetAtime(s string) { + m.atime = &s +} + +// Atime returns the value of the "atime" field in the mutation. +func (m *PosixMutation) Atime() (r string, exists bool) { + v := m.atime + if v == nil { + return + } + return *v, true +} + +// OldAtime returns the old "atime" field's value of the Posix entity. +// If the Posix 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 *PosixMutation) OldAtime(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldAtime is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldAtime requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldAtime: %w", err) + } + return oldValue.Atime, nil +} + +// ResetAtime resets all changes to the "atime" field. +func (m *PosixMutation) ResetAtime() { + m.atime = nil +} + +// SetCtime sets the "ctime" field. +func (m *PosixMutation) SetCtime(s string) { + m.ctime = &s +} + +// Ctime returns the value of the "ctime" field in the mutation. +func (m *PosixMutation) Ctime() (r string, exists bool) { + v := m.ctime + if v == nil { + return + } + return *v, true +} + +// OldCtime returns the old "ctime" field's value of the Posix entity. +// If the Posix 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 *PosixMutation) OldCtime(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCtime is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCtime requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCtime: %w", err) + } + return oldValue.Ctime, nil +} + +// ResetCtime resets all changes to the "ctime" field. +func (m *PosixMutation) ResetCtime() { + m.ctime = nil +} + +// SetCreationTime sets the "creation_time" field. +func (m *PosixMutation) SetCreationTime(s string) { + m.creation_time = &s +} + +// CreationTime returns the value of the "creation_time" field in the mutation. +func (m *PosixMutation) CreationTime() (r string, exists bool) { + v := m.creation_time + if v == nil { + return + } + return *v, true +} + +// OldCreationTime returns the old "creation_time" field's value of the Posix entity. +// If the Posix 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 *PosixMutation) OldCreationTime(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreationTime is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreationTime requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreationTime: %w", err) + } + return oldValue.CreationTime, nil +} + +// ResetCreationTime resets all changes to the "creation_time" field. +func (m *PosixMutation) ResetCreationTime() { + m.creation_time = nil +} + +// SetExtendedAttributes sets the "extended_attributes" field. +func (m *PosixMutation) SetExtendedAttributes(s string) { + m.extended_attributes = &s +} + +// ExtendedAttributes returns the value of the "extended_attributes" field in the mutation. +func (m *PosixMutation) ExtendedAttributes() (r string, exists bool) { + v := m.extended_attributes + if v == nil { + return + } + return *v, true +} + +// OldExtendedAttributes returns the old "extended_attributes" field's value of the Posix entity. +// If the Posix 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 *PosixMutation) OldExtendedAttributes(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldExtendedAttributes is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldExtendedAttributes requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldExtendedAttributes: %w", err) + } + return oldValue.ExtendedAttributes, nil +} + +// ResetExtendedAttributes resets all changes to the "extended_attributes" field. +func (m *PosixMutation) ResetExtendedAttributes() { + m.extended_attributes = nil +} + +// SetFileDeviceID sets the "file_device_id" field. +func (m *PosixMutation) SetFileDeviceID(s string) { + m.file_device_id = &s +} + +// FileDeviceID returns the value of the "file_device_id" field in the mutation. +func (m *PosixMutation) FileDeviceID() (r string, exists bool) { + v := m.file_device_id + if v == nil { + return + } + return *v, true +} + +// OldFileDeviceID returns the old "file_device_id" field's value of the Posix entity. +// If the Posix 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 *PosixMutation) OldFileDeviceID(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldFileDeviceID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldFileDeviceID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldFileDeviceID: %w", err) + } + return oldValue.FileDeviceID, nil +} + +// ResetFileDeviceID resets all changes to the "file_device_id" field. +func (m *PosixMutation) ResetFileDeviceID() { + m.file_device_id = nil +} + +// SetFileFlags sets the "file_flags" field. +func (m *PosixMutation) SetFileFlags(s string) { + m.file_flags = &s +} + +// FileFlags returns the value of the "file_flags" field in the mutation. +func (m *PosixMutation) FileFlags() (r string, exists bool) { + v := m.file_flags + if v == nil { + return + } + return *v, true +} + +// OldFileFlags returns the old "file_flags" field's value of the Posix entity. +// If the Posix 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 *PosixMutation) OldFileFlags(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldFileFlags is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldFileFlags requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldFileFlags: %w", err) + } + return oldValue.FileFlags, nil +} + +// ResetFileFlags resets all changes to the "file_flags" field. +func (m *PosixMutation) ResetFileFlags() { + m.file_flags = nil +} + +// SetFileInode sets the "file_inode" field. +func (m *PosixMutation) SetFileInode(s string) { + m.file_inode = &s +} + +// FileInode returns the value of the "file_inode" field in the mutation. +func (m *PosixMutation) FileInode() (r string, exists bool) { + v := m.file_inode + if v == nil { + return + } + return *v, true +} + +// OldFileInode returns the old "file_inode" field's value of the Posix entity. +// If the Posix 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 *PosixMutation) OldFileInode(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldFileInode is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldFileInode requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldFileInode: %w", err) + } + return oldValue.FileInode, nil +} + +// ResetFileInode resets all changes to the "file_inode" field. +func (m *PosixMutation) ResetFileInode() { + m.file_inode = nil +} + +// SetFileSystemID sets the "file_system_id" field. +func (m *PosixMutation) SetFileSystemID(s string) { + m.file_system_id = &s +} + +// FileSystemID returns the value of the "file_system_id" field in the mutation. +func (m *PosixMutation) FileSystemID() (r string, exists bool) { + v := m.file_system_id + if v == nil { + return + } + return *v, true +} + +// OldFileSystemID returns the old "file_system_id" field's value of the Posix entity. +// If the Posix 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 *PosixMutation) OldFileSystemID(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldFileSystemID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldFileSystemID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldFileSystemID: %w", err) + } + return oldValue.FileSystemID, nil +} + +// ResetFileSystemID resets all changes to the "file_system_id" field. +func (m *PosixMutation) ResetFileSystemID() { + m.file_system_id = nil +} + +// SetFileType sets the "file_type" field. +func (m *PosixMutation) SetFileType(s string) { + m.file_type = &s +} + +// FileType returns the value of the "file_type" field in the mutation. +func (m *PosixMutation) FileType() (r string, exists bool) { + v := m.file_type + if v == nil { + return + } + return *v, true +} + +// OldFileType returns the old "file_type" field's value of the Posix entity. +// If the Posix 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 *PosixMutation) OldFileType(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldFileType is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldFileType requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldFileType: %w", err) + } + return oldValue.FileType, nil +} + +// ResetFileType resets all changes to the "file_type" field. +func (m *PosixMutation) ResetFileType() { + m.file_type = nil +} + +// SetHardLinkCount sets the "hard_link_count" field. +func (m *PosixMutation) SetHardLinkCount(s string) { + m.hard_link_count = &s +} + +// HardLinkCount returns the value of the "hard_link_count" field in the mutation. +func (m *PosixMutation) HardLinkCount() (r string, exists bool) { + v := m.hard_link_count + if v == nil { + return + } + return *v, true +} + +// OldHardLinkCount returns the old "hard_link_count" field's value of the Posix entity. +// If the Posix 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 *PosixMutation) OldHardLinkCount(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldHardLinkCount is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldHardLinkCount requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldHardLinkCount: %w", err) + } + return oldValue.HardLinkCount, nil +} + +// ResetHardLinkCount resets all changes to the "hard_link_count" field. +func (m *PosixMutation) ResetHardLinkCount() { + m.hard_link_count = nil +} + +// SetMtime sets the "mtime" field. +func (m *PosixMutation) SetMtime(s string) { + m.mtime = &s +} + +// Mtime returns the value of the "mtime" field in the mutation. +func (m *PosixMutation) Mtime() (r string, exists bool) { + v := m.mtime + if v == nil { + return + } + return *v, true +} + +// OldMtime returns the old "mtime" field's value of the Posix entity. +// If the Posix 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 *PosixMutation) OldMtime(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldMtime is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldMtime requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldMtime: %w", err) + } + return oldValue.Mtime, nil +} + +// ResetMtime resets all changes to the "mtime" field. +func (m *PosixMutation) ResetMtime() { + m.mtime = nil +} + +// SetMetadataCtime sets the "metadata_ctime" field. +func (m *PosixMutation) SetMetadataCtime(s string) { + m.metadata_ctime = &s +} + +// MetadataCtime returns the value of the "metadata_ctime" field in the mutation. +func (m *PosixMutation) MetadataCtime() (r string, exists bool) { + v := m.metadata_ctime + if v == nil { + return + } + return *v, true +} + +// OldMetadataCtime returns the old "metadata_ctime" field's value of the Posix entity. +// If the Posix 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 *PosixMutation) OldMetadataCtime(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldMetadataCtime is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldMetadataCtime requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldMetadataCtime: %w", err) + } + return oldValue.MetadataCtime, nil +} + +// ResetMetadataCtime resets all changes to the "metadata_ctime" field. +func (m *PosixMutation) ResetMetadataCtime() { + m.metadata_ctime = nil +} + +// SetOwnerGid sets the "owner_gid" field. +func (m *PosixMutation) SetOwnerGid(s string) { + m.owner_gid = &s +} + +// OwnerGid returns the value of the "owner_gid" field in the mutation. +func (m *PosixMutation) OwnerGid() (r string, exists bool) { + v := m.owner_gid + if v == nil { + return + } + return *v, true +} + +// OldOwnerGid returns the old "owner_gid" field's value of the Posix entity. +// If the Posix 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 *PosixMutation) OldOwnerGid(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldOwnerGid is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldOwnerGid requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldOwnerGid: %w", err) + } + return oldValue.OwnerGid, nil +} + +// ResetOwnerGid resets all changes to the "owner_gid" field. +func (m *PosixMutation) ResetOwnerGid() { + m.owner_gid = nil +} + +// SetOwnerUID sets the "owner_uid" field. +func (m *PosixMutation) SetOwnerUID(s string) { + m.owner_uid = &s +} + +// OwnerUID returns the value of the "owner_uid" field in the mutation. +func (m *PosixMutation) OwnerUID() (r string, exists bool) { + v := m.owner_uid + if v == nil { + return + } + return *v, true +} + +// OldOwnerUID returns the old "owner_uid" field's value of the Posix entity. +// If the Posix 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 *PosixMutation) OldOwnerUID(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldOwnerUID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldOwnerUID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldOwnerUID: %w", err) + } + return oldValue.OwnerUID, nil +} + +// ResetOwnerUID resets all changes to the "owner_uid" field. +func (m *PosixMutation) ResetOwnerUID() { + m.owner_uid = nil +} + +// SetPermissions sets the "permissions" field. +func (m *PosixMutation) SetPermissions(s string) { + m.permissions = &s +} + +// Permissions returns the value of the "permissions" field in the mutation. +func (m *PosixMutation) Permissions() (r string, exists bool) { + v := m.permissions + if v == nil { + return + } + return *v, true +} + +// OldPermissions returns the old "permissions" field's value of the Posix entity. +// If the Posix 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 *PosixMutation) OldPermissions(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldPermissions is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldPermissions requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldPermissions: %w", err) + } + return oldValue.Permissions, nil +} + +// ResetPermissions resets all changes to the "permissions" field. +func (m *PosixMutation) ResetPermissions() { + m.permissions = nil +} + +// SetSize sets the "size" field. +func (m *PosixMutation) SetSize(s string) { + m.size = &s +} + +// Size returns the value of the "size" field in the mutation. +func (m *PosixMutation) Size() (r string, exists bool) { + v := m.size + if v == nil { + return + } + return *v, true +} + +// OldSize returns the old "size" field's value of the Posix entity. +// If the Posix 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 *PosixMutation) OldSize(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldSize is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldSize requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldSize: %w", err) + } + return oldValue.Size, nil +} + +// ResetSize resets all changes to the "size" field. +func (m *PosixMutation) ResetSize() { + m.size = nil +} + +// SetMappingID sets the "mapping" edge to the Mapping entity by id. +func (m *PosixMutation) SetMappingID(id int) { + m.mapping = &id +} + +// ClearMapping clears the "mapping" edge to the Mapping entity. +func (m *PosixMutation) ClearMapping() { + m.clearedmapping = true +} + +// MappingCleared reports if the "mapping" edge to the Mapping entity was cleared. +func (m *PosixMutation) MappingCleared() bool { + return m.clearedmapping +} + +// MappingID returns the "mapping" edge ID in the mutation. +func (m *PosixMutation) MappingID() (id int, exists bool) { + if m.mapping != nil { + return *m.mapping, true + } + return +} + +// MappingIDs returns the "mapping" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// MappingID instead. It exists only for internal usage by the builders. +func (m *PosixMutation) MappingIDs() (ids []int) { + if id := m.mapping; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetMapping resets all changes to the "mapping" edge. +func (m *PosixMutation) ResetMapping() { + m.mapping = nil + m.clearedmapping = false +} + +// Where appends a list predicates to the PosixMutation builder. +func (m *PosixMutation) Where(ps ...predicate.Posix) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the PosixMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *PosixMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.Posix, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *PosixMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *PosixMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (Posix). +func (m *PosixMutation) 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 *PosixMutation) Fields() []string { + fields := make([]string, 0, 16) + if m.atime != nil { + fields = append(fields, posix.FieldAtime) + } + if m.ctime != nil { + fields = append(fields, posix.FieldCtime) + } + if m.creation_time != nil { + fields = append(fields, posix.FieldCreationTime) + } + if m.extended_attributes != nil { + fields = append(fields, posix.FieldExtendedAttributes) + } + if m.file_device_id != nil { + fields = append(fields, posix.FieldFileDeviceID) + } + if m.file_flags != nil { + fields = append(fields, posix.FieldFileFlags) + } + if m.file_inode != nil { + fields = append(fields, posix.FieldFileInode) + } + if m.file_system_id != nil { + fields = append(fields, posix.FieldFileSystemID) + } + if m.file_type != nil { + fields = append(fields, posix.FieldFileType) + } + if m.hard_link_count != nil { + fields = append(fields, posix.FieldHardLinkCount) + } + if m.mtime != nil { + fields = append(fields, posix.FieldMtime) + } + if m.metadata_ctime != nil { + fields = append(fields, posix.FieldMetadataCtime) + } + if m.owner_gid != nil { + fields = append(fields, posix.FieldOwnerGid) + } + if m.owner_uid != nil { + fields = append(fields, posix.FieldOwnerUID) + } + if m.permissions != nil { + fields = append(fields, posix.FieldPermissions) + } + if m.size != nil { + fields = append(fields, posix.FieldSize) } return fields } @@ -2196,12 +4432,40 @@ func (m *PayloadDigestMutation) Fields() []string { // 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 *PayloadDigestMutation) Field(name string) (ent.Value, bool) { +func (m *PosixMutation) Field(name string) (ent.Value, bool) { switch name { - case payloaddigest.FieldAlgorithm: - return m.Algorithm() - case payloaddigest.FieldValue: - return m.Value() + case posix.FieldAtime: + return m.Atime() + case posix.FieldCtime: + return m.Ctime() + case posix.FieldCreationTime: + return m.CreationTime() + case posix.FieldExtendedAttributes: + return m.ExtendedAttributes() + case posix.FieldFileDeviceID: + return m.FileDeviceID() + case posix.FieldFileFlags: + return m.FileFlags() + case posix.FieldFileInode: + return m.FileInode() + case posix.FieldFileSystemID: + return m.FileSystemID() + case posix.FieldFileType: + return m.FileType() + case posix.FieldHardLinkCount: + return m.HardLinkCount() + case posix.FieldMtime: + return m.Mtime() + case posix.FieldMetadataCtime: + return m.MetadataCtime() + case posix.FieldOwnerGid: + return m.OwnerGid() + case posix.FieldOwnerUID: + return m.OwnerUID() + case posix.FieldPermissions: + return m.Permissions() + case posix.FieldSize: + return m.Size() } return nil, false } @@ -2209,109 +4473,277 @@ func (m *PayloadDigestMutation) Field(name string) (ent.Value, bool) { // 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 *PayloadDigestMutation) OldField(ctx context.Context, name string) (ent.Value, error) { +func (m *PosixMutation) OldField(ctx context.Context, name string) (ent.Value, error) { switch name { - case payloaddigest.FieldAlgorithm: - return m.OldAlgorithm(ctx) - case payloaddigest.FieldValue: - return m.OldValue(ctx) - } - return nil, fmt.Errorf("unknown PayloadDigest field %s", name) + case posix.FieldAtime: + return m.OldAtime(ctx) + case posix.FieldCtime: + return m.OldCtime(ctx) + case posix.FieldCreationTime: + return m.OldCreationTime(ctx) + case posix.FieldExtendedAttributes: + return m.OldExtendedAttributes(ctx) + case posix.FieldFileDeviceID: + return m.OldFileDeviceID(ctx) + case posix.FieldFileFlags: + return m.OldFileFlags(ctx) + case posix.FieldFileInode: + return m.OldFileInode(ctx) + case posix.FieldFileSystemID: + return m.OldFileSystemID(ctx) + case posix.FieldFileType: + return m.OldFileType(ctx) + case posix.FieldHardLinkCount: + return m.OldHardLinkCount(ctx) + case posix.FieldMtime: + return m.OldMtime(ctx) + case posix.FieldMetadataCtime: + return m.OldMetadataCtime(ctx) + case posix.FieldOwnerGid: + return m.OldOwnerGid(ctx) + case posix.FieldOwnerUID: + return m.OldOwnerUID(ctx) + case posix.FieldPermissions: + return m.OldPermissions(ctx) + case posix.FieldSize: + return m.OldSize(ctx) + } + return nil, fmt.Errorf("unknown Posix 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 *PayloadDigestMutation) SetField(name string, value ent.Value) error { +func (m *PosixMutation) SetField(name string, value ent.Value) error { switch name { - case payloaddigest.FieldAlgorithm: + case posix.FieldAtime: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetAlgorithm(v) + m.SetAtime(v) return nil - case payloaddigest.FieldValue: + case posix.FieldCtime: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetValue(v) + m.SetCtime(v) + return nil + case posix.FieldCreationTime: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreationTime(v) + return nil + case posix.FieldExtendedAttributes: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetExtendedAttributes(v) + return nil + case posix.FieldFileDeviceID: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetFileDeviceID(v) + return nil + case posix.FieldFileFlags: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetFileFlags(v) + return nil + case posix.FieldFileInode: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetFileInode(v) + return nil + case posix.FieldFileSystemID: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetFileSystemID(v) + return nil + case posix.FieldFileType: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetFileType(v) + return nil + case posix.FieldHardLinkCount: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetHardLinkCount(v) + return nil + case posix.FieldMtime: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetMtime(v) + return nil + case posix.FieldMetadataCtime: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetMetadataCtime(v) + return nil + case posix.FieldOwnerGid: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetOwnerGid(v) + return nil + case posix.FieldOwnerUID: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetOwnerUID(v) + return nil + case posix.FieldPermissions: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetPermissions(v) + return nil + case posix.FieldSize: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetSize(v) return nil } - return fmt.Errorf("unknown PayloadDigest field %s", name) + return fmt.Errorf("unknown Posix field %s", name) } // AddedFields returns all numeric fields that were incremented/decremented during // this mutation. -func (m *PayloadDigestMutation) AddedFields() []string { +func (m *PosixMutation) AddedFields() []string { return nil } // 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 *PayloadDigestMutation) AddedField(name string) (ent.Value, bool) { +func (m *PosixMutation) AddedField(name string) (ent.Value, bool) { 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 *PayloadDigestMutation) AddField(name string, value ent.Value) error { +func (m *PosixMutation) AddField(name string, value ent.Value) error { switch name { } - return fmt.Errorf("unknown PayloadDigest numeric field %s", name) + return fmt.Errorf("unknown Posix numeric field %s", name) } // ClearedFields returns all nullable fields that were cleared during this // mutation. -func (m *PayloadDigestMutation) ClearedFields() []string { +func (m *PosixMutation) ClearedFields() []string { return nil } // FieldCleared returns a boolean indicating if a field with the given name was // cleared in this mutation. -func (m *PayloadDigestMutation) FieldCleared(name string) bool { +func (m *PosixMutation) 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 *PayloadDigestMutation) ClearField(name string) error { - return fmt.Errorf("unknown PayloadDigest nullable field %s", name) +func (m *PosixMutation) ClearField(name string) error { + return fmt.Errorf("unknown Posix 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 *PayloadDigestMutation) ResetField(name string) error { +func (m *PosixMutation) ResetField(name string) error { switch name { - case payloaddigest.FieldAlgorithm: - m.ResetAlgorithm() + case posix.FieldAtime: + m.ResetAtime() return nil - case payloaddigest.FieldValue: - m.ResetValue() + case posix.FieldCtime: + m.ResetCtime() + return nil + case posix.FieldCreationTime: + m.ResetCreationTime() + return nil + case posix.FieldExtendedAttributes: + m.ResetExtendedAttributes() + return nil + case posix.FieldFileDeviceID: + m.ResetFileDeviceID() + return nil + case posix.FieldFileFlags: + m.ResetFileFlags() + return nil + case posix.FieldFileInode: + m.ResetFileInode() + return nil + case posix.FieldFileSystemID: + m.ResetFileSystemID() + return nil + case posix.FieldFileType: + m.ResetFileType() + return nil + case posix.FieldHardLinkCount: + m.ResetHardLinkCount() + return nil + case posix.FieldMtime: + m.ResetMtime() + return nil + case posix.FieldMetadataCtime: + m.ResetMetadataCtime() + return nil + case posix.FieldOwnerGid: + m.ResetOwnerGid() + return nil + case posix.FieldOwnerUID: + m.ResetOwnerUID() + return nil + case posix.FieldPermissions: + m.ResetPermissions() + return nil + case posix.FieldSize: + m.ResetSize() return nil } - return fmt.Errorf("unknown PayloadDigest field %s", name) + return fmt.Errorf("unknown Posix field %s", name) } // AddedEdges returns all edge names that were set/added in this mutation. -func (m *PayloadDigestMutation) AddedEdges() []string { +func (m *PosixMutation) AddedEdges() []string { edges := make([]string, 0, 1) - if m.dsse != nil { - edges = append(edges, payloaddigest.EdgeDsse) + if m.mapping != nil { + edges = append(edges, posix.EdgeMapping) } return edges } // AddedIDs returns all IDs (to other nodes) that were added for the given edge // name in this mutation. -func (m *PayloadDigestMutation) AddedIDs(name string) []ent.Value { +func (m *PosixMutation) AddedIDs(name string) []ent.Value { switch name { - case payloaddigest.EdgeDsse: - if id := m.dsse; id != nil { + case posix.EdgeMapping: + if id := m.mapping; id != nil { return []ent.Value{*id} } } @@ -2319,56 +4751,56 @@ func (m *PayloadDigestMutation) AddedIDs(name string) []ent.Value { } // RemovedEdges returns all edge names that were removed in this mutation. -func (m *PayloadDigestMutation) RemovedEdges() []string { +func (m *PosixMutation) RemovedEdges() []string { edges := make([]string, 0, 1) return edges } // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with // the given name in this mutation. -func (m *PayloadDigestMutation) RemovedIDs(name string) []ent.Value { +func (m *PosixMutation) RemovedIDs(name string) []ent.Value { return nil } // ClearedEdges returns all edge names that were cleared in this mutation. -func (m *PayloadDigestMutation) ClearedEdges() []string { +func (m *PosixMutation) ClearedEdges() []string { edges := make([]string, 0, 1) - if m.cleareddsse { - edges = append(edges, payloaddigest.EdgeDsse) + if m.clearedmapping { + edges = append(edges, posix.EdgeMapping) } return edges } // EdgeCleared returns a boolean which indicates if the edge with the given name // was cleared in this mutation. -func (m *PayloadDigestMutation) EdgeCleared(name string) bool { +func (m *PosixMutation) EdgeCleared(name string) bool { switch name { - case payloaddigest.EdgeDsse: - return m.cleareddsse + case posix.EdgeMapping: + return m.clearedmapping } 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 *PayloadDigestMutation) ClearEdge(name string) error { +func (m *PosixMutation) ClearEdge(name string) error { switch name { - case payloaddigest.EdgeDsse: - m.ClearDsse() + case posix.EdgeMapping: + m.ClearMapping() return nil } - return fmt.Errorf("unknown PayloadDigest unique edge %s", name) + return fmt.Errorf("unknown Posix 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 *PayloadDigestMutation) ResetEdge(name string) error { +func (m *PosixMutation) ResetEdge(name string) error { switch name { - case payloaddigest.EdgeDsse: - m.ResetDsse() + case posix.EdgeMapping: + m.ResetMapping() return nil } - return fmt.Errorf("unknown PayloadDigest edge %s", name) + return fmt.Errorf("unknown Posix edge %s", name) } // SignatureMutation represents an operation that mutates the Signature nodes in the graph. diff --git a/ent/omnitrail.go b/ent/omnitrail.go new file mode 100644 index 00000000..d0fb22ae --- /dev/null +++ b/ent/omnitrail.go @@ -0,0 +1,174 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "fmt" + "strings" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "github.com/in-toto/archivista/ent/attestation" + "github.com/in-toto/archivista/ent/omnitrail" +) + +// Omnitrail is the model entity for the Omnitrail schema. +type Omnitrail struct { + config + // ID of the ent. + ID int `json:"id,omitempty"` + // Edges holds the relations/edges for other nodes in the graph. + // The values are being populated by the OmnitrailQuery when eager-loading is set. + Edges OmnitrailEdges `json:"edges"` + attestation_omnitrail *int + selectValues sql.SelectValues +} + +// OmnitrailEdges holds the relations/edges for other nodes in the graph. +type OmnitrailEdges struct { + // Mappings holds the value of the mappings edge. + Mappings []*Mapping `json:"mappings,omitempty"` + // Attestation holds the value of the attestation edge. + Attestation *Attestation `json:"attestation,omitempty"` + // loadedTypes holds the information for reporting if a + // type was loaded (or requested) in eager-loading or not. + loadedTypes [2]bool + // totalCount holds the count of the edges above. + totalCount [2]map[string]int + + namedMappings map[string][]*Mapping +} + +// MappingsOrErr returns the Mappings value or an error if the edge +// was not loaded in eager-loading. +func (e OmnitrailEdges) MappingsOrErr() ([]*Mapping, error) { + if e.loadedTypes[0] { + return e.Mappings, nil + } + return nil, &NotLoadedError{edge: "mappings"} +} + +// AttestationOrErr returns the Attestation value or an error if the edge +// was not loaded in eager-loading, or loaded but was not found. +func (e OmnitrailEdges) AttestationOrErr() (*Attestation, error) { + if e.Attestation != nil { + return e.Attestation, nil + } else if e.loadedTypes[1] { + return nil, &NotFoundError{label: attestation.Label} + } + return nil, &NotLoadedError{edge: "attestation"} +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*Omnitrail) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case omnitrail.FieldID: + values[i] = new(sql.NullInt64) + case omnitrail.ForeignKeys[0]: // attestation_omnitrail + values[i] = new(sql.NullInt64) + default: + values[i] = new(sql.UnknownType) + } + } + return values, nil +} + +// assignValues assigns the values that were returned from sql.Rows (after scanning) +// to the Omnitrail fields. +func (o *Omnitrail) 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 omnitrail.FieldID: + value, ok := values[i].(*sql.NullInt64) + if !ok { + return fmt.Errorf("unexpected type %T for field id", value) + } + o.ID = int(value.Int64) + case omnitrail.ForeignKeys[0]: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for edge-field attestation_omnitrail", value) + } else if value.Valid { + o.attestation_omnitrail = new(int) + *o.attestation_omnitrail = int(value.Int64) + } + default: + o.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the Omnitrail. +// This includes values selected through modifiers, order, etc. +func (o *Omnitrail) Value(name string) (ent.Value, error) { + return o.selectValues.Get(name) +} + +// QueryMappings queries the "mappings" edge of the Omnitrail entity. +func (o *Omnitrail) QueryMappings() *MappingQuery { + return NewOmnitrailClient(o.config).QueryMappings(o) +} + +// QueryAttestation queries the "attestation" edge of the Omnitrail entity. +func (o *Omnitrail) QueryAttestation() *AttestationQuery { + return NewOmnitrailClient(o.config).QueryAttestation(o) +} + +// Update returns a builder for updating this Omnitrail. +// Note that you need to call Omnitrail.Unwrap() before calling this method if this Omnitrail +// was returned from a transaction, and the transaction was committed or rolled back. +func (o *Omnitrail) Update() *OmnitrailUpdateOne { + return NewOmnitrailClient(o.config).UpdateOne(o) +} + +// Unwrap unwraps the Omnitrail 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 (o *Omnitrail) Unwrap() *Omnitrail { + _tx, ok := o.config.driver.(*txDriver) + if !ok { + panic("ent: Omnitrail is not a transactional entity") + } + o.config.driver = _tx.drv + return o +} + +// String implements the fmt.Stringer. +func (o *Omnitrail) String() string { + var builder strings.Builder + builder.WriteString("Omnitrail(") + builder.WriteString(fmt.Sprintf("id=%v", o.ID)) + builder.WriteByte(')') + return builder.String() +} + +// NamedMappings returns the Mappings named value or an error if the edge was not +// loaded in eager-loading with this name. +func (o *Omnitrail) NamedMappings(name string) ([]*Mapping, error) { + if o.Edges.namedMappings == nil { + return nil, &NotLoadedError{edge: name} + } + nodes, ok := o.Edges.namedMappings[name] + if !ok { + return nil, &NotLoadedError{edge: name} + } + return nodes, nil +} + +func (o *Omnitrail) appendNamedMappings(name string, edges ...*Mapping) { + if o.Edges.namedMappings == nil { + o.Edges.namedMappings = make(map[string][]*Mapping) + } + if len(edges) == 0 { + o.Edges.namedMappings[name] = []*Mapping{} + } else { + o.Edges.namedMappings[name] = append(o.Edges.namedMappings[name], edges...) + } +} + +// Omnitrails is a parsable slice of Omnitrail. +type Omnitrails []*Omnitrail diff --git a/ent/omnitrail/omnitrail.go b/ent/omnitrail/omnitrail.go new file mode 100644 index 00000000..76915df3 --- /dev/null +++ b/ent/omnitrail/omnitrail.go @@ -0,0 +1,104 @@ +// Code generated by ent, DO NOT EDIT. + +package omnitrail + +import ( + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +const ( + // Label holds the string label denoting the omnitrail type in the database. + Label = "omnitrail" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // EdgeMappings holds the string denoting the mappings edge name in mutations. + EdgeMappings = "mappings" + // EdgeAttestation holds the string denoting the attestation edge name in mutations. + EdgeAttestation = "attestation" + // Table holds the table name of the omnitrail in the database. + Table = "omnitrails" + // MappingsTable is the table that holds the mappings relation/edge. + MappingsTable = "mappings" + // MappingsInverseTable is the table name for the Mapping entity. + // It exists in this package in order to avoid circular dependency with the "mapping" package. + MappingsInverseTable = "mappings" + // MappingsColumn is the table column denoting the mappings relation/edge. + MappingsColumn = "omnitrail_mappings" + // AttestationTable is the table that holds the attestation relation/edge. + AttestationTable = "omnitrails" + // AttestationInverseTable is the table name for the Attestation entity. + // It exists in this package in order to avoid circular dependency with the "attestation" package. + AttestationInverseTable = "attestations" + // AttestationColumn is the table column denoting the attestation relation/edge. + AttestationColumn = "attestation_omnitrail" +) + +// Columns holds all SQL columns for omnitrail fields. +var Columns = []string{ + FieldID, +} + +// ForeignKeys holds the SQL foreign-keys that are owned by the "omnitrails" +// table and are not defined as standalone fields in the schema. +var ForeignKeys = []string{ + "attestation_omnitrail", +} + +// 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 + } + } + for i := range ForeignKeys { + if column == ForeignKeys[i] { + return true + } + } + return false +} + +// OrderOption defines the ordering options for the Omnitrail queries. +type OrderOption func(*sql.Selector) + +// ByID orders the results by the id field. +func ByID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldID, opts...).ToFunc() +} + +// ByMappingsCount orders the results by mappings count. +func ByMappingsCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newMappingsStep(), opts...) + } +} + +// ByMappings orders the results by mappings terms. +func ByMappings(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newMappingsStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} + +// ByAttestationField orders the results by attestation field. +func ByAttestationField(field string, opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newAttestationStep(), sql.OrderByField(field, opts...)) + } +} +func newMappingsStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(MappingsInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, MappingsTable, MappingsColumn), + ) +} +func newAttestationStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(AttestationInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.O2O, true, AttestationTable, AttestationColumn), + ) +} diff --git a/ent/omnitrail/where.go b/ent/omnitrail/where.go new file mode 100644 index 00000000..fe713df1 --- /dev/null +++ b/ent/omnitrail/where.go @@ -0,0 +1,115 @@ +// Code generated by ent, DO NOT EDIT. + +package omnitrail + +import ( + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "github.com/in-toto/archivista/ent/predicate" +) + +// ID filters vertices based on their ID field. +func ID(id int) predicate.Omnitrail { + return predicate.Omnitrail(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id int) predicate.Omnitrail { + return predicate.Omnitrail(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id int) predicate.Omnitrail { + return predicate.Omnitrail(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...int) predicate.Omnitrail { + return predicate.Omnitrail(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...int) predicate.Omnitrail { + return predicate.Omnitrail(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id int) predicate.Omnitrail { + return predicate.Omnitrail(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id int) predicate.Omnitrail { + return predicate.Omnitrail(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id int) predicate.Omnitrail { + return predicate.Omnitrail(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id int) predicate.Omnitrail { + return predicate.Omnitrail(sql.FieldLTE(FieldID, id)) +} + +// HasMappings applies the HasEdge predicate on the "mappings" edge. +func HasMappings() predicate.Omnitrail { + return predicate.Omnitrail(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, MappingsTable, MappingsColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasMappingsWith applies the HasEdge predicate on the "mappings" edge with a given conditions (other predicates). +func HasMappingsWith(preds ...predicate.Mapping) predicate.Omnitrail { + return predicate.Omnitrail(func(s *sql.Selector) { + step := newMappingsStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasAttestation applies the HasEdge predicate on the "attestation" edge. +func HasAttestation() predicate.Omnitrail { + return predicate.Omnitrail(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2O, true, AttestationTable, AttestationColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasAttestationWith applies the HasEdge predicate on the "attestation" edge with a given conditions (other predicates). +func HasAttestationWith(preds ...predicate.Attestation) predicate.Omnitrail { + return predicate.Omnitrail(func(s *sql.Selector) { + step := newAttestationStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.Omnitrail) predicate.Omnitrail { + return predicate.Omnitrail(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.Omnitrail) predicate.Omnitrail { + return predicate.Omnitrail(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.Omnitrail) predicate.Omnitrail { + return predicate.Omnitrail(sql.NotPredicates(p)) +} diff --git a/ent/omnitrail_create.go b/ent/omnitrail_create.go new file mode 100644 index 00000000..617397d9 --- /dev/null +++ b/ent/omnitrail_create.go @@ -0,0 +1,234 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/in-toto/archivista/ent/attestation" + "github.com/in-toto/archivista/ent/mapping" + "github.com/in-toto/archivista/ent/omnitrail" +) + +// OmnitrailCreate is the builder for creating a Omnitrail entity. +type OmnitrailCreate struct { + config + mutation *OmnitrailMutation + hooks []Hook +} + +// AddMappingIDs adds the "mappings" edge to the Mapping entity by IDs. +func (oc *OmnitrailCreate) AddMappingIDs(ids ...int) *OmnitrailCreate { + oc.mutation.AddMappingIDs(ids...) + return oc +} + +// AddMappings adds the "mappings" edges to the Mapping entity. +func (oc *OmnitrailCreate) AddMappings(m ...*Mapping) *OmnitrailCreate { + ids := make([]int, len(m)) + for i := range m { + ids[i] = m[i].ID + } + return oc.AddMappingIDs(ids...) +} + +// SetAttestationID sets the "attestation" edge to the Attestation entity by ID. +func (oc *OmnitrailCreate) SetAttestationID(id int) *OmnitrailCreate { + oc.mutation.SetAttestationID(id) + return oc +} + +// SetAttestation sets the "attestation" edge to the Attestation entity. +func (oc *OmnitrailCreate) SetAttestation(a *Attestation) *OmnitrailCreate { + return oc.SetAttestationID(a.ID) +} + +// Mutation returns the OmnitrailMutation object of the builder. +func (oc *OmnitrailCreate) Mutation() *OmnitrailMutation { + return oc.mutation +} + +// Save creates the Omnitrail in the database. +func (oc *OmnitrailCreate) Save(ctx context.Context) (*Omnitrail, error) { + return withHooks(ctx, oc.sqlSave, oc.mutation, oc.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (oc *OmnitrailCreate) SaveX(ctx context.Context) *Omnitrail { + v, err := oc.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (oc *OmnitrailCreate) Exec(ctx context.Context) error { + _, err := oc.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (oc *OmnitrailCreate) ExecX(ctx context.Context) { + if err := oc.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (oc *OmnitrailCreate) check() error { + if _, ok := oc.mutation.AttestationID(); !ok { + return &ValidationError{Name: "attestation", err: errors.New(`ent: missing required edge "Omnitrail.attestation"`)} + } + return nil +} + +func (oc *OmnitrailCreate) sqlSave(ctx context.Context) (*Omnitrail, error) { + if err := oc.check(); err != nil { + return nil, err + } + _node, _spec := oc.createSpec() + if err := sqlgraph.CreateNode(ctx, oc.driver, _spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + id := _spec.ID.Value.(int64) + _node.ID = int(id) + oc.mutation.id = &_node.ID + oc.mutation.done = true + return _node, nil +} + +func (oc *OmnitrailCreate) createSpec() (*Omnitrail, *sqlgraph.CreateSpec) { + var ( + _node = &Omnitrail{config: oc.config} + _spec = sqlgraph.NewCreateSpec(omnitrail.Table, sqlgraph.NewFieldSpec(omnitrail.FieldID, field.TypeInt)) + ) + if nodes := oc.mutation.MappingsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: omnitrail.MappingsTable, + Columns: []string{omnitrail.MappingsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(mapping.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := oc.mutation.AttestationIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2O, + Inverse: true, + Table: omnitrail.AttestationTable, + Columns: []string{omnitrail.AttestationColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(attestation.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _node.attestation_omnitrail = &nodes[0] + _spec.Edges = append(_spec.Edges, edge) + } + return _node, _spec +} + +// OmnitrailCreateBulk is the builder for creating many Omnitrail entities in bulk. +type OmnitrailCreateBulk struct { + config + err error + builders []*OmnitrailCreate +} + +// Save creates the Omnitrail entities in the database. +func (ocb *OmnitrailCreateBulk) Save(ctx context.Context) ([]*Omnitrail, error) { + if ocb.err != nil { + return nil, ocb.err + } + specs := make([]*sqlgraph.CreateSpec, len(ocb.builders)) + nodes := make([]*Omnitrail, len(ocb.builders)) + mutators := make([]Mutator, len(ocb.builders)) + for i := range ocb.builders { + func(i int, root context.Context) { + builder := ocb.builders[i] + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*OmnitrailMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + if err := builder.check(); err != nil { + return nil, err + } + builder.mutation = mutation + var err error + nodes[i], specs[i] = builder.createSpec() + if i < len(mutators)-1 { + _, err = mutators[i+1].Mutate(root, ocb.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, ocb.driver, spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + } + } + if err != nil { + return nil, err + } + mutation.id = &nodes[i].ID + if specs[i].ID.Value != nil { + id := specs[i].ID.Value.(int64) + nodes[i].ID = int(id) + } + mutation.done = true + 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, ocb.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (ocb *OmnitrailCreateBulk) SaveX(ctx context.Context) []*Omnitrail { + v, err := ocb.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (ocb *OmnitrailCreateBulk) Exec(ctx context.Context) error { + _, err := ocb.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (ocb *OmnitrailCreateBulk) ExecX(ctx context.Context) { + if err := ocb.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/ent/omnitrail_delete.go b/ent/omnitrail_delete.go new file mode 100644 index 00000000..4bcaeb11 --- /dev/null +++ b/ent/omnitrail_delete.go @@ -0,0 +1,88 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/in-toto/archivista/ent/omnitrail" + "github.com/in-toto/archivista/ent/predicate" +) + +// OmnitrailDelete is the builder for deleting a Omnitrail entity. +type OmnitrailDelete struct { + config + hooks []Hook + mutation *OmnitrailMutation +} + +// Where appends a list predicates to the OmnitrailDelete builder. +func (od *OmnitrailDelete) Where(ps ...predicate.Omnitrail) *OmnitrailDelete { + od.mutation.Where(ps...) + return od +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (od *OmnitrailDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, od.sqlExec, od.mutation, od.hooks) +} + +// ExecX is like Exec, but panics if an error occurs. +func (od *OmnitrailDelete) ExecX(ctx context.Context) int { + n, err := od.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (od *OmnitrailDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(omnitrail.Table, sqlgraph.NewFieldSpec(omnitrail.FieldID, field.TypeInt)) + if ps := od.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + affected, err := sqlgraph.DeleteNodes(ctx, od.driver, _spec) + if err != nil && sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + od.mutation.done = true + return affected, err +} + +// OmnitrailDeleteOne is the builder for deleting a single Omnitrail entity. +type OmnitrailDeleteOne struct { + od *OmnitrailDelete +} + +// Where appends a list predicates to the OmnitrailDelete builder. +func (odo *OmnitrailDeleteOne) Where(ps ...predicate.Omnitrail) *OmnitrailDeleteOne { + odo.od.mutation.Where(ps...) + return odo +} + +// Exec executes the deletion query. +func (odo *OmnitrailDeleteOne) Exec(ctx context.Context) error { + n, err := odo.od.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{omnitrail.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (odo *OmnitrailDeleteOne) ExecX(ctx context.Context) { + if err := odo.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/ent/omnitrail_query.go b/ent/omnitrail_query.go new file mode 100644 index 00000000..90ef230c --- /dev/null +++ b/ent/omnitrail_query.go @@ -0,0 +1,702 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "database/sql/driver" + "fmt" + "math" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/in-toto/archivista/ent/attestation" + "github.com/in-toto/archivista/ent/mapping" + "github.com/in-toto/archivista/ent/omnitrail" + "github.com/in-toto/archivista/ent/predicate" +) + +// OmnitrailQuery is the builder for querying Omnitrail entities. +type OmnitrailQuery struct { + config + ctx *QueryContext + order []omnitrail.OrderOption + inters []Interceptor + predicates []predicate.Omnitrail + withMappings *MappingQuery + withAttestation *AttestationQuery + withFKs bool + modifiers []func(*sql.Selector) + loadTotal []func(context.Context, []*Omnitrail) error + withNamedMappings map[string]*MappingQuery + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Where adds a new predicate for the OmnitrailQuery builder. +func (oq *OmnitrailQuery) Where(ps ...predicate.Omnitrail) *OmnitrailQuery { + oq.predicates = append(oq.predicates, ps...) + return oq +} + +// Limit the number of records to be returned by this query. +func (oq *OmnitrailQuery) Limit(limit int) *OmnitrailQuery { + oq.ctx.Limit = &limit + return oq +} + +// Offset to start from. +func (oq *OmnitrailQuery) Offset(offset int) *OmnitrailQuery { + oq.ctx.Offset = &offset + return oq +} + +// 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 (oq *OmnitrailQuery) Unique(unique bool) *OmnitrailQuery { + oq.ctx.Unique = &unique + return oq +} + +// Order specifies how the records should be ordered. +func (oq *OmnitrailQuery) Order(o ...omnitrail.OrderOption) *OmnitrailQuery { + oq.order = append(oq.order, o...) + return oq +} + +// QueryMappings chains the current query on the "mappings" edge. +func (oq *OmnitrailQuery) QueryMappings() *MappingQuery { + query := (&MappingClient{config: oq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := oq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := oq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(omnitrail.Table, omnitrail.FieldID, selector), + sqlgraph.To(mapping.Table, mapping.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, omnitrail.MappingsTable, omnitrail.MappingsColumn), + ) + fromU = sqlgraph.SetNeighbors(oq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryAttestation chains the current query on the "attestation" edge. +func (oq *OmnitrailQuery) QueryAttestation() *AttestationQuery { + query := (&AttestationClient{config: oq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := oq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := oq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(omnitrail.Table, omnitrail.FieldID, selector), + sqlgraph.To(attestation.Table, attestation.FieldID), + sqlgraph.Edge(sqlgraph.O2O, true, omnitrail.AttestationTable, omnitrail.AttestationColumn), + ) + fromU = sqlgraph.SetNeighbors(oq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// First returns the first Omnitrail entity from the query. +// Returns a *NotFoundError when no Omnitrail was found. +func (oq *OmnitrailQuery) First(ctx context.Context) (*Omnitrail, error) { + nodes, err := oq.Limit(1).All(setContextOp(ctx, oq.ctx, "First")) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{omnitrail.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (oq *OmnitrailQuery) FirstX(ctx context.Context) *Omnitrail { + node, err := oq.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first Omnitrail ID from the query. +// Returns a *NotFoundError when no Omnitrail ID was found. +func (oq *OmnitrailQuery) FirstID(ctx context.Context) (id int, err error) { + var ids []int + if ids, err = oq.Limit(1).IDs(setContextOp(ctx, oq.ctx, "FirstID")); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{omnitrail.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (oq *OmnitrailQuery) FirstIDX(ctx context.Context) int { + id, err := oq.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single Omnitrail entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one Omnitrail entity is found. +// Returns a *NotFoundError when no Omnitrail entities are found. +func (oq *OmnitrailQuery) Only(ctx context.Context) (*Omnitrail, error) { + nodes, err := oq.Limit(2).All(setContextOp(ctx, oq.ctx, "Only")) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{omnitrail.Label} + default: + return nil, &NotSingularError{omnitrail.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (oq *OmnitrailQuery) OnlyX(ctx context.Context) *Omnitrail { + node, err := oq.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only Omnitrail ID in the query. +// Returns a *NotSingularError when more than one Omnitrail ID is found. +// Returns a *NotFoundError when no entities are found. +func (oq *OmnitrailQuery) OnlyID(ctx context.Context) (id int, err error) { + var ids []int + if ids, err = oq.Limit(2).IDs(setContextOp(ctx, oq.ctx, "OnlyID")); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{omnitrail.Label} + default: + err = &NotSingularError{omnitrail.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (oq *OmnitrailQuery) OnlyIDX(ctx context.Context) int { + id, err := oq.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of Omnitrails. +func (oq *OmnitrailQuery) All(ctx context.Context) ([]*Omnitrail, error) { + ctx = setContextOp(ctx, oq.ctx, "All") + if err := oq.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*Omnitrail, *OmnitrailQuery]() + return withInterceptors[[]*Omnitrail](ctx, oq, qr, oq.inters) +} + +// AllX is like All, but panics if an error occurs. +func (oq *OmnitrailQuery) AllX(ctx context.Context) []*Omnitrail { + nodes, err := oq.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of Omnitrail IDs. +func (oq *OmnitrailQuery) IDs(ctx context.Context) (ids []int, err error) { + if oq.ctx.Unique == nil && oq.path != nil { + oq.Unique(true) + } + ctx = setContextOp(ctx, oq.ctx, "IDs") + if err = oq.Select(omnitrail.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (oq *OmnitrailQuery) IDsX(ctx context.Context) []int { + ids, err := oq.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (oq *OmnitrailQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, oq.ctx, "Count") + if err := oq.prepareQuery(ctx); err != nil { + return 0, err + } + return withInterceptors[int](ctx, oq, querierCount[*OmnitrailQuery](), oq.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (oq *OmnitrailQuery) CountX(ctx context.Context) int { + count, err := oq.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (oq *OmnitrailQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, oq.ctx, "Exist") + switch _, err := oq.FirstID(ctx); { + case IsNotFound(err): + return false, nil + case err != nil: + return false, fmt.Errorf("ent: check existence: %w", err) + default: + return true, nil + } +} + +// ExistX is like Exist, but panics if an error occurs. +func (oq *OmnitrailQuery) ExistX(ctx context.Context) bool { + exist, err := oq.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the OmnitrailQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (oq *OmnitrailQuery) Clone() *OmnitrailQuery { + if oq == nil { + return nil + } + return &OmnitrailQuery{ + config: oq.config, + ctx: oq.ctx.Clone(), + order: append([]omnitrail.OrderOption{}, oq.order...), + inters: append([]Interceptor{}, oq.inters...), + predicates: append([]predicate.Omnitrail{}, oq.predicates...), + withMappings: oq.withMappings.Clone(), + withAttestation: oq.withAttestation.Clone(), + // clone intermediate query. + sql: oq.sql.Clone(), + path: oq.path, + } +} + +// WithMappings tells the query-builder to eager-load the nodes that are connected to +// the "mappings" edge. The optional arguments are used to configure the query builder of the edge. +func (oq *OmnitrailQuery) WithMappings(opts ...func(*MappingQuery)) *OmnitrailQuery { + query := (&MappingClient{config: oq.config}).Query() + for _, opt := range opts { + opt(query) + } + oq.withMappings = query + return oq +} + +// WithAttestation tells the query-builder to eager-load the nodes that are connected to +// the "attestation" edge. The optional arguments are used to configure the query builder of the edge. +func (oq *OmnitrailQuery) WithAttestation(opts ...func(*AttestationQuery)) *OmnitrailQuery { + query := (&AttestationClient{config: oq.config}).Query() + for _, opt := range opts { + opt(query) + } + oq.withAttestation = query + return oq +} + +// 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. +func (oq *OmnitrailQuery) GroupBy(field string, fields ...string) *OmnitrailGroupBy { + oq.ctx.Fields = append([]string{field}, fields...) + grbuild := &OmnitrailGroupBy{build: oq} + grbuild.flds = &oq.ctx.Fields + grbuild.label = omnitrail.Label + grbuild.scan = grbuild.Scan + return grbuild +} + +// Select allows the selection one or more fields/columns for the given query, +// instead of selecting all fields in the entity. +func (oq *OmnitrailQuery) Select(fields ...string) *OmnitrailSelect { + oq.ctx.Fields = append(oq.ctx.Fields, fields...) + sbuild := &OmnitrailSelect{OmnitrailQuery: oq} + sbuild.label = omnitrail.Label + sbuild.flds, sbuild.scan = &oq.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a OmnitrailSelect configured with the given aggregations. +func (oq *OmnitrailQuery) Aggregate(fns ...AggregateFunc) *OmnitrailSelect { + return oq.Select().Aggregate(fns...) +} + +func (oq *OmnitrailQuery) prepareQuery(ctx context.Context) error { + for _, inter := range oq.inters { + if inter == nil { + return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") + } + if trv, ok := inter.(Traverser); ok { + if err := trv.Traverse(ctx, oq); err != nil { + return err + } + } + } + for _, f := range oq.ctx.Fields { + if !omnitrail.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + } + if oq.path != nil { + prev, err := oq.path(ctx) + if err != nil { + return err + } + oq.sql = prev + } + return nil +} + +func (oq *OmnitrailQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Omnitrail, error) { + var ( + nodes = []*Omnitrail{} + withFKs = oq.withFKs + _spec = oq.querySpec() + loadedTypes = [2]bool{ + oq.withMappings != nil, + oq.withAttestation != nil, + } + ) + if oq.withAttestation != nil { + withFKs = true + } + if withFKs { + _spec.Node.Columns = append(_spec.Node.Columns, omnitrail.ForeignKeys...) + } + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*Omnitrail).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &Omnitrail{config: oq.config} + nodes = append(nodes, node) + node.Edges.loadedTypes = loadedTypes + return node.assignValues(columns, values) + } + if len(oq.modifiers) > 0 { + _spec.Modifiers = oq.modifiers + } + for i := range hooks { + hooks[i](ctx, _spec) + } + if err := sqlgraph.QueryNodes(ctx, oq.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + if query := oq.withMappings; query != nil { + if err := oq.loadMappings(ctx, query, nodes, + func(n *Omnitrail) { n.Edges.Mappings = []*Mapping{} }, + func(n *Omnitrail, e *Mapping) { n.Edges.Mappings = append(n.Edges.Mappings, e) }); err != nil { + return nil, err + } + } + if query := oq.withAttestation; query != nil { + if err := oq.loadAttestation(ctx, query, nodes, nil, + func(n *Omnitrail, e *Attestation) { n.Edges.Attestation = e }); err != nil { + return nil, err + } + } + for name, query := range oq.withNamedMappings { + if err := oq.loadMappings(ctx, query, nodes, + func(n *Omnitrail) { n.appendNamedMappings(name) }, + func(n *Omnitrail, e *Mapping) { n.appendNamedMappings(name, e) }); err != nil { + return nil, err + } + } + for i := range oq.loadTotal { + if err := oq.loadTotal[i](ctx, nodes); err != nil { + return nil, err + } + } + return nodes, nil +} + +func (oq *OmnitrailQuery) loadMappings(ctx context.Context, query *MappingQuery, nodes []*Omnitrail, init func(*Omnitrail), assign func(*Omnitrail, *Mapping)) error { + fks := make([]driver.Value, 0, len(nodes)) + nodeids := make(map[int]*Omnitrail) + for i := range nodes { + fks = append(fks, nodes[i].ID) + nodeids[nodes[i].ID] = nodes[i] + if init != nil { + init(nodes[i]) + } + } + query.withFKs = true + query.Where(predicate.Mapping(func(s *sql.Selector) { + s.Where(sql.InValues(s.C(omnitrail.MappingsColumn), fks...)) + })) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + fk := n.omnitrail_mappings + if fk == nil { + return fmt.Errorf(`foreign-key "omnitrail_mappings" is nil for node %v`, n.ID) + } + node, ok := nodeids[*fk] + if !ok { + return fmt.Errorf(`unexpected referenced foreign-key "omnitrail_mappings" returned %v for node %v`, *fk, n.ID) + } + assign(node, n) + } + return nil +} +func (oq *OmnitrailQuery) loadAttestation(ctx context.Context, query *AttestationQuery, nodes []*Omnitrail, init func(*Omnitrail), assign func(*Omnitrail, *Attestation)) error { + ids := make([]int, 0, len(nodes)) + nodeids := make(map[int][]*Omnitrail) + for i := range nodes { + if nodes[i].attestation_omnitrail == nil { + continue + } + fk := *nodes[i].attestation_omnitrail + if _, ok := nodeids[fk]; !ok { + ids = append(ids, fk) + } + nodeids[fk] = append(nodeids[fk], nodes[i]) + } + if len(ids) == 0 { + return nil + } + query.Where(attestation.IDIn(ids...)) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nodeids[n.ID] + if !ok { + return fmt.Errorf(`unexpected foreign-key "attestation_omnitrail" returned %v`, n.ID) + } + for i := range nodes { + assign(nodes[i], n) + } + } + return nil +} + +func (oq *OmnitrailQuery) sqlCount(ctx context.Context) (int, error) { + _spec := oq.querySpec() + if len(oq.modifiers) > 0 { + _spec.Modifiers = oq.modifiers + } + _spec.Node.Columns = oq.ctx.Fields + if len(oq.ctx.Fields) > 0 { + _spec.Unique = oq.ctx.Unique != nil && *oq.ctx.Unique + } + return sqlgraph.CountNodes(ctx, oq.driver, _spec) +} + +func (oq *OmnitrailQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(omnitrail.Table, omnitrail.Columns, sqlgraph.NewFieldSpec(omnitrail.FieldID, field.TypeInt)) + _spec.From = oq.sql + if unique := oq.ctx.Unique; unique != nil { + _spec.Unique = *unique + } else if oq.path != nil { + _spec.Unique = true + } + if fields := oq.ctx.Fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, omnitrail.FieldID) + for i := range fields { + if fields[i] != omnitrail.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + } + if ps := oq.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := oq.ctx.Limit; limit != nil { + _spec.Limit = *limit + } + if offset := oq.ctx.Offset; offset != nil { + _spec.Offset = *offset + } + if ps := oq.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (oq *OmnitrailQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(oq.driver.Dialect()) + t1 := builder.Table(omnitrail.Table) + columns := oq.ctx.Fields + if len(columns) == 0 { + columns = omnitrail.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if oq.sql != nil { + selector = oq.sql + selector.Select(selector.Columns(columns...)...) + } + if oq.ctx.Unique != nil && *oq.ctx.Unique { + selector.Distinct() + } + for _, p := range oq.predicates { + p(selector) + } + for _, p := range oq.order { + p(selector) + } + if offset := oq.ctx.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 := oq.ctx.Limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// WithNamedMappings tells the query-builder to eager-load the nodes that are connected to the "mappings" +// edge with the given name. The optional arguments are used to configure the query builder of the edge. +func (oq *OmnitrailQuery) WithNamedMappings(name string, opts ...func(*MappingQuery)) *OmnitrailQuery { + query := (&MappingClient{config: oq.config}).Query() + for _, opt := range opts { + opt(query) + } + if oq.withNamedMappings == nil { + oq.withNamedMappings = make(map[string]*MappingQuery) + } + oq.withNamedMappings[name] = query + return oq +} + +// OmnitrailGroupBy is the group-by builder for Omnitrail entities. +type OmnitrailGroupBy struct { + selector + build *OmnitrailQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (ogb *OmnitrailGroupBy) Aggregate(fns ...AggregateFunc) *OmnitrailGroupBy { + ogb.fns = append(ogb.fns, fns...) + return ogb +} + +// Scan applies the selector query and scans the result into the given value. +func (ogb *OmnitrailGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, ogb.build.ctx, "GroupBy") + if err := ogb.build.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*OmnitrailQuery, *OmnitrailGroupBy](ctx, ogb.build, ogb, ogb.build.inters, v) +} + +func (ogb *OmnitrailGroupBy) sqlScan(ctx context.Context, root *OmnitrailQuery, v any) error { + selector := root.sqlQuery(ctx).Select() + aggregation := make([]string, 0, len(ogb.fns)) + for _, fn := range ogb.fns { + aggregation = append(aggregation, fn(selector)) + } + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*ogb.flds)+len(ogb.fns)) + for _, f := range *ogb.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*ogb.flds...)...) + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := ogb.build.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// OmnitrailSelect is the builder for selecting fields of Omnitrail entities. +type OmnitrailSelect struct { + *OmnitrailQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (os *OmnitrailSelect) Aggregate(fns ...AggregateFunc) *OmnitrailSelect { + os.fns = append(os.fns, fns...) + return os +} + +// Scan applies the selector query and scans the result into the given value. +func (os *OmnitrailSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, os.ctx, "Select") + if err := os.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*OmnitrailQuery, *OmnitrailSelect](ctx, os.OmnitrailQuery, os, os.inters, v) +} + +func (os *OmnitrailSelect) sqlScan(ctx context.Context, root *OmnitrailQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(os.fns)) + for _, fn := range os.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*os.selector.flds); { + case n == 0 && len(aggregation) > 0: + selector.Select(aggregation...) + case n != 0 && len(aggregation) > 0: + selector.AppendSelect(aggregation...) + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := os.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} diff --git a/ent/omnitrail_update.go b/ent/omnitrail_update.go new file mode 100644 index 00000000..85510c40 --- /dev/null +++ b/ent/omnitrail_update.go @@ -0,0 +1,453 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/in-toto/archivista/ent/attestation" + "github.com/in-toto/archivista/ent/mapping" + "github.com/in-toto/archivista/ent/omnitrail" + "github.com/in-toto/archivista/ent/predicate" +) + +// OmnitrailUpdate is the builder for updating Omnitrail entities. +type OmnitrailUpdate struct { + config + hooks []Hook + mutation *OmnitrailMutation +} + +// Where appends a list predicates to the OmnitrailUpdate builder. +func (ou *OmnitrailUpdate) Where(ps ...predicate.Omnitrail) *OmnitrailUpdate { + ou.mutation.Where(ps...) + return ou +} + +// AddMappingIDs adds the "mappings" edge to the Mapping entity by IDs. +func (ou *OmnitrailUpdate) AddMappingIDs(ids ...int) *OmnitrailUpdate { + ou.mutation.AddMappingIDs(ids...) + return ou +} + +// AddMappings adds the "mappings" edges to the Mapping entity. +func (ou *OmnitrailUpdate) AddMappings(m ...*Mapping) *OmnitrailUpdate { + ids := make([]int, len(m)) + for i := range m { + ids[i] = m[i].ID + } + return ou.AddMappingIDs(ids...) +} + +// SetAttestationID sets the "attestation" edge to the Attestation entity by ID. +func (ou *OmnitrailUpdate) SetAttestationID(id int) *OmnitrailUpdate { + ou.mutation.SetAttestationID(id) + return ou +} + +// SetAttestation sets the "attestation" edge to the Attestation entity. +func (ou *OmnitrailUpdate) SetAttestation(a *Attestation) *OmnitrailUpdate { + return ou.SetAttestationID(a.ID) +} + +// Mutation returns the OmnitrailMutation object of the builder. +func (ou *OmnitrailUpdate) Mutation() *OmnitrailMutation { + return ou.mutation +} + +// ClearMappings clears all "mappings" edges to the Mapping entity. +func (ou *OmnitrailUpdate) ClearMappings() *OmnitrailUpdate { + ou.mutation.ClearMappings() + return ou +} + +// RemoveMappingIDs removes the "mappings" edge to Mapping entities by IDs. +func (ou *OmnitrailUpdate) RemoveMappingIDs(ids ...int) *OmnitrailUpdate { + ou.mutation.RemoveMappingIDs(ids...) + return ou +} + +// RemoveMappings removes "mappings" edges to Mapping entities. +func (ou *OmnitrailUpdate) RemoveMappings(m ...*Mapping) *OmnitrailUpdate { + ids := make([]int, len(m)) + for i := range m { + ids[i] = m[i].ID + } + return ou.RemoveMappingIDs(ids...) +} + +// ClearAttestation clears the "attestation" edge to the Attestation entity. +func (ou *OmnitrailUpdate) ClearAttestation() *OmnitrailUpdate { + ou.mutation.ClearAttestation() + return ou +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (ou *OmnitrailUpdate) Save(ctx context.Context) (int, error) { + return withHooks(ctx, ou.sqlSave, ou.mutation, ou.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (ou *OmnitrailUpdate) SaveX(ctx context.Context) int { + affected, err := ou.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (ou *OmnitrailUpdate) Exec(ctx context.Context) error { + _, err := ou.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (ou *OmnitrailUpdate) ExecX(ctx context.Context) { + if err := ou.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (ou *OmnitrailUpdate) check() error { + if _, ok := ou.mutation.AttestationID(); ou.mutation.AttestationCleared() && !ok { + return errors.New(`ent: clearing a required unique edge "Omnitrail.attestation"`) + } + return nil +} + +func (ou *OmnitrailUpdate) sqlSave(ctx context.Context) (n int, err error) { + if err := ou.check(); err != nil { + return n, err + } + _spec := sqlgraph.NewUpdateSpec(omnitrail.Table, omnitrail.Columns, sqlgraph.NewFieldSpec(omnitrail.FieldID, field.TypeInt)) + if ps := ou.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if ou.mutation.MappingsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: omnitrail.MappingsTable, + Columns: []string{omnitrail.MappingsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(mapping.FieldID, field.TypeInt), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := ou.mutation.RemovedMappingsIDs(); len(nodes) > 0 && !ou.mutation.MappingsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: omnitrail.MappingsTable, + Columns: []string{omnitrail.MappingsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(mapping.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := ou.mutation.MappingsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: omnitrail.MappingsTable, + Columns: []string{omnitrail.MappingsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(mapping.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if ou.mutation.AttestationCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2O, + Inverse: true, + Table: omnitrail.AttestationTable, + Columns: []string{omnitrail.AttestationColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(attestation.FieldID, field.TypeInt), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := ou.mutation.AttestationIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2O, + Inverse: true, + Table: omnitrail.AttestationTable, + Columns: []string{omnitrail.AttestationColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(attestation.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if n, err = sqlgraph.UpdateNodes(ctx, ou.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{omnitrail.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + ou.mutation.done = true + return n, nil +} + +// OmnitrailUpdateOne is the builder for updating a single Omnitrail entity. +type OmnitrailUpdateOne struct { + config + fields []string + hooks []Hook + mutation *OmnitrailMutation +} + +// AddMappingIDs adds the "mappings" edge to the Mapping entity by IDs. +func (ouo *OmnitrailUpdateOne) AddMappingIDs(ids ...int) *OmnitrailUpdateOne { + ouo.mutation.AddMappingIDs(ids...) + return ouo +} + +// AddMappings adds the "mappings" edges to the Mapping entity. +func (ouo *OmnitrailUpdateOne) AddMappings(m ...*Mapping) *OmnitrailUpdateOne { + ids := make([]int, len(m)) + for i := range m { + ids[i] = m[i].ID + } + return ouo.AddMappingIDs(ids...) +} + +// SetAttestationID sets the "attestation" edge to the Attestation entity by ID. +func (ouo *OmnitrailUpdateOne) SetAttestationID(id int) *OmnitrailUpdateOne { + ouo.mutation.SetAttestationID(id) + return ouo +} + +// SetAttestation sets the "attestation" edge to the Attestation entity. +func (ouo *OmnitrailUpdateOne) SetAttestation(a *Attestation) *OmnitrailUpdateOne { + return ouo.SetAttestationID(a.ID) +} + +// Mutation returns the OmnitrailMutation object of the builder. +func (ouo *OmnitrailUpdateOne) Mutation() *OmnitrailMutation { + return ouo.mutation +} + +// ClearMappings clears all "mappings" edges to the Mapping entity. +func (ouo *OmnitrailUpdateOne) ClearMappings() *OmnitrailUpdateOne { + ouo.mutation.ClearMappings() + return ouo +} + +// RemoveMappingIDs removes the "mappings" edge to Mapping entities by IDs. +func (ouo *OmnitrailUpdateOne) RemoveMappingIDs(ids ...int) *OmnitrailUpdateOne { + ouo.mutation.RemoveMappingIDs(ids...) + return ouo +} + +// RemoveMappings removes "mappings" edges to Mapping entities. +func (ouo *OmnitrailUpdateOne) RemoveMappings(m ...*Mapping) *OmnitrailUpdateOne { + ids := make([]int, len(m)) + for i := range m { + ids[i] = m[i].ID + } + return ouo.RemoveMappingIDs(ids...) +} + +// ClearAttestation clears the "attestation" edge to the Attestation entity. +func (ouo *OmnitrailUpdateOne) ClearAttestation() *OmnitrailUpdateOne { + ouo.mutation.ClearAttestation() + return ouo +} + +// Where appends a list predicates to the OmnitrailUpdate builder. +func (ouo *OmnitrailUpdateOne) Where(ps ...predicate.Omnitrail) *OmnitrailUpdateOne { + ouo.mutation.Where(ps...) + return ouo +} + +// Select allows selecting one or more fields (columns) of the returned entity. +// The default is selecting all fields defined in the entity schema. +func (ouo *OmnitrailUpdateOne) Select(field string, fields ...string) *OmnitrailUpdateOne { + ouo.fields = append([]string{field}, fields...) + return ouo +} + +// Save executes the query and returns the updated Omnitrail entity. +func (ouo *OmnitrailUpdateOne) Save(ctx context.Context) (*Omnitrail, error) { + return withHooks(ctx, ouo.sqlSave, ouo.mutation, ouo.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (ouo *OmnitrailUpdateOne) SaveX(ctx context.Context) *Omnitrail { + node, err := ouo.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (ouo *OmnitrailUpdateOne) Exec(ctx context.Context) error { + _, err := ouo.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (ouo *OmnitrailUpdateOne) ExecX(ctx context.Context) { + if err := ouo.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (ouo *OmnitrailUpdateOne) check() error { + if _, ok := ouo.mutation.AttestationID(); ouo.mutation.AttestationCleared() && !ok { + return errors.New(`ent: clearing a required unique edge "Omnitrail.attestation"`) + } + return nil +} + +func (ouo *OmnitrailUpdateOne) sqlSave(ctx context.Context) (_node *Omnitrail, err error) { + if err := ouo.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(omnitrail.Table, omnitrail.Columns, sqlgraph.NewFieldSpec(omnitrail.FieldID, field.TypeInt)) + id, ok := ouo.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Omnitrail.id" for update`)} + } + _spec.Node.ID.Value = id + if fields := ouo.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, omnitrail.FieldID) + for _, f := range fields { + if !omnitrail.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != omnitrail.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, f) + } + } + } + if ps := ouo.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if ouo.mutation.MappingsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: omnitrail.MappingsTable, + Columns: []string{omnitrail.MappingsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(mapping.FieldID, field.TypeInt), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := ouo.mutation.RemovedMappingsIDs(); len(nodes) > 0 && !ouo.mutation.MappingsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: omnitrail.MappingsTable, + Columns: []string{omnitrail.MappingsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(mapping.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := ouo.mutation.MappingsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: omnitrail.MappingsTable, + Columns: []string{omnitrail.MappingsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(mapping.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if ouo.mutation.AttestationCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2O, + Inverse: true, + Table: omnitrail.AttestationTable, + Columns: []string{omnitrail.AttestationColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(attestation.FieldID, field.TypeInt), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := ouo.mutation.AttestationIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2O, + Inverse: true, + Table: omnitrail.AttestationTable, + Columns: []string{omnitrail.AttestationColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(attestation.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + _node = &Omnitrail{config: ouo.config} + _spec.Assign = _node.assignValues + _spec.ScanValues = _node.scanValues + if err = sqlgraph.UpdateNode(ctx, ouo.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{omnitrail.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + ouo.mutation.done = true + return _node, nil +} diff --git a/ent/posix.go b/ent/posix.go new file mode 100644 index 00000000..7b39a6f4 --- /dev/null +++ b/ent/posix.go @@ -0,0 +1,309 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "fmt" + "strings" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "github.com/in-toto/archivista/ent/mapping" + "github.com/in-toto/archivista/ent/posix" +) + +// Posix is the model entity for the Posix schema. +type Posix struct { + config `json:"-"` + // ID of the ent. + ID int `json:"id,omitempty"` + // Atime holds the value of the "atime" field. + Atime string `json:"atime,omitempty"` + // Ctime holds the value of the "ctime" field. + Ctime string `json:"ctime,omitempty"` + // CreationTime holds the value of the "creation_time" field. + CreationTime string `json:"creation_time,omitempty"` + // ExtendedAttributes holds the value of the "extended_attributes" field. + ExtendedAttributes string `json:"extended_attributes,omitempty"` + // FileDeviceID holds the value of the "file_device_id" field. + FileDeviceID string `json:"file_device_id,omitempty"` + // FileFlags holds the value of the "file_flags" field. + FileFlags string `json:"file_flags,omitempty"` + // FileInode holds the value of the "file_inode" field. + FileInode string `json:"file_inode,omitempty"` + // FileSystemID holds the value of the "file_system_id" field. + FileSystemID string `json:"file_system_id,omitempty"` + // FileType holds the value of the "file_type" field. + FileType string `json:"file_type,omitempty"` + // HardLinkCount holds the value of the "hard_link_count" field. + HardLinkCount string `json:"hard_link_count,omitempty"` + // Mtime holds the value of the "mtime" field. + Mtime string `json:"mtime,omitempty"` + // MetadataCtime holds the value of the "metadata_ctime" field. + MetadataCtime string `json:"metadata_ctime,omitempty"` + // OwnerGid holds the value of the "owner_gid" field. + OwnerGid string `json:"owner_gid,omitempty"` + // OwnerUID holds the value of the "owner_uid" field. + OwnerUID string `json:"owner_uid,omitempty"` + // Permissions holds the value of the "permissions" field. + Permissions string `json:"permissions,omitempty"` + // Size holds the value of the "size" field. + Size string `json:"size,omitempty"` + // Edges holds the relations/edges for other nodes in the graph. + // The values are being populated by the PosixQuery when eager-loading is set. + Edges PosixEdges `json:"edges"` + mapping_posix *int + selectValues sql.SelectValues +} + +// PosixEdges holds the relations/edges for other nodes in the graph. +type PosixEdges struct { + // Mapping holds the value of the mapping edge. + Mapping *Mapping `json:"mapping,omitempty"` + // loadedTypes holds the information for reporting if a + // type was loaded (or requested) in eager-loading or not. + loadedTypes [1]bool + // totalCount holds the count of the edges above. + totalCount [1]map[string]int +} + +// MappingOrErr returns the Mapping value or an error if the edge +// was not loaded in eager-loading, or loaded but was not found. +func (e PosixEdges) MappingOrErr() (*Mapping, error) { + if e.Mapping != nil { + return e.Mapping, nil + } else if e.loadedTypes[0] { + return nil, &NotFoundError{label: mapping.Label} + } + return nil, &NotLoadedError{edge: "mapping"} +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*Posix) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case posix.FieldID: + values[i] = new(sql.NullInt64) + case posix.FieldAtime, posix.FieldCtime, posix.FieldCreationTime, posix.FieldExtendedAttributes, posix.FieldFileDeviceID, posix.FieldFileFlags, posix.FieldFileInode, posix.FieldFileSystemID, posix.FieldFileType, posix.FieldHardLinkCount, posix.FieldMtime, posix.FieldMetadataCtime, posix.FieldOwnerGid, posix.FieldOwnerUID, posix.FieldPermissions, posix.FieldSize: + values[i] = new(sql.NullString) + case posix.ForeignKeys[0]: // mapping_posix + values[i] = new(sql.NullInt64) + default: + values[i] = new(sql.UnknownType) + } + } + return values, nil +} + +// assignValues assigns the values that were returned from sql.Rows (after scanning) +// to the Posix fields. +func (po *Posix) 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 posix.FieldID: + value, ok := values[i].(*sql.NullInt64) + if !ok { + return fmt.Errorf("unexpected type %T for field id", value) + } + po.ID = int(value.Int64) + case posix.FieldAtime: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field atime", values[i]) + } else if value.Valid { + po.Atime = value.String + } + case posix.FieldCtime: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field ctime", values[i]) + } else if value.Valid { + po.Ctime = value.String + } + case posix.FieldCreationTime: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field creation_time", values[i]) + } else if value.Valid { + po.CreationTime = value.String + } + case posix.FieldExtendedAttributes: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field extended_attributes", values[i]) + } else if value.Valid { + po.ExtendedAttributes = value.String + } + case posix.FieldFileDeviceID: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field file_device_id", values[i]) + } else if value.Valid { + po.FileDeviceID = value.String + } + case posix.FieldFileFlags: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field file_flags", values[i]) + } else if value.Valid { + po.FileFlags = value.String + } + case posix.FieldFileInode: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field file_inode", values[i]) + } else if value.Valid { + po.FileInode = value.String + } + case posix.FieldFileSystemID: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field file_system_id", values[i]) + } else if value.Valid { + po.FileSystemID = value.String + } + case posix.FieldFileType: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field file_type", values[i]) + } else if value.Valid { + po.FileType = value.String + } + case posix.FieldHardLinkCount: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field hard_link_count", values[i]) + } else if value.Valid { + po.HardLinkCount = value.String + } + case posix.FieldMtime: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field mtime", values[i]) + } else if value.Valid { + po.Mtime = value.String + } + case posix.FieldMetadataCtime: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field metadata_ctime", values[i]) + } else if value.Valid { + po.MetadataCtime = value.String + } + case posix.FieldOwnerGid: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field owner_gid", values[i]) + } else if value.Valid { + po.OwnerGid = value.String + } + case posix.FieldOwnerUID: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field owner_uid", values[i]) + } else if value.Valid { + po.OwnerUID = value.String + } + case posix.FieldPermissions: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field permissions", values[i]) + } else if value.Valid { + po.Permissions = value.String + } + case posix.FieldSize: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field size", values[i]) + } else if value.Valid { + po.Size = value.String + } + case posix.ForeignKeys[0]: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for edge-field mapping_posix", value) + } else if value.Valid { + po.mapping_posix = new(int) + *po.mapping_posix = int(value.Int64) + } + default: + po.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the Posix. +// This includes values selected through modifiers, order, etc. +func (po *Posix) Value(name string) (ent.Value, error) { + return po.selectValues.Get(name) +} + +// QueryMapping queries the "mapping" edge of the Posix entity. +func (po *Posix) QueryMapping() *MappingQuery { + return NewPosixClient(po.config).QueryMapping(po) +} + +// Update returns a builder for updating this Posix. +// Note that you need to call Posix.Unwrap() before calling this method if this Posix +// was returned from a transaction, and the transaction was committed or rolled back. +func (po *Posix) Update() *PosixUpdateOne { + return NewPosixClient(po.config).UpdateOne(po) +} + +// Unwrap unwraps the Posix 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 (po *Posix) Unwrap() *Posix { + _tx, ok := po.config.driver.(*txDriver) + if !ok { + panic("ent: Posix is not a transactional entity") + } + po.config.driver = _tx.drv + return po +} + +// String implements the fmt.Stringer. +func (po *Posix) String() string { + var builder strings.Builder + builder.WriteString("Posix(") + builder.WriteString(fmt.Sprintf("id=%v, ", po.ID)) + builder.WriteString("atime=") + builder.WriteString(po.Atime) + builder.WriteString(", ") + builder.WriteString("ctime=") + builder.WriteString(po.Ctime) + builder.WriteString(", ") + builder.WriteString("creation_time=") + builder.WriteString(po.CreationTime) + builder.WriteString(", ") + builder.WriteString("extended_attributes=") + builder.WriteString(po.ExtendedAttributes) + builder.WriteString(", ") + builder.WriteString("file_device_id=") + builder.WriteString(po.FileDeviceID) + builder.WriteString(", ") + builder.WriteString("file_flags=") + builder.WriteString(po.FileFlags) + builder.WriteString(", ") + builder.WriteString("file_inode=") + builder.WriteString(po.FileInode) + builder.WriteString(", ") + builder.WriteString("file_system_id=") + builder.WriteString(po.FileSystemID) + builder.WriteString(", ") + builder.WriteString("file_type=") + builder.WriteString(po.FileType) + builder.WriteString(", ") + builder.WriteString("hard_link_count=") + builder.WriteString(po.HardLinkCount) + builder.WriteString(", ") + builder.WriteString("mtime=") + builder.WriteString(po.Mtime) + builder.WriteString(", ") + builder.WriteString("metadata_ctime=") + builder.WriteString(po.MetadataCtime) + builder.WriteString(", ") + builder.WriteString("owner_gid=") + builder.WriteString(po.OwnerGid) + builder.WriteString(", ") + builder.WriteString("owner_uid=") + builder.WriteString(po.OwnerUID) + builder.WriteString(", ") + builder.WriteString("permissions=") + builder.WriteString(po.Permissions) + builder.WriteString(", ") + builder.WriteString("size=") + builder.WriteString(po.Size) + builder.WriteByte(')') + return builder.String() +} + +// Posixes is a parsable slice of Posix. +type Posixes []*Posix diff --git a/ent/posix/posix.go b/ent/posix/posix.go new file mode 100644 index 00000000..0f0b5fd1 --- /dev/null +++ b/ent/posix/posix.go @@ -0,0 +1,202 @@ +// Code generated by ent, DO NOT EDIT. + +package posix + +import ( + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +const ( + // Label holds the string label denoting the posix type in the database. + Label = "posix" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // FieldAtime holds the string denoting the atime field in the database. + FieldAtime = "atime" + // FieldCtime holds the string denoting the ctime field in the database. + FieldCtime = "ctime" + // FieldCreationTime holds the string denoting the creation_time field in the database. + FieldCreationTime = "creation_time" + // FieldExtendedAttributes holds the string denoting the extended_attributes field in the database. + FieldExtendedAttributes = "extended_attributes" + // FieldFileDeviceID holds the string denoting the file_device_id field in the database. + FieldFileDeviceID = "file_device_id" + // FieldFileFlags holds the string denoting the file_flags field in the database. + FieldFileFlags = "file_flags" + // FieldFileInode holds the string denoting the file_inode field in the database. + FieldFileInode = "file_inode" + // FieldFileSystemID holds the string denoting the file_system_id field in the database. + FieldFileSystemID = "file_system_id" + // FieldFileType holds the string denoting the file_type field in the database. + FieldFileType = "file_type" + // FieldHardLinkCount holds the string denoting the hard_link_count field in the database. + FieldHardLinkCount = "hard_link_count" + // FieldMtime holds the string denoting the mtime field in the database. + FieldMtime = "mtime" + // FieldMetadataCtime holds the string denoting the metadata_ctime field in the database. + FieldMetadataCtime = "metadata_ctime" + // FieldOwnerGid holds the string denoting the owner_gid field in the database. + FieldOwnerGid = "owner_gid" + // FieldOwnerUID holds the string denoting the owner_uid field in the database. + FieldOwnerUID = "owner_uid" + // FieldPermissions holds the string denoting the permissions field in the database. + FieldPermissions = "permissions" + // FieldSize holds the string denoting the size field in the database. + FieldSize = "size" + // EdgeMapping holds the string denoting the mapping edge name in mutations. + EdgeMapping = "mapping" + // Table holds the table name of the posix in the database. + Table = "posixes" + // MappingTable is the table that holds the mapping relation/edge. + MappingTable = "posixes" + // MappingInverseTable is the table name for the Mapping entity. + // It exists in this package in order to avoid circular dependency with the "mapping" package. + MappingInverseTable = "mappings" + // MappingColumn is the table column denoting the mapping relation/edge. + MappingColumn = "mapping_posix" +) + +// Columns holds all SQL columns for posix fields. +var Columns = []string{ + FieldID, + FieldAtime, + FieldCtime, + FieldCreationTime, + FieldExtendedAttributes, + FieldFileDeviceID, + FieldFileFlags, + FieldFileInode, + FieldFileSystemID, + FieldFileType, + FieldHardLinkCount, + FieldMtime, + FieldMetadataCtime, + FieldOwnerGid, + FieldOwnerUID, + FieldPermissions, + FieldSize, +} + +// ForeignKeys holds the SQL foreign-keys that are owned by the "posixes" +// table and are not defined as standalone fields in the schema. +var ForeignKeys = []string{ + "mapping_posix", +} + +// 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 + } + } + for i := range ForeignKeys { + if column == ForeignKeys[i] { + return true + } + } + return false +} + +// OrderOption defines the ordering options for the Posix queries. +type OrderOption func(*sql.Selector) + +// ByID orders the results by the id field. +func ByID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldID, opts...).ToFunc() +} + +// ByAtime orders the results by the atime field. +func ByAtime(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldAtime, opts...).ToFunc() +} + +// ByCtime orders the results by the ctime field. +func ByCtime(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCtime, opts...).ToFunc() +} + +// ByCreationTime orders the results by the creation_time field. +func ByCreationTime(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreationTime, opts...).ToFunc() +} + +// ByExtendedAttributes orders the results by the extended_attributes field. +func ByExtendedAttributes(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldExtendedAttributes, opts...).ToFunc() +} + +// ByFileDeviceID orders the results by the file_device_id field. +func ByFileDeviceID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldFileDeviceID, opts...).ToFunc() +} + +// ByFileFlags orders the results by the file_flags field. +func ByFileFlags(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldFileFlags, opts...).ToFunc() +} + +// ByFileInode orders the results by the file_inode field. +func ByFileInode(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldFileInode, opts...).ToFunc() +} + +// ByFileSystemID orders the results by the file_system_id field. +func ByFileSystemID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldFileSystemID, opts...).ToFunc() +} + +// ByFileType orders the results by the file_type field. +func ByFileType(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldFileType, opts...).ToFunc() +} + +// ByHardLinkCount orders the results by the hard_link_count field. +func ByHardLinkCount(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldHardLinkCount, opts...).ToFunc() +} + +// ByMtime orders the results by the mtime field. +func ByMtime(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldMtime, opts...).ToFunc() +} + +// ByMetadataCtime orders the results by the metadata_ctime field. +func ByMetadataCtime(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldMetadataCtime, opts...).ToFunc() +} + +// ByOwnerGid orders the results by the owner_gid field. +func ByOwnerGid(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldOwnerGid, opts...).ToFunc() +} + +// ByOwnerUID orders the results by the owner_uid field. +func ByOwnerUID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldOwnerUID, opts...).ToFunc() +} + +// ByPermissions orders the results by the permissions field. +func ByPermissions(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldPermissions, opts...).ToFunc() +} + +// BySize orders the results by the size field. +func BySize(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldSize, opts...).ToFunc() +} + +// ByMappingField orders the results by mapping field. +func ByMappingField(field string, opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newMappingStep(), sql.OrderByField(field, opts...)) + } +} +func newMappingStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(MappingInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, MappingTable, MappingColumn), + ) +} diff --git a/ent/posix/where.go b/ent/posix/where.go new file mode 100644 index 00000000..cb93f613 --- /dev/null +++ b/ent/posix/where.go @@ -0,0 +1,1212 @@ +// Code generated by ent, DO NOT EDIT. + +package posix + +import ( + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "github.com/in-toto/archivista/ent/predicate" +) + +// ID filters vertices based on their ID field. +func ID(id int) predicate.Posix { + return predicate.Posix(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id int) predicate.Posix { + return predicate.Posix(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id int) predicate.Posix { + return predicate.Posix(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...int) predicate.Posix { + return predicate.Posix(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...int) predicate.Posix { + return predicate.Posix(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id int) predicate.Posix { + return predicate.Posix(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id int) predicate.Posix { + return predicate.Posix(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id int) predicate.Posix { + return predicate.Posix(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id int) predicate.Posix { + return predicate.Posix(sql.FieldLTE(FieldID, id)) +} + +// Atime applies equality check predicate on the "atime" field. It's identical to AtimeEQ. +func Atime(v string) predicate.Posix { + return predicate.Posix(sql.FieldEQ(FieldAtime, v)) +} + +// Ctime applies equality check predicate on the "ctime" field. It's identical to CtimeEQ. +func Ctime(v string) predicate.Posix { + return predicate.Posix(sql.FieldEQ(FieldCtime, v)) +} + +// CreationTime applies equality check predicate on the "creation_time" field. It's identical to CreationTimeEQ. +func CreationTime(v string) predicate.Posix { + return predicate.Posix(sql.FieldEQ(FieldCreationTime, v)) +} + +// ExtendedAttributes applies equality check predicate on the "extended_attributes" field. It's identical to ExtendedAttributesEQ. +func ExtendedAttributes(v string) predicate.Posix { + return predicate.Posix(sql.FieldEQ(FieldExtendedAttributes, v)) +} + +// FileDeviceID applies equality check predicate on the "file_device_id" field. It's identical to FileDeviceIDEQ. +func FileDeviceID(v string) predicate.Posix { + return predicate.Posix(sql.FieldEQ(FieldFileDeviceID, v)) +} + +// FileFlags applies equality check predicate on the "file_flags" field. It's identical to FileFlagsEQ. +func FileFlags(v string) predicate.Posix { + return predicate.Posix(sql.FieldEQ(FieldFileFlags, v)) +} + +// FileInode applies equality check predicate on the "file_inode" field. It's identical to FileInodeEQ. +func FileInode(v string) predicate.Posix { + return predicate.Posix(sql.FieldEQ(FieldFileInode, v)) +} + +// FileSystemID applies equality check predicate on the "file_system_id" field. It's identical to FileSystemIDEQ. +func FileSystemID(v string) predicate.Posix { + return predicate.Posix(sql.FieldEQ(FieldFileSystemID, v)) +} + +// FileType applies equality check predicate on the "file_type" field. It's identical to FileTypeEQ. +func FileType(v string) predicate.Posix { + return predicate.Posix(sql.FieldEQ(FieldFileType, v)) +} + +// HardLinkCount applies equality check predicate on the "hard_link_count" field. It's identical to HardLinkCountEQ. +func HardLinkCount(v string) predicate.Posix { + return predicate.Posix(sql.FieldEQ(FieldHardLinkCount, v)) +} + +// Mtime applies equality check predicate on the "mtime" field. It's identical to MtimeEQ. +func Mtime(v string) predicate.Posix { + return predicate.Posix(sql.FieldEQ(FieldMtime, v)) +} + +// MetadataCtime applies equality check predicate on the "metadata_ctime" field. It's identical to MetadataCtimeEQ. +func MetadataCtime(v string) predicate.Posix { + return predicate.Posix(sql.FieldEQ(FieldMetadataCtime, v)) +} + +// OwnerGid applies equality check predicate on the "owner_gid" field. It's identical to OwnerGidEQ. +func OwnerGid(v string) predicate.Posix { + return predicate.Posix(sql.FieldEQ(FieldOwnerGid, v)) +} + +// OwnerUID applies equality check predicate on the "owner_uid" field. It's identical to OwnerUIDEQ. +func OwnerUID(v string) predicate.Posix { + return predicate.Posix(sql.FieldEQ(FieldOwnerUID, v)) +} + +// Permissions applies equality check predicate on the "permissions" field. It's identical to PermissionsEQ. +func Permissions(v string) predicate.Posix { + return predicate.Posix(sql.FieldEQ(FieldPermissions, v)) +} + +// Size applies equality check predicate on the "size" field. It's identical to SizeEQ. +func Size(v string) predicate.Posix { + return predicate.Posix(sql.FieldEQ(FieldSize, v)) +} + +// AtimeEQ applies the EQ predicate on the "atime" field. +func AtimeEQ(v string) predicate.Posix { + return predicate.Posix(sql.FieldEQ(FieldAtime, v)) +} + +// AtimeNEQ applies the NEQ predicate on the "atime" field. +func AtimeNEQ(v string) predicate.Posix { + return predicate.Posix(sql.FieldNEQ(FieldAtime, v)) +} + +// AtimeIn applies the In predicate on the "atime" field. +func AtimeIn(vs ...string) predicate.Posix { + return predicate.Posix(sql.FieldIn(FieldAtime, vs...)) +} + +// AtimeNotIn applies the NotIn predicate on the "atime" field. +func AtimeNotIn(vs ...string) predicate.Posix { + return predicate.Posix(sql.FieldNotIn(FieldAtime, vs...)) +} + +// AtimeGT applies the GT predicate on the "atime" field. +func AtimeGT(v string) predicate.Posix { + return predicate.Posix(sql.FieldGT(FieldAtime, v)) +} + +// AtimeGTE applies the GTE predicate on the "atime" field. +func AtimeGTE(v string) predicate.Posix { + return predicate.Posix(sql.FieldGTE(FieldAtime, v)) +} + +// AtimeLT applies the LT predicate on the "atime" field. +func AtimeLT(v string) predicate.Posix { + return predicate.Posix(sql.FieldLT(FieldAtime, v)) +} + +// AtimeLTE applies the LTE predicate on the "atime" field. +func AtimeLTE(v string) predicate.Posix { + return predicate.Posix(sql.FieldLTE(FieldAtime, v)) +} + +// AtimeContains applies the Contains predicate on the "atime" field. +func AtimeContains(v string) predicate.Posix { + return predicate.Posix(sql.FieldContains(FieldAtime, v)) +} + +// AtimeHasPrefix applies the HasPrefix predicate on the "atime" field. +func AtimeHasPrefix(v string) predicate.Posix { + return predicate.Posix(sql.FieldHasPrefix(FieldAtime, v)) +} + +// AtimeHasSuffix applies the HasSuffix predicate on the "atime" field. +func AtimeHasSuffix(v string) predicate.Posix { + return predicate.Posix(sql.FieldHasSuffix(FieldAtime, v)) +} + +// AtimeEqualFold applies the EqualFold predicate on the "atime" field. +func AtimeEqualFold(v string) predicate.Posix { + return predicate.Posix(sql.FieldEqualFold(FieldAtime, v)) +} + +// AtimeContainsFold applies the ContainsFold predicate on the "atime" field. +func AtimeContainsFold(v string) predicate.Posix { + return predicate.Posix(sql.FieldContainsFold(FieldAtime, v)) +} + +// CtimeEQ applies the EQ predicate on the "ctime" field. +func CtimeEQ(v string) predicate.Posix { + return predicate.Posix(sql.FieldEQ(FieldCtime, v)) +} + +// CtimeNEQ applies the NEQ predicate on the "ctime" field. +func CtimeNEQ(v string) predicate.Posix { + return predicate.Posix(sql.FieldNEQ(FieldCtime, v)) +} + +// CtimeIn applies the In predicate on the "ctime" field. +func CtimeIn(vs ...string) predicate.Posix { + return predicate.Posix(sql.FieldIn(FieldCtime, vs...)) +} + +// CtimeNotIn applies the NotIn predicate on the "ctime" field. +func CtimeNotIn(vs ...string) predicate.Posix { + return predicate.Posix(sql.FieldNotIn(FieldCtime, vs...)) +} + +// CtimeGT applies the GT predicate on the "ctime" field. +func CtimeGT(v string) predicate.Posix { + return predicate.Posix(sql.FieldGT(FieldCtime, v)) +} + +// CtimeGTE applies the GTE predicate on the "ctime" field. +func CtimeGTE(v string) predicate.Posix { + return predicate.Posix(sql.FieldGTE(FieldCtime, v)) +} + +// CtimeLT applies the LT predicate on the "ctime" field. +func CtimeLT(v string) predicate.Posix { + return predicate.Posix(sql.FieldLT(FieldCtime, v)) +} + +// CtimeLTE applies the LTE predicate on the "ctime" field. +func CtimeLTE(v string) predicate.Posix { + return predicate.Posix(sql.FieldLTE(FieldCtime, v)) +} + +// CtimeContains applies the Contains predicate on the "ctime" field. +func CtimeContains(v string) predicate.Posix { + return predicate.Posix(sql.FieldContains(FieldCtime, v)) +} + +// CtimeHasPrefix applies the HasPrefix predicate on the "ctime" field. +func CtimeHasPrefix(v string) predicate.Posix { + return predicate.Posix(sql.FieldHasPrefix(FieldCtime, v)) +} + +// CtimeHasSuffix applies the HasSuffix predicate on the "ctime" field. +func CtimeHasSuffix(v string) predicate.Posix { + return predicate.Posix(sql.FieldHasSuffix(FieldCtime, v)) +} + +// CtimeEqualFold applies the EqualFold predicate on the "ctime" field. +func CtimeEqualFold(v string) predicate.Posix { + return predicate.Posix(sql.FieldEqualFold(FieldCtime, v)) +} + +// CtimeContainsFold applies the ContainsFold predicate on the "ctime" field. +func CtimeContainsFold(v string) predicate.Posix { + return predicate.Posix(sql.FieldContainsFold(FieldCtime, v)) +} + +// CreationTimeEQ applies the EQ predicate on the "creation_time" field. +func CreationTimeEQ(v string) predicate.Posix { + return predicate.Posix(sql.FieldEQ(FieldCreationTime, v)) +} + +// CreationTimeNEQ applies the NEQ predicate on the "creation_time" field. +func CreationTimeNEQ(v string) predicate.Posix { + return predicate.Posix(sql.FieldNEQ(FieldCreationTime, v)) +} + +// CreationTimeIn applies the In predicate on the "creation_time" field. +func CreationTimeIn(vs ...string) predicate.Posix { + return predicate.Posix(sql.FieldIn(FieldCreationTime, vs...)) +} + +// CreationTimeNotIn applies the NotIn predicate on the "creation_time" field. +func CreationTimeNotIn(vs ...string) predicate.Posix { + return predicate.Posix(sql.FieldNotIn(FieldCreationTime, vs...)) +} + +// CreationTimeGT applies the GT predicate on the "creation_time" field. +func CreationTimeGT(v string) predicate.Posix { + return predicate.Posix(sql.FieldGT(FieldCreationTime, v)) +} + +// CreationTimeGTE applies the GTE predicate on the "creation_time" field. +func CreationTimeGTE(v string) predicate.Posix { + return predicate.Posix(sql.FieldGTE(FieldCreationTime, v)) +} + +// CreationTimeLT applies the LT predicate on the "creation_time" field. +func CreationTimeLT(v string) predicate.Posix { + return predicate.Posix(sql.FieldLT(FieldCreationTime, v)) +} + +// CreationTimeLTE applies the LTE predicate on the "creation_time" field. +func CreationTimeLTE(v string) predicate.Posix { + return predicate.Posix(sql.FieldLTE(FieldCreationTime, v)) +} + +// CreationTimeContains applies the Contains predicate on the "creation_time" field. +func CreationTimeContains(v string) predicate.Posix { + return predicate.Posix(sql.FieldContains(FieldCreationTime, v)) +} + +// CreationTimeHasPrefix applies the HasPrefix predicate on the "creation_time" field. +func CreationTimeHasPrefix(v string) predicate.Posix { + return predicate.Posix(sql.FieldHasPrefix(FieldCreationTime, v)) +} + +// CreationTimeHasSuffix applies the HasSuffix predicate on the "creation_time" field. +func CreationTimeHasSuffix(v string) predicate.Posix { + return predicate.Posix(sql.FieldHasSuffix(FieldCreationTime, v)) +} + +// CreationTimeEqualFold applies the EqualFold predicate on the "creation_time" field. +func CreationTimeEqualFold(v string) predicate.Posix { + return predicate.Posix(sql.FieldEqualFold(FieldCreationTime, v)) +} + +// CreationTimeContainsFold applies the ContainsFold predicate on the "creation_time" field. +func CreationTimeContainsFold(v string) predicate.Posix { + return predicate.Posix(sql.FieldContainsFold(FieldCreationTime, v)) +} + +// ExtendedAttributesEQ applies the EQ predicate on the "extended_attributes" field. +func ExtendedAttributesEQ(v string) predicate.Posix { + return predicate.Posix(sql.FieldEQ(FieldExtendedAttributes, v)) +} + +// ExtendedAttributesNEQ applies the NEQ predicate on the "extended_attributes" field. +func ExtendedAttributesNEQ(v string) predicate.Posix { + return predicate.Posix(sql.FieldNEQ(FieldExtendedAttributes, v)) +} + +// ExtendedAttributesIn applies the In predicate on the "extended_attributes" field. +func ExtendedAttributesIn(vs ...string) predicate.Posix { + return predicate.Posix(sql.FieldIn(FieldExtendedAttributes, vs...)) +} + +// ExtendedAttributesNotIn applies the NotIn predicate on the "extended_attributes" field. +func ExtendedAttributesNotIn(vs ...string) predicate.Posix { + return predicate.Posix(sql.FieldNotIn(FieldExtendedAttributes, vs...)) +} + +// ExtendedAttributesGT applies the GT predicate on the "extended_attributes" field. +func ExtendedAttributesGT(v string) predicate.Posix { + return predicate.Posix(sql.FieldGT(FieldExtendedAttributes, v)) +} + +// ExtendedAttributesGTE applies the GTE predicate on the "extended_attributes" field. +func ExtendedAttributesGTE(v string) predicate.Posix { + return predicate.Posix(sql.FieldGTE(FieldExtendedAttributes, v)) +} + +// ExtendedAttributesLT applies the LT predicate on the "extended_attributes" field. +func ExtendedAttributesLT(v string) predicate.Posix { + return predicate.Posix(sql.FieldLT(FieldExtendedAttributes, v)) +} + +// ExtendedAttributesLTE applies the LTE predicate on the "extended_attributes" field. +func ExtendedAttributesLTE(v string) predicate.Posix { + return predicate.Posix(sql.FieldLTE(FieldExtendedAttributes, v)) +} + +// ExtendedAttributesContains applies the Contains predicate on the "extended_attributes" field. +func ExtendedAttributesContains(v string) predicate.Posix { + return predicate.Posix(sql.FieldContains(FieldExtendedAttributes, v)) +} + +// ExtendedAttributesHasPrefix applies the HasPrefix predicate on the "extended_attributes" field. +func ExtendedAttributesHasPrefix(v string) predicate.Posix { + return predicate.Posix(sql.FieldHasPrefix(FieldExtendedAttributes, v)) +} + +// ExtendedAttributesHasSuffix applies the HasSuffix predicate on the "extended_attributes" field. +func ExtendedAttributesHasSuffix(v string) predicate.Posix { + return predicate.Posix(sql.FieldHasSuffix(FieldExtendedAttributes, v)) +} + +// ExtendedAttributesEqualFold applies the EqualFold predicate on the "extended_attributes" field. +func ExtendedAttributesEqualFold(v string) predicate.Posix { + return predicate.Posix(sql.FieldEqualFold(FieldExtendedAttributes, v)) +} + +// ExtendedAttributesContainsFold applies the ContainsFold predicate on the "extended_attributes" field. +func ExtendedAttributesContainsFold(v string) predicate.Posix { + return predicate.Posix(sql.FieldContainsFold(FieldExtendedAttributes, v)) +} + +// FileDeviceIDEQ applies the EQ predicate on the "file_device_id" field. +func FileDeviceIDEQ(v string) predicate.Posix { + return predicate.Posix(sql.FieldEQ(FieldFileDeviceID, v)) +} + +// FileDeviceIDNEQ applies the NEQ predicate on the "file_device_id" field. +func FileDeviceIDNEQ(v string) predicate.Posix { + return predicate.Posix(sql.FieldNEQ(FieldFileDeviceID, v)) +} + +// FileDeviceIDIn applies the In predicate on the "file_device_id" field. +func FileDeviceIDIn(vs ...string) predicate.Posix { + return predicate.Posix(sql.FieldIn(FieldFileDeviceID, vs...)) +} + +// FileDeviceIDNotIn applies the NotIn predicate on the "file_device_id" field. +func FileDeviceIDNotIn(vs ...string) predicate.Posix { + return predicate.Posix(sql.FieldNotIn(FieldFileDeviceID, vs...)) +} + +// FileDeviceIDGT applies the GT predicate on the "file_device_id" field. +func FileDeviceIDGT(v string) predicate.Posix { + return predicate.Posix(sql.FieldGT(FieldFileDeviceID, v)) +} + +// FileDeviceIDGTE applies the GTE predicate on the "file_device_id" field. +func FileDeviceIDGTE(v string) predicate.Posix { + return predicate.Posix(sql.FieldGTE(FieldFileDeviceID, v)) +} + +// FileDeviceIDLT applies the LT predicate on the "file_device_id" field. +func FileDeviceIDLT(v string) predicate.Posix { + return predicate.Posix(sql.FieldLT(FieldFileDeviceID, v)) +} + +// FileDeviceIDLTE applies the LTE predicate on the "file_device_id" field. +func FileDeviceIDLTE(v string) predicate.Posix { + return predicate.Posix(sql.FieldLTE(FieldFileDeviceID, v)) +} + +// FileDeviceIDContains applies the Contains predicate on the "file_device_id" field. +func FileDeviceIDContains(v string) predicate.Posix { + return predicate.Posix(sql.FieldContains(FieldFileDeviceID, v)) +} + +// FileDeviceIDHasPrefix applies the HasPrefix predicate on the "file_device_id" field. +func FileDeviceIDHasPrefix(v string) predicate.Posix { + return predicate.Posix(sql.FieldHasPrefix(FieldFileDeviceID, v)) +} + +// FileDeviceIDHasSuffix applies the HasSuffix predicate on the "file_device_id" field. +func FileDeviceIDHasSuffix(v string) predicate.Posix { + return predicate.Posix(sql.FieldHasSuffix(FieldFileDeviceID, v)) +} + +// FileDeviceIDEqualFold applies the EqualFold predicate on the "file_device_id" field. +func FileDeviceIDEqualFold(v string) predicate.Posix { + return predicate.Posix(sql.FieldEqualFold(FieldFileDeviceID, v)) +} + +// FileDeviceIDContainsFold applies the ContainsFold predicate on the "file_device_id" field. +func FileDeviceIDContainsFold(v string) predicate.Posix { + return predicate.Posix(sql.FieldContainsFold(FieldFileDeviceID, v)) +} + +// FileFlagsEQ applies the EQ predicate on the "file_flags" field. +func FileFlagsEQ(v string) predicate.Posix { + return predicate.Posix(sql.FieldEQ(FieldFileFlags, v)) +} + +// FileFlagsNEQ applies the NEQ predicate on the "file_flags" field. +func FileFlagsNEQ(v string) predicate.Posix { + return predicate.Posix(sql.FieldNEQ(FieldFileFlags, v)) +} + +// FileFlagsIn applies the In predicate on the "file_flags" field. +func FileFlagsIn(vs ...string) predicate.Posix { + return predicate.Posix(sql.FieldIn(FieldFileFlags, vs...)) +} + +// FileFlagsNotIn applies the NotIn predicate on the "file_flags" field. +func FileFlagsNotIn(vs ...string) predicate.Posix { + return predicate.Posix(sql.FieldNotIn(FieldFileFlags, vs...)) +} + +// FileFlagsGT applies the GT predicate on the "file_flags" field. +func FileFlagsGT(v string) predicate.Posix { + return predicate.Posix(sql.FieldGT(FieldFileFlags, v)) +} + +// FileFlagsGTE applies the GTE predicate on the "file_flags" field. +func FileFlagsGTE(v string) predicate.Posix { + return predicate.Posix(sql.FieldGTE(FieldFileFlags, v)) +} + +// FileFlagsLT applies the LT predicate on the "file_flags" field. +func FileFlagsLT(v string) predicate.Posix { + return predicate.Posix(sql.FieldLT(FieldFileFlags, v)) +} + +// FileFlagsLTE applies the LTE predicate on the "file_flags" field. +func FileFlagsLTE(v string) predicate.Posix { + return predicate.Posix(sql.FieldLTE(FieldFileFlags, v)) +} + +// FileFlagsContains applies the Contains predicate on the "file_flags" field. +func FileFlagsContains(v string) predicate.Posix { + return predicate.Posix(sql.FieldContains(FieldFileFlags, v)) +} + +// FileFlagsHasPrefix applies the HasPrefix predicate on the "file_flags" field. +func FileFlagsHasPrefix(v string) predicate.Posix { + return predicate.Posix(sql.FieldHasPrefix(FieldFileFlags, v)) +} + +// FileFlagsHasSuffix applies the HasSuffix predicate on the "file_flags" field. +func FileFlagsHasSuffix(v string) predicate.Posix { + return predicate.Posix(sql.FieldHasSuffix(FieldFileFlags, v)) +} + +// FileFlagsEqualFold applies the EqualFold predicate on the "file_flags" field. +func FileFlagsEqualFold(v string) predicate.Posix { + return predicate.Posix(sql.FieldEqualFold(FieldFileFlags, v)) +} + +// FileFlagsContainsFold applies the ContainsFold predicate on the "file_flags" field. +func FileFlagsContainsFold(v string) predicate.Posix { + return predicate.Posix(sql.FieldContainsFold(FieldFileFlags, v)) +} + +// FileInodeEQ applies the EQ predicate on the "file_inode" field. +func FileInodeEQ(v string) predicate.Posix { + return predicate.Posix(sql.FieldEQ(FieldFileInode, v)) +} + +// FileInodeNEQ applies the NEQ predicate on the "file_inode" field. +func FileInodeNEQ(v string) predicate.Posix { + return predicate.Posix(sql.FieldNEQ(FieldFileInode, v)) +} + +// FileInodeIn applies the In predicate on the "file_inode" field. +func FileInodeIn(vs ...string) predicate.Posix { + return predicate.Posix(sql.FieldIn(FieldFileInode, vs...)) +} + +// FileInodeNotIn applies the NotIn predicate on the "file_inode" field. +func FileInodeNotIn(vs ...string) predicate.Posix { + return predicate.Posix(sql.FieldNotIn(FieldFileInode, vs...)) +} + +// FileInodeGT applies the GT predicate on the "file_inode" field. +func FileInodeGT(v string) predicate.Posix { + return predicate.Posix(sql.FieldGT(FieldFileInode, v)) +} + +// FileInodeGTE applies the GTE predicate on the "file_inode" field. +func FileInodeGTE(v string) predicate.Posix { + return predicate.Posix(sql.FieldGTE(FieldFileInode, v)) +} + +// FileInodeLT applies the LT predicate on the "file_inode" field. +func FileInodeLT(v string) predicate.Posix { + return predicate.Posix(sql.FieldLT(FieldFileInode, v)) +} + +// FileInodeLTE applies the LTE predicate on the "file_inode" field. +func FileInodeLTE(v string) predicate.Posix { + return predicate.Posix(sql.FieldLTE(FieldFileInode, v)) +} + +// FileInodeContains applies the Contains predicate on the "file_inode" field. +func FileInodeContains(v string) predicate.Posix { + return predicate.Posix(sql.FieldContains(FieldFileInode, v)) +} + +// FileInodeHasPrefix applies the HasPrefix predicate on the "file_inode" field. +func FileInodeHasPrefix(v string) predicate.Posix { + return predicate.Posix(sql.FieldHasPrefix(FieldFileInode, v)) +} + +// FileInodeHasSuffix applies the HasSuffix predicate on the "file_inode" field. +func FileInodeHasSuffix(v string) predicate.Posix { + return predicate.Posix(sql.FieldHasSuffix(FieldFileInode, v)) +} + +// FileInodeEqualFold applies the EqualFold predicate on the "file_inode" field. +func FileInodeEqualFold(v string) predicate.Posix { + return predicate.Posix(sql.FieldEqualFold(FieldFileInode, v)) +} + +// FileInodeContainsFold applies the ContainsFold predicate on the "file_inode" field. +func FileInodeContainsFold(v string) predicate.Posix { + return predicate.Posix(sql.FieldContainsFold(FieldFileInode, v)) +} + +// FileSystemIDEQ applies the EQ predicate on the "file_system_id" field. +func FileSystemIDEQ(v string) predicate.Posix { + return predicate.Posix(sql.FieldEQ(FieldFileSystemID, v)) +} + +// FileSystemIDNEQ applies the NEQ predicate on the "file_system_id" field. +func FileSystemIDNEQ(v string) predicate.Posix { + return predicate.Posix(sql.FieldNEQ(FieldFileSystemID, v)) +} + +// FileSystemIDIn applies the In predicate on the "file_system_id" field. +func FileSystemIDIn(vs ...string) predicate.Posix { + return predicate.Posix(sql.FieldIn(FieldFileSystemID, vs...)) +} + +// FileSystemIDNotIn applies the NotIn predicate on the "file_system_id" field. +func FileSystemIDNotIn(vs ...string) predicate.Posix { + return predicate.Posix(sql.FieldNotIn(FieldFileSystemID, vs...)) +} + +// FileSystemIDGT applies the GT predicate on the "file_system_id" field. +func FileSystemIDGT(v string) predicate.Posix { + return predicate.Posix(sql.FieldGT(FieldFileSystemID, v)) +} + +// FileSystemIDGTE applies the GTE predicate on the "file_system_id" field. +func FileSystemIDGTE(v string) predicate.Posix { + return predicate.Posix(sql.FieldGTE(FieldFileSystemID, v)) +} + +// FileSystemIDLT applies the LT predicate on the "file_system_id" field. +func FileSystemIDLT(v string) predicate.Posix { + return predicate.Posix(sql.FieldLT(FieldFileSystemID, v)) +} + +// FileSystemIDLTE applies the LTE predicate on the "file_system_id" field. +func FileSystemIDLTE(v string) predicate.Posix { + return predicate.Posix(sql.FieldLTE(FieldFileSystemID, v)) +} + +// FileSystemIDContains applies the Contains predicate on the "file_system_id" field. +func FileSystemIDContains(v string) predicate.Posix { + return predicate.Posix(sql.FieldContains(FieldFileSystemID, v)) +} + +// FileSystemIDHasPrefix applies the HasPrefix predicate on the "file_system_id" field. +func FileSystemIDHasPrefix(v string) predicate.Posix { + return predicate.Posix(sql.FieldHasPrefix(FieldFileSystemID, v)) +} + +// FileSystemIDHasSuffix applies the HasSuffix predicate on the "file_system_id" field. +func FileSystemIDHasSuffix(v string) predicate.Posix { + return predicate.Posix(sql.FieldHasSuffix(FieldFileSystemID, v)) +} + +// FileSystemIDEqualFold applies the EqualFold predicate on the "file_system_id" field. +func FileSystemIDEqualFold(v string) predicate.Posix { + return predicate.Posix(sql.FieldEqualFold(FieldFileSystemID, v)) +} + +// FileSystemIDContainsFold applies the ContainsFold predicate on the "file_system_id" field. +func FileSystemIDContainsFold(v string) predicate.Posix { + return predicate.Posix(sql.FieldContainsFold(FieldFileSystemID, v)) +} + +// FileTypeEQ applies the EQ predicate on the "file_type" field. +func FileTypeEQ(v string) predicate.Posix { + return predicate.Posix(sql.FieldEQ(FieldFileType, v)) +} + +// FileTypeNEQ applies the NEQ predicate on the "file_type" field. +func FileTypeNEQ(v string) predicate.Posix { + return predicate.Posix(sql.FieldNEQ(FieldFileType, v)) +} + +// FileTypeIn applies the In predicate on the "file_type" field. +func FileTypeIn(vs ...string) predicate.Posix { + return predicate.Posix(sql.FieldIn(FieldFileType, vs...)) +} + +// FileTypeNotIn applies the NotIn predicate on the "file_type" field. +func FileTypeNotIn(vs ...string) predicate.Posix { + return predicate.Posix(sql.FieldNotIn(FieldFileType, vs...)) +} + +// FileTypeGT applies the GT predicate on the "file_type" field. +func FileTypeGT(v string) predicate.Posix { + return predicate.Posix(sql.FieldGT(FieldFileType, v)) +} + +// FileTypeGTE applies the GTE predicate on the "file_type" field. +func FileTypeGTE(v string) predicate.Posix { + return predicate.Posix(sql.FieldGTE(FieldFileType, v)) +} + +// FileTypeLT applies the LT predicate on the "file_type" field. +func FileTypeLT(v string) predicate.Posix { + return predicate.Posix(sql.FieldLT(FieldFileType, v)) +} + +// FileTypeLTE applies the LTE predicate on the "file_type" field. +func FileTypeLTE(v string) predicate.Posix { + return predicate.Posix(sql.FieldLTE(FieldFileType, v)) +} + +// FileTypeContains applies the Contains predicate on the "file_type" field. +func FileTypeContains(v string) predicate.Posix { + return predicate.Posix(sql.FieldContains(FieldFileType, v)) +} + +// FileTypeHasPrefix applies the HasPrefix predicate on the "file_type" field. +func FileTypeHasPrefix(v string) predicate.Posix { + return predicate.Posix(sql.FieldHasPrefix(FieldFileType, v)) +} + +// FileTypeHasSuffix applies the HasSuffix predicate on the "file_type" field. +func FileTypeHasSuffix(v string) predicate.Posix { + return predicate.Posix(sql.FieldHasSuffix(FieldFileType, v)) +} + +// FileTypeEqualFold applies the EqualFold predicate on the "file_type" field. +func FileTypeEqualFold(v string) predicate.Posix { + return predicate.Posix(sql.FieldEqualFold(FieldFileType, v)) +} + +// FileTypeContainsFold applies the ContainsFold predicate on the "file_type" field. +func FileTypeContainsFold(v string) predicate.Posix { + return predicate.Posix(sql.FieldContainsFold(FieldFileType, v)) +} + +// HardLinkCountEQ applies the EQ predicate on the "hard_link_count" field. +func HardLinkCountEQ(v string) predicate.Posix { + return predicate.Posix(sql.FieldEQ(FieldHardLinkCount, v)) +} + +// HardLinkCountNEQ applies the NEQ predicate on the "hard_link_count" field. +func HardLinkCountNEQ(v string) predicate.Posix { + return predicate.Posix(sql.FieldNEQ(FieldHardLinkCount, v)) +} + +// HardLinkCountIn applies the In predicate on the "hard_link_count" field. +func HardLinkCountIn(vs ...string) predicate.Posix { + return predicate.Posix(sql.FieldIn(FieldHardLinkCount, vs...)) +} + +// HardLinkCountNotIn applies the NotIn predicate on the "hard_link_count" field. +func HardLinkCountNotIn(vs ...string) predicate.Posix { + return predicate.Posix(sql.FieldNotIn(FieldHardLinkCount, vs...)) +} + +// HardLinkCountGT applies the GT predicate on the "hard_link_count" field. +func HardLinkCountGT(v string) predicate.Posix { + return predicate.Posix(sql.FieldGT(FieldHardLinkCount, v)) +} + +// HardLinkCountGTE applies the GTE predicate on the "hard_link_count" field. +func HardLinkCountGTE(v string) predicate.Posix { + return predicate.Posix(sql.FieldGTE(FieldHardLinkCount, v)) +} + +// HardLinkCountLT applies the LT predicate on the "hard_link_count" field. +func HardLinkCountLT(v string) predicate.Posix { + return predicate.Posix(sql.FieldLT(FieldHardLinkCount, v)) +} + +// HardLinkCountLTE applies the LTE predicate on the "hard_link_count" field. +func HardLinkCountLTE(v string) predicate.Posix { + return predicate.Posix(sql.FieldLTE(FieldHardLinkCount, v)) +} + +// HardLinkCountContains applies the Contains predicate on the "hard_link_count" field. +func HardLinkCountContains(v string) predicate.Posix { + return predicate.Posix(sql.FieldContains(FieldHardLinkCount, v)) +} + +// HardLinkCountHasPrefix applies the HasPrefix predicate on the "hard_link_count" field. +func HardLinkCountHasPrefix(v string) predicate.Posix { + return predicate.Posix(sql.FieldHasPrefix(FieldHardLinkCount, v)) +} + +// HardLinkCountHasSuffix applies the HasSuffix predicate on the "hard_link_count" field. +func HardLinkCountHasSuffix(v string) predicate.Posix { + return predicate.Posix(sql.FieldHasSuffix(FieldHardLinkCount, v)) +} + +// HardLinkCountEqualFold applies the EqualFold predicate on the "hard_link_count" field. +func HardLinkCountEqualFold(v string) predicate.Posix { + return predicate.Posix(sql.FieldEqualFold(FieldHardLinkCount, v)) +} + +// HardLinkCountContainsFold applies the ContainsFold predicate on the "hard_link_count" field. +func HardLinkCountContainsFold(v string) predicate.Posix { + return predicate.Posix(sql.FieldContainsFold(FieldHardLinkCount, v)) +} + +// MtimeEQ applies the EQ predicate on the "mtime" field. +func MtimeEQ(v string) predicate.Posix { + return predicate.Posix(sql.FieldEQ(FieldMtime, v)) +} + +// MtimeNEQ applies the NEQ predicate on the "mtime" field. +func MtimeNEQ(v string) predicate.Posix { + return predicate.Posix(sql.FieldNEQ(FieldMtime, v)) +} + +// MtimeIn applies the In predicate on the "mtime" field. +func MtimeIn(vs ...string) predicate.Posix { + return predicate.Posix(sql.FieldIn(FieldMtime, vs...)) +} + +// MtimeNotIn applies the NotIn predicate on the "mtime" field. +func MtimeNotIn(vs ...string) predicate.Posix { + return predicate.Posix(sql.FieldNotIn(FieldMtime, vs...)) +} + +// MtimeGT applies the GT predicate on the "mtime" field. +func MtimeGT(v string) predicate.Posix { + return predicate.Posix(sql.FieldGT(FieldMtime, v)) +} + +// MtimeGTE applies the GTE predicate on the "mtime" field. +func MtimeGTE(v string) predicate.Posix { + return predicate.Posix(sql.FieldGTE(FieldMtime, v)) +} + +// MtimeLT applies the LT predicate on the "mtime" field. +func MtimeLT(v string) predicate.Posix { + return predicate.Posix(sql.FieldLT(FieldMtime, v)) +} + +// MtimeLTE applies the LTE predicate on the "mtime" field. +func MtimeLTE(v string) predicate.Posix { + return predicate.Posix(sql.FieldLTE(FieldMtime, v)) +} + +// MtimeContains applies the Contains predicate on the "mtime" field. +func MtimeContains(v string) predicate.Posix { + return predicate.Posix(sql.FieldContains(FieldMtime, v)) +} + +// MtimeHasPrefix applies the HasPrefix predicate on the "mtime" field. +func MtimeHasPrefix(v string) predicate.Posix { + return predicate.Posix(sql.FieldHasPrefix(FieldMtime, v)) +} + +// MtimeHasSuffix applies the HasSuffix predicate on the "mtime" field. +func MtimeHasSuffix(v string) predicate.Posix { + return predicate.Posix(sql.FieldHasSuffix(FieldMtime, v)) +} + +// MtimeEqualFold applies the EqualFold predicate on the "mtime" field. +func MtimeEqualFold(v string) predicate.Posix { + return predicate.Posix(sql.FieldEqualFold(FieldMtime, v)) +} + +// MtimeContainsFold applies the ContainsFold predicate on the "mtime" field. +func MtimeContainsFold(v string) predicate.Posix { + return predicate.Posix(sql.FieldContainsFold(FieldMtime, v)) +} + +// MetadataCtimeEQ applies the EQ predicate on the "metadata_ctime" field. +func MetadataCtimeEQ(v string) predicate.Posix { + return predicate.Posix(sql.FieldEQ(FieldMetadataCtime, v)) +} + +// MetadataCtimeNEQ applies the NEQ predicate on the "metadata_ctime" field. +func MetadataCtimeNEQ(v string) predicate.Posix { + return predicate.Posix(sql.FieldNEQ(FieldMetadataCtime, v)) +} + +// MetadataCtimeIn applies the In predicate on the "metadata_ctime" field. +func MetadataCtimeIn(vs ...string) predicate.Posix { + return predicate.Posix(sql.FieldIn(FieldMetadataCtime, vs...)) +} + +// MetadataCtimeNotIn applies the NotIn predicate on the "metadata_ctime" field. +func MetadataCtimeNotIn(vs ...string) predicate.Posix { + return predicate.Posix(sql.FieldNotIn(FieldMetadataCtime, vs...)) +} + +// MetadataCtimeGT applies the GT predicate on the "metadata_ctime" field. +func MetadataCtimeGT(v string) predicate.Posix { + return predicate.Posix(sql.FieldGT(FieldMetadataCtime, v)) +} + +// MetadataCtimeGTE applies the GTE predicate on the "metadata_ctime" field. +func MetadataCtimeGTE(v string) predicate.Posix { + return predicate.Posix(sql.FieldGTE(FieldMetadataCtime, v)) +} + +// MetadataCtimeLT applies the LT predicate on the "metadata_ctime" field. +func MetadataCtimeLT(v string) predicate.Posix { + return predicate.Posix(sql.FieldLT(FieldMetadataCtime, v)) +} + +// MetadataCtimeLTE applies the LTE predicate on the "metadata_ctime" field. +func MetadataCtimeLTE(v string) predicate.Posix { + return predicate.Posix(sql.FieldLTE(FieldMetadataCtime, v)) +} + +// MetadataCtimeContains applies the Contains predicate on the "metadata_ctime" field. +func MetadataCtimeContains(v string) predicate.Posix { + return predicate.Posix(sql.FieldContains(FieldMetadataCtime, v)) +} + +// MetadataCtimeHasPrefix applies the HasPrefix predicate on the "metadata_ctime" field. +func MetadataCtimeHasPrefix(v string) predicate.Posix { + return predicate.Posix(sql.FieldHasPrefix(FieldMetadataCtime, v)) +} + +// MetadataCtimeHasSuffix applies the HasSuffix predicate on the "metadata_ctime" field. +func MetadataCtimeHasSuffix(v string) predicate.Posix { + return predicate.Posix(sql.FieldHasSuffix(FieldMetadataCtime, v)) +} + +// MetadataCtimeEqualFold applies the EqualFold predicate on the "metadata_ctime" field. +func MetadataCtimeEqualFold(v string) predicate.Posix { + return predicate.Posix(sql.FieldEqualFold(FieldMetadataCtime, v)) +} + +// MetadataCtimeContainsFold applies the ContainsFold predicate on the "metadata_ctime" field. +func MetadataCtimeContainsFold(v string) predicate.Posix { + return predicate.Posix(sql.FieldContainsFold(FieldMetadataCtime, v)) +} + +// OwnerGidEQ applies the EQ predicate on the "owner_gid" field. +func OwnerGidEQ(v string) predicate.Posix { + return predicate.Posix(sql.FieldEQ(FieldOwnerGid, v)) +} + +// OwnerGidNEQ applies the NEQ predicate on the "owner_gid" field. +func OwnerGidNEQ(v string) predicate.Posix { + return predicate.Posix(sql.FieldNEQ(FieldOwnerGid, v)) +} + +// OwnerGidIn applies the In predicate on the "owner_gid" field. +func OwnerGidIn(vs ...string) predicate.Posix { + return predicate.Posix(sql.FieldIn(FieldOwnerGid, vs...)) +} + +// OwnerGidNotIn applies the NotIn predicate on the "owner_gid" field. +func OwnerGidNotIn(vs ...string) predicate.Posix { + return predicate.Posix(sql.FieldNotIn(FieldOwnerGid, vs...)) +} + +// OwnerGidGT applies the GT predicate on the "owner_gid" field. +func OwnerGidGT(v string) predicate.Posix { + return predicate.Posix(sql.FieldGT(FieldOwnerGid, v)) +} + +// OwnerGidGTE applies the GTE predicate on the "owner_gid" field. +func OwnerGidGTE(v string) predicate.Posix { + return predicate.Posix(sql.FieldGTE(FieldOwnerGid, v)) +} + +// OwnerGidLT applies the LT predicate on the "owner_gid" field. +func OwnerGidLT(v string) predicate.Posix { + return predicate.Posix(sql.FieldLT(FieldOwnerGid, v)) +} + +// OwnerGidLTE applies the LTE predicate on the "owner_gid" field. +func OwnerGidLTE(v string) predicate.Posix { + return predicate.Posix(sql.FieldLTE(FieldOwnerGid, v)) +} + +// OwnerGidContains applies the Contains predicate on the "owner_gid" field. +func OwnerGidContains(v string) predicate.Posix { + return predicate.Posix(sql.FieldContains(FieldOwnerGid, v)) +} + +// OwnerGidHasPrefix applies the HasPrefix predicate on the "owner_gid" field. +func OwnerGidHasPrefix(v string) predicate.Posix { + return predicate.Posix(sql.FieldHasPrefix(FieldOwnerGid, v)) +} + +// OwnerGidHasSuffix applies the HasSuffix predicate on the "owner_gid" field. +func OwnerGidHasSuffix(v string) predicate.Posix { + return predicate.Posix(sql.FieldHasSuffix(FieldOwnerGid, v)) +} + +// OwnerGidEqualFold applies the EqualFold predicate on the "owner_gid" field. +func OwnerGidEqualFold(v string) predicate.Posix { + return predicate.Posix(sql.FieldEqualFold(FieldOwnerGid, v)) +} + +// OwnerGidContainsFold applies the ContainsFold predicate on the "owner_gid" field. +func OwnerGidContainsFold(v string) predicate.Posix { + return predicate.Posix(sql.FieldContainsFold(FieldOwnerGid, v)) +} + +// OwnerUIDEQ applies the EQ predicate on the "owner_uid" field. +func OwnerUIDEQ(v string) predicate.Posix { + return predicate.Posix(sql.FieldEQ(FieldOwnerUID, v)) +} + +// OwnerUIDNEQ applies the NEQ predicate on the "owner_uid" field. +func OwnerUIDNEQ(v string) predicate.Posix { + return predicate.Posix(sql.FieldNEQ(FieldOwnerUID, v)) +} + +// OwnerUIDIn applies the In predicate on the "owner_uid" field. +func OwnerUIDIn(vs ...string) predicate.Posix { + return predicate.Posix(sql.FieldIn(FieldOwnerUID, vs...)) +} + +// OwnerUIDNotIn applies the NotIn predicate on the "owner_uid" field. +func OwnerUIDNotIn(vs ...string) predicate.Posix { + return predicate.Posix(sql.FieldNotIn(FieldOwnerUID, vs...)) +} + +// OwnerUIDGT applies the GT predicate on the "owner_uid" field. +func OwnerUIDGT(v string) predicate.Posix { + return predicate.Posix(sql.FieldGT(FieldOwnerUID, v)) +} + +// OwnerUIDGTE applies the GTE predicate on the "owner_uid" field. +func OwnerUIDGTE(v string) predicate.Posix { + return predicate.Posix(sql.FieldGTE(FieldOwnerUID, v)) +} + +// OwnerUIDLT applies the LT predicate on the "owner_uid" field. +func OwnerUIDLT(v string) predicate.Posix { + return predicate.Posix(sql.FieldLT(FieldOwnerUID, v)) +} + +// OwnerUIDLTE applies the LTE predicate on the "owner_uid" field. +func OwnerUIDLTE(v string) predicate.Posix { + return predicate.Posix(sql.FieldLTE(FieldOwnerUID, v)) +} + +// OwnerUIDContains applies the Contains predicate on the "owner_uid" field. +func OwnerUIDContains(v string) predicate.Posix { + return predicate.Posix(sql.FieldContains(FieldOwnerUID, v)) +} + +// OwnerUIDHasPrefix applies the HasPrefix predicate on the "owner_uid" field. +func OwnerUIDHasPrefix(v string) predicate.Posix { + return predicate.Posix(sql.FieldHasPrefix(FieldOwnerUID, v)) +} + +// OwnerUIDHasSuffix applies the HasSuffix predicate on the "owner_uid" field. +func OwnerUIDHasSuffix(v string) predicate.Posix { + return predicate.Posix(sql.FieldHasSuffix(FieldOwnerUID, v)) +} + +// OwnerUIDEqualFold applies the EqualFold predicate on the "owner_uid" field. +func OwnerUIDEqualFold(v string) predicate.Posix { + return predicate.Posix(sql.FieldEqualFold(FieldOwnerUID, v)) +} + +// OwnerUIDContainsFold applies the ContainsFold predicate on the "owner_uid" field. +func OwnerUIDContainsFold(v string) predicate.Posix { + return predicate.Posix(sql.FieldContainsFold(FieldOwnerUID, v)) +} + +// PermissionsEQ applies the EQ predicate on the "permissions" field. +func PermissionsEQ(v string) predicate.Posix { + return predicate.Posix(sql.FieldEQ(FieldPermissions, v)) +} + +// PermissionsNEQ applies the NEQ predicate on the "permissions" field. +func PermissionsNEQ(v string) predicate.Posix { + return predicate.Posix(sql.FieldNEQ(FieldPermissions, v)) +} + +// PermissionsIn applies the In predicate on the "permissions" field. +func PermissionsIn(vs ...string) predicate.Posix { + return predicate.Posix(sql.FieldIn(FieldPermissions, vs...)) +} + +// PermissionsNotIn applies the NotIn predicate on the "permissions" field. +func PermissionsNotIn(vs ...string) predicate.Posix { + return predicate.Posix(sql.FieldNotIn(FieldPermissions, vs...)) +} + +// PermissionsGT applies the GT predicate on the "permissions" field. +func PermissionsGT(v string) predicate.Posix { + return predicate.Posix(sql.FieldGT(FieldPermissions, v)) +} + +// PermissionsGTE applies the GTE predicate on the "permissions" field. +func PermissionsGTE(v string) predicate.Posix { + return predicate.Posix(sql.FieldGTE(FieldPermissions, v)) +} + +// PermissionsLT applies the LT predicate on the "permissions" field. +func PermissionsLT(v string) predicate.Posix { + return predicate.Posix(sql.FieldLT(FieldPermissions, v)) +} + +// PermissionsLTE applies the LTE predicate on the "permissions" field. +func PermissionsLTE(v string) predicate.Posix { + return predicate.Posix(sql.FieldLTE(FieldPermissions, v)) +} + +// PermissionsContains applies the Contains predicate on the "permissions" field. +func PermissionsContains(v string) predicate.Posix { + return predicate.Posix(sql.FieldContains(FieldPermissions, v)) +} + +// PermissionsHasPrefix applies the HasPrefix predicate on the "permissions" field. +func PermissionsHasPrefix(v string) predicate.Posix { + return predicate.Posix(sql.FieldHasPrefix(FieldPermissions, v)) +} + +// PermissionsHasSuffix applies the HasSuffix predicate on the "permissions" field. +func PermissionsHasSuffix(v string) predicate.Posix { + return predicate.Posix(sql.FieldHasSuffix(FieldPermissions, v)) +} + +// PermissionsEqualFold applies the EqualFold predicate on the "permissions" field. +func PermissionsEqualFold(v string) predicate.Posix { + return predicate.Posix(sql.FieldEqualFold(FieldPermissions, v)) +} + +// PermissionsContainsFold applies the ContainsFold predicate on the "permissions" field. +func PermissionsContainsFold(v string) predicate.Posix { + return predicate.Posix(sql.FieldContainsFold(FieldPermissions, v)) +} + +// SizeEQ applies the EQ predicate on the "size" field. +func SizeEQ(v string) predicate.Posix { + return predicate.Posix(sql.FieldEQ(FieldSize, v)) +} + +// SizeNEQ applies the NEQ predicate on the "size" field. +func SizeNEQ(v string) predicate.Posix { + return predicate.Posix(sql.FieldNEQ(FieldSize, v)) +} + +// SizeIn applies the In predicate on the "size" field. +func SizeIn(vs ...string) predicate.Posix { + return predicate.Posix(sql.FieldIn(FieldSize, vs...)) +} + +// SizeNotIn applies the NotIn predicate on the "size" field. +func SizeNotIn(vs ...string) predicate.Posix { + return predicate.Posix(sql.FieldNotIn(FieldSize, vs...)) +} + +// SizeGT applies the GT predicate on the "size" field. +func SizeGT(v string) predicate.Posix { + return predicate.Posix(sql.FieldGT(FieldSize, v)) +} + +// SizeGTE applies the GTE predicate on the "size" field. +func SizeGTE(v string) predicate.Posix { + return predicate.Posix(sql.FieldGTE(FieldSize, v)) +} + +// SizeLT applies the LT predicate on the "size" field. +func SizeLT(v string) predicate.Posix { + return predicate.Posix(sql.FieldLT(FieldSize, v)) +} + +// SizeLTE applies the LTE predicate on the "size" field. +func SizeLTE(v string) predicate.Posix { + return predicate.Posix(sql.FieldLTE(FieldSize, v)) +} + +// SizeContains applies the Contains predicate on the "size" field. +func SizeContains(v string) predicate.Posix { + return predicate.Posix(sql.FieldContains(FieldSize, v)) +} + +// SizeHasPrefix applies the HasPrefix predicate on the "size" field. +func SizeHasPrefix(v string) predicate.Posix { + return predicate.Posix(sql.FieldHasPrefix(FieldSize, v)) +} + +// SizeHasSuffix applies the HasSuffix predicate on the "size" field. +func SizeHasSuffix(v string) predicate.Posix { + return predicate.Posix(sql.FieldHasSuffix(FieldSize, v)) +} + +// SizeEqualFold applies the EqualFold predicate on the "size" field. +func SizeEqualFold(v string) predicate.Posix { + return predicate.Posix(sql.FieldEqualFold(FieldSize, v)) +} + +// SizeContainsFold applies the ContainsFold predicate on the "size" field. +func SizeContainsFold(v string) predicate.Posix { + return predicate.Posix(sql.FieldContainsFold(FieldSize, v)) +} + +// HasMapping applies the HasEdge predicate on the "mapping" edge. +func HasMapping() predicate.Posix { + return predicate.Posix(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, MappingTable, MappingColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasMappingWith applies the HasEdge predicate on the "mapping" edge with a given conditions (other predicates). +func HasMappingWith(preds ...predicate.Mapping) predicate.Posix { + return predicate.Posix(func(s *sql.Selector) { + step := newMappingStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.Posix) predicate.Posix { + return predicate.Posix(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.Posix) predicate.Posix { + return predicate.Posix(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.Posix) predicate.Posix { + return predicate.Posix(sql.NotPredicates(p)) +} diff --git a/ent/posix_create.go b/ent/posix_create.go new file mode 100644 index 00000000..88b7695d --- /dev/null +++ b/ent/posix_create.go @@ -0,0 +1,410 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/in-toto/archivista/ent/mapping" + "github.com/in-toto/archivista/ent/posix" +) + +// PosixCreate is the builder for creating a Posix entity. +type PosixCreate struct { + config + mutation *PosixMutation + hooks []Hook +} + +// SetAtime sets the "atime" field. +func (pc *PosixCreate) SetAtime(s string) *PosixCreate { + pc.mutation.SetAtime(s) + return pc +} + +// SetCtime sets the "ctime" field. +func (pc *PosixCreate) SetCtime(s string) *PosixCreate { + pc.mutation.SetCtime(s) + return pc +} + +// SetCreationTime sets the "creation_time" field. +func (pc *PosixCreate) SetCreationTime(s string) *PosixCreate { + pc.mutation.SetCreationTime(s) + return pc +} + +// SetExtendedAttributes sets the "extended_attributes" field. +func (pc *PosixCreate) SetExtendedAttributes(s string) *PosixCreate { + pc.mutation.SetExtendedAttributes(s) + return pc +} + +// SetFileDeviceID sets the "file_device_id" field. +func (pc *PosixCreate) SetFileDeviceID(s string) *PosixCreate { + pc.mutation.SetFileDeviceID(s) + return pc +} + +// SetFileFlags sets the "file_flags" field. +func (pc *PosixCreate) SetFileFlags(s string) *PosixCreate { + pc.mutation.SetFileFlags(s) + return pc +} + +// SetFileInode sets the "file_inode" field. +func (pc *PosixCreate) SetFileInode(s string) *PosixCreate { + pc.mutation.SetFileInode(s) + return pc +} + +// SetFileSystemID sets the "file_system_id" field. +func (pc *PosixCreate) SetFileSystemID(s string) *PosixCreate { + pc.mutation.SetFileSystemID(s) + return pc +} + +// SetFileType sets the "file_type" field. +func (pc *PosixCreate) SetFileType(s string) *PosixCreate { + pc.mutation.SetFileType(s) + return pc +} + +// SetHardLinkCount sets the "hard_link_count" field. +func (pc *PosixCreate) SetHardLinkCount(s string) *PosixCreate { + pc.mutation.SetHardLinkCount(s) + return pc +} + +// SetMtime sets the "mtime" field. +func (pc *PosixCreate) SetMtime(s string) *PosixCreate { + pc.mutation.SetMtime(s) + return pc +} + +// SetMetadataCtime sets the "metadata_ctime" field. +func (pc *PosixCreate) SetMetadataCtime(s string) *PosixCreate { + pc.mutation.SetMetadataCtime(s) + return pc +} + +// SetOwnerGid sets the "owner_gid" field. +func (pc *PosixCreate) SetOwnerGid(s string) *PosixCreate { + pc.mutation.SetOwnerGid(s) + return pc +} + +// SetOwnerUID sets the "owner_uid" field. +func (pc *PosixCreate) SetOwnerUID(s string) *PosixCreate { + pc.mutation.SetOwnerUID(s) + return pc +} + +// SetPermissions sets the "permissions" field. +func (pc *PosixCreate) SetPermissions(s string) *PosixCreate { + pc.mutation.SetPermissions(s) + return pc +} + +// SetSize sets the "size" field. +func (pc *PosixCreate) SetSize(s string) *PosixCreate { + pc.mutation.SetSize(s) + return pc +} + +// SetMappingID sets the "mapping" edge to the Mapping entity by ID. +func (pc *PosixCreate) SetMappingID(id int) *PosixCreate { + pc.mutation.SetMappingID(id) + return pc +} + +// SetMapping sets the "mapping" edge to the Mapping entity. +func (pc *PosixCreate) SetMapping(m *Mapping) *PosixCreate { + return pc.SetMappingID(m.ID) +} + +// Mutation returns the PosixMutation object of the builder. +func (pc *PosixCreate) Mutation() *PosixMutation { + return pc.mutation +} + +// Save creates the Posix in the database. +func (pc *PosixCreate) Save(ctx context.Context) (*Posix, error) { + return withHooks(ctx, pc.sqlSave, pc.mutation, pc.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (pc *PosixCreate) SaveX(ctx context.Context) *Posix { + v, err := pc.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (pc *PosixCreate) Exec(ctx context.Context) error { + _, err := pc.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (pc *PosixCreate) ExecX(ctx context.Context) { + if err := pc.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (pc *PosixCreate) check() error { + if _, ok := pc.mutation.Atime(); !ok { + return &ValidationError{Name: "atime", err: errors.New(`ent: missing required field "Posix.atime"`)} + } + if _, ok := pc.mutation.Ctime(); !ok { + return &ValidationError{Name: "ctime", err: errors.New(`ent: missing required field "Posix.ctime"`)} + } + if _, ok := pc.mutation.CreationTime(); !ok { + return &ValidationError{Name: "creation_time", err: errors.New(`ent: missing required field "Posix.creation_time"`)} + } + if _, ok := pc.mutation.ExtendedAttributes(); !ok { + return &ValidationError{Name: "extended_attributes", err: errors.New(`ent: missing required field "Posix.extended_attributes"`)} + } + if _, ok := pc.mutation.FileDeviceID(); !ok { + return &ValidationError{Name: "file_device_id", err: errors.New(`ent: missing required field "Posix.file_device_id"`)} + } + if _, ok := pc.mutation.FileFlags(); !ok { + return &ValidationError{Name: "file_flags", err: errors.New(`ent: missing required field "Posix.file_flags"`)} + } + if _, ok := pc.mutation.FileInode(); !ok { + return &ValidationError{Name: "file_inode", err: errors.New(`ent: missing required field "Posix.file_inode"`)} + } + if _, ok := pc.mutation.FileSystemID(); !ok { + return &ValidationError{Name: "file_system_id", err: errors.New(`ent: missing required field "Posix.file_system_id"`)} + } + if _, ok := pc.mutation.FileType(); !ok { + return &ValidationError{Name: "file_type", err: errors.New(`ent: missing required field "Posix.file_type"`)} + } + if _, ok := pc.mutation.HardLinkCount(); !ok { + return &ValidationError{Name: "hard_link_count", err: errors.New(`ent: missing required field "Posix.hard_link_count"`)} + } + if _, ok := pc.mutation.Mtime(); !ok { + return &ValidationError{Name: "mtime", err: errors.New(`ent: missing required field "Posix.mtime"`)} + } + if _, ok := pc.mutation.MetadataCtime(); !ok { + return &ValidationError{Name: "metadata_ctime", err: errors.New(`ent: missing required field "Posix.metadata_ctime"`)} + } + if _, ok := pc.mutation.OwnerGid(); !ok { + return &ValidationError{Name: "owner_gid", err: errors.New(`ent: missing required field "Posix.owner_gid"`)} + } + if _, ok := pc.mutation.OwnerUID(); !ok { + return &ValidationError{Name: "owner_uid", err: errors.New(`ent: missing required field "Posix.owner_uid"`)} + } + if _, ok := pc.mutation.Permissions(); !ok { + return &ValidationError{Name: "permissions", err: errors.New(`ent: missing required field "Posix.permissions"`)} + } + if _, ok := pc.mutation.Size(); !ok { + return &ValidationError{Name: "size", err: errors.New(`ent: missing required field "Posix.size"`)} + } + if _, ok := pc.mutation.MappingID(); !ok { + return &ValidationError{Name: "mapping", err: errors.New(`ent: missing required edge "Posix.mapping"`)} + } + return nil +} + +func (pc *PosixCreate) sqlSave(ctx context.Context) (*Posix, error) { + if err := pc.check(); err != nil { + return nil, err + } + _node, _spec := pc.createSpec() + if err := sqlgraph.CreateNode(ctx, pc.driver, _spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + id := _spec.ID.Value.(int64) + _node.ID = int(id) + pc.mutation.id = &_node.ID + pc.mutation.done = true + return _node, nil +} + +func (pc *PosixCreate) createSpec() (*Posix, *sqlgraph.CreateSpec) { + var ( + _node = &Posix{config: pc.config} + _spec = sqlgraph.NewCreateSpec(posix.Table, sqlgraph.NewFieldSpec(posix.FieldID, field.TypeInt)) + ) + if value, ok := pc.mutation.Atime(); ok { + _spec.SetField(posix.FieldAtime, field.TypeString, value) + _node.Atime = value + } + if value, ok := pc.mutation.Ctime(); ok { + _spec.SetField(posix.FieldCtime, field.TypeString, value) + _node.Ctime = value + } + if value, ok := pc.mutation.CreationTime(); ok { + _spec.SetField(posix.FieldCreationTime, field.TypeString, value) + _node.CreationTime = value + } + if value, ok := pc.mutation.ExtendedAttributes(); ok { + _spec.SetField(posix.FieldExtendedAttributes, field.TypeString, value) + _node.ExtendedAttributes = value + } + if value, ok := pc.mutation.FileDeviceID(); ok { + _spec.SetField(posix.FieldFileDeviceID, field.TypeString, value) + _node.FileDeviceID = value + } + if value, ok := pc.mutation.FileFlags(); ok { + _spec.SetField(posix.FieldFileFlags, field.TypeString, value) + _node.FileFlags = value + } + if value, ok := pc.mutation.FileInode(); ok { + _spec.SetField(posix.FieldFileInode, field.TypeString, value) + _node.FileInode = value + } + if value, ok := pc.mutation.FileSystemID(); ok { + _spec.SetField(posix.FieldFileSystemID, field.TypeString, value) + _node.FileSystemID = value + } + if value, ok := pc.mutation.FileType(); ok { + _spec.SetField(posix.FieldFileType, field.TypeString, value) + _node.FileType = value + } + if value, ok := pc.mutation.HardLinkCount(); ok { + _spec.SetField(posix.FieldHardLinkCount, field.TypeString, value) + _node.HardLinkCount = value + } + if value, ok := pc.mutation.Mtime(); ok { + _spec.SetField(posix.FieldMtime, field.TypeString, value) + _node.Mtime = value + } + if value, ok := pc.mutation.MetadataCtime(); ok { + _spec.SetField(posix.FieldMetadataCtime, field.TypeString, value) + _node.MetadataCtime = value + } + if value, ok := pc.mutation.OwnerGid(); ok { + _spec.SetField(posix.FieldOwnerGid, field.TypeString, value) + _node.OwnerGid = value + } + if value, ok := pc.mutation.OwnerUID(); ok { + _spec.SetField(posix.FieldOwnerUID, field.TypeString, value) + _node.OwnerUID = value + } + if value, ok := pc.mutation.Permissions(); ok { + _spec.SetField(posix.FieldPermissions, field.TypeString, value) + _node.Permissions = value + } + if value, ok := pc.mutation.Size(); ok { + _spec.SetField(posix.FieldSize, field.TypeString, value) + _node.Size = value + } + if nodes := pc.mutation.MappingIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: posix.MappingTable, + Columns: []string{posix.MappingColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(mapping.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _node.mapping_posix = &nodes[0] + _spec.Edges = append(_spec.Edges, edge) + } + return _node, _spec +} + +// PosixCreateBulk is the builder for creating many Posix entities in bulk. +type PosixCreateBulk struct { + config + err error + builders []*PosixCreate +} + +// Save creates the Posix entities in the database. +func (pcb *PosixCreateBulk) Save(ctx context.Context) ([]*Posix, error) { + if pcb.err != nil { + return nil, pcb.err + } + specs := make([]*sqlgraph.CreateSpec, len(pcb.builders)) + nodes := make([]*Posix, len(pcb.builders)) + mutators := make([]Mutator, len(pcb.builders)) + for i := range pcb.builders { + func(i int, root context.Context) { + builder := pcb.builders[i] + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*PosixMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + if err := builder.check(); err != nil { + return nil, err + } + builder.mutation = mutation + var err error + nodes[i], specs[i] = builder.createSpec() + if i < len(mutators)-1 { + _, err = mutators[i+1].Mutate(root, pcb.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, pcb.driver, spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + } + } + if err != nil { + return nil, err + } + mutation.id = &nodes[i].ID + if specs[i].ID.Value != nil { + id := specs[i].ID.Value.(int64) + nodes[i].ID = int(id) + } + mutation.done = true + 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, pcb.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (pcb *PosixCreateBulk) SaveX(ctx context.Context) []*Posix { + v, err := pcb.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (pcb *PosixCreateBulk) Exec(ctx context.Context) error { + _, err := pcb.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (pcb *PosixCreateBulk) ExecX(ctx context.Context) { + if err := pcb.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/ent/posix_delete.go b/ent/posix_delete.go new file mode 100644 index 00000000..c9f4a5f9 --- /dev/null +++ b/ent/posix_delete.go @@ -0,0 +1,88 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/in-toto/archivista/ent/posix" + "github.com/in-toto/archivista/ent/predicate" +) + +// PosixDelete is the builder for deleting a Posix entity. +type PosixDelete struct { + config + hooks []Hook + mutation *PosixMutation +} + +// Where appends a list predicates to the PosixDelete builder. +func (pd *PosixDelete) Where(ps ...predicate.Posix) *PosixDelete { + pd.mutation.Where(ps...) + return pd +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (pd *PosixDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, pd.sqlExec, pd.mutation, pd.hooks) +} + +// ExecX is like Exec, but panics if an error occurs. +func (pd *PosixDelete) ExecX(ctx context.Context) int { + n, err := pd.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (pd *PosixDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(posix.Table, sqlgraph.NewFieldSpec(posix.FieldID, field.TypeInt)) + if ps := pd.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + affected, err := sqlgraph.DeleteNodes(ctx, pd.driver, _spec) + if err != nil && sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + pd.mutation.done = true + return affected, err +} + +// PosixDeleteOne is the builder for deleting a single Posix entity. +type PosixDeleteOne struct { + pd *PosixDelete +} + +// Where appends a list predicates to the PosixDelete builder. +func (pdo *PosixDeleteOne) Where(ps ...predicate.Posix) *PosixDeleteOne { + pdo.pd.mutation.Where(ps...) + return pdo +} + +// Exec executes the deletion query. +func (pdo *PosixDeleteOne) Exec(ctx context.Context) error { + n, err := pdo.pd.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{posix.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (pdo *PosixDeleteOne) ExecX(ctx context.Context) { + if err := pdo.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/ent/posix_query.go b/ent/posix_query.go new file mode 100644 index 00000000..24d14ff1 --- /dev/null +++ b/ent/posix_query.go @@ -0,0 +1,626 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "fmt" + "math" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/in-toto/archivista/ent/mapping" + "github.com/in-toto/archivista/ent/posix" + "github.com/in-toto/archivista/ent/predicate" +) + +// PosixQuery is the builder for querying Posix entities. +type PosixQuery struct { + config + ctx *QueryContext + order []posix.OrderOption + inters []Interceptor + predicates []predicate.Posix + withMapping *MappingQuery + withFKs bool + modifiers []func(*sql.Selector) + loadTotal []func(context.Context, []*Posix) error + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Where adds a new predicate for the PosixQuery builder. +func (pq *PosixQuery) Where(ps ...predicate.Posix) *PosixQuery { + pq.predicates = append(pq.predicates, ps...) + return pq +} + +// Limit the number of records to be returned by this query. +func (pq *PosixQuery) Limit(limit int) *PosixQuery { + pq.ctx.Limit = &limit + return pq +} + +// Offset to start from. +func (pq *PosixQuery) Offset(offset int) *PosixQuery { + pq.ctx.Offset = &offset + return pq +} + +// 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 (pq *PosixQuery) Unique(unique bool) *PosixQuery { + pq.ctx.Unique = &unique + return pq +} + +// Order specifies how the records should be ordered. +func (pq *PosixQuery) Order(o ...posix.OrderOption) *PosixQuery { + pq.order = append(pq.order, o...) + return pq +} + +// QueryMapping chains the current query on the "mapping" edge. +func (pq *PosixQuery) QueryMapping() *MappingQuery { + query := (&MappingClient{config: pq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := pq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := pq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(posix.Table, posix.FieldID, selector), + sqlgraph.To(mapping.Table, mapping.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, posix.MappingTable, posix.MappingColumn), + ) + fromU = sqlgraph.SetNeighbors(pq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// First returns the first Posix entity from the query. +// Returns a *NotFoundError when no Posix was found. +func (pq *PosixQuery) First(ctx context.Context) (*Posix, error) { + nodes, err := pq.Limit(1).All(setContextOp(ctx, pq.ctx, "First")) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{posix.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (pq *PosixQuery) FirstX(ctx context.Context) *Posix { + node, err := pq.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first Posix ID from the query. +// Returns a *NotFoundError when no Posix ID was found. +func (pq *PosixQuery) FirstID(ctx context.Context) (id int, err error) { + var ids []int + if ids, err = pq.Limit(1).IDs(setContextOp(ctx, pq.ctx, "FirstID")); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{posix.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (pq *PosixQuery) FirstIDX(ctx context.Context) int { + id, err := pq.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single Posix entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one Posix entity is found. +// Returns a *NotFoundError when no Posix entities are found. +func (pq *PosixQuery) Only(ctx context.Context) (*Posix, error) { + nodes, err := pq.Limit(2).All(setContextOp(ctx, pq.ctx, "Only")) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{posix.Label} + default: + return nil, &NotSingularError{posix.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (pq *PosixQuery) OnlyX(ctx context.Context) *Posix { + node, err := pq.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only Posix ID in the query. +// Returns a *NotSingularError when more than one Posix ID is found. +// Returns a *NotFoundError when no entities are found. +func (pq *PosixQuery) OnlyID(ctx context.Context) (id int, err error) { + var ids []int + if ids, err = pq.Limit(2).IDs(setContextOp(ctx, pq.ctx, "OnlyID")); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{posix.Label} + default: + err = &NotSingularError{posix.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (pq *PosixQuery) OnlyIDX(ctx context.Context) int { + id, err := pq.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of Posixes. +func (pq *PosixQuery) All(ctx context.Context) ([]*Posix, error) { + ctx = setContextOp(ctx, pq.ctx, "All") + if err := pq.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*Posix, *PosixQuery]() + return withInterceptors[[]*Posix](ctx, pq, qr, pq.inters) +} + +// AllX is like All, but panics if an error occurs. +func (pq *PosixQuery) AllX(ctx context.Context) []*Posix { + nodes, err := pq.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of Posix IDs. +func (pq *PosixQuery) IDs(ctx context.Context) (ids []int, err error) { + if pq.ctx.Unique == nil && pq.path != nil { + pq.Unique(true) + } + ctx = setContextOp(ctx, pq.ctx, "IDs") + if err = pq.Select(posix.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (pq *PosixQuery) IDsX(ctx context.Context) []int { + ids, err := pq.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (pq *PosixQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, pq.ctx, "Count") + if err := pq.prepareQuery(ctx); err != nil { + return 0, err + } + return withInterceptors[int](ctx, pq, querierCount[*PosixQuery](), pq.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (pq *PosixQuery) CountX(ctx context.Context) int { + count, err := pq.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (pq *PosixQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, pq.ctx, "Exist") + switch _, err := pq.FirstID(ctx); { + case IsNotFound(err): + return false, nil + case err != nil: + return false, fmt.Errorf("ent: check existence: %w", err) + default: + return true, nil + } +} + +// ExistX is like Exist, but panics if an error occurs. +func (pq *PosixQuery) ExistX(ctx context.Context) bool { + exist, err := pq.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the PosixQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (pq *PosixQuery) Clone() *PosixQuery { + if pq == nil { + return nil + } + return &PosixQuery{ + config: pq.config, + ctx: pq.ctx.Clone(), + order: append([]posix.OrderOption{}, pq.order...), + inters: append([]Interceptor{}, pq.inters...), + predicates: append([]predicate.Posix{}, pq.predicates...), + withMapping: pq.withMapping.Clone(), + // clone intermediate query. + sql: pq.sql.Clone(), + path: pq.path, + } +} + +// WithMapping tells the query-builder to eager-load the nodes that are connected to +// the "mapping" edge. The optional arguments are used to configure the query builder of the edge. +func (pq *PosixQuery) WithMapping(opts ...func(*MappingQuery)) *PosixQuery { + query := (&MappingClient{config: pq.config}).Query() + for _, opt := range opts { + opt(query) + } + pq.withMapping = query + return pq +} + +// 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 { +// Atime string `json:"atime,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.Posix.Query(). +// GroupBy(posix.FieldAtime). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +func (pq *PosixQuery) GroupBy(field string, fields ...string) *PosixGroupBy { + pq.ctx.Fields = append([]string{field}, fields...) + grbuild := &PosixGroupBy{build: pq} + grbuild.flds = &pq.ctx.Fields + grbuild.label = posix.Label + grbuild.scan = grbuild.Scan + return grbuild +} + +// 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 { +// Atime string `json:"atime,omitempty"` +// } +// +// client.Posix.Query(). +// Select(posix.FieldAtime). +// Scan(ctx, &v) +func (pq *PosixQuery) Select(fields ...string) *PosixSelect { + pq.ctx.Fields = append(pq.ctx.Fields, fields...) + sbuild := &PosixSelect{PosixQuery: pq} + sbuild.label = posix.Label + sbuild.flds, sbuild.scan = &pq.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a PosixSelect configured with the given aggregations. +func (pq *PosixQuery) Aggregate(fns ...AggregateFunc) *PosixSelect { + return pq.Select().Aggregate(fns...) +} + +func (pq *PosixQuery) prepareQuery(ctx context.Context) error { + for _, inter := range pq.inters { + if inter == nil { + return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") + } + if trv, ok := inter.(Traverser); ok { + if err := trv.Traverse(ctx, pq); err != nil { + return err + } + } + } + for _, f := range pq.ctx.Fields { + if !posix.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + } + if pq.path != nil { + prev, err := pq.path(ctx) + if err != nil { + return err + } + pq.sql = prev + } + return nil +} + +func (pq *PosixQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Posix, error) { + var ( + nodes = []*Posix{} + withFKs = pq.withFKs + _spec = pq.querySpec() + loadedTypes = [1]bool{ + pq.withMapping != nil, + } + ) + if pq.withMapping != nil { + withFKs = true + } + if withFKs { + _spec.Node.Columns = append(_spec.Node.Columns, posix.ForeignKeys...) + } + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*Posix).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &Posix{config: pq.config} + nodes = append(nodes, node) + node.Edges.loadedTypes = loadedTypes + return node.assignValues(columns, values) + } + if len(pq.modifiers) > 0 { + _spec.Modifiers = pq.modifiers + } + for i := range hooks { + hooks[i](ctx, _spec) + } + if err := sqlgraph.QueryNodes(ctx, pq.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + if query := pq.withMapping; query != nil { + if err := pq.loadMapping(ctx, query, nodes, nil, + func(n *Posix, e *Mapping) { n.Edges.Mapping = e }); err != nil { + return nil, err + } + } + for i := range pq.loadTotal { + if err := pq.loadTotal[i](ctx, nodes); err != nil { + return nil, err + } + } + return nodes, nil +} + +func (pq *PosixQuery) loadMapping(ctx context.Context, query *MappingQuery, nodes []*Posix, init func(*Posix), assign func(*Posix, *Mapping)) error { + ids := make([]int, 0, len(nodes)) + nodeids := make(map[int][]*Posix) + for i := range nodes { + if nodes[i].mapping_posix == nil { + continue + } + fk := *nodes[i].mapping_posix + if _, ok := nodeids[fk]; !ok { + ids = append(ids, fk) + } + nodeids[fk] = append(nodeids[fk], nodes[i]) + } + if len(ids) == 0 { + return nil + } + query.Where(mapping.IDIn(ids...)) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nodeids[n.ID] + if !ok { + return fmt.Errorf(`unexpected foreign-key "mapping_posix" returned %v`, n.ID) + } + for i := range nodes { + assign(nodes[i], n) + } + } + return nil +} + +func (pq *PosixQuery) sqlCount(ctx context.Context) (int, error) { + _spec := pq.querySpec() + if len(pq.modifiers) > 0 { + _spec.Modifiers = pq.modifiers + } + _spec.Node.Columns = pq.ctx.Fields + if len(pq.ctx.Fields) > 0 { + _spec.Unique = pq.ctx.Unique != nil && *pq.ctx.Unique + } + return sqlgraph.CountNodes(ctx, pq.driver, _spec) +} + +func (pq *PosixQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(posix.Table, posix.Columns, sqlgraph.NewFieldSpec(posix.FieldID, field.TypeInt)) + _spec.From = pq.sql + if unique := pq.ctx.Unique; unique != nil { + _spec.Unique = *unique + } else if pq.path != nil { + _spec.Unique = true + } + if fields := pq.ctx.Fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, posix.FieldID) + for i := range fields { + if fields[i] != posix.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + } + if ps := pq.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := pq.ctx.Limit; limit != nil { + _spec.Limit = *limit + } + if offset := pq.ctx.Offset; offset != nil { + _spec.Offset = *offset + } + if ps := pq.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (pq *PosixQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(pq.driver.Dialect()) + t1 := builder.Table(posix.Table) + columns := pq.ctx.Fields + if len(columns) == 0 { + columns = posix.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if pq.sql != nil { + selector = pq.sql + selector.Select(selector.Columns(columns...)...) + } + if pq.ctx.Unique != nil && *pq.ctx.Unique { + selector.Distinct() + } + for _, p := range pq.predicates { + p(selector) + } + for _, p := range pq.order { + p(selector) + } + if offset := pq.ctx.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 := pq.ctx.Limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// PosixGroupBy is the group-by builder for Posix entities. +type PosixGroupBy struct { + selector + build *PosixQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (pgb *PosixGroupBy) Aggregate(fns ...AggregateFunc) *PosixGroupBy { + pgb.fns = append(pgb.fns, fns...) + return pgb +} + +// Scan applies the selector query and scans the result into the given value. +func (pgb *PosixGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, pgb.build.ctx, "GroupBy") + if err := pgb.build.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*PosixQuery, *PosixGroupBy](ctx, pgb.build, pgb, pgb.build.inters, v) +} + +func (pgb *PosixGroupBy) sqlScan(ctx context.Context, root *PosixQuery, v any) error { + selector := root.sqlQuery(ctx).Select() + aggregation := make([]string, 0, len(pgb.fns)) + for _, fn := range pgb.fns { + aggregation = append(aggregation, fn(selector)) + } + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*pgb.flds)+len(pgb.fns)) + for _, f := range *pgb.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*pgb.flds...)...) + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := pgb.build.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// PosixSelect is the builder for selecting fields of Posix entities. +type PosixSelect struct { + *PosixQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (ps *PosixSelect) Aggregate(fns ...AggregateFunc) *PosixSelect { + ps.fns = append(ps.fns, fns...) + return ps +} + +// Scan applies the selector query and scans the result into the given value. +func (ps *PosixSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, ps.ctx, "Select") + if err := ps.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*PosixQuery, *PosixSelect](ctx, ps.PosixQuery, ps, ps.inters, v) +} + +func (ps *PosixSelect) sqlScan(ctx context.Context, root *PosixQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(ps.fns)) + for _, fn := range ps.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*ps.selector.flds); { + case n == 0 && len(aggregation) > 0: + selector.Select(aggregation...) + case n != 0 && len(aggregation) > 0: + selector.AppendSelect(aggregation...) + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := ps.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} diff --git a/ent/posix_update.go b/ent/posix_update.go new file mode 100644 index 00000000..d15dcae1 --- /dev/null +++ b/ent/posix_update.go @@ -0,0 +1,834 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/in-toto/archivista/ent/mapping" + "github.com/in-toto/archivista/ent/posix" + "github.com/in-toto/archivista/ent/predicate" +) + +// PosixUpdate is the builder for updating Posix entities. +type PosixUpdate struct { + config + hooks []Hook + mutation *PosixMutation +} + +// Where appends a list predicates to the PosixUpdate builder. +func (pu *PosixUpdate) Where(ps ...predicate.Posix) *PosixUpdate { + pu.mutation.Where(ps...) + return pu +} + +// SetAtime sets the "atime" field. +func (pu *PosixUpdate) SetAtime(s string) *PosixUpdate { + pu.mutation.SetAtime(s) + return pu +} + +// SetNillableAtime sets the "atime" field if the given value is not nil. +func (pu *PosixUpdate) SetNillableAtime(s *string) *PosixUpdate { + if s != nil { + pu.SetAtime(*s) + } + return pu +} + +// SetCtime sets the "ctime" field. +func (pu *PosixUpdate) SetCtime(s string) *PosixUpdate { + pu.mutation.SetCtime(s) + return pu +} + +// SetNillableCtime sets the "ctime" field if the given value is not nil. +func (pu *PosixUpdate) SetNillableCtime(s *string) *PosixUpdate { + if s != nil { + pu.SetCtime(*s) + } + return pu +} + +// SetCreationTime sets the "creation_time" field. +func (pu *PosixUpdate) SetCreationTime(s string) *PosixUpdate { + pu.mutation.SetCreationTime(s) + return pu +} + +// SetNillableCreationTime sets the "creation_time" field if the given value is not nil. +func (pu *PosixUpdate) SetNillableCreationTime(s *string) *PosixUpdate { + if s != nil { + pu.SetCreationTime(*s) + } + return pu +} + +// SetExtendedAttributes sets the "extended_attributes" field. +func (pu *PosixUpdate) SetExtendedAttributes(s string) *PosixUpdate { + pu.mutation.SetExtendedAttributes(s) + return pu +} + +// SetNillableExtendedAttributes sets the "extended_attributes" field if the given value is not nil. +func (pu *PosixUpdate) SetNillableExtendedAttributes(s *string) *PosixUpdate { + if s != nil { + pu.SetExtendedAttributes(*s) + } + return pu +} + +// SetFileDeviceID sets the "file_device_id" field. +func (pu *PosixUpdate) SetFileDeviceID(s string) *PosixUpdate { + pu.mutation.SetFileDeviceID(s) + return pu +} + +// SetNillableFileDeviceID sets the "file_device_id" field if the given value is not nil. +func (pu *PosixUpdate) SetNillableFileDeviceID(s *string) *PosixUpdate { + if s != nil { + pu.SetFileDeviceID(*s) + } + return pu +} + +// SetFileFlags sets the "file_flags" field. +func (pu *PosixUpdate) SetFileFlags(s string) *PosixUpdate { + pu.mutation.SetFileFlags(s) + return pu +} + +// SetNillableFileFlags sets the "file_flags" field if the given value is not nil. +func (pu *PosixUpdate) SetNillableFileFlags(s *string) *PosixUpdate { + if s != nil { + pu.SetFileFlags(*s) + } + return pu +} + +// SetFileInode sets the "file_inode" field. +func (pu *PosixUpdate) SetFileInode(s string) *PosixUpdate { + pu.mutation.SetFileInode(s) + return pu +} + +// SetNillableFileInode sets the "file_inode" field if the given value is not nil. +func (pu *PosixUpdate) SetNillableFileInode(s *string) *PosixUpdate { + if s != nil { + pu.SetFileInode(*s) + } + return pu +} + +// SetFileSystemID sets the "file_system_id" field. +func (pu *PosixUpdate) SetFileSystemID(s string) *PosixUpdate { + pu.mutation.SetFileSystemID(s) + return pu +} + +// SetNillableFileSystemID sets the "file_system_id" field if the given value is not nil. +func (pu *PosixUpdate) SetNillableFileSystemID(s *string) *PosixUpdate { + if s != nil { + pu.SetFileSystemID(*s) + } + return pu +} + +// SetFileType sets the "file_type" field. +func (pu *PosixUpdate) SetFileType(s string) *PosixUpdate { + pu.mutation.SetFileType(s) + return pu +} + +// SetNillableFileType sets the "file_type" field if the given value is not nil. +func (pu *PosixUpdate) SetNillableFileType(s *string) *PosixUpdate { + if s != nil { + pu.SetFileType(*s) + } + return pu +} + +// SetHardLinkCount sets the "hard_link_count" field. +func (pu *PosixUpdate) SetHardLinkCount(s string) *PosixUpdate { + pu.mutation.SetHardLinkCount(s) + return pu +} + +// SetNillableHardLinkCount sets the "hard_link_count" field if the given value is not nil. +func (pu *PosixUpdate) SetNillableHardLinkCount(s *string) *PosixUpdate { + if s != nil { + pu.SetHardLinkCount(*s) + } + return pu +} + +// SetMtime sets the "mtime" field. +func (pu *PosixUpdate) SetMtime(s string) *PosixUpdate { + pu.mutation.SetMtime(s) + return pu +} + +// SetNillableMtime sets the "mtime" field if the given value is not nil. +func (pu *PosixUpdate) SetNillableMtime(s *string) *PosixUpdate { + if s != nil { + pu.SetMtime(*s) + } + return pu +} + +// SetMetadataCtime sets the "metadata_ctime" field. +func (pu *PosixUpdate) SetMetadataCtime(s string) *PosixUpdate { + pu.mutation.SetMetadataCtime(s) + return pu +} + +// SetNillableMetadataCtime sets the "metadata_ctime" field if the given value is not nil. +func (pu *PosixUpdate) SetNillableMetadataCtime(s *string) *PosixUpdate { + if s != nil { + pu.SetMetadataCtime(*s) + } + return pu +} + +// SetOwnerGid sets the "owner_gid" field. +func (pu *PosixUpdate) SetOwnerGid(s string) *PosixUpdate { + pu.mutation.SetOwnerGid(s) + return pu +} + +// SetNillableOwnerGid sets the "owner_gid" field if the given value is not nil. +func (pu *PosixUpdate) SetNillableOwnerGid(s *string) *PosixUpdate { + if s != nil { + pu.SetOwnerGid(*s) + } + return pu +} + +// SetOwnerUID sets the "owner_uid" field. +func (pu *PosixUpdate) SetOwnerUID(s string) *PosixUpdate { + pu.mutation.SetOwnerUID(s) + return pu +} + +// SetNillableOwnerUID sets the "owner_uid" field if the given value is not nil. +func (pu *PosixUpdate) SetNillableOwnerUID(s *string) *PosixUpdate { + if s != nil { + pu.SetOwnerUID(*s) + } + return pu +} + +// SetPermissions sets the "permissions" field. +func (pu *PosixUpdate) SetPermissions(s string) *PosixUpdate { + pu.mutation.SetPermissions(s) + return pu +} + +// SetNillablePermissions sets the "permissions" field if the given value is not nil. +func (pu *PosixUpdate) SetNillablePermissions(s *string) *PosixUpdate { + if s != nil { + pu.SetPermissions(*s) + } + return pu +} + +// SetSize sets the "size" field. +func (pu *PosixUpdate) SetSize(s string) *PosixUpdate { + pu.mutation.SetSize(s) + return pu +} + +// SetNillableSize sets the "size" field if the given value is not nil. +func (pu *PosixUpdate) SetNillableSize(s *string) *PosixUpdate { + if s != nil { + pu.SetSize(*s) + } + return pu +} + +// SetMappingID sets the "mapping" edge to the Mapping entity by ID. +func (pu *PosixUpdate) SetMappingID(id int) *PosixUpdate { + pu.mutation.SetMappingID(id) + return pu +} + +// SetMapping sets the "mapping" edge to the Mapping entity. +func (pu *PosixUpdate) SetMapping(m *Mapping) *PosixUpdate { + return pu.SetMappingID(m.ID) +} + +// Mutation returns the PosixMutation object of the builder. +func (pu *PosixUpdate) Mutation() *PosixMutation { + return pu.mutation +} + +// ClearMapping clears the "mapping" edge to the Mapping entity. +func (pu *PosixUpdate) ClearMapping() *PosixUpdate { + pu.mutation.ClearMapping() + return pu +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (pu *PosixUpdate) Save(ctx context.Context) (int, error) { + return withHooks(ctx, pu.sqlSave, pu.mutation, pu.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (pu *PosixUpdate) SaveX(ctx context.Context) int { + affected, err := pu.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (pu *PosixUpdate) Exec(ctx context.Context) error { + _, err := pu.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (pu *PosixUpdate) ExecX(ctx context.Context) { + if err := pu.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (pu *PosixUpdate) check() error { + if _, ok := pu.mutation.MappingID(); pu.mutation.MappingCleared() && !ok { + return errors.New(`ent: clearing a required unique edge "Posix.mapping"`) + } + return nil +} + +func (pu *PosixUpdate) sqlSave(ctx context.Context) (n int, err error) { + if err := pu.check(); err != nil { + return n, err + } + _spec := sqlgraph.NewUpdateSpec(posix.Table, posix.Columns, sqlgraph.NewFieldSpec(posix.FieldID, field.TypeInt)) + if ps := pu.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := pu.mutation.Atime(); ok { + _spec.SetField(posix.FieldAtime, field.TypeString, value) + } + if value, ok := pu.mutation.Ctime(); ok { + _spec.SetField(posix.FieldCtime, field.TypeString, value) + } + if value, ok := pu.mutation.CreationTime(); ok { + _spec.SetField(posix.FieldCreationTime, field.TypeString, value) + } + if value, ok := pu.mutation.ExtendedAttributes(); ok { + _spec.SetField(posix.FieldExtendedAttributes, field.TypeString, value) + } + if value, ok := pu.mutation.FileDeviceID(); ok { + _spec.SetField(posix.FieldFileDeviceID, field.TypeString, value) + } + if value, ok := pu.mutation.FileFlags(); ok { + _spec.SetField(posix.FieldFileFlags, field.TypeString, value) + } + if value, ok := pu.mutation.FileInode(); ok { + _spec.SetField(posix.FieldFileInode, field.TypeString, value) + } + if value, ok := pu.mutation.FileSystemID(); ok { + _spec.SetField(posix.FieldFileSystemID, field.TypeString, value) + } + if value, ok := pu.mutation.FileType(); ok { + _spec.SetField(posix.FieldFileType, field.TypeString, value) + } + if value, ok := pu.mutation.HardLinkCount(); ok { + _spec.SetField(posix.FieldHardLinkCount, field.TypeString, value) + } + if value, ok := pu.mutation.Mtime(); ok { + _spec.SetField(posix.FieldMtime, field.TypeString, value) + } + if value, ok := pu.mutation.MetadataCtime(); ok { + _spec.SetField(posix.FieldMetadataCtime, field.TypeString, value) + } + if value, ok := pu.mutation.OwnerGid(); ok { + _spec.SetField(posix.FieldOwnerGid, field.TypeString, value) + } + if value, ok := pu.mutation.OwnerUID(); ok { + _spec.SetField(posix.FieldOwnerUID, field.TypeString, value) + } + if value, ok := pu.mutation.Permissions(); ok { + _spec.SetField(posix.FieldPermissions, field.TypeString, value) + } + if value, ok := pu.mutation.Size(); ok { + _spec.SetField(posix.FieldSize, field.TypeString, value) + } + if pu.mutation.MappingCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: posix.MappingTable, + Columns: []string{posix.MappingColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(mapping.FieldID, field.TypeInt), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := pu.mutation.MappingIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: posix.MappingTable, + Columns: []string{posix.MappingColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(mapping.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if n, err = sqlgraph.UpdateNodes(ctx, pu.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{posix.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + pu.mutation.done = true + return n, nil +} + +// PosixUpdateOne is the builder for updating a single Posix entity. +type PosixUpdateOne struct { + config + fields []string + hooks []Hook + mutation *PosixMutation +} + +// SetAtime sets the "atime" field. +func (puo *PosixUpdateOne) SetAtime(s string) *PosixUpdateOne { + puo.mutation.SetAtime(s) + return puo +} + +// SetNillableAtime sets the "atime" field if the given value is not nil. +func (puo *PosixUpdateOne) SetNillableAtime(s *string) *PosixUpdateOne { + if s != nil { + puo.SetAtime(*s) + } + return puo +} + +// SetCtime sets the "ctime" field. +func (puo *PosixUpdateOne) SetCtime(s string) *PosixUpdateOne { + puo.mutation.SetCtime(s) + return puo +} + +// SetNillableCtime sets the "ctime" field if the given value is not nil. +func (puo *PosixUpdateOne) SetNillableCtime(s *string) *PosixUpdateOne { + if s != nil { + puo.SetCtime(*s) + } + return puo +} + +// SetCreationTime sets the "creation_time" field. +func (puo *PosixUpdateOne) SetCreationTime(s string) *PosixUpdateOne { + puo.mutation.SetCreationTime(s) + return puo +} + +// SetNillableCreationTime sets the "creation_time" field if the given value is not nil. +func (puo *PosixUpdateOne) SetNillableCreationTime(s *string) *PosixUpdateOne { + if s != nil { + puo.SetCreationTime(*s) + } + return puo +} + +// SetExtendedAttributes sets the "extended_attributes" field. +func (puo *PosixUpdateOne) SetExtendedAttributes(s string) *PosixUpdateOne { + puo.mutation.SetExtendedAttributes(s) + return puo +} + +// SetNillableExtendedAttributes sets the "extended_attributes" field if the given value is not nil. +func (puo *PosixUpdateOne) SetNillableExtendedAttributes(s *string) *PosixUpdateOne { + if s != nil { + puo.SetExtendedAttributes(*s) + } + return puo +} + +// SetFileDeviceID sets the "file_device_id" field. +func (puo *PosixUpdateOne) SetFileDeviceID(s string) *PosixUpdateOne { + puo.mutation.SetFileDeviceID(s) + return puo +} + +// SetNillableFileDeviceID sets the "file_device_id" field if the given value is not nil. +func (puo *PosixUpdateOne) SetNillableFileDeviceID(s *string) *PosixUpdateOne { + if s != nil { + puo.SetFileDeviceID(*s) + } + return puo +} + +// SetFileFlags sets the "file_flags" field. +func (puo *PosixUpdateOne) SetFileFlags(s string) *PosixUpdateOne { + puo.mutation.SetFileFlags(s) + return puo +} + +// SetNillableFileFlags sets the "file_flags" field if the given value is not nil. +func (puo *PosixUpdateOne) SetNillableFileFlags(s *string) *PosixUpdateOne { + if s != nil { + puo.SetFileFlags(*s) + } + return puo +} + +// SetFileInode sets the "file_inode" field. +func (puo *PosixUpdateOne) SetFileInode(s string) *PosixUpdateOne { + puo.mutation.SetFileInode(s) + return puo +} + +// SetNillableFileInode sets the "file_inode" field if the given value is not nil. +func (puo *PosixUpdateOne) SetNillableFileInode(s *string) *PosixUpdateOne { + if s != nil { + puo.SetFileInode(*s) + } + return puo +} + +// SetFileSystemID sets the "file_system_id" field. +func (puo *PosixUpdateOne) SetFileSystemID(s string) *PosixUpdateOne { + puo.mutation.SetFileSystemID(s) + return puo +} + +// SetNillableFileSystemID sets the "file_system_id" field if the given value is not nil. +func (puo *PosixUpdateOne) SetNillableFileSystemID(s *string) *PosixUpdateOne { + if s != nil { + puo.SetFileSystemID(*s) + } + return puo +} + +// SetFileType sets the "file_type" field. +func (puo *PosixUpdateOne) SetFileType(s string) *PosixUpdateOne { + puo.mutation.SetFileType(s) + return puo +} + +// SetNillableFileType sets the "file_type" field if the given value is not nil. +func (puo *PosixUpdateOne) SetNillableFileType(s *string) *PosixUpdateOne { + if s != nil { + puo.SetFileType(*s) + } + return puo +} + +// SetHardLinkCount sets the "hard_link_count" field. +func (puo *PosixUpdateOne) SetHardLinkCount(s string) *PosixUpdateOne { + puo.mutation.SetHardLinkCount(s) + return puo +} + +// SetNillableHardLinkCount sets the "hard_link_count" field if the given value is not nil. +func (puo *PosixUpdateOne) SetNillableHardLinkCount(s *string) *PosixUpdateOne { + if s != nil { + puo.SetHardLinkCount(*s) + } + return puo +} + +// SetMtime sets the "mtime" field. +func (puo *PosixUpdateOne) SetMtime(s string) *PosixUpdateOne { + puo.mutation.SetMtime(s) + return puo +} + +// SetNillableMtime sets the "mtime" field if the given value is not nil. +func (puo *PosixUpdateOne) SetNillableMtime(s *string) *PosixUpdateOne { + if s != nil { + puo.SetMtime(*s) + } + return puo +} + +// SetMetadataCtime sets the "metadata_ctime" field. +func (puo *PosixUpdateOne) SetMetadataCtime(s string) *PosixUpdateOne { + puo.mutation.SetMetadataCtime(s) + return puo +} + +// SetNillableMetadataCtime sets the "metadata_ctime" field if the given value is not nil. +func (puo *PosixUpdateOne) SetNillableMetadataCtime(s *string) *PosixUpdateOne { + if s != nil { + puo.SetMetadataCtime(*s) + } + return puo +} + +// SetOwnerGid sets the "owner_gid" field. +func (puo *PosixUpdateOne) SetOwnerGid(s string) *PosixUpdateOne { + puo.mutation.SetOwnerGid(s) + return puo +} + +// SetNillableOwnerGid sets the "owner_gid" field if the given value is not nil. +func (puo *PosixUpdateOne) SetNillableOwnerGid(s *string) *PosixUpdateOne { + if s != nil { + puo.SetOwnerGid(*s) + } + return puo +} + +// SetOwnerUID sets the "owner_uid" field. +func (puo *PosixUpdateOne) SetOwnerUID(s string) *PosixUpdateOne { + puo.mutation.SetOwnerUID(s) + return puo +} + +// SetNillableOwnerUID sets the "owner_uid" field if the given value is not nil. +func (puo *PosixUpdateOne) SetNillableOwnerUID(s *string) *PosixUpdateOne { + if s != nil { + puo.SetOwnerUID(*s) + } + return puo +} + +// SetPermissions sets the "permissions" field. +func (puo *PosixUpdateOne) SetPermissions(s string) *PosixUpdateOne { + puo.mutation.SetPermissions(s) + return puo +} + +// SetNillablePermissions sets the "permissions" field if the given value is not nil. +func (puo *PosixUpdateOne) SetNillablePermissions(s *string) *PosixUpdateOne { + if s != nil { + puo.SetPermissions(*s) + } + return puo +} + +// SetSize sets the "size" field. +func (puo *PosixUpdateOne) SetSize(s string) *PosixUpdateOne { + puo.mutation.SetSize(s) + return puo +} + +// SetNillableSize sets the "size" field if the given value is not nil. +func (puo *PosixUpdateOne) SetNillableSize(s *string) *PosixUpdateOne { + if s != nil { + puo.SetSize(*s) + } + return puo +} + +// SetMappingID sets the "mapping" edge to the Mapping entity by ID. +func (puo *PosixUpdateOne) SetMappingID(id int) *PosixUpdateOne { + puo.mutation.SetMappingID(id) + return puo +} + +// SetMapping sets the "mapping" edge to the Mapping entity. +func (puo *PosixUpdateOne) SetMapping(m *Mapping) *PosixUpdateOne { + return puo.SetMappingID(m.ID) +} + +// Mutation returns the PosixMutation object of the builder. +func (puo *PosixUpdateOne) Mutation() *PosixMutation { + return puo.mutation +} + +// ClearMapping clears the "mapping" edge to the Mapping entity. +func (puo *PosixUpdateOne) ClearMapping() *PosixUpdateOne { + puo.mutation.ClearMapping() + return puo +} + +// Where appends a list predicates to the PosixUpdate builder. +func (puo *PosixUpdateOne) Where(ps ...predicate.Posix) *PosixUpdateOne { + puo.mutation.Where(ps...) + return puo +} + +// Select allows selecting one or more fields (columns) of the returned entity. +// The default is selecting all fields defined in the entity schema. +func (puo *PosixUpdateOne) Select(field string, fields ...string) *PosixUpdateOne { + puo.fields = append([]string{field}, fields...) + return puo +} + +// Save executes the query and returns the updated Posix entity. +func (puo *PosixUpdateOne) Save(ctx context.Context) (*Posix, error) { + return withHooks(ctx, puo.sqlSave, puo.mutation, puo.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (puo *PosixUpdateOne) SaveX(ctx context.Context) *Posix { + node, err := puo.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (puo *PosixUpdateOne) Exec(ctx context.Context) error { + _, err := puo.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (puo *PosixUpdateOne) ExecX(ctx context.Context) { + if err := puo.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (puo *PosixUpdateOne) check() error { + if _, ok := puo.mutation.MappingID(); puo.mutation.MappingCleared() && !ok { + return errors.New(`ent: clearing a required unique edge "Posix.mapping"`) + } + return nil +} + +func (puo *PosixUpdateOne) sqlSave(ctx context.Context) (_node *Posix, err error) { + if err := puo.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(posix.Table, posix.Columns, sqlgraph.NewFieldSpec(posix.FieldID, field.TypeInt)) + id, ok := puo.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Posix.id" for update`)} + } + _spec.Node.ID.Value = id + if fields := puo.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, posix.FieldID) + for _, f := range fields { + if !posix.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != posix.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, f) + } + } + } + if ps := puo.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := puo.mutation.Atime(); ok { + _spec.SetField(posix.FieldAtime, field.TypeString, value) + } + if value, ok := puo.mutation.Ctime(); ok { + _spec.SetField(posix.FieldCtime, field.TypeString, value) + } + if value, ok := puo.mutation.CreationTime(); ok { + _spec.SetField(posix.FieldCreationTime, field.TypeString, value) + } + if value, ok := puo.mutation.ExtendedAttributes(); ok { + _spec.SetField(posix.FieldExtendedAttributes, field.TypeString, value) + } + if value, ok := puo.mutation.FileDeviceID(); ok { + _spec.SetField(posix.FieldFileDeviceID, field.TypeString, value) + } + if value, ok := puo.mutation.FileFlags(); ok { + _spec.SetField(posix.FieldFileFlags, field.TypeString, value) + } + if value, ok := puo.mutation.FileInode(); ok { + _spec.SetField(posix.FieldFileInode, field.TypeString, value) + } + if value, ok := puo.mutation.FileSystemID(); ok { + _spec.SetField(posix.FieldFileSystemID, field.TypeString, value) + } + if value, ok := puo.mutation.FileType(); ok { + _spec.SetField(posix.FieldFileType, field.TypeString, value) + } + if value, ok := puo.mutation.HardLinkCount(); ok { + _spec.SetField(posix.FieldHardLinkCount, field.TypeString, value) + } + if value, ok := puo.mutation.Mtime(); ok { + _spec.SetField(posix.FieldMtime, field.TypeString, value) + } + if value, ok := puo.mutation.MetadataCtime(); ok { + _spec.SetField(posix.FieldMetadataCtime, field.TypeString, value) + } + if value, ok := puo.mutation.OwnerGid(); ok { + _spec.SetField(posix.FieldOwnerGid, field.TypeString, value) + } + if value, ok := puo.mutation.OwnerUID(); ok { + _spec.SetField(posix.FieldOwnerUID, field.TypeString, value) + } + if value, ok := puo.mutation.Permissions(); ok { + _spec.SetField(posix.FieldPermissions, field.TypeString, value) + } + if value, ok := puo.mutation.Size(); ok { + _spec.SetField(posix.FieldSize, field.TypeString, value) + } + if puo.mutation.MappingCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: posix.MappingTable, + Columns: []string{posix.MappingColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(mapping.FieldID, field.TypeInt), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := puo.mutation.MappingIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: posix.MappingTable, + Columns: []string{posix.MappingColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(mapping.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + _node = &Posix{config: puo.config} + _spec.Assign = _node.assignValues + _spec.ScanValues = _node.scanValues + if err = sqlgraph.UpdateNode(ctx, puo.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{posix.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + puo.mutation.done = true + return _node, nil +} diff --git a/ent/predicate/predicate.go b/ent/predicate/predicate.go index 3306c827..85b7a460 100644 --- a/ent/predicate/predicate.go +++ b/ent/predicate/predicate.go @@ -18,9 +18,18 @@ type AttestationPolicy func(*sql.Selector) // Dsse is the predicate function for dsse builders. type Dsse func(*sql.Selector) +// Mapping is the predicate function for mapping builders. +type Mapping func(*sql.Selector) + +// Omnitrail is the predicate function for omnitrail builders. +type Omnitrail func(*sql.Selector) + // PayloadDigest is the predicate function for payloaddigest builders. type PayloadDigest func(*sql.Selector) +// Posix is the predicate function for posix builders. +type Posix func(*sql.Selector) + // Signature is the predicate function for signature builders. type Signature func(*sql.Selector) diff --git a/ent/runtime.go b/ent/runtime.go index 06f23d34..8afc5001 100644 --- a/ent/runtime.go +++ b/ent/runtime.go @@ -7,6 +7,7 @@ import ( "github.com/in-toto/archivista/ent/attestationcollection" "github.com/in-toto/archivista/ent/attestationpolicy" "github.com/in-toto/archivista/ent/dsse" + "github.com/in-toto/archivista/ent/mapping" "github.com/in-toto/archivista/ent/payloaddigest" "github.com/in-toto/archivista/ent/schema" "github.com/in-toto/archivista/ent/signature" @@ -47,6 +48,24 @@ func init() { dsseDescPayloadType := dsseFields[1].Descriptor() // dsse.PayloadTypeValidator is a validator for the "payload_type" field. It is called by the builders before save. dsse.PayloadTypeValidator = dsseDescPayloadType.Validators[0].(func(string) error) + mappingFields := schema.Mapping{}.Fields() + _ = mappingFields + // mappingDescPath is the schema descriptor for path field. + mappingDescPath := mappingFields[0].Descriptor() + // mapping.PathValidator is a validator for the "path" field. It is called by the builders before save. + mapping.PathValidator = mappingDescPath.Validators[0].(func(string) error) + // mappingDescType is the schema descriptor for type field. + mappingDescType := mappingFields[1].Descriptor() + // mapping.TypeValidator is a validator for the "type" field. It is called by the builders before save. + mapping.TypeValidator = mappingDescType.Validators[0].(func(string) error) + // mappingDescGitoidSha1 is the schema descriptor for gitoidSha1 field. + mappingDescGitoidSha1 := mappingFields[4].Descriptor() + // mapping.GitoidSha1Validator is a validator for the "gitoidSha1" field. It is called by the builders before save. + mapping.GitoidSha1Validator = mappingDescGitoidSha1.Validators[0].(func(string) error) + // mappingDescGitoidSha256 is the schema descriptor for gitoidSha256 field. + mappingDescGitoidSha256 := mappingFields[5].Descriptor() + // mapping.GitoidSha256Validator is a validator for the "gitoidSha256" field. It is called by the builders before save. + mapping.GitoidSha256Validator = mappingDescGitoidSha256.Validators[0].(func(string) error) payloaddigestFields := schema.PayloadDigest{}.Fields() _ = payloaddigestFields // payloaddigestDescAlgorithm is the schema descriptor for algorithm field. diff --git a/ent/schema/attestation.go b/ent/schema/attestation.go index e9f864b8..d7134544 100644 --- a/ent/schema/attestation.go +++ b/ent/schema/attestation.go @@ -34,6 +34,8 @@ func (Attestation) Fields() []ent.Field { func (Attestation) Edges() []ent.Edge { return []ent.Edge{ + edge.To("omnitrail", Omnitrail.Type).Unique(), + edge.From("attestation_collection", AttestationCollection.Type).Ref("attestations").Unique().Required(), } } diff --git a/ent/schema/mapping.go b/ent/schema/mapping.go new file mode 100644 index 00000000..6f1be379 --- /dev/null +++ b/ent/schema/mapping.go @@ -0,0 +1,49 @@ +// Copyright 2022 The Archivista Contributors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package schema + +import ( + "entgo.io/ent" + "entgo.io/ent/schema/edge" + "entgo.io/ent/schema/field" +) + +// Attestation represents an attestation from a witness attestation collection +type Mapping struct { + ent.Schema +} + +func (Mapping) Fields() []ent.Field { + return []ent.Field{ + field.String("path").NotEmpty(), + field.String("type").NotEmpty(), + field.String("sha1"), + field.String("sha256"), + field.String("gitoidSha1").NotEmpty(), + field.String("gitoidSha256").NotEmpty(), + } +} + +func (Mapping) Edges() []ent.Edge { + return []ent.Edge{ + edge.To("posix", Posix.Type), + + edge.From("omnitrail", Omnitrail.Type).Ref("mappings").Unique().Required(), + } +} + +func (Mapping) Indexes() []ent.Index { + return []ent.Index{} +} diff --git a/ent/schema/omnitrail.go b/ent/schema/omnitrail.go new file mode 100644 index 00000000..f08aa329 --- /dev/null +++ b/ent/schema/omnitrail.go @@ -0,0 +1,41 @@ +// Copyright 2022 The Archivista Contributors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package schema + +import ( + "entgo.io/ent" + "entgo.io/ent/schema/edge" +) + +// Attestation represents an attestation from a witness attestation collection +type Omnitrail struct { + ent.Schema +} + +func (Omnitrail) Fields() []ent.Field { + return []ent.Field{} +} + +func (Omnitrail) Edges() []ent.Edge { + return []ent.Edge{ + edge.To("mappings", Mapping.Type), + + edge.From("attestation", Attestation.Type).Ref("omnitrail").Unique().Required(), + } +} + +func (Omnitrail) Indexes() []ent.Index { + return []ent.Index{} +} diff --git a/ent/schema/posix.go b/ent/schema/posix.go new file mode 100644 index 00000000..c9a82e56 --- /dev/null +++ b/ent/schema/posix.go @@ -0,0 +1,61 @@ +// Copyright 2022 The Archivista Contributors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package schema + +import ( + "entgo.io/ent" + "entgo.io/ent/schema/edge" + "entgo.io/ent/schema/field" +) + +// Attestation represents an attestation from a witness attestation collection +type Posix struct { + ent.Schema +} + +func (Posix) Fields() []ent.Field { + return []ent.Field{ + field.String("atime"), + field.String("ctime"), + field.String("creation_time"), + field.String("extended_attributes"), + field.String("file_device_id"), + field.String("file_flags"), + field.String("file_inode"), + field.String("file_system_id"), + field.String("file_type"), + field.String("hard_link_count"), + field.String("mtime"), + field.String("metadata_ctime"), + field.String("owner_gid"), + field.String("owner_uid"), + field.String("permissions"), + field.String("size"), + } +} + +func (Posix) Edges() []ent.Edge { + return []ent.Edge{ + // edge.To("mappings", Mapping.Type), + + edge.From("mapping", Mapping.Type).Ref("posix").Unique().Required(), + } +} + +func (Posix) Indexes() []ent.Index { + return []ent.Index{ + // index.Fields("type"), + } +} diff --git a/ent/tx.go b/ent/tx.go index 8a1f4cd8..731225b9 100644 --- a/ent/tx.go +++ b/ent/tx.go @@ -20,8 +20,14 @@ type Tx struct { AttestationPolicy *AttestationPolicyClient // Dsse is the client for interacting with the Dsse builders. Dsse *DsseClient + // Mapping is the client for interacting with the Mapping builders. + Mapping *MappingClient + // Omnitrail is the client for interacting with the Omnitrail builders. + Omnitrail *OmnitrailClient // PayloadDigest is the client for interacting with the PayloadDigest builders. PayloadDigest *PayloadDigestClient + // Posix is the client for interacting with the Posix builders. + Posix *PosixClient // Signature is the client for interacting with the Signature builders. Signature *SignatureClient // Statement is the client for interacting with the Statement builders. @@ -167,7 +173,10 @@ func (tx *Tx) init() { tx.AttestationCollection = NewAttestationCollectionClient(tx.config) tx.AttestationPolicy = NewAttestationPolicyClient(tx.config) tx.Dsse = NewDsseClient(tx.config) + tx.Mapping = NewMappingClient(tx.config) + tx.Omnitrail = NewOmnitrailClient(tx.config) tx.PayloadDigest = NewPayloadDigestClient(tx.config) + tx.Posix = NewPosixClient(tx.config) tx.Signature = NewSignatureClient(tx.config) tx.Statement = NewStatementClient(tx.config) tx.Subject = NewSubjectClient(tx.config) diff --git a/gen.go b/gen.go index f84d0682..c563ed85 100644 --- a/gen.go +++ b/gen.go @@ -14,5 +14,5 @@ package archivista -//go:generate go run -mod=mod ./ent/entc.go -//go:generate go run -mod=mod github.com/99designs/gqlgen +//go:generate go run ./ent/entc.go +//go:generate go run github.com/99designs/gqlgen diff --git a/generated.go b/generated.go index a3187b6d..dc95c479 100644 --- a/generated.go +++ b/generated.go @@ -51,6 +51,7 @@ type ComplexityRoot struct { Attestation struct { AttestationCollection func(childComplexity int) int ID func(childComplexity int) int + Omnitrail func(childComplexity int) int Type func(childComplexity int) int } @@ -98,6 +99,24 @@ type ComplexityRoot struct { Node func(childComplexity int) int } + Mapping struct { + GitoidSha1 func(childComplexity int) int + GitoidSha256 func(childComplexity int) int + ID func(childComplexity int) int + Omnitrail func(childComplexity int) int + Path func(childComplexity int) int + Posix func(childComplexity int) int + Sha1 func(childComplexity int) int + Sha256 func(childComplexity int) int + Type func(childComplexity int) int + } + + Omnitrail struct { + Attestation func(childComplexity int) int + ID func(childComplexity int) int + Mappings func(childComplexity int) int + } + PageInfo struct { EndCursor func(childComplexity int) int HasNextPage func(childComplexity int) int @@ -112,6 +131,27 @@ type ComplexityRoot struct { Value func(childComplexity int) int } + Posix struct { + Atime func(childComplexity int) int + CreationTime func(childComplexity int) int + Ctime func(childComplexity int) int + ExtendedAttributes func(childComplexity int) int + FileDeviceID func(childComplexity int) int + FileFlags func(childComplexity int) int + FileInode func(childComplexity int) int + FileSystemID func(childComplexity int) int + FileType func(childComplexity int) int + HardLinkCount func(childComplexity int) int + ID func(childComplexity int) int + Mapping func(childComplexity int) int + MetadataCtime func(childComplexity int) int + Mtime func(childComplexity int) int + OwnerGid func(childComplexity int) int + OwnerUID func(childComplexity int) int + Permissions func(childComplexity int) int + Size func(childComplexity int) int + } + Query struct { AttestationPolicies func(childComplexity int, after *entgql.Cursor[int], first *int, before *entgql.Cursor[int], last *int, where *ent.AttestationPolicyWhereInput) int Dsses func(childComplexity int, after *entgql.Cursor[int], first *int, before *entgql.Cursor[int], last *int, where *ent.DsseWhereInput) int @@ -211,6 +251,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Attestation.ID(childComplexity), true + case "Attestation.omnitrail": + if e.complexity.Attestation.Omnitrail == nil { + break + } + + return e.complexity.Attestation.Omnitrail(childComplexity), true + case "Attestation.type": if e.complexity.Attestation.Type == nil { break @@ -379,6 +426,90 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.DsseEdge.Node(childComplexity), true + case "Mapping.gitoidsha1": + if e.complexity.Mapping.GitoidSha1 == nil { + break + } + + return e.complexity.Mapping.GitoidSha1(childComplexity), true + + case "Mapping.gitoidsha256": + if e.complexity.Mapping.GitoidSha256 == nil { + break + } + + return e.complexity.Mapping.GitoidSha256(childComplexity), true + + case "Mapping.id": + if e.complexity.Mapping.ID == nil { + break + } + + return e.complexity.Mapping.ID(childComplexity), true + + case "Mapping.omnitrail": + if e.complexity.Mapping.Omnitrail == nil { + break + } + + return e.complexity.Mapping.Omnitrail(childComplexity), true + + case "Mapping.path": + if e.complexity.Mapping.Path == nil { + break + } + + return e.complexity.Mapping.Path(childComplexity), true + + case "Mapping.posix": + if e.complexity.Mapping.Posix == nil { + break + } + + return e.complexity.Mapping.Posix(childComplexity), true + + case "Mapping.sha1": + if e.complexity.Mapping.Sha1 == nil { + break + } + + return e.complexity.Mapping.Sha1(childComplexity), true + + case "Mapping.sha256": + if e.complexity.Mapping.Sha256 == nil { + break + } + + return e.complexity.Mapping.Sha256(childComplexity), true + + case "Mapping.type": + if e.complexity.Mapping.Type == nil { + break + } + + return e.complexity.Mapping.Type(childComplexity), true + + case "Omnitrail.attestation": + if e.complexity.Omnitrail.Attestation == nil { + break + } + + return e.complexity.Omnitrail.Attestation(childComplexity), true + + case "Omnitrail.id": + if e.complexity.Omnitrail.ID == nil { + break + } + + return e.complexity.Omnitrail.ID(childComplexity), true + + case "Omnitrail.mappings": + if e.complexity.Omnitrail.Mappings == nil { + break + } + + return e.complexity.Omnitrail.Mappings(childComplexity), true + case "PageInfo.endCursor": if e.complexity.PageInfo.EndCursor == nil { break @@ -435,6 +566,132 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.PayloadDigest.Value(childComplexity), true + case "Posix.atime": + if e.complexity.Posix.Atime == nil { + break + } + + return e.complexity.Posix.Atime(childComplexity), true + + case "Posix.creationTime": + if e.complexity.Posix.CreationTime == nil { + break + } + + return e.complexity.Posix.CreationTime(childComplexity), true + + case "Posix.ctime": + if e.complexity.Posix.Ctime == nil { + break + } + + return e.complexity.Posix.Ctime(childComplexity), true + + case "Posix.extendedAttributes": + if e.complexity.Posix.ExtendedAttributes == nil { + break + } + + return e.complexity.Posix.ExtendedAttributes(childComplexity), true + + case "Posix.fileDeviceID": + if e.complexity.Posix.FileDeviceID == nil { + break + } + + return e.complexity.Posix.FileDeviceID(childComplexity), true + + case "Posix.fileFlags": + if e.complexity.Posix.FileFlags == nil { + break + } + + return e.complexity.Posix.FileFlags(childComplexity), true + + case "Posix.fileInode": + if e.complexity.Posix.FileInode == nil { + break + } + + return e.complexity.Posix.FileInode(childComplexity), true + + case "Posix.fileSystemID": + if e.complexity.Posix.FileSystemID == nil { + break + } + + return e.complexity.Posix.FileSystemID(childComplexity), true + + case "Posix.fileType": + if e.complexity.Posix.FileType == nil { + break + } + + return e.complexity.Posix.FileType(childComplexity), true + + case "Posix.hardLinkCount": + if e.complexity.Posix.HardLinkCount == nil { + break + } + + return e.complexity.Posix.HardLinkCount(childComplexity), true + + case "Posix.id": + if e.complexity.Posix.ID == nil { + break + } + + return e.complexity.Posix.ID(childComplexity), true + + case "Posix.mapping": + if e.complexity.Posix.Mapping == nil { + break + } + + return e.complexity.Posix.Mapping(childComplexity), true + + case "Posix.metadataCtime": + if e.complexity.Posix.MetadataCtime == nil { + break + } + + return e.complexity.Posix.MetadataCtime(childComplexity), true + + case "Posix.mtime": + if e.complexity.Posix.Mtime == nil { + break + } + + return e.complexity.Posix.Mtime(childComplexity), true + + case "Posix.ownerGid": + if e.complexity.Posix.OwnerGid == nil { + break + } + + return e.complexity.Posix.OwnerGid(childComplexity), true + + case "Posix.ownerUID": + if e.complexity.Posix.OwnerUID == nil { + break + } + + return e.complexity.Posix.OwnerUID(childComplexity), true + + case "Posix.permissions": + if e.complexity.Posix.Permissions == nil { + break + } + + return e.complexity.Posix.Permissions(childComplexity), true + + case "Posix.size": + if e.complexity.Posix.Size == nil { + break + } + + return e.complexity.Posix.Size(childComplexity), true + case "Query.attestationPolicies": if e.complexity.Query.AttestationPolicies == nil { break @@ -708,7 +965,10 @@ func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { ec.unmarshalInputAttestationPolicyWhereInput, ec.unmarshalInputAttestationWhereInput, ec.unmarshalInputDsseWhereInput, + ec.unmarshalInputMappingWhereInput, + ec.unmarshalInputOmnitrailWhereInput, ec.unmarshalInputPayloadDigestWhereInput, + ec.unmarshalInputPosixWhereInput, ec.unmarshalInputSignatureWhereInput, ec.unmarshalInputStatementWhereInput, ec.unmarshalInputSubjectDigestWhereInput, @@ -1134,7 +1394,7 @@ func (ec *executionContext) _Attestation_id(ctx context.Context, field graphql.C return ec.marshalNID2int(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Attestation_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Attestation_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Attestation", Field: field, @@ -1178,7 +1438,7 @@ func (ec *executionContext) _Attestation_type(ctx context.Context, field graphql return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Attestation_type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Attestation_type(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Attestation", Field: field, @@ -1191,6 +1451,55 @@ func (ec *executionContext) fieldContext_Attestation_type(ctx context.Context, f return fc, nil } +func (ec *executionContext) _Attestation_omnitrail(ctx context.Context, field graphql.CollectedField, obj *ent.Attestation) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Attestation_omnitrail(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Omnitrail(ctx) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*ent.Omnitrail) + fc.Result = res + return ec.marshalOOmnitrail2ᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐOmnitrail(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Attestation_omnitrail(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Attestation", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Omnitrail_id(ctx, field) + case "mappings": + return ec.fieldContext_Omnitrail_mappings(ctx, field) + case "attestation": + return ec.fieldContext_Omnitrail_attestation(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Omnitrail", field.Name) + }, + } + return fc, nil +} + func (ec *executionContext) _Attestation_attestationCollection(ctx context.Context, field graphql.CollectedField, obj *ent.Attestation) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Attestation_attestationCollection(ctx, field) if err != nil { @@ -1222,7 +1531,7 @@ func (ec *executionContext) _Attestation_attestationCollection(ctx context.Conte return ec.marshalNAttestationCollection2ᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐAttestationCollection(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Attestation_attestationCollection(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Attestation_attestationCollection(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Attestation", Field: field, @@ -1276,7 +1585,7 @@ func (ec *executionContext) _AttestationCollection_id(ctx context.Context, field return ec.marshalNID2int(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_AttestationCollection_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_AttestationCollection_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "AttestationCollection", Field: field, @@ -1320,7 +1629,7 @@ func (ec *executionContext) _AttestationCollection_name(ctx context.Context, fie return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_AttestationCollection_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_AttestationCollection_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "AttestationCollection", Field: field, @@ -1361,7 +1670,7 @@ func (ec *executionContext) _AttestationCollection_attestations(ctx context.Cont return ec.marshalOAttestation2ᚕᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐAttestationᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_AttestationCollection_attestations(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_AttestationCollection_attestations(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "AttestationCollection", Field: field, @@ -1373,6 +1682,8 @@ func (ec *executionContext) fieldContext_AttestationCollection_attestations(ctx return ec.fieldContext_Attestation_id(ctx, field) case "type": return ec.fieldContext_Attestation_type(ctx, field) + case "omnitrail": + return ec.fieldContext_Attestation_omnitrail(ctx, field) case "attestationCollection": return ec.fieldContext_Attestation_attestationCollection(ctx, field) } @@ -1413,7 +1724,7 @@ func (ec *executionContext) _AttestationCollection_statement(ctx context.Context return ec.marshalNStatement2ᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐStatement(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_AttestationCollection_statement(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_AttestationCollection_statement(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "AttestationCollection", Field: field, @@ -1471,7 +1782,7 @@ func (ec *executionContext) _AttestationPolicy_id(ctx context.Context, field gra return ec.marshalNID2int(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_AttestationPolicy_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_AttestationPolicy_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "AttestationPolicy", Field: field, @@ -1515,7 +1826,7 @@ func (ec *executionContext) _AttestationPolicy_name(ctx context.Context, field g return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_AttestationPolicy_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_AttestationPolicy_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "AttestationPolicy", Field: field, @@ -1556,7 +1867,7 @@ func (ec *executionContext) _AttestationPolicy_statement(ctx context.Context, fi return ec.marshalOStatement2ᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐStatement(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_AttestationPolicy_statement(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_AttestationPolicy_statement(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "AttestationPolicy", Field: field, @@ -1611,7 +1922,7 @@ func (ec *executionContext) _AttestationPolicyConnection_edges(ctx context.Conte return ec.marshalOAttestationPolicyEdge2ᚕᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐAttestationPolicyEdge(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_AttestationPolicyConnection_edges(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_AttestationPolicyConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "AttestationPolicyConnection", Field: field, @@ -1661,7 +1972,7 @@ func (ec *executionContext) _AttestationPolicyConnection_pageInfo(ctx context.Co return ec.marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_AttestationPolicyConnection_pageInfo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_AttestationPolicyConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "AttestationPolicyConnection", Field: field, @@ -1715,7 +2026,7 @@ func (ec *executionContext) _AttestationPolicyConnection_totalCount(ctx context. return ec.marshalNInt2int(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_AttestationPolicyConnection_totalCount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_AttestationPolicyConnection_totalCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "AttestationPolicyConnection", Field: field, @@ -1756,7 +2067,7 @@ func (ec *executionContext) _AttestationPolicyEdge_node(ctx context.Context, fie return ec.marshalOAttestationPolicy2ᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐAttestationPolicy(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_AttestationPolicyEdge_node(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_AttestationPolicyEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "AttestationPolicyEdge", Field: field, @@ -1808,7 +2119,7 @@ func (ec *executionContext) _AttestationPolicyEdge_cursor(ctx context.Context, f return ec.marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_AttestationPolicyEdge_cursor(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_AttestationPolicyEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "AttestationPolicyEdge", Field: field, @@ -1852,7 +2163,7 @@ func (ec *executionContext) _Dsse_id(ctx context.Context, field graphql.Collecte return ec.marshalNID2int(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Dsse_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Dsse_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Dsse", Field: field, @@ -1896,7 +2207,7 @@ func (ec *executionContext) _Dsse_gitoidSha256(ctx context.Context, field graphq return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Dsse_gitoidSha256(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Dsse_gitoidSha256(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Dsse", Field: field, @@ -1940,7 +2251,7 @@ func (ec *executionContext) _Dsse_payloadType(ctx context.Context, field graphql return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Dsse_payloadType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Dsse_payloadType(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Dsse", Field: field, @@ -1981,7 +2292,7 @@ func (ec *executionContext) _Dsse_statement(ctx context.Context, field graphql.C return ec.marshalOStatement2ᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐStatement(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Dsse_statement(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Dsse_statement(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Dsse", Field: field, @@ -2036,7 +2347,7 @@ func (ec *executionContext) _Dsse_signatures(ctx context.Context, field graphql. return ec.marshalOSignature2ᚕᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐSignatureᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Dsse_signatures(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Dsse_signatures(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Dsse", Field: field, @@ -2089,7 +2400,7 @@ func (ec *executionContext) _Dsse_payloadDigests(ctx context.Context, field grap return ec.marshalOPayloadDigest2ᚕᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐPayloadDigestᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Dsse_payloadDigests(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Dsse_payloadDigests(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Dsse", Field: field, @@ -2140,7 +2451,7 @@ func (ec *executionContext) _DsseConnection_edges(ctx context.Context, field gra return ec.marshalODsseEdge2ᚕᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐDsseEdge(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_DsseConnection_edges(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_DsseConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "DsseConnection", Field: field, @@ -2190,7 +2501,7 @@ func (ec *executionContext) _DsseConnection_pageInfo(ctx context.Context, field return ec.marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_DsseConnection_pageInfo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_DsseConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "DsseConnection", Field: field, @@ -2244,7 +2555,7 @@ func (ec *executionContext) _DsseConnection_totalCount(ctx context.Context, fiel return ec.marshalNInt2int(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_DsseConnection_totalCount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_DsseConnection_totalCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "DsseConnection", Field: field, @@ -2285,7 +2596,7 @@ func (ec *executionContext) _DsseEdge_node(ctx context.Context, field graphql.Co return ec.marshalODsse2ᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐDsse(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_DsseEdge_node(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_DsseEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "DsseEdge", Field: field, @@ -2343,7 +2654,7 @@ func (ec *executionContext) _DsseEdge_cursor(ctx context.Context, field graphql. return ec.marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_DsseEdge_cursor(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_DsseEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "DsseEdge", Field: field, @@ -2356,8 +2667,8 @@ func (ec *executionContext) fieldContext_DsseEdge_cursor(ctx context.Context, fi return fc, nil } -func (ec *executionContext) _PageInfo_hasNextPage(ctx context.Context, field graphql.CollectedField, obj *entgql.PageInfo[int]) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_PageInfo_hasNextPage(ctx, field) +func (ec *executionContext) _Mapping_id(ctx context.Context, field graphql.CollectedField, obj *ent.Mapping) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mapping_id(ctx, field) if err != nil { return graphql.Null } @@ -2370,7 +2681,7 @@ func (ec *executionContext) _PageInfo_hasNextPage(ctx context.Context, field gra }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.HasNextPage, nil + return obj.ID, nil }) if err != nil { ec.Error(ctx, err) @@ -2382,26 +2693,26 @@ func (ec *executionContext) _PageInfo_hasNextPage(ctx context.Context, field gra } return graphql.Null } - res := resTmp.(bool) + res := resTmp.(int) fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) + return ec.marshalNID2int(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_PageInfo_hasNextPage(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mapping_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "PageInfo", + Object: "Mapping", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") + return nil, errors.New("field of type ID does not have child fields") }, } return fc, nil } -func (ec *executionContext) _PageInfo_hasPreviousPage(ctx context.Context, field graphql.CollectedField, obj *entgql.PageInfo[int]) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_PageInfo_hasPreviousPage(ctx, field) +func (ec *executionContext) _Mapping_path(ctx context.Context, field graphql.CollectedField, obj *ent.Mapping) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mapping_path(ctx, field) if err != nil { return graphql.Null } @@ -2414,7 +2725,7 @@ func (ec *executionContext) _PageInfo_hasPreviousPage(ctx context.Context, field }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.HasPreviousPage, nil + return obj.Path, nil }) if err != nil { ec.Error(ctx, err) @@ -2426,26 +2737,26 @@ func (ec *executionContext) _PageInfo_hasPreviousPage(ctx context.Context, field } return graphql.Null } - res := resTmp.(bool) + res := resTmp.(string) fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_PageInfo_hasPreviousPage(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mapping_path(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "PageInfo", + Object: "Mapping", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _PageInfo_startCursor(ctx context.Context, field graphql.CollectedField, obj *entgql.PageInfo[int]) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_PageInfo_startCursor(ctx, field) +func (ec *executionContext) _Mapping_type(ctx context.Context, field graphql.CollectedField, obj *ent.Mapping) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mapping_type(ctx, field) if err != nil { return graphql.Null } @@ -2458,35 +2769,38 @@ func (ec *executionContext) _PageInfo_startCursor(ctx context.Context, field gra }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.StartCursor, nil + return obj.Type, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*entgql.Cursor[int]) + res := resTmp.(string) fc.Result = res - return ec.marshalOCursor2ᚖentgoᚗioᚋcontribᚋentgqlᚐCursor(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_PageInfo_startCursor(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mapping_type(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "PageInfo", + Object: "Mapping", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Cursor does not have child fields") + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _PageInfo_endCursor(ctx context.Context, field graphql.CollectedField, obj *entgql.PageInfo[int]) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_PageInfo_endCursor(ctx, field) +func (ec *executionContext) _Mapping_sha1(ctx context.Context, field graphql.CollectedField, obj *ent.Mapping) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mapping_sha1(ctx, field) if err != nil { return graphql.Null } @@ -2499,35 +2813,38 @@ func (ec *executionContext) _PageInfo_endCursor(ctx context.Context, field graph }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.EndCursor, nil + return obj.Sha1, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*entgql.Cursor[int]) + res := resTmp.(string) fc.Result = res - return ec.marshalOCursor2ᚖentgoᚗioᚋcontribᚋentgqlᚐCursor(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_PageInfo_endCursor(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mapping_sha1(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "PageInfo", + Object: "Mapping", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Cursor does not have child fields") + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _PayloadDigest_id(ctx context.Context, field graphql.CollectedField, obj *ent.PayloadDigest) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_PayloadDigest_id(ctx, field) +func (ec *executionContext) _Mapping_sha256(ctx context.Context, field graphql.CollectedField, obj *ent.Mapping) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mapping_sha256(ctx, field) if err != nil { return graphql.Null } @@ -2540,7 +2857,7 @@ func (ec *executionContext) _PayloadDigest_id(ctx context.Context, field graphql }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.ID, nil + return obj.Sha256, nil }) if err != nil { ec.Error(ctx, err) @@ -2552,26 +2869,26 @@ func (ec *executionContext) _PayloadDigest_id(ctx context.Context, field graphql } return graphql.Null } - res := resTmp.(int) + res := resTmp.(string) fc.Result = res - return ec.marshalNID2int(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_PayloadDigest_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mapping_sha256(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "PayloadDigest", + Object: "Mapping", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type ID does not have child fields") + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _PayloadDigest_algorithm(ctx context.Context, field graphql.CollectedField, obj *ent.PayloadDigest) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_PayloadDigest_algorithm(ctx, field) +func (ec *executionContext) _Mapping_gitoidsha1(ctx context.Context, field graphql.CollectedField, obj *ent.Mapping) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mapping_gitoidsha1(ctx, field) if err != nil { return graphql.Null } @@ -2584,7 +2901,7 @@ func (ec *executionContext) _PayloadDigest_algorithm(ctx context.Context, field }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Algorithm, nil + return obj.GitoidSha1, nil }) if err != nil { ec.Error(ctx, err) @@ -2601,9 +2918,9 @@ func (ec *executionContext) _PayloadDigest_algorithm(ctx context.Context, field return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_PayloadDigest_algorithm(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mapping_gitoidsha1(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "PayloadDigest", + Object: "Mapping", Field: field, IsMethod: false, IsResolver: false, @@ -2614,8 +2931,8 @@ func (ec *executionContext) fieldContext_PayloadDigest_algorithm(ctx context.Con return fc, nil } -func (ec *executionContext) _PayloadDigest_value(ctx context.Context, field graphql.CollectedField, obj *ent.PayloadDigest) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_PayloadDigest_value(ctx, field) +func (ec *executionContext) _Mapping_gitoidsha256(ctx context.Context, field graphql.CollectedField, obj *ent.Mapping) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mapping_gitoidsha256(ctx, field) if err != nil { return graphql.Null } @@ -2628,7 +2945,7 @@ func (ec *executionContext) _PayloadDigest_value(ctx context.Context, field grap }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Value, nil + return obj.GitoidSha256, nil }) if err != nil { ec.Error(ctx, err) @@ -2645,9 +2962,9 @@ func (ec *executionContext) _PayloadDigest_value(ctx context.Context, field grap return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_PayloadDigest_value(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mapping_gitoidsha256(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "PayloadDigest", + Object: "Mapping", Field: field, IsMethod: false, IsResolver: false, @@ -2658,8 +2975,8 @@ func (ec *executionContext) fieldContext_PayloadDigest_value(ctx context.Context return fc, nil } -func (ec *executionContext) _PayloadDigest_dsse(ctx context.Context, field graphql.CollectedField, obj *ent.PayloadDigest) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_PayloadDigest_dsse(ctx, field) +func (ec *executionContext) _Mapping_posix(ctx context.Context, field graphql.CollectedField, obj *ent.Mapping) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mapping_posix(ctx, field) if err != nil { return graphql.Null } @@ -2672,7 +2989,7 @@ func (ec *executionContext) _PayloadDigest_dsse(ctx context.Context, field graph }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Dsse(ctx) + return obj.Posix(ctx) }) if err != nil { ec.Error(ctx, err) @@ -2681,40 +2998,64 @@ func (ec *executionContext) _PayloadDigest_dsse(ctx context.Context, field graph if resTmp == nil { return graphql.Null } - res := resTmp.(*ent.Dsse) + res := resTmp.([]*ent.Posix) fc.Result = res - return ec.marshalODsse2ᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐDsse(ctx, field.Selections, res) + return ec.marshalOPosix2ᚕᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐPosixᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_PayloadDigest_dsse(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mapping_posix(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "PayloadDigest", + Object: "Mapping", Field: field, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": - return ec.fieldContext_Dsse_id(ctx, field) - case "gitoidSha256": - return ec.fieldContext_Dsse_gitoidSha256(ctx, field) - case "payloadType": - return ec.fieldContext_Dsse_payloadType(ctx, field) - case "statement": - return ec.fieldContext_Dsse_statement(ctx, field) - case "signatures": - return ec.fieldContext_Dsse_signatures(ctx, field) - case "payloadDigests": - return ec.fieldContext_Dsse_payloadDigests(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Dsse", field.Name) + return ec.fieldContext_Posix_id(ctx, field) + case "atime": + return ec.fieldContext_Posix_atime(ctx, field) + case "ctime": + return ec.fieldContext_Posix_ctime(ctx, field) + case "creationTime": + return ec.fieldContext_Posix_creationTime(ctx, field) + case "extendedAttributes": + return ec.fieldContext_Posix_extendedAttributes(ctx, field) + case "fileDeviceID": + return ec.fieldContext_Posix_fileDeviceID(ctx, field) + case "fileFlags": + return ec.fieldContext_Posix_fileFlags(ctx, field) + case "fileInode": + return ec.fieldContext_Posix_fileInode(ctx, field) + case "fileSystemID": + return ec.fieldContext_Posix_fileSystemID(ctx, field) + case "fileType": + return ec.fieldContext_Posix_fileType(ctx, field) + case "hardLinkCount": + return ec.fieldContext_Posix_hardLinkCount(ctx, field) + case "mtime": + return ec.fieldContext_Posix_mtime(ctx, field) + case "metadataCtime": + return ec.fieldContext_Posix_metadataCtime(ctx, field) + case "ownerGid": + return ec.fieldContext_Posix_ownerGid(ctx, field) + case "ownerUID": + return ec.fieldContext_Posix_ownerUID(ctx, field) + case "permissions": + return ec.fieldContext_Posix_permissions(ctx, field) + case "size": + return ec.fieldContext_Posix_size(ctx, field) + case "mapping": + return ec.fieldContext_Posix_mapping(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Posix", field.Name) }, } return fc, nil } -func (ec *executionContext) _Query_node(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_node(ctx, field) +func (ec *executionContext) _Mapping_omnitrail(ctx context.Context, field graphql.CollectedField, obj *ent.Mapping) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mapping_omnitrail(ctx, field) if err != nil { return graphql.Null } @@ -2727,46 +3068,46 @@ func (ec *executionContext) _Query_node(ctx context.Context, field graphql.Colle }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Node(rctx, fc.Args["id"].(int)) + return obj.Omnitrail(ctx) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(ent.Noder) + res := resTmp.(*ent.Omnitrail) fc.Result = res - return ec.marshalONode2githubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐNoder(ctx, field.Selections, res) + return ec.marshalNOmnitrail2ᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐOmnitrail(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_node(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mapping_omnitrail(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "Mapping", Field: field, IsMethod: true, - IsResolver: true, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("FieldContext.Child cannot be called on type INTERFACE") + switch field.Name { + case "id": + return ec.fieldContext_Omnitrail_id(ctx, field) + case "mappings": + return ec.fieldContext_Omnitrail_mappings(ctx, field) + case "attestation": + return ec.fieldContext_Omnitrail_attestation(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Omnitrail", field.Name) }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_node_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Query_nodes(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_nodes(ctx, field) +func (ec *executionContext) _Omnitrail_id(ctx context.Context, field graphql.CollectedField, obj *ent.Omnitrail) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Omnitrail_id(ctx, field) if err != nil { return graphql.Null } @@ -2779,7 +3120,7 @@ func (ec *executionContext) _Query_nodes(ctx context.Context, field graphql.Coll }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Nodes(rctx, fc.Args["ids"].([]int)) + return obj.ID, nil }) if err != nil { ec.Error(ctx, err) @@ -2791,37 +3132,26 @@ func (ec *executionContext) _Query_nodes(ctx context.Context, field graphql.Coll } return graphql.Null } - res := resTmp.([]ent.Noder) + res := resTmp.(int) fc.Result = res - return ec.marshalNNode2ᚕgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐNoder(ctx, field.Selections, res) + return ec.marshalNID2int(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_nodes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Omnitrail_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "Omnitrail", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("FieldContext.Child cannot be called on type INTERFACE") + return nil, errors.New("field of type ID does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_nodes_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Query_attestationPolicies(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_attestationPolicies(ctx, field) +func (ec *executionContext) _Omnitrail_mappings(ctx context.Context, field graphql.CollectedField, obj *ent.Omnitrail) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Omnitrail_mappings(ctx, field) if err != nil { return graphql.Null } @@ -2834,57 +3164,55 @@ func (ec *executionContext) _Query_attestationPolicies(ctx context.Context, fiel }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().AttestationPolicies(rctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["where"].(*ent.AttestationPolicyWhereInput)) + return obj.Mappings(ctx) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(*ent.AttestationPolicyConnection) + res := resTmp.([]*ent.Mapping) fc.Result = res - return ec.marshalNAttestationPolicyConnection2ᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐAttestationPolicyConnection(ctx, field.Selections, res) + return ec.marshalOMapping2ᚕᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐMappingᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_attestationPolicies(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Omnitrail_mappings(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "Omnitrail", Field: field, IsMethod: true, - IsResolver: true, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "edges": - return ec.fieldContext_AttestationPolicyConnection_edges(ctx, field) - case "pageInfo": - return ec.fieldContext_AttestationPolicyConnection_pageInfo(ctx, field) - case "totalCount": - return ec.fieldContext_AttestationPolicyConnection_totalCount(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type AttestationPolicyConnection", field.Name) + case "id": + return ec.fieldContext_Mapping_id(ctx, field) + case "path": + return ec.fieldContext_Mapping_path(ctx, field) + case "type": + return ec.fieldContext_Mapping_type(ctx, field) + case "sha1": + return ec.fieldContext_Mapping_sha1(ctx, field) + case "sha256": + return ec.fieldContext_Mapping_sha256(ctx, field) + case "gitoidsha1": + return ec.fieldContext_Mapping_gitoidsha1(ctx, field) + case "gitoidsha256": + return ec.fieldContext_Mapping_gitoidsha256(ctx, field) + case "posix": + return ec.fieldContext_Mapping_posix(ctx, field) + case "omnitrail": + return ec.fieldContext_Mapping_omnitrail(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Mapping", field.Name) }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_attestationPolicies_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Query_dsses(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_dsses(ctx, field) +func (ec *executionContext) _Omnitrail_attestation(ctx context.Context, field graphql.CollectedField, obj *ent.Omnitrail) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Omnitrail_attestation(ctx, field) if err != nil { return graphql.Null } @@ -2897,7 +3225,7 @@ func (ec *executionContext) _Query_dsses(ctx context.Context, field graphql.Coll }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Dsses(rctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["where"].(*ent.DsseWhereInput)) + return obj.Attestation(ctx) }) if err != nil { ec.Error(ctx, err) @@ -2909,45 +3237,36 @@ func (ec *executionContext) _Query_dsses(ctx context.Context, field graphql.Coll } return graphql.Null } - res := resTmp.(*ent.DsseConnection) + res := resTmp.(*ent.Attestation) fc.Result = res - return ec.marshalNDsseConnection2ᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐDsseConnection(ctx, field.Selections, res) + return ec.marshalNAttestation2ᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐAttestation(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_dsses(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Omnitrail_attestation(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "Omnitrail", Field: field, IsMethod: true, - IsResolver: true, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "edges": - return ec.fieldContext_DsseConnection_edges(ctx, field) - case "pageInfo": - return ec.fieldContext_DsseConnection_pageInfo(ctx, field) - case "totalCount": - return ec.fieldContext_DsseConnection_totalCount(ctx, field) + case "id": + return ec.fieldContext_Attestation_id(ctx, field) + case "type": + return ec.fieldContext_Attestation_type(ctx, field) + case "omnitrail": + return ec.fieldContext_Attestation_omnitrail(ctx, field) + case "attestationCollection": + return ec.fieldContext_Attestation_attestationCollection(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type DsseConnection", field.Name) + return nil, fmt.Errorf("no field named %q was found under type Attestation", field.Name) }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_dsses_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Query_subjects(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_subjects(ctx, field) +func (ec *executionContext) _PageInfo_hasNextPage(ctx context.Context, field graphql.CollectedField, obj *entgql.PageInfo[int]) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_PageInfo_hasNextPage(ctx, field) if err != nil { return graphql.Null } @@ -2960,7 +3279,7 @@ func (ec *executionContext) _Query_subjects(ctx context.Context, field graphql.C }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Subjects(rctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["where"].(*ent.SubjectWhereInput)) + return obj.HasNextPage, nil }) if err != nil { ec.Error(ctx, err) @@ -2972,45 +3291,26 @@ func (ec *executionContext) _Query_subjects(ctx context.Context, field graphql.C } return graphql.Null } - res := resTmp.(*ent.SubjectConnection) + res := resTmp.(bool) fc.Result = res - return ec.marshalNSubjectConnection2ᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐSubjectConnection(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_subjects(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_PageInfo_hasNextPage(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "PageInfo", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "edges": - return ec.fieldContext_SubjectConnection_edges(ctx, field) - case "pageInfo": - return ec.fieldContext_SubjectConnection_pageInfo(ctx, field) - case "totalCount": - return ec.fieldContext_SubjectConnection_totalCount(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type SubjectConnection", field.Name) + return nil, errors.New("field of type Boolean does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_subjects_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query___type(ctx, field) +func (ec *executionContext) _PageInfo_hasPreviousPage(ctx context.Context, field graphql.CollectedField, obj *entgql.PageInfo[int]) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_PageInfo_hasPreviousPage(ctx, field) if err != nil { return graphql.Null } @@ -3023,68 +3323,38 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.introspectType(fc.Args["name"].(string)) + return obj.HasPreviousPage, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*introspection.Type) + res := resTmp.(bool) fc.Result = res - return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query___type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_PageInfo_hasPreviousPage(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "PageInfo", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) - case "name": - return ec.fieldContext___Type_name(ctx, field) - case "description": - return ec.fieldContext___Type_description(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + return nil, errors.New("field of type Boolean does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query___type_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query___schema(ctx, field) +func (ec *executionContext) _PageInfo_startCursor(ctx context.Context, field graphql.CollectedField, obj *entgql.PageInfo[int]) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_PageInfo_startCursor(ctx, field) if err != nil { return graphql.Null } @@ -3097,7 +3367,7 @@ func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.C }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.introspectSchema() + return obj.StartCursor, nil }) if err != nil { ec.Error(ctx, err) @@ -3106,40 +3376,26 @@ func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.C if resTmp == nil { return graphql.Null } - res := resTmp.(*introspection.Schema) + res := resTmp.(*entgql.Cursor[int]) fc.Result = res - return ec.marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) + return ec.marshalOCursor2ᚖentgoᚗioᚋcontribᚋentgqlᚐCursor(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query___schema(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_PageInfo_startCursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "PageInfo", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "description": - return ec.fieldContext___Schema_description(ctx, field) - case "types": - return ec.fieldContext___Schema_types(ctx, field) - case "queryType": - return ec.fieldContext___Schema_queryType(ctx, field) - case "mutationType": - return ec.fieldContext___Schema_mutationType(ctx, field) - case "subscriptionType": - return ec.fieldContext___Schema_subscriptionType(ctx, field) - case "directives": - return ec.fieldContext___Schema_directives(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Schema", field.Name) + return nil, errors.New("field of type Cursor does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Signature_id(ctx context.Context, field graphql.CollectedField, obj *ent.Signature) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Signature_id(ctx, field) +func (ec *executionContext) _PageInfo_endCursor(ctx context.Context, field graphql.CollectedField, obj *entgql.PageInfo[int]) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_PageInfo_endCursor(ctx, field) if err != nil { return graphql.Null } @@ -3152,38 +3408,35 @@ func (ec *executionContext) _Signature_id(ctx context.Context, field graphql.Col }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.ID, nil + return obj.EndCursor, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(int) + res := resTmp.(*entgql.Cursor[int]) fc.Result = res - return ec.marshalNID2int(ctx, field.Selections, res) + return ec.marshalOCursor2ᚖentgoᚗioᚋcontribᚋentgqlᚐCursor(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Signature_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_PageInfo_endCursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Signature", + Object: "PageInfo", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type ID does not have child fields") + return nil, errors.New("field of type Cursor does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Signature_keyID(ctx context.Context, field graphql.CollectedField, obj *ent.Signature) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Signature_keyID(ctx, field) +func (ec *executionContext) _PayloadDigest_id(ctx context.Context, field graphql.CollectedField, obj *ent.PayloadDigest) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_PayloadDigest_id(ctx, field) if err != nil { return graphql.Null } @@ -3196,7 +3449,7 @@ func (ec *executionContext) _Signature_keyID(ctx context.Context, field graphql. }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.KeyID, nil + return obj.ID, nil }) if err != nil { ec.Error(ctx, err) @@ -3208,26 +3461,26 @@ func (ec *executionContext) _Signature_keyID(ctx context.Context, field graphql. } return graphql.Null } - res := resTmp.(string) + res := resTmp.(int) fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) + return ec.marshalNID2int(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Signature_keyID(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_PayloadDigest_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Signature", + Object: "PayloadDigest", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type ID does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Signature_signature(ctx context.Context, field graphql.CollectedField, obj *ent.Signature) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Signature_signature(ctx, field) +func (ec *executionContext) _PayloadDigest_algorithm(ctx context.Context, field graphql.CollectedField, obj *ent.PayloadDigest) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_PayloadDigest_algorithm(ctx, field) if err != nil { return graphql.Null } @@ -3240,7 +3493,7 @@ func (ec *executionContext) _Signature_signature(ctx context.Context, field grap }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Signature, nil + return obj.Algorithm, nil }) if err != nil { ec.Error(ctx, err) @@ -3257,9 +3510,9 @@ func (ec *executionContext) _Signature_signature(ctx context.Context, field grap return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Signature_signature(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_PayloadDigest_algorithm(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Signature", + Object: "PayloadDigest", Field: field, IsMethod: false, IsResolver: false, @@ -3270,8 +3523,8 @@ func (ec *executionContext) fieldContext_Signature_signature(ctx context.Context return fc, nil } -func (ec *executionContext) _Signature_dsse(ctx context.Context, field graphql.CollectedField, obj *ent.Signature) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Signature_dsse(ctx, field) +func (ec *executionContext) _PayloadDigest_value(ctx context.Context, field graphql.CollectedField, obj *ent.PayloadDigest) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_PayloadDigest_value(ctx, field) if err != nil { return graphql.Null } @@ -3284,49 +3537,38 @@ func (ec *executionContext) _Signature_dsse(ctx context.Context, field graphql.C }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Dsse(ctx) + return obj.Value, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*ent.Dsse) + res := resTmp.(string) fc.Result = res - return ec.marshalODsse2ᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐDsse(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Signature_dsse(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_PayloadDigest_value(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Signature", + Object: "PayloadDigest", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_Dsse_id(ctx, field) - case "gitoidSha256": - return ec.fieldContext_Dsse_gitoidSha256(ctx, field) - case "payloadType": - return ec.fieldContext_Dsse_payloadType(ctx, field) - case "statement": - return ec.fieldContext_Dsse_statement(ctx, field) - case "signatures": - return ec.fieldContext_Dsse_signatures(ctx, field) - case "payloadDigests": - return ec.fieldContext_Dsse_payloadDigests(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Dsse", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Signature_timestamps(ctx context.Context, field graphql.CollectedField, obj *ent.Signature) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Signature_timestamps(ctx, field) +func (ec *executionContext) _PayloadDigest_dsse(ctx context.Context, field graphql.CollectedField, obj *ent.PayloadDigest) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_PayloadDigest_dsse(ctx, field) if err != nil { return graphql.Null } @@ -3339,7 +3581,7 @@ func (ec *executionContext) _Signature_timestamps(ctx context.Context, field gra }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Timestamps(ctx) + return obj.Dsse(ctx) }) if err != nil { ec.Error(ctx, err) @@ -3348,36 +3590,40 @@ func (ec *executionContext) _Signature_timestamps(ctx context.Context, field gra if resTmp == nil { return graphql.Null } - res := resTmp.([]*ent.Timestamp) + res := resTmp.(*ent.Dsse) fc.Result = res - return ec.marshalOTimestamp2ᚕᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐTimestampᚄ(ctx, field.Selections, res) + return ec.marshalODsse2ᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐDsse(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Signature_timestamps(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_PayloadDigest_dsse(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Signature", + Object: "PayloadDigest", Field: field, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": - return ec.fieldContext_Timestamp_id(ctx, field) - case "type": - return ec.fieldContext_Timestamp_type(ctx, field) - case "timestamp": - return ec.fieldContext_Timestamp_timestamp(ctx, field) - case "signature": - return ec.fieldContext_Timestamp_signature(ctx, field) + return ec.fieldContext_Dsse_id(ctx, field) + case "gitoidSha256": + return ec.fieldContext_Dsse_gitoidSha256(ctx, field) + case "payloadType": + return ec.fieldContext_Dsse_payloadType(ctx, field) + case "statement": + return ec.fieldContext_Dsse_statement(ctx, field) + case "signatures": + return ec.fieldContext_Dsse_signatures(ctx, field) + case "payloadDigests": + return ec.fieldContext_Dsse_payloadDigests(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type Timestamp", field.Name) + return nil, fmt.Errorf("no field named %q was found under type Dsse", field.Name) }, } return fc, nil } -func (ec *executionContext) _Statement_id(ctx context.Context, field graphql.CollectedField, obj *ent.Statement) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Statement_id(ctx, field) +func (ec *executionContext) _Posix_id(ctx context.Context, field graphql.CollectedField, obj *ent.Posix) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Posix_id(ctx, field) if err != nil { return graphql.Null } @@ -3407,9 +3653,9 @@ func (ec *executionContext) _Statement_id(ctx context.Context, field graphql.Col return ec.marshalNID2int(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Statement_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Posix_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Statement", + Object: "Posix", Field: field, IsMethod: false, IsResolver: false, @@ -3420,8 +3666,8 @@ func (ec *executionContext) fieldContext_Statement_id(ctx context.Context, field return fc, nil } -func (ec *executionContext) _Statement_predicate(ctx context.Context, field graphql.CollectedField, obj *ent.Statement) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Statement_predicate(ctx, field) +func (ec *executionContext) _Posix_atime(ctx context.Context, field graphql.CollectedField, obj *ent.Posix) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Posix_atime(ctx, field) if err != nil { return graphql.Null } @@ -3434,7 +3680,7 @@ func (ec *executionContext) _Statement_predicate(ctx context.Context, field grap }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Predicate, nil + return obj.Atime, nil }) if err != nil { ec.Error(ctx, err) @@ -3451,9 +3697,9 @@ func (ec *executionContext) _Statement_predicate(ctx context.Context, field grap return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Statement_predicate(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Posix_atime(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Statement", + Object: "Posix", Field: field, IsMethod: false, IsResolver: false, @@ -3464,8 +3710,8 @@ func (ec *executionContext) fieldContext_Statement_predicate(ctx context.Context return fc, nil } -func (ec *executionContext) _Statement_subjects(ctx context.Context, field graphql.CollectedField, obj *ent.Statement) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Statement_subjects(ctx, field) +func (ec *executionContext) _Posix_ctime(ctx context.Context, field graphql.CollectedField, obj *ent.Posix) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Posix_ctime(ctx, field) if err != nil { return graphql.Null } @@ -3478,7 +3724,7 @@ func (ec *executionContext) _Statement_subjects(ctx context.Context, field graph }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Subjects(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["where"].(*ent.SubjectWhereInput)) + return obj.Ctime, nil }) if err != nil { ec.Error(ctx, err) @@ -3490,45 +3736,26 @@ func (ec *executionContext) _Statement_subjects(ctx context.Context, field graph } return graphql.Null } - res := resTmp.(*ent.SubjectConnection) + res := resTmp.(string) fc.Result = res - return ec.marshalNSubjectConnection2ᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐSubjectConnection(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Statement_subjects(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Posix_ctime(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Statement", + Object: "Posix", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "edges": - return ec.fieldContext_SubjectConnection_edges(ctx, field) - case "pageInfo": - return ec.fieldContext_SubjectConnection_pageInfo(ctx, field) - case "totalCount": - return ec.fieldContext_SubjectConnection_totalCount(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type SubjectConnection", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Statement_subjects_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Statement_policy(ctx context.Context, field graphql.CollectedField, obj *ent.Statement) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Statement_policy(ctx, field) +func (ec *executionContext) _Posix_creationTime(ctx context.Context, field graphql.CollectedField, obj *ent.Posix) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Posix_creationTime(ctx, field) if err != nil { return graphql.Null } @@ -3541,43 +3768,38 @@ func (ec *executionContext) _Statement_policy(ctx context.Context, field graphql }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Policy(ctx) + return obj.CreationTime, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*ent.AttestationPolicy) + res := resTmp.(string) fc.Result = res - return ec.marshalOAttestationPolicy2ᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐAttestationPolicy(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Statement_policy(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Posix_creationTime(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Statement", + Object: "Posix", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_AttestationPolicy_id(ctx, field) - case "name": - return ec.fieldContext_AttestationPolicy_name(ctx, field) - case "statement": - return ec.fieldContext_AttestationPolicy_statement(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type AttestationPolicy", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Statement_attestationCollections(ctx context.Context, field graphql.CollectedField, obj *ent.Statement) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Statement_attestationCollections(ctx, field) +func (ec *executionContext) _Posix_extendedAttributes(ctx context.Context, field graphql.CollectedField, obj *ent.Posix) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Posix_extendedAttributes(ctx, field) if err != nil { return graphql.Null } @@ -3590,45 +3812,38 @@ func (ec *executionContext) _Statement_attestationCollections(ctx context.Contex }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.AttestationCollections(ctx) + return obj.ExtendedAttributes, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*ent.AttestationCollection) + res := resTmp.(string) fc.Result = res - return ec.marshalOAttestationCollection2ᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐAttestationCollection(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Statement_attestationCollections(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Posix_extendedAttributes(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Statement", + Object: "Posix", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_AttestationCollection_id(ctx, field) - case "name": - return ec.fieldContext_AttestationCollection_name(ctx, field) - case "attestations": - return ec.fieldContext_AttestationCollection_attestations(ctx, field) - case "statement": - return ec.fieldContext_AttestationCollection_statement(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type AttestationCollection", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Statement_dsse(ctx context.Context, field graphql.CollectedField, obj *ent.Statement) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Statement_dsse(ctx, field) +func (ec *executionContext) _Posix_fileDeviceID(ctx context.Context, field graphql.CollectedField, obj *ent.Posix) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Posix_fileDeviceID(ctx, field) if err != nil { return graphql.Null } @@ -3641,49 +3856,38 @@ func (ec *executionContext) _Statement_dsse(ctx context.Context, field graphql.C }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Dsse(ctx) + return obj.FileDeviceID, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.([]*ent.Dsse) + res := resTmp.(string) fc.Result = res - return ec.marshalODsse2ᚕᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐDsseᚄ(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Statement_dsse(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Posix_fileDeviceID(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Statement", + Object: "Posix", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_Dsse_id(ctx, field) - case "gitoidSha256": - return ec.fieldContext_Dsse_gitoidSha256(ctx, field) - case "payloadType": - return ec.fieldContext_Dsse_payloadType(ctx, field) - case "statement": - return ec.fieldContext_Dsse_statement(ctx, field) - case "signatures": - return ec.fieldContext_Dsse_signatures(ctx, field) - case "payloadDigests": - return ec.fieldContext_Dsse_payloadDigests(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Dsse", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Subject_id(ctx context.Context, field graphql.CollectedField, obj *ent.Subject) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Subject_id(ctx, field) +func (ec *executionContext) _Posix_fileFlags(ctx context.Context, field graphql.CollectedField, obj *ent.Posix) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Posix_fileFlags(ctx, field) if err != nil { return graphql.Null } @@ -3696,7 +3900,7 @@ func (ec *executionContext) _Subject_id(ctx context.Context, field graphql.Colle }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.ID, nil + return obj.FileFlags, nil }) if err != nil { ec.Error(ctx, err) @@ -3708,26 +3912,26 @@ func (ec *executionContext) _Subject_id(ctx context.Context, field graphql.Colle } return graphql.Null } - res := resTmp.(int) + res := resTmp.(string) fc.Result = res - return ec.marshalNID2int(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Subject_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Posix_fileFlags(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Subject", + Object: "Posix", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type ID does not have child fields") + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Subject_name(ctx context.Context, field graphql.CollectedField, obj *ent.Subject) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Subject_name(ctx, field) +func (ec *executionContext) _Posix_fileInode(ctx context.Context, field graphql.CollectedField, obj *ent.Posix) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Posix_fileInode(ctx, field) if err != nil { return graphql.Null } @@ -3740,7 +3944,7 @@ func (ec *executionContext) _Subject_name(ctx context.Context, field graphql.Col }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Name, nil + return obj.FileInode, nil }) if err != nil { ec.Error(ctx, err) @@ -3757,9 +3961,9 @@ func (ec *executionContext) _Subject_name(ctx context.Context, field graphql.Col return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Subject_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Posix_fileInode(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Subject", + Object: "Posix", Field: field, IsMethod: false, IsResolver: false, @@ -3770,8 +3974,8 @@ func (ec *executionContext) fieldContext_Subject_name(ctx context.Context, field return fc, nil } -func (ec *executionContext) _Subject_subjectDigests(ctx context.Context, field graphql.CollectedField, obj *ent.Subject) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Subject_subjectDigests(ctx, field) +func (ec *executionContext) _Posix_fileSystemID(ctx context.Context, field graphql.CollectedField, obj *ent.Posix) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Posix_fileSystemID(ctx, field) if err != nil { return graphql.Null } @@ -3784,45 +3988,38 @@ func (ec *executionContext) _Subject_subjectDigests(ctx context.Context, field g }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.SubjectDigests(ctx) + return obj.FileSystemID, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.([]*ent.SubjectDigest) + res := resTmp.(string) fc.Result = res - return ec.marshalOSubjectDigest2ᚕᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐSubjectDigestᚄ(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Subject_subjectDigests(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Posix_fileSystemID(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Subject", + Object: "Posix", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_SubjectDigest_id(ctx, field) - case "algorithm": - return ec.fieldContext_SubjectDigest_algorithm(ctx, field) - case "value": - return ec.fieldContext_SubjectDigest_value(ctx, field) - case "subject": - return ec.fieldContext_SubjectDigest_subject(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type SubjectDigest", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Subject_statement(ctx context.Context, field graphql.CollectedField, obj *ent.Subject) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Subject_statement(ctx, field) +func (ec *executionContext) _Posix_fileType(ctx context.Context, field graphql.CollectedField, obj *ent.Posix) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Posix_fileType(ctx, field) if err != nil { return graphql.Null } @@ -3835,49 +4032,38 @@ func (ec *executionContext) _Subject_statement(ctx context.Context, field graphq }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Statement(ctx) + return obj.FileType, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*ent.Statement) + res := resTmp.(string) fc.Result = res - return ec.marshalOStatement2ᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐStatement(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Subject_statement(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Posix_fileType(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Subject", + Object: "Posix", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_Statement_id(ctx, field) - case "predicate": - return ec.fieldContext_Statement_predicate(ctx, field) - case "subjects": - return ec.fieldContext_Statement_subjects(ctx, field) - case "policy": - return ec.fieldContext_Statement_policy(ctx, field) - case "attestationCollections": - return ec.fieldContext_Statement_attestationCollections(ctx, field) - case "dsse": - return ec.fieldContext_Statement_dsse(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Statement", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _SubjectConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.SubjectConnection) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_SubjectConnection_edges(ctx, field) +func (ec *executionContext) _Posix_hardLinkCount(ctx context.Context, field graphql.CollectedField, obj *ent.Posix) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Posix_hardLinkCount(ctx, field) if err != nil { return graphql.Null } @@ -3890,41 +4076,38 @@ func (ec *executionContext) _SubjectConnection_edges(ctx context.Context, field }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Edges, nil + return obj.HardLinkCount, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.([]*ent.SubjectEdge) + res := resTmp.(string) fc.Result = res - return ec.marshalOSubjectEdge2ᚕᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐSubjectEdge(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_SubjectConnection_edges(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Posix_hardLinkCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "SubjectConnection", + Object: "Posix", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "node": - return ec.fieldContext_SubjectEdge_node(ctx, field) - case "cursor": - return ec.fieldContext_SubjectEdge_cursor(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type SubjectEdge", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _SubjectConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.SubjectConnection) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_SubjectConnection_pageInfo(ctx, field) +func (ec *executionContext) _Posix_mtime(ctx context.Context, field graphql.CollectedField, obj *ent.Posix) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Posix_mtime(ctx, field) if err != nil { return graphql.Null } @@ -3937,7 +4120,7 @@ func (ec *executionContext) _SubjectConnection_pageInfo(ctx context.Context, fie }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.PageInfo, nil + return obj.Mtime, nil }) if err != nil { ec.Error(ctx, err) @@ -3949,36 +4132,26 @@ func (ec *executionContext) _SubjectConnection_pageInfo(ctx context.Context, fie } return graphql.Null } - res := resTmp.(entgql.PageInfo[int]) + res := resTmp.(string) fc.Result = res - return ec.marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_SubjectConnection_pageInfo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Posix_mtime(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "SubjectConnection", + Object: "Posix", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "hasNextPage": - return ec.fieldContext_PageInfo_hasNextPage(ctx, field) - case "hasPreviousPage": - return ec.fieldContext_PageInfo_hasPreviousPage(ctx, field) - case "startCursor": - return ec.fieldContext_PageInfo_startCursor(ctx, field) - case "endCursor": - return ec.fieldContext_PageInfo_endCursor(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _SubjectConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.SubjectConnection) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_SubjectConnection_totalCount(ctx, field) +func (ec *executionContext) _Posix_metadataCtime(ctx context.Context, field graphql.CollectedField, obj *ent.Posix) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Posix_metadataCtime(ctx, field) if err != nil { return graphql.Null } @@ -3991,7 +4164,7 @@ func (ec *executionContext) _SubjectConnection_totalCount(ctx context.Context, f }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.TotalCount, nil + return obj.MetadataCtime, nil }) if err != nil { ec.Error(ctx, err) @@ -4003,26 +4176,26 @@ func (ec *executionContext) _SubjectConnection_totalCount(ctx context.Context, f } return graphql.Null } - res := resTmp.(int) + res := resTmp.(string) fc.Result = res - return ec.marshalNInt2int(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_SubjectConnection_totalCount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Posix_metadataCtime(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "SubjectConnection", + Object: "Posix", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Int does not have child fields") + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _SubjectDigest_id(ctx context.Context, field graphql.CollectedField, obj *ent.SubjectDigest) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_SubjectDigest_id(ctx, field) +func (ec *executionContext) _Posix_ownerGid(ctx context.Context, field graphql.CollectedField, obj *ent.Posix) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Posix_ownerGid(ctx, field) if err != nil { return graphql.Null } @@ -4035,7 +4208,7 @@ func (ec *executionContext) _SubjectDigest_id(ctx context.Context, field graphql }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.ID, nil + return obj.OwnerGid, nil }) if err != nil { ec.Error(ctx, err) @@ -4047,26 +4220,26 @@ func (ec *executionContext) _SubjectDigest_id(ctx context.Context, field graphql } return graphql.Null } - res := resTmp.(int) + res := resTmp.(string) fc.Result = res - return ec.marshalNID2int(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_SubjectDigest_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Posix_ownerGid(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "SubjectDigest", + Object: "Posix", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type ID does not have child fields") + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _SubjectDigest_algorithm(ctx context.Context, field graphql.CollectedField, obj *ent.SubjectDigest) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_SubjectDigest_algorithm(ctx, field) +func (ec *executionContext) _Posix_ownerUID(ctx context.Context, field graphql.CollectedField, obj *ent.Posix) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Posix_ownerUID(ctx, field) if err != nil { return graphql.Null } @@ -4079,7 +4252,7 @@ func (ec *executionContext) _SubjectDigest_algorithm(ctx context.Context, field }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Algorithm, nil + return obj.OwnerUID, nil }) if err != nil { ec.Error(ctx, err) @@ -4096,9 +4269,9 @@ func (ec *executionContext) _SubjectDigest_algorithm(ctx context.Context, field return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_SubjectDigest_algorithm(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Posix_ownerUID(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "SubjectDigest", + Object: "Posix", Field: field, IsMethod: false, IsResolver: false, @@ -4109,8 +4282,8 @@ func (ec *executionContext) fieldContext_SubjectDigest_algorithm(ctx context.Con return fc, nil } -func (ec *executionContext) _SubjectDigest_value(ctx context.Context, field graphql.CollectedField, obj *ent.SubjectDigest) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_SubjectDigest_value(ctx, field) +func (ec *executionContext) _Posix_permissions(ctx context.Context, field graphql.CollectedField, obj *ent.Posix) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Posix_permissions(ctx, field) if err != nil { return graphql.Null } @@ -4123,7 +4296,7 @@ func (ec *executionContext) _SubjectDigest_value(ctx context.Context, field grap }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Value, nil + return obj.Permissions, nil }) if err != nil { ec.Error(ctx, err) @@ -4140,9 +4313,9 @@ func (ec *executionContext) _SubjectDigest_value(ctx context.Context, field grap return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_SubjectDigest_value(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Posix_permissions(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "SubjectDigest", + Object: "Posix", Field: field, IsMethod: false, IsResolver: false, @@ -4153,8 +4326,8 @@ func (ec *executionContext) fieldContext_SubjectDigest_value(ctx context.Context return fc, nil } -func (ec *executionContext) _SubjectDigest_subject(ctx context.Context, field graphql.CollectedField, obj *ent.SubjectDigest) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_SubjectDigest_subject(ctx, field) +func (ec *executionContext) _Posix_size(ctx context.Context, field graphql.CollectedField, obj *ent.Posix) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Posix_size(ctx, field) if err != nil { return graphql.Null } @@ -4167,45 +4340,38 @@ func (ec *executionContext) _SubjectDigest_subject(ctx context.Context, field gr }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Subject(ctx) + return obj.Size, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*ent.Subject) + res := resTmp.(string) fc.Result = res - return ec.marshalOSubject2ᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐSubject(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_SubjectDigest_subject(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Posix_size(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "SubjectDigest", + Object: "Posix", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_Subject_id(ctx, field) - case "name": - return ec.fieldContext_Subject_name(ctx, field) - case "subjectDigests": - return ec.fieldContext_Subject_subjectDigests(ctx, field) - case "statement": - return ec.fieldContext_Subject_statement(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Subject", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _SubjectEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.SubjectEdge) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_SubjectEdge_node(ctx, field) +func (ec *executionContext) _Posix_mapping(ctx context.Context, field graphql.CollectedField, obj *ent.Posix) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Posix_mapping(ctx, field) if err != nil { return graphql.Null } @@ -4218,45 +4384,58 @@ func (ec *executionContext) _SubjectEdge_node(ctx context.Context, field graphql }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Node, nil + return obj.Mapping(ctx) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*ent.Subject) + res := resTmp.(*ent.Mapping) fc.Result = res - return ec.marshalOSubject2ᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐSubject(ctx, field.Selections, res) + return ec.marshalNMapping2ᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐMapping(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_SubjectEdge_node(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Posix_mapping(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "SubjectEdge", + Object: "Posix", Field: field, - IsMethod: false, + IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": - return ec.fieldContext_Subject_id(ctx, field) - case "name": - return ec.fieldContext_Subject_name(ctx, field) - case "subjectDigests": - return ec.fieldContext_Subject_subjectDigests(ctx, field) - case "statement": - return ec.fieldContext_Subject_statement(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Subject", field.Name) + return ec.fieldContext_Mapping_id(ctx, field) + case "path": + return ec.fieldContext_Mapping_path(ctx, field) + case "type": + return ec.fieldContext_Mapping_type(ctx, field) + case "sha1": + return ec.fieldContext_Mapping_sha1(ctx, field) + case "sha256": + return ec.fieldContext_Mapping_sha256(ctx, field) + case "gitoidsha1": + return ec.fieldContext_Mapping_gitoidsha1(ctx, field) + case "gitoidsha256": + return ec.fieldContext_Mapping_gitoidsha256(ctx, field) + case "posix": + return ec.fieldContext_Mapping_posix(ctx, field) + case "omnitrail": + return ec.fieldContext_Mapping_omnitrail(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Mapping", field.Name) }, } return fc, nil } -func (ec *executionContext) _SubjectEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.SubjectEdge) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_SubjectEdge_cursor(ctx, field) +func (ec *executionContext) _Query_node(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_node(ctx, field) if err != nil { return graphql.Null } @@ -4269,38 +4448,46 @@ func (ec *executionContext) _SubjectEdge_cursor(ctx context.Context, field graph }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Cursor, nil + return ec.resolvers.Query().Node(rctx, fc.Args["id"].(int)) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(entgql.Cursor[int]) + res := resTmp.(ent.Noder) fc.Result = res - return ec.marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor(ctx, field.Selections, res) + return ec.marshalONode2githubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐNoder(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_SubjectEdge_cursor(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_node(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "SubjectEdge", + Object: "Query", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Cursor does not have child fields") + return nil, errors.New("FieldContext.Child cannot be called on type INTERFACE") }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_node_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _Timestamp_id(ctx context.Context, field graphql.CollectedField, obj *ent.Timestamp) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Timestamp_id(ctx, field) +func (ec *executionContext) _Query_nodes(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_nodes(ctx, field) if err != nil { return graphql.Null } @@ -4313,7 +4500,7 @@ func (ec *executionContext) _Timestamp_id(ctx context.Context, field graphql.Col }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.ID, nil + return ec.resolvers.Query().Nodes(rctx, fc.Args["ids"].([]int)) }) if err != nil { ec.Error(ctx, err) @@ -4325,26 +4512,37 @@ func (ec *executionContext) _Timestamp_id(ctx context.Context, field graphql.Col } return graphql.Null } - res := resTmp.(int) + res := resTmp.([]ent.Noder) fc.Result = res - return ec.marshalNID2int(ctx, field.Selections, res) + return ec.marshalNNode2ᚕgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐNoder(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Timestamp_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_nodes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Timestamp", + Object: "Query", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type ID does not have child fields") + return nil, errors.New("FieldContext.Child cannot be called on type INTERFACE") }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_nodes_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _Timestamp_type(ctx context.Context, field graphql.CollectedField, obj *ent.Timestamp) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Timestamp_type(ctx, field) +func (ec *executionContext) _Query_attestationPolicies(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_attestationPolicies(ctx, field) if err != nil { return graphql.Null } @@ -4357,7 +4555,7 @@ func (ec *executionContext) _Timestamp_type(ctx context.Context, field graphql.C }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Type, nil + return ec.resolvers.Query().AttestationPolicies(rctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["where"].(*ent.AttestationPolicyWhereInput)) }) if err != nil { ec.Error(ctx, err) @@ -4369,26 +4567,45 @@ func (ec *executionContext) _Timestamp_type(ctx context.Context, field graphql.C } return graphql.Null } - res := resTmp.(string) + res := resTmp.(*ent.AttestationPolicyConnection) fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) + return ec.marshalNAttestationPolicyConnection2ᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐAttestationPolicyConnection(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Timestamp_type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_attestationPolicies(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Timestamp", + Object: "Query", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + switch field.Name { + case "edges": + return ec.fieldContext_AttestationPolicyConnection_edges(ctx, field) + case "pageInfo": + return ec.fieldContext_AttestationPolicyConnection_pageInfo(ctx, field) + case "totalCount": + return ec.fieldContext_AttestationPolicyConnection_totalCount(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type AttestationPolicyConnection", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_attestationPolicies_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _Timestamp_timestamp(ctx context.Context, field graphql.CollectedField, obj *ent.Timestamp) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Timestamp_timestamp(ctx, field) +func (ec *executionContext) _Query_dsses(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_dsses(ctx, field) if err != nil { return graphql.Null } @@ -4401,7 +4618,7 @@ func (ec *executionContext) _Timestamp_timestamp(ctx context.Context, field grap }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Timestamp, nil + return ec.resolvers.Query().Dsses(rctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["where"].(*ent.DsseWhereInput)) }) if err != nil { ec.Error(ctx, err) @@ -4413,79 +4630,45 @@ func (ec *executionContext) _Timestamp_timestamp(ctx context.Context, field grap } return graphql.Null } - res := resTmp.(time.Time) + res := resTmp.(*ent.DsseConnection) fc.Result = res - return ec.marshalNTime2timeᚐTime(ctx, field.Selections, res) + return ec.marshalNDsseConnection2ᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐDsseConnection(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Timestamp_timestamp(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_dsses(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Timestamp", + Object: "Query", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Time does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _Timestamp_signature(ctx context.Context, field graphql.CollectedField, obj *ent.Timestamp) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Timestamp_signature(ctx, field) - if err != nil { - return graphql.Null + switch field.Name { + case "edges": + return ec.fieldContext_DsseConnection_edges(ctx, field) + case "pageInfo": + return ec.fieldContext_DsseConnection_pageInfo(ctx, field) + case "totalCount": + return ec.fieldContext_DsseConnection_totalCount(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type DsseConnection", field.Name) + }, } - ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null + err = ec.Recover(ctx, r) + ec.Error(ctx, err) } }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Signature(ctx) - }) - if err != nil { + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_dsses_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*ent.Signature) - fc.Result = res - return ec.marshalOSignature2ᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐSignature(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Timestamp_signature(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Timestamp", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_Signature_id(ctx, field) - case "keyID": - return ec.fieldContext_Signature_keyID(ctx, field) - case "signature": - return ec.fieldContext_Signature_signature(ctx, field) - case "dsse": - return ec.fieldContext_Signature_dsse(ctx, field) - case "timestamps": - return ec.fieldContext_Signature_timestamps(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Signature", field.Name) - }, + return fc, err } return fc, nil } -func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Directive_name(ctx, field) +func (ec *executionContext) _Query_subjects(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_subjects(ctx, field) if err != nil { return graphql.Null } @@ -4498,7 +4681,7 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Name, nil + return ec.resolvers.Query().Subjects(rctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["where"].(*ent.SubjectWhereInput)) }) if err != nil { ec.Error(ctx, err) @@ -4510,26 +4693,45 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql } return graphql.Null } - res := resTmp.(string) + res := resTmp.(*ent.SubjectConnection) fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) + return ec.marshalNSubjectConnection2ᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐSubjectConnection(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Directive_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_subjects(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Directive", + Object: "Query", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + switch field.Name { + case "edges": + return ec.fieldContext_SubjectConnection_edges(ctx, field) + case "pageInfo": + return ec.fieldContext_SubjectConnection_pageInfo(ctx, field) + case "totalCount": + return ec.fieldContext_SubjectConnection_totalCount(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type SubjectConnection", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_subjects_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Directive_description(ctx, field) +func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query___type(ctx, field) if err != nil { return graphql.Null } @@ -4542,7 +4744,7 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Description(), nil + return ec.introspectType(fc.Args["name"].(string)) }) if err != nil { ec.Error(ctx, err) @@ -4551,26 +4753,59 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field if resTmp == nil { return graphql.Null } - res := resTmp.(*string) + res := resTmp.(*introspection.Type) fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) + return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Directive_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query___type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Directive", + Object: "Query", Field: field, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query___type_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Directive_locations(ctx, field) +func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query___schema(ctx, field) if err != nil { return graphql.Null } @@ -4583,38 +4818,49 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Locations, nil + return ec.introspectSchema() }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.([]string) + res := resTmp.(*introspection.Schema) fc.Result = res - return ec.marshalN__DirectiveLocation2ᚕstringᚄ(ctx, field.Selections, res) + return ec.marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Directive_locations(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query___schema(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Directive", + Object: "Query", Field: field, - IsMethod: false, + IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type __DirectiveLocation does not have child fields") + switch field.Name { + case "description": + return ec.fieldContext___Schema_description(ctx, field) + case "types": + return ec.fieldContext___Schema_types(ctx, field) + case "queryType": + return ec.fieldContext___Schema_queryType(ctx, field) + case "mutationType": + return ec.fieldContext___Schema_mutationType(ctx, field) + case "subscriptionType": + return ec.fieldContext___Schema_subscriptionType(ctx, field) + case "directives": + return ec.fieldContext___Schema_directives(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Schema", field.Name) }, } return fc, nil } -func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Directive_args(ctx, field) +func (ec *executionContext) _Signature_id(ctx context.Context, field graphql.CollectedField, obj *ent.Signature) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Signature_id(ctx, field) if err != nil { return graphql.Null } @@ -4627,7 +4873,7 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Args, nil + return obj.ID, nil }) if err != nil { ec.Error(ctx, err) @@ -4639,36 +4885,26 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql } return graphql.Null } - res := resTmp.([]introspection.InputValue) + res := resTmp.(int) fc.Result = res - return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) + return ec.marshalNID2int(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Directive_args(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Signature_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Directive", + Object: "Signature", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "name": - return ec.fieldContext___InputValue_name(ctx, field) - case "description": - return ec.fieldContext___InputValue_description(ctx, field) - case "type": - return ec.fieldContext___InputValue_type(ctx, field) - case "defaultValue": - return ec.fieldContext___InputValue_defaultValue(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + return nil, errors.New("field of type ID does not have child fields") }, } return fc, nil } -func (ec *executionContext) ___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Directive_isRepeatable(ctx, field) +func (ec *executionContext) _Signature_keyID(ctx context.Context, field graphql.CollectedField, obj *ent.Signature) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Signature_keyID(ctx, field) if err != nil { return graphql.Null } @@ -4681,7 +4917,7 @@ func (ec *executionContext) ___Directive_isRepeatable(ctx context.Context, field }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.IsRepeatable, nil + return obj.KeyID, nil }) if err != nil { ec.Error(ctx, err) @@ -4693,26 +4929,26 @@ func (ec *executionContext) ___Directive_isRepeatable(ctx context.Context, field } return graphql.Null } - res := resTmp.(bool) + res := resTmp.(string) fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Signature_keyID(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Directive", + Object: "Signature", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___EnumValue_name(ctx, field) +func (ec *executionContext) _Signature_signature(ctx context.Context, field graphql.CollectedField, obj *ent.Signature) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Signature_signature(ctx, field) if err != nil { return graphql.Null } @@ -4725,7 +4961,7 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Name, nil + return obj.Signature, nil }) if err != nil { ec.Error(ctx, err) @@ -4742,9 +4978,9 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___EnumValue_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Signature_signature(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__EnumValue", + Object: "Signature", Field: field, IsMethod: false, IsResolver: false, @@ -4755,8 +4991,8 @@ func (ec *executionContext) fieldContext___EnumValue_name(ctx context.Context, f return fc, nil } -func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___EnumValue_description(ctx, field) +func (ec *executionContext) _Signature_dsse(ctx context.Context, field graphql.CollectedField, obj *ent.Signature) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Signature_dsse(ctx, field) if err != nil { return graphql.Null } @@ -4769,7 +5005,7 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Description(), nil + return obj.Dsse(ctx) }) if err != nil { ec.Error(ctx, err) @@ -4778,26 +5014,40 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field if resTmp == nil { return graphql.Null } - res := resTmp.(*string) + res := resTmp.(*ent.Dsse) fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) + return ec.marshalODsse2ᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐDsse(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___EnumValue_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Signature_dsse(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__EnumValue", + Object: "Signature", Field: field, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_Dsse_id(ctx, field) + case "gitoidSha256": + return ec.fieldContext_Dsse_gitoidSha256(ctx, field) + case "payloadType": + return ec.fieldContext_Dsse_payloadType(ctx, field) + case "statement": + return ec.fieldContext_Dsse_statement(ctx, field) + case "signatures": + return ec.fieldContext_Dsse_signatures(ctx, field) + case "payloadDigests": + return ec.fieldContext_Dsse_payloadDigests(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Dsse", field.Name) }, } return fc, nil } -func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___EnumValue_isDeprecated(ctx, field) +func (ec *executionContext) _Signature_timestamps(ctx context.Context, field graphql.CollectedField, obj *ent.Signature) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Signature_timestamps(ctx, field) if err != nil { return graphql.Null } @@ -4810,38 +5060,45 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.IsDeprecated(), nil + return obj.Timestamps(ctx) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(bool) + res := resTmp.([]*ent.Timestamp) fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) + return ec.marshalOTimestamp2ᚕᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐTimestampᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Signature_timestamps(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__EnumValue", + Object: "Signature", Field: field, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_Timestamp_id(ctx, field) + case "type": + return ec.fieldContext_Timestamp_type(ctx, field) + case "timestamp": + return ec.fieldContext_Timestamp_timestamp(ctx, field) + case "signature": + return ec.fieldContext_Timestamp_signature(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Timestamp", field.Name) }, } return fc, nil } -func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___EnumValue_deprecationReason(ctx, field) +func (ec *executionContext) _Statement_id(ctx context.Context, field graphql.CollectedField, obj *ent.Statement) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Statement_id(ctx, field) if err != nil { return graphql.Null } @@ -4854,35 +5111,38 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.DeprecationReason(), nil + return obj.ID, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*string) + res := resTmp.(int) fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) + return ec.marshalNID2int(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Statement_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__EnumValue", + Object: "Statement", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type ID does not have child fields") }, } return fc, nil } -func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Field_name(ctx, field) +func (ec *executionContext) _Statement_predicate(ctx context.Context, field graphql.CollectedField, obj *ent.Statement) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Statement_predicate(ctx, field) if err != nil { return graphql.Null } @@ -4895,7 +5155,7 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Name, nil + return obj.Predicate, nil }) if err != nil { ec.Error(ctx, err) @@ -4912,9 +5172,9 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Field_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Statement_predicate(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Field", + Object: "Statement", Field: field, IsMethod: false, IsResolver: false, @@ -4925,8 +5185,8 @@ func (ec *executionContext) fieldContext___Field_name(ctx context.Context, field return fc, nil } -func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Field_description(ctx, field) +func (ec *executionContext) _Statement_subjects(ctx context.Context, field graphql.CollectedField, obj *ent.Statement) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Statement_subjects(ctx, field) if err != nil { return graphql.Null } @@ -4939,35 +5199,57 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Description(), nil + return obj.Subjects(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["where"].(*ent.SubjectWhereInput)) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*string) + res := resTmp.(*ent.SubjectConnection) fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) + return ec.marshalNSubjectConnection2ᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐSubjectConnection(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Field_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Statement_subjects(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Field", + Object: "Statement", Field: field, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + switch field.Name { + case "edges": + return ec.fieldContext_SubjectConnection_edges(ctx, field) + case "pageInfo": + return ec.fieldContext_SubjectConnection_pageInfo(ctx, field) + case "totalCount": + return ec.fieldContext_SubjectConnection_totalCount(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type SubjectConnection", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Statement_subjects_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Field_args(ctx, field) +func (ec *executionContext) _Statement_policy(ctx context.Context, field graphql.CollectedField, obj *ent.Statement) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Statement_policy(ctx, field) if err != nil { return graphql.Null } @@ -4980,48 +5262,43 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Args, nil + return obj.Policy(ctx) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.([]introspection.InputValue) + res := resTmp.(*ent.AttestationPolicy) fc.Result = res - return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) + return ec.marshalOAttestationPolicy2ᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐAttestationPolicy(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Field_args(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Statement_policy(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Field", + Object: "Statement", Field: field, - IsMethod: false, + IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { + case "id": + return ec.fieldContext_AttestationPolicy_id(ctx, field) case "name": - return ec.fieldContext___InputValue_name(ctx, field) - case "description": - return ec.fieldContext___InputValue_description(ctx, field) - case "type": - return ec.fieldContext___InputValue_type(ctx, field) - case "defaultValue": - return ec.fieldContext___InputValue_defaultValue(ctx, field) + return ec.fieldContext_AttestationPolicy_name(ctx, field) + case "statement": + return ec.fieldContext_AttestationPolicy_statement(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + return nil, fmt.Errorf("no field named %q was found under type AttestationPolicy", field.Name) }, } return fc, nil } -func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Field_type(ctx, field) +func (ec *executionContext) _Statement_attestationCollections(ctx context.Context, field graphql.CollectedField, obj *ent.Statement) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Statement_attestationCollections(ctx, field) if err != nil { return graphql.Null } @@ -5034,60 +5311,45 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Type, nil + return obj.AttestationCollections(ctx) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(*introspection.Type) + res := resTmp.(*ent.AttestationCollection) fc.Result = res - return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalOAttestationCollection2ᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐAttestationCollection(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Field_type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Statement_attestationCollections(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Field", + Object: "Statement", Field: field, - IsMethod: false, + IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) + case "id": + return ec.fieldContext_AttestationCollection_id(ctx, field) case "name": - return ec.fieldContext___Type_name(ctx, field) - case "description": - return ec.fieldContext___Type_description(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) + return ec.fieldContext_AttestationCollection_name(ctx, field) + case "attestations": + return ec.fieldContext_AttestationCollection_attestations(ctx, field) + case "statement": + return ec.fieldContext_AttestationCollection_statement(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + return nil, fmt.Errorf("no field named %q was found under type AttestationCollection", field.Name) }, } return fc, nil } -func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Field_isDeprecated(ctx, field) +func (ec *executionContext) _Statement_dsse(ctx context.Context, field graphql.CollectedField, obj *ent.Statement) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Statement_dsse(ctx, field) if err != nil { return graphql.Null } @@ -5100,38 +5362,49 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.IsDeprecated(), nil + return obj.Dsse(ctx) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(bool) + res := resTmp.([]*ent.Dsse) fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) + return ec.marshalODsse2ᚕᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐDsseᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Field_isDeprecated(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Statement_dsse(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Field", + Object: "Statement", Field: field, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_Dsse_id(ctx, field) + case "gitoidSha256": + return ec.fieldContext_Dsse_gitoidSha256(ctx, field) + case "payloadType": + return ec.fieldContext_Dsse_payloadType(ctx, field) + case "statement": + return ec.fieldContext_Dsse_statement(ctx, field) + case "signatures": + return ec.fieldContext_Dsse_signatures(ctx, field) + case "payloadDigests": + return ec.fieldContext_Dsse_payloadDigests(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Dsse", field.Name) }, } return fc, nil } -func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Field_deprecationReason(ctx, field) +func (ec *executionContext) _Subject_id(ctx context.Context, field graphql.CollectedField, obj *ent.Subject) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Subject_id(ctx, field) if err != nil { return graphql.Null } @@ -5144,35 +5417,38 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.DeprecationReason(), nil + return obj.ID, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*string) + res := resTmp.(int) fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) + return ec.marshalNID2int(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Field_deprecationReason(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Subject_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Field", + Object: "Subject", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type ID does not have child fields") }, } return fc, nil } -func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___InputValue_name(ctx, field) +func (ec *executionContext) _Subject_name(ctx context.Context, field graphql.CollectedField, obj *ent.Subject) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Subject_name(ctx, field) if err != nil { return graphql.Null } @@ -5202,9 +5478,9 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___InputValue_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Subject_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__InputValue", + Object: "Subject", Field: field, IsMethod: false, IsResolver: false, @@ -5215,8 +5491,8 @@ func (ec *executionContext) fieldContext___InputValue_name(ctx context.Context, return fc, nil } -func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___InputValue_description(ctx, field) +func (ec *executionContext) _Subject_subjectDigests(ctx context.Context, field graphql.CollectedField, obj *ent.Subject) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Subject_subjectDigests(ctx, field) if err != nil { return graphql.Null } @@ -5229,7 +5505,7 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Description(), nil + return obj.SubjectDigests(ctx) }) if err != nil { ec.Error(ctx, err) @@ -5238,26 +5514,36 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field if resTmp == nil { return graphql.Null } - res := resTmp.(*string) + res := resTmp.([]*ent.SubjectDigest) fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) + return ec.marshalOSubjectDigest2ᚕᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐSubjectDigestᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___InputValue_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Subject_subjectDigests(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__InputValue", + Object: "Subject", Field: field, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_SubjectDigest_id(ctx, field) + case "algorithm": + return ec.fieldContext_SubjectDigest_algorithm(ctx, field) + case "value": + return ec.fieldContext_SubjectDigest_value(ctx, field) + case "subject": + return ec.fieldContext_SubjectDigest_subject(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type SubjectDigest", field.Name) }, } return fc, nil } -func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___InputValue_type(ctx, field) +func (ec *executionContext) _Subject_statement(ctx context.Context, field graphql.CollectedField, obj *ent.Subject) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Subject_statement(ctx, field) if err != nil { return graphql.Null } @@ -5270,60 +5556,49 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Type, nil + return obj.Statement(ctx) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(*introspection.Type) + res := resTmp.(*ent.Statement) fc.Result = res - return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalOStatement2ᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐStatement(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___InputValue_type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Subject_statement(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__InputValue", + Object: "Subject", Field: field, - IsMethod: false, + IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) - case "name": - return ec.fieldContext___Type_name(ctx, field) - case "description": - return ec.fieldContext___Type_description(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) + case "id": + return ec.fieldContext_Statement_id(ctx, field) + case "predicate": + return ec.fieldContext_Statement_predicate(ctx, field) + case "subjects": + return ec.fieldContext_Statement_subjects(ctx, field) + case "policy": + return ec.fieldContext_Statement_policy(ctx, field) + case "attestationCollections": + return ec.fieldContext_Statement_attestationCollections(ctx, field) + case "dsse": + return ec.fieldContext_Statement_dsse(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + return nil, fmt.Errorf("no field named %q was found under type Statement", field.Name) }, } return fc, nil } -func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___InputValue_defaultValue(ctx, field) +func (ec *executionContext) _SubjectConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.SubjectConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_SubjectConnection_edges(ctx, field) if err != nil { return graphql.Null } @@ -5336,7 +5611,7 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.DefaultValue, nil + return obj.Edges, nil }) if err != nil { ec.Error(ctx, err) @@ -5345,26 +5620,32 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel if resTmp == nil { return graphql.Null } - res := resTmp.(*string) + res := resTmp.([]*ent.SubjectEdge) fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) + return ec.marshalOSubjectEdge2ᚕᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐSubjectEdge(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_SubjectConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__InputValue", + Object: "SubjectConnection", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + switch field.Name { + case "node": + return ec.fieldContext_SubjectEdge_node(ctx, field) + case "cursor": + return ec.fieldContext_SubjectEdge_cursor(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type SubjectEdge", field.Name) }, } return fc, nil } -func (ec *executionContext) ___Schema_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Schema_description(ctx, field) +func (ec *executionContext) _SubjectConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.SubjectConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_SubjectConnection_pageInfo(ctx, field) if err != nil { return graphql.Null } @@ -5377,35 +5658,48 @@ func (ec *executionContext) ___Schema_description(ctx context.Context, field gra }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Description(), nil + return obj.PageInfo, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*string) + res := resTmp.(entgql.PageInfo[int]) fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) + return ec.marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Schema_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_SubjectConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Schema", + Object: "SubjectConnection", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + switch field.Name { + case "hasNextPage": + return ec.fieldContext_PageInfo_hasNextPage(ctx, field) + case "hasPreviousPage": + return ec.fieldContext_PageInfo_hasPreviousPage(ctx, field) + case "startCursor": + return ec.fieldContext_PageInfo_startCursor(ctx, field) + case "endCursor": + return ec.fieldContext_PageInfo_endCursor(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) }, } return fc, nil } -func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Schema_types(ctx, field) +func (ec *executionContext) _SubjectConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.SubjectConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_SubjectConnection_totalCount(ctx, field) if err != nil { return graphql.Null } @@ -5418,7 +5712,7 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Types(), nil + return obj.TotalCount, nil }) if err != nil { ec.Error(ctx, err) @@ -5430,48 +5724,26 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C } return graphql.Null } - res := resTmp.([]introspection.Type) + res := resTmp.(int) fc.Result = res - return ec.marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) + return ec.marshalNInt2int(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Schema_types(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_SubjectConnection_totalCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Schema", + Object: "SubjectConnection", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) - case "name": - return ec.fieldContext___Type_name(ctx, field) - case "description": - return ec.fieldContext___Type_description(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } -func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Schema_queryType(ctx, field) +func (ec *executionContext) _SubjectDigest_id(ctx context.Context, field graphql.CollectedField, obj *ent.SubjectDigest) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_SubjectDigest_id(ctx, field) if err != nil { return graphql.Null } @@ -5484,7 +5756,7 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.QueryType(), nil + return obj.ID, nil }) if err != nil { ec.Error(ctx, err) @@ -5496,48 +5768,26 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph } return graphql.Null } - res := resTmp.(*introspection.Type) + res := resTmp.(int) fc.Result = res - return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalNID2int(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Schema_queryType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_SubjectDigest_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Schema", + Object: "SubjectDigest", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) - case "name": - return ec.fieldContext___Type_name(ctx, field) - case "description": - return ec.fieldContext___Type_description(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + return nil, errors.New("field of type ID does not have child fields") }, } return fc, nil } -func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Schema_mutationType(ctx, field) +func (ec *executionContext) _SubjectDigest_algorithm(ctx context.Context, field graphql.CollectedField, obj *ent.SubjectDigest) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_SubjectDigest_algorithm(ctx, field) if err != nil { return graphql.Null } @@ -5550,57 +5800,38 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.MutationType(), nil + return obj.Algorithm, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*introspection.Type) + res := resTmp.(string) fc.Result = res - return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Schema_mutationType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_SubjectDigest_algorithm(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Schema", + Object: "SubjectDigest", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) - case "name": - return ec.fieldContext___Type_name(ctx, field) - case "description": - return ec.fieldContext___Type_description(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Schema_subscriptionType(ctx, field) +func (ec *executionContext) _SubjectDigest_value(ctx context.Context, field graphql.CollectedField, obj *ent.SubjectDigest) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_SubjectDigest_value(ctx, field) if err != nil { return graphql.Null } @@ -5613,57 +5844,38 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.SubscriptionType(), nil + return obj.Value, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*introspection.Type) + res := resTmp.(string) fc.Result = res - return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_SubjectDigest_value(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Schema", + Object: "SubjectDigest", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) - case "name": - return ec.fieldContext___Type_name(ctx, field) - case "description": - return ec.fieldContext___Type_description(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Schema_directives(ctx, field) +func (ec *executionContext) _SubjectDigest_subject(ctx context.Context, field graphql.CollectedField, obj *ent.SubjectDigest) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_SubjectDigest_subject(ctx, field) if err != nil { return graphql.Null } @@ -5676,50 +5888,45 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Directives(), nil + return obj.Subject(ctx) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.([]introspection.Directive) + res := resTmp.(*ent.Subject) fc.Result = res - return ec.marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ(ctx, field.Selections, res) + return ec.marshalOSubject2ᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐSubject(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Schema_directives(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_SubjectDigest_subject(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Schema", + Object: "SubjectDigest", Field: field, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "name": - return ec.fieldContext___Directive_name(ctx, field) - case "description": - return ec.fieldContext___Directive_description(ctx, field) - case "locations": - return ec.fieldContext___Directive_locations(ctx, field) - case "args": - return ec.fieldContext___Directive_args(ctx, field) - case "isRepeatable": - return ec.fieldContext___Directive_isRepeatable(ctx, field) + case "id": + return ec.fieldContext_Subject_id(ctx, field) + case "name": + return ec.fieldContext_Subject_name(ctx, field) + case "subjectDigests": + return ec.fieldContext_Subject_subjectDigests(ctx, field) + case "statement": + return ec.fieldContext_Subject_statement(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type __Directive", field.Name) + return nil, fmt.Errorf("no field named %q was found under type Subject", field.Name) }, } return fc, nil } -func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Type_kind(ctx, field) +func (ec *executionContext) _SubjectEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.SubjectEdge) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_SubjectEdge_node(ctx, field) if err != nil { return graphql.Null } @@ -5732,38 +5939,45 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Kind(), nil + return obj.Node, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(string) + res := resTmp.(*ent.Subject) fc.Result = res - return ec.marshalN__TypeKind2string(ctx, field.Selections, res) + return ec.marshalOSubject2ᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐSubject(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Type_kind(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_SubjectEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Type", + Object: "SubjectEdge", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type __TypeKind does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_Subject_id(ctx, field) + case "name": + return ec.fieldContext_Subject_name(ctx, field) + case "subjectDigests": + return ec.fieldContext_Subject_subjectDigests(ctx, field) + case "statement": + return ec.fieldContext_Subject_statement(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Subject", field.Name) }, } return fc, nil } -func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Type_name(ctx, field) +func (ec *executionContext) _SubjectEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.SubjectEdge) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_SubjectEdge_cursor(ctx, field) if err != nil { return graphql.Null } @@ -5776,35 +5990,38 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Name(), nil + return obj.Cursor, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*string) + res := resTmp.(entgql.Cursor[int]) fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) + return ec.marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Type_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_SubjectEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Type", + Object: "SubjectEdge", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type Cursor does not have child fields") }, } return fc, nil } -func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Type_description(ctx, field) +func (ec *executionContext) _Timestamp_id(ctx context.Context, field graphql.CollectedField, obj *ent.Timestamp) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Timestamp_id(ctx, field) if err != nil { return graphql.Null } @@ -5817,35 +6034,38 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Description(), nil + return obj.ID, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*string) + res := resTmp.(int) fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) + return ec.marshalNID2int(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Type_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Timestamp_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Type", + Object: "Timestamp", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type ID does not have child fields") }, } return fc, nil } -func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Type_fields(ctx, field) +func (ec *executionContext) _Timestamp_type(ctx context.Context, field graphql.CollectedField, obj *ent.Timestamp) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Timestamp_type(ctx, field) if err != nil { return graphql.Null } @@ -5858,60 +6078,38 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Fields(fc.Args["includeDeprecated"].(bool)), nil + return obj.Type, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.([]introspection.Field) + res := resTmp.(string) fc.Result = res - return ec.marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Type_fields(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Timestamp_type(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Type", + Object: "Timestamp", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "name": - return ec.fieldContext___Field_name(ctx, field) - case "description": - return ec.fieldContext___Field_description(ctx, field) - case "args": - return ec.fieldContext___Field_args(ctx, field) - case "type": - return ec.fieldContext___Field_type(ctx, field) - case "isDeprecated": - return ec.fieldContext___Field_isDeprecated(ctx, field) - case "deprecationReason": - return ec.fieldContext___Field_deprecationReason(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Field", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field___Type_fields_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Type_interfaces(ctx, field) +func (ec *executionContext) _Timestamp_timestamp(ctx context.Context, field graphql.CollectedField, obj *ent.Timestamp) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Timestamp_timestamp(ctx, field) if err != nil { return graphql.Null } @@ -5924,57 +6122,38 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Interfaces(), nil + return obj.Timestamp, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.([]introspection.Type) + res := resTmp.(time.Time) fc.Result = res - return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) + return ec.marshalNTime2timeᚐTime(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Type_interfaces(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Timestamp_timestamp(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Type", + Object: "Timestamp", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) - case "name": - return ec.fieldContext___Type_name(ctx, field) - case "description": - return ec.fieldContext___Type_description(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + return nil, errors.New("field of type Time does not have child fields") }, } return fc, nil } -func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Type_possibleTypes(ctx, field) +func (ec *executionContext) _Timestamp_signature(ctx context.Context, field graphql.CollectedField, obj *ent.Timestamp) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Timestamp_signature(ctx, field) if err != nil { return graphql.Null } @@ -5987,7 +6166,7 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.PossibleTypes(), nil + return obj.Signature(ctx) }) if err != nil { ec.Error(ctx, err) @@ -5996,48 +6175,38 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra if resTmp == nil { return graphql.Null } - res := resTmp.([]introspection.Type) + res := resTmp.(*ent.Signature) fc.Result = res - return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) + return ec.marshalOSignature2ᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐSignature(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Type_possibleTypes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Timestamp_signature(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Type", + Object: "Timestamp", Field: field, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) - case "name": - return ec.fieldContext___Type_name(ctx, field) - case "description": - return ec.fieldContext___Type_description(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) + case "id": + return ec.fieldContext_Signature_id(ctx, field) + case "keyID": + return ec.fieldContext_Signature_keyID(ctx, field) + case "signature": + return ec.fieldContext_Signature_signature(ctx, field) + case "dsse": + return ec.fieldContext_Signature_dsse(ctx, field) + case "timestamps": + return ec.fieldContext_Signature_timestamps(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + return nil, fmt.Errorf("no field named %q was found under type Signature", field.Name) }, } return fc, nil } -func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Type_enumValues(ctx, field) +func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_name(ctx, field) if err != nil { return graphql.Null } @@ -6050,56 +6219,123 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.EnumValues(fc.Args["includeDeprecated"].(bool)), nil + return obj.Name, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.([]introspection.EnumValue) + res := resTmp.(string) fc.Result = res - return ec.marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Type_enumValues(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___Directive_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Type", + Object: "__Directive", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "name": - return ec.fieldContext___EnumValue_name(ctx, field) - case "description": - return ec.fieldContext___EnumValue_description(ctx, field) - case "isDeprecated": - return ec.fieldContext___EnumValue_isDeprecated(ctx, field) - case "deprecationReason": - return ec.fieldContext___EnumValue_deprecationReason(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __EnumValue", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } + return fc, nil +} + +func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null } }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Directive_description(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_locations(ctx, field) + if err != nil { + return graphql.Null + } ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field___Type_enumValues_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Locations, nil + }) + if err != nil { ec.Error(ctx, err) - return fc, err + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.([]string) + fc.Result = res + return ec.marshalN__DirectiveLocation2ᚕstringᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Directive_locations(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type __DirectiveLocation does not have child fields") + }, } return fc, nil } -func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Type_inputFields(ctx, field) +func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_args(ctx, field) if err != nil { return graphql.Null } @@ -6112,25 +6348,28 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.InputFields(), nil + return obj.Args, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } res := resTmp.([]introspection.InputValue) fc.Result = res - return ec.marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) + return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Type_inputFields(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___Directive_args(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Type", + Object: "__Directive", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { @@ -6149,8 +6388,8 @@ func (ec *executionContext) fieldContext___Type_inputFields(ctx context.Context, return fc, nil } -func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Type_ofType(ctx, field) +func (ec *executionContext) ___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_isRepeatable(ctx, field) if err != nil { return graphql.Null } @@ -6163,57 +6402,38 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.OfType(), nil + return obj.IsRepeatable, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*introspection.Type) + res := resTmp.(bool) fc.Result = res - return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Type_ofType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___Directive_isRepeatable(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Type", + Object: "__Directive", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) - case "name": - return ec.fieldContext___Type_name(ctx, field) - case "description": - return ec.fieldContext___Type_description(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + return nil, errors.New("field of type Boolean does not have child fields") }, } return fc, nil } -func (ec *executionContext) ___Type_specifiedByURL(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Type_specifiedByURL(ctx, field) +func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_name(ctx, field) if err != nil { return graphql.Null } @@ -6226,7 +6446,51 @@ func (ec *executionContext) ___Type_specifiedByURL(ctx context.Context, field gr }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.SpecifiedByURL(), nil + return obj.Name, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___EnumValue_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil }) if err != nil { ec.Error(ctx, err) @@ -6240,9 +6504,9 @@ func (ec *executionContext) ___Type_specifiedByURL(ctx context.Context, field gr return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Type_specifiedByURL(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___EnumValue_description(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Type", + Object: "__EnumValue", Field: field, IsMethod: true, IsResolver: false, @@ -6253,41 +6517,3542 @@ func (ec *executionContext) fieldContext___Type_specifiedByURL(ctx context.Conte return fc, nil } -// endregion **************************** field.gotpl ***************************** - -// region **************************** input.gotpl ***************************** +func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_isDeprecated(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.IsDeprecated(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(bool) + fc.Result = res + return ec.marshalNBoolean2bool(ctx, field.Selections, res) +} -func (ec *executionContext) unmarshalInputAttestationCollectionWhereInput(ctx context.Context, obj interface{}) (ent.AttestationCollectionWhereInput, error) { - var it ent.AttestationCollectionWhereInput - asMap := map[string]interface{}{} - for k, v := range obj.(map[string]interface{}) { - asMap[k] = v +func (ec *executionContext) fieldContext___EnumValue_isDeprecated(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, } + return fc, nil +} - fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "name", "nameNEQ", "nameIn", "nameNotIn", "nameGT", "nameGTE", "nameLT", "nameLTE", "nameContains", "nameHasPrefix", "nameHasSuffix", "nameEqualFold", "nameContainsFold", "hasAttestations", "hasAttestationsWith", "hasStatement", "hasStatementWith"} - for _, k := range fieldsInOrder { - v, ok := asMap[k] - if !ok { - continue +func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_deprecationReason(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null } - switch k { - case "not": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("not")) - data, err := ec.unmarshalOAttestationCollectionWhereInput2ᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐAttestationCollectionWhereInput(ctx, v) - if err != nil { - return it, err - } - it.Not = data - case "and": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("and")) - data, err := ec.unmarshalOAttestationCollectionWhereInput2ᚕᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐAttestationCollectionWhereInputᚄ(ctx, v) - if err != nil { - return it, err - } - it.And = data - case "or": + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DeprecationReason(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___EnumValue_deprecationReason(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Name, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_description(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_args(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Args, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.([]introspection.InputValue) + fc.Result = res + return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_args(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___InputValue_name(ctx, field) + case "description": + return ec.fieldContext___InputValue_description(ctx, field) + case "type": + return ec.fieldContext___InputValue_type(ctx, field) + case "defaultValue": + return ec.fieldContext___InputValue_defaultValue(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_type(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Type, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_type(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_isDeprecated(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.IsDeprecated(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(bool) + fc.Result = res + return ec.marshalNBoolean2bool(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_isDeprecated(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_deprecationReason(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DeprecationReason(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_deprecationReason(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Name, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_description(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_type(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Type, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_type(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_defaultValue(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DefaultValue, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_defaultValue(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_description(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_types(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Types(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.([]introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_types(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_queryType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.QueryType(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_queryType(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_mutationType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.MutationType(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_mutationType(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_subscriptionType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.SubscriptionType(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_subscriptionType(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_directives(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Directives(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.([]introspection.Directive) + fc.Result = res + return ec.marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_directives(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___Directive_name(ctx, field) + case "description": + return ec.fieldContext___Directive_description(ctx, field) + case "locations": + return ec.fieldContext___Directive_locations(ctx, field) + case "args": + return ec.fieldContext___Directive_args(ctx, field) + case "isRepeatable": + return ec.fieldContext___Directive_isRepeatable(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Directive", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_kind(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Kind(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalN__TypeKind2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_kind(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type __TypeKind does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Name(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_description(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_fields(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Fields(fc.Args["includeDeprecated"].(bool)), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Field) + fc.Result = res + return ec.marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_fields(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___Field_name(ctx, field) + case "description": + return ec.fieldContext___Field_description(ctx, field) + case "args": + return ec.fieldContext___Field_args(ctx, field) + case "type": + return ec.fieldContext___Field_type(ctx, field) + case "isDeprecated": + return ec.fieldContext___Field_isDeprecated(ctx, field) + case "deprecationReason": + return ec.fieldContext___Field_deprecationReason(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Field", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field___Type_fields_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_interfaces(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Interfaces(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_interfaces(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_possibleTypes(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.PossibleTypes(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_possibleTypes(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_enumValues(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.EnumValues(fc.Args["includeDeprecated"].(bool)), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.EnumValue) + fc.Result = res + return ec.marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_enumValues(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___EnumValue_name(ctx, field) + case "description": + return ec.fieldContext___EnumValue_description(ctx, field) + case "isDeprecated": + return ec.fieldContext___EnumValue_isDeprecated(ctx, field) + case "deprecationReason": + return ec.fieldContext___EnumValue_deprecationReason(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __EnumValue", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field___Type_enumValues_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_inputFields(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.InputFields(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.InputValue) + fc.Result = res + return ec.marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_inputFields(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___InputValue_name(ctx, field) + case "description": + return ec.fieldContext___InputValue_description(ctx, field) + case "type": + return ec.fieldContext___InputValue_type(ctx, field) + case "defaultValue": + return ec.fieldContext___InputValue_defaultValue(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_ofType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.OfType(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_ofType(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_specifiedByURL(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_specifiedByURL(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.SpecifiedByURL(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_specifiedByURL(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +// endregion **************************** field.gotpl ***************************** + +// region **************************** input.gotpl ***************************** + +func (ec *executionContext) unmarshalInputAttestationCollectionWhereInput(ctx context.Context, obj interface{}) (ent.AttestationCollectionWhereInput, error) { + var it ent.AttestationCollectionWhereInput + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "name", "nameNEQ", "nameIn", "nameNotIn", "nameGT", "nameGTE", "nameLT", "nameLTE", "nameContains", "nameHasPrefix", "nameHasSuffix", "nameEqualFold", "nameContainsFold", "hasAttestations", "hasAttestationsWith", "hasStatement", "hasStatementWith"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "not": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("not")) + data, err := ec.unmarshalOAttestationCollectionWhereInput2ᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐAttestationCollectionWhereInput(ctx, v) + if err != nil { + return it, err + } + it.Not = data + case "and": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("and")) + data, err := ec.unmarshalOAttestationCollectionWhereInput2ᚕᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐAttestationCollectionWhereInputᚄ(ctx, v) + if err != nil { + return it, err + } + it.And = data + case "or": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("or")) + data, err := ec.unmarshalOAttestationCollectionWhereInput2ᚕᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐAttestationCollectionWhereInputᚄ(ctx, v) + if err != nil { + return it, err + } + it.Or = data + case "id": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.ID = data + case "idNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNEQ")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.IDNEQ = data + case "idIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idIn")) + data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) + if err != nil { + return it, err + } + it.IDIn = data + case "idNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNotIn")) + data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) + if err != nil { + return it, err + } + it.IDNotIn = data + case "idGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGT")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.IDGT = data + case "idGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGTE")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.IDGTE = data + case "idLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLT")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.IDLT = data + case "idLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLTE")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.IDLTE = data + case "name": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Name = data + case "nameNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNEQ")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameNEQ = data + case "nameIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.NameIn = data + case "nameNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNotIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.NameNotIn = data + case "nameGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameGT = data + case "nameGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameGTE = data + case "nameLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameLT = data + case "nameLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameLTE = data + case "nameContains": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContains")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameContains = data + case "nameHasPrefix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasPrefix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameHasPrefix = data + case "nameHasSuffix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasSuffix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameHasSuffix = data + case "nameEqualFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameEqualFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameEqualFold = data + case "nameContainsFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContainsFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameContainsFold = data + case "hasAttestations": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasAttestations")) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + if err != nil { + return it, err + } + it.HasAttestations = data + case "hasAttestationsWith": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasAttestationsWith")) + data, err := ec.unmarshalOAttestationWhereInput2ᚕᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐAttestationWhereInputᚄ(ctx, v) + if err != nil { + return it, err + } + it.HasAttestationsWith = data + case "hasStatement": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasStatement")) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + if err != nil { + return it, err + } + it.HasStatement = data + case "hasStatementWith": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasStatementWith")) + data, err := ec.unmarshalOStatementWhereInput2ᚕᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐStatementWhereInputᚄ(ctx, v) + if err != nil { + return it, err + } + it.HasStatementWith = data + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputAttestationPolicyWhereInput(ctx context.Context, obj interface{}) (ent.AttestationPolicyWhereInput, error) { + var it ent.AttestationPolicyWhereInput + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "name", "nameNEQ", "nameIn", "nameNotIn", "nameGT", "nameGTE", "nameLT", "nameLTE", "nameContains", "nameHasPrefix", "nameHasSuffix", "nameEqualFold", "nameContainsFold", "hasStatement", "hasStatementWith"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "not": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("not")) + data, err := ec.unmarshalOAttestationPolicyWhereInput2ᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐAttestationPolicyWhereInput(ctx, v) + if err != nil { + return it, err + } + it.Not = data + case "and": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("and")) + data, err := ec.unmarshalOAttestationPolicyWhereInput2ᚕᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐAttestationPolicyWhereInputᚄ(ctx, v) + if err != nil { + return it, err + } + it.And = data + case "or": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("or")) + data, err := ec.unmarshalOAttestationPolicyWhereInput2ᚕᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐAttestationPolicyWhereInputᚄ(ctx, v) + if err != nil { + return it, err + } + it.Or = data + case "id": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.ID = data + case "idNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNEQ")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.IDNEQ = data + case "idIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idIn")) + data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) + if err != nil { + return it, err + } + it.IDIn = data + case "idNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNotIn")) + data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) + if err != nil { + return it, err + } + it.IDNotIn = data + case "idGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGT")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.IDGT = data + case "idGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGTE")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.IDGTE = data + case "idLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLT")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.IDLT = data + case "idLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLTE")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.IDLTE = data + case "name": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Name = data + case "nameNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNEQ")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameNEQ = data + case "nameIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.NameIn = data + case "nameNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNotIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.NameNotIn = data + case "nameGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameGT = data + case "nameGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameGTE = data + case "nameLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameLT = data + case "nameLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameLTE = data + case "nameContains": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContains")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameContains = data + case "nameHasPrefix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasPrefix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameHasPrefix = data + case "nameHasSuffix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasSuffix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameHasSuffix = data + case "nameEqualFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameEqualFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameEqualFold = data + case "nameContainsFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContainsFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameContainsFold = data + case "hasStatement": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasStatement")) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + if err != nil { + return it, err + } + it.HasStatement = data + case "hasStatementWith": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasStatementWith")) + data, err := ec.unmarshalOStatementWhereInput2ᚕᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐStatementWhereInputᚄ(ctx, v) + if err != nil { + return it, err + } + it.HasStatementWith = data + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputAttestationWhereInput(ctx context.Context, obj interface{}) (ent.AttestationWhereInput, error) { + var it ent.AttestationWhereInput + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "type", "typeNEQ", "typeIn", "typeNotIn", "typeGT", "typeGTE", "typeLT", "typeLTE", "typeContains", "typeHasPrefix", "typeHasSuffix", "typeEqualFold", "typeContainsFold", "hasOmnitrail", "hasOmnitrailWith", "hasAttestationCollection", "hasAttestationCollectionWith"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "not": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("not")) + data, err := ec.unmarshalOAttestationWhereInput2ᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐAttestationWhereInput(ctx, v) + if err != nil { + return it, err + } + it.Not = data + case "and": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("and")) + data, err := ec.unmarshalOAttestationWhereInput2ᚕᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐAttestationWhereInputᚄ(ctx, v) + if err != nil { + return it, err + } + it.And = data + case "or": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("or")) + data, err := ec.unmarshalOAttestationWhereInput2ᚕᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐAttestationWhereInputᚄ(ctx, v) + if err != nil { + return it, err + } + it.Or = data + case "id": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.ID = data + case "idNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNEQ")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.IDNEQ = data + case "idIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idIn")) + data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) + if err != nil { + return it, err + } + it.IDIn = data + case "idNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNotIn")) + data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) + if err != nil { + return it, err + } + it.IDNotIn = data + case "idGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGT")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.IDGT = data + case "idGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGTE")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.IDGTE = data + case "idLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLT")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.IDLT = data + case "idLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLTE")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.IDLTE = data + case "type": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("type")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Type = data + case "typeNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("typeNEQ")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.TypeNEQ = data + case "typeIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("typeIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.TypeIn = data + case "typeNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("typeNotIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.TypeNotIn = data + case "typeGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("typeGT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.TypeGT = data + case "typeGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("typeGTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.TypeGTE = data + case "typeLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("typeLT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.TypeLT = data + case "typeLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("typeLTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.TypeLTE = data + case "typeContains": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("typeContains")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.TypeContains = data + case "typeHasPrefix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("typeHasPrefix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.TypeHasPrefix = data + case "typeHasSuffix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("typeHasSuffix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.TypeHasSuffix = data + case "typeEqualFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("typeEqualFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.TypeEqualFold = data + case "typeContainsFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("typeContainsFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.TypeContainsFold = data + case "hasOmnitrail": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasOmnitrail")) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + if err != nil { + return it, err + } + it.HasOmnitrail = data + case "hasOmnitrailWith": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasOmnitrailWith")) + data, err := ec.unmarshalOOmnitrailWhereInput2ᚕᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐOmnitrailWhereInputᚄ(ctx, v) + if err != nil { + return it, err + } + it.HasOmnitrailWith = data + case "hasAttestationCollection": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasAttestationCollection")) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + if err != nil { + return it, err + } + it.HasAttestationCollection = data + case "hasAttestationCollectionWith": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasAttestationCollectionWith")) + data, err := ec.unmarshalOAttestationCollectionWhereInput2ᚕᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐAttestationCollectionWhereInputᚄ(ctx, v) + if err != nil { + return it, err + } + it.HasAttestationCollectionWith = data + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputDsseWhereInput(ctx context.Context, obj interface{}) (ent.DsseWhereInput, error) { + var it ent.DsseWhereInput + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "gitoidSha256", "gitoidSha256NEQ", "gitoidSha256In", "gitoidSha256NotIn", "gitoidSha256GT", "gitoidSha256GTE", "gitoidSha256LT", "gitoidSha256LTE", "gitoidSha256Contains", "gitoidSha256HasPrefix", "gitoidSha256HasSuffix", "gitoidSha256EqualFold", "gitoidSha256ContainsFold", "payloadType", "payloadTypeNEQ", "payloadTypeIn", "payloadTypeNotIn", "payloadTypeGT", "payloadTypeGTE", "payloadTypeLT", "payloadTypeLTE", "payloadTypeContains", "payloadTypeHasPrefix", "payloadTypeHasSuffix", "payloadTypeEqualFold", "payloadTypeContainsFold", "hasStatement", "hasStatementWith", "hasSignatures", "hasSignaturesWith", "hasPayloadDigests", "hasPayloadDigestsWith"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "not": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("not")) + data, err := ec.unmarshalODsseWhereInput2ᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐDsseWhereInput(ctx, v) + if err != nil { + return it, err + } + it.Not = data + case "and": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("and")) + data, err := ec.unmarshalODsseWhereInput2ᚕᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐDsseWhereInputᚄ(ctx, v) + if err != nil { + return it, err + } + it.And = data + case "or": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("or")) + data, err := ec.unmarshalODsseWhereInput2ᚕᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐDsseWhereInputᚄ(ctx, v) + if err != nil { + return it, err + } + it.Or = data + case "id": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.ID = data + case "idNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNEQ")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.IDNEQ = data + case "idIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idIn")) + data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) + if err != nil { + return it, err + } + it.IDIn = data + case "idNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNotIn")) + data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) + if err != nil { + return it, err + } + it.IDNotIn = data + case "idGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGT")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.IDGT = data + case "idGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGTE")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.IDGTE = data + case "idLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLT")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.IDLT = data + case "idLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLTE")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.IDLTE = data + case "gitoidSha256": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("gitoidSha256")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.GitoidSha256 = data + case "gitoidSha256NEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("gitoidSha256NEQ")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.GitoidSha256NEQ = data + case "gitoidSha256In": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("gitoidSha256In")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.GitoidSha256In = data + case "gitoidSha256NotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("gitoidSha256NotIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.GitoidSha256NotIn = data + case "gitoidSha256GT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("gitoidSha256GT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.GitoidSha256GT = data + case "gitoidSha256GTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("gitoidSha256GTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.GitoidSha256GTE = data + case "gitoidSha256LT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("gitoidSha256LT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.GitoidSha256LT = data + case "gitoidSha256LTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("gitoidSha256LTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.GitoidSha256LTE = data + case "gitoidSha256Contains": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("gitoidSha256Contains")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.GitoidSha256Contains = data + case "gitoidSha256HasPrefix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("gitoidSha256HasPrefix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.GitoidSha256HasPrefix = data + case "gitoidSha256HasSuffix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("gitoidSha256HasSuffix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.GitoidSha256HasSuffix = data + case "gitoidSha256EqualFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("gitoidSha256EqualFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.GitoidSha256EqualFold = data + case "gitoidSha256ContainsFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("gitoidSha256ContainsFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.GitoidSha256ContainsFold = data + case "payloadType": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("payloadType")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.PayloadType = data + case "payloadTypeNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("payloadTypeNEQ")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.PayloadTypeNEQ = data + case "payloadTypeIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("payloadTypeIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.PayloadTypeIn = data + case "payloadTypeNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("payloadTypeNotIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.PayloadTypeNotIn = data + case "payloadTypeGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("payloadTypeGT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.PayloadTypeGT = data + case "payloadTypeGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("payloadTypeGTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.PayloadTypeGTE = data + case "payloadTypeLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("payloadTypeLT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.PayloadTypeLT = data + case "payloadTypeLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("payloadTypeLTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.PayloadTypeLTE = data + case "payloadTypeContains": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("payloadTypeContains")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.PayloadTypeContains = data + case "payloadTypeHasPrefix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("payloadTypeHasPrefix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.PayloadTypeHasPrefix = data + case "payloadTypeHasSuffix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("payloadTypeHasSuffix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.PayloadTypeHasSuffix = data + case "payloadTypeEqualFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("payloadTypeEqualFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.PayloadTypeEqualFold = data + case "payloadTypeContainsFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("payloadTypeContainsFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.PayloadTypeContainsFold = data + case "hasStatement": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasStatement")) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + if err != nil { + return it, err + } + it.HasStatement = data + case "hasStatementWith": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasStatementWith")) + data, err := ec.unmarshalOStatementWhereInput2ᚕᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐStatementWhereInputᚄ(ctx, v) + if err != nil { + return it, err + } + it.HasStatementWith = data + case "hasSignatures": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasSignatures")) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + if err != nil { + return it, err + } + it.HasSignatures = data + case "hasSignaturesWith": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasSignaturesWith")) + data, err := ec.unmarshalOSignatureWhereInput2ᚕᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐSignatureWhereInputᚄ(ctx, v) + if err != nil { + return it, err + } + it.HasSignaturesWith = data + case "hasPayloadDigests": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasPayloadDigests")) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + if err != nil { + return it, err + } + it.HasPayloadDigests = data + case "hasPayloadDigestsWith": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasPayloadDigestsWith")) + data, err := ec.unmarshalOPayloadDigestWhereInput2ᚕᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐPayloadDigestWhereInputᚄ(ctx, v) + if err != nil { + return it, err + } + it.HasPayloadDigestsWith = data + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputMappingWhereInput(ctx context.Context, obj interface{}) (ent.MappingWhereInput, error) { + var it ent.MappingWhereInput + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "path", "pathNEQ", "pathIn", "pathNotIn", "pathGT", "pathGTE", "pathLT", "pathLTE", "pathContains", "pathHasPrefix", "pathHasSuffix", "pathEqualFold", "pathContainsFold", "type", "typeNEQ", "typeIn", "typeNotIn", "typeGT", "typeGTE", "typeLT", "typeLTE", "typeContains", "typeHasPrefix", "typeHasSuffix", "typeEqualFold", "typeContainsFold", "sha1", "sha1NEQ", "sha1In", "sha1NotIn", "sha1GT", "sha1GTE", "sha1LT", "sha1LTE", "sha1Contains", "sha1HasPrefix", "sha1HasSuffix", "sha1EqualFold", "sha1ContainsFold", "sha256", "sha256NEQ", "sha256In", "sha256NotIn", "sha256GT", "sha256GTE", "sha256LT", "sha256LTE", "sha256Contains", "sha256HasPrefix", "sha256HasSuffix", "sha256EqualFold", "sha256ContainsFold", "gitoidsha1", "gitoidsha1NEQ", "gitoidsha1In", "gitoidsha1NotIn", "gitoidsha1GT", "gitoidsha1GTE", "gitoidsha1LT", "gitoidsha1LTE", "gitoidsha1Contains", "gitoidsha1HasPrefix", "gitoidsha1HasSuffix", "gitoidsha1EqualFold", "gitoidsha1ContainsFold", "gitoidsha256", "gitoidsha256NEQ", "gitoidsha256In", "gitoidsha256NotIn", "gitoidsha256GT", "gitoidsha256GTE", "gitoidsha256LT", "gitoidsha256LTE", "gitoidsha256Contains", "gitoidsha256HasPrefix", "gitoidsha256HasSuffix", "gitoidsha256EqualFold", "gitoidsha256ContainsFold", "hasPosix", "hasPosixWith", "hasOmnitrail", "hasOmnitrailWith"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "not": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("not")) + data, err := ec.unmarshalOMappingWhereInput2ᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐMappingWhereInput(ctx, v) + if err != nil { + return it, err + } + it.Not = data + case "and": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("and")) + data, err := ec.unmarshalOMappingWhereInput2ᚕᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐMappingWhereInputᚄ(ctx, v) + if err != nil { + return it, err + } + it.And = data + case "or": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("or")) + data, err := ec.unmarshalOMappingWhereInput2ᚕᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐMappingWhereInputᚄ(ctx, v) + if err != nil { + return it, err + } + it.Or = data + case "id": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.ID = data + case "idNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNEQ")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.IDNEQ = data + case "idIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idIn")) + data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) + if err != nil { + return it, err + } + it.IDIn = data + case "idNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNotIn")) + data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) + if err != nil { + return it, err + } + it.IDNotIn = data + case "idGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGT")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.IDGT = data + case "idGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGTE")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.IDGTE = data + case "idLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLT")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.IDLT = data + case "idLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLTE")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.IDLTE = data + case "path": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("path")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Path = data + case "pathNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathNEQ")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.PathNEQ = data + case "pathIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.PathIn = data + case "pathNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathNotIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.PathNotIn = data + case "pathGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathGT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.PathGT = data + case "pathGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathGTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.PathGTE = data + case "pathLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathLT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.PathLT = data + case "pathLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathLTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.PathLTE = data + case "pathContains": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathContains")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.PathContains = data + case "pathHasPrefix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathHasPrefix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.PathHasPrefix = data + case "pathHasSuffix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathHasSuffix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.PathHasSuffix = data + case "pathEqualFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathEqualFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.PathEqualFold = data + case "pathContainsFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathContainsFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.PathContainsFold = data + case "type": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("type")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Type = data + case "typeNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("typeNEQ")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.TypeNEQ = data + case "typeIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("typeIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.TypeIn = data + case "typeNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("typeNotIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.TypeNotIn = data + case "typeGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("typeGT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.TypeGT = data + case "typeGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("typeGTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.TypeGTE = data + case "typeLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("typeLT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.TypeLT = data + case "typeLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("typeLTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.TypeLTE = data + case "typeContains": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("typeContains")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.TypeContains = data + case "typeHasPrefix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("typeHasPrefix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.TypeHasPrefix = data + case "typeHasSuffix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("typeHasSuffix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.TypeHasSuffix = data + case "typeEqualFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("typeEqualFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.TypeEqualFold = data + case "typeContainsFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("typeContainsFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.TypeContainsFold = data + case "sha1": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sha1")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Sha1 = data + case "sha1NEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sha1NEQ")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Sha1NEQ = data + case "sha1In": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sha1In")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.Sha1In = data + case "sha1NotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sha1NotIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.Sha1NotIn = data + case "sha1GT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sha1GT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Sha1GT = data + case "sha1GTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sha1GTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Sha1GTE = data + case "sha1LT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sha1LT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Sha1LT = data + case "sha1LTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sha1LTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Sha1LTE = data + case "sha1Contains": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sha1Contains")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Sha1Contains = data + case "sha1HasPrefix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sha1HasPrefix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Sha1HasPrefix = data + case "sha1HasSuffix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sha1HasSuffix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Sha1HasSuffix = data + case "sha1EqualFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sha1EqualFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Sha1EqualFold = data + case "sha1ContainsFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sha1ContainsFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Sha1ContainsFold = data + case "sha256": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sha256")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Sha256 = data + case "sha256NEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sha256NEQ")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Sha256NEQ = data + case "sha256In": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sha256In")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.Sha256In = data + case "sha256NotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sha256NotIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.Sha256NotIn = data + case "sha256GT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sha256GT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Sha256GT = data + case "sha256GTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sha256GTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Sha256GTE = data + case "sha256LT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sha256LT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Sha256LT = data + case "sha256LTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sha256LTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Sha256LTE = data + case "sha256Contains": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sha256Contains")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Sha256Contains = data + case "sha256HasPrefix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sha256HasPrefix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Sha256HasPrefix = data + case "sha256HasSuffix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sha256HasSuffix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Sha256HasSuffix = data + case "sha256EqualFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sha256EqualFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Sha256EqualFold = data + case "sha256ContainsFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sha256ContainsFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Sha256ContainsFold = data + case "gitoidsha1": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("gitoidsha1")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.GitoidSha1 = data + case "gitoidsha1NEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("gitoidsha1NEQ")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.GitoidSha1NEQ = data + case "gitoidsha1In": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("gitoidsha1In")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.GitoidSha1In = data + case "gitoidsha1NotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("gitoidsha1NotIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.GitoidSha1NotIn = data + case "gitoidsha1GT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("gitoidsha1GT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.GitoidSha1GT = data + case "gitoidsha1GTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("gitoidsha1GTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.GitoidSha1GTE = data + case "gitoidsha1LT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("gitoidsha1LT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.GitoidSha1LT = data + case "gitoidsha1LTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("gitoidsha1LTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.GitoidSha1LTE = data + case "gitoidsha1Contains": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("gitoidsha1Contains")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.GitoidSha1Contains = data + case "gitoidsha1HasPrefix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("gitoidsha1HasPrefix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.GitoidSha1HasPrefix = data + case "gitoidsha1HasSuffix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("gitoidsha1HasSuffix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.GitoidSha1HasSuffix = data + case "gitoidsha1EqualFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("gitoidsha1EqualFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.GitoidSha1EqualFold = data + case "gitoidsha1ContainsFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("gitoidsha1ContainsFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.GitoidSha1ContainsFold = data + case "gitoidsha256": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("gitoidsha256")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.GitoidSha256 = data + case "gitoidsha256NEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("gitoidsha256NEQ")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.GitoidSha256NEQ = data + case "gitoidsha256In": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("gitoidsha256In")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.GitoidSha256In = data + case "gitoidsha256NotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("gitoidsha256NotIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.GitoidSha256NotIn = data + case "gitoidsha256GT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("gitoidsha256GT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.GitoidSha256GT = data + case "gitoidsha256GTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("gitoidsha256GTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.GitoidSha256GTE = data + case "gitoidsha256LT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("gitoidsha256LT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.GitoidSha256LT = data + case "gitoidsha256LTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("gitoidsha256LTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.GitoidSha256LTE = data + case "gitoidsha256Contains": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("gitoidsha256Contains")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.GitoidSha256Contains = data + case "gitoidsha256HasPrefix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("gitoidsha256HasPrefix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.GitoidSha256HasPrefix = data + case "gitoidsha256HasSuffix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("gitoidsha256HasSuffix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.GitoidSha256HasSuffix = data + case "gitoidsha256EqualFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("gitoidsha256EqualFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.GitoidSha256EqualFold = data + case "gitoidsha256ContainsFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("gitoidsha256ContainsFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.GitoidSha256ContainsFold = data + case "hasPosix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasPosix")) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + if err != nil { + return it, err + } + it.HasPosix = data + case "hasPosixWith": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasPosixWith")) + data, err := ec.unmarshalOPosixWhereInput2ᚕᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐPosixWhereInputᚄ(ctx, v) + if err != nil { + return it, err + } + it.HasPosixWith = data + case "hasOmnitrail": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasOmnitrail")) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + if err != nil { + return it, err + } + it.HasOmnitrail = data + case "hasOmnitrailWith": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasOmnitrailWith")) + data, err := ec.unmarshalOOmnitrailWhereInput2ᚕᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐOmnitrailWhereInputᚄ(ctx, v) + if err != nil { + return it, err + } + it.HasOmnitrailWith = data + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputOmnitrailWhereInput(ctx context.Context, obj interface{}) (ent.OmnitrailWhereInput, error) { + var it ent.OmnitrailWhereInput + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "hasMappings", "hasMappingsWith", "hasAttestation", "hasAttestationWith"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "not": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("not")) + data, err := ec.unmarshalOOmnitrailWhereInput2ᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐOmnitrailWhereInput(ctx, v) + if err != nil { + return it, err + } + it.Not = data + case "and": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("and")) + data, err := ec.unmarshalOOmnitrailWhereInput2ᚕᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐOmnitrailWhereInputᚄ(ctx, v) + if err != nil { + return it, err + } + it.And = data + case "or": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("or")) + data, err := ec.unmarshalOOmnitrailWhereInput2ᚕᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐOmnitrailWhereInputᚄ(ctx, v) + if err != nil { + return it, err + } + it.Or = data + case "id": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.ID = data + case "idNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNEQ")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.IDNEQ = data + case "idIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idIn")) + data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) + if err != nil { + return it, err + } + it.IDIn = data + case "idNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNotIn")) + data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) + if err != nil { + return it, err + } + it.IDNotIn = data + case "idGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGT")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.IDGT = data + case "idGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGTE")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.IDGTE = data + case "idLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLT")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.IDLT = data + case "idLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLTE")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.IDLTE = data + case "hasMappings": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasMappings")) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + if err != nil { + return it, err + } + it.HasMappings = data + case "hasMappingsWith": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasMappingsWith")) + data, err := ec.unmarshalOMappingWhereInput2ᚕᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐMappingWhereInputᚄ(ctx, v) + if err != nil { + return it, err + } + it.HasMappingsWith = data + case "hasAttestation": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasAttestation")) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + if err != nil { + return it, err + } + it.HasAttestation = data + case "hasAttestationWith": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasAttestationWith")) + data, err := ec.unmarshalOAttestationWhereInput2ᚕᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐAttestationWhereInputᚄ(ctx, v) + if err != nil { + return it, err + } + it.HasAttestationWith = data + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputPayloadDigestWhereInput(ctx context.Context, obj interface{}) (ent.PayloadDigestWhereInput, error) { + var it ent.PayloadDigestWhereInput + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "algorithm", "algorithmNEQ", "algorithmIn", "algorithmNotIn", "algorithmGT", "algorithmGTE", "algorithmLT", "algorithmLTE", "algorithmContains", "algorithmHasPrefix", "algorithmHasSuffix", "algorithmEqualFold", "algorithmContainsFold", "value", "valueNEQ", "valueIn", "valueNotIn", "valueGT", "valueGTE", "valueLT", "valueLTE", "valueContains", "valueHasPrefix", "valueHasSuffix", "valueEqualFold", "valueContainsFold", "hasDsse", "hasDsseWith"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "not": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("not")) + data, err := ec.unmarshalOPayloadDigestWhereInput2ᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐPayloadDigestWhereInput(ctx, v) + if err != nil { + return it, err + } + it.Not = data + case "and": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("and")) + data, err := ec.unmarshalOPayloadDigestWhereInput2ᚕᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐPayloadDigestWhereInputᚄ(ctx, v) + if err != nil { + return it, err + } + it.And = data + case "or": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("or")) + data, err := ec.unmarshalOPayloadDigestWhereInput2ᚕᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐPayloadDigestWhereInputᚄ(ctx, v) + if err != nil { + return it, err + } + it.Or = data + case "id": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.ID = data + case "idNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNEQ")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.IDNEQ = data + case "idIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idIn")) + data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) + if err != nil { + return it, err + } + it.IDIn = data + case "idNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNotIn")) + data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) + if err != nil { + return it, err + } + it.IDNotIn = data + case "idGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGT")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.IDGT = data + case "idGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGTE")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.IDGTE = data + case "idLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLT")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.IDLT = data + case "idLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLTE")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.IDLTE = data + case "algorithm": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("algorithm")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Algorithm = data + case "algorithmNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("algorithmNEQ")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.AlgorithmNEQ = data + case "algorithmIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("algorithmIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.AlgorithmIn = data + case "algorithmNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("algorithmNotIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.AlgorithmNotIn = data + case "algorithmGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("algorithmGT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.AlgorithmGT = data + case "algorithmGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("algorithmGTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.AlgorithmGTE = data + case "algorithmLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("algorithmLT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.AlgorithmLT = data + case "algorithmLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("algorithmLTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.AlgorithmLTE = data + case "algorithmContains": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("algorithmContains")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.AlgorithmContains = data + case "algorithmHasPrefix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("algorithmHasPrefix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.AlgorithmHasPrefix = data + case "algorithmHasSuffix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("algorithmHasSuffix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.AlgorithmHasSuffix = data + case "algorithmEqualFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("algorithmEqualFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.AlgorithmEqualFold = data + case "algorithmContainsFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("algorithmContainsFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.AlgorithmContainsFold = data + case "value": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("value")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Value = data + case "valueNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("valueNEQ")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.ValueNEQ = data + case "valueIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("valueIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.ValueIn = data + case "valueNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("valueNotIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.ValueNotIn = data + case "valueGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("valueGT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.ValueGT = data + case "valueGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("valueGTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.ValueGTE = data + case "valueLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("valueLT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.ValueLT = data + case "valueLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("valueLTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.ValueLTE = data + case "valueContains": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("valueContains")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.ValueContains = data + case "valueHasPrefix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("valueHasPrefix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.ValueHasPrefix = data + case "valueHasSuffix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("valueHasSuffix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.ValueHasSuffix = data + case "valueEqualFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("valueEqualFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.ValueEqualFold = data + case "valueContainsFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("valueContainsFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.ValueContainsFold = data + case "hasDsse": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasDsse")) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + if err != nil { + return it, err + } + it.HasDsse = data + case "hasDsseWith": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasDsseWith")) + data, err := ec.unmarshalODsseWhereInput2ᚕᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐDsseWhereInputᚄ(ctx, v) + if err != nil { + return it, err + } + it.HasDsseWith = data + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputPosixWhereInput(ctx context.Context, obj interface{}) (ent.PosixWhereInput, error) { + var it ent.PosixWhereInput + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "atime", "atimeNEQ", "atimeIn", "atimeNotIn", "atimeGT", "atimeGTE", "atimeLT", "atimeLTE", "atimeContains", "atimeHasPrefix", "atimeHasSuffix", "atimeEqualFold", "atimeContainsFold", "ctime", "ctimeNEQ", "ctimeIn", "ctimeNotIn", "ctimeGT", "ctimeGTE", "ctimeLT", "ctimeLTE", "ctimeContains", "ctimeHasPrefix", "ctimeHasSuffix", "ctimeEqualFold", "ctimeContainsFold", "creationTime", "creationTimeNEQ", "creationTimeIn", "creationTimeNotIn", "creationTimeGT", "creationTimeGTE", "creationTimeLT", "creationTimeLTE", "creationTimeContains", "creationTimeHasPrefix", "creationTimeHasSuffix", "creationTimeEqualFold", "creationTimeContainsFold", "extendedAttributes", "extendedAttributesNEQ", "extendedAttributesIn", "extendedAttributesNotIn", "extendedAttributesGT", "extendedAttributesGTE", "extendedAttributesLT", "extendedAttributesLTE", "extendedAttributesContains", "extendedAttributesHasPrefix", "extendedAttributesHasSuffix", "extendedAttributesEqualFold", "extendedAttributesContainsFold", "fileDeviceID", "fileDeviceIDNEQ", "fileDeviceIDIn", "fileDeviceIDNotIn", "fileDeviceIDGT", "fileDeviceIDGTE", "fileDeviceIDLT", "fileDeviceIDLTE", "fileDeviceIDContains", "fileDeviceIDHasPrefix", "fileDeviceIDHasSuffix", "fileDeviceIDEqualFold", "fileDeviceIDContainsFold", "fileFlags", "fileFlagsNEQ", "fileFlagsIn", "fileFlagsNotIn", "fileFlagsGT", "fileFlagsGTE", "fileFlagsLT", "fileFlagsLTE", "fileFlagsContains", "fileFlagsHasPrefix", "fileFlagsHasSuffix", "fileFlagsEqualFold", "fileFlagsContainsFold", "fileInode", "fileInodeNEQ", "fileInodeIn", "fileInodeNotIn", "fileInodeGT", "fileInodeGTE", "fileInodeLT", "fileInodeLTE", "fileInodeContains", "fileInodeHasPrefix", "fileInodeHasSuffix", "fileInodeEqualFold", "fileInodeContainsFold", "fileSystemID", "fileSystemIDNEQ", "fileSystemIDIn", "fileSystemIDNotIn", "fileSystemIDGT", "fileSystemIDGTE", "fileSystemIDLT", "fileSystemIDLTE", "fileSystemIDContains", "fileSystemIDHasPrefix", "fileSystemIDHasSuffix", "fileSystemIDEqualFold", "fileSystemIDContainsFold", "fileType", "fileTypeNEQ", "fileTypeIn", "fileTypeNotIn", "fileTypeGT", "fileTypeGTE", "fileTypeLT", "fileTypeLTE", "fileTypeContains", "fileTypeHasPrefix", "fileTypeHasSuffix", "fileTypeEqualFold", "fileTypeContainsFold", "hardLinkCount", "hardLinkCountNEQ", "hardLinkCountIn", "hardLinkCountNotIn", "hardLinkCountGT", "hardLinkCountGTE", "hardLinkCountLT", "hardLinkCountLTE", "hardLinkCountContains", "hardLinkCountHasPrefix", "hardLinkCountHasSuffix", "hardLinkCountEqualFold", "hardLinkCountContainsFold", "mtime", "mtimeNEQ", "mtimeIn", "mtimeNotIn", "mtimeGT", "mtimeGTE", "mtimeLT", "mtimeLTE", "mtimeContains", "mtimeHasPrefix", "mtimeHasSuffix", "mtimeEqualFold", "mtimeContainsFold", "metadataCtime", "metadataCtimeNEQ", "metadataCtimeIn", "metadataCtimeNotIn", "metadataCtimeGT", "metadataCtimeGTE", "metadataCtimeLT", "metadataCtimeLTE", "metadataCtimeContains", "metadataCtimeHasPrefix", "metadataCtimeHasSuffix", "metadataCtimeEqualFold", "metadataCtimeContainsFold", "ownerGid", "ownerGidNEQ", "ownerGidIn", "ownerGidNotIn", "ownerGidGT", "ownerGidGTE", "ownerGidLT", "ownerGidLTE", "ownerGidContains", "ownerGidHasPrefix", "ownerGidHasSuffix", "ownerGidEqualFold", "ownerGidContainsFold", "ownerUID", "ownerUIDNEQ", "ownerUIDIn", "ownerUIDNotIn", "ownerUIDGT", "ownerUIDGTE", "ownerUIDLT", "ownerUIDLTE", "ownerUIDContains", "ownerUIDHasPrefix", "ownerUIDHasSuffix", "ownerUIDEqualFold", "ownerUIDContainsFold", "permissions", "permissionsNEQ", "permissionsIn", "permissionsNotIn", "permissionsGT", "permissionsGTE", "permissionsLT", "permissionsLTE", "permissionsContains", "permissionsHasPrefix", "permissionsHasSuffix", "permissionsEqualFold", "permissionsContainsFold", "size", "sizeNEQ", "sizeIn", "sizeNotIn", "sizeGT", "sizeGTE", "sizeLT", "sizeLTE", "sizeContains", "sizeHasPrefix", "sizeHasSuffix", "sizeEqualFold", "sizeContainsFold", "hasMapping", "hasMappingWith"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "not": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("not")) + data, err := ec.unmarshalOPosixWhereInput2ᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐPosixWhereInput(ctx, v) + if err != nil { + return it, err + } + it.Not = data + case "and": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("and")) + data, err := ec.unmarshalOPosixWhereInput2ᚕᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐPosixWhereInputᚄ(ctx, v) + if err != nil { + return it, err + } + it.And = data + case "or": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("or")) - data, err := ec.unmarshalOAttestationCollectionWhereInput2ᚕᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐAttestationCollectionWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOPosixWhereInput2ᚕᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐPosixWhereInputᚄ(ctx, v) if err != nil { return it, err } @@ -6312,1179 +10077,1512 @@ func (ec *executionContext) unmarshalInputAttestationCollectionWhereInput(ctx co if err != nil { return it, err } - it.IDIn = data - case "idNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNotIn")) - data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) + it.IDIn = data + case "idNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNotIn")) + data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) + if err != nil { + return it, err + } + it.IDNotIn = data + case "idGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGT")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.IDGT = data + case "idGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGTE")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.IDGTE = data + case "idLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLT")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.IDLT = data + case "idLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLTE")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.IDLTE = data + case "atime": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("atime")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Atime = data + case "atimeNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("atimeNEQ")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.AtimeNEQ = data + case "atimeIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("atimeIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.AtimeIn = data + case "atimeNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("atimeNotIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.AtimeNotIn = data + case "atimeGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("atimeGT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.AtimeGT = data + case "atimeGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("atimeGTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.AtimeGTE = data + case "atimeLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("atimeLT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.AtimeLT = data + case "atimeLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("atimeLTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.AtimeLTE = data + case "atimeContains": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("atimeContains")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.AtimeContains = data + case "atimeHasPrefix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("atimeHasPrefix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.AtimeHasPrefix = data + case "atimeHasSuffix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("atimeHasSuffix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.AtimeHasSuffix = data + case "atimeEqualFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("atimeEqualFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.AtimeEqualFold = data + case "atimeContainsFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("atimeContainsFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.AtimeContainsFold = data + case "ctime": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ctime")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Ctime = data + case "ctimeNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ctimeNEQ")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.CtimeNEQ = data + case "ctimeIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ctimeIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.CtimeIn = data + case "ctimeNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ctimeNotIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.CtimeNotIn = data + case "ctimeGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ctimeGT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.CtimeGT = data + case "ctimeGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ctimeGTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.CtimeGTE = data + case "ctimeLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ctimeLT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.CtimeLT = data + case "ctimeLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ctimeLTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.CtimeLTE = data + case "ctimeContains": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ctimeContains")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.CtimeContains = data + case "ctimeHasPrefix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ctimeHasPrefix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.CtimeHasPrefix = data + case "ctimeHasSuffix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ctimeHasSuffix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.CtimeHasSuffix = data + case "ctimeEqualFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ctimeEqualFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.CtimeEqualFold = data + case "ctimeContainsFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ctimeContainsFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.CtimeContainsFold = data + case "creationTime": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("creationTime")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.CreationTime = data + case "creationTimeNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("creationTimeNEQ")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.CreationTimeNEQ = data + case "creationTimeIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("creationTimeIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.CreationTimeIn = data + case "creationTimeNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("creationTimeNotIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.CreationTimeNotIn = data + case "creationTimeGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("creationTimeGT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.CreationTimeGT = data + case "creationTimeGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("creationTimeGTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.CreationTimeGTE = data + case "creationTimeLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("creationTimeLT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.CreationTimeLT = data + case "creationTimeLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("creationTimeLTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.CreationTimeLTE = data + case "creationTimeContains": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("creationTimeContains")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.CreationTimeContains = data + case "creationTimeHasPrefix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("creationTimeHasPrefix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.CreationTimeHasPrefix = data + case "creationTimeHasSuffix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("creationTimeHasSuffix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.CreationTimeHasSuffix = data + case "creationTimeEqualFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("creationTimeEqualFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.CreationTimeEqualFold = data + case "creationTimeContainsFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("creationTimeContainsFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.CreationTimeContainsFold = data + case "extendedAttributes": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("extendedAttributes")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.ExtendedAttributes = data + case "extendedAttributesNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("extendedAttributesNEQ")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.ExtendedAttributesNEQ = data + case "extendedAttributesIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("extendedAttributesIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.ExtendedAttributesIn = data + case "extendedAttributesNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("extendedAttributesNotIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.ExtendedAttributesNotIn = data + case "extendedAttributesGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("extendedAttributesGT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.ExtendedAttributesGT = data + case "extendedAttributesGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("extendedAttributesGTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IDNotIn = data - case "idGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGT")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + it.ExtendedAttributesGTE = data + case "extendedAttributesLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("extendedAttributesLT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IDGT = data - case "idGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGTE")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + it.ExtendedAttributesLT = data + case "extendedAttributesLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("extendedAttributesLTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IDGTE = data - case "idLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLT")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + it.ExtendedAttributesLTE = data + case "extendedAttributesContains": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("extendedAttributesContains")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IDLT = data - case "idLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLTE")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + it.ExtendedAttributesContains = data + case "extendedAttributesHasPrefix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("extendedAttributesHasPrefix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IDLTE = data - case "name": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) + it.ExtendedAttributesHasPrefix = data + case "extendedAttributesHasSuffix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("extendedAttributesHasSuffix")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.Name = data - case "nameNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNEQ")) + it.ExtendedAttributesHasSuffix = data + case "extendedAttributesEqualFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("extendedAttributesEqualFold")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.NameNEQ = data - case "nameIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + it.ExtendedAttributesEqualFold = data + case "extendedAttributesContainsFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("extendedAttributesContainsFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.NameIn = data - case "nameNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNotIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + it.ExtendedAttributesContainsFold = data + case "fileDeviceID": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("fileDeviceID")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.NameNotIn = data - case "nameGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGT")) + it.FileDeviceID = data + case "fileDeviceIDNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("fileDeviceIDNEQ")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.NameGT = data - case "nameGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGTE")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.FileDeviceIDNEQ = data + case "fileDeviceIDIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("fileDeviceIDIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.NameGTE = data - case "nameLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLT")) + it.FileDeviceIDIn = data + case "fileDeviceIDNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("fileDeviceIDNotIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.FileDeviceIDNotIn = data + case "fileDeviceIDGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("fileDeviceIDGT")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.NameLT = data - case "nameLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLTE")) + it.FileDeviceIDGT = data + case "fileDeviceIDGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("fileDeviceIDGTE")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.NameLTE = data - case "nameContains": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContains")) + it.FileDeviceIDGTE = data + case "fileDeviceIDLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("fileDeviceIDLT")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.NameContains = data - case "nameHasPrefix": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasPrefix")) + it.FileDeviceIDLT = data + case "fileDeviceIDLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("fileDeviceIDLTE")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.NameHasPrefix = data - case "nameHasSuffix": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasSuffix")) + it.FileDeviceIDLTE = data + case "fileDeviceIDContains": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("fileDeviceIDContains")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.NameHasSuffix = data - case "nameEqualFold": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameEqualFold")) + it.FileDeviceIDContains = data + case "fileDeviceIDHasPrefix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("fileDeviceIDHasPrefix")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.NameEqualFold = data - case "nameContainsFold": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContainsFold")) + it.FileDeviceIDHasPrefix = data + case "fileDeviceIDHasSuffix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("fileDeviceIDHasSuffix")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.NameContainsFold = data - case "hasAttestations": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasAttestations")) - data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + it.FileDeviceIDHasSuffix = data + case "fileDeviceIDEqualFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("fileDeviceIDEqualFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.HasAttestations = data - case "hasAttestationsWith": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasAttestationsWith")) - data, err := ec.unmarshalOAttestationWhereInput2ᚕᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐAttestationWhereInputᚄ(ctx, v) + it.FileDeviceIDEqualFold = data + case "fileDeviceIDContainsFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("fileDeviceIDContainsFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.HasAttestationsWith = data - case "hasStatement": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasStatement")) - data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + it.FileDeviceIDContainsFold = data + case "fileFlags": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("fileFlags")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.HasStatement = data - case "hasStatementWith": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasStatementWith")) - data, err := ec.unmarshalOStatementWhereInput2ᚕᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐStatementWhereInputᚄ(ctx, v) + it.FileFlags = data + case "fileFlagsNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("fileFlagsNEQ")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.HasStatementWith = data - } - } - - return it, nil -} - -func (ec *executionContext) unmarshalInputAttestationPolicyWhereInput(ctx context.Context, obj interface{}) (ent.AttestationPolicyWhereInput, error) { - var it ent.AttestationPolicyWhereInput - asMap := map[string]interface{}{} - for k, v := range obj.(map[string]interface{}) { - asMap[k] = v - } - - fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "name", "nameNEQ", "nameIn", "nameNotIn", "nameGT", "nameGTE", "nameLT", "nameLTE", "nameContains", "nameHasPrefix", "nameHasSuffix", "nameEqualFold", "nameContainsFold", "hasStatement", "hasStatementWith"} - for _, k := range fieldsInOrder { - v, ok := asMap[k] - if !ok { - continue - } - switch k { - case "not": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("not")) - data, err := ec.unmarshalOAttestationPolicyWhereInput2ᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐAttestationPolicyWhereInput(ctx, v) + it.FileFlagsNEQ = data + case "fileFlagsIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("fileFlagsIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.Not = data - case "and": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("and")) - data, err := ec.unmarshalOAttestationPolicyWhereInput2ᚕᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐAttestationPolicyWhereInputᚄ(ctx, v) + it.FileFlagsIn = data + case "fileFlagsNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("fileFlagsNotIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.And = data - case "or": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("or")) - data, err := ec.unmarshalOAttestationPolicyWhereInput2ᚕᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐAttestationPolicyWhereInputᚄ(ctx, v) + it.FileFlagsNotIn = data + case "fileFlagsGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("fileFlagsGT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.Or = data - case "id": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + it.FileFlagsGT = data + case "fileFlagsGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("fileFlagsGTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.ID = data - case "idNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNEQ")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + it.FileFlagsGTE = data + case "fileFlagsLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("fileFlagsLT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IDNEQ = data - case "idIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idIn")) - data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) + it.FileFlagsLT = data + case "fileFlagsLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("fileFlagsLTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IDIn = data - case "idNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNotIn")) - data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) + it.FileFlagsLTE = data + case "fileFlagsContains": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("fileFlagsContains")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IDNotIn = data - case "idGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGT")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + it.FileFlagsContains = data + case "fileFlagsHasPrefix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("fileFlagsHasPrefix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IDGT = data - case "idGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGTE")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + it.FileFlagsHasPrefix = data + case "fileFlagsHasSuffix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("fileFlagsHasSuffix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IDGTE = data - case "idLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLT")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + it.FileFlagsHasSuffix = data + case "fileFlagsEqualFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("fileFlagsEqualFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IDLT = data - case "idLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLTE")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + it.FileFlagsEqualFold = data + case "fileFlagsContainsFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("fileFlagsContainsFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IDLTE = data - case "name": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) + it.FileFlagsContainsFold = data + case "fileInode": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("fileInode")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.Name = data - case "nameNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNEQ")) + it.FileInode = data + case "fileInodeNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("fileInodeNEQ")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.NameNEQ = data - case "nameIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameIn")) + it.FileInodeNEQ = data + case "fileInodeIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("fileInodeIn")) data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.NameIn = data - case "nameNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNotIn")) + it.FileInodeIn = data + case "fileInodeNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("fileInodeNotIn")) data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.NameNotIn = data - case "nameGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGT")) + it.FileInodeNotIn = data + case "fileInodeGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("fileInodeGT")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.NameGT = data - case "nameGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGTE")) + it.FileInodeGT = data + case "fileInodeGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("fileInodeGTE")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.NameGTE = data - case "nameLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLT")) + it.FileInodeGTE = data + case "fileInodeLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("fileInodeLT")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.NameLT = data - case "nameLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLTE")) + it.FileInodeLT = data + case "fileInodeLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("fileInodeLTE")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.NameLTE = data - case "nameContains": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContains")) + it.FileInodeLTE = data + case "fileInodeContains": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("fileInodeContains")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.NameContains = data - case "nameHasPrefix": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasPrefix")) + it.FileInodeContains = data + case "fileInodeHasPrefix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("fileInodeHasPrefix")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.NameHasPrefix = data - case "nameHasSuffix": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasSuffix")) + it.FileInodeHasPrefix = data + case "fileInodeHasSuffix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("fileInodeHasSuffix")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.NameHasSuffix = data - case "nameEqualFold": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameEqualFold")) + it.FileInodeHasSuffix = data + case "fileInodeEqualFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("fileInodeEqualFold")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.NameEqualFold = data - case "nameContainsFold": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContainsFold")) + it.FileInodeEqualFold = data + case "fileInodeContainsFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("fileInodeContainsFold")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.NameContainsFold = data - case "hasStatement": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasStatement")) - data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + it.FileInodeContainsFold = data + case "fileSystemID": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("fileSystemID")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.HasStatement = data - case "hasStatementWith": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasStatementWith")) - data, err := ec.unmarshalOStatementWhereInput2ᚕᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐStatementWhereInputᚄ(ctx, v) + it.FileSystemID = data + case "fileSystemIDNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("fileSystemIDNEQ")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.HasStatementWith = data - } - } - - return it, nil -} - -func (ec *executionContext) unmarshalInputAttestationWhereInput(ctx context.Context, obj interface{}) (ent.AttestationWhereInput, error) { - var it ent.AttestationWhereInput - asMap := map[string]interface{}{} - for k, v := range obj.(map[string]interface{}) { - asMap[k] = v - } - - fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "type", "typeNEQ", "typeIn", "typeNotIn", "typeGT", "typeGTE", "typeLT", "typeLTE", "typeContains", "typeHasPrefix", "typeHasSuffix", "typeEqualFold", "typeContainsFold", "hasAttestationCollection", "hasAttestationCollectionWith"} - for _, k := range fieldsInOrder { - v, ok := asMap[k] - if !ok { - continue - } - switch k { - case "not": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("not")) - data, err := ec.unmarshalOAttestationWhereInput2ᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐAttestationWhereInput(ctx, v) + it.FileSystemIDNEQ = data + case "fileSystemIDIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("fileSystemIDIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.Not = data - case "and": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("and")) - data, err := ec.unmarshalOAttestationWhereInput2ᚕᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐAttestationWhereInputᚄ(ctx, v) + it.FileSystemIDIn = data + case "fileSystemIDNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("fileSystemIDNotIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.And = data - case "or": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("or")) - data, err := ec.unmarshalOAttestationWhereInput2ᚕᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐAttestationWhereInputᚄ(ctx, v) + it.FileSystemIDNotIn = data + case "fileSystemIDGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("fileSystemIDGT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.Or = data - case "id": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + it.FileSystemIDGT = data + case "fileSystemIDGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("fileSystemIDGTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.ID = data - case "idNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNEQ")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + it.FileSystemIDGTE = data + case "fileSystemIDLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("fileSystemIDLT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IDNEQ = data - case "idIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idIn")) - data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) + it.FileSystemIDLT = data + case "fileSystemIDLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("fileSystemIDLTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IDIn = data - case "idNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNotIn")) - data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) + it.FileSystemIDLTE = data + case "fileSystemIDContains": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("fileSystemIDContains")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IDNotIn = data - case "idGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGT")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + it.FileSystemIDContains = data + case "fileSystemIDHasPrefix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("fileSystemIDHasPrefix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IDGT = data - case "idGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGTE")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + it.FileSystemIDHasPrefix = data + case "fileSystemIDHasSuffix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("fileSystemIDHasSuffix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IDGTE = data - case "idLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLT")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + it.FileSystemIDHasSuffix = data + case "fileSystemIDEqualFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("fileSystemIDEqualFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IDLT = data - case "idLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLTE")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + it.FileSystemIDEqualFold = data + case "fileSystemIDContainsFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("fileSystemIDContainsFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IDLTE = data - case "type": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("type")) + it.FileSystemIDContainsFold = data + case "fileType": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("fileType")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.Type = data - case "typeNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("typeNEQ")) + it.FileType = data + case "fileTypeNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("fileTypeNEQ")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.TypeNEQ = data - case "typeIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("typeIn")) + it.FileTypeNEQ = data + case "fileTypeIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("fileTypeIn")) data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.TypeIn = data - case "typeNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("typeNotIn")) + it.FileTypeIn = data + case "fileTypeNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("fileTypeNotIn")) data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.TypeNotIn = data - case "typeGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("typeGT")) + it.FileTypeNotIn = data + case "fileTypeGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("fileTypeGT")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.TypeGT = data - case "typeGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("typeGTE")) + it.FileTypeGT = data + case "fileTypeGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("fileTypeGTE")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.TypeGTE = data - case "typeLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("typeLT")) + it.FileTypeGTE = data + case "fileTypeLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("fileTypeLT")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.TypeLT = data - case "typeLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("typeLTE")) + it.FileTypeLT = data + case "fileTypeLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("fileTypeLTE")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.TypeLTE = data - case "typeContains": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("typeContains")) + it.FileTypeLTE = data + case "fileTypeContains": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("fileTypeContains")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.TypeContains = data - case "typeHasPrefix": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("typeHasPrefix")) + it.FileTypeContains = data + case "fileTypeHasPrefix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("fileTypeHasPrefix")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.TypeHasPrefix = data - case "typeHasSuffix": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("typeHasSuffix")) + it.FileTypeHasPrefix = data + case "fileTypeHasSuffix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("fileTypeHasSuffix")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.TypeHasSuffix = data - case "typeEqualFold": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("typeEqualFold")) + it.FileTypeHasSuffix = data + case "fileTypeEqualFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("fileTypeEqualFold")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.TypeEqualFold = data - case "typeContainsFold": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("typeContainsFold")) + it.FileTypeEqualFold = data + case "fileTypeContainsFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("fileTypeContainsFold")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.TypeContainsFold = data - case "hasAttestationCollection": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasAttestationCollection")) - data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + it.FileTypeContainsFold = data + case "hardLinkCount": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hardLinkCount")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.HasAttestationCollection = data - case "hasAttestationCollectionWith": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasAttestationCollectionWith")) - data, err := ec.unmarshalOAttestationCollectionWhereInput2ᚕᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐAttestationCollectionWhereInputᚄ(ctx, v) + it.HardLinkCount = data + case "hardLinkCountNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hardLinkCountNEQ")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.HasAttestationCollectionWith = data - } - } - - return it, nil -} - -func (ec *executionContext) unmarshalInputDsseWhereInput(ctx context.Context, obj interface{}) (ent.DsseWhereInput, error) { - var it ent.DsseWhereInput - asMap := map[string]interface{}{} - for k, v := range obj.(map[string]interface{}) { - asMap[k] = v - } - - fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "gitoidSha256", "gitoidSha256NEQ", "gitoidSha256In", "gitoidSha256NotIn", "gitoidSha256GT", "gitoidSha256GTE", "gitoidSha256LT", "gitoidSha256LTE", "gitoidSha256Contains", "gitoidSha256HasPrefix", "gitoidSha256HasSuffix", "gitoidSha256EqualFold", "gitoidSha256ContainsFold", "payloadType", "payloadTypeNEQ", "payloadTypeIn", "payloadTypeNotIn", "payloadTypeGT", "payloadTypeGTE", "payloadTypeLT", "payloadTypeLTE", "payloadTypeContains", "payloadTypeHasPrefix", "payloadTypeHasSuffix", "payloadTypeEqualFold", "payloadTypeContainsFold", "hasStatement", "hasStatementWith", "hasSignatures", "hasSignaturesWith", "hasPayloadDigests", "hasPayloadDigestsWith"} - for _, k := range fieldsInOrder { - v, ok := asMap[k] - if !ok { - continue - } - switch k { - case "not": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("not")) - data, err := ec.unmarshalODsseWhereInput2ᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐDsseWhereInput(ctx, v) + it.HardLinkCountNEQ = data + case "hardLinkCountIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hardLinkCountIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.Not = data - case "and": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("and")) - data, err := ec.unmarshalODsseWhereInput2ᚕᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐDsseWhereInputᚄ(ctx, v) + it.HardLinkCountIn = data + case "hardLinkCountNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hardLinkCountNotIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.And = data - case "or": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("or")) - data, err := ec.unmarshalODsseWhereInput2ᚕᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐDsseWhereInputᚄ(ctx, v) + it.HardLinkCountNotIn = data + case "hardLinkCountGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hardLinkCountGT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.Or = data - case "id": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + it.HardLinkCountGT = data + case "hardLinkCountGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hardLinkCountGTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.ID = data - case "idNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNEQ")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + it.HardLinkCountGTE = data + case "hardLinkCountLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hardLinkCountLT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IDNEQ = data - case "idIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idIn")) - data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) + it.HardLinkCountLT = data + case "hardLinkCountLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hardLinkCountLTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IDIn = data - case "idNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNotIn")) - data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) + it.HardLinkCountLTE = data + case "hardLinkCountContains": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hardLinkCountContains")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IDNotIn = data - case "idGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGT")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + it.HardLinkCountContains = data + case "hardLinkCountHasPrefix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hardLinkCountHasPrefix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IDGT = data - case "idGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGTE")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + it.HardLinkCountHasPrefix = data + case "hardLinkCountHasSuffix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hardLinkCountHasSuffix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IDGTE = data - case "idLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLT")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + it.HardLinkCountHasSuffix = data + case "hardLinkCountEqualFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hardLinkCountEqualFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IDLT = data - case "idLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLTE")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + it.HardLinkCountEqualFold = data + case "hardLinkCountContainsFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hardLinkCountContainsFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IDLTE = data - case "gitoidSha256": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("gitoidSha256")) + it.HardLinkCountContainsFold = data + case "mtime": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("mtime")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.GitoidSha256 = data - case "gitoidSha256NEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("gitoidSha256NEQ")) + it.Mtime = data + case "mtimeNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("mtimeNEQ")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.GitoidSha256NEQ = data - case "gitoidSha256In": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("gitoidSha256In")) + it.MtimeNEQ = data + case "mtimeIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("mtimeIn")) data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.GitoidSha256In = data - case "gitoidSha256NotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("gitoidSha256NotIn")) + it.MtimeIn = data + case "mtimeNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("mtimeNotIn")) data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.GitoidSha256NotIn = data - case "gitoidSha256GT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("gitoidSha256GT")) + it.MtimeNotIn = data + case "mtimeGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("mtimeGT")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.GitoidSha256GT = data - case "gitoidSha256GTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("gitoidSha256GTE")) + it.MtimeGT = data + case "mtimeGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("mtimeGTE")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.GitoidSha256GTE = data - case "gitoidSha256LT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("gitoidSha256LT")) + it.MtimeGTE = data + case "mtimeLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("mtimeLT")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.GitoidSha256LT = data - case "gitoidSha256LTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("gitoidSha256LTE")) + it.MtimeLT = data + case "mtimeLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("mtimeLTE")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.GitoidSha256LTE = data - case "gitoidSha256Contains": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("gitoidSha256Contains")) + it.MtimeLTE = data + case "mtimeContains": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("mtimeContains")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.GitoidSha256Contains = data - case "gitoidSha256HasPrefix": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("gitoidSha256HasPrefix")) + it.MtimeContains = data + case "mtimeHasPrefix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("mtimeHasPrefix")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.GitoidSha256HasPrefix = data - case "gitoidSha256HasSuffix": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("gitoidSha256HasSuffix")) + it.MtimeHasPrefix = data + case "mtimeHasSuffix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("mtimeHasSuffix")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.GitoidSha256HasSuffix = data - case "gitoidSha256EqualFold": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("gitoidSha256EqualFold")) + it.MtimeHasSuffix = data + case "mtimeEqualFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("mtimeEqualFold")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.GitoidSha256EqualFold = data - case "gitoidSha256ContainsFold": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("gitoidSha256ContainsFold")) + it.MtimeEqualFold = data + case "mtimeContainsFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("mtimeContainsFold")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.GitoidSha256ContainsFold = data - case "payloadType": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("payloadType")) + it.MtimeContainsFold = data + case "metadataCtime": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("metadataCtime")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.PayloadType = data - case "payloadTypeNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("payloadTypeNEQ")) + it.MetadataCtime = data + case "metadataCtimeNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("metadataCtimeNEQ")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.PayloadTypeNEQ = data - case "payloadTypeIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("payloadTypeIn")) + it.MetadataCtimeNEQ = data + case "metadataCtimeIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("metadataCtimeIn")) data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.PayloadTypeIn = data - case "payloadTypeNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("payloadTypeNotIn")) + it.MetadataCtimeIn = data + case "metadataCtimeNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("metadataCtimeNotIn")) data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.PayloadTypeNotIn = data - case "payloadTypeGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("payloadTypeGT")) + it.MetadataCtimeNotIn = data + case "metadataCtimeGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("metadataCtimeGT")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.PayloadTypeGT = data - case "payloadTypeGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("payloadTypeGTE")) + it.MetadataCtimeGT = data + case "metadataCtimeGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("metadataCtimeGTE")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.PayloadTypeGTE = data - case "payloadTypeLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("payloadTypeLT")) + it.MetadataCtimeGTE = data + case "metadataCtimeLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("metadataCtimeLT")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.PayloadTypeLT = data - case "payloadTypeLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("payloadTypeLTE")) + it.MetadataCtimeLT = data + case "metadataCtimeLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("metadataCtimeLTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.MetadataCtimeLTE = data + case "metadataCtimeContains": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("metadataCtimeContains")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.MetadataCtimeContains = data + case "metadataCtimeHasPrefix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("metadataCtimeHasPrefix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.MetadataCtimeHasPrefix = data + case "metadataCtimeHasSuffix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("metadataCtimeHasSuffix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.MetadataCtimeHasSuffix = data + case "metadataCtimeEqualFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("metadataCtimeEqualFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.MetadataCtimeEqualFold = data + case "metadataCtimeContainsFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("metadataCtimeContainsFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.MetadataCtimeContainsFold = data + case "ownerGid": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerGid")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.OwnerGid = data + case "ownerGidNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerGidNEQ")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.PayloadTypeLTE = data - case "payloadTypeContains": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("payloadTypeContains")) + it.OwnerGidNEQ = data + case "ownerGidIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerGidIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.OwnerGidIn = data + case "ownerGidNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerGidNotIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.OwnerGidNotIn = data + case "ownerGidGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerGidGT")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.PayloadTypeContains = data - case "payloadTypeHasPrefix": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("payloadTypeHasPrefix")) + it.OwnerGidGT = data + case "ownerGidGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerGidGTE")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.PayloadTypeHasPrefix = data - case "payloadTypeHasSuffix": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("payloadTypeHasSuffix")) + it.OwnerGidGTE = data + case "ownerGidLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerGidLT")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.PayloadTypeHasSuffix = data - case "payloadTypeEqualFold": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("payloadTypeEqualFold")) + it.OwnerGidLT = data + case "ownerGidLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerGidLTE")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.PayloadTypeEqualFold = data - case "payloadTypeContainsFold": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("payloadTypeContainsFold")) + it.OwnerGidLTE = data + case "ownerGidContains": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerGidContains")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.PayloadTypeContainsFold = data - case "hasStatement": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasStatement")) - data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + it.OwnerGidContains = data + case "ownerGidHasPrefix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerGidHasPrefix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.HasStatement = data - case "hasStatementWith": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasStatementWith")) - data, err := ec.unmarshalOStatementWhereInput2ᚕᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐStatementWhereInputᚄ(ctx, v) + it.OwnerGidHasPrefix = data + case "ownerGidHasSuffix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerGidHasSuffix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.HasStatementWith = data - case "hasSignatures": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasSignatures")) - data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + it.OwnerGidHasSuffix = data + case "ownerGidEqualFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerGidEqualFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.HasSignatures = data - case "hasSignaturesWith": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasSignaturesWith")) - data, err := ec.unmarshalOSignatureWhereInput2ᚕᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐSignatureWhereInputᚄ(ctx, v) + it.OwnerGidEqualFold = data + case "ownerGidContainsFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerGidContainsFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.HasSignaturesWith = data - case "hasPayloadDigests": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasPayloadDigests")) - data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + it.OwnerGidContainsFold = data + case "ownerUID": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerUID")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.HasPayloadDigests = data - case "hasPayloadDigestsWith": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasPayloadDigestsWith")) - data, err := ec.unmarshalOPayloadDigestWhereInput2ᚕᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐPayloadDigestWhereInputᚄ(ctx, v) + it.OwnerUID = data + case "ownerUIDNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerUIDNEQ")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.HasPayloadDigestsWith = data - } - } - - return it, nil -} - -func (ec *executionContext) unmarshalInputPayloadDigestWhereInput(ctx context.Context, obj interface{}) (ent.PayloadDigestWhereInput, error) { - var it ent.PayloadDigestWhereInput - asMap := map[string]interface{}{} - for k, v := range obj.(map[string]interface{}) { - asMap[k] = v - } - - fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "algorithm", "algorithmNEQ", "algorithmIn", "algorithmNotIn", "algorithmGT", "algorithmGTE", "algorithmLT", "algorithmLTE", "algorithmContains", "algorithmHasPrefix", "algorithmHasSuffix", "algorithmEqualFold", "algorithmContainsFold", "value", "valueNEQ", "valueIn", "valueNotIn", "valueGT", "valueGTE", "valueLT", "valueLTE", "valueContains", "valueHasPrefix", "valueHasSuffix", "valueEqualFold", "valueContainsFold", "hasDsse", "hasDsseWith"} - for _, k := range fieldsInOrder { - v, ok := asMap[k] - if !ok { - continue - } - switch k { - case "not": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("not")) - data, err := ec.unmarshalOPayloadDigestWhereInput2ᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐPayloadDigestWhereInput(ctx, v) + it.OwnerUIDNEQ = data + case "ownerUIDIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerUIDIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.Not = data - case "and": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("and")) - data, err := ec.unmarshalOPayloadDigestWhereInput2ᚕᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐPayloadDigestWhereInputᚄ(ctx, v) + it.OwnerUIDIn = data + case "ownerUIDNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerUIDNotIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.And = data - case "or": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("or")) - data, err := ec.unmarshalOPayloadDigestWhereInput2ᚕᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐPayloadDigestWhereInputᚄ(ctx, v) + it.OwnerUIDNotIn = data + case "ownerUIDGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerUIDGT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.Or = data - case "id": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + it.OwnerUIDGT = data + case "ownerUIDGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerUIDGTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.ID = data - case "idNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNEQ")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + it.OwnerUIDGTE = data + case "ownerUIDLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerUIDLT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IDNEQ = data - case "idIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idIn")) - data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) + it.OwnerUIDLT = data + case "ownerUIDLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerUIDLTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IDIn = data - case "idNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNotIn")) - data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) + it.OwnerUIDLTE = data + case "ownerUIDContains": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerUIDContains")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IDNotIn = data - case "idGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGT")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + it.OwnerUIDContains = data + case "ownerUIDHasPrefix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerUIDHasPrefix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IDGT = data - case "idGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGTE")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + it.OwnerUIDHasPrefix = data + case "ownerUIDHasSuffix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerUIDHasSuffix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IDGTE = data - case "idLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLT")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + it.OwnerUIDHasSuffix = data + case "ownerUIDEqualFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerUIDEqualFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IDLT = data - case "idLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLTE")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + it.OwnerUIDEqualFold = data + case "ownerUIDContainsFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerUIDContainsFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IDLTE = data - case "algorithm": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("algorithm")) + it.OwnerUIDContainsFold = data + case "permissions": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("permissions")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.Algorithm = data - case "algorithmNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("algorithmNEQ")) + it.Permissions = data + case "permissionsNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("permissionsNEQ")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.AlgorithmNEQ = data - case "algorithmIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("algorithmIn")) + it.PermissionsNEQ = data + case "permissionsIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("permissionsIn")) data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.AlgorithmIn = data - case "algorithmNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("algorithmNotIn")) + it.PermissionsIn = data + case "permissionsNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("permissionsNotIn")) data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.AlgorithmNotIn = data - case "algorithmGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("algorithmGT")) + it.PermissionsNotIn = data + case "permissionsGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("permissionsGT")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.AlgorithmGT = data - case "algorithmGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("algorithmGTE")) + it.PermissionsGT = data + case "permissionsGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("permissionsGTE")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.AlgorithmGTE = data - case "algorithmLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("algorithmLT")) + it.PermissionsGTE = data + case "permissionsLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("permissionsLT")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.AlgorithmLT = data - case "algorithmLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("algorithmLTE")) + it.PermissionsLT = data + case "permissionsLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("permissionsLTE")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.AlgorithmLTE = data - case "algorithmContains": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("algorithmContains")) + it.PermissionsLTE = data + case "permissionsContains": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("permissionsContains")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.AlgorithmContains = data - case "algorithmHasPrefix": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("algorithmHasPrefix")) + it.PermissionsContains = data + case "permissionsHasPrefix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("permissionsHasPrefix")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.AlgorithmHasPrefix = data - case "algorithmHasSuffix": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("algorithmHasSuffix")) + it.PermissionsHasPrefix = data + case "permissionsHasSuffix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("permissionsHasSuffix")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.AlgorithmHasSuffix = data - case "algorithmEqualFold": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("algorithmEqualFold")) + it.PermissionsHasSuffix = data + case "permissionsEqualFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("permissionsEqualFold")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.AlgorithmEqualFold = data - case "algorithmContainsFold": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("algorithmContainsFold")) + it.PermissionsEqualFold = data + case "permissionsContainsFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("permissionsContainsFold")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.AlgorithmContainsFold = data - case "value": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("value")) + it.PermissionsContainsFold = data + case "size": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("size")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.Value = data - case "valueNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("valueNEQ")) + it.Size = data + case "sizeNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeNEQ")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.ValueNEQ = data - case "valueIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("valueIn")) + it.SizeNEQ = data + case "sizeIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeIn")) data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.ValueIn = data - case "valueNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("valueNotIn")) + it.SizeIn = data + case "sizeNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeNotIn")) data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.ValueNotIn = data - case "valueGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("valueGT")) + it.SizeNotIn = data + case "sizeGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeGT")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.ValueGT = data - case "valueGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("valueGTE")) + it.SizeGT = data + case "sizeGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeGTE")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.ValueGTE = data - case "valueLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("valueLT")) + it.SizeGTE = data + case "sizeLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeLT")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.ValueLT = data - case "valueLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("valueLTE")) + it.SizeLT = data + case "sizeLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeLTE")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.ValueLTE = data - case "valueContains": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("valueContains")) + it.SizeLTE = data + case "sizeContains": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeContains")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.ValueContains = data - case "valueHasPrefix": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("valueHasPrefix")) + it.SizeContains = data + case "sizeHasPrefix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeHasPrefix")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.ValueHasPrefix = data - case "valueHasSuffix": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("valueHasSuffix")) + it.SizeHasPrefix = data + case "sizeHasSuffix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeHasSuffix")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.ValueHasSuffix = data - case "valueEqualFold": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("valueEqualFold")) + it.SizeHasSuffix = data + case "sizeEqualFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeEqualFold")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.ValueEqualFold = data - case "valueContainsFold": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("valueContainsFold")) + it.SizeEqualFold = data + case "sizeContainsFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeContainsFold")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.ValueContainsFold = data - case "hasDsse": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasDsse")) + it.SizeContainsFold = data + case "hasMapping": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasMapping")) data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } - it.HasDsse = data - case "hasDsseWith": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasDsseWith")) - data, err := ec.unmarshalODsseWhereInput2ᚕᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐDsseWhereInputᚄ(ctx, v) + it.HasMapping = data + case "hasMappingWith": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasMappingWith")) + data, err := ec.unmarshalOMappingWhereInput2ᚕᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐMappingWhereInputᚄ(ctx, v) if err != nil { return it, err } - it.HasDsseWith = data + it.HasMappingWith = data } } @@ -8837,11 +12935,26 @@ func (ec *executionContext) _Node(ctx context.Context, sel ast.SelectionSet, obj return graphql.Null } return ec._Dsse(ctx, sel, obj) + case *ent.Mapping: + if obj == nil { + return graphql.Null + } + return ec._Mapping(ctx, sel, obj) + case *ent.Omnitrail: + if obj == nil { + return graphql.Null + } + return ec._Omnitrail(ctx, sel, obj) case *ent.PayloadDigest: if obj == nil { return graphql.Null } return ec._PayloadDigest(ctx, sel, obj) + case *ent.Posix: + if obj == nil { + return graphql.Null + } + return ec._Posix(ctx, sel, obj) case *ent.Signature: if obj == nil { return graphql.Null @@ -8881,22 +12994,55 @@ var attestationImplementors = []string{"Attestation", "Node"} func (ec *executionContext) _Attestation(ctx context.Context, sel ast.SelectionSet, obj *ent.Attestation) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, attestationImplementors) - out := graphql.NewFieldSet(fields) - deferred := make(map[string]*graphql.FieldSet) - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("Attestation") - case "id": - out.Values[i] = ec._Attestation_id(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&out.Invalids, 1) - } - case "type": - out.Values[i] = ec._Attestation_type(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&out.Invalids, 1) + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Attestation") + case "id": + out.Values[i] = ec._Attestation_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "type": + out.Values[i] = ec._Attestation_type(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "omnitrail": + field := field + + innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Attestation_omnitrail(ctx, field, obj) + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) case "attestationCollection": field := field @@ -8980,7 +13126,7 @@ func (ec *executionContext) _AttestationCollection(ctx context.Context, sel ast. case "attestations": field := field - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -9093,13 +13239,248 @@ func (ec *executionContext) _AttestationPolicy(ctx context.Context, sel ast.Sele case "statement": field := field - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._AttestationPolicy_statement(ctx, field, obj) + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var attestationPolicyConnectionImplementors = []string{"AttestationPolicyConnection"} + +func (ec *executionContext) _AttestationPolicyConnection(ctx context.Context, sel ast.SelectionSet, obj *ent.AttestationPolicyConnection) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, attestationPolicyConnectionImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("AttestationPolicyConnection") + case "edges": + out.Values[i] = ec._AttestationPolicyConnection_edges(ctx, field, obj) + case "pageInfo": + out.Values[i] = ec._AttestationPolicyConnection_pageInfo(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "totalCount": + out.Values[i] = ec._AttestationPolicyConnection_totalCount(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var attestationPolicyEdgeImplementors = []string{"AttestationPolicyEdge"} + +func (ec *executionContext) _AttestationPolicyEdge(ctx context.Context, sel ast.SelectionSet, obj *ent.AttestationPolicyEdge) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, attestationPolicyEdgeImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("AttestationPolicyEdge") + case "node": + out.Values[i] = ec._AttestationPolicyEdge_node(ctx, field, obj) + case "cursor": + out.Values[i] = ec._AttestationPolicyEdge_cursor(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var dsseImplementors = []string{"Dsse", "Node"} + +func (ec *executionContext) _Dsse(ctx context.Context, sel ast.SelectionSet, obj *ent.Dsse) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, dsseImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Dsse") + case "id": + out.Values[i] = ec._Dsse_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "gitoidSha256": + out.Values[i] = ec._Dsse_gitoidSha256(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "payloadType": + out.Values[i] = ec._Dsse_payloadType(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "statement": + field := field + + innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Dsse_statement(ctx, field, obj) + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + case "signatures": + field := field + + innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Dsse_signatures(ctx, field, obj) + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + case "payloadDigests": + field := field + + innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._AttestationPolicy_statement(ctx, field, obj) + res = ec._Dsse_payloadDigests(ctx, field, obj) return res } @@ -9146,26 +13527,26 @@ func (ec *executionContext) _AttestationPolicy(ctx context.Context, sel ast.Sele return out } -var attestationPolicyConnectionImplementors = []string{"AttestationPolicyConnection"} +var dsseConnectionImplementors = []string{"DsseConnection"} -func (ec *executionContext) _AttestationPolicyConnection(ctx context.Context, sel ast.SelectionSet, obj *ent.AttestationPolicyConnection) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, attestationPolicyConnectionImplementors) +func (ec *executionContext) _DsseConnection(ctx context.Context, sel ast.SelectionSet, obj *ent.DsseConnection) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, dsseConnectionImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": - out.Values[i] = graphql.MarshalString("AttestationPolicyConnection") + out.Values[i] = graphql.MarshalString("DsseConnection") case "edges": - out.Values[i] = ec._AttestationPolicyConnection_edges(ctx, field, obj) + out.Values[i] = ec._DsseConnection_edges(ctx, field, obj) case "pageInfo": - out.Values[i] = ec._AttestationPolicyConnection_pageInfo(ctx, field, obj) + out.Values[i] = ec._DsseConnection_pageInfo(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "totalCount": - out.Values[i] = ec._AttestationPolicyConnection_totalCount(ctx, field, obj) + out.Values[i] = ec._DsseConnection_totalCount(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } @@ -9192,21 +13573,21 @@ func (ec *executionContext) _AttestationPolicyConnection(ctx context.Context, se return out } -var attestationPolicyEdgeImplementors = []string{"AttestationPolicyEdge"} +var dsseEdgeImplementors = []string{"DsseEdge"} -func (ec *executionContext) _AttestationPolicyEdge(ctx context.Context, sel ast.SelectionSet, obj *ent.AttestationPolicyEdge) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, attestationPolicyEdgeImplementors) +func (ec *executionContext) _DsseEdge(ctx context.Context, sel ast.SelectionSet, obj *ent.DsseEdge) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, dsseEdgeImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": - out.Values[i] = graphql.MarshalString("AttestationPolicyEdge") + out.Values[i] = graphql.MarshalString("DsseEdge") case "node": - out.Values[i] = ec._AttestationPolicyEdge_node(ctx, field, obj) + out.Values[i] = ec._DsseEdge_node(ctx, field, obj) case "cursor": - out.Values[i] = ec._AttestationPolicyEdge_cursor(ctx, field, obj) + out.Values[i] = ec._DsseEdge_cursor(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } @@ -9233,42 +13614,62 @@ func (ec *executionContext) _AttestationPolicyEdge(ctx context.Context, sel ast. return out } -var dsseImplementors = []string{"Dsse", "Node"} +var mappingImplementors = []string{"Mapping", "Node"} -func (ec *executionContext) _Dsse(ctx context.Context, sel ast.SelectionSet, obj *ent.Dsse) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, dsseImplementors) +func (ec *executionContext) _Mapping(ctx context.Context, sel ast.SelectionSet, obj *ent.Mapping) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, mappingImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": - out.Values[i] = graphql.MarshalString("Dsse") + out.Values[i] = graphql.MarshalString("Mapping") case "id": - out.Values[i] = ec._Dsse_id(ctx, field, obj) + out.Values[i] = ec._Mapping_id(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } - case "gitoidSha256": - out.Values[i] = ec._Dsse_gitoidSha256(ctx, field, obj) + case "path": + out.Values[i] = ec._Mapping_path(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } - case "payloadType": - out.Values[i] = ec._Dsse_payloadType(ctx, field, obj) + case "type": + out.Values[i] = ec._Mapping_type(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } - case "statement": + case "sha1": + out.Values[i] = ec._Mapping_sha1(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "sha256": + out.Values[i] = ec._Mapping_sha256(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "gitoidsha1": + out.Values[i] = ec._Mapping_gitoidsha1(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "gitoidsha256": + out.Values[i] = ec._Mapping_gitoidsha256(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "posix": field := field - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._Dsse_statement(ctx, field, obj) + res = ec._Mapping_posix(ctx, field, obj) return res } @@ -9292,7 +13693,7 @@ func (ec *executionContext) _Dsse(ctx context.Context, sel ast.SelectionSet, obj } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - case "signatures": + case "omnitrail": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { @@ -9301,7 +13702,10 @@ func (ec *executionContext) _Dsse(ctx context.Context, sel ast.SelectionSet, obj ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._Dsse_signatures(ctx, field, obj) + res = ec._Mapping_omnitrail(ctx, field, obj) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } return res } @@ -9325,7 +13729,79 @@ func (ec *executionContext) _Dsse(ctx context.Context, sel ast.SelectionSet, obj } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - case "payloadDigests": + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var omnitrailImplementors = []string{"Omnitrail", "Node"} + +func (ec *executionContext) _Omnitrail(ctx context.Context, sel ast.SelectionSet, obj *ent.Omnitrail) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, omnitrailImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Omnitrail") + case "id": + out.Values[i] = ec._Omnitrail_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "mappings": + field := field + + innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Omnitrail_mappings(ctx, field, obj) + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + case "attestation": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { @@ -9334,7 +13810,10 @@ func (ec *executionContext) _Dsse(ctx context.Context, sel ast.SelectionSet, obj ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._Dsse_payloadDigests(ctx, field, obj) + res = ec._Omnitrail_attestation(ctx, field, obj) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } return res } @@ -9381,29 +13860,31 @@ func (ec *executionContext) _Dsse(ctx context.Context, sel ast.SelectionSet, obj return out } -var dsseConnectionImplementors = []string{"DsseConnection"} +var pageInfoImplementors = []string{"PageInfo"} -func (ec *executionContext) _DsseConnection(ctx context.Context, sel ast.SelectionSet, obj *ent.DsseConnection) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, dsseConnectionImplementors) +func (ec *executionContext) _PageInfo(ctx context.Context, sel ast.SelectionSet, obj *entgql.PageInfo[int]) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, pageInfoImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": - out.Values[i] = graphql.MarshalString("DsseConnection") - case "edges": - out.Values[i] = ec._DsseConnection_edges(ctx, field, obj) - case "pageInfo": - out.Values[i] = ec._DsseConnection_pageInfo(ctx, field, obj) + out.Values[i] = graphql.MarshalString("PageInfo") + case "hasNextPage": + out.Values[i] = ec._PageInfo_hasNextPage(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } - case "totalCount": - out.Values[i] = ec._DsseConnection_totalCount(ctx, field, obj) + case "hasPreviousPage": + out.Values[i] = ec._PageInfo_hasPreviousPage(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } + case "startCursor": + out.Values[i] = ec._PageInfo_startCursor(ctx, field, obj) + case "endCursor": + out.Values[i] = ec._PageInfo_endCursor(ctx, field, obj) default: panic("unknown field " + strconv.Quote(field.Name)) } @@ -9427,24 +13908,65 @@ func (ec *executionContext) _DsseConnection(ctx context.Context, sel ast.Selecti return out } -var dsseEdgeImplementors = []string{"DsseEdge"} +var payloadDigestImplementors = []string{"PayloadDigest", "Node"} -func (ec *executionContext) _DsseEdge(ctx context.Context, sel ast.SelectionSet, obj *ent.DsseEdge) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, dsseEdgeImplementors) +func (ec *executionContext) _PayloadDigest(ctx context.Context, sel ast.SelectionSet, obj *ent.PayloadDigest) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, payloadDigestImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": - out.Values[i] = graphql.MarshalString("DsseEdge") - case "node": - out.Values[i] = ec._DsseEdge_node(ctx, field, obj) - case "cursor": - out.Values[i] = ec._DsseEdge_cursor(ctx, field, obj) + out.Values[i] = graphql.MarshalString("PayloadDigest") + case "id": + out.Values[i] = ec._PayloadDigest_id(ctx, field, obj) if out.Values[i] == graphql.Null { - out.Invalids++ + atomic.AddUint32(&out.Invalids, 1) + } + case "algorithm": + out.Values[i] = ec._PayloadDigest_algorithm(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "value": + out.Values[i] = ec._PayloadDigest_value(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "dsse": + field := field + + innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._PayloadDigest_dsse(ctx, field, obj) + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) default: panic("unknown field " + strconv.Quote(field.Name)) } @@ -9468,81 +13990,103 @@ func (ec *executionContext) _DsseEdge(ctx context.Context, sel ast.SelectionSet, return out } -var pageInfoImplementors = []string{"PageInfo"} +var posixImplementors = []string{"Posix", "Node"} -func (ec *executionContext) _PageInfo(ctx context.Context, sel ast.SelectionSet, obj *entgql.PageInfo[int]) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, pageInfoImplementors) +func (ec *executionContext) _Posix(ctx context.Context, sel ast.SelectionSet, obj *ent.Posix) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, posixImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": - out.Values[i] = graphql.MarshalString("PageInfo") - case "hasNextPage": - out.Values[i] = ec._PageInfo_hasNextPage(ctx, field, obj) + out.Values[i] = graphql.MarshalString("Posix") + case "id": + out.Values[i] = ec._Posix_id(ctx, field, obj) if out.Values[i] == graphql.Null { - out.Invalids++ + atomic.AddUint32(&out.Invalids, 1) } - case "hasPreviousPage": - out.Values[i] = ec._PageInfo_hasPreviousPage(ctx, field, obj) + case "atime": + out.Values[i] = ec._Posix_atime(ctx, field, obj) if out.Values[i] == graphql.Null { - out.Invalids++ + atomic.AddUint32(&out.Invalids, 1) + } + case "ctime": + out.Values[i] = ec._Posix_ctime(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "creationTime": + out.Values[i] = ec._Posix_creationTime(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "extendedAttributes": + out.Values[i] = ec._Posix_extendedAttributes(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "fileDeviceID": + out.Values[i] = ec._Posix_fileDeviceID(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "fileFlags": + out.Values[i] = ec._Posix_fileFlags(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "fileInode": + out.Values[i] = ec._Posix_fileInode(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "fileSystemID": + out.Values[i] = ec._Posix_fileSystemID(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "fileType": + out.Values[i] = ec._Posix_fileType(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "hardLinkCount": + out.Values[i] = ec._Posix_hardLinkCount(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "mtime": + out.Values[i] = ec._Posix_mtime(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "metadataCtime": + out.Values[i] = ec._Posix_metadataCtime(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "ownerGid": + out.Values[i] = ec._Posix_ownerGid(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) } - case "startCursor": - out.Values[i] = ec._PageInfo_startCursor(ctx, field, obj) - case "endCursor": - out.Values[i] = ec._PageInfo_endCursor(ctx, field, obj) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch(ctx) - if out.Invalids > 0 { - return graphql.Null - } - - atomic.AddInt32(&ec.deferred, int32(len(deferred))) - - for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ - Label: label, - Path: graphql.GetPath(ctx), - FieldSet: dfs, - Context: ctx, - }) - } - - return out -} - -var payloadDigestImplementors = []string{"PayloadDigest", "Node"} - -func (ec *executionContext) _PayloadDigest(ctx context.Context, sel ast.SelectionSet, obj *ent.PayloadDigest) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, payloadDigestImplementors) - - out := graphql.NewFieldSet(fields) - deferred := make(map[string]*graphql.FieldSet) - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("PayloadDigest") - case "id": - out.Values[i] = ec._PayloadDigest_id(ctx, field, obj) + case "ownerUID": + out.Values[i] = ec._Posix_ownerUID(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } - case "algorithm": - out.Values[i] = ec._PayloadDigest_algorithm(ctx, field, obj) + case "permissions": + out.Values[i] = ec._Posix_permissions(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } - case "value": - out.Values[i] = ec._PayloadDigest_value(ctx, field, obj) + case "size": + out.Values[i] = ec._Posix_size(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } - case "dsse": + case "mapping": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { @@ -9551,7 +14095,10 @@ func (ec *executionContext) _PayloadDigest(ctx context.Context, sel ast.Selectio ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._PayloadDigest_dsse(ctx, field, obj) + res = ec._Posix_mapping(ctx, field, obj) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } return res } @@ -9620,7 +14167,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr case "node": field := field - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -9784,7 +14331,7 @@ func (ec *executionContext) _Signature(ctx context.Context, sel ast.SelectionSet case "dsse": field := field - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -9817,7 +14364,7 @@ func (ec *executionContext) _Signature(ctx context.Context, sel ast.SelectionSet case "timestamps": field := field - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -9930,7 +14477,7 @@ func (ec *executionContext) _Statement(ctx context.Context, sel ast.SelectionSet case "policy": field := field - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -9963,7 +14510,7 @@ func (ec *executionContext) _Statement(ctx context.Context, sel ast.SelectionSet case "attestationCollections": field := field - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -9996,7 +14543,7 @@ func (ec *executionContext) _Statement(ctx context.Context, sel ast.SelectionSet case "dsse": field := field - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -10073,7 +14620,7 @@ func (ec *executionContext) _Subject(ctx context.Context, sel ast.SelectionSet, case "subjectDigests": field := field - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -10106,7 +14653,7 @@ func (ec *executionContext) _Subject(ctx context.Context, sel ast.SelectionSet, case "statement": field := field - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -10234,7 +14781,7 @@ func (ec *executionContext) _SubjectDigest(ctx context.Context, sel ast.Selectio case "subject": field := field - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -10357,7 +14904,7 @@ func (ec *executionContext) _Timestamp(ctx context.Context, sel ast.SelectionSet case "signature": field := field - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -10901,6 +15448,21 @@ func (ec *executionContext) marshalNInt2int(ctx context.Context, sel ast.Selecti return res } +func (ec *executionContext) marshalNMapping2ᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐMapping(ctx context.Context, sel ast.SelectionSet, v *ent.Mapping) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._Mapping(ctx, sel, v) +} + +func (ec *executionContext) unmarshalNMappingWhereInput2ᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐMappingWhereInput(ctx context.Context, v interface{}) (*ent.MappingWhereInput, error) { + res, err := ec.unmarshalInputMappingWhereInput(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + func (ec *executionContext) marshalNNode2ᚕgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐNoder(ctx context.Context, sel ast.SelectionSet, v []ent.Noder) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup @@ -10939,6 +15501,21 @@ func (ec *executionContext) marshalNNode2ᚕgithubᚗcomᚋinᚑtotoᚋarchivist return ret } +func (ec *executionContext) marshalNOmnitrail2ᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐOmnitrail(ctx context.Context, sel ast.SelectionSet, v *ent.Omnitrail) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._Omnitrail(ctx, sel, v) +} + +func (ec *executionContext) unmarshalNOmnitrailWhereInput2ᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐOmnitrailWhereInput(ctx context.Context, v interface{}) (*ent.OmnitrailWhereInput, error) { + res, err := ec.unmarshalInputOmnitrailWhereInput(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + func (ec *executionContext) marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo(ctx context.Context, sel ast.SelectionSet, v entgql.PageInfo[int]) graphql.Marshaler { return ec._PageInfo(ctx, sel, &v) } @@ -10958,6 +15535,21 @@ func (ec *executionContext) unmarshalNPayloadDigestWhereInput2ᚖgithubᚗcomᚋ return &res, graphql.ErrorOnPath(ctx, err) } +func (ec *executionContext) marshalNPosix2ᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐPosix(ctx context.Context, sel ast.SelectionSet, v *ent.Posix) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._Posix(ctx, sel, v) +} + +func (ec *executionContext) unmarshalNPosixWhereInput2ᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐPosixWhereInput(ctx context.Context, v interface{}) (*ent.PosixWhereInput, error) { + res, err := ec.unmarshalInputPosixWhereInput(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + func (ec *executionContext) marshalNSignature2ᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐSignature(ctx context.Context, sel ast.SelectionSet, v *ent.Signature) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { @@ -11755,6 +16347,81 @@ func (ec *executionContext) marshalOInt2ᚖint(ctx context.Context, sel ast.Sele return res } +func (ec *executionContext) marshalOMapping2ᚕᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐMappingᚄ(ctx context.Context, sel ast.SelectionSet, v []*ent.Mapping) graphql.Marshaler { + if v == nil { + return graphql.Null + } + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + fc := &graphql.FieldContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithFieldContext(ctx, fc) + f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalNMapping2ᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐMapping(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + + return ret +} + +func (ec *executionContext) unmarshalOMappingWhereInput2ᚕᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐMappingWhereInputᚄ(ctx context.Context, v interface{}) ([]*ent.MappingWhereInput, error) { + if v == nil { + return nil, nil + } + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(v) + } + var err error + res := make([]*ent.MappingWhereInput, len(vSlice)) + for i := range vSlice { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) + res[i], err = ec.unmarshalNMappingWhereInput2ᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐMappingWhereInput(ctx, vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) unmarshalOMappingWhereInput2ᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐMappingWhereInput(ctx context.Context, v interface{}) (*ent.MappingWhereInput, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalInputMappingWhereInput(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + func (ec *executionContext) marshalONode2githubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐNoder(ctx context.Context, sel ast.SelectionSet, v ent.Noder) graphql.Marshaler { if v == nil { return graphql.Null @@ -11762,6 +16429,41 @@ func (ec *executionContext) marshalONode2githubᚗcomᚋinᚑtotoᚋarchivista return ec._Node(ctx, sel, v) } +func (ec *executionContext) marshalOOmnitrail2ᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐOmnitrail(ctx context.Context, sel ast.SelectionSet, v *ent.Omnitrail) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._Omnitrail(ctx, sel, v) +} + +func (ec *executionContext) unmarshalOOmnitrailWhereInput2ᚕᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐOmnitrailWhereInputᚄ(ctx context.Context, v interface{}) ([]*ent.OmnitrailWhereInput, error) { + if v == nil { + return nil, nil + } + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(v) + } + var err error + res := make([]*ent.OmnitrailWhereInput, len(vSlice)) + for i := range vSlice { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) + res[i], err = ec.unmarshalNOmnitrailWhereInput2ᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐOmnitrailWhereInput(ctx, vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) unmarshalOOmnitrailWhereInput2ᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐOmnitrailWhereInput(ctx context.Context, v interface{}) (*ent.OmnitrailWhereInput, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalInputOmnitrailWhereInput(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + func (ec *executionContext) marshalOPayloadDigest2ᚕᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐPayloadDigestᚄ(ctx context.Context, sel ast.SelectionSet, v []*ent.PayloadDigest) graphql.Marshaler { if v == nil { return graphql.Null @@ -11837,6 +16539,81 @@ func (ec *executionContext) unmarshalOPayloadDigestWhereInput2ᚖgithubᚗcomᚋ return &res, graphql.ErrorOnPath(ctx, err) } +func (ec *executionContext) marshalOPosix2ᚕᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐPosixᚄ(ctx context.Context, sel ast.SelectionSet, v []*ent.Posix) graphql.Marshaler { + if v == nil { + return graphql.Null + } + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + fc := &graphql.FieldContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithFieldContext(ctx, fc) + f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalNPosix2ᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐPosix(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + + return ret +} + +func (ec *executionContext) unmarshalOPosixWhereInput2ᚕᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐPosixWhereInputᚄ(ctx context.Context, v interface{}) ([]*ent.PosixWhereInput, error) { + if v == nil { + return nil, nil + } + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(v) + } + var err error + res := make([]*ent.PosixWhereInput, len(vSlice)) + for i := range vSlice { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) + res[i], err = ec.unmarshalNPosixWhereInput2ᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐPosixWhereInput(ctx, vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) unmarshalOPosixWhereInput2ᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐPosixWhereInput(ctx context.Context, v interface{}) (*ent.PosixWhereInput, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalInputPosixWhereInput(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + func (ec *executionContext) marshalOSignature2ᚕᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐSignatureᚄ(ctx context.Context, sel ast.SelectionSet, v []*ent.Signature) graphql.Marshaler { if v == nil { return graphql.Null diff --git a/go.mod b/go.mod index d34b7317..f10617d0 100644 --- a/go.mod +++ b/go.mod @@ -12,6 +12,7 @@ require ( github.com/antonfisher/nested-logrus-formatter v1.3.1 github.com/digitorus/timestamp v0.0.0-20231217203849-220c5c2851b7 github.com/edwarnicke/gitoid v0.0.0-20220710194850-1be5bfda1f9d + github.com/fkautz/omnitrail-go v0.0.0-20230808061951-37d34c23539d github.com/go-sql-driver/mysql v1.8.1 github.com/gorilla/handlers v1.5.2 github.com/gorilla/mux v1.8.1 @@ -79,6 +80,7 @@ require ( github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect + github.com/omnibor/omnibor-go v0.0.0-20230521145532-a77de61a16cd // indirect github.com/open-policy-agent/opa v0.64.0 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect github.com/prometheus/client_golang v1.19.0 // indirect diff --git a/go.sum b/go.sum index afd2b9b4..8a68b923 100644 --- a/go.sum +++ b/go.sum @@ -117,6 +117,8 @@ github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1m github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg= github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= +github.com/fkautz/omnitrail-go v0.0.0-20230808061951-37d34c23539d h1:p4DOjnN5IAuUhtksK+RuwR2q3VclzeI1+zh+AfNFFjw= +github.com/fkautz/omnitrail-go v0.0.0-20230808061951-37d34c23539d/go.mod h1:To+426All36lUwebm2u5Qptl3daW1Nnk+LHrkTFhiWQ= github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw= github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g= github.com/foxcpp/go-mockdns v1.1.0 h1:jI0rD8M0wuYAxL7r/ynTrCQQq0BVqfB99Vgk7DlmewI= @@ -260,6 +262,8 @@ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= +github.com/omnibor/omnibor-go v0.0.0-20230521145532-a77de61a16cd h1:25EpGVgctk6V3DUa1gqFHvjVbmdWqM+jBZAed7p/krQ= +github.com/omnibor/omnibor-go v0.0.0-20230521145532-a77de61a16cd/go.mod h1:ArlQivzDQvZnFe8itjlA3ndPTXd9iWOgqzF31OyIEFQ= github.com/open-policy-agent/opa v0.64.0 h1:2g0JTt78zxhFaoBmZViY4UXvtOlzBjhhrnyrIxkm+tI= github.com/open-policy-agent/opa v0.64.0/go.mod h1:j4VeLorVpKipnkQ2TDjWshEuV3cvP/rHzQhYaraUXZY= github.com/pjbgf/sha1cd v0.3.0 h1:4D5XXmUUBUl/xQ6IjCkEAbqXskkq/4O7LmGn0AqMDs4= diff --git a/internal/metadatastorage/attestationcollection/parserstorer.go b/internal/metadatastorage/attestationcollection/parserstorer.go index eaab6f5c..57bf6108 100644 --- a/internal/metadatastorage/attestationcollection/parserstorer.go +++ b/internal/metadatastorage/attestationcollection/parserstorer.go @@ -1,4 +1,4 @@ -// Copyright 2023 The Archivista Contributors +// Copyright 2024 The Archivista Contributors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -18,18 +18,18 @@ import ( "context" "encoding/json" + omnitrail "github.com/fkautz/omnitrail-go" "github.com/in-toto/archivista/ent" "github.com/in-toto/archivista/internal/metadatastorage" "github.com/in-toto/go-witness/attestation" ) const ( + // Predicate is the URL that defines the schema for the attestation collection. Predicate = "https://witness.testifysec.com/attestation-collection/v0.1" ) -// attestation.Collection from go-witness will try to parse each of the attestations by calling their factory functions, -// which require the attestations to be registered in the go-witness library. We don't really care about the actual attestation -// data for the purposes here, so just leave it as a raw message. +// ParsedCollection represents a collection of attestations. type ParsedCollection struct { attestation.Collection Attestations []struct { @@ -38,16 +38,18 @@ type ParsedCollection struct { } `json:"attestations"` } +// Parse takes a byte array of JSON data and unmarshals it into a ParsedCollection. func Parse(data []byte) (metadatastorage.Storer, error) { - parsedCollection := ParsedCollection{} + var parsedCollection ParsedCollection if err := json.Unmarshal(data, &parsedCollection); err != nil { return parsedCollection, err } - return parsedCollection, nil } +// Store saves the parsed collection into the database. func (parsedCollection ParsedCollection) Store(ctx context.Context, tx *ent.Tx, stmtID int) error { + // Create a new AttestationCollection entity in the database. collection, err := tx.AttestationCollection.Create(). SetStatementID(stmtID). SetName(parsedCollection.Name). @@ -56,13 +58,84 @@ func (parsedCollection ParsedCollection) Store(ctx context.Context, tx *ent.Tx, return err } + // Iterate over each attestation in the parsed collection. for _, a := range parsedCollection.Attestations { - if err := tx.Attestation.Create(). + // Create a new Attestation entity in the database. + attestation, err := tx.Attestation.Create(). SetAttestationCollectionID(collection.ID). SetType(a.Type). - Exec(ctx); err != nil { + Save(ctx) + if err != nil { return err } + + // Check if the attestation type is "https://witness.dev/attestations/omnitrail/v0.1". + if a.Type == "https://witness.dev/attestations/omnitrail/v0.1" { + var envelope struct { + Envelope json.RawMessage `json:"Envelope"` + } + // Unmarshal the attestation into an envelope. + if err := json.Unmarshal(a.Attestation, &envelope); err != nil { + return err + } + + var omnitrailData omnitrail.Envelope + // Unmarshal the envelope into omnitrailData. + if err := json.Unmarshal(envelope.Envelope, &omnitrailData); err != nil { + return err + } + + // Create a new Omnitrail entity in the database. + omnitrailEntity, err := tx.Omnitrail.Create(). + SetAttestationID(attestation.ID). + Save(ctx) + if err != nil { + return err + } + + // Iterate over each mapping in the omnitrail data. + for key, element := range omnitrailData.Mapping { + // Create a new Mapping entity in the database. + mappingEntity, err := tx.Mapping.Create(). + SetPath(key). + SetOmnitrailID(omnitrailEntity.ID). + SetType(element.Type). + SetSha1(element.Sha1). + SetSha256(element.Sha256). + SetGitoidSha1(element.Sha1Gitoid). + SetGitoidSha256(element.Sha256Gitoid). + Save(ctx) + if err != nil { + return err + } + + // Extract posix data from the element. + posixData := element.Posix + // Create a new Posix entity in the database. + _, err = tx.Posix.Create(). + SetAtime(posixData.ATime). + SetCtime(posixData.CTime). + SetCreationTime(posixData.CreationTime). + SetExtendedAttributes(posixData.ExtendedAttributes). + SetFileDeviceID(posixData.FileDeviceID). + SetFileFlags(posixData.FileFlags). + SetFileInode(posixData.FileInode). + SetFileSystemID(posixData.FileSystemID). + SetFileType(posixData.FileType). + SetHardLinkCount(posixData.HardLinkCount). + SetMtime(posixData.MTime). + SetMetadataCtime(posixData.MetadataCTime). + SetOwnerUID(posixData.OwnerUID). + SetOwnerGid(posixData.OwnerGID). + SetPermissions(posixData.Permissions). + SetSize(posixData.Size). + SetMappingID(mappingEntity.ID). + Save(ctx) + if err != nil { + return err + } + } + } } return nil