Skip to content

Commit

Permalink
rename config user fields
Browse files Browse the repository at this point in the history
  • Loading branch information
pPrecel committed Mar 23, 2024
1 parent cc3ff5e commit 723ccea
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
8 changes: 4 additions & 4 deletions cmd/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,16 +247,16 @@ func genCommandAction(ctx *cli.Context, opts *genActionOpts) error {
func buildConfigFromOpts(opts *genActionOpts) *config.Config {
cfg := &config.Config{
Template: opts.templatePath,
Users: []config.User{
Reports: []config.Report{
{
Usernames: []config.Username{
Signatures: []config.Signature{
{
Username: opts.username,
EnterpriseUrl: opts.enterpriseURL,
},
},
OutputDir: opts.outputDir,
ReportFields: opts.reportFields,
OutputDir: opts.outputDir,
ExtraFields: opts.reportFields,
},
},
}
Expand Down
14 changes: 7 additions & 7 deletions pkg/compose/compose.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ func (c *compose) ForConfig(config *config.Config, opts Options) error {

c.repoCommitsLister = utils.NewLazyRepoCommitsLister(c.logger, remoteClients)

for i := range config.Users {
user := config.Users[i]
for i := range config.Reports {
user := config.Reports[i]

valChan := make(chan []*view.RepoCommit)
errChan := make(chan error)
Expand All @@ -81,13 +81,13 @@ func (c *compose) ForConfig(config *config.Config, opts Options) error {
return taskView.Run()
}

func (c *compose) composeForUser(remoteClients *utils.RemoteClients, user *config.User, config *config.Config, opts *Options) ([]*view.RepoCommit, error) {
func (c *compose) composeForUser(remoteClients *utils.RemoteClients, user *config.Report, config *config.Config, opts *Options) ([]*view.RepoCommit, error) {
outputDir, err := sanitizeOutputDir(user.OutputDir)
if err != nil {
return nil, fmt.Errorf("failed to sanitize path '%s': %s", user.OutputDir, err.Error())
}

urlAuthors, err := utils.BuildUrlAuthors(remoteClients, user.Usernames)
urlAuthors, err := utils.BuildUrlAuthors(remoteClients, user.Signatures)
if err != nil {
return nil, fmt.Errorf("failed to list user signatures: %s", err.Error())
}
Expand Down Expand Up @@ -176,7 +176,7 @@ func (c *compose) composeForUser(remoteClients *utils.RemoteClients, user *confi
PeriodFrom: opts.Since,
PeriodTill: opts.Until,
Results: results,
CustomValues: user.ReportFields,
CustomValues: user.ExtraFields,
})
if err != nil {
return nil, fmt.Errorf("failed to render report: %s", err.Error())
Expand All @@ -186,9 +186,9 @@ func (c *compose) composeForUser(remoteClients *utils.RemoteClients, user *confi
return commitList, nil
}

func getUsernames(user config.User) string {
func getUsernames(user config.Report) string {
users := []string{}
for _, u := range user.Usernames {
for _, u := range user.Signatures {
users = append(users, u.Username)
}

Expand Down
12 changes: 6 additions & 6 deletions pkg/compose/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ type Config struct {
Template string `yaml:"template"`
Repos []Remote `yaml:"repos,omitempty"`
Orgs []Remote `yaml:"orgs,omitempty"`
Users []User `yaml:"users,omitempty"`
Reports []Report `yaml:"reports,omitempty"`
}

type Remote struct {
Expand All @@ -22,13 +22,13 @@ type Remote struct {
UniqueOnly bool `yaml:"uniqueOnly"`
}

type User struct {
Usernames []Username `yaml:"usernames,omitempty"`
OutputDir string `yaml:"outputDir,omitempty"`
ReportFields map[string]string `yaml:"reportFields,omitempty"`
type Report struct {
Signatures []Signature `yaml:"signatures,omitempty"`
OutputDir string `yaml:"outputDir,omitempty"`
ExtraFields map[string]string `yaml:"extraFields,omitempty"`
}

type Username struct {
type Signature struct {
Username string `yaml:"username"`
EnterpriseUrl string `yaml:"enterpriseUrl,omitempty"`
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/compose/utils/authors.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func (ua UrlAuthors) set(url string, authors []string) {
ua[url] = authors
}

func BuildUrlAuthors(remoteClients *RemoteClients, usernames []config.Username) (*UrlAuthors, error) {
func BuildUrlAuthors(remoteClients *RemoteClients, usernames []config.Signature) (*UrlAuthors, error) {
authorsMap := &UrlAuthors{}

for _, u := range usernames {
Expand Down

0 comments on commit 723ccea

Please sign in to comment.