Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include Metadata Schema #269

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
feat: add metadata schema
Signed-off-by: Kairo Araujo <[email protected]>
Kairo Araujo committed May 8, 2024

Unverified

This user has not yet uploaded their public signing key.
commit 3b0a64a83055d8360561a13fa917af6c111d9cbb
1 change: 1 addition & 0 deletions ent/schema/dsse.go
Original file line number Diff line number Diff line change
@@ -41,6 +41,7 @@ func (Dsse) Edges() []ent.Edge {
edge.To("statement", Statement.Type).Unique(),
edge.To("signatures", Signature.Type),
edge.To("payload_digests", PayloadDigest.Type),
edge.To("metadata", Metadata.Type),
}
}

46 changes: 46 additions & 0 deletions ent/schema/metadata.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// 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"
"entgo.io/ent/schema/index"
)

type Metadata struct {
ent.Schema
}

func (Metadata) Fields() []ent.Field {
return []ent.Field{
field.String("key").NotEmpty().Comment("Key value for the metadata item"),
field.String("value").NotEmpty().Comment("Value for the metadata item"),
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @jkjell,
Should we have a string as a value or any data structure?
Any data structure could bring some flexibility, such as in the unrecognized fields TUF uses.
IMO, it helps a lot in application integrations or even operational usage.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️ the idea. The biggest unknown for me is if/how that complicates the creation of metadata (i.e. if we go the HTTP header route or something else)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest having it in the DSSE envelope JSON, but I know many people disagree.

{
    "payload": "payload.....",
    "payloadType": "https://witness.testifysec.com/...",
    "signatures": [
        {
            "keyid": "keyid...",
            "sig": "signature..."
        }
    ],
    "metadata": "any"
}

}
}

func (Metadata) Indexes() []ent.Index {
return []ent.Index{
index.Fields("key", "value").Unique(),
}
}

func (Metadata) Edges() []ent.Edge {
return []ent.Edge{
edge.From("envelope", Dsse.Type).
Ref("metadata"),
}
}