@@ -24,18 +24,25 @@ const command = new Command({
2424 . option ( 'type' , {
2525 describe : 'Context type' ,
2626 choices : [
27- 'config' , 'git.bitbucket-server' , 'git.bitbucket' , 'git.github' , 'git.gitlab ' ,
28- 'git.stash' , 'helm-repository ', 'secret-yaml ' , 'secret ' , 'storage.gc ' , 'storage.s3 ' , 'yaml ' ,
29- 'secret-store.kubernetes' , 'secret-store.kubernetes-runtime' ,
27+ 'config' , 'git.bitbucket-server' , 'git.bitbucket' , 'git.github' , 'git.github-app ' ,
28+ 'git.codefresh-github-app ' , 'git.gitlab ' , 'git.stash ' , 'helm-repository ' , 'secret-yaml ' , 'secret ' ,
29+ 'storage.gc' , 'storage.s3' , 'yaml' , ' secret-store.kubernetes', 'secret-store.kubernetes-runtime' ,
3030 ] ,
3131 } )
3232 . option ( 'decrypt' , {
3333 describe : 'Either to show decoded credentials or not' ,
3434 } )
3535 . option ( 'prepare' , {
36- describe : 'Activate tokens in case its invalid' ,
36+ describe : 'Activate tokens in case its invalid. It\'s supported only for types: '
37+ + '`git.codefresh-github-app`, `git.github-app` and `git.bitbucket` (OAuth2)' ,
38+ } )
39+ . option ( 'force-prepare' , {
40+ describe : 'Refresh the token even if the current token is still valid. Unlike `--prepare`, '
41+ + 'which only refreshes expired tokens, this flag forces a token refresh unconditionally. '
42+ + 'It\'s supported only for `git.bitbucket` (OAuth2)' ,
3743 } )
3844 . example ( 'codefresh get context NAME' , 'Get context NAME' )
45+ . example ( 'codefresh get context NAME --prepare' , 'Get context by NAME and active token if it\'s expired' )
3946 . example ( 'codefresh get contexts' , 'Get all contexts' )
4047 . example ( 'codefresh get context --decrypt' , 'Get all contexts with credentials decrypted' )
4148 . example ( 'codefresh get context --type secret' , 'Get all secret contexts' )
@@ -50,10 +57,13 @@ const command = new Command({
5057 }
5158 data . decrypt = argv . decrypt || undefined ;
5259 data . prepare = argv . prepare || undefined ;
60+ data . forcePrepare = argv [ 'force-prepare' ] || undefined ;
5361
5462 let contexts = [ ] ;
5563 if ( ! _ . isEmpty ( names ) ) {
56- if ( data . prepare ) {
64+ if ( data . forcePrepare ) {
65+ contexts = await Promise . map ( names , name => sdk . contexts . prepare ( { name, forceRefresh : true } ) ) ;
66+ } else if ( data . prepare ) {
5767 contexts = await Promise . map ( names , name => sdk . contexts . prepare ( { name } ) ) ;
5868 } else {
5969 contexts = await Promise . map ( names , name => sdk . contexts . get ( { name, decrypt : data . decrypt } ) ) ;
0 commit comments