Skip to content

Commit

Permalink
Add clarifying comment explaining e.Metadata check
Browse files Browse the repository at this point in the history
Signed-off-by: Enis Inan <[email protected]>
  • Loading branch information
ekinanp committed Feb 3, 2020
1 parent 80c9ebb commit da8e63d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 4 additions & 0 deletions cmd/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ func docsMain(cmd *cobra.Command, args []string) exitCode {
//
// if the entry has any supported attributes. Otherwise, it prints an appropriate
// note then prints the attributes/metadata description.
//
// NOTE: If the entry has attributes but doesn't have any partial metadata, then
// entry.Metadata contains all of the attributes so this check still works. See
// plugin.PartialMetadata's comments for more details.
if len(entry.Metadata) > 0 {
addSection(docs, stringifySupportedAttributes(path, entry))
}
Expand Down
4 changes: 3 additions & 1 deletion plugin/methodWrappers.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,9 @@ func Size(ctx context.Context, e Entry) (uint64, error) {
}

// PartialMetadata returns the entry's partial metadata, a subset of the entry's
// metadata that is typically provided by the plugin API's List endpoint.
// metadata that is typically provided by the plugin API's List endpoint. If the
// entry didn't specify any partial metadata, then this returns Attributes(e).ToMap()
// to enforce the "attributes are a subset of the partial metadata" invariant.
func PartialMetadata(e Entry) JSONObject {
return e.eb().partialMetadata()
}
Expand Down

0 comments on commit da8e63d

Please sign in to comment.