Skip to content

Commit

Permalink
refactor: Move default value up the stack TDE-1030 (#854)
Browse files Browse the repository at this point in the history
#### Motivation

A slightly simpler implementation.

#### Checklist

- [ ] Tests updated (unnecessary)
- [ ] Docs updated (N/A)
- [x] Issue linked in Title
  • Loading branch information
l0b0 authored Feb 9, 2024
1 parent 5a8678d commit 18576e6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/commands/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { logger, registerLogger } from '../log.js';
import { isArgo } from '../utils/argo.js';

export const config = option({
defaultValue: () => process.env['AWS_ROLE_CONFIG_PATH'],
long: 'config',
description: 'Location of role configuration file',
type: optional(string),
Expand All @@ -31,7 +32,7 @@ export const forceOutput = flag({
export function registerCli(cli: { name: string }, args: { verbose?: boolean; config?: string }): void {
cleanArgs(args);
registerLogger(args);
registerFileSystem(args);
registerFileSystem(args.config);

logger.info({ package: CliInfo, cli: cli.name, args, isArgo: isArgo() }, 'Cli:Start');
}
Expand Down
7 changes: 3 additions & 4 deletions src/fs.register.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,12 @@ function splitConfig(x: string): string[] {
return x.split(',');
}

export function registerFileSystem(opts: { config?: string }): void {
export function registerFileSystem(config?: string): void {
fsa.register('s3://', s3Fs);

const configPath = opts.config ?? process.env['AWS_ROLE_CONFIG_PATH'];
if (configPath == null || configPath === '') return;
if (config == null || config === '') return;

const paths = splitConfig(configPath);
const paths = splitConfig(config);

for (const path of paths) s3Fs.credentials.registerConfig(path, fsa);
}

0 comments on commit 18576e6

Please sign in to comment.