Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add workflow_settings.yaml validation/completion VSCode extension #1770

Merged
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
2 changes: 2 additions & 0 deletions vscode/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ sh_binary(
":language-configuration.json",
":package.json",
":sqlx.grammar.json",
":workflow_settings_yaml.schema.json",
":vscode-sources",
],
)
Expand All @@ -46,6 +47,7 @@ sh_binary(
":README.md",
":LICENSE",
":sqlx.grammar.json",
":workflow_settings_yaml.schema.json",
":vscode-sources",
],
)
31 changes: 31 additions & 0 deletions vscode/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,35 @@ export async function activate(context: vscode.ExtensionContext) {
client.onNotification("success", message => {
vscode.window.showInformationMessage(message);
});

// Recommend YAML extension if not installed
// We also can add the extension to "extensionDependencies" in package.json,
// but this way we can avoid forcing users to install the extension.
// You can control this recommendation behavior through the setting.
if (workspace.getConfiguration("dataform").get("recommendYamlExtension")) {
const yamlExtension = vscode.extensions.getExtension("redhat.vscode-yaml");
if (!yamlExtension) {
await vscode.window.showInformationMessage(
"The Dataform extension recommends installing the YAML extension for workflow_settings.yaml support.",
"Install",
"Don't show again"
).then(selection => {
if (selection === "Install") {
// Open the YAML extension page
vscode.env.openExternal(
vscode.Uri.parse(
"vscode:extension/redhat.vscode-yaml"
)
);
} else if (selection === "Don't show again") {
// Disable the recommendation
workspace.getConfiguration("dataform").update(
"recommendYamlExtension",
false,
vscode.ConfigurationTarget.Global
);
}
});
}
}
}
11 changes: 11 additions & 0 deletions vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@
},
"default": [],
"markdownDescription": "An array of additional arguments the extension should pass to the Dataform cli while executing `dataform compile --json`."
},
"dataform.recommendYamlExtension": {
"type": "boolean",
"default": true,
"markdownDescription": "Whether to recommend the YAML extension for validating `workflow_settings.yaml`."
}
}
}
Expand All @@ -66,6 +71,12 @@
"scopeName": "source.sqlx",
"path": "sqlx.grammar.json"
}
],
"yamlValidation": [
{
"fileMatch": "workflow_settings.yaml",
"url": "./workflow_settings_yaml.schema.json"
}
]
}
}
58 changes: 58 additions & 0 deletions vscode/workflow_settings_yaml.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"$comment": "Created from 'protos/configs.proto'. Even options are specified as 'required' in proto, they might be specified from the CLI options, so leave them optional except for the dataformCoreVersion which is required in compile.",
"additionalProperties": false,
"properties": {
"dataformCoreVersion": {
"type": "string",
"description": "The desired dataform core version to compile against."
},
"defaultProject": {
"type": "string",
"description": "The default Google Cloud project (database)."
},
"defaultDataset": {
"type": "string",
"description": "The default dataset (schema)."
},
"defaultLocation": {
"type": "string",
"description": "The default BigQuery location to use."
},
"defaultAssertionDataset": {
"type": "string",
"description": "The default dataset (schema) for assertions."
},
"vars": {
"type": "object",
"description": "User-defined variables that are made available to project code during compilation. An object containing a list of key-value pairs.",
"additionalProperties": {
"type": "string"
}
},
"projectSuffix": {
"type": "string",
"description": "The suffix to append to all Google Cloud project references."
},
"datasetSuffix": {
"type": "string",
"description": "The suffix to append to all dataset references."
},
"namePrefix": {
"type": "string",
"description": "The prefix to append to all action names."
},
"defaultNotebookRuntimeOptions": {
"type": "object",
"description": "Default runtime options for Notebook actions.",
"outputBucket": {
"type": "string",
"description": "Storage bucket to output notebooks to after their execution."
}
}
},
"required": [
"dataformCoreVersion"
]
}