eid

package
v1.36.0 Latest Latest
Warning

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

Go to latest
Published: May 24, 2024 License: MIT Imports: 6 Imported by: 11

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultParser = Parser{}

Functions

func SortFunc

func SortFunc(a, b EID) int

Types

type EID

type EID struct {
	// Type of the entity.
	// e.g. in GCP::Project::dev
	// it is 'GCP::Project'
	Type string `json:"type"`

	// ID of the entity.
	// e.g. in GCP::Project::dev
	// it is 'dev'
	ID string `json:"id"`
}

EID is a unique identifier for an entity which includes both it's type and ID.

e.g. 'GCP::Project::dev'

func FromAPI

func FromAPI(eid *entityv1alpha1.EID) EID

func New

func New(entityType string, id string) EID

New creates a EID from a provided entity type and ID.

func Parse

func Parse(input string) (EID, error)

Parse extracts a EID from the input string using the DefaultParser. Unlike Cedar policies, we accept EIDs without mandatory double quotes around the ID component.

For example: AWS::Account::123456789012 is a valid Common Fate EID, but is an invalid Cedar EID.

We are more relaxed about parsing because nearly all of our EIDs do not contain any whitespace, so it saves users having to type additional quote characters when using our CLI.

If the ID component of the EID contains any whitespace it must be enclosed in double quotes.

func Ptr

func Ptr(entityType string, id string) *EID

Ptr creates a EID from a provided entity type and ID and returns it as a pointer.

func (EID) Equals

func (u EID) Equals(other EID) bool

func (EID) JSON added in v1.24.0

func (e EID) JSON() EIDJSON

func (EID) String

func (u EID) String() string

func (EID) ToAPI

func (u EID) ToAPI() *entityv1alpha1.EID

func (EID) ToSpecifier

func (u EID) ToSpecifier() *accessv1alpha1.Specifier

ToSpecifier returns a Specifier which will match the EID.

func (EID) Valid

func (u EID) Valid() error

Valid returns true if the EID has both a type and an ID.

type EIDJSON added in v1.24.0

type EIDJSON struct {
	Entity struct {
		Type string `json:"type"`
		ID   string `json:"id"`
	} `json:"__entity"`
}

func (EIDJSON) EID added in v1.24.0

func (e EIDJSON) EID() EID

type Parser added in v1.21.0

type Parser struct {
	// Whether or not the parser should enforce that the ID component of the EID is wrapped with quotes
	RequireQuotedID bool
}

func (Parser) Parse added in v1.21.0

func (p Parser) Parse(input string) (EID, error)

Jump to

Keyboard shortcuts

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