Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into witemple-msft/rollup2
Browse files Browse the repository at this point in the history
  • Loading branch information
witemple-msft committed Jan 25, 2022
2 parents e834674 + 97b77df commit bdd4bca
Show file tree
Hide file tree
Showing 1,039 changed files with 87,003 additions and 29,654 deletions.
347 changes: 175 additions & 172 deletions .github/CODEOWNERS

Large diffs are not rendered by default.

2,228 changes: 1,183 additions & 1,045 deletions common/config/rush/pnpm-lock.yaml

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions eng/common/pipelines/templates/steps/retain-run.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
parameters:
- name: DaysValid
default: 365
default: 731
type: number

steps:
Expand All @@ -16,7 +16,6 @@ steps:
-Project $(System.TeamProject)
-DefinitionId $(System.DefinitionId)
-RunId $(Build.BuildId)
-OwnerId Pipeline
-DaysValid ${{parameters.DaysValid}}
-DaysValid ${{ parameters.DaysValid }}
-AccessToken $env:SYSTEM_ACCESSTOKEN
-Debug
29 changes: 17 additions & 12 deletions eng/common/scripts/Add-RetentionLease.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,33 @@ param(
[Parameter(Mandatory = $true)]
[int]$RunId,

[Parameter(Mandatory = $true)]
[string]$OwnerId,

[Parameter(Mandatory = $true)]
[int]$DaysValid,

[Parameter(Mandatory = $true)]
[string]$AccessToken
[Parameter(Mandatory = $false)]
[string]$OwnerId = "azure-sdk-pipeline-automation",

[Parameter(Mandatory = $false)]
[string]$AccessToken = $env:DEVOPS_PAT
)

Set-StrictMode -Version 3

. (Join-Path $PSScriptRoot common.ps1)

$unencodedAuthToken = "nobody:$AccessToken"
$unencodedAuthTokenBytes = [System.Text.Encoding]::UTF8.GetBytes($unencodedAuthToken)
$encodedAuthToken = [System.Convert]::ToBase64String($unencodedAuthTokenBytes)

# We are doing this here so that there is zero chance that this token is emitted in Azure Pipelines
# build logs. Azure Pipelines will see this text and register the secret as a value it should *** out
# before being transmitted to the server (and shown in logs). It means if the value is accidentally
# leaked anywhere else that it won't be visible. The downside is that when the script is executed
# on a local development box, it will be visible.
Write-Host "##vso[task.setvariable variable=_throwawayencodedaccesstoken;issecret=true;]$($encodedAuthToken)"
if ($isDevOpsRun) {
# We are doing this here so that there is zero chance that this token is emitted in Azure Pipelines
# build logs. Azure Pipelines will see this text and register the secret as a value it should *** out
# before being transmitted to the server (and shown in logs). It means if the value is accidentally
# leaked anywhere else that it won't be visible. The downside is that when the script is executed
# on a local development box, it will be visible.
Write-Host "##vso[task.setvariable variable=_throwawayencodedaccesstoken;issecret=true;]$($encodedAuthToken)"
}

. (Join-Path $PSScriptRoot common.ps1)

LogDebug "Checking for existing leases on run: $RunId"
$existingLeases = Get-RetentionLeases -Organization $Organization -Project $Project -DefinitionId $DefinitionId -RunId $RunId -OwnerId $OwnerId -Base64EncodedAuthToken $encodedAuthToken
Expand Down
81 changes: 81 additions & 0 deletions eng/common/scripts/Get-AADIdentityFromGithubUser.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<#
.DESCRIPTION
Get the corresponding ms alias from github identity
.PARAMETER AadToken
The aad access token.
.PARAMETER GithubName
Github identity. E.g sima-zhu
.PARAMETER ContentType
Content type of http requests.
.PARAMETER AdditionalHeaders
Additional parameters for http request headers in key-value pair format, e.g. @{ key1 = val1; key2 = val2; key3 = val3}
#>
[CmdletBinding(SupportsShouldProcess = $true)]
param(
[Parameter(Mandatory = $true)]
[string]$TenantId,

[Parameter(Mandatory = $true)]
[string]$ClientId,

[Parameter(Mandatory = $true)]
[string]$ClientSecret,

[Parameter(Mandatory = $true)]
[string]$GithubUser
)
Set-StrictMode -Version 3

. "${PSScriptRoot}\common.ps1"

$OpensourceAPIBaseURI = "https://repos.opensource.microsoft.com/api/people/links/github/$GithubUser"

function Generate-AadToken ($TenantId, $ClientId, $ClientSecret) {
$LoginAPIBaseURI = "https://login.microsoftonline.com/$TenantId/oauth2/token"
try {
$headers = @{
"content-type" = "application/x-www-form-urlencoded"
}

$body = @{
"grant_type" = "client_credentials"
"client_id" = $ClientId
"client_secret" = $ClientSecret
"resource" = "api://repos.opensource.microsoft.com/audience/7e04aa67"
}
Write-Host "Generating aad token..."
$resp = Invoke-RestMethod $LoginAPIBaseURI -Method 'POST' -Headers $headers -Body $body
}
catch {
LogError $_
exit 1
}

return $resp.access_token
}

$Headers = @{
"Content-Type" = "application/json"
"api-version" = "2019-10-01"
}

try {
$opsAuthToken = Generate-AadToken -TenantId $TenantId -ClientId $ClientId -ClientSecret $ClientSecret
$Headers["Authorization"] = "Bearer $opsAuthToken"
Write-Host "Fetching aad identity for github user: $GithubName"
$resp = Invoke-RestMethod $OpensourceAPIBaseURI -Method 'GET' -Headers $Headers
}
catch {
LogError $_
exit 1
}

$resp | Write-Verbose

if ($resp.aad) {
Write-Host "Fetched aad identity $($resp.aad.alias) for github user $GithubName."
return $resp.aad.alias
}

LogError "Failed to retrieve the aad identity from given github user: $GithubName"
exit 1
2 changes: 1 addition & 1 deletion eng/common/scripts/Invoke-DevOpsAPI.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ function Add-RetentionLease {
$RunId,
$OwnerId,
$DaysValid,
$Base64AuthToken
$Base64EncodedAuthToken
)

$parameter = @{}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ class StressTestPackageInfo {
[string]$Namespace
[string]$Directory
[string]$ReleaseName
[string]$Dockerfile
[string]$DockerBuildDir
}

function FindStressPackages([string]$directory, [hashtable]$filters = @{}, [switch]$CI) {
Expand Down Expand Up @@ -52,6 +54,8 @@ function NewStressTestPackageInfo([hashtable]$chart, [System.IO.FileInfo]$chartF
Namespace = $namespace.ToLower()
Directory = $chartFile.DirectoryName
ReleaseName = $chart.name
Dockerfile = $chart.annotations.dockerfile
DockerBuildDir = $chart.annotations.dockerbuilddir
}
}

Expand Down
23 changes: 15 additions & 8 deletions eng/common/scripts/stress-testing/stress-test-deployment-lib.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,6 @@ function DeployStressTests(
$subscription = 'Azure SDK Test Resources'
}

if (!$repository) {
$repository = if ($env:USER) { $env:USER } else { "${env:USERNAME}" }
# Remove spaces, etc. that may be in $namespace
$repository -replace '\W'
}

if ($login) {
if (!$clusterGroup -or !$subscription) {
throw "clusterGroup and subscription parameters must be specified when logging into an environment that is not test or prod."
Expand Down Expand Up @@ -156,11 +150,24 @@ function DeployStressPackage(
}
$imageTag += "/$($pkg.Namespace)/$($pkg.ReleaseName):${deployId}"

$dockerFilePath = "$($pkg.Directory)/Dockerfile"
$dockerFilePath = if ($pkg.Dockerfile) {
Join-Path $pkg.Directory $pkg.Dockerfile
} else {
"$($pkg.Directory)/Dockerfile"
}
$dockerFilePath = [System.IO.Path]::GetFullPath($dockerFilePath)

if ($pushImages -and (Test-Path $dockerFilePath)) {
Write-Host "Building and pushing stress test docker image '$imageTag'"
$dockerFile = Get-ChildItem $dockerFilePath
Run docker build -t $imageTag -f $dockerFile.FullName $dockerFile.DirectoryName
$dockerBuildFolder = if ($pkg.DockerBuildDir) {
Join-Path $pkg.Directory $pkg.DockerBuildDir
} else {
$dockerFile.DirectoryName
}
$dockerBuildFolder = [System.IO.Path]::GetFullPath($dockerBuildFolder).Trim()

Run docker build -t $imageTag -f $dockerFile $dockerBuildFolder
if ($LASTEXITCODE) { return }
Run docker push $imageTag
if ($LASTEXITCODE) {
Expand Down
25 changes: 25 additions & 0 deletions rush.json
Original file line number Diff line number Diff line change
Expand Up @@ -1554,6 +1554,31 @@
"packageName": "@azure/arm-vmwarecloudsimple",
"projectFolder": "sdk/vmwarecloudsimple/arm-vmwarecloudsimple",
"versionPolicyName": "management"
},
{
"packageName": "@azure/arm-servicefabricmesh",
"projectFolder": "sdk/servicefabricmesh/arm-servicefabricmesh",
"versionPolicyName": "management"
},
{
"packageName": "@azure/arm-storageimportexport",
"projectFolder": "sdk/storageimportexport/arm-storageimportexport",
"versionPolicyName": "management"
},
{
"packageName": "@azure/arm-privatedns",
"projectFolder": "sdk/privatedns/arm-privatedns",
"versionPolicyName": "management"
},
{
"packageName": "@azure/arm-policyinsights",
"projectFolder": "sdk/policyinsights/arm-policyinsights",
"versionPolicyName": "management"
},
{
"packageName": "@azure/arm-kusto",
"projectFolder": "sdk/kusto/arm-kusto",
"versionPolicyName": "management"
}
]
}
2 changes: 1 addition & 1 deletion sdk/communication/communication-chat/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"files": [
"dist/",
"dist-esm/src/",
"types/",
"types/communication-chat.d.ts",
"README.md",
"LICENSE"
],
Expand Down
7 changes: 7 additions & 0 deletions sdk/core/core-amqp/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"plugins": ["@azure/azure-sdk"],
"extends": ["plugin:@azure/azure-sdk/azure-sdk-base"],
"rules": {
"sort-imports": "error"
}
}
4 changes: 2 additions & 2 deletions sdk/core/core-amqp/src/cbs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ import {
SenderOptions,
generate_uuid,
} from "rhea-promise";
import { translate } from "./errors";
import { StandardAbortMessage } from "./util/constants";
import { logErrorStackTrace, logger } from "./log";
import { Constants } from "./util/constants";
import { RequestResponseLink } from "./requestResponseLink";
import { StandardAbortMessage } from "./util/constants";
import { TokenType } from "./auth/token";
import { defaultCancellableLock } from "./util/utils";
import { translate } from "./errors";

/**
* Describes the CBS Response.
Expand Down
2 changes: 1 addition & 1 deletion sdk/core/core-amqp/src/requestResponseLink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import {
Session,
generate_uuid,
} from "rhea-promise";
import { logErrorStackTrace, logger } from "./log";
import { Constants, StandardAbortMessage } from "./util/constants";
import { logErrorStackTrace, logger } from "./log";
import { isDefined } from "./util/typeGuards";

/**
Expand Down
7 changes: 7 additions & 0 deletions sdk/core/core-auth/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"plugins": ["@azure/azure-sdk"],
"extends": ["plugin:@azure/azure-sdk/azure-sdk-base"],
"rules": {
"sort-imports": "error"
}
}
7 changes: 7 additions & 0 deletions sdk/core/core-crypto/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"plugins": ["@azure/azure-sdk"],
"extends": ["plugin:@azure/azure-sdk/azure-sdk-base"],
"rules": {
"sort-imports": "error"
}
}
3 changes: 2 additions & 1 deletion sdk/core/core-http/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"@azure/azure-sdk/ts-apiextractor-json-types": "off",
"@azure/azure-sdk/ts-package-json-types": "off",
"@azure/azure-sdk/ts-package-json-module": "off",
"@azure/azure-sdk/ts-package-json-files-required": "off"
"@azure/azure-sdk/ts-package-json-files-required": "off",
"sort-imports": "error"
}
}
2 changes: 1 addition & 1 deletion sdk/core/core-http/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
"@types/node-fetch": "^2.5.0",
"@types/tunnel": "^0.0.3",
"form-data": "^4.0.0",
"node-fetch": "^2.6.6",
"node-fetch": "^2.6.7",
"process": "^0.11.10",
"tough-cookie": "^4.0.0",
"tslib": "^2.2.0",
Expand Down
7 changes: 7 additions & 0 deletions sdk/core/core-lro/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"plugins": ["@azure/azure-sdk"],
"extends": ["plugin:@azure/azure-sdk/azure-sdk-base"],
"rules": {
"sort-imports": "error"
}
}
3 changes: 2 additions & 1 deletion sdk/core/core-paging/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"rules": {
// `package.json`'s sideEffects has to be true because this package loads a
// polyfill.
"@azure/azure-sdk/ts-package-json-sideeffects": "off"
"@azure/azure-sdk/ts-package-json-sideeffects": "off",
"sort-imports": "error"
}
}
3 changes: 2 additions & 1 deletion sdk/core/core-tracing/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"extends": ["plugin:@azure/azure-sdk/azure-sdk-base"],
"rules": {
"@azure/azure-sdk/ts-no-const-enums": "off",
"@azure/azure-sdk/ts-versioning-semver": "warn"
"@azure/azure-sdk/ts-versioning-semver": "warn",
"sort-imports": "error"
}
}
2 changes: 1 addition & 1 deletion sdk/core/core-tracing/test/instrumenter.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

import { assert } from "chai";
import { Instrumenter, TracingSpan } from "../src/interfaces";
import {
createDefaultInstrumenter,
Expand All @@ -10,6 +9,7 @@ import {
useInstrumenter,
} from "../src/instrumenter";
import { createTracingContext, knownContextKeys } from "../src/tracingContext";
import { assert } from "chai";

describe("Instrumenter", () => {
describe("NoOpInstrumenter", () => {
Expand Down
4 changes: 2 additions & 2 deletions sdk/core/core-tracing/test/interfaces.spec.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

import * as coreAuth from "@azure/core-auth";
import * as coreTracing from "../src";
import { assert } from "chai";
import { createTracingContext } from "../src/tracingContext";
import * as coreTracing from "../src";
import * as coreAuth from "@azure/core-auth";

describe("Interface compatibility", () => {
describe("OperationTracingOptions", () => {
Expand Down
6 changes: 3 additions & 3 deletions sdk/core/core-tracing/test/tracingClient.spec.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

import { assert } from "chai";
import sinon from "sinon";
import { Instrumenter, TracingClient, TracingContext, TracingSpan } from "../src/interfaces";
import {
createDefaultInstrumenter,
createDefaultTracingSpan,
useInstrumenter,
} from "../src/instrumenter";
import { createTracingClient } from "../src/tracingClient";
import { createTracingContext, knownContextKeys } from "../src/tracingContext";
import { assert } from "chai";
import { createTracingClient } from "../src/tracingClient";
import sinon from "sinon";

describe("TracingClient", () => {
let instrumenter: Instrumenter;
Expand Down
Loading

0 comments on commit bdd4bca

Please sign in to comment.