object

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2019 License: MIT Imports: 10 Imported by: 2

Documentation

Index

Constants

View Source
const (
	PolicyType = "/policy"
)

Variables

This section is empty.

Functions

func Dump

func Dump(o *Object, skipKeys ...string) string

Dump returns the object as pretty-printed json

func Hash

func Hash(o *Object) []byte

Hash returns the ObjectHash of the object

func ObjectHash

func ObjectHash(o *Object) ([]byte, error)

ObjectHash consistently hashes a map. It is based on Ben Laurie's object hash, but using the same type hints as TJSON instead. TODO add redaction

Types

type Member

type Member struct {
	Name     string
	Value    interface{}
	TypeHint string
}

Member -

func (*Member) HintedName

func (m *Member) HintedName() string

HintedName returns the member's name and hint

type Mutator

type Mutator interface {
	Mutate(o *Object) error
}

Mutator receives an object, mutates it, or errors

type Object

type Object struct {
	Members map[string]*Member
}

Object for everything f12n

func Copy

func Copy(f *Object) *Object

Copy object

func FromMap

func FromMap(m map[string]interface{}) *Object

FromMap returns an object from a map

func New

func New() *Object

New returns an object from a map

func (*Object) Compact

func (o *Object) Compact() (string, error)

func (Object) CompactHash

func (o Object) CompactHash() string

CompactHash returns the object's hash in its (not really) compact format

func (*Object) Copy

func (o *Object) Copy() *Object

Copy creates a copy of the original object

func (*Object) FromMap

func (o *Object) FromMap(m map[string]interface{}) error

FromMap inits the object from a map

func (Object) GetParents

func (o Object) GetParents() []string

GetParents returns the object's parent refs

func (Object) GetPolicy

func (o Object) GetPolicy() *Object

GetPolicy returns the object's policy, or nil

func (Object) GetRaw

func (o Object) GetRaw(lk string) interface{}

GetRaw -

func (Object) GetSignature

func (o Object) GetSignature() *Object

GetSignature returns the object's signature, or nil

func (Object) GetType

func (o Object) GetType() string

GetType returns the object's type

func (Object) Hash

func (o Object) Hash() []byte

Hash returns the object's hash

func (Object) HashBase58

func (o Object) HashBase58() string

HashBase58 returns the object's hash base58 encoded

func (Object) SetParents

func (o Object) SetParents(v []string)

SetParents sets the object's parents

func (Object) SetPolicy

func (o Object) SetPolicy(v *Object)

SetPolicy sets the object's policy

func (*Object) SetRaw

func (o *Object) SetRaw(n string, v interface{})

SetRaw -

func (Object) SetSignature

func (o Object) SetSignature(v *Object)

SetSignature sets the object's signature

func (Object) SetType

func (o Object) SetType(v string)

SetType sets the object's type

func (Object) ToMap

func (o Object) ToMap() map[string]interface{}

ToMap returns the object as a map

func (*Object) ToObject

func (o *Object) ToObject() *Object

ToObject simply returns a copy of the object This is mostly a hack for generated objects

func (Object) ToPlainMap

func (o Object) ToPlainMap() map[string]interface{}

ToPlainMap returns the object as a map, without adding type hints on the keys

type Objectable

type Objectable interface {
	// contains filtered or unexported methods
}

Objectable is a temp interface, we should consider removing

type Policy

type Policy struct {
	Description string   `json:"description,omitempty"`
	Subjects    []string `json:"subjects,omitempty"`
	Actions     []string `json:"actions,omitempty"`
	Effect      string   `json:"effect,omitempty"`
}

Policy for object

func (*Policy) FromObject

func (s *Policy) FromObject(o *Object) error

FromObject populates the struct from a f12n object

func (Policy) GetType

func (s Policy) GetType() string

GetType returns the object's type

func (Policy) ToObject

func (s Policy) ToObject() *Object

ToObject returns a f12n object

type TypeHint

type TypeHint string

TypeHint are the hints of a member's type

const (
	HintUndefined TypeHint = ""
	HintObject    TypeHint = "o"
	HintArray     TypeHint = "a"
	HintBool      TypeHint = "b"
	HintData      TypeHint = "d"
	HintFloat     TypeHint = "f"
	HintInt       TypeHint = "i"
	HintNil       TypeHint = "n"
	HintString    TypeHint = "s"
	HintUint      TypeHint = "u"
)

func DeduceTypeHint

func DeduceTypeHint(o interface{}) TypeHint

DeduceTypeHint returns a TypeHint from a given value

func GetTypeHint

func GetTypeHint(t string) TypeHint

GetTypeHint returns a TypeHint from a string

func (TypeHint) String

func (t TypeHint) String() string

String implements the Stringer interface

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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