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

Support validation of fully qualified task names (Especially for tasks installed as extensions). #532

Open
Clockwork-Muse opened this issue Jun 27, 2023 · 2 comments
Labels
accurate-yaml-validation Fidelity of matching YAML features Area: VsCodeExtension enhancement Small enhancement to existing functionality

Comments

@Clockwork-Muse
Copy link

To allow for better discrimination of the source of tasks, it can be handy to include the fully qualified list of task names, eg:

- task: qetza.replacetokens.replacetokens-task.replacetokens@3
  displayName: Replace Tokens
  inputs:
    rootDirectory: $(TerraformDirectory)
    targetFiles: |
      variables.tf
    tokenPrefix: "#{"
    tokenSuffix: "}"
    actionOnMissing: fail
    escapeType: json
    enableTransforms: true

Unfortunately this currently fails to validate:
Fully qualified name fails to validate

Part of this is probably potentially due to the autogenerated (assumedly - I don't control it for my org) yaml schema, which looks like this:

// most properties elided
{
// ...
                        {
                            "description": "Replace tokens in files",
                            "doNotSuggest": false,
                            "ignoreCase": "value",
                            "enum": [
                                "replacetokens@3"
                            ]
                        },
// .....
                    "properties": {
                        "task": {
                            "description": "Replace Tokens\n\nReplace tokens in files",
                            "ignoreCase": "value",
                            "pattern": "^replacetokens@5$"
                        },
                        // ......
                    },
// .....

So it has no concept that there could be a fully qualified name....

@50Wliu 50Wliu added the enhancement Small enhancement to existing functionality label Sep 22, 2023
@50Wliu
Copy link
Member

50Wliu commented Sep 22, 2023

Yes, I agree this is much needed :). Unfortunately not something this extension can handle - that knowledge comes from ADO itself, and you're correct in assuming that it does all the work necessary to generate that schema file.

@50Wliu 50Wliu added the accurate-yaml-validation Fidelity of matching YAML features label Sep 22, 2023
@michha
Copy link

michha commented Aug 23, 2024

I got this working 😃

The Azure DevOps schema would need to change:

  1. Update Task Property List
{
    "description": "Replace tokens in text based files",
    "doNotSuggest": false,
    "ignoreCase": "value",
    "enum": [
        "qetza.replacetokens.replacetokens-task.replacetokens@6",
        "replacetokens@6"
    ]
},
  1. Update pattern matching
"task": {
    "description": "Replace Tokens\n\nReplace tokens in text based files",
    "ignoreCase": "value",
    "pattern": "^(qetza.replacetokens.replacetokens-task.)?replacetokens@6$"
},

I downloaded my org schema file, saved it locally, updated it and pointed the VSCode extension to my local file:
"azure-pipelines.customSchemaFile": "C:\\your-custom-schema.json"

The whole process (download + edit) could be scripted and ran regulary.

But of course it would be nice if the Azure DevOps team could expand their schema.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accurate-yaml-validation Fidelity of matching YAML features Area: VsCodeExtension enhancement Small enhancement to existing functionality
Projects
None yet
Development

No branches or pull requests

4 participants