Skip to content

Commit

Permalink
Merge pull request #88 from cloudgraphdev/beta
Browse files Browse the repository at this point in the history
Release 0.68
  • Loading branch information
tyler-dunkel authored Oct 17, 2023
2 parents 8d37910 + 1572747 commit d7265c5
Show file tree
Hide file tree
Showing 17 changed files with 596 additions and 1 deletion.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# [0.68.0-beta.1](https://github.com/cloudgraphdev/cloudgraph-provider-azure/compare/0.67.0...0.68.0-beta.1) (2023-10-02)


### Features

* **azure:** Add ContainerApp services ([6a0c656](https://github.com/cloudgraphdev/cloudgraph-provider-azure/commit/6a0c656e3b99361ada25cbc40f58cba90cd0bef5))

# [0.68.0-alpha.1](https://github.com/cloudgraphdev/cloudgraph-provider-azure/compare/0.67.0...0.68.0-alpha.1) (2023-10-02)


### Features

* **azure:** Add ContainerApp services ([6a0c656](https://github.com/cloudgraphdev/cloudgraph-provider-azure/commit/6a0c656e3b99361ada25cbc40f58cba90cd0bef5))

# [0.67.0](https://github.com/cloudgraphdev/cloudgraph-provider-azure/compare/0.66.0...0.67.0) (2023-07-19)


Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cloudgraph/cg-provider-azure",
"version": "0.67.0",
"version": "0.68.0-beta.1",
"description": "CloudGraph provider plugin for Azure used to fetch Azure cloud data.",
"publishConfig": {
"registry": "https://registry.npmjs.org/",
Expand Down Expand Up @@ -31,6 +31,7 @@
"terraform:cleanup": "rimraf ./tests/terraform/{.terraform,.terraform.lock.hcl,tfplan} ./tests/terraform/*.{tfstate,tfplan,backup}"
},
"dependencies": {
"@azure/arm-appcontainers": "^2.0.0",
"@azure/arm-appinsights": "^4.0.0",
"@azure/arm-appservice": "^11.0.0",
"@azure/arm-authorization": "^8.4.1",
Expand Down
4 changes: 4 additions & 0 deletions src/enums/serviceMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import AzureCdnOrigins from '../services/cdnOrigins'
import AzureCdnProfiles from '../services/cdnProfiles'
import AzureCognitiveServicesAccount from '../services/cognitiveServicesAccount'
import AzureContainerRegistry from '../services/containerRegistry'
import AzureContainerApp from '../services/containerApp'
import AzureContainerAppEnvironment from '../services/containerAppEnvironment'
import AzureDataCollectionRule from '../services/dataCollectionRule'
import AzureDataFactory from '../services/dataFactory'
import AzureDatabaseManagedSqlInstance from '../services/databaseManagedSqlInstance'
Expand Down Expand Up @@ -131,6 +133,8 @@ export default {
[services.cdnProfiles]: AzureCdnProfiles,
[services.cognitiveServicesAccount]: AzureCognitiveServicesAccount,
[services.containerRegistry]: AzureContainerRegistry,
[services.containerApp]: AzureContainerApp,
[services.containerAppEnvironment]: AzureContainerAppEnvironment,
[services.cosmosDb]: AzureCosmosDb,
[services.dataCollectionRule]: AzureDataCollectionRule,
[services.dataFactory]: AzureDataFactory,
Expand Down
2 changes: 2 additions & 0 deletions src/enums/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ export default {
cdnProfiles: 'cdnProfiles',
cognitiveServicesAccount: 'cognitiveServicesAccount',
containerRegistry: 'containerRegistry',
containerApp: 'containerApp',
containerAppEnvironment: 'containerAppEnvironment',
cosmosDb: 'cosmosDb',
dataCollectionRule: 'dataCollectionRule',
dataFactory: 'dataFactory',
Expand Down
3 changes: 3 additions & 0 deletions src/properties/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ export default {
`Found ${num} CDN origin groups`,
foundContainerRegistries: (num: number): string =>
`Found ${num} container registries`,
foundContainerApps: (num: number): string => `Found ${num} container apps`,
foundContainerAppEnvironment: (num: number): string =>
`Found ${num} container environments`,
/* Cosmos DB */
foundCosmosDbAccounts: (num: number): string =>
`Found ${num} cosmos DB accounts`,
Expand Down
76 changes: 76 additions & 0 deletions src/services/containerApp/data.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import { ContainerApp, ContainerAppsAPIClient } from '@azure/arm-appcontainers'

import CloudGraph from '@cloudgraph/sdk'

import azureLoggerText from '../../properties/logger'
import { AzureServiceInput, TagMap } from '../../types'
import { tryCatchWrapper } from '../../utils/index'
import { regionMap } from '../../enums/regions'

const { logger } = CloudGraph
const lt = { ...azureLoggerText }
const serviceName = 'ContainerApp'

export interface RawAzureContainerApp
extends Omit<ContainerApp, 'location' | 'tags'> {
resourceGroupId?: string
region: string
customDomainVerificationId?: string
environmentId?: string
latestReadyRevisionName?: string
latestRevisionFqdn?: string
latestRevisionName?: string
location?: string
managedEnvironmentId?: string
provisioningState?: string
workloadProfileName?: string
Tags: TagMap
}

export default async ({
config,
}: AzureServiceInput): Promise<{
[property: string]: RawAzureContainerApp[]
}> => {
try {
const { tokenCredentials, subscriptionId } = config
const client = new ContainerAppsAPIClient(tokenCredentials, subscriptionId)

const containerApps: RawAzureContainerApp[] = []
const result = { global: [] }
await tryCatchWrapper(
async () => {
for await (const containerApp of client.containerApps.listBySubscription()) {
if (containerApp) {
const { tags, ...rest } = containerApp

containerApps.push({
...rest,
id: rest.id.replace('/containerapps/', '/containerApps/'), // fix casing in Id
region: containerApp.location || regionMap.global,
Tags: tags || {},
})
}
}
},
{
service: serviceName,
client,
scope: 'containerApps',
operation: 'listBySubscription',
}
)
logger.debug(lt.foundContainerApps(containerApps.length))

containerApps.map(({ region, ...rest }) => {
result.global.push({
...rest,
region,
})
})
return result
} catch (e) {
logger.error(e)
return {}
}
}
47 changes: 47 additions & 0 deletions src/services/containerApp/format.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { RawAzureContainerApp } from './data'
import { formatTagsFromMap } from '../../utils/format'
import { AzureContainerApp } from '../../types/generated'

export default ({
service,
account: subscriptionId,
}: {
service: RawAzureContainerApp
account: string
}): AzureContainerApp => {
const {
id,
name,
type,
region,
resourceGroupId,
customDomainVerificationId,
environmentId,
latestReadyRevisionName,
latestRevisionFqdn,
latestRevisionName,
location,
managedEnvironmentId,
provisioningState,
workloadProfileName,
Tags = {},
} = service
return {
id,
name,
type,
region,
resourceGroupId,
customDomainVerificationId,
environmentId,
latestReadyRevisionName,
latestRevisionFqdn,
latestRevisionName,
location,
managedEnvironmentId,
provisioningState,
workloadProfileName,
subscriptionId,
tags: formatTagsFromMap(Tags),
}
}
13 changes: 13 additions & 0 deletions src/services/containerApp/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Service } from '@cloudgraph/sdk'
import BaseService from '../base'
import format from './format'
import mutation from './mutation'
import getData from './data'

export default class AzureContainerApp extends BaseService implements Service {
format = format.bind(this)

getData = getData.bind(this)

mutation = mutation
}
5 changes: 5 additions & 0 deletions src/services/containerApp/mutation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export default `mutation($input: [AddazureContainerAppInput!]!) {
addazureContainerApp(input: $input, upsert: true) {
numUids
}
}`
16 changes: 16 additions & 0 deletions src/services/containerApp/schema.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
type azureContainerApp implements azureResource
@generate(
query: { get: true, query: true, aggregate: true }
mutation: { add: true, delete: false }
)
@key(fields: "id") {
location: String @search(by: [hash, regexp])
provisioningState: String @search(by: [hash, regexp])
managedEnvironmentId: String @search(by: [hash, regexp])
environmentId: String @search(by: [hash, regexp])
workloadProfileName: String @search(by: [hash, regexp])
latestRevisionName: String @search(by: [hash, regexp])
latestReadyRevisionName: String @search(by: [hash, regexp])
latestRevisionFqdn: String @search(by: [hash, regexp])
customDomainVerificationId: String @search(by: [hash, regexp])
}
Loading

0 comments on commit d7265c5

Please sign in to comment.