Documentation
¶
Overview ¶
Package data provides functions to manage persistent data storage. For the time being, storage is file-based on the local filesystem. Future implementations may include remote key-value stores and databases.
Index ¶
- func AddReviewerToPR(url, email string) error
- func CleanupPRData(ctx workflow.Context, channelID, prURL string)
- func DeleteBitbucketBuilds(url string) error
- func DeleteBitbucketDiffstat(url string) error
- func DeleteBitbucketPR(url string) error
- func DeleteReminder(userID string) error
- func DeleteSlackBotIDs(botID string) error
- func DeleteTurns(url string) error
- func DeleteURLAndIDMapping(key string) error
- func FollowUser(followerSlackID, followedSlackID string) error
- func FreezeTurn(url, email string) (bool, error)
- func GetCurrentTurn(url string) ([]string, error)
- func GetSlackBotUserID(botID string) (string, error)
- func InitTurns(url, author string, reviewers []string) error
- func IsOptedIn(u User) bool
- func ListReminders() (map[string]string, error)
- func LoadBitbucketPR(url string) (map[string]any, error)
- func LogSlackChannelArchived(channelID, url string) error
- func LogSlackChannelCreated(channelID, name, url string) error
- func LogSlackChannelDeleted(channelID string) error
- func LogSlackChannelRenamed(channelID, name string) error
- func MapURLAndID(url, id string) error
- func Nudge(url, email string) (bool, error)
- func ReadBitbucketDiffstatLength(url string) int
- func ReadBitbucketDiffstatPaths(url string) []string
- func RemoveFromTurn(url, email string) error
- func SetReminder(userID, kitchenTime, tz string) error
- func SetSlackBotUserID(botID, userID string) error
- func StoreBitbucketPR(url string, pr any) error
- func SummarizeBitbucketBuilds(url string) string
- func SwitchTurn(url, email string) error
- func SwitchURLAndID(key string) (string, error)
- func UnfollowUser(unfollowerSlackID, followedSlackID string) error
- func UnfreezeTurn(url string) (bool, error)
- func UpdateBitbucketBuilds(url, commitHash, key string, cs CommitStatus) error
- func UpdateBitbucketDiffstat(url string, ds []bitbucket.Diffstat) error
- func UpsertUser(email, bitbucketID, githubID, slackID, realName, thrippyLink string) error
- type CommitStatus
- type PRStatus
- type PRTurn
- type RWMutexMap
- type User
- type Users
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddReviewerToPR ¶ added in v0.6.0
AddReviewerToPR adds a new reviewer to the attention state of a specific PR. This function is idempotent: if a reviewer already exists, or is the PR author, it does nothing. It also ignores empty or "bot" email addresses.
func CleanupPRData ¶ added in v1.0.0
CleanupPRData deletes all the data associated with a PR. If there are errors, they are logged but ignored, as they do not affect the overall need to clean up.
func DeleteBitbucketBuilds ¶ added in v0.8.0
func DeleteBitbucketDiffstat ¶ added in v0.8.0
func DeleteBitbucketPR ¶ added in v0.2.0
DeleteBitbucketPR deletes the snapshot of a Bitbucket pull request when it becomes obsolete (i.e. when the PR is merged, closed, or marked as a draft). This function is idempotent: it does not return an error if the snapshot does not exist.
func DeleteReminder ¶ added in v0.5.0
func DeleteSlackBotIDs ¶ added in v0.4.0
func DeleteTurns ¶ added in v0.8.0
DeleteTurns removes the attention state file of a specific PR. This is used when the PR is closed or marked as a draft.
func DeleteURLAndIDMapping ¶ added in v0.2.0
DeleteURLAndIDMapping deletes the 2-way mapping between PR URLs and chat channel and thread IDs when they become obsolete (i.e. when the PR is merged, closed, or marked as a draft).
func FollowUser ¶ added in v1.0.0
func FreezeTurn ¶ added in v1.0.0
FreezeTurn marks the attention state of a specific PR as frozen by a specific user. This prevents any changes by SwitchTurn, and only by it, until it is unfrozen. If the turn is already frozen, this function returns false and does nothing.
func GetCurrentTurn ¶ added in v0.6.0
GetCurrentTurn returns the email addresses of all the users whose turn it is to pay attention to a specific PR. If the PR has no assigned reviewers, this function returns the PR author (as a reminder for them to assign reviewers). If any assigned reviewer has their turn flag set to false, we add the author to the list as well.
func GetSlackBotUserID ¶ added in v0.4.0
func InitTurns ¶ added in v0.8.0
InitTurns initializes the attention state of a new PR. Users are specified using their email addresses.
func ListReminders ¶ added in v0.5.0
func LoadBitbucketPR ¶ added in v0.2.0
LoadBitbucketPR loads a snapshot of a Bitbucket pull request. This is used to detect changes in the pull request over time. This function returns nil if no snapshot is found.
func LogSlackChannelArchived ¶ added in v0.6.0
func LogSlackChannelCreated ¶ added in v0.6.0
func LogSlackChannelDeleted ¶ added in v0.6.0
func LogSlackChannelRenamed ¶ added in v0.6.0
func MapURLAndID ¶ added in v0.2.0
MapURLAndID saves a 2-way mapping between a PR URL and its dedicated chat channel or thread IDs.
func Nudge ¶ added in v0.7.0
Nudge records that a specific user has been nudged about a specific PR, so it becomes their turn to pay attention to that PR if it wasn't already. It returns true if the nudge is valid (the user is in the current turn list).
func ReadBitbucketDiffstatLength ¶ added in v0.8.0
func ReadBitbucketDiffstatPaths ¶ added in v0.8.0
func RemoveFromTurn ¶ added in v0.6.0
RemoveFromTurn completely removes a reviewer from the attention state of a specific PR. This is used when that reviewer approves the PR, or is unassigned from the PR. This function is idempotent: if the reviewer does not exist, it does nothing. It also ignores empty or "bot" email addresses.
func SetReminder ¶ added in v0.5.0
func SetSlackBotUserID ¶ added in v0.4.0
func StoreBitbucketPR ¶ added in v0.2.0
StoreBitbucketPR saves a snapshot of a Bitbucket pull request. This is used to detect changes in the pull request over time.
func SummarizeBitbucketBuilds ¶ added in v0.7.0
func SwitchTurn ¶ added in v0.6.0
SwitchTurn switches the turn of a specific user in a specific PR. If the user is not found, or if the turn is frozen, this function does nothing. If the user is the PR author, it adds all reviewers to the attention state. If the user is a reviewer, it adds the author to the attention state.
func SwitchURLAndID ¶ added in v0.2.0
SwitchURLAndID converts a PR URL to its mapped chat channel or thread IDs, and vice versa.
func UnfollowUser ¶ added in v1.0.0
func UnfreezeTurn ¶ added in v1.0.0
UnfreezeTurn is the inverse of FreezeTurn. If the turn is not frozen, this function returns false and does nothing.
func UpdateBitbucketBuilds ¶ added in v0.7.0
func UpdateBitbucketBuilds(url, commitHash, key string, cs CommitStatus) error
func UpdateBitbucketDiffstat ¶ added in v0.8.0
func UpsertUser ¶ added in v0.6.0
Types ¶
type CommitStatus ¶ added in v0.7.0
type PRStatus ¶ added in v0.7.0
type PRStatus struct {
CommitHash string `json:"commit_hash"`
Builds map[string]CommitStatus `json:"builds"`
}
func ReadBitbucketBuilds ¶ added in v0.7.0
type PRTurn ¶ added in v0.6.0
type PRTurn struct {
Author string `json:"author"` // Email address of the PR author.
Reviewers map[string]bool `json:"reviewers"` // Email address -> is it their turn?
FrozenAt string `json:"frozen_at,omitempty"`
FrozenBy string `json:"frozen_by,omitempty"`
}
PRTurn represents the attention state for all the author-reviewer pairs in a specific pull request.
type RWMutexMap ¶ added in v0.7.0
type RWMutexMap struct {
// contains filtered or unexported fields
}
type User ¶ added in v0.6.0
type User struct {
Created string `json:"created,omitempty"`
Updated string `json:"updated,omitempty"`
Deleted string `json:"deleted,omitempty"`
Email string `json:"email,omitempty"`
BitbucketID string `json:"bitbucket_id,omitempty"`
GitHubID string `json:"github_id,omitempty"`
SlackID string `json:"slack_id,omitempty"`
RealName string `json:"real_name,omitempty"`
ThrippyLink string `json:"thrippy_link,omitempty"`
// Slack user IDs, controlled by the un/follow slash commands, used when creating channels.
Followers []string `json:"followers,omitempty"`
}
User represents a mapping between various user IDs and email addresses across different platforms (Bitbucket, GitHub, Slack).