Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add all-current-oncall-engineers #12

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ This will result in a pair of slack groups with the combined users:
- `@all-oncall-platform-engineers` => combined list of all users in `abcd` and `efgh` schedules
- `@current-oncall-platform-engineer` => combined list of current on call users in `abcd` and `efgh` schedules

A slack group will be created with all the current on call engineers of the company:
- `@all-current-oncall-engineers`

Full parameter list:

Expand Down
12 changes: 12 additions & 0 deletions internal/sync/schedule_sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ import (
"github.com/sirupsen/logrus"
)

const (
allCurrentOncallEngineersSlackGroup = "all-current-oncall-engineers"
)

// Schedules does the sync
func Schedules(config *Config) error {
logrus.Infof("running schedule sync...")
Expand Down Expand Up @@ -57,6 +61,8 @@ func Schedules(config *Config) error {
return emails, nil
}

var allCurrentOncallEngineerEmails []string

for _, schedule := range config.Schedules {
logrus.Infof("checking slack group: %s", schedule.CurrentOnCallGroupName)

Expand All @@ -65,6 +71,7 @@ func Schedules(config *Config) error {
logrus.Errorf("failed to get emails for %s: %v", schedule.CurrentOnCallGroupName, err)
continue
}
allCurrentOncallEngineerEmails = appendIfMissing(allCurrentOncallEngineerEmails, currentOncallEngineerEmails...)

err = updateSlackGroup(currentOncallEngineerEmails, schedule.CurrentOnCallGroupName)
if err != nil {
Expand All @@ -87,6 +94,11 @@ func Schedules(config *Config) error {
}
}

err = updateSlackGroup(allCurrentOncallEngineerEmails, allCurrentOncallEngineersSlackGroup)
if err != nil {
logrus.Errorf("failed to update slack group %s: %v", allCurrentOncallEngineersSlackGroup, err)
}

return nil
}

Expand Down