77
88import type { GetReleasesConfig , ReleaseResult } from './utils/types' ;
99
10- import { fromNodeProviderChain } from '@aws-sdk/credential-providers' ;
10+ // import { fromNodeProviderChain } from '@aws-sdk/credential-providers';
1111
1212import { EksFilter } from './schema' ;
1313import { logger } from './utils/logger' ;
@@ -16,30 +16,30 @@ import { ClusterVersionInformation } from '@aws-sdk/client-eks/dist-types/models
1616
1717export class AwsEKSDataSource {
1818
19- private readonly clients : Record < string , EKSClient > = { } ;
19+ // private readonly clients: Record<string, EKSClient> = {};
2020
2121 async getReleases ( {
2222 packageName : serializedFilter
2323 } : GetReleasesConfig ) : Promise < ReleaseResult | null > {
2424 const res = EksFilter . safeParse ( serializedFilter ) ;
2525 if ( ! res . success ) {
26+ console . log ( "UPS ERROR" )
2627 logger . debug (
2728 { err : res . error , serializedFilter } ,
2829 'Error parsing eks-addons config.' ,
2930 ) ;
3031 return null
3132 }
3233
33- const filter = res . data ;
34-
3534 const input : DescribeClusterVersionsCommandInput = {
36- defaultOnly : false ,
37- includeAll : true ,
38- maxResults : 1 ,
35+ defaultOnly : res . data . default ?? undefined ,
36+ includeAll : res . data ?. default === undefined ? true : undefined ,
3937 } ;
38+ console . log ( input )
4039 const cmd = new DescribeClusterVersionsCommand ( input )
41- const response : DescribeClusterVersionsCommandOutput = await this . getClient ( filter ) . send ( cmd )
40+ const response : DescribeClusterVersionsCommandOutput = await this . getClientS ( ) . send ( cmd )
4241 const addons : ClusterVersionInformation [ ] = response . clusterVersions ?? [ ] ;
42+ // console.log(addons)
4343 const result = {
4444 releases : addons
4545 . filter ( ( info ) : info is ClusterVersionInformation & { clusterVersion : string } =>
@@ -50,7 +50,7 @@ export class AwsEKSDataSource {
5050 status : info . status ,
5151 } ) )
5252 }
53- console . log ( addons )
53+ // console.log(addons)
5454 return result
5555 // return {
5656 // releases: addons
@@ -73,23 +73,30 @@ export class AwsEKSDataSource {
7373 // };
7474 }
7575
76- private getClient ( { region, profile } : EksFilter ) : EKSClient {
77- const cacheKey = `${ region ?? 'default' } #${ profile ?? 'default' } ` ;
78- if ( ! ( cacheKey in this . clients ) ) {
79- this . clients [ cacheKey ] = new EKSClient ( {
80- region : region ?? undefined ,
81- credentials : fromNodeProviderChain ( profile ? { profile : profile } : undefined )
82- } )
83- }
84- return this . clients [ cacheKey ] ;
76+ // private getClient({ region, profile }: EksFilter): EKSClient {
77+ // const cacheKey = `${region ?? 'default'}#${profile ?? 'default'}`;
78+ // if (!(cacheKey in this.clients)) {
79+ // this.clients[cacheKey] = new EKSClient({
80+ // region: region ?? undefined,
81+ // credentials: fromNodeProviderChain(profile ? { profile: profile } : undefined)
82+ // })
83+ // }
84+ // return this.clients[cacheKey];
85+ // }
86+
87+ private getClientS ( ) : EKSClient {
88+ return new EKSClient ( )
8589 }
8690}
8791
8892const eks = new AwsEKSDataSource ( )
8993
9094const input : readonly string [ ] = [
9195 '{}' ,
92- // '{"addonName":"amazon-cloudwatch-observability", "default":true}'
96+ '{"default":true}' ,
97+ '{"default":false}' ,
98+ // '{"status":"standard-support", "default":true}',
99+ // '{"status":"standard_support"}',
93100] ;
94101
95102input . forEach ( ( el ) => {
0 commit comments