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

Add provider selection logic, file provider and tests #17

Merged
merged 10 commits into from
Nov 29, 2023

Conversation

csatib02
Copy link
Member

@csatib02 csatib02 commented Nov 9, 2023

Overview

This PR contains a file provider, with tests, and implemented provider selection logic.

Continuation of issue: #1

Functionality

The provider selection works by getting it from an environment variable.
The file provider by default uses / as root path for file system.

The main function has been reworked:

  1. Provider creation.
  2. Extract the secrets path from environment variables.
  3. Load secrets using the provider. (This gives back a slice of secret data, which contains a field for the secret itself, and another for the path.)
  4. Create environment variables from the loaded secrets, and map them to the right environment variable key, using the struct's path field.

env.go has been created.
It encapsulates functionality extracted from the main package, providing a clean separation of concerns and promoting reusability. This approach also enhances testability.

Signed-off-by: Bence Csati <csatib02@gmail.com>
@csatib02 csatib02 self-assigned this Nov 9, 2023
Signed-off-by: Bence Csati <csatib02@gmail.com>
Signed-off-by: Bence Csati <csatib02@gmail.com>
Signed-off-by: Bence Csati <csatib02@gmail.com>
Signed-off-by: Bence Csati <csatib02@gmail.com>
@csatib02 csatib02 marked this pull request as ready for review November 11, 2023 10:41
main.go Outdated Show resolved Hide resolved
main.go Outdated Show resolved Hide resolved
provider/file/file.go Outdated Show resolved Hide resolved
provider/file/file.go Outdated Show resolved Hide resolved
provider/file/file.go Outdated Show resolved Hide resolved
provider/file/file.go Outdated Show resolved Hide resolved
provider/file/file_test.go Outdated Show resolved Hide resolved
Signed-off-by: Bence Csati <csatib02@gmail.com>
go.mod Outdated Show resolved Hide resolved
main.go Outdated Show resolved Hide resolved
main.go Show resolved Hide resolved
provider/file/file.go Outdated Show resolved Hide resolved
provider/file/file.go Outdated Show resolved Hide resolved
provider/file/file.go Outdated Show resolved Hide resolved
provider/file/file.go Outdated Show resolved Hide resolved
…ogic to provider package, and minor fixes

Signed-off-by: Bence Csati <csatib02@gmail.com>
model/provider.go Outdated Show resolved Hide resolved
model/provider.go Outdated Show resolved Hide resolved
provider/file/file.go Show resolved Hide resolved
provider/file/file.go Outdated Show resolved Hide resolved
provider/file/file.go Outdated Show resolved Hide resolved
provider/file/file_test.go Outdated Show resolved Hide resolved
provider/provider.go Outdated Show resolved Hide resolved
…o provider package

Signed-off-by: Bence Csati <csatib02@gmail.com>
…ed tests

Signed-off-by: Bence Csati <csatib02@gmail.com>
Copy link
Member

@ramizpolic ramizpolic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left the final review on the overall logic. The flow makes sense now 👍

provider/file/file.go Outdated Show resolved Hide resolved
provider/file/file.go Outdated Show resolved Hide resolved
provider/file/file.go Outdated Show resolved Hide resolved
provider/file/file.go Outdated Show resolved Hide resolved
main.go Outdated Show resolved Hide resolved
main.go Outdated Show resolved Hide resolved
main.go Outdated Show resolved Hide resolved
Signed-off-by: Bence Csati <csatib02@gmail.com>
Copy link
Member

@ramizpolic ramizpolic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work @csatib02, lgtm!

@csatib02 csatib02 merged commit 1562a95 into bank-vaults:main Nov 29, 2023
13 checks passed
@csatib02 csatib02 deleted the feat/file-provider branch December 15, 2023 12:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants