Changes based on latest round of feedback

Signed-off-by: Andre Wanlin <awanlin@rapidrtc.com>
This commit is contained in:
Andre Wanlin
2022-01-22 15:28:39 -06:00
parent 539d686c93
commit 520007b8b0
7 changed files with 32 additions and 32 deletions
+5 -4
View File
@@ -51,13 +51,14 @@ spec:
#### Azure Pipelines Only
If you are only using Azure Pipelines along with a different SCM tool then you can use the following annotation to see Builds:
If you are only using Azure Pipelines along with a different SCM tool then you can use the following two annotations to see Builds:
```yaml
dev.azure.com/project-definition: <project-name>/<definition-name>
dev.azure.com/project: <project-name>
dev.azure.com/build-definition: <build-definition-name>
```
In this case `<project-name>` will be the name of your Team Project and `<definition-name>` will be the name of the Build Definition you would like to see Builds for. If the Build Definition name has spaces in it make sure to put quotes around it
In this case `<project-name>` will be the name of your Team Project and `<build-definition-name>` will be the name of the Build Definition you would like to see Builds for. If the Build Definition name has spaces in it make sure to put quotes around it
### Azure Pipelines Component
@@ -93,7 +94,7 @@ To get the Azure Pipelines component working you'll need to do the following two
</EntitySwitch>
```
2. If you are using the `dev.azure.com/project-definition` annotation then you'll want to do this:
2. If you are using the ``dev.azure.com/project` and `dev.azure.com/build-definition` annotations then you'll want to do this:
```tsx
// In packages/app/src/components/catalog/EntityPage.tsx
@@ -51,7 +51,7 @@ export interface AzureDevOpsApi {
getAllTeams(): Promise<Team[]>;
getUserTeamIds(userId: string): Promise<string[]>;
getBuildRuns(
projectName: string,
repoName?: string,
@@ -93,7 +93,7 @@ export class AzureDevOpsClient implements AzureDevOpsApi {
public getUserTeamIds(userId: string): Promise<string[]> {
return this.get<string[]>(`users/${userId}/team-ids`);
}
public async getBuildRuns(
projectName: string,
repoName?: string,
+3 -2
View File
@@ -14,7 +14,8 @@
* limitations under the License.
*/
export const AZURE_DEVOPS_BUILD_DEFINITION_ANNOTATION =
'dev.azure.com/build-definition';
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_DEFINITION_ANNOTATION =
'dev.azure.com/project-definition';
export const AZURE_DEVOPS_DEFAULT_TOP: number = 10;
+6 -2
View File
@@ -15,7 +15,8 @@
*/
import {
AZURE_DEVOPS_DEFINITION_ANNOTATION,
AZURE_DEVOPS_BUILD_DEFINITION_ANNOTATION,
AZURE_DEVOPS_PROJECT_ANNOTATION,
AZURE_DEVOPS_REPO_ANNOTATION,
} from './constants';
import {
@@ -40,7 +41,10 @@ export const isAzureDevOpsAvailable = (entity: Entity) =>
export const isAzurePipelinesAvailable = (entity: Entity) =>
Boolean(entity.metadata.annotations?.[AZURE_DEVOPS_REPO_ANNOTATION]) ||
Boolean(entity.metadata.annotations?.[AZURE_DEVOPS_DEFINITION_ANNOTATION]);
(Boolean(entity.metadata.annotations?.[AZURE_DEVOPS_PROJECT_ANNOTATION]) &&
Boolean(
entity.metadata.annotations?.[AZURE_DEVOPS_BUILD_DEFINITION_ANNOTATION],
));
export const azureDevOpsPlugin = createPlugin({
id: 'azureDevOps',
@@ -15,7 +15,8 @@
*/
import {
AZURE_DEVOPS_DEFINITION_ANNOTATION,
AZURE_DEVOPS_BUILD_DEFINITION_ANNOTATION,
AZURE_DEVOPS_PROJECT_ANNOTATION,
AZURE_DEVOPS_REPO_ANNOTATION,
} from '../constants';
@@ -26,37 +27,30 @@ export function getAnnotationFromEntity(entity: Entity): {
repo?: string;
definition?: string;
} {
let annotation =
entity.metadata.annotations?.[AZURE_DEVOPS_DEFINITION_ANNOTATION];
if (annotation) {
const { project, definition } = getProjectDefinition(annotation);
const repo = undefined;
return { project, repo, definition };
}
annotation = entity.metadata.annotations?.[AZURE_DEVOPS_REPO_ANNOTATION];
const annotation =
entity.metadata.annotations?.[AZURE_DEVOPS_REPO_ANNOTATION];
if (annotation) {
const { project, repo } = getProjectRepo(annotation);
const definition = undefined;
return { project, repo, definition };
}
throw new Error('No supported Azure DevOps annotation was found');
}
const project =
entity.metadata.annotations?.[AZURE_DEVOPS_PROJECT_ANNOTATION];
if (!project) {
throw new Error('Value for annotation dev.azure.com/project was not found');
}
function getProjectDefinition(annotation: string): {
project: string;
definition: string;
} {
const [project, definition] = annotation.split('/');
if (!project && !definition) {
const definition =
entity.metadata.annotations?.[AZURE_DEVOPS_BUILD_DEFINITION_ANNOTATION];
if (!definition) {
throw new Error(
'Value for annotation dev.azure.com/project-definition was not in the correct format: <project-name>/<definition-name>',
'Value for annotation dev.azure.com/build-definition was not found',
);
}
return { project, definition };
const repo = undefined;
return { project, repo, definition };
}
function getProjectRepo(annotation: string): {