Skip to content

Commit

Permalink
chronogen: More general singleton handling for names (#23)
Browse files Browse the repository at this point in the history
Singleton names should be used as-is -- both when we want a singular
name and a plural name. This has no impact on the existing chronogen
code but simplifies logic for future singletons.
  • Loading branch information
prashantv committed May 10, 2024
1 parent 397a48c commit e1542ce
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions tools/cmd/chronogen/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,11 @@ type entitySpec struct {

// Name returns the singularized name.
func (e entitySpec) Name() string {
if e.Entity.IsNotSingleton() {
return inflect.Singularize(upperCamel(e.Entity.Name))
} else {
return e.NameP()
if e.Entity.IsSingleton {
// Singletons shouldn't have singular/plural applied.
return upperCamel(e.Entity.Name)
}
return inflect.Singularize(upperCamel(e.Entity.Name))
}

func (e entitySpec) ModelName() string {
Expand All @@ -109,8 +109,8 @@ func (e entitySpec) ModelName() string {

// NameP returns the pluralized name.
func (e entitySpec) NameP() string {
// Unlike other singletons, the base name of OtelMetricsIngestion is not plural.
if e.Entity.Name == "otel-metrics-ingestion" {
if e.Entity.IsSingleton {
// Singletons shouldn't have singular/plural applied.
return upperCamel(e.Entity.Name)
}
return inflect.Pluralize(upperCamel(e.Entity.Name))
Expand Down

0 comments on commit e1542ce

Please sign in to comment.