Skip to content

Commit c9ab37c

Browse files
committed
CLOUDP-314920 Telemetry for Custom Roles
1 parent 549d2f6 commit c9ab37c

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

pkg/telemetry/collector.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ func getMdbEvents(ctx context.Context, operatorClusterClient kubeclient.Client,
234234
Type: string(item.Spec.GetResourceType()),
235235
IsRunningEnterpriseImage: images.IsEnterpriseImage(imageURL),
236236
ExternalDomains: getExternalDomainProperty(item),
237+
CustomRoles: getCustomRoles(item.Spec.Security),
237238
}
238239

239240
if numberOfClustersUsed > 0 {
@@ -272,6 +273,7 @@ func addMultiEvents(ctx context.Context, operatorClusterClient kubeclient.Client
272273
Type: string(item.Spec.GetResourceType()),
273274
IsRunningEnterpriseImage: images.IsEnterpriseImage(imageURL),
274275
ExternalDomains: getExternalDomainPropertyForMongoDBMulti(item),
276+
CustomRoles: getCustomRoles(item.Spec.Security),
275277
}
276278

277279
if event := createEvent(properties, now, Deployments); event != nil {
@@ -534,3 +536,25 @@ func isExternalDomainSpecifiedInClusterSpecList(clusterSpecList mdbv1.ClusterSpe
534536

535537
return clusterSpecList.IsExternalDomainSpecifiedInClusterSpecList()
536538
}
539+
540+
const (
541+
CustomRoleNone = "None"
542+
CustomRoleEmbedded = "Embedded"
543+
CustomRoleReferenced = "Referenced"
544+
)
545+
546+
func getCustomRoles(security *mdbv1.Security) string {
547+
if security == nil {
548+
return CustomRoleNone
549+
}
550+
551+
if len(security.Roles) > 0 {
552+
return CustomRoleEmbedded
553+
}
554+
555+
if len(security.RoleRefs) > 0 {
556+
return CustomRoleReferenced
557+
}
558+
559+
return CustomRoleNone
560+
}

pkg/telemetry/types.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ type DeploymentUsageSnapshotProperties struct {
3232
IsMultiCluster bool `json:"isMultiCluster"`
3333
Type string `json:"type"` // RS, SC, OM, Single
3434
IsRunningEnterpriseImage bool `json:"IsRunningEnterpriseImage"`
35-
ExternalDomains string `json:"externalDomains"` // None, Uniform, ClusterSpecific, Mixed
35+
ExternalDomains string `json:"externalDomains"` // None, Uniform, ClusterSpecific, Mixed
36+
CustomRoles string `json:"customRoles,omitempty"` // Custom roles used
3637
}
3738

3839
type Event struct {

0 commit comments

Comments
 (0)