Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(cli): reorganize CLI code (#19324)
Reorganize CLI code so that the `aws-auth` and `plugin` directories can be (mostly) airlifted out. Any dependencies it has on surrounding code is encoded in the `_env.ts` source file, which will do foreign imports. The plugin subsystem used to call the context provider subsystem directly--that's now inverted so that you don't have to lift the context provider system out with it. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
- Loading branch information
Showing
28 changed files
with
1,129 additions
and
1,084 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/** | ||
* This file exists to expose and centralize some features that the files in this module expect from the surrounding | ||
* CLI. | ||
* | ||
* The calls will be forwarded to whatever logging system is the "official" logging system for this CLI. | ||
* | ||
* Centralizing in this way makes it easy to copy/paste this directory out and have a single place to | ||
* break dependencies and replace these functions. | ||
*/ | ||
|
||
export { debug, warning, trace } from '../../logging'; | ||
|
||
import { cdkCacheDir } from '../../util/directories'; | ||
|
||
export function accountCacheDir() { | ||
return cdkCacheDir(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,3 @@ | ||
import * as aws from 'aws-sdk'; | ||
|
||
export enum Mode { | ||
ForReading, | ||
ForWriting | ||
} | ||
|
||
/** | ||
*/ | ||
export interface CredentialProviderSource { | ||
name: string; | ||
|
||
/** | ||
* Whether the credential provider is even online | ||
* | ||
* Guaranteed to be called before any of the other functions are called. | ||
*/ | ||
isAvailable(): Promise<boolean>; | ||
|
||
/** | ||
* Whether the credential provider can provide credentials for the given account. | ||
*/ | ||
canProvideCredentials(accountId: string): Promise<boolean>; | ||
|
||
/** | ||
* Construct a credential provider for the given account and the given access mode | ||
* | ||
* Guaranteed to be called only if canProvideCredentails() returned true at some point. | ||
*/ | ||
getProvider(accountId: string, mode: Mode): Promise<aws.Credentials>; | ||
} | ||
// Re-export this here because it used to be here and I don't want | ||
// to change imports too much. | ||
export { Mode } from '../plugin'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/** | ||
* This file exists to expose and centralize some features that the files in this module expect from the surrounding | ||
* CLI. | ||
* | ||
* The calls will be forwarded to whatever logging system is the "official" logging system for this CLI. | ||
* | ||
* Centralizing in this way makes it easy to copy/paste this directory out and have a single place to | ||
* break dependencies and replace these functions. | ||
*/ | ||
|
||
export { error } from '../../logging'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
packages/aws-cdk/lib/api/plugin/credential-provider-source.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import * as aws from 'aws-sdk'; | ||
|
||
export enum Mode { | ||
ForReading, | ||
ForWriting | ||
} | ||
|
||
/** | ||
*/ | ||
export interface CredentialProviderSource { | ||
name: string; | ||
|
||
/** | ||
* Whether the credential provider is even online | ||
* | ||
* Guaranteed to be called before any of the other functions are called. | ||
*/ | ||
isAvailable(): Promise<boolean>; | ||
|
||
/** | ||
* Whether the credential provider can provide credentials for the given account. | ||
*/ | ||
canProvideCredentials(accountId: string): Promise<boolean>; | ||
|
||
/** | ||
* Construct a credential provider for the given account and the given access mode | ||
* | ||
* Guaranteed to be called only if canProvideCredentails() returned true at some point. | ||
*/ | ||
getProvider(accountId: string, mode: Mode): Promise<aws.Credentials>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export * from './plugin'; | ||
export * from './context-provider-plugin'; | ||
export * from './credential-provider-source'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/aws-cdk/lib/context-providers/endpoint-service-availability-zones.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
export * from './api'; | ||
export * from './plugin'; | ||
export { cli } from './cli'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters