diff --git a/.changeset/calm-buckets-relax.md b/.changeset/calm-buckets-relax.md new file mode 100644 index 0000000000000..b950df89b82ed --- /dev/null +++ b/.changeset/calm-buckets-relax.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-azure-devops-backend': patch +--- + +Marked all configuration values as required in the schema. diff --git a/app-config.yaml b/app-config.yaml index 3e2ab8471dce1..16298f3550efa 100644 --- a/app-config.yaml +++ b/app-config.yaml @@ -403,5 +403,5 @@ jenkins: azureDevOps: host: dev.azure.com - token: ${AZURE_TOKEN} + token: my-token organization: my-company diff --git a/plugins/azure-devops-backend/config.d.ts b/plugins/azure-devops-backend/config.d.ts index 9d4e896a89d44..433e4df22fe1c 100644 --- a/plugins/azure-devops-backend/config.d.ts +++ b/plugins/azure-devops-backend/config.d.ts @@ -16,7 +16,7 @@ export interface Config { /** Configuration options for the azure-devops-backend plugin */ - azureDevOps?: { + azureDevOps: { /** * The hostname of the given Azure instance */ @@ -25,7 +25,7 @@ export interface Config { * Token used to authenticate requests. * @visibility secret */ - token?: string; + token: string; /** * The organization of the given Azure instance */ diff --git a/plugins/azure-devops-backend/src/service/router.test.ts b/plugins/azure-devops-backend/src/service/router.test.ts index 08d86c5cc8e2d..a66b86f418e75 100644 --- a/plugins/azure-devops-backend/src/service/router.test.ts +++ b/plugins/azure-devops-backend/src/service/router.test.ts @@ -62,10 +62,7 @@ describe('createRouter', () => { const response = await request(app).get('/health'); expect(response.status).toEqual(200); - expect(response.body).toEqual({ - status: 'Healthy', - details: 'All required config has been provided', - }); + expect(response.body).toEqual({ status: 'ok' }); }); }); diff --git a/plugins/azure-devops-backend/src/service/router.ts b/plugins/azure-devops-backend/src/service/router.ts index c223926848754..1fc86128e60ab 100644 --- a/plugins/azure-devops-backend/src/service/router.ts +++ b/plugins/azure-devops-backend/src/service/router.ts @@ -36,9 +36,9 @@ export async function createRouter( const { logger } = options; const config = options.config.getConfig('azureDevOps'); - const token: string = config.getString('token'); - const host: string = config.getString('host'); - const organization: string = config.getString('organization'); + const token = config.getString('token'); + const host = config.getString('host'); + const organization = config.getString('organization'); const authHandler = getPersonalAccessTokenHandler(token); const webApi = new WebApi(`https://${host}/${organization}`, authHandler); @@ -49,36 +49,8 @@ export async function createRouter( const router = Router(); router.use(express.json()); - router.get('/health', (_, response) => { - let code: number = 200; - let status: string = ''; - let details: string = ''; - - if (token && host && organization) { - code = 200; - status = 'Healthy'; - details = 'All required config has been provided'; - } - - if (!token) { - code = 500; - status = 'Unhealthy'; - details = 'Token is missing'; - } - - if (!host) { - code = 500; - status = 'Unhealthy'; - details = 'Host is missing'; - } - - if (!organization) { - code = 500; - status = 'Unhealthy'; - details = 'Organization is missing'; - } - - response.status(code).json({ status: status, details: details }); + router.get('/health', (_req, res) => { + res.status(200).json({ status: 'ok' }); }); router.get('/repository/:projectName/:repoName', async (req, res) => {