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 loading source dynamically for nested external modules #13495

Merged
merged 8 commits into from
Mar 4, 2024

Conversation

StephenWeatherford
Copy link
Contributor

@StephenWeatherford StephenWeatherford commented Feb 29, 2024

Two main pieces to this (most of the rest of the changes are minor, tests, or refactoring/renaming):

  1. Add sourceArtifactId to source.gzp for module JSON files that were published with source, so that when the client module is published and displayed on another user's machine, that user view the source as well (if they have permissions to restore it)
    NOTE: I need to do some work to handle errors better here, such as don't have permissions to restore
  2. Changed the document link handler (that displays links for nested external modules when viewing the sources for a module) so that it is resolved when clicked, giving us a chance to try to restore the module first

An example __metadata.json file with sourceArtifactId:

{
    "metadataVersion": 1,
    "bicepVersion": "0.25.0.0",
    "entryPoint": "my complicated module.bicep",
    "sourceFiles": [
        {
            "path": "\u003Ccache\u003E/br/mcr.microsoft.com/bicep$storage$storage-account/1.0.1$/main.json",
            "archivePath": "files/_cache_/br/mcr.microsoft.com/bicep$storage$storage-account/1.0.1$/main.json",
            "kind": "armTemplate",
            "sourceArtifactId": null
        },
        {
            "path": "\u003Ccache\u003E/br/mcr.microsoft.com/bicep$app$app-configuration/1.0.1$/main.json",
            "archivePath": "files/_cache_/br/mcr.microsoft.com/bicep$app$app-configuration/1.0.1$/main.json",
            "kind": "armTemplate",
            "sourceArtifactId": null
        },
        {
            "path": "\u003Ccache\u003E/br/contoso.azurecr.io/demo$complicated/v101$/main.json",
            "archivePath": "files/_cache_/br/contoso.azurecr.io/demo$complicated/v101$/main.json",
            "kind": "armTemplate",
            "sourceArtifactId": "br:contoso.azurecr.io/demo/complicated:v101"
        },
        {
            "path": "\u003Croot2\u003E/storageAccount.bicep",
            "archivePath": "files/_root2_/storageAccount.bicep",
            "kind": "bicep",
            "sourceArtifactId": null
        },
        {
            "path": "\u003Ccache\u003E/br/mcr.microsoft.com/bicep$avm$res$network$public-ip-prefix/0.2.1$/main.json",
            "archivePath": "files/_cache_/br/mcr.microsoft.com/bicep$avm$res$network$public-ip-prefix/0.2.1$/main.json",
            "kind": "armTemplate",
            "sourceArtifactId": "br:mcr.microsoft.com/bicep/avm/res/network/public-ip-prefix:0.2.1"
        },
        {
            "path": "my complicated module.bicep",
            "archivePath": "files/my complicated module.bicep",
            "kind": "bicep",
            "sourceArtifactId": null
        },
        {
            "path": "\u003Ccache\u003E/br/contosopublic.azurecr.io/sourcetest$avm$automation$automation-account/v1.0.1$/main.json",
            "archivePath": "files/_cache_/br/contosopublic.azurecr.io/sourcetest$avm$automation$automation-account/v1.0.1$/main.json",
            "kind": "armTemplate",
            "sourceArtifactId": "br:contosopublic.azurecr.io/sourcetest/avm/automation/automation-account:v1.0.1"
        },
        {
            "path": "\u003Ccache\u003E/br/mcr.microsoft.com/bicep$samples$hello-world/1.0.2$/main.json",
            "archivePath": "files/_cache_/br/mcr.microsoft.com/bicep$samples$hello-world/1.0.2$/main.json",
            "kind": "armTemplate",
            "sourceArtifactId": null
        },
        {
            "path": "modules/module1.bicep",
            "archivePath": "files/modules/module1.bicep",
            "kind": "bicep",
            "sourceArtifactId": null
        }
    ],
    "documentLinks": {
        "modules/module1.bicep": [
            {
                "range": "[8:10]-[8:47]",
                "target": "\u003Ccache\u003E/br/mcr.microsoft.com/bicep$samples$hello-world/1.0.2$/main.json"
            }
        ],
        "my complicated module.bicep": [
            {
                "range": "[183:20]-[183:58]",
                "target": "\u003Croot2\u003E/storageAccount.bicep"
            },
            {
                "range": "[55:10]-[55:47]",
                "target": "\u003Ccache\u003E/br/mcr.microsoft.com/bicep$samples$hello-world/1.0.2$/main.json"
            },
            {
                "range": "[121:17]-[121:73]",
                "target": "\u003Ccache\u003E/br/mcr.microsoft.com/bicep$app$app-configuration/1.0.1$/main.json"
            },
            {
                "range": "[44:27]-[44:66]",
                "target": "\u003Ccache\u003E/br/contosopublic.azurecr.io/sourcetest$avm$automation$automation-account/v1.0.1$/main.json"
            },
            {
                "range": "[151:27]-[151:74]",
                "target": "\u003Ccache\u003E/br/mcr.microsoft.com/bicep$storage$storage-account/1.0.1$/main.json"
            },
            {
                "range": "[138:26]-[138:67]",
                "target": "\u003Ccache\u003E/br/mcr.microsoft.com/bicep$storage$storage-account/1.0.1$/main.json"
            },
            {
                "range": "[125:17]-[125:75]",
                "target": "\u003Ccache\u003E/br/mcr.microsoft.com/bicep$storage$storage-account/1.0.1$/main.json"
            },
            {
                "range": "[147:27]-[147:72]",
                "target": "\u003Ccache\u003E/br/mcr.microsoft.com/bicep$app$app-configuration/1.0.1$/main.json"
            },
            {
                "range": "[134:26]-[134:65]",
                "target": "\u003Ccache\u003E/br/mcr.microsoft.com/bicep$app$app-configuration/1.0.1$/main.json"
            },
            {
                "range": "[62:22]-[62:72]",
                "target": "\u003Ccache\u003E/br/mcr.microsoft.com/bicep$avm$res$network$public-ip-prefix/0.2.1$/main.json"
            },
            {
                "range": "[179:11]-[179:34]",
                "target": "modules/module1.bicep"
            },
            {
                "range": "[176:10]-[176:33]",
                "target": "modules/module1.bicep"
            },
            {
                "range": "[32:26]-[32:51]",
                "target": "\u003Ccache\u003E/br/contoso.azurecr.io/demo$complicated/v101$/main.json"
            }
        ]
    }
}

Copy link
Contributor

github-actions bot commented Feb 29, 2024

Test this change out locally with the following install scripts (Action run 8146552724)

VSCode
  • Mac/Linux
    bash <(curl -Ls https://aka.ms/bicep/nightly-vsix.sh) --run-id 8146552724
  • Windows
    iex "& { $(irm https://aka.ms/bicep/nightly-vsix.ps1) } -RunId 8146552724"
Azure CLI
  • Mac/Linux
    bash <(curl -Ls https://aka.ms/bicep/nightly-cli.sh) --run-id 8146552724
  • Windows
    iex "& { $(irm https://aka.ms/bicep/nightly-cli.ps1) } -RunId 8146552724"

Copy link
Contributor

github-actions bot commented Feb 29, 2024

Test Results

    66 files   -     32      66 suites   - 32   23m 48s ⏱️ - 22m 24s
10 675 tests  -     15  10 674 ✅  -     15  1 💤 ±0  0 ❌ ±0 
25 240 runs   - 12 601  25 238 ✅  - 12 600  2 💤  - 1  0 ❌ ±0 

Results for commit bbc7411. ± Comparison against base commit ff0af89.

♻️ This comment has been updated with latest results.

@StephenWeatherford StephenWeatherford force-pushed the sw/f12-nested-links4 branch 4 times, most recently from 959f6ca to f81da95 Compare March 1, 2024 01:19
@StephenWeatherford StephenWeatherford changed the title work Support loading source dynamically for nested external modules Mar 1, 2024
@StephenWeatherford StephenWeatherford marked this pull request as ready for review March 1, 2024 01:36
@asilverman

This comment was marked as resolved.

@StephenWeatherford

This comment was marked as resolved.

@asilverman asilverman self-requested a review March 4, 2024 20:16
@StephenWeatherford StephenWeatherford merged commit 9094ad6 into main Mar 4, 2024
44 checks passed
@StephenWeatherford StephenWeatherford deleted the sw/f12-nested-links4 branch March 4, 2024 20:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants