Skip to content

Commit

Permalink
🧹 Replace llx.StringData and llx.BoolData with llx.StringDataPtr and …
Browse files Browse the repository at this point in the history
…llx.BoolDataPtr in azure. (#3351)

* 🧹 Replace llx.StringData and llx.BoolData with llx.StringDataPtr and llx.BoolDataPtr in azure.
* replace timedata too.
* More llx.StringData replacements. Remove redundant StringDataPtr usages where string is not a pointer.

---------

Signed-off-by: Preslav <[email protected]>
  • Loading branch information
preslavgerchev authored Feb 19, 2024
1 parent 5d821e8 commit 0589a74
Show file tree
Hide file tree
Showing 17 changed files with 413 additions and 413 deletions.
20 changes: 10 additions & 10 deletions providers/azure/resources/aks.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,18 +103,18 @@ func (a *mqlAzureSubscriptionAksService) clusters() ([]interface{}, error) {

mqlAksCluster, err := CreateResource(a.MqlRuntime, "azure.subscription.aksService.cluster",
map[string]*llx.RawData{
"id": llx.StringData(convert.ToString(entry.ID)),
"name": llx.StringData(convert.ToString(entry.Name)),
"location": llx.StringData(convert.ToString(entry.Location)),
"kubernetesVersion": llx.StringData(convert.ToString(entry.Properties.KubernetesVersion)),
"provisioningState": llx.StringData(convert.ToString(entry.Properties.ProvisioningState)),
"id": llx.StringDataPtr(entry.ID),
"name": llx.StringDataPtr(entry.Name),
"location": llx.StringDataPtr(entry.Location),
"kubernetesVersion": llx.StringDataPtr(entry.Properties.KubernetesVersion),
"provisioningState": llx.StringDataPtr(entry.Properties.ProvisioningState),
"createdAt": llx.TimeDataPtr(createdAt),
"nodeResourceGroup": llx.StringData(convert.ToString(entry.Properties.NodeResourceGroup)),
"powerState": llx.StringData(convert.ToString((*string)(entry.Properties.PowerState.Code))),
"nodeResourceGroup": llx.StringDataPtr(entry.Properties.NodeResourceGroup),
"powerState": llx.StringDataPtr((*string)(entry.Properties.PowerState.Code)),
"tags": llx.MapData(convert.PtrMapStrToInterface(entry.Tags), types.String),
"rbacEnabled": llx.BoolData(convert.ToBool(entry.Properties.EnableRBAC)),
"dnsPrefix": llx.StringData(convert.ToString(entry.Properties.DNSPrefix)),
"fqdn": llx.StringData(convert.ToString(entry.Properties.Fqdn)),
"rbacEnabled": llx.BoolDataPtr(entry.Properties.EnableRBAC),
"dnsPrefix": llx.StringDataPtr(entry.Properties.DNSPrefix),
"fqdn": llx.StringDataPtr(entry.Properties.Fqdn),
"agentPoolProfiles": llx.DictData(agentPoolProfiles),
"addonProfiles": llx.DictData(addonProfiles),
"httpProxyConfig": llx.DictData(httpProxyConfig),
Expand Down
6 changes: 3 additions & 3 deletions providers/azure/resources/authorization.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ func (a *mqlAzureSubscriptionAuthorizationService) roleDefinitions() ([]interfac
}
mqlRoleDefinition, err := CreateResource(a.MqlRuntime, "azure.subscription.authorizationService.roleDefinition",
map[string]*llx.RawData{
"id": llx.StringData(convert.ToString(roleDef.ID)),
"name": llx.StringData(convert.ToString(roleDef.Properties.RoleName)),
"description": llx.StringData(convert.ToString(roleDef.Properties.Description)),
"id": llx.StringDataPtr(roleDef.ID),
"name": llx.StringDataPtr(roleDef.Properties.RoleName),
"description": llx.StringDataPtr(roleDef.Properties.Description),
"isCustom": llx.BoolData(isCustom),
"scopes": llx.ArrayData(scopes, types.String),
"permissions": llx.ArrayData(permissions, types.ResourceLike),
Expand Down
4 changes: 2 additions & 2 deletions providers/azure/resources/cloud_defender.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,8 @@ func (a *mqlAzureSubscriptionCloudDefenderService) securityContacts() ([]interfa
mailsArr := strings.Split(mails, ";")
mqlSecurityContact, err := CreateResource(a.MqlRuntime, "azure.subscription.cloudDefenderService.securityContact",
map[string]*llx.RawData{
"id": llx.StringData(convert.ToString(contact.ID)),
"name": llx.StringData(convert.ToString(contact.Name)),
"id": llx.StringDataPtr(contact.ID),
"name": llx.StringDataPtr(contact.Name),
"emails": llx.ArrayData(convert.SliceAnyToInterface(mailsArr), types.String),
"notificationsByRole": llx.DictData(notificationsByRole),
"alertNotifications": llx.DictData(alertNotifications),
Expand Down
28 changes: 14 additions & 14 deletions providers/azure/resources/compute.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,12 @@ func (a *mqlAzureSubscriptionComputeService) vms() ([]interface{}, error) {

mqlAzureVm, err := CreateResource(a.MqlRuntime, "azure.subscription.computeService.vm",
map[string]*llx.RawData{
"id": llx.StringData(convert.ToString(vm.ID)),
"name": llx.StringData(convert.ToString(vm.Name)),
"location": llx.StringData(convert.ToString(vm.Location)),
"id": llx.StringDataPtr(vm.ID),
"name": llx.StringDataPtr(vm.Name),
"location": llx.StringDataPtr(vm.Location),
"zones": llx.ArrayData(convert.SliceStrPtrToInterface(vm.Zones), types.String),
"tags": llx.MapData(convert.PtrMapStrToInterface(vm.Tags), types.String),
"type": llx.StringData(convert.ToString(vm.Type)),
"type": llx.StringDataPtr(vm.Type),
"properties": llx.DictData(properties),
})
if err != nil {
Expand Down Expand Up @@ -254,12 +254,12 @@ func diskToMql(runtime *plugin.Runtime, disk compute.Disk) (*mqlAzureSubscriptio

res, err := CreateResource(runtime, "azure.subscription.computeService.disk",
map[string]*llx.RawData{
"id": llx.StringData(convert.ToString(disk.ID)),
"name": llx.StringData(convert.ToString(disk.Name)),
"location": llx.StringData(convert.ToString(disk.Location)),
"id": llx.StringDataPtr(disk.ID),
"name": llx.StringDataPtr(disk.Name),
"location": llx.StringDataPtr(disk.Location),
"tags": llx.MapData(convert.PtrMapStrToInterface(disk.Tags), types.String),
"type": llx.StringData(convert.ToString(disk.Type)),
"managedBy": llx.StringData(convert.ToString(disk.ManagedBy)),
"type": llx.StringDataPtr(disk.Type),
"managedBy": llx.StringDataPtr(disk.ManagedBy),
"managedByExtended": llx.ArrayData(managedByExtended, types.String),
"zones": llx.ArrayData(zones, types.String),
"sku": llx.DictData(sku),
Expand Down Expand Up @@ -462,12 +462,12 @@ func (a *mqlAzureSubscriptionComputeServiceVm) publicIpAddresses() ([]interface{
}
mqlIpAddress, err := CreateResource(a.MqlRuntime, "azure.subscription.networkService.ipAddress",
map[string]*llx.RawData{
"id": llx.StringData(convert.ToString(ipAddress.ID)),
"name": llx.StringData(convert.ToString(ipAddress.Name)),
"location": llx.StringData(convert.ToString(ipAddress.Location)),
"id": llx.StringDataPtr(ipAddress.ID),
"name": llx.StringDataPtr(ipAddress.Name),
"location": llx.StringDataPtr(ipAddress.Location),
"tags": llx.MapData(convert.PtrMapStrToInterface(ipAddress.Tags), types.String),
"ipAddress": llx.StringData(convert.ToString(ipAddress.Properties.IPAddress)),
"type": llx.StringData(convert.ToString(ipAddress.Type)),
"ipAddress": llx.StringDataPtr(ipAddress.Properties.IPAddress),
"type": llx.StringDataPtr(ipAddress.Type),
})
if err != nil {
return nil, err
Expand Down
10 changes: 5 additions & 5 deletions providers/azure/resources/cosmosdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@ func (a *mqlAzureSubscriptionCosmosDbService) accounts() ([]interface{}, error)

mqlCosmosDbAccount, err := CreateResource(a.MqlRuntime, "azure.subscription.cosmosDbService.account",
map[string]*llx.RawData{
"id": llx.StringData(convert.ToString(account.ID)),
"name": llx.StringData(convert.ToString(account.Name)),
"id": llx.StringDataPtr(account.ID),
"name": llx.StringDataPtr(account.Name),
"tags": llx.MapData(convert.PtrMapStrToInterface(account.Tags), types.String),
"location": llx.StringData(convert.ToString(account.Location)),
"kind": llx.StringData(convert.ToString((*string)(account.Kind))),
"type": llx.StringData(convert.ToString(account.Type)),
"location": llx.StringDataPtr(account.Location),
"kind": llx.StringDataPtr((*string)(account.Kind)),
"type": llx.StringDataPtr(account.Type),
"properties": llx.DictData(properties),
})
if err != nil {
Expand Down
52 changes: 26 additions & 26 deletions providers/azure/resources/keyvault.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,10 @@ func (a *mqlAzureSubscriptionKeyVaultService) vaults() ([]interface{}, error) {
for _, entry := range page.Value {
mqlAzure, err := CreateResource(a.MqlRuntime, "azure.subscription.keyVaultService.vault",
map[string]*llx.RawData{
"id": llx.StringData(convert.ToString(entry.ID)),
"vaultName": llx.StringData(convert.ToString(entry.Name)),
"location": llx.StringData(convert.ToString(entry.Location)),
"type": llx.StringData(convert.ToString(entry.Type)),
"id": llx.StringDataPtr(entry.ID),
"vaultName": llx.StringDataPtr(entry.Name),
"location": llx.StringDataPtr(entry.Location),
"type": llx.StringDataPtr(entry.Type),
"tags": llx.MapData(convert.PtrMapStrToInterface(entry.Tags), types.String),
})
if err != nil {
Expand Down Expand Up @@ -188,15 +188,15 @@ func (a *mqlAzureSubscriptionKeyVaultServiceVault) keys() ([]interface{}, error)
for _, entry := range page.Value {
mqlAzure, err := CreateResource(a.MqlRuntime, "azure.subscription.keyVaultService.key",
map[string]*llx.RawData{
"kid": llx.StringData(convert.ToString((*string)(entry.KID))),
"managed": llx.BoolData(convert.ToBool(entry.Managed)),
"kid": llx.StringDataPtr((*string)(entry.KID)),
"managed": llx.BoolDataPtr(entry.Managed),
"tags": llx.MapData(convert.PtrMapStrToInterface(entry.Tags), types.String),
"enabled": llx.BoolData(convert.ToBool(entry.Attributes.Enabled)),
"enabled": llx.BoolDataPtr(entry.Attributes.Enabled),
"created": llx.TimeDataPtr(entry.Attributes.Created),
"updated": llx.TimeDataPtr(entry.Attributes.Updated),
"expires": llx.TimeDataPtr(entry.Attributes.Expires),
"notBefore": llx.TimeDataPtr(entry.Attributes.NotBefore),
"recoveryLevel": llx.StringData(convert.ToString((*string)(entry.Attributes.RecoveryLevel))),
"recoveryLevel": llx.StringDataPtr((*string)(entry.Attributes.RecoveryLevel)),
})
if err != nil {
return nil, err
Expand Down Expand Up @@ -230,11 +230,11 @@ func (a *mqlAzureSubscriptionKeyVaultServiceVault) secrets() ([]interface{}, err
for _, entry := range page.Value {
mqlAzure, err := CreateResource(a.MqlRuntime, "azure.subscription.keyVaultService.secret",
map[string]*llx.RawData{
"id": llx.StringData(convert.ToString((*string)(entry.ID))),
"id": llx.StringDataPtr((*string)(entry.ID)),
"tags": llx.MapData(convert.PtrMapStrToInterface(entry.Tags), types.String),
"contentType": llx.StringData(convert.ToString(entry.ContentType)),
"managed": llx.BoolData(convert.ToBool(entry.Managed)),
"enabled": llx.BoolData(convert.ToBool(entry.Attributes.Enabled)),
"contentType": llx.StringDataPtr(entry.ContentType),
"managed": llx.BoolDataPtr(entry.Managed),
"enabled": llx.BoolDataPtr(entry.Attributes.Enabled),
"created": llx.TimeDataPtr(entry.Attributes.Created),
"updated": llx.TimeDataPtr(entry.Attributes.Updated),
"expires": llx.TimeDataPtr(entry.Attributes.Expires),
Expand Down Expand Up @@ -272,14 +272,14 @@ func (a *mqlAzureSubscriptionKeyVaultServiceVault) certificates() ([]interface{}
for _, entry := range page.Value {
mqlAzure, err := CreateResource(a.MqlRuntime, "azure.subscription.keyVaultService.certificate",
map[string]*llx.RawData{
"id": llx.StringData(convert.ToString((*string)(entry.ID))),
"id": llx.StringDataPtr((*string)(entry.ID)),
"tags": llx.MapData(convert.PtrMapStrToInterface(entry.Tags), types.String),
"enabled": llx.BoolData(convert.ToBool(entry.Attributes.Enabled)),
"enabled": llx.BoolDataPtr(entry.Attributes.Enabled),
"created": llx.TimeDataPtr(entry.Attributes.Created),
"updated": llx.TimeDataPtr(entry.Attributes.Updated),
"expires": llx.TimeDataPtr(entry.Attributes.Expires),
"notBefore": llx.TimeDataPtr(entry.Attributes.NotBefore),
"recoveryLevel": llx.StringData(convert.ToString((*string)(entry.Attributes.RecoveryLevel))),
"recoveryLevel": llx.StringDataPtr((*string)(entry.Attributes.RecoveryLevel)),
"x5t": llx.StringData(hex.EncodeToString(entry.X509Thumbprint)),
})
if err != nil {
Expand Down Expand Up @@ -350,15 +350,15 @@ func (a *mqlAzureSubscriptionKeyVaultServiceKey) versions() ([]interface{}, erro
for _, entry := range page.Value {
mqlAzure, err := CreateResource(a.MqlRuntime, "azure.subscription.keyVaultService.key",
map[string]*llx.RawData{
"kid": llx.StringData(convert.ToString((*string)(entry.KID))),
"managed": llx.BoolData(convert.ToBool(entry.Managed)),
"kid": llx.StringDataPtr((*string)(entry.KID)),
"managed": llx.BoolDataPtr(entry.Managed),
"tags": llx.MapData(convert.PtrMapStrToInterface(entry.Tags), types.String),
"enabled": llx.BoolData(convert.ToBool(entry.Attributes.Enabled)),
"enabled": llx.BoolDataPtr(entry.Attributes.Enabled),
"created": llx.TimeDataPtr(entry.Attributes.Created),
"updated": llx.TimeDataPtr(entry.Attributes.Updated),
"expires": llx.TimeDataPtr(entry.Attributes.Expires),
"notBefore": llx.TimeDataPtr(entry.Attributes.NotBefore),
"recoveryLevel": llx.StringData(convert.ToString((*string)(entry.Attributes.RecoveryLevel))),
"recoveryLevel": llx.StringDataPtr((*string)(entry.Attributes.RecoveryLevel)),
})
if err != nil {
return nil, err
Expand Down Expand Up @@ -424,14 +424,14 @@ func (a *mqlAzureSubscriptionKeyVaultServiceCertificate) versions() ([]interface
for _, entry := range page.Value {
mqlAzure, err := CreateResource(a.MqlRuntime, "azure.subscription.keyVaultService.certificate",
map[string]*llx.RawData{
"id": llx.StringData(convert.ToString((*string)(entry.ID))),
"id": llx.StringDataPtr((*string)(entry.ID)),
"tags": llx.MapData(convert.PtrMapStrToInterface(entry.Tags), types.String),
"enabled": llx.BoolData(convert.ToBool(entry.Attributes.Enabled)),
"enabled": llx.BoolDataPtr(entry.Attributes.Enabled),
"created": llx.TimeDataPtr(entry.Attributes.Created),
"updated": llx.TimeDataPtr(entry.Attributes.Updated),
"expires": llx.TimeDataPtr(entry.Attributes.Expires),
"notBefore": llx.TimeDataPtr(entry.Attributes.NotBefore),
"recoveryLevel": llx.StringData(convert.ToString((*string)(entry.Attributes.RecoveryLevel))),
"recoveryLevel": llx.StringDataPtr((*string)(entry.Attributes.RecoveryLevel)),
"x5t": llx.StringData(hex.EncodeToString(entry.X509Thumbprint)),
})
if err != nil {
Expand Down Expand Up @@ -500,11 +500,11 @@ func (a *mqlAzureSubscriptionKeyVaultServiceSecret) versions() ([]interface{}, e
for _, entry := range page.Value {
mqlAzure, err := CreateResource(a.MqlRuntime, "azure.subscription.keyVaultService.secret",
map[string]*llx.RawData{
"id": llx.StringData(convert.ToString((*string)(entry.ID))),
"id": llx.StringDataPtr((*string)(entry.ID)),
"tags": llx.MapData(convert.PtrMapStrToInterface(entry.Tags), types.String),
"contentType": llx.StringData(convert.ToString(entry.ContentType)),
"managed": llx.BoolData(convert.ToBool(entry.Managed)),
"enabled": llx.BoolData(convert.ToBool(entry.Attributes.Enabled)),
"contentType": llx.StringDataPtr(entry.ContentType),
"managed": llx.BoolDataPtr(entry.Managed),
"enabled": llx.BoolDataPtr(entry.Attributes.Enabled),
"created": llx.TimeDataPtr(entry.Attributes.Created),
"updated": llx.TimeDataPtr(entry.Attributes.Updated),
"expires": llx.TimeDataPtr(entry.Attributes.Expires),
Expand Down
Loading

0 comments on commit 0589a74

Please sign in to comment.