Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
# [0.23.0-alpha.1](https://github.com/cloudgraphdev/cli/compare/0.22.0...0.23.0-alpha.1) (2022-07-07)


### Features

* adapt CLI to pass data instead of queries ([1244617](https://github.com/cloudgraphdev/cli/commit/1244617f21abb7ae0686b16487c246b51be8dd21))
* update sdk version ([fc6ad87](https://github.com/cloudgraphdev/cli/commit/fc6ad873761d02cf9e5961e4713ac027d99d0bb0))

# [0.22.0](https://github.com/cloudgraphdev/cli/compare/0.21.4...0.22.0) (2022-05-27)


### Features

* **tencent:** add tencent in provider list ([f4ade5b](https://github.com/cloudgraphdev/cli/commit/f4ade5b3dbf6343e7595afb2ee8ecf5c7dbb412b))

# [0.22.0-beta.1](https://github.com/cloudgraphdev/cli/compare/0.21.4...0.22.0-beta.1) (2022-05-20)


Expand Down
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1450,7 +1450,7 @@ EXAMPLES
$ cg init aws -r [Specify resources to crawl]
```

_See code: [src/commands/init.ts](https://github.com/cloudgraphdev/cli/blob/v0.22.0-beta.1/src/commands/init.ts)_
_See code: [src/commands/init.ts](https://github.com/cloudgraphdev/cli/blob/v0.23.0-alpha.1/src/commands/init.ts)_

## `cg launch [PROVIDER]`

Expand Down Expand Up @@ -1482,7 +1482,7 @@ EXAMPLES
$ cg launch
```

_See code: [src/commands/launch.ts](https://github.com/cloudgraphdev/cli/blob/v0.22.0-beta.1/src/commands/launch.ts)_
_See code: [src/commands/launch.ts](https://github.com/cloudgraphdev/cli/blob/v0.23.0-alpha.1/src/commands/launch.ts)_

## `cg load [PROVIDER]`

Expand Down Expand Up @@ -1516,7 +1516,7 @@ EXAMPLES
$ cg load aws [Load data for AWS]
```

_See code: [src/commands/load.ts](https://github.com/cloudgraphdev/cli/blob/v0.22.0-beta.1/src/commands/load.ts)_
_See code: [src/commands/load.ts](https://github.com/cloudgraphdev/cli/blob/v0.23.0-alpha.1/src/commands/load.ts)_

## `cg policy [PROVIDER]`

Expand Down Expand Up @@ -1545,7 +1545,7 @@ DESCRIPTION
Commands to manage policy pack modules, run $ cg policy for more info.
```

_See code: [src/commands/policy/index.ts](https://github.com/cloudgraphdev/cli/blob/v0.22.0-beta.1/src/commands/policy/index.ts)_
_See code: [src/commands/policy/index.ts](https://github.com/cloudgraphdev/cli/blob/v0.23.0-alpha.1/src/commands/policy/index.ts)_

## `cg policy add [PROVIDER]`

Expand Down Expand Up @@ -1758,7 +1758,7 @@ DESCRIPTION
Commands to manage provider modules, run $ cg provider for more info.
```

_See code: [src/commands/provider/index.ts](https://github.com/cloudgraphdev/cli/blob/v0.22.0-beta.1/src/commands/provider/index.ts)_
_See code: [src/commands/provider/index.ts](https://github.com/cloudgraphdev/cli/blob/v0.23.0-alpha.1/src/commands/provider/index.ts)_

## `cg provider add [PROVIDER]`

Expand Down Expand Up @@ -1980,7 +1980,7 @@ EXAMPLES
$ cg scan aws --no-serve [Do not start the query engine]
```

_See code: [src/commands/scan.ts](https://github.com/cloudgraphdev/cli/blob/v0.22.0-beta.1/src/commands/scan.ts)_
_See code: [src/commands/scan.ts](https://github.com/cloudgraphdev/cli/blob/v0.23.0-alpha.1/src/commands/scan.ts)_

## `cg serve [PROVIDER]`

Expand Down Expand Up @@ -2012,7 +2012,7 @@ EXAMPLES
$ cg serve
```

_See code: [src/commands/serve.ts](https://github.com/cloudgraphdev/cli/blob/v0.22.0-beta.1/src/commands/serve.ts)_
_See code: [src/commands/serve.ts](https://github.com/cloudgraphdev/cli/blob/v0.23.0-alpha.1/src/commands/serve.ts)_

## `cg teardown [PROVIDER]`

Expand All @@ -2034,7 +2034,7 @@ EXAMPLES
$ cg teardown --delete-image
```

_See code: [src/commands/teardown.ts](https://github.com/cloudgraphdev/cli/blob/v0.22.0-beta.1/src/commands/teardown.ts)_
_See code: [src/commands/teardown.ts](https://github.com/cloudgraphdev/cli/blob/v0.23.0-alpha.1/src/commands/teardown.ts)_

## `cg update [PROVIDER]`

Expand Down Expand Up @@ -2070,5 +2070,5 @@ EXAMPLES
$ cg update
```

_See code: [src/commands/update.ts](https://github.com/cloudgraphdev/cli/blob/v0.22.0-beta.1/src/commands/update.ts)_
_See code: [src/commands/update.ts](https://github.com/cloudgraphdev/cli/blob/v0.23.0-alpha.1/src/commands/update.ts)_
<!-- commandsstop -->
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@cloudgraph/cli",
"description": "Scan your cloud infrastructure data and query it with GraphQL",
"version": "0.22.0-beta.1",
"version": "0.23.0-alpha.1",
"author": "AutoCloud",
"license": "MPL-2.0",
"publishConfig": {
Expand All @@ -15,7 +15,7 @@
},
"bugs": "https://github.com/cloudgraphdev/cli/issues",
"dependencies": {
"@cloudgraph/sdk": "^0.18.1",
"@cloudgraph/sdk": "^0.21.0",
"@graphql-tools/load-files": "^6.3.2",
"@graphql-tools/merge": "^8.2.0",
"@oclif/core": "1.6.1",
Expand Down
11 changes: 10 additions & 1 deletion src/commands/scan.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import chalk from 'chalk'
import fs from 'fs'
import path from 'path'
import { Opts, pluginMap, PluginType, StorageEngine } from '@cloudgraph/sdk'
import { Opts, pluginMap, PluginType, ProviderData, StorageEngine } from '@cloudgraph/sdk'
import { range } from 'lodash'

import Command from './base'
Expand Down Expand Up @@ -34,6 +34,7 @@ export default class Scan extends Command {
private async plugins({
storage: { isRunning, engine },
flags,
providerData,
}: {
storage: {
isRunning: boolean
Expand All @@ -42,6 +43,7 @@ export default class Scan extends Command {
flags: {
[flag: string]: any
}
providerData: ProviderData
}): Promise<void> {
const config = this.getCGConfig('cloudGraph')
const { plugins = {} } = config
Expand Down Expand Up @@ -80,6 +82,7 @@ export default class Scan extends Command {
await PluginInstance.execute({
storageRunning: isRunning,
storageEngine: engine,
providerData,
processConnectionsBetweenEntities,
})
}
Expand Down Expand Up @@ -167,6 +170,7 @@ export default class Scan extends Command {
* loop through providers and attempt to scan each of them
*/
const failedProviderList: string[] = []
const allProviderData: ProviderData = { entities: [], connections: {} }
for (const provider of allProviders) {
this.logger.info(
`Beginning ${chalk.italic.green('SCAN')} for ${provider}`
Expand Down Expand Up @@ -203,6 +207,10 @@ export default class Scan extends Command {
`${chalk.italic.green(provider)} data scanned successfully`
)

// Merge all providers data
allProviderData.entities.push(...providerData.entities)
Object.assign(allProviderData.connections, providerData.connections)

// Handle schema, write provider and combined schema to file and store in Dgraph if running
this.logger.startSpinner(
`updating ${chalk.italic.green('Schema')} for ${chalk.italic.green(
Expand Down Expand Up @@ -297,6 +305,7 @@ export default class Scan extends Command {
isRunning: storageRunning,
engine: storageEngine,
},
providerData: allProviderData
})
}

Expand Down
4 changes: 2 additions & 2 deletions src/utils/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export const processConnectionsBetweenEntities = ({
// Add service mutation to promises array
storageEngine.push({
query:
mutation ||
mutation?.toString() ||
(provider &&
generateMutation({ type: 'add', provider, entity, schemaMap })) ||
'',
Expand Down Expand Up @@ -166,7 +166,7 @@ export function insertEntitiesAndConnections({
})
if (storageRunning) {
const query =
mutation ||
mutation?.toString() ||
generateMutation({ type: 'add', provider, entity, schemaMap })
storageEngine.push({ query, input: connectedData, name })
}
Expand Down
Loading