Skip to content

Commit

Permalink
Add missing entity type url and event
Browse files Browse the repository at this point in the history
  • Loading branch information
alanhamlett committed Sep 14, 2024
1 parent f231541 commit 661e50c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func setFlags(cmd *cobra.Command, v *viper.Viper) {
flags.String(
"entity-type",
"",
"Entity type for this heartbeat. Can be \"file\", \"domain\" or \"app\". Defaults to \"file\".",
"Entity type for this heartbeat. Can be \"file\", \"domain\", \"url\", or \"app\". Defaults to \"file\".",
)
flags.StringSlice(
"exclude",
Expand Down
14 changes: 14 additions & 0 deletions pkg/heartbeat/entity.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,19 @@ const (
FileType EntityType = iota
// DomainType represents a domain entity.
DomainType
// UrlType represents a url entity without the url params.
UrlType

Check warning on line 17 in pkg/heartbeat/entity.go

View workflow job for this annotation

GitHub Actions / Unit Tests

var-naming: const UrlType should be URLType (revive)

Check warning on line 17 in pkg/heartbeat/entity.go

View workflow job for this annotation

GitHub Actions / Unit Tests macOS

var-naming: const UrlType should be URLType (revive)

Check warning on line 17 in pkg/heartbeat/entity.go

View workflow job for this annotation

GitHub Actions / Unit Tests Windows

var-naming: const UrlType should be URLType (revive)
// EventType represents a meeting or calendar event.
EventType
// AppType represents an app entity.
AppType
)

const (
fileTypeString = "file"
domainTypeString = "domain"
urlTypeString = "url"
eventTypeString = "event"
appTypeString = "app"
)

Expand All @@ -30,6 +36,10 @@ func ParseEntityType(s string) (EntityType, error) {
return FileType, nil
case domainTypeString:
return DomainType, nil
case urlTypeString:
return UrlType, nil
case eventTypeString:
return EventType, nil
case appTypeString:
return AppType, nil
default:
Expand Down Expand Up @@ -68,6 +78,10 @@ func (t EntityType) String() string {
return fileTypeString
case DomainType:
return domainTypeString
case UrlType:
return urlTypeString
case EventType:
return eventTypeString
case AppType:
return appTypeString
default:
Expand Down
2 changes: 2 additions & 0 deletions pkg/heartbeat/entity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ func typeTests() map[string]heartbeat.EntityType {
return map[string]heartbeat.EntityType{
"file": heartbeat.FileType,
"domain": heartbeat.DomainType,
"url": heartbeat.UrlType,
"event": heartbeat.EventType,
"app": heartbeat.AppType,
}
}
Expand Down

0 comments on commit 661e50c

Please sign in to comment.