From 6769c1c576a64c95eced78eedbadc64deb9ba834 Mon Sep 17 00:00:00 2001 From: Rohan Cragg Date: Fri, 7 Jul 2023 11:32:41 +0000 Subject: [PATCH 1/3] Settings and extensions --- .devcontainer/devcontainer.json | 111 +++++++++++++++++--------------- .vscode/extensions.json | 7 +- psrule.code-workspace | 6 +- 3 files changed, 69 insertions(+), 55 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 2128669..0a6b72a 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,59 +1,64 @@ // For format details, see https://aka.ms/devcontainer.json. For config options, see the // README at: https://github.com/devcontainers/templates/tree/main/src/ubuntu { - "name": "Ubuntu", - // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile - "image": "mcr.microsoft.com/devcontainers/base:jammy", - // Features to add to the dev container. More info: https://containers.dev/features. - "features": { - "ghcr.io/devcontainers/features/git:1": { - "ppa": true, - "version": "latest" - }, - "ghcr.io/devcontainers/features/github-cli:1": { - "installDirectlyFromGitHubRelease": true, - "version": "latest" - }, - "ghcr.io/devcontainers/features/powershell:1": { - "version": "latest", - "modules": "Az,PSRule.Rules.Azure" - }, - "azure-cli": { - "version": "latest" - }, - "ghcr.io/devcontainers/features/azure-cli:1": { - "installBicep": true, - "version": "latest" - }, - "ghcr.io/devcontainers/features/dotnet:1": { - "runtimeOnly": true, - "version": "6" - } + "name": "Ubuntu", + // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile + "image": "mcr.microsoft.com/devcontainers/base:jammy", + // Features to add to the dev container. More info: https://containers.dev/features. + "features": { + "ghcr.io/devcontainers/features/git:1": { + "ppa": true, + "version": "latest" }, - - // Use 'forwardPorts' to make a list of ports inside the container available locally. - // "forwardPorts": [], - // Use 'postCreateCommand' to run commands after the container is created. - // "postCreateCommand": "uname -a", - // Configure tool-specific properties. - "customizations": { - "vscode": { - "extensions": [ - "ms-vscode.powershell", - "ms-azuretools.vscode-azureresourcegroups", - "ms-azuretools.vscode-bicep", - "editorconfig.editorconfig", - "bewhite.psrule-vscode-preview", - "shuworks.vscode-table-formatter", - "streetsidesoftware.code-spell-checker", - "wmaurer.change-case", - "esbenp.prettier-vscode", - "davidanson.vscode-markdownlint", - "vsls-contrib.codetour" - ] - } - + "ghcr.io/devcontainers/features/github-cli:1": { + "installDirectlyFromGitHubRelease": true, + "version": "latest" + }, + "ghcr.io/devcontainers/features/powershell:1": { + "version": "latest", + "modules": "Az,PSRule.Rules.Azure" }, - // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. - "remoteUser": "vscode" + "azure-cli": { + "version": "latest" + }, + "ghcr.io/devcontainers/features/azure-cli:1": { + "installBicep": true, + "version": "latest" + }, + "ghcr.io/devcontainers/features/dotnet:1": { + "runtimeOnly": true, + "version": "6" + } + }, + + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // "forwardPorts": [], + // Use 'postCreateCommand' to run commands after the container is created. + // "postCreateCommand": "uname -a", + // Configure tool-specific properties. + "customizations": { + "vscode": { + "extensions": [ + "ms-vscode.powershell", + "bewhite.psrule-vscode-preview", + "msazurermtools.azurerm-vscode-tools", + "ms-azuretools.vscode-bicep", + "ms-azure-devops.azure-pipelines", + "shuworks.vscode-table-formatter", + "streetsidesoftware.code-spell-checker", + "wmaurer.change-case", + "esbenp.prettier-vscode", + "davidanson.vscode-markdownlint", + "vsls-contrib.codetour", + "ms-azuretools.vscode-azureresourcegroups", + "editorconfig.editorconfig" + ], + "settings": { + "PSRule.notifications.showPowerShellExtension": false, + "PSRule.notifications.showChannelUpgrade": false + } + } + }, + // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. + "remoteUser": "vscode" } diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 6985b8a..b652d9d 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -4,11 +4,16 @@ "recommendations": [ "ms-vscode.powershell", "bewhite.psrule-vscode-preview", + "msazurermtools.azurerm-vscode-tools", + "ms-azuretools.vscode-bicep", + "ms-azure-devops.azure-pipelines", "shuworks.vscode-table-formatter", "streetsidesoftware.code-spell-checker", "wmaurer.change-case", "esbenp.prettier-vscode", "davidanson.vscode-markdownlint", - "vsls-contrib.codetour" + "vsls-contrib.codetour", + "ms-azuretools.vscode-azureresourcegroups", + "editorconfig.editorconfig" ] } diff --git a/psrule.code-workspace b/psrule.code-workspace index 10576fe..6123ed9 100644 --- a/psrule.code-workspace +++ b/psrule.code-workspace @@ -6,5 +6,9 @@ } ], "settings": { - } + "workbench.colorTheme": "GitHub Dark", + "redhat.telemetry.enabled": true, + "powershell.integratedConsole.showOnStartup": false, + "powershell.integratedConsole.focusConsoleOnExecute": false + } } From 79582c22fad95b1975a35dceb8828d75cf01c4f2 Mon Sep 17 00:00:00 2001 From: Rohan Cragg Date: Fri, 7 Jul 2023 12:01:36 +0000 Subject: [PATCH 2/3] Be more explicit with dev container config --- .devcontainer/Dockerfile | 10 +++++++++ .devcontainer/container-build.ps1 | 5 +++++ .devcontainer/container-start.ps1 | 5 +++++ .devcontainer/devcontainer.json | 20 ++++++++++++++--- .gitignore | 1 - .vscode/extensions.json | 1 + .vscode/settings.json | 27 ++++++++++++++++++++++ .vscode/tasks.json | 5 ----- cspell.config.yaml | 1 + ps-rule.yaml | 37 +++++++++++++++++++++++++++---- psrule.code-workspace | 14 ------------ 11 files changed, 99 insertions(+), 27 deletions(-) create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/container-build.ps1 create mode 100644 .devcontainer/container-start.ps1 create mode 100644 .vscode/settings.json delete mode 100644 psrule.code-workspace diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..8dde120 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,10 @@ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. + +# Visual Studio Code image with .NET + +# NOTE: +# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.245.2/containers/dotnet/.devcontainer/base.Dockerfile + +ARG VARIANT="6.0-bullseye-slim" +FROM mcr.microsoft.com/vscode/devcontainers/dotnet:0-${VARIANT} diff --git a/.devcontainer/container-build.ps1 b/.devcontainer/container-build.ps1 new file mode 100644 index 0000000..98c6323 --- /dev/null +++ b/.devcontainer/container-build.ps1 @@ -0,0 +1,5 @@ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. + +# Note: +# This is run during container creation. diff --git a/.devcontainer/container-start.ps1 b/.devcontainer/container-start.ps1 new file mode 100644 index 0000000..2732a66 --- /dev/null +++ b/.devcontainer/container-start.ps1 @@ -0,0 +1,5 @@ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. + +# Note: +# This is run during container startup. diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 0a6b72a..39c1d9a 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,9 +1,8 @@ // For format details, see https://aka.ms/devcontainer.json. For config options, see the // README at: https://github.com/devcontainers/templates/tree/main/src/ubuntu { - "name": "Ubuntu", - // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile - "image": "mcr.microsoft.com/devcontainers/base:jammy", + "$schema": "https://raw.githubusercontent.com/devcontainers/spec/main/schemas/devContainer.schema.json", + "name": "PSRule Demo on Ubuntu Container", // Features to add to the dev container. More info: https://containers.dev/features. "features": { "ghcr.io/devcontainers/features/git:1": { @@ -39,6 +38,7 @@ "customizations": { "vscode": { "extensions": [ + "ms-azuretools.vscode-docker", "ms-vscode.powershell", "bewhite.psrule-vscode-preview", "msazurermtools.azurerm-vscode-tools", @@ -54,11 +54,25 @@ "editorconfig.editorconfig" ], "settings": { + "terminal.integrated.defaultProfile.linux": "pwsh", + "terminal.integrated.profiles.linux": { + "pwsh": { + "path": "/opt/microsoft/powershell/7/pwsh" + } + }, "PSRule.notifications.showPowerShellExtension": false, "PSRule.notifications.showChannelUpgrade": false } } }, + "onCreateCommand": "/opt/microsoft/powershell/7/pwsh -f .devcontainer/container-build.ps1", + "postStartCommand": "/opt/microsoft/powershell/7/pwsh -f .devcontainer/container-start.ps1", + "build": { + "dockerfile": "Dockerfile", + "args": { + "VARIANT": "6.0-bullseye-slim" + } + }, // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. "remoteUser": "vscode" } diff --git a/.gitignore b/.gitignore index 48f586b..59490af 100644 --- a/.gitignore +++ b/.gitignore @@ -15,7 +15,6 @@ packages/ Tools/NuGet/ updatablehelp/ xhtml/ -**/settings.json StaleContentReport.*.csv .vscode/styles .vale/ diff --git a/.vscode/extensions.json b/.vscode/extensions.json index b652d9d..4eef8c7 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -2,6 +2,7 @@ // See https://go.microsoft.com/fwlink/?LinkId=827846 // for the documentation about the extensions.json format "recommendations": [ + "ms-azuretools.vscode-docker", "ms-vscode.powershell", "bewhite.psrule-vscode-preview", "msazurermtools.azurerm-vscode-tools", diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..353d33d --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,27 @@ +{ + "workbench.colorTheme": "GitHub Dark", + "redhat.telemetry.enabled": true, + "powershell.integratedConsole.showOnStartup": false, + "powershell.integratedConsole.focusConsoleOnExecute": false, + "files.associations": { + "**/.pipelines/**/*.yaml": "azure-pipelines" + }, + "editor.insertSpaces": true, + "[json]": { + "editor.detectIndentation": false, + "editor.formatOnSave": true, + "editor.tabSize": 2, + "files.insertFinalNewline": true + }, + "[jsonc]": { + "editor.detectIndentation": false, + "editor.formatOnSave": true, + "editor.tabSize": 2, + "files.insertFinalNewline": true + }, + "[markdown]": { + "editor.detectIndentation": false, + "editor.tabSize": 2, + "files.insertFinalNewline": true + } +} diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 94a0423..a6a368b 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -20,11 +20,6 @@ "kind": "build", "isDefault": true }, - "inputPath": "examples/", - "outcome": [ - "Fail", - "Error", - ] } ] } diff --git a/cspell.config.yaml b/cspell.config.yaml index 0338677..6a24ef7 100644 --- a/cspell.config.yaml +++ b/cspell.config.yaml @@ -2,6 +2,7 @@ version: "0.2" ignorePaths: - .vscode/ - devcontainer.json + - '**/settings.json' - cspell.config.yaml dictionaryDefinitions: [] words: diff --git a/ps-rule.yaml b/ps-rule.yaml index 8447fb2..009d1a9 100644 --- a/ps-rule.yaml +++ b/ps-rule.yaml @@ -1,10 +1,42 @@ -## YAML: Enable expansion for Bicep source files. +# +# PSRule for Azure configuration +# + +# Please see the documentation for all configuration options: +# https://aka.ms/ps-rule/options +# https://aka.ms/ps-rule-azure/options + +# Configure binding for local rules. +binding: + preferTargetInfo: true + targetType: + - type + - resourceType + +requires: + PSRule: '@pre >=2.9.0' + PSRule.Rules.Azure: '@pre >=1.27.3' + configuration: + # Enable automatic expansion of JSON parameter files. + AZURE_PARAMETER_FILE_EXPANSION: true + + # Enable automatic expansion of Azure Bicep source files. AZURE_BICEP_FILE_EXPANSION: true + + # Configures the number of seconds to wait for build Bicep files. + AZURE_BICEP_FILE_EXPANSION_TIMEOUT: 10 + + # Enable automatic expansion of Bicep parameter files. AZURE_BICEP_PARAMS_FILE_EXPANSION: true input: pathIgnore: + # Ignore other files in the repository. + - '.vscode/' + - '.github/' + - '*.md' + # Exclude bicepconfig.json - 'bicepconfig.json' @@ -16,9 +48,6 @@ include: module: - PSRule.Rules.Azure -requires: - PSRule.Rules.Azure: 'v1.27.3' - execution: aliasReference: Warn duplicateResourceId: Error diff --git a/psrule.code-workspace b/psrule.code-workspace deleted file mode 100644 index 6123ed9..0000000 --- a/psrule.code-workspace +++ /dev/null @@ -1,14 +0,0 @@ -{ - "folders": [ - { - "name": "psrule", - "path": "." - } - ], - "settings": { - "workbench.colorTheme": "GitHub Dark", - "redhat.telemetry.enabled": true, - "powershell.integratedConsole.showOnStartup": false, - "powershell.integratedConsole.focusConsoleOnExecute": false - } -} From 2c3b48bb3ef54f8c386039295c80766be06f8314 Mon Sep 17 00:00:00 2001 From: Rohan Cragg Date: Fri, 7 Jul 2023 12:19:41 +0000 Subject: [PATCH 3/3] Editor settings and bicep check --- .vscode/settings.json | 24 ++++++++---------------- ps-rule.yaml | 6 ++++++ 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 353d33d..ccfee57 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -6,22 +6,14 @@ "files.associations": { "**/.pipelines/**/*.yaml": "azure-pipelines" }, + "yaml.format.singleQuote": true, + "files.insertFinalNewline": true, "editor.insertSpaces": true, - "[json]": { - "editor.detectIndentation": false, - "editor.formatOnSave": true, - "editor.tabSize": 2, - "files.insertFinalNewline": true + "editor.detectIndentation": false, + "editor.formatOnSave": true, + "editor.tabSize": 2, + "[powershell]": { + "editor.formatOnSave": false, + "editor.tabSize": 4 }, - "[jsonc]": { - "editor.detectIndentation": false, - "editor.formatOnSave": true, - "editor.tabSize": 2, - "files.insertFinalNewline": true - }, - "[markdown]": { - "editor.detectIndentation": false, - "editor.tabSize": 2, - "files.insertFinalNewline": true - } } diff --git a/ps-rule.yaml b/ps-rule.yaml index 009d1a9..08ec9f2 100644 --- a/ps-rule.yaml +++ b/ps-rule.yaml @@ -30,6 +30,12 @@ configuration: # Enable automatic expansion of Bicep parameter files. AZURE_BICEP_PARAMS_FILE_EXPANSION: true + # Enable Bicep CLI checks. + AZURE_BICEP_CHECK_TOOL: true + + # Configure the minimum version of the Bicep CLI. + AZURE_BICEP_MINIMUM_VERSION: '0.18.4' + input: pathIgnore: # Ignore other files in the repository.