// OncallRotationPath returns the path to the oncall rotation file. func OncallRotationPath(ctx *tool.Context) (string, error) { dataDir, err := project.DataDirPath(ctx, tool.Name) if err != nil { return "", err } return filepath.Join(dataDir, "oncall.v1.xml"), nil }
func loadAliases(ctx *tool.Context) (*aliasMaps, error) { aliasesFile := aliasesFlag if aliasesFile == "" { dataDir, err := project.DataDirPath(ctx, tool.Name) if err != nil { return nil, err } aliasesFile = filepath.Join(dataDir, aliasesFileName) } bytes, err := ctx.Run().ReadFile(aliasesFile) if err != nil { return nil, err } var data aliasesSchema if err := xml.Unmarshal(bytes, &data); err != nil { return nil, fmt.Errorf("Unmarshal(%v) failed: %v", string(bytes), err) } aliases := &aliasMaps{ emails: map[string]string{}, names: map[string]string{}, } for _, email := range data.Emails { for _, alias := range email.Aliases { aliases.emails[alias] = email.Canonical } } for _, name := range data.Names { for _, alias := range name.Aliases { aliases.names[alias] = name.Canonical } } return aliases, nil }
// ConfigFilePath returns the path to the tools configuration file. func ConfigFilePath(ctx *tool.Context) (string, error) { dataDir, err := project.DataDirPath(ctx, tool.Name) if err != nil { return "", err } return filepath.Join(dataDir, "config.v1.xml"), nil }