forked from cloudquery/cloudquery
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Use autogenerated JSON schema (cloudquery#14111)
Follow-up for cloudquery#13876 Blocked by: - [x] invopop/jsonschema#103 - [x] invopop/jsonschema#105 - [x] cloudquery/codegen#29 - [x] cloudquery/plugin-sdk#1254
- Loading branch information
1 parent
b183ea6
commit ec3a607
Showing
7 changed files
with
125 additions
and
112 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
"path" | ||
"runtime" | ||
|
||
"github.com/cloudquery/cloudquery/plugins/source/gcp/client/spec" | ||
"github.com/cloudquery/codegen/jsonschema" | ||
) | ||
|
||
func main() { | ||
fmt.Println("Generating JSON schema for plugin spec") | ||
jsonschema.GenerateIntoFile(new(spec.Spec), path.Join(currDir(), "..", "schema.json")) | ||
} | ||
|
||
func currDir() string { | ||
_, filename, _, ok := runtime.Caller(0) | ||
if !ok { | ||
log.Fatal("Failed to get caller information") | ||
} | ||
return path.Dir(filename) | ||
} |
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 |
---|---|---|
@@ -1,159 +1,127 @@ | ||
{ | ||
"$schema": "https://json-schema.org/draft/2020-12/schema", | ||
"$id": "https://github.com/cloudquery/cloudquery/plugins/source/gcp/client/spec/spec", | ||
"$ref": "#/$defs/Spec", | ||
"$defs": { | ||
"Spec": { | ||
"title": "CloudQuery GCP Source Plugin Spec", | ||
"CredentialsConfig": { | ||
"properties": { | ||
"target_principal": { | ||
"type": "string", | ||
"format": "email" | ||
}, | ||
"scopes": { | ||
"items": { | ||
"type": "string", | ||
"pattern": "^https://www.googleapis.com/auth/(.)+$" | ||
}, | ||
"type": "array", | ||
"default": [ | ||
"https://www.googleapis.com/auth/cloud-platform" | ||
] | ||
}, | ||
"delegates": { | ||
"items": { | ||
"type": "string", | ||
"format": "email" | ||
}, | ||
"type": "array" | ||
}, | ||
"subject": { | ||
"type": "string", | ||
"minLength": 1 | ||
} | ||
}, | ||
"additionalProperties": false, | ||
"type": "object", | ||
"required": [ | ||
"target_principal" | ||
] | ||
}, | ||
"Spec": { | ||
"not": { | ||
"required": [ | ||
"project_filter", | ||
"folder_ids" | ||
] | ||
}, | ||
"properties": { | ||
"project_ids": { | ||
"title": "Project IDs", | ||
"description": "GCP projects to connect to. By default will use all projects available to the current authenticated account", | ||
"type": "array", | ||
"items": { | ||
"type": "string", | ||
"minLength": 1 | ||
} | ||
}, | ||
"type": "array" | ||
}, | ||
"folder_ids": { | ||
"title": "Folder IDs", | ||
"description": "Location of the projects to sync from. Mutually exclusive with project_filter", | ||
"type": "array", | ||
"items": { | ||
"type": "string", | ||
"pattern": "^(folders|organizations)/(.)+$" | ||
} | ||
}, | ||
"type": "array" | ||
}, | ||
"folder_recursion_depth": { | ||
"type": "integer", | ||
"minimum": 0, | ||
"default": 100 | ||
}, | ||
"organization_ids": { | ||
"title": "Organization IDs", | ||
"description": "List of GCP organization IDs to query. Defaults to all accessible projects", | ||
"type": "array", | ||
"items": { | ||
"type": "string", | ||
"minLength": 1 | ||
} | ||
}, | ||
"type": "array" | ||
}, | ||
"project_filter": { | ||
"title": "Project Filter", | ||
"description": "Filter to apply to projects. See https://cloud.google.com/resource-manager/docs/creating-managing-projects#listing_projects_with_a_filter for more information. Mutually exclusive with folder_ids", | ||
"type": "string" | ||
}, | ||
"organization_filter": { | ||
"title": "Organization Filter", | ||
"description": "Filter to apply to organizations. See https://cloud.google.com/resource-manager/docs/creating-managing-projects#listing_projects_with_a_filter for more information.", | ||
"type": "string" | ||
}, | ||
"folder_recursion_depth": { | ||
"title": "Folder Recursion Depth", | ||
"description": "Number of levels of folders to recurse into. 0 means no recursion, 1 means only immediate children, etc.", | ||
"type": "integer", | ||
"minimum": 0, | ||
"default": 100 | ||
}, | ||
"service_account_key_json": { | ||
"type": "string", | ||
"description": "GCP service account key content. Using service accounts is not recommended, but if it is used it is better to use environment or file variable substitution" | ||
"type": "string" | ||
}, | ||
"backoff_delay": { | ||
"title": "Backoff Delay", | ||
"description": "Number of seconds to wait before retrying a failed API call", | ||
"type": "integer", | ||
"minimum": 0, | ||
"default": 30 | ||
}, | ||
"backoff_retries": { | ||
"title": "Backoff Retries", | ||
"description": "Number of times to retry a failed API call", | ||
"type": "integer", | ||
"minimum": 0, | ||
"default": 0 | ||
}, | ||
"discovery_concurrency": { | ||
"title": "Discovery Concurrency", | ||
"description": "Number of concurrent API discovery requests to make", | ||
"type": "integer", | ||
"minimum": 1, | ||
"default": 100 | ||
}, | ||
"enabled_services_only": { | ||
"title": "Enabled Services Only", | ||
"description": "Whether only enabled services should be queried", | ||
"type": "boolean" | ||
}, | ||
"concurrency": { | ||
"title": "Concurrency", | ||
"description": "Number of concurrent API requests to make", | ||
"type": "integer", | ||
"minimum": 1, | ||
"default": 50000 | ||
}, | ||
"scheduler": { | ||
"title": "Scheduler Strategy", | ||
"description": "The scheduler strategy to use when determining the order of resources to sync", | ||
"type": "string", | ||
"enum": [ | ||
"dfs", | ||
"round-robin", | ||
"shuffle" | ||
], | ||
"default": "dfs" | ||
"$ref": "#/$defs/Strategy" | ||
}, | ||
"service_account_impersonation": { | ||
"title": "Service Account Impersonation", | ||
"$ref": "#/$defs/CredentialsConfig" | ||
} | ||
}, | ||
"not": { | ||
"description": "project_filter & folder_ids are mutually exclusive", | ||
"required": [ | ||
"project_filter", | ||
"folder_ids" | ||
] | ||
}, | ||
"additionalProperties": false | ||
}, | ||
"CredentialsConfig": { | ||
"type": "object", | ||
"title": "Credentials Config", | ||
"properties": { | ||
"target_principal": { | ||
"title": "Target Principal", | ||
"type": "string", | ||
"description": "Email address of the service account to impersonate", | ||
"format": "email" | ||
}, | ||
"scopes": { | ||
"title": "Scopes", | ||
"description": "OAuth 2.0 scopes that the impersonated credential should have. See https://developers.google.com/identity/protocols/oauth2/scopes for more details.", | ||
"type": "array", | ||
"items": { | ||
"type": "string", | ||
"pattern": "^https://www.googleapis.com/auth/(.)+$" | ||
}, | ||
"default": [ | ||
"https://www.googleapis.com/auth/cloud-platform" | ||
] | ||
}, | ||
"delegates": { | ||
"title": "Delegates", | ||
"description": "Service account email addresses in a delegation chain. Each service account must be granted roles/iam.serviceAccountTokenCreator on the next service account in the chain.", | ||
"type": "array", | ||
"items": { | ||
"type": "string", | ||
"format": "email" | ||
} | ||
}, | ||
"subject": { | ||
"title": "Subject", | ||
"description": "The subject field of a JWT (sub)", | ||
"type": "string", | ||
"minLength": 1 | ||
} | ||
}, | ||
"additionalProperties": false, | ||
"required": [ | ||
"target_principal" | ||
] | ||
"type": "object" | ||
}, | ||
"Strategy": { | ||
"type": "string", | ||
"enum": [ | ||
"dfs", | ||
"round-robin", | ||
"shuffle" | ||
], | ||
"title": "CloudQuery scheduling strategy", | ||
"default": "dfs" | ||
} | ||
} | ||
} |
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