-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #88 from cloudgraphdev/beta
Release 0.68
- Loading branch information
Showing
17 changed files
with
596 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 {} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
}` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]) | ||
} |
Oops, something went wrong.