Skip to content

Commit

Permalink
Sync IntegrationEnrollKind (#47106) (#47779)
Browse files Browse the repository at this point in the history
* Sync IntegrationEnrollKind

* Map usage to prehog
  • Loading branch information
bernardjkim authored Oct 23, 2024
1 parent b530ee5 commit d1d8d31
Show file tree
Hide file tree
Showing 6 changed files with 470 additions and 395 deletions.
677 changes: 349 additions & 328 deletions api/gen/proto/go/usageevents/v1/usageevents.pb.go

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions api/proto/teleport/usageevents/v1/usageevents.proto
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,10 @@ message AccessListReviewDelete {

// IntegrationEnrollKind represents the types of integration that
// can be enrolled.
//
// Note: IntegrationEnrollKind enum must be kept in sync with the values defined
// in proto/prehog/v1alpha/teleport.proto. Values 18-25 have become out of sync
// and are manually mapped to each other.
enum IntegrationEnrollKind {
INTEGRATION_ENROLL_KIND_UNSPECIFIED = 0;
INTEGRATION_ENROLL_KIND_SLACK = 1;
Expand All @@ -573,6 +577,11 @@ enum IntegrationEnrollKind {
INTEGRATION_ENROLL_KIND_SERVICENOW = 18;
INTEGRATION_ENROLL_KIND_ENTRA_ID = 19;
INTEGRATION_ENROLL_KIND_DATADOG_INCIDENT_MANAGEMENT = 20;
INTEGRATION_ENROLL_KIND_MACHINE_ID_AWS = 21;
INTEGRATION_ENROLL_KIND_MACHINE_ID_GCP = 22;
INTEGRATION_ENROLL_KIND_MACHINE_ID_AZURE = 23;
INTEGRATION_ENROLL_KIND_MACHINE_ID_SPACELIFT = 24;
INTEGRATION_ENROLL_KIND_MACHINE_ID_KUBERNETES = 25;
}

// IntegrationEnrollMetadata contains common metadata
Expand Down
140 changes: 75 additions & 65 deletions gen/proto/go/prehog/v1alpha/teleport.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion gen/proto/ts/prehog/v1alpha/teleport_pb.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 23 additions & 1 deletion lib/usagereporter/teleport/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,31 @@ func (u *ResourceCreateEvent) Anonymize(a utils.Anonymizer) prehogv1a.SubmitEven
}

func integrationEnrollMetadataToPrehog(u *usageeventsv1.IntegrationEnrollMetadata, userMD UserMetadata) *prehogv1a.IntegrationEnrollMetadata {
// Some enums are out of sync and need to be mapped manually
var prehogKind prehogv1a.IntegrationEnrollKind
switch u.Kind {
case usageeventsv1.IntegrationEnrollKind_INTEGRATION_ENROLL_KIND_SERVICENOW:
prehogKind = prehogv1a.IntegrationEnrollKind_INTEGRATION_ENROLL_KIND_SERVICENOW
case usageeventsv1.IntegrationEnrollKind_INTEGRATION_ENROLL_KIND_ENTRA_ID:
prehogKind = prehogv1a.IntegrationEnrollKind_INTEGRATION_ENROLL_KIND_ENTRA_ID
case usageeventsv1.IntegrationEnrollKind_INTEGRATION_ENROLL_KIND_DATADOG_INCIDENT_MANAGEMENT:
prehogKind = prehogv1a.IntegrationEnrollKind_INTEGRATION_ENROLL_KIND_DATADOG_INCIDENT_MANAGEMENT
case usageeventsv1.IntegrationEnrollKind_INTEGRATION_ENROLL_KIND_MACHINE_ID_AWS:
prehogKind = prehogv1a.IntegrationEnrollKind_INTEGRATION_ENROLL_KIND_MACHINE_ID_AWS
case usageeventsv1.IntegrationEnrollKind_INTEGRATION_ENROLL_KIND_MACHINE_ID_GCP:
prehogKind = prehogv1a.IntegrationEnrollKind_INTEGRATION_ENROLL_KIND_MACHINE_ID_GCP
case usageeventsv1.IntegrationEnrollKind_INTEGRATION_ENROLL_KIND_MACHINE_ID_AZURE:
prehogKind = prehogv1a.IntegrationEnrollKind_INTEGRATION_ENROLL_KIND_MACHINE_ID_AZURE
case usageeventsv1.IntegrationEnrollKind_INTEGRATION_ENROLL_KIND_MACHINE_ID_SPACELIFT:
prehogKind = prehogv1a.IntegrationEnrollKind_INTEGRATION_ENROLL_KIND_MACHINE_ID_SPACELIFT
case usageeventsv1.IntegrationEnrollKind_INTEGRATION_ENROLL_KIND_MACHINE_ID_KUBERNETES:
prehogKind = prehogv1a.IntegrationEnrollKind_INTEGRATION_ENROLL_KIND_MACHINE_ID_KUBERNETES
default:
prehogKind = prehogv1a.IntegrationEnrollKind(u.Kind)
}
return &prehogv1a.IntegrationEnrollMetadata{
Id: u.Id,
Kind: prehogv1a.IntegrationEnrollKind(u.Kind),
Kind: prehogKind,
UserName: userMD.Username,
}
}
Expand Down
5 changes: 5 additions & 0 deletions proto/prehog/v1alpha/teleport.proto
Original file line number Diff line number Diff line change
Expand Up @@ -1008,6 +1008,10 @@ message AccessListReviewComplianceEvent {

// IntegrationEnrollKind represents the types of integration that
// can be enrolled.
//
// Note: IntegrationEnrollKind enum must be kept in sync with the values defined
// in api/proto/teleport/usageevents/v1/usageevents.proto. Values 18-25 have
// become out of sync and are manually mapped to each other.
enum IntegrationEnrollKind {
INTEGRATION_ENROLL_KIND_UNSPECIFIED = 0;
INTEGRATION_ENROLL_KIND_SLACK = 1;
Expand All @@ -1034,6 +1038,7 @@ enum IntegrationEnrollKind {
INTEGRATION_ENROLL_KIND_MACHINE_ID_KUBERNETES = 22;
INTEGRATION_ENROLL_KIND_ENTRA_ID = 23;
INTEGRATION_ENROLL_KIND_DATADOG_INCIDENT_MANAGEMENT = 24;
INTEGRATION_ENROLL_KIND_SERVICENOW = 25;
}

// IntegrationEnrollMetadata contains common metadata
Expand Down

0 comments on commit d1d8d31

Please sign in to comment.