Skip to content

Commit 3a8ef6c

Browse files
committed
2 parents c0ef36c + 599590c commit 3a8ef6c

File tree

11,171 files changed

+3985993
-2621675
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

11,171 files changed

+3985993
-2621675
lines changed

.azure-pipelines/breaking-change-tests.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ jobs:
2020
- checkout: self
2121
fetchDepth: 0
2222
fetchTags: true
23-
persistCredentials: true
2423
- task: UsePythonVersion@0
2524
displayName: 'Use Python 3.10'
2625
inputs:

.azure-pipelines/sync-alias.yml

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
name: Azure CLI Sync Alias
2+
3+
schedules:
4+
- cron: "50 15 * * 0"
5+
displayName: 11:50 PM (UTC + 8:00) China Weekly Run
6+
branches:
7+
include:
8+
- main
9+
10+
# The 'resources' and 'uses' below are used to resolve the error 'Repository associated with wiki ID <WikiId> does not exist or you do not have permissions for the operation you are attempting.'
11+
resources:
12+
repositories:
13+
- repository: ServiceContactList
14+
type: git
15+
name: internal.wiki
16+
17+
jobs:
18+
- job: UpdateYaml
19+
displayName: Update resourceManagement.yml
20+
pool: pool-windows-2019
21+
uses:
22+
repositories:
23+
- ServiceContactList
24+
25+
steps:
26+
- task: UseDotNet@2
27+
displayName: Install .NET 8 SDK
28+
inputs:
29+
packageType: sdk
30+
version: 8.0.x
31+
32+
- pwsh: |
33+
dotnet --version
34+
dotnet new tool-manifest --force
35+
dotnet tool install powershell --version 7.4.*
36+
displayName: Install PowerShell 7.4.x
37+
38+
- pwsh: |
39+
dotnet tool run pwsh -NoLogo -NoProfile -NonInteractive -File ./scripts/automation/ParseServiceContactsList.ps1 -AccessToken $env:SYSTEM_ACCESSTOKEN
40+
env:
41+
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
42+
displayName: Update resourceManagement.yml file locally
43+
44+
- pwsh: |
45+
$hasChanges = git diff --name-only .github/policies
46+
if ($null -eq $hasChanges) {
47+
Write-Host "The wiki has no changes."
48+
Write-Host "##vso[task.setvariable variable=ChangesDetected]false"
49+
} else {
50+
Write-Host "There are changes in the repository."
51+
Write-Host "##vso[task.setvariable variable=ChangesDetected]true"
52+
}
53+
displayName: Check if Wiki table has any changes
54+
55+
- task: AzurePowerShell@5
56+
inputs:
57+
pwsh: true
58+
azureSubscription: '$(AZURE_SDK_INFRA_SUB_CONNECTED_SERVICE)'
59+
ScriptType: 'InlineScript'
60+
Inline: |
61+
$GithubToken = Get-AzKeyVaultSecret -VaultName $(GithubPATKeyVaultName) -Name $(GithubPATKeyVaultAccount) -AsPlainText
62+
Write-Host "##vso[task.setvariable variable=GithubToken;issecret=true]$GithubToken"
63+
azurePowerShellVersion: 'LatestVersion'
64+
displayName: Get Github PAT from Key Vault
65+
66+
- pwsh: |
67+
git config --global user.email "[email protected]"
68+
git config --global user.name "Azure CLI Team"
69+
git checkout -b "sync_alias_$env:Build_BuildId"
70+
71+
git add .github/policies
72+
git commit -m "Sync resourceManagement.yml"
73+
74+
git remote set-url origin https://azclibot:$(GithubToken)@github.com/Azure/azure-cli-extensions.git;
75+
git push origin "sync_alias_$env:Build_BuildId" --force
76+
displayName: Git commit and push
77+
condition: and(succeeded(), eq(variables['ChangesDetected'], 'true'))
78+
79+
- pwsh: |
80+
$Title = "{CI} Sync resourceManagement.yml according To ADO Wiki Page - Service Contact List"
81+
$HeadBranch = "sync_alias_$env:Build_BuildId"
82+
$BaseBranch = "main"
83+
$Description = "This PR synchronizes the task: 'Triage issues to the service team' part of resourceManagement.yml from table of Service Contact List in ADO wiki page"
84+
85+
$Headers = @{"Accept" = "application/vnd.github+json"; "Authorization" = "Bearer $(GithubToken)" }
86+
$RequestBody = @{"title" = $Title; "body" = $Description; "head" = $HeadBranch; "base" = $BaseBranch;}
87+
$Uri = "https://api.github.com/repos/Azure/azure-cli-extensions/pulls"
88+
89+
Invoke-WebRequest -Uri $Uri -Method POST -Headers $Headers -Body ($RequestBody | ConvertTo-Json)
90+
91+
displayName: Create PR to main branch
92+
condition: and(succeeded(), eq(variables['ChangesDetected'], 'true'))

.azure-pipelines/templates/azdev_setup.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ steps:
1717
pip install azdev
1818
azdev --version
1919
azdev setup -c $CLI_REPO_PATH -r $CLI_EXT_REPO_PATH --debug
20+
# Installing setuptools with a version higher than 70.0.0 will not generate metadata.json
21+
pip install setuptools==70.0.0
2022
pip list -v
2123
az --version
2224
displayName: 'azdev setup'

.devcontainer/devcontainer.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"name": "Azure CLI Dev Container",
3+
"image": "mcr.microsoft.com/devcontainers/python:3.12",
4+
"features": {
5+
"ghcr.io/devcontainers/features/github-cli:1": {}
6+
},
7+
"workspaceFolder": "/workspaces",
8+
"onCreateCommand": "python -m venv venv",
9+
"postCreateCommand": "REPO_NAME=$(basename $GITHUB_REPOSITORY) && cat $REPO_NAME/.devcontainer/login.sh >> ~/.bashrc && cp $REPO_NAME/.devcontainer/setup.sh easy_setup.sh && chmod +x easy_setup.sh",
10+
"hostRequirements": {
11+
"cpus": 16,
12+
"memory": "64gb",
13+
"storage": "128gb"
14+
},
15+
"customizations": {
16+
"vscode": {
17+
"extensions": [
18+
"ms-python.python"
19+
]
20+
}
21+
}
22+
}

.devcontainer/login.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
. /workspaces/venv/bin/activate
3+
4+
export GITHUB_TOKEN= # logout default account
5+
6+
if gh auth status -a 2>/dev/null | grep "Token scopes: " | grep -q "repo"; then # check `repo` scope exists or not
7+
echo "You were already logged into GitHub."
8+
else
9+
gh auth login -p https -w
10+
fi

.devcontainer/setup.sh

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#!/bin/bash
2+
3+
# define color codes
4+
GREEN="\033[0;32m"
5+
YELLOW="\033[1;33m"
6+
NC="\033[0m" # no color
7+
8+
set_or_add_remote() {
9+
local REMOTE_NAME=$1
10+
local REMOTE_URL=$2
11+
local REPO_PATH="/workspaces/$REPO_NAME"
12+
13+
git -C "$REPO_PATH" remote get-url "$REMOTE_NAME" &>/dev/null || git -C "$REPO_PATH" remote add "$REMOTE_NAME" "$REMOTE_URL"
14+
git -C "$REPO_PATH" remote set-url "$REMOTE_NAME" "$REMOTE_URL"
15+
}
16+
17+
setup_repo() {
18+
local DIR_NAME="$1"
19+
local DIR_PATH="/workspaces/$DIR_NAME"
20+
local REPO="Azure/$DIR_NAME"
21+
22+
if [ -d "$DIR_PATH" ]; then
23+
echo -e "\n${YELLOW}($DIR_NAME) Pulling the latest changes from upstream...${NC}"
24+
gh repo fork "$REPO" --clone=false
25+
else
26+
echo -e "\n${GREEN}($DIR_NAME) Forking and cloning the repository...${NC}"
27+
gh repo fork "$REPO" --clone=true
28+
fi
29+
30+
# git doesn't work well with private repository
31+
if [ "$(gh repo view "$REPO" --json visibility --jq '.visibility')" == "PRIVATE" ]; then
32+
cd "$DIR_PATH"
33+
gh repo sync --source "$REPO"
34+
cd /workspaces
35+
else
36+
DEFAULT_BRANCH=$(git -C "$DIR_PATH" remote show upstream | grep "HEAD branch" | awk '{print $NF}')
37+
git -C "$DIR_PATH" pull -r upstream "$DEFAULT_BRANCH"
38+
fi
39+
}
40+
41+
SECONDS=0
42+
43+
REPO_NAME=$(basename "$GITHUB_REPOSITORY")
44+
set_or_add_remote origin "https://github.com/$GITHUB_USER/$REPO_NAME.git"
45+
set_or_add_remote upstream "https://github.com/Azure/$REPO_NAME.git"
46+
47+
pip install aaz-dev
48+
49+
# azdev repositories
50+
setup_repo "azure-cli"
51+
setup_repo "azure-cli-extensions"
52+
53+
azdev setup -c -r ./azure-cli-extensions
54+
55+
# aaz-dev repositories
56+
setup_repo "aaz"
57+
setup_repo "azure-rest-api-specs"
58+
setup_repo "azure-rest-api-specs-pr"
59+
60+
ELAPSED_TIME=$SECONDS
61+
echo -e "\n${YELLOW}Elapsed time: $((ELAPSED_TIME / 60)) min $((ELAPSED_TIME % 60)) sec.${NC}"
62+
echo -e "${GREEN}Finished setup! Please launch the codegen tool via \`aaz-dev run -c azure-cli -e azure-cli-extensions -s azure-rest-api-specs -a aaz\`.${NC}\n"

.gitattributes

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,10 @@
1+
# Set default behavior to automatically normalize line endings
2+
* text=auto
3+
4+
# Force bash scripts to use LF
5+
*.sh text eol=lf
6+
7+
# Force batch scripts to use CRLF
8+
*.bat text eol=crlf
9+
110
src/vmware/azext_vmware/tests/latest/recordings/*.yaml linguist-generated=true

.githooks/README.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Git Hooks for Azure CLI Extension Development
2+
3+
## Setup
4+
5+
Please run the following command to enable the hooks.
6+
7+
```bash
8+
azdev setup -c {azure_cli_repo_path} -r {azure_cli_extension_repo_path}
9+
10+
# if you install azdev which version is less than 0.1.84, you need to run the following command to enable the hooks
11+
git config --local core.hooksPath .githooks
12+
```
13+
14+
## Usage
15+
16+
Every time you git commit or git push, please make sure you have activated the python environment and completed the azdev setup.
17+
18+
If you want to skip the verification, you can add `--no-verify` to the git command.
19+
This option will bypass any pre-commit or pre-push hooks that are configured in the repository, allowing you to commit or push changes without running these checks.
20+
For example:
21+
Skipping verification during commit
22+
git commit -m "your commit message" --no-verify
23+
Skipping verification during push
24+
git push origin main --no-verify
25+
26+
## Note
27+
28+
### pre-commit
29+
30+
The pre-commit hook (`pre-commit.ps1`) performs the following checks:
31+
32+
1. Verifies that azdev is active in your current environment
33+
2. Runs `azdev scan` on all staged files to detect potential secrets
34+
3. If any secrets are detected, the commit will be blocked
35+
- You can use `azdev mask` to remove secrets before committing
36+
- Alternatively, use `git commit --no-verify` to bypass the check
37+
38+
### pre-push
39+
40+
The pre-push hooks (`pre-push.sh` for bash and `pre-push.ps1` for PowerShell) perform several quality checks:
41+
42+
1. Verifies that azdev is active in your current environment
43+
2. Detects which repository you're working in:
44+
- For azure-cli (when installed in editable mode):
45+
* Checks if your branch needs rebasing against upstream/dev
46+
* If rebasing is needed, displays instructions and provides a 5-second window to cancel
47+
- For extensions:
48+
* Automatically detects modified extensions
49+
* Adds them to the test scope using `azdev extension add`
50+
3. Runs the following quality checks on changed files:
51+
- `azdev lint`: Checks for linting issues
52+
- `azdev style`: Verifies code style compliance
53+
- `azdev test`: Runs tests for modified code/extensions
54+
4. If any check fails, the push will be blocked
55+
- Use `git push --no-verify` to bypass these checks (not recommended)
56+
57+
The hooks support both Windows (PowerShell) and Unix-like systems (Bash), automatically using the appropriate script for your environment.

.githooks/azdev_active.ps1

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Check if in the python environment
2+
$pythonPath = (Get-Command python -ErrorAction SilentlyContinue).Path
3+
Write-Host "PYTHON_PATH: $pythonPath"
4+
5+
if (-not $pythonPath) {
6+
Write-Host "Error: Python not found in PATH" -ForegroundColor Red
7+
exit 1
8+
}
9+
10+
$pythonEnvFolder = Split-Path -Parent (Split-Path -Parent $pythonPath)
11+
$pythonActiveFile = Join-Path $pythonEnvFolder "Scripts\activate.ps1"
12+
13+
if (-not (Test-Path $pythonActiveFile)) {
14+
Write-Host "Python active file does not exist: $pythonActiveFile" -ForegroundColor Red
15+
Write-Host "Error: Please activate the python environment first." -ForegroundColor Red
16+
exit 1
17+
}
18+
19+
# Construct the full path to the .azdev\env_config directory
20+
$azdevEnvConfigFolder = Join-Path $env:USERPROFILE ".azdev\env_config"
21+
Write-Host "AZDEV_ENV_CONFIG_FOLDER: $azdevEnvConfigFolder"
22+
23+
# Check if the directory exists
24+
if (-not (Test-Path $azdevEnvConfigFolder)) {
25+
Write-Host "AZDEV_ENV_CONFIG_FOLDER does not exist: $azdevEnvConfigFolder" -ForegroundColor Red
26+
Write-Host "Error: azdev environment is not completed, please run 'azdev setup' first." -ForegroundColor Red
27+
exit 1
28+
}
29+
30+
$configFile = Join-Path $azdevEnvConfigFolder ($pythonEnvFolder.Substring(2) + "\config")
31+
if (-not (Test-Path $configFile)) {
32+
Write-Host "CONFIG_FILE does not exist: $configFile" -ForegroundColor Red
33+
Write-Host "Error: azdev environment is not completed, please run 'azdev setup' first." -ForegroundColor Red
34+
exit 1
35+
}
36+
37+
Write-Host "CONFIG_FILE: $configFile"
38+
39+
exit 0

.githooks/azdev_active.sh

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/bin/bash
2+
3+
# Check if in the python environment
4+
PYTHON_FILE=$(which python)
5+
printf "PYTHON_PATH: %s\n" "$PYTHON_FILE"
6+
7+
if [ -z "$PYTHON_FILE" ]; then
8+
printf "\033[0;31mError: Python not found in PATH\033[0m\n"
9+
exit 1
10+
fi
11+
12+
PYTHON_ENV_FOLDER=$(dirname "$PYTHON_FILE")
13+
PYTHON_ACTIVE_FILE="$PYTHON_ENV_FOLDER/activate"
14+
15+
if [ ! -f "$PYTHON_ACTIVE_FILE" ]; then
16+
printf "Python active file does not exist: %s\n" "$PYTHON_ACTIVE_FILE"
17+
printf "\033[0;31mError: Please activate the python environment first.\033[0m\n"
18+
exit 1
19+
fi
20+
21+
# Construct the full path to the .azdev/env_config directory
22+
AZDEV_ENV_CONFIG_FOLDER="$HOME/.azdev/env_config"
23+
printf "AZDEV_ENV_CONFIG_FOLDER: %s\n" "$AZDEV_ENV_CONFIG_FOLDER"
24+
25+
# Check if the directory exists
26+
if [ ! -d "$AZDEV_ENV_CONFIG_FOLDER" ]; then
27+
printf "AZDEV_ENV_CONFIG_FOLDER does not exist: %s\n" "$AZDEV_ENV_CONFIG_FOLDER"
28+
printf "\033[0;31mError: azdev environment is not completed, please run 'azdev setup' first.\033[0m\n"
29+
exit 1
30+
fi
31+
32+
PYTHON_ENV_FOLDER=$(dirname "$PYTHON_ENV_FOLDER")
33+
34+
CONFIG_FILE="$AZDEV_ENV_CONFIG_FOLDER${PYTHON_ENV_FOLDER}/config"
35+
if [ ! -f "$CONFIG_FILE" ]; then
36+
printf "CONFIG_FILE does not exist: %s\n" "$CONFIG_FILE"
37+
printf "\033[0;31mError: azdev environment is not completed, please run 'azdev setup' first.\033[0m\n"
38+
exit 1
39+
fi
40+
41+
printf "CONFIG_FILE: %s\n" "$CONFIG_FILE"

0 commit comments

Comments
 (0)