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

Move the repository package under examples/repository #656

Merged
merged 1 commit into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion examples/multirepo/repository/generate_metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ import (
"time"

"github.com/sigstore/sigstore/pkg/signature"
"github.com/theupdateframework/go-tuf/v2/examples/repository/repository"
"github.com/theupdateframework/go-tuf/v2/metadata"
"github.com/theupdateframework/go-tuf/v2/metadata/repository"
)

func main() {
Expand Down
2 changes: 1 addition & 1 deletion examples/repository/basic_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ import (
"time"

"github.com/sigstore/sigstore/pkg/signature"
"github.com/theupdateframework/go-tuf/v2/examples/repository/repository"
"github.com/theupdateframework/go-tuf/v2/metadata"
"github.com/theupdateframework/go-tuf/v2/metadata/repository"
)

// A TUF repository example using the low-level TUF Metadata API.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,57 +21,57 @@ import (
"github.com/theupdateframework/go-tuf/v2/metadata"
)

// repositoryType struct for storing metadata
type repositoryType struct {
// Type struct for storing metadata
type Type struct {
root *metadata.Metadata[metadata.RootType]
snapshot *metadata.Metadata[metadata.SnapshotType]
timestamp *metadata.Metadata[metadata.TimestampType]
targets map[string]*metadata.Metadata[metadata.TargetsType]
}

// New creates an empty repository instance
func New() *repositoryType {
return &repositoryType{
func New() *Type {
return &Type{
targets: map[string]*metadata.Metadata[metadata.TargetsType]{},
}
}

// Root returns metadata of type Root
func (r *repositoryType) Root() *metadata.Metadata[metadata.RootType] {
func (r *Type) Root() *metadata.Metadata[metadata.RootType] {
return r.root
}

// SetRoot sets metadata of type Root
func (r *repositoryType) SetRoot(meta *metadata.Metadata[metadata.RootType]) {
func (r *Type) SetRoot(meta *metadata.Metadata[metadata.RootType]) {
r.root = meta
}

// Snapshot returns metadata of type Snapshot
func (r *repositoryType) Snapshot() *metadata.Metadata[metadata.SnapshotType] {
func (r *Type) Snapshot() *metadata.Metadata[metadata.SnapshotType] {
return r.snapshot
}

// SetSnapshot sets metadata of type Snapshot
func (r *repositoryType) SetSnapshot(meta *metadata.Metadata[metadata.SnapshotType]) {
func (r *Type) SetSnapshot(meta *metadata.Metadata[metadata.SnapshotType]) {
r.snapshot = meta
}

// Timestamp returns metadata of type Timestamp
func (r *repositoryType) Timestamp() *metadata.Metadata[metadata.TimestampType] {
func (r *Type) Timestamp() *metadata.Metadata[metadata.TimestampType] {
return r.timestamp
}

// SetTimestamp sets metadata of type Timestamp
func (r *repositoryType) SetTimestamp(meta *metadata.Metadata[metadata.TimestampType]) {
func (r *Type) SetTimestamp(meta *metadata.Metadata[metadata.TimestampType]) {
r.timestamp = meta
}

// Targets returns metadata of type Targets
func (r *repositoryType) Targets(name string) *metadata.Metadata[metadata.TargetsType] {
func (r *Type) Targets(name string) *metadata.Metadata[metadata.TargetsType] {
return r.targets[name]
}

// SetTargets sets metadata of type Targets
func (r *repositoryType) SetTargets(name string, meta *metadata.Metadata[metadata.TargetsType]) {
func (r *Type) SetTargets(name string, meta *metadata.Metadata[metadata.TargetsType]) {
r.targets[name] = meta
}
Loading