entity

package
v0.2402.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 20, 2024 License: Apache-2.0 Imports: 11 Imported by: 11

Documentation

Overview

Package entity implements common entity routines.

Index

Constants

View Source
const (
	// LatestDescriptorVersion is the latest descriptor version that should be
	// used for all new descriptors. Using earlier versions may be rejected.
	LatestDescriptorVersion = 2

	// MinDescriptorVersion is the minimum descriptor version that is allowed.
	MinDescriptorVersion = 1
	// MaxDescriptorVersion is the maximum descriptor version that is allowed.
	MaxDescriptorVersion = LatestDescriptorVersion
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Entity

type Entity struct {
	cbor.Versioned

	// ID is the public key identifying the entity.
	ID signature.PublicKey `json:"id"`

	// Nodes is the vector of node identity keys owned by this entity, that
	// will sign the descriptor with the node signing key rather than the
	// entity signing key.
	Nodes []signature.PublicKey `json:"nodes,omitempty"`
}

Entity represents an entity that controls one or more Nodes and or services.

func Generate

func Generate(baseDir string, signerFactory signature.SignerFactory, template *Entity) (*Entity, signature.Signer, error)

Generate generates a new entity and serializes it to disk.

func GenerateWithSigner

func GenerateWithSigner(baseDir string, signer signature.Signer, template *Entity) (*Entity, error)

GenerateWithSigner generates a new entity using an existing signer and serializes it to disk.

func Load

func Load(baseDir string, signerFactory signature.SignerFactory) (*Entity, signature.Signer, error)

Load loads an existing entity from disk.

func LoadDescriptor

func LoadDescriptor(f string) (*Entity, error)

LoadDescriptor loads an existing entity from disk, without loading the signer. Note: This takes the path to the descriptor rather than a base directory.

func TestEntity

func TestEntity() (*Entity, signature.Signer, error)

TestEntity returns the built-in test entity and signer.

func (*Entity) HasNode added in v0.2200.0

func (e *Entity) HasNode(id signature.PublicKey) bool

HasNode checks if the given node is in this entity's node whitelist.

func (*Entity) Save

func (e *Entity) Save(baseDir string) error

Save saves the JSON serialized entity descriptor.

func (Entity) String

func (e Entity) String() string

String returns a string representation of itself.

func (*Entity) UnmarshalCBOR added in v0.2100.0

func (e *Entity) UnmarshalCBOR(data []byte) error

UnmarshalCBOR is a custom deserializer that handles both v1 and v2 Entity structures. A v1 structure is converted to v2 seamlessly if the field AllowEntitySignedNodes is false or missing, otherwise an error is returned.

func (*Entity) ValidateBasic

func (e *Entity) ValidateBasic(strictVersion bool) error

ValidateBasic performs basic descriptor validity checks.

type SignedEntity

type SignedEntity struct {
	signature.Signed
}

SignedEntity is a signed blob containing a CBOR-serialized Entity.

func SignEntity

func SignEntity(signer signature.Signer, context signature.Context, entity *Entity) (*SignedEntity, error)

SignEntity serializes the Entity and signs the result.

func (*SignedEntity) Open

func (s *SignedEntity) Open(context signature.Context, entity *Entity) error

Open first verifies the blob signature and then unmarshals the blob.

func (SignedEntity) PrettyPrint

func (s SignedEntity) PrettyPrint(ctx context.Context, prefix string, w io.Writer)

PrettyPrint writes a pretty-printed representation of the type to the given writer.

func (SignedEntity) PrettyType

func (s SignedEntity) PrettyType() (interface{}, error)

PrettyType returns a representation of the type that can be used for pretty printing.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL