Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Print log format #285

Merged
merged 4 commits into from
Feb 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@

Thanks for upgrading to the latest version of the ALKS CLI!

* Removes node-fetch/request usage that resulted in punycode deprecation warnings.
# Removes dependency on alks-node.
* Improves logging around output formats

Have feedback? https://github.com/Cox-Automotive/ALKS-CLI/issues

Expand Down
3 changes: 1 addition & 2 deletions dist/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@

Thanks for upgrading to the latest version of the ALKS CLI!

* Removes node-fetch/request usage that resulted in punycode deprecation warnings.
# Removes dependency on alks-node.
* Improves logging around output formats

Have feedback? https://github.com/Cox-Automotive/ALKS-CLI/issues

Expand Down
3 changes: 3 additions & 0 deletions dist/src/lib/getKeyOutput.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/src/lib/getKeyOutput.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions src/lib/getKeyOutput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import moment from 'moment';
import { Key } from '../model/keys';
import { isWindows } from './isWindows';
import { updateCreds } from './updateCreds';
import { log } from './log';

// if adding new output types be sure to update getOutputValues.ts
export function getKeyOutput(
Expand All @@ -13,6 +14,8 @@ export function getKeyOutput(
) {
const keyExpires = moment(key.expires).format();

log(`using output format: ${format}`);

switch (format) {
case 'docker': {
return `-e AWS_ACCESS_KEY_ID=${key.accessKey} -e AWS_SECRET_ACCESS_KEY=${key.secretKey} -e AWS_SESSION_TOKEN=${key.sessionToken} -e AWS_SESSION_EXPIRES=${keyExpires}`;
Expand Down Expand Up @@ -73,6 +76,10 @@ export function getKeyOutput(
case 'export': // fall through to default case
case 'set':
default: {
console.error(
'WARNING: Because this tool runs in a subshell, it cannot set environment variables in the parent shell. To use these keys, copy the commands printed below and run them in your current shell to have these environment variables set'
);

const cmd = isWindows() || format === 'set' ? 'SET' : 'export';

return `${cmd} AWS_ACCESS_KEY_ID=${key.accessKey} && ${cmd} AWS_SECRET_ACCESS_KEY=${key.secretKey} && ${cmd} AWS_SESSION_TOKEN=${key.sessionToken} && ${cmd} AWS_SESSION_EXPIRES=${keyExpires}`;
Expand Down