Skip to content

Commit

Permalink
chore: normalizes attribution notice comments and adds additional whe…
Browse files Browse the repository at this point in the history
…re missing

- Adds attrbution for adapted generic Graph and iterator implementation
- Adds reference to NodeBudget adaptation

Signed-off-by: Jennifer Power <[email protected]>
  • Loading branch information
jpower432 committed Oct 2, 2023
1 parent 0c92cc9 commit 7f6bdfb
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 5 deletions.
3 changes: 3 additions & 0 deletions attributes/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,6 @@ package attributes

// This package contains helper functions when creating new attributes.
// WARNING: The helper functions (attribute.Reflect) in this package use reflection and therefore will incur a performance penalty.

// Similar implementation to the go-ipld-prime library.
// Reference: https://github.com/ipld/go-ipld-prime/tree/master/node/basicnode
3 changes: 3 additions & 0 deletions model/traversal/budget.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import (
"github.com/emporous/emporous-go/model"
)

// Similar to the budget in the go-ipld-prime library.
// Reference: https://github.com/ipld/go-ipld-prime/blob/ab0f17bec1e700e4c76a6bbc28e7260cea7c035d/traversal/fns.go#L114

// Budget tracks budgeted operations during graph traversal.
type Budget struct {
// Maximum numbers of nodes to visit in a single traversal operator before stopping.
Expand Down
5 changes: 5 additions & 0 deletions nodes/collection/collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ var (
_ model.Iterator = &Collection{}
)

// Adapted from gonum/graph/simple/directed.go.
// Reference: https://github.com/gonum/gonum/blob/e8ed540b8ee27ad9adf717046542d9ed24eb9215/graph/simple/directed.go#L36
// Copyright ©2013 The Gonum Authors. All rights reserved.
// Use of this source code is governed by a BSD-style

// Collection is implementation of a model Node represent one OCI artifact
// stored in memory.
// WARNING: Collection type is not thread-safe.
Expand Down
7 changes: 7 additions & 0 deletions nodes/collection/iterator.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ var (
_ model.Iterator = &ByAttributesIterator{}
)

// Adapted from gonum/graph/iterator/nodes.go
// Reference: https://github.com/gonum/gonum/blob/master/graph/iterator/nodes.go
// Copyright ©2013 The Gonum Authors. All rights reserved.
// Use of this source code is governed by a BSD-style

// Note(jpower432): Could possibly removed or deprecated. I do not believe this is used anywhere.

// InOrderIterator implements the model.Iterator interface and traverse the nodes
// in the order provided.
type InOrderIterator struct {
Expand Down
8 changes: 8 additions & 0 deletions nodes/collection/loader/manifest_to_collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,14 @@ func addOrGetNode(graph *collection.Collection, desc ocispec.Descriptor) (model.
return n, nil
}

// Adapted from the `oras` content.Successors.
// Reference: https://github.com/oras-project/oras-go/blob/a428ca67f59b94f7365298870bcac78c769b80bd/content/graph.go#L50
// Copyright The ORAS Authors.
// Apache License 2.0
// Changes:
// - Added FetcherFunc to allow for custom fetching of content.


// getSuccessor returns the nodes directly pointed by the current node. This is adapted from the `oras` content.Successors
// to allow the use of a function signature to pull descriptor content.
func getSuccessors(ctx context.Context, fetcher FetcherFunc, node ocispec.Descriptor) ([]ocispec.Descriptor, error) {
Expand Down
3 changes: 2 additions & 1 deletion registryclient/orasclient/oras.go
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,8 @@ func (c *orasClient) setupRepo(ref string) (*remote.Repository, error) {
}

// TODO(jpower432): PR upstream so that this can be done with the pre-copy option. Currently the error to skip descriptors is
// private https://github.com/oras-project/oras-go/blob/9e5b1419cdedd6240a5bf836c83f75270ba9d74b/copy.go#L49.
// private
// Reference: https://github.com/oras-project/oras-go/blob/9e5b1419cdedd6240a5bf836c83f75270ba9d74b/copy.go#L49.

// successorFnWithSparseManifest defines a successor function to use with oras.Copy that will skip any expected linked content (i.e. sparse manifests)
func successorFnWithSparseManifests(ctx context.Context, fetcher orascontent.Fetcher, desc ocispec.Descriptor) ([]ocispec.Descriptor, error) {
Expand Down
11 changes: 7 additions & 4 deletions registryclient/orasclient/pack.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,13 @@ var (
ErrInvalidDateTimeFormat = errors.New("invalid date and time format")
)

// PackOptions and Pack are modified version of the upstream oras.Pack.
// The main difference is that the timestamp information is not optional in the annotations.
// To ensure digest reproducibility for this effort, timestamp information will be collected and stored
// in predicate information in the artifact attestations.
// PackOptions and Pack are modified versions of the upstream oras.Pack.
// Reference: https://github.com/oras-project/oras-go/blob/main/pack.go
// Copyright The ORAS Authors.
// Apache License 2.0
// Changes:
// - Add `DisableTimestamp` option to disable the creation timestamp annotation.

// TODO(jpower432): PR this back to `oras-go` if it makes sense.

// PackOptions contains parameters for Pack.
Expand Down

0 comments on commit 7f6bdfb

Please sign in to comment.