-
Notifications
You must be signed in to change notification settings - Fork 95
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
Add support for domain name label scopes #2703
Open
MicroFish91
wants to merge
11
commits into
main
Choose a base branch
from
mwf/icy-amber
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
1b46243
WIP: First pass generic client call impl
MicroFish91 ced0018
Fix site return types
MicroFish91 72db4df
Finish basic scenario
MicroFish91 53d25c4
WIP: Appservice updates
MicroFish91 d849730
Merge branch 'main' of https://github.com/microsoft/vscode-azureappse…
MicroFish91 52c0857
Fully implemented, before feedback
MicroFish91 65896e1
WIP: Demo-able
MicroFish91 ae9d71c
Add copyright header
MicroFish91 3503a7a
Rename types
MicroFish91 b827efd
Update dep
MicroFish91 95530d3
Add readme
MicroFish91 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import { type Site } from "@azure/arm-appservice"; | ||
import { uiUtils } from "@microsoft/vscode-azext-azureutils"; | ||
import { callWithTelemetryAndErrorHandling, nonNullProp, nonNullValue, type IActionContext, type ISubscriptionContext } from "@microsoft/vscode-azext-utils"; | ||
import { callWithTelemetryAndErrorHandling, nonNullProp, nonNullValue, nonNullValueAndProp, type IActionContext, type ISubscriptionContext } from "@microsoft/vscode-azext-utils"; | ||
import { type AppResource, type AppResourceResolver } from "@microsoft/vscode-azext-utils/hostapi"; | ||
import { ResolvedWebAppResource } from "./tree/ResolvedWebAppResource"; | ||
import { createWebSiteClient } from "./utils/azureClients"; | ||
|
@@ -9,6 +9,7 @@ export class WebAppResolver implements AppResourceResolver { | |
|
||
private siteCacheLastUpdated = 0; | ||
private siteCache: Map<string, Site> = new Map<string, Site>(); | ||
private siteNameCounter: Map<string, number> = new Map<string, number>(); | ||
private listWebAppsTask: Promise<void> | undefined; | ||
|
||
public async resolveResource(subContext: ISubscriptionContext, resource: AppResource): Promise<ResolvedWebAppResource | undefined> { | ||
|
@@ -17,10 +18,17 @@ export class WebAppResolver implements AppResourceResolver { | |
|
||
if (this.siteCacheLastUpdated < Date.now() - 1000 * 3) { | ||
this.siteCacheLastUpdated = Date.now(); | ||
|
||
this.listWebAppsTask = new Promise((resolve, reject) => { | ||
this.siteCache.clear(); | ||
this.siteNameCounter.clear(); | ||
|
||
uiUtils.listAllIterator(client.webApps.list()).then((sites) => { | ||
for (const site of sites) { | ||
const siteName: string = nonNullProp(site, 'name'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
const count: number = (this.siteNameCounter.get(siteName) ?? 0) + 1; | ||
|
||
this.siteNameCounter.set(siteName, count); | ||
this.siteCache.set(nonNullProp(site, 'id').toLowerCase(), site); | ||
} | ||
resolve(); | ||
|
@@ -33,7 +41,12 @@ export class WebAppResolver implements AppResourceResolver { | |
|
||
await this.listWebAppsTask; | ||
const site = this.siteCache.get(nonNullProp(resource, 'id').toLowerCase()); | ||
return new ResolvedWebAppResource(subContext, nonNullValue(site)); | ||
|
||
return new ResolvedWebAppResource(subContext, nonNullValue(site), { | ||
// Multiple sites with the same name could be displayed as long as they are in different locations | ||
// To help distinguish these apps for our users, lookahead and determine if the location should be provided for duplicated site names | ||
showLocationAsTreeItemDescription: (this.siteNameCounter.get(nonNullValueAndProp(site, 'name')) ?? 1) > 1, | ||
}); | ||
}); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
## Domain Label Scope | ||
|
||
The files in this folder are intended to be temporary because the App Service SDK does not currently support the required API version we need. Consequently, we needed to implement a custom call with custom types. In the future, we expect to be able to remove this folder and consolidate everything into a single web app creation file. | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll clean up the
package.json
andpackage-lock.json
after these packages are ready to be imported through npm registry.