Skip to content

Commit cbb8dd5

Browse files
amp-powellAbby Powell
and
Abby Powell
authored
Allowed duplicates by not re-writing env vars for internal connection (#20166)
* Allowed duplicates by not re-writing env vars for internal connections if already used * Added warning when registry auth is already set * Using debug instead of warning * Updated for BuildConfigGen * Ran BuildConfigGen * Re-ran and re-built for BuildConfigGen * Added new message to EN resjson --------- Co-authored-by: Abby Powell <[email protected]>
1 parent 3cd3564 commit cbb8dd5

File tree

13 files changed

+48
-30
lines changed

13 files changed

+48
-30
lines changed

Tasks/CargoAuthenticateV0/Strings/resources.resjson/en-US/resources.resjson

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@
1313
"loc.messages.ConfigTomlMissingRegistry": "The config.toml file you selected must contain registries table",
1414
"loc.messages.AuthenticatingThisConfigToml": "Adding authentication for registry listed in this config.toml file at %s",
1515
"loc.messages.AddingAuthRegistry": "Adding auth for registry: %s with token name: %s",
16-
"loc.messages.AddingAuthExternalRegistry": "Adding auth for external registry: %s with token name: %s"
16+
"loc.messages.AddingAuthExternalRegistry": "Adding auth for external registry: %s with token name: %s",
17+
"loc.messages.ConnectionAlreadySet": "%s registry is already set for an %s connection"
1718
}

Tasks/CargoAuthenticateV0/cargoauthenticatemain.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ async function main(): Promise<void> {
7979
const registryConfigName = registry.toLocaleUpperCase().replace(/-/g, "_");
8080
const tokenName = `CARGO_REGISTRIES_${registryConfigName}_TOKEN`;
8181
const credProviderName = `CARGO_REGISTRIES_${registryConfigName}_CREDENTIAL_PROVIDER`;
82+
if (tl.getVariable(tokenName)) {
83+
tl.debug(tl.loc('ConnectionAlreadySet', registry, tl.getVariable(tokenName).indexOf('Basic') !== -1 ? 'external' : 'internal'));
84+
}
8285
if (registryUrl && registryUrl.host && collectionHosts.indexOf(registryUrl.host.toLowerCase()) >= 0) {
8386
let currentRegistry : string;
8487
for (let serviceConnection of externalServiceConnections) {
@@ -92,7 +95,7 @@ async function main(): Promise<void> {
9295
}
9396
}
9497
// Default to internal registry if no token has been set yet
95-
if (!currentRegistry) {
98+
if (!currentRegistry && !tl.getVariable(tokenName)) {
9699
tl.debug(tl.loc('AddingAuthRegistry', registry, tokenName));
97100
setSecretEnvVariable(tokenName, localAccesstoken);
98101
tl.setVariable(credProviderName, "cargo:token");

Tasks/CargoAuthenticateV0/task.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"author": "Microsoft Corporation",
1010
"version": {
1111
"Major": 0,
12-
"Minor": 241,
12+
"Minor": 243,
1313
"Patch": 0
1414
},
1515
"runsOn": [
@@ -52,6 +52,7 @@
5252
"ConfigTomlMissingRegistry": "The config.toml file you selected must contain registries table",
5353
"AuthenticatingThisConfigToml": "Adding authentication for registry listed in this config.toml file at %s",
5454
"AddingAuthRegistry": "Adding auth for registry: %s with token name: %s",
55-
"AddingAuthExternalRegistry": "Adding auth for external registry: %s with token name: %s"
55+
"AddingAuthExternalRegistry": "Adding auth for external registry: %s with token name: %s",
56+
"ConnectionAlreadySet": "%s registry is already set for an %s connection"
5657
}
5758
}

Tasks/CargoAuthenticateV0/task.loc.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"author": "Microsoft Corporation",
1010
"version": {
1111
"Major": 0,
12-
"Minor": 241,
12+
"Minor": 243,
1313
"Patch": 0
1414
},
1515
"runsOn": [
@@ -52,6 +52,7 @@
5252
"ConfigTomlMissingRegistry": "ms-resource:loc.messages.ConfigTomlMissingRegistry",
5353
"AuthenticatingThisConfigToml": "ms-resource:loc.messages.AuthenticatingThisConfigToml",
5454
"AddingAuthRegistry": "ms-resource:loc.messages.AddingAuthRegistry",
55-
"AddingAuthExternalRegistry": "ms-resource:loc.messages.AddingAuthExternalRegistry"
55+
"AddingAuthExternalRegistry": "ms-resource:loc.messages.AddingAuthExternalRegistry",
56+
"ConnectionAlreadySet": "ms-resource:loc.messages.ConnectionAlreadySet"
5657
}
5758
}
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
Default|0.241.0
2-
Node20_229_1|0.241.1
1+
Default|0.243.0
2+
Node20_229_1|0.243.5

_generated/CargoAuthenticateV0/Strings/resources.resjson/en-US/resources.resjson

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@
1313
"loc.messages.ConfigTomlMissingRegistry": "The config.toml file you selected must contain registries table",
1414
"loc.messages.AuthenticatingThisConfigToml": "Adding authentication for registry listed in this config.toml file at %s",
1515
"loc.messages.AddingAuthRegistry": "Adding auth for registry: %s with token name: %s",
16-
"loc.messages.AddingAuthExternalRegistry": "Adding auth for external registry: %s with token name: %s"
16+
"loc.messages.AddingAuthExternalRegistry": "Adding auth for external registry: %s with token name: %s",
17+
"loc.messages.ConnectionAlreadySet": "%s registry is already set for an %s connection"
1718
}

_generated/CargoAuthenticateV0/cargoauthenticatemain.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ async function main(): Promise<void> {
7979
const registryConfigName = registry.toLocaleUpperCase().replace(/-/g, "_");
8080
const tokenName = `CARGO_REGISTRIES_${registryConfigName}_TOKEN`;
8181
const credProviderName = `CARGO_REGISTRIES_${registryConfigName}_CREDENTIAL_PROVIDER`;
82+
if (tl.getVariable(tokenName)) {
83+
tl.debug(tl.loc('ConnectionAlreadySet', registry, tl.getVariable(tokenName).indexOf('Basic') !== -1 ? 'external' : 'internal'));
84+
}
8285
if (registryUrl && registryUrl.host && collectionHosts.indexOf(registryUrl.host.toLowerCase()) >= 0) {
8386
let currentRegistry : string;
8487
for (let serviceConnection of externalServiceConnections) {
@@ -92,7 +95,7 @@ async function main(): Promise<void> {
9295
}
9396
}
9497
// Default to internal registry if no token has been set yet
95-
if (!currentRegistry) {
98+
if (!currentRegistry && !tl.getVariable(tokenName)) {
9699
tl.debug(tl.loc('AddingAuthRegistry', registry, tokenName));
97100
setSecretEnvVariable(tokenName, localAccesstoken);
98101
tl.setVariable(credProviderName, "cargo:token");

_generated/CargoAuthenticateV0/task.json

+5-4
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"author": "Microsoft Corporation",
1010
"version": {
1111
"Major": 0,
12-
"Minor": 241,
12+
"Minor": 243,
1313
"Patch": 0
1414
},
1515
"runsOn": [
@@ -52,10 +52,11 @@
5252
"ConfigTomlMissingRegistry": "The config.toml file you selected must contain registries table",
5353
"AuthenticatingThisConfigToml": "Adding authentication for registry listed in this config.toml file at %s",
5454
"AddingAuthRegistry": "Adding auth for registry: %s with token name: %s",
55-
"AddingAuthExternalRegistry": "Adding auth for external registry: %s with token name: %s"
55+
"AddingAuthExternalRegistry": "Adding auth for external registry: %s with token name: %s",
56+
"ConnectionAlreadySet": "%s registry is already set for an %s connection"
5657
},
5758
"_buildConfigMapping": {
58-
"Default": "0.241.0",
59-
"Node20_229_1": "0.241.1"
59+
"Default": "0.243.0",
60+
"Node20_229_1": "0.243.5"
6061
}
6162
}

_generated/CargoAuthenticateV0/task.loc.json

+5-4
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"author": "Microsoft Corporation",
1010
"version": {
1111
"Major": 0,
12-
"Minor": 241,
12+
"Minor": 243,
1313
"Patch": 0
1414
},
1515
"runsOn": [
@@ -52,10 +52,11 @@
5252
"ConfigTomlMissingRegistry": "ms-resource:loc.messages.ConfigTomlMissingRegistry",
5353
"AuthenticatingThisConfigToml": "ms-resource:loc.messages.AuthenticatingThisConfigToml",
5454
"AddingAuthRegistry": "ms-resource:loc.messages.AddingAuthRegistry",
55-
"AddingAuthExternalRegistry": "ms-resource:loc.messages.AddingAuthExternalRegistry"
55+
"AddingAuthExternalRegistry": "ms-resource:loc.messages.AddingAuthExternalRegistry",
56+
"ConnectionAlreadySet": "ms-resource:loc.messages.ConnectionAlreadySet"
5657
},
5758
"_buildConfigMapping": {
58-
"Default": "0.241.0",
59-
"Node20_229_1": "0.241.1"
59+
"Default": "0.243.0",
60+
"Node20_229_1": "0.243.5"
6061
}
6162
}

_generated/CargoAuthenticateV0_Node20/Strings/resources.resjson/en-US/resources.resjson

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@
1313
"loc.messages.ConfigTomlMissingRegistry": "The config.toml file you selected must contain registries table",
1414
"loc.messages.AuthenticatingThisConfigToml": "Adding authentication for registry listed in this config.toml file at %s",
1515
"loc.messages.AddingAuthRegistry": "Adding auth for registry: %s with token name: %s",
16-
"loc.messages.AddingAuthExternalRegistry": "Adding auth for external registry: %s with token name: %s"
16+
"loc.messages.AddingAuthExternalRegistry": "Adding auth for external registry: %s with token name: %s",
17+
"loc.messages.ConnectionAlreadySet": "%s registry is already set for an %s connection"
1718
}

_generated/CargoAuthenticateV0_Node20/cargoauthenticatemain.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ async function main(): Promise<void> {
7979
const registryConfigName = registry.toLocaleUpperCase().replace(/-/g, "_");
8080
const tokenName = `CARGO_REGISTRIES_${registryConfigName}_TOKEN`;
8181
const credProviderName = `CARGO_REGISTRIES_${registryConfigName}_CREDENTIAL_PROVIDER`;
82+
if (tl.getVariable(tokenName)) {
83+
tl.debug(tl.loc('ConnectionAlreadySet', registry, tl.getVariable(tokenName).indexOf('Basic') !== -1 ? 'external' : 'internal'));
84+
}
8285
if (registryUrl && registryUrl.host && collectionHosts.indexOf(registryUrl.host.toLowerCase()) >= 0) {
8386
let currentRegistry : string;
8487
for (let serviceConnection of externalServiceConnections) {
@@ -92,7 +95,7 @@ async function main(): Promise<void> {
9295
}
9396
}
9497
// Default to internal registry if no token has been set yet
95-
if (!currentRegistry) {
98+
if (!currentRegistry && !tl.getVariable(tokenName)) {
9699
tl.debug(tl.loc('AddingAuthRegistry', registry, tokenName));
97100
setSecretEnvVariable(tokenName, localAccesstoken);
98101
tl.setVariable(credProviderName, "cargo:token");

_generated/CargoAuthenticateV0_Node20/task.json

+6-5
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
"author": "Microsoft Corporation",
1010
"version": {
1111
"Major": 0,
12-
"Minor": 241,
13-
"Patch": 1
12+
"Minor": 243,
13+
"Patch": 5
1414
},
1515
"runsOn": [
1616
"Agent",
@@ -56,10 +56,11 @@
5656
"ConfigTomlMissingRegistry": "The config.toml file you selected must contain registries table",
5757
"AuthenticatingThisConfigToml": "Adding authentication for registry listed in this config.toml file at %s",
5858
"AddingAuthRegistry": "Adding auth for registry: %s with token name: %s",
59-
"AddingAuthExternalRegistry": "Adding auth for external registry: %s with token name: %s"
59+
"AddingAuthExternalRegistry": "Adding auth for external registry: %s with token name: %s",
60+
"ConnectionAlreadySet": "%s registry is already set for an %s connection"
6061
},
6162
"_buildConfigMapping": {
62-
"Default": "0.241.0",
63-
"Node20_229_1": "0.241.1"
63+
"Default": "0.243.0",
64+
"Node20_229_1": "0.243.5"
6465
}
6566
}

_generated/CargoAuthenticateV0_Node20/task.loc.json

+6-5
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
"author": "Microsoft Corporation",
1010
"version": {
1111
"Major": 0,
12-
"Minor": 241,
13-
"Patch": 1
12+
"Minor": 243,
13+
"Patch": 5
1414
},
1515
"runsOn": [
1616
"Agent",
@@ -56,10 +56,11 @@
5656
"ConfigTomlMissingRegistry": "ms-resource:loc.messages.ConfigTomlMissingRegistry",
5757
"AuthenticatingThisConfigToml": "ms-resource:loc.messages.AuthenticatingThisConfigToml",
5858
"AddingAuthRegistry": "ms-resource:loc.messages.AddingAuthRegistry",
59-
"AddingAuthExternalRegistry": "ms-resource:loc.messages.AddingAuthExternalRegistry"
59+
"AddingAuthExternalRegistry": "ms-resource:loc.messages.AddingAuthExternalRegistry",
60+
"ConnectionAlreadySet": "ms-resource:loc.messages.ConnectionAlreadySet"
6061
},
6162
"_buildConfigMapping": {
62-
"Default": "0.241.0",
63-
"Node20_229_1": "0.241.1"
63+
"Default": "0.243.0",
64+
"Node20_229_1": "0.243.5"
6465
}
6566
}

0 commit comments

Comments
 (0)