team

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: May 9, 2019 License: AGPL-3.0 Imports: 15 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrPersonWouldNotBeChanged means the person being upserted already exists in the team and would
	// be unchanged
	ErrPersonWouldNotBeChanged = fmt.Errorf("person already exists in roster")

	// ErrEmailWouldBeUpdated means there's already a key with a matching fingerprint, but a
	// different email address. Upserting this new person would change the email address.
	ErrEmailWouldBeUpdated = fmt.Errorf(
		"existing team member's email would be updated",
	)

	// ErrKeyWouldBeUpdated means there's already a person with the same email address but a
	// different key fingerprint, so their key will be updated.
	ErrKeyWouldBeUpdated = fmt.Errorf(
		"existing team member's key would be updated",
	)

	// ErrPersonWouldBeDemotedAsAdmin means the person is currently in the team as an admin.
	// Upserting this new person would demote them from being an admin.
	ErrPersonWouldBeDemotedAsAdmin = fmt.Errorf(
		"existing team member would be demoted as team admin",
	)

	// ErrPersonWouldBePromotedToAdmin means the person is currently in the team, but is not an
	// admin. Upserting this new person would promote them to admin.
	ErrPersonWouldBePromotedToAdmin = fmt.Errorf(
		"existing team member would be promoted to team admin",
	)
)

Functions

func Directory

func Directory(t Team, fluidkeysDirectory string) (directory string, err error)

Directory returns the team subdirectory

func VerifyRoster

func VerifyRoster(roster string, signature string, adminKeys []*pgpkey.PgpKey) error

VerifyRoster cryptographically checks the signature against the roster, using the given signing keys

Types

type Person

type Person struct {
	Email       string          `toml:"email"`
	Fingerprint fpr.Fingerprint `toml:"fingerprint"`
	IsAdmin     bool            `toml:"is_admin"`
}

Person represents a human team member

type RequestToJoinTeam

type RequestToJoinTeam struct {
	UUID        uuid.UUID
	TeamUUID    uuid.UUID
	TeamName    string
	Email       string
	Fingerprint fpr.Fingerprint
	// RequestAt is the moment at which the local client made the request
	RequestedAt time.Time
}

RequestToJoinTeam represents a request to join a team

type RosterSaver

type RosterSaver struct {
	Directory string
	// contains filtered or unexported fields
}

RosterSaver provides a way to do a 2-part save where a roster is saved as a "draft" which can be either committed or discarded.

func (*RosterSaver) CommitDraft

func (rs *RosterSaver) CommitDraft() error

CommitDraft actually saves the previously saved draft roster and signature

func (*RosterSaver) DiscardDraft

func (rs *RosterSaver) DiscardDraft() error

DiscardDraft deletes the previously saved draft roster and signature

func (*RosterSaver) Save

func (rs *RosterSaver) Save(roster string, signature string) error

Save saves the roster and signature straight to disk.

func (*RosterSaver) SaveDraft

func (rs *RosterSaver) SaveDraft(roster string, signature string) error

SaveDraft saves the roster and signature to temporary files. This call should be followed by either CommitDraft() or DiscardDraft() to actually write or delete the roster & signature.

type Team

type Team struct {
	UUID   uuid.UUID `toml:"uuid"`
	Name   string    `toml:"name"`
	People []Person  `toml:"person"`
	// contains filtered or unexported fields
}

Team represents a group of people in Fluidkeys

func Load

func Load(roster string, signature string) (*Team, error)

Load loads a team from the given roster and signature

func LoadTeams

func LoadTeams(fluidkeysDirectory string) ([]Team, error)

LoadTeams scans the fluidkeys/teams directory for subdirectories, enters them and tries to load roster.toml Returns a slice of Team

func (Team) Admins

func (t Team) Admins() (admins []Person)

Admins returns the People who have IsAdmin set to true

func (*Team) Fingerprints

func (t *Team) Fingerprints() []fpr.Fingerprint

Fingerprints returns the key fingerprints for all people in the team

func (*Team) GetPersonForFingerprint

func (t *Team) GetPersonForFingerprint(fingerprint fpr.Fingerprint) (*Person, error)

GetPersonForFingerprint takes a fingerprint and returns the person in the team with the matching fingperint.

func (*Team) GetUpsertPersonWarnings

func (t *Team) GetUpsertPersonWarnings(newPerson Person) (err error, existingPerson *Person)

GetUpsertPersonWarnings checks if the given request to join a team causes any other team member to be overwritten, returning an error if so.

func (Team) IsAdmin

func (t Team) IsAdmin(fingerprint fpr.Fingerprint) bool

IsAdmin takes a given fingerprint and returns whether they are an administor of the team

func (Team) PreviewRoster

func (t Team) PreviewRoster() (roster string, err error)

PreviewRoster returns an (unsigned) roster based on the current state of the Team. Use this to preview the effect of any changes to the team, e.g. AddTeam, before actually updating and signing the roster.

func (Team) Roster

func (t Team) Roster() (roster string, signature string)

Roster returns the TOML file representing the team roster, and the ASCII armored detached signature of that file.

func (*Team) UpdateRoster

func (t *Team) UpdateRoster(signingKey *pgpkey.PgpKey) error

UpdateRoster updates and signs the roster based on the state of the team. Subsequent calls to Roster() will return the new roster and signature.

func (*Team) UpsertPerson

func (t *Team) UpsertPerson(newPerson Person)

UpsertPerson adds a Person to the team and removes anyone else that matches either the email or fingerprint.

func (*Team) Validate

func (t *Team) Validate() error

Validate asserts that the team roster has no email addresses or fingerprints that are listed more than once.

Jump to

Keyboard shortcuts

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