-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
@@customeAzureResource decorator for resources that doesn't use the b…
…ase resource types (#1923) issue: #1474 --------- Co-authored-by: Mark Cowlishaw <[email protected]>
- Loading branch information
1 parent
8f21320
commit b29dfc6
Showing
19 changed files
with
311 additions
and
5 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
.chronus/changes/new-decorator-custom-azure-resource-2024-10-27-15-43-13.md
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,7 @@ | ||
--- | ||
changeKind: feature | ||
packages: | ||
- "@azure-tools/typespec-azure-resource-manager" | ||
--- | ||
|
||
Add the `@Azure.ResourceManager.Legacy.customAzureResource` decorator to identify ARM resources that do not use the base resource types. |
7 changes: 7 additions & 0 deletions
7
.chronus/changes/new-decorator-custom-azure-resource-2024-11-5-11-0-40.md
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,7 @@ | ||
--- | ||
changeKind: feature | ||
packages: | ||
- "@azure-tools/typespec-azure-rulesets" | ||
--- | ||
|
||
Discourage usage of new decorator `@Azure.ResourceManager.Legacy.customAzureResource` |
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
1 change: 1 addition & 0 deletions
1
packages/typespec-azure-resource-manager/lib/Legacy/arm.legacy.tsp
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 +1,2 @@ | ||
import "./managed-identity.tsp"; | ||
import "./decorator.tsp"; |
9 changes: 9 additions & 0 deletions
9
packages/typespec-azure-resource-manager/lib/Legacy/decorator.tsp
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,9 @@ | ||
using TypeSpec.Reflection; | ||
|
||
namespace Azure.ResourceManager.Legacy; | ||
|
||
/** | ||
* This decorator is used on resources that do not satisfy the definition of a resource | ||
* but need to be identified as such. | ||
*/ | ||
extern dec customAzureResource(target: Model); |
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
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
23 changes: 23 additions & 0 deletions
23
packages/typespec-azure-resource-manager/src/rules/arm-custom-resource-usage-discourage.ts
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,23 @@ | ||
import { createRule, Model } from "@typespec/compiler"; | ||
import { isCustomAzureResource } from "../resource.js"; | ||
|
||
export const armCustomResourceUsageDiscourage = createRule({ | ||
name: "arm-custom-resource-usage-discourage", | ||
severity: "warning", | ||
description: "Verify the usage of @customAzureResource decorator.", | ||
messages: { | ||
default: `Avoid using this decorator except when converting old APIs to TypeSpec, as it does not provide validation for ARM resources.`, | ||
}, | ||
create(context) { | ||
return { | ||
model: (model: Model) => { | ||
if (isCustomAzureResource(context.program, model)) { | ||
context.reportDiagnostic({ | ||
code: "arm-custom-resource-usage-discourage", | ||
target: model, | ||
}); | ||
} | ||
}, | ||
}; | ||
}, | ||
}); |
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
Oops, something went wrong.