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

New API #14

Merged
merged 17 commits into from
Feb 12, 2021
Merged

New API #14

merged 17 commits into from
Feb 12, 2021

Conversation

hebime
Copy link
Contributor

@hebime hebime commented Feb 10, 2021

This majorly overhauls Serum's API.
It allows you to provide options to initialize serum in a declarative way.

It adds a new source FromEnv which allows Serum to read existing environment variables and decrypt any if necessary.

@hebime hebime requested review from amineck and iToto February 10, 2021 02:18
serum.go Outdated
@@ -16,17 +16,30 @@ type Injector struct {
envVars *envparser.EnvVars
}

// NewInjector creates a new injector using the provided options.
func NewInjector(options ...Option) (*Injector, error) {
Copy link
Contributor

@amineck amineck Feb 10, 2021

Choose a reason for hiding this comment

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

I thought we agreed to have the from as a required param NewInjector(from fInterface, options ...Option). otherwise the API is bit confusing and error prone

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, I must have misunderstood. That works too. I currently have them as Options. I could make a separate type for the source.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated! The first param now is an interface called a Loader. It's responsible for loading env vars from an arbitrary source.

@hebime hebime mentioned this pull request Feb 10, 2021
@hebime hebime marked this pull request as ready for review February 10, 2021 22:57
iToto
iToto previously approved these changes Feb 10, 2021
Copy link
Member

@iToto iToto left a comment

Choose a reason for hiding this comment

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

LGTM

@hebime hebime requested review from amineck and iToto February 11, 2021 18:07
Copy link
Contributor

@amineck amineck left a comment

Choose a reason for hiding this comment

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

Great job Rob!
Beside the defer ij.SecretProvider.Close() I think we have a great api now.

@hebime
Copy link
Contributor Author

hebime commented Feb 12, 2021

Great job Rob!
Beside the defer ij.SecretProvider.Close() I think we have a great api now.

Yea I don't like that either. We can move into the inject but then the user loses control. Either way, we can move this later.

@amineck
Copy link
Contributor

amineck commented Feb 12, 2021

sounds good 🙌
we can also do that by having https://github.com/wingocard/serum/blob/master/serum.go#L15 be a func() secretprovider.SecretProvider instead of secretprovider.SecretProvider.
or simpler, create an ij.Close() that closes all underlying connections.

@hebime hebime merged commit 3e5b352 into master Feb 12, 2021
@hebime hebime deleted the from-env branch February 12, 2021 18:20
@hebime hebime mentioned this pull request Feb 19, 2021
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

3 participants