From 558515fee8114d6a5b05451eb1d7975280a05310 Mon Sep 17 00:00:00 2001 From: ivan katliarchuk Date: Fri, 27 Dec 2024 17:45:57 +0000 Subject: [PATCH] feat(datasource): add aws-eks datasource lint fixes Signed-off-by: ivan katliarchuk --- lib/modules/datasource/aws-eks/index.spec.ts | 43 ++++++++++++-------- lib/modules/datasource/aws-eks/index.ts | 13 ++++-- lib/modules/datasource/aws-eks/readme.md | 10 +---- 3 files changed, 38 insertions(+), 28 deletions(-) diff --git a/lib/modules/datasource/aws-eks/index.spec.ts b/lib/modules/datasource/aws-eks/index.spec.ts index bb3178b90f579c..3ff2082ebb5df8 100644 --- a/lib/modules/datasource/aws-eks/index.spec.ts +++ b/lib/modules/datasource/aws-eks/index.spec.ts @@ -20,11 +20,15 @@ describe('modules/datasource/aws-eks/index', () => { it('should return releases when the response is valid', async () => { const mockResponse: DescribeClusterVersionsCommandOutput = { $metadata: {}, - clusterVersions : [ + clusterVersions: [ { clusterVersion: '1.21', - releaseDate: new Date(new Date().setMonth(new Date().getMonth() - 24)), - endOfStandardSupportDate: new Date(new Date().setMonth(new Date().getMonth() + 10)), + releaseDate: new Date( + new Date().setMonth(new Date().getMonth() - 24), + ), + endOfStandardSupportDate: new Date( + new Date().setMonth(new Date().getMonth() + 10), + ), }, ], }; @@ -33,7 +37,7 @@ describe('modules/datasource/aws-eks/index', () => { const result = await getPkgReleases({ datasource, packageName: '{}' }); - expect(result?.releases).toHaveLength(1) + expect(result?.releases).toHaveLength(1); expect(result).toEqual({ releases: [ { @@ -48,7 +52,10 @@ describe('modules/datasource/aws-eks/index', () => { it('should return null and log an error when the filter is invalid', async () => { const invalidFilter = '{ invalid json }'; - const actual = await getPkgReleases({ datasource, packageName: invalidFilter }); + const actual = await getPkgReleases({ + datasource, + packageName: invalidFilter, + }); expect(actual).toBeNull(); expect(logger.logger.error).toHaveBeenCalledTimes(1); }); @@ -66,12 +73,13 @@ describe('modules/datasource/aws-eks/index', () => { }; eksMock.on(DescribeClusterVersionsCommand).resolves(mockResponse); - const actual = await getPkgReleases( - { datasource, packageName: '{"default":"true", "region":"eu-west-1"}' } - ); + const actual = await getPkgReleases({ + datasource, + packageName: '{"default":"true", "region":"eu-west-1"}', + }); expect(eksMock.calls()).toHaveLength(1); - expect(eksMock.call(0).args[0].input).toEqual({"defaultOnly": true}); + expect(eksMock.call(0).args[0].input).toEqual({ defaultOnly: true }); expect(actual).toEqual({ releases: [ @@ -102,12 +110,14 @@ describe('modules/datasource/aws-eks/index', () => { }; eksMock.on(DescribeClusterVersionsCommand).resolves(mockResponse); - const actual = await getPkgReleases( - { datasource, packageName: '{"default":"false", "region":"eu-west-1", "profile":"admin"}' } - ); + const actual = await getPkgReleases({ + datasource, + packageName: + '{"default":"false", "region":"eu-west-1", "profile":"admin"}', + }); expect(eksMock.calls()).toHaveLength(1); - expect(eksMock.call(0).args[0].input).toEqual({"defaultOnly": false}); + expect(eksMock.call(0).args[0].input).toEqual({ defaultOnly: false }); expect(actual).toEqual({ releases: [ @@ -125,9 +135,10 @@ describe('modules/datasource/aws-eks/index', () => { }; eksMock.on(DescribeClusterVersionsCommand).resolves(mockResponse); - const actual = await getPkgReleases( - { datasource, packageName: '{"profile":"not-exist-profile"}' } - ); + const actual = await getPkgReleases({ + datasource, + packageName: '{"profile":"not-exist-profile"}', + }); expect(eksMock.calls()).toHaveLength(1); expect(eksMock.call(0).args[0].input).toEqual({}); diff --git a/lib/modules/datasource/aws-eks/index.ts b/lib/modules/datasource/aws-eks/index.ts index 1fcfd73a712731..a8a6cc64b742ec 100644 --- a/lib/modules/datasource/aws-eks/index.ts +++ b/lib/modules/datasource/aws-eks/index.ts @@ -4,7 +4,7 @@ import { type DescribeClusterVersionsCommandInput, type DescribeClusterVersionsCommandOutput, EKSClient, -} from "@aws-sdk/client-eks"; +} from '@aws-sdk/client-eks'; import { fromNodeProviderChain } from '@aws-sdk/credential-providers'; import { logger } from '../../../logger'; @@ -51,12 +51,17 @@ export class AwsEKSDataSource extends Datasource { const input: DescribeClusterVersionsCommandInput = { defaultOnly: res.data.default ?? undefined, }; - const cmd = new DescribeClusterVersionsCommand(input) - const response: DescribeClusterVersionsCommandOutput = await this.getClient(res.data).send(cmd) + const cmd = new DescribeClusterVersionsCommand(input); + const response: DescribeClusterVersionsCommandOutput = await this.getClient( + res.data, + ).send(cmd); const results: ClusterVersionInformation[] = response.clusterVersions ?? []; return { releases: results - .filter((el): el is ClusterVersionInformation & { clusterVersion: string } => Boolean(el.clusterVersion)) + .filter( + (el): el is ClusterVersionInformation & { clusterVersion: string } => + Boolean(el.clusterVersion), + ) .map((el) => ({ version: el.clusterVersion, })), diff --git a/lib/modules/datasource/aws-eks/readme.md b/lib/modules/datasource/aws-eks/readme.md index 999e40e18dd52a..03784b52b44a9e 100644 --- a/lib/modules/datasource/aws-eks/readme.md +++ b/lib/modules/datasource/aws-eks/readme.md @@ -50,16 +50,10 @@ renovate: eksFilter={"region":"us-east-1","profile":"renovate-east"} "packageRules": [ { "matchDatasources": ["aws-eks"], - "prBodyColumns": [ - "Package", - "Update", - "Change", - "Sources", - "Changelog" - ], + "prBodyColumns": ["Package", "Update", "Change", "Sources", "Changelog"], "prBodyDefinitions": { "Sources": "[▶️](https://github.com/aws/eks-distro/)", - "Changelog": "[▶️](https://github.com/kubernetes/kubernetes/blob/master/CHANGELOG/CHANGELOG-{{{newVersion}}}.md)", + "Changelog": "[▶️](https://github.com/kubernetes/kubernetes/blob/master/CHANGELOG/CHANGELOG-{{{newVersion}}}.md)" } } ],