Skip to content

Commit

Permalink
feat: Implements the basic schema for Policy
Browse files Browse the repository at this point in the history
Adds the basic schema for the policy

Signed-off-by: Kairo Araujo <[email protected]>
  • Loading branch information
kairoaraujo committed Apr 10, 2024
1 parent 7355f33 commit ac5e1d2
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
56 changes: 56 additions & 0 deletions ent/schema/attestationpolicy.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// 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.
// 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/contrib/entgql"
"entgo.io/ent"
"entgo.io/ent/schema"
"entgo.io/ent/schema/edge"
"entgo.io/ent/schema/field"
"entgo.io/ent/schema/index"
)

// Attestation represents an attestation from a witness attestation collection
type AttestationPolicy struct {
ent.Schema
}

func (AttestationPolicy) Fields() []ent.Field {
return []ent.Field{
field.String("name").NotEmpty(),
}
}

// Edges of the AttestationPolicy.
func (AttestationPolicy) Edges() []ent.Edge {
return []ent.Edge{
edge.From("statement", Statement.Type).
Ref("policies").Unique(),
}
}

func (AttestationPolicy) Indexes() []ent.Index {
return []ent.Index{
index.Fields("name"),
}
}

func (AttestationPolicy) Annotations() []schema.Annotation {
return []schema.Annotation{
entgql.RelayConnection(),
entgql.QueryField(),
}
}
1 change: 1 addition & 0 deletions ent/schema/statement.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ func (Statement) Fields() []ent.Field {
func (Statement) Edges() []ent.Edge {
return []ent.Edge{
edge.To("subjects", Subject.Type).Annotations(entgql.RelayConnection()),
edge.To("policies", AttestationPolicy.Type).Annotations(entgql.RelayConnection()),
edge.To("attestation_collections", AttestationCollection.Type).Unique(),

edge.From("dsse", Dsse.Type).Ref("statement"),
Expand Down

0 comments on commit ac5e1d2

Please sign in to comment.