storage

package
v0.0.0-...-d983439 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2024 License: Apache-2.0 Imports: 4 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotFound is returned when a requested team wasn't found
	ErrNotFound = errors.New("not found")

	// ErrConflict is returned when a team there is a clash of team IDs
	ErrConflict = errors.New("conflict")

	// ErrCannotDelete is returned when a request attempts to delete a team that
	// is not allowed to be deleted such as the "admins" team.
	ErrCannotDelete = errors.New("cannot delete")

	// If this id changes, we need a migration to change the id, see 02_add-deletable-column.up.sql.
	AdminsTeamID = "admins"

	// NonDeletableTeams contains all the teams that are not allowed to be deleted.
	// If this id changes, we need a migration to add the new team, see 02_add-deletable-column.up.sql.
	NonDeletableTeams = []string{AdminsTeamID}
)

Errors returned from the backend

Functions

func IsTeamDeletable

func IsTeamDeletable(teamID string) bool

IsTeamDeletable returns whether or not an input team is deletable by id.

Types

type Resetter

type Resetter interface {
	Reset(context.Context) error
}

Resetter is, if exposed, used for tests to reset the storage backend to a pristine state.

type Storage

type Storage interface {
	GetTeams(context.Context) ([]Team, error)
	StoreTeam(ctx context.Context, id string, name string, projects []string) (Team, error)
	RemoveUsers(ctx context.Context, id string, userIDs []string) ([]string, error)
	GetTeam(ctx context.Context, id string) (Team, error)
	PurgeUserMembership(ctx context.Context, userID string) (teamsUpdated []string, err error)
	AddUsers(ctx context.Context, id string, userIDs []string) ([]string, error)
	GetTeamsForUser(ctx context.Context, userID string) ([]Team, error)
	GetUserIDsForTeam(ctx context.Context, id string) ([]string, error)
	DeleteTeam(ctx context.Context, id string) (Team, error)
	EditTeam(ctx context.Context, id string, name string, projects []string) (Team, error)
	PurgeProject(ctx context.Context, id string) error
}

Storage is the interface provided by our various storage backends.

type Team

type Team struct {
	ID        string
	Name      string
	CreatedAt time.Time
	UpdatedAt time.Time
	Projects  []string
}

Team is the struct ingested and returned by our backend implementations.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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