Skip to content

Commit

Permalink
🐛 Fix Azure resources to be v8 compatible (#1686)
Browse files Browse the repository at this point in the history
  • Loading branch information
preslavgerchev authored Sep 12, 2023
1 parent e196863 commit e0901bd
Show file tree
Hide file tree
Showing 19 changed files with 5,165 additions and 3,814 deletions.
8 changes: 4 additions & 4 deletions providers/azure/resources/aks.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
"go.mondoo.com/cnquery/types"
)

func (a *mqlAzureSubscriptionAks) id() (string, error) {
func (a *mqlAzureSubscriptionAksService) id() (string, error) {
return "azure.subscription.aks/" + a.SubscriptionId.Data, nil
}

Expand All @@ -31,11 +31,11 @@ func initAzureSubscriptionAks(runtime *plugin.Runtime, args map[string]*llx.RawD
return args, nil, nil
}

func (a *mqlAzureSubscriptionAksCluster) id() (string, error) {
func (a *mqlAzureSubscriptionAksServiceCluster) id() (string, error) {
return a.Id.Data, nil
}

func (a *mqlAzureSubscriptionAks) clusters() ([]interface{}, error) {
func (a *mqlAzureSubscriptionAksService) clusters() ([]interface{}, error) {
conn := a.MqlRuntime.Connection.(*connection.AzureConnection)
ctx := context.Background()
token := conn.Token()
Expand Down Expand Up @@ -99,7 +99,7 @@ func (a *mqlAzureSubscriptionAks) clusters() ([]interface{}, error) {
createdAt = entry.SystemData.CreatedAt
}

mqlAksCluster, err := CreateResource(a.MqlRuntime, "azure.subscription.aks.cluster",
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)),
Expand Down
16 changes: 8 additions & 8 deletions providers/azure/resources/authorization.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ import (
authorization "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/authorization/armauthorization/v2"
)

func (a *mqlAzureSubscriptionAuthorization) id() (string, error) {
func (a *mqlAzureSubscriptionAuthorizationService) id() (string, error) {
return "azure.subscription.authorization/" + a.SubscriptionId.Data, nil
}

func initAzureSubscriptionAuthorization(runtime *plugin.Runtime, args map[string]*llx.RawData) (map[string]*llx.RawData, plugin.Resource, error) {
func initAzureSubscriptionAuthorizationService(runtime *plugin.Runtime, args map[string]*llx.RawData) (map[string]*llx.RawData, plugin.Resource, error) {
if len(args) > 0 {
return args, nil, nil
}
Expand All @@ -32,15 +32,15 @@ func initAzureSubscriptionAuthorization(runtime *plugin.Runtime, args map[string
return args, nil, nil
}

func (a *mqlAzureSubscriptionAuthorizationRoleDefinition) id() (string, error) {
func (a *mqlAzureSubscriptionAuthorizationServiceRoleDefinition) id() (string, error) {
return a.Id.Data, nil
}

func (a *mqlAzureSubscriptionAuthorizationRoleDefinitionPermission) id() (string, error) {
func (a *mqlAzureSubscriptionAuthorizationServiceRoleDefinitionPermission) id() (string, error) {
return a.Id.Data, nil
}

func (a *mqlAzureSubscriptionAuthorization) roleDefinitions() ([]interface{}, error) {
func (a *mqlAzureSubscriptionAuthorizationService) roleDefinitions() ([]interface{}, error) {
conn := a.MqlRuntime.Connection.(*connection.AzureConnection)
ctx := context.Background()
token := conn.Token()
Expand Down Expand Up @@ -71,7 +71,7 @@ func (a *mqlAzureSubscriptionAuthorization) roleDefinitions() ([]interface{}, er
}
permissions := []interface{}{}
for idx, p := range roleDef.Properties.Permissions {
id := fmt.Sprintf("%s/azure.subscription.authorization.roleDefinition.permission/%d", *roleDef.ID, idx)
id := fmt.Sprintf("%s/azure.subscription.authorizationService.roleDefinition.permission/%d", *roleDef.ID, idx)
permission, err := azureToMqlPermission(a.MqlRuntime, id, p)
if err != nil {
return nil, err
Expand All @@ -81,7 +81,7 @@ func (a *mqlAzureSubscriptionAuthorization) roleDefinitions() ([]interface{}, er
if isCustom {
isCustom = true
}
mqlRoleDefinition, err := CreateResource(a.MqlRuntime, "azure.subscription.authorization.roleDefinition",
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)),
Expand Down Expand Up @@ -126,7 +126,7 @@ func azureToMqlPermission(runtime *plugin.Runtime, id string, permission *author
}
}

p, err := CreateResource(runtime, "azure.subscription.authorization.roleDefinition.permission",
p, err := CreateResource(runtime, "azure.subscription.authorizationService.roleDefinition.permission",
map[string]*llx.RawData{
"id": llx.StringData(id),
"allowedActions": llx.ArrayData(allowedActions, types.String),
Expand Down
Loading

0 comments on commit e0901bd

Please sign in to comment.