feedback changes
Signed-off-by: Tarak Nath Tatwa <bikashcric1995@gmail.com>
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/plugin-azure-devops': minor
|
||||
---
|
||||
|
||||
the project and repository details can be obtained using the `backstage.io/managed-by-location` annotation
|
||||
@@ -65,7 +65,7 @@ spec:
|
||||
backstage.io/managed-by-location: https://dev.azure.com/{org}/{project}/_git/{repo}?path=/.catalog/component.yml
|
||||
```
|
||||
|
||||
if `dev.azure.com/project-repo` annotation is not provided and `dev.azure.com/project` not exits then to extract the project and repo information we can use `backstage.io/managed-by-location` annotation if location contains `dev.azure.com` in url to enable CICD tab.
|
||||
In cases where the annotations `dev.azure.com/project-repo` or `dev.azure.com/project` are not present, **the project and repository details can be obtained using the `backstage.io/managed-by-location` annotation**. This method comes into play when the URL within the location includes `dev.azure.com`, which then triggers the activation of the CICD tab.
|
||||
|
||||
#### Azure Pipelines Only
|
||||
|
||||
|
||||
@@ -20,3 +20,4 @@ export const AZURE_DEVOPS_PROJECT_ANNOTATION = 'dev.azure.com/project';
|
||||
export const AZURE_DEVOPS_REPO_ANNOTATION = 'dev.azure.com/project-repo';
|
||||
export const AZURE_DEVOPS_PROJECT_LOCATION = 'backstage.io/managed-by-location';
|
||||
export const AZURE_DEVOPS_DEFAULT_TOP: number = 10;
|
||||
export const AZURE_DEVOPS_URL_FORMAT = 'https://dev.azure.com';
|
||||
|
||||
@@ -19,8 +19,11 @@ import {
|
||||
AZURE_DEVOPS_PROJECT_ANNOTATION,
|
||||
AZURE_DEVOPS_REPO_ANNOTATION,
|
||||
AZURE_DEVOPS_PROJECT_LOCATION,
|
||||
AZURE_DEVOPS_URL_FORMAT,
|
||||
} from '../constants';
|
||||
|
||||
import parseGitUrl from 'git-url-parse';
|
||||
|
||||
import { Entity } from '@backstage/catalog-model';
|
||||
|
||||
export function getAnnotationFromEntity(entity: Entity): {
|
||||
@@ -40,14 +43,15 @@ export function getAnnotationFromEntity(entity: Entity): {
|
||||
entity.metadata.annotations?.[AZURE_DEVOPS_PROJECT_ANNOTATION];
|
||||
|
||||
const location = entity.metadata.annotations?.[AZURE_DEVOPS_PROJECT_LOCATION];
|
||||
const isAzureDevUrl = location?.includes('dev.azure.com');
|
||||
const isAzureDevUrl = location?.includes(AZURE_DEVOPS_URL_FORMAT);
|
||||
|
||||
if (!project && location && isAzureDevUrl) {
|
||||
const locInfoArr = location
|
||||
.substring(location.indexOf('//') + 2)
|
||||
.split('/');
|
||||
const { name: repo, owner } = parseGitUrl(location);
|
||||
|
||||
const projArrData = owner.split('/');
|
||||
|
||||
const proj = projArrData[projArrData.length - 2];
|
||||
|
||||
const [proj, repo] = [locInfoArr[2], locInfoArr[4].split('?')[0]];
|
||||
const definition = undefined;
|
||||
return { project: proj, repo, definition };
|
||||
}
|
||||
|
||||
@@ -14,11 +14,14 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { Entity } from '@backstage/catalog-model';
|
||||
import { AZURE_DEVOPS_PROJECT_LOCATION } from '../constants';
|
||||
import {
|
||||
AZURE_DEVOPS_PROJECT_LOCATION,
|
||||
AZURE_DEVOPS_URL_FORMAT,
|
||||
} from '../constants';
|
||||
|
||||
export const isDevAzureLocation = (entity: Entity): boolean => {
|
||||
const location = entity.metadata.annotations?.[AZURE_DEVOPS_PROJECT_LOCATION];
|
||||
|
||||
if (location) return location.includes('dev.azure.com');
|
||||
if (location) return location.includes(AZURE_DEVOPS_URL_FORMAT);
|
||||
return false;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user