-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Detect new Resource Provider Namespaces, check and validate arm-leases for the RP's #39625
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
base: main
Are you sure you want to change the base?
Conversation
…s for the new RP's
Next Steps to MergeNext steps that must be taken to merge this PR:
Comment generated by summarize-checks workflow run. |
| @@ -0,0 +1,73 @@ | |||
| import { existsSync, readFileSync } from 'fs'; | |||
| import { join } from 'path'; | |||
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.
Is this file just being checked in and not used currently ?
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.
| const SPECIFICATION_PATH = 'specification'; | ||
| // Match pattern: specification/<service>/resource-manager/<ResourceProvider.Namespace>/... | ||
| const RESOURCE_MANAGER_PATTERN = /^specification\/[^\/]+\/resource-manager\/([^\/]+)/; | ||
|
|
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.
We probably need to consider the folder structure for new service groups as well eventually right ? for example Microsoft.Compute :
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.
Updated code considering service group as optional
| export function checkLease(serviceName, resourceProvider) { | ||
| try { | ||
| const repoRoot = process.env.TEST_REPO_ROOT || execSync('git rev-parse --show-toplevel', { encoding: 'utf-8' }).trim(); | ||
| const leasePath = join(repoRoot, '.github', 'arm-leases', serviceName, resourceProvider, 'lease.yaml'); |
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.
here again we need to take in servicergoup as optional param. Look at Microsoft.Compute as an example :
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.
Updated
Overview
The ARM lease validation system makes it easy to check Azure Resource Manager resource provider leases automatically when you open or update a pull request. It helps teams confirm they've got valid leases before making changes to resource providers in the azure-rest-api-specs repo.
Core Components
There are two main modules: detect-arm-leases.js, which handles the lease validation with the checkLease(serviceName, resourceProvider) function, and detect-new-resource-provider.js, which spots new resource provider namespaces and connects with the lease check.
Resource Provider Detection Workflow
Whenever a pull request comes in, the workflow checks for changes in specification/**/resource-manager directories to find new RP namespaces. The extractResourceProviders function gives you a Map of namespace-to-serviceName pairs, which are checked against existing paths with resourceProviderExists. For each new namespace found, checkLease runs and the results are collected and output is designed for consumption by GitHub Actions through the GitHub Script action, enabling automated PR comments that direct contributors to attend office hours for missing or expired leases.
Lease Validation Logic
The checkLease function reads YAML lease files from arm-leases///lease.yaml and checks if the lease is still valid using today <= (startDate + duration). It returns true if the lease is good, or false if it's missing or expired. The system works with different duration formats and handles issues like missing files, invalid YAML, and future start dates without crashing
Just a heads up, this workflow is currently behind a feature flag, so the PMs will decide when and how it gets released.