Skip to content

Commit

Permalink
[#40] Fix !file resolver, the path is not being resolved correctly …
Browse files Browse the repository at this point in the history
…based on the config directory (#41)
  • Loading branch information
lucasvieirasilva authored Sep 14, 2021
1 parent eaad2d8 commit bede46c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

## [2.0.3] - 2021-09-14

### Fixed

- Fix `!file` resolver, the path is not being resolved correctly based on the config directory. [issue-40](https://github.com/lucasvieirasilva/aws-ssm-secrets-cli/issues/40)

## [2.0.2] - 2021-09-14

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion aws_secrets/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '2.0.2'
__version__ = '2.0.3'
8 changes: 4 additions & 4 deletions aws_secrets/tags/file.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import logging
import os
from pathlib import Path

import click
import yaml
Expand Down Expand Up @@ -46,10 +45,11 @@ def __repr__(self) -> str:
config_file = click_ctx.obj.get('config_file', '')
working_dir = os.path.dirname(config_file)

source_file_path = Path(os.path.relpath(self.value, working_dir)).resolve()
source_file_path = os.path.join(working_dir, self.value)

if source_file_path.exists():
return source_file_path.read_text()
if os.path.exists(source_file_path):
with open(source_file_path, 'r') as source:
return source.read()
else:
raise CLIError(f"File '{source_file_path}' not found")

Expand Down

0 comments on commit bede46c

Please sign in to comment.