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

Support unexported fields #198

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kuritka
Copy link

@kuritka kuritka commented Oct 19, 2021

I decided to extend the functionality to support unexported fields.
I have one main reason for this.

  • After I load a structure from envvars, I want to perform the steps that further create the state. I load several variables and then calculate a new one from them, but there is no reason to have the originals public. Another example is that I parse the value of an enum from a private string variable. etc...
// ENV_LOG_LEVEL=info
// my.strLogLevel is unexported and loaded from ENV_LOG_LEVEL
// exported my.LogLevel is NOT string and calculated from unexported one
my.LogLevel = parseLogLevel(my.strLogLevel) 

Signed-off-by: kuritka [email protected]

I decided to extend the functionality to support unexported fields.
I have one main reason for this.
 - After I load a structure from envvars, I want to perform the steps that further create the state.  I load several variables and then calculate a new one from them, but there is no reason to have the originals public. Another example is that I parse the value of an enum from a private string variable. etc...

Signed-off-by: kuritka <[email protected]>
kuritka added a commit to k8gb-io/k8gb that referenced this pull request Oct 21, 2021
Thanks to ENV-BINDER we have moved the responsibility for bindings of environment variables to an external, well tested package.

ENV-BINDER works with unexported fields, so we can bind the values of some fields and calculate a new value from them in the calculation phase.
An example is enum, where env_variable has the value "info" but the internal state of the structure has the value 1. (I have also created a
PR in [kelsyhightower/envconfig](kelseyhightower/envconfig#198), which solves the problem with private fields).

Thanks to the delegation of responsibility I could delete about a third of the test without changing the depressolver
 coverage, which increased to 95% with the changes.

Signed-off-by: kuritka <[email protected]>
kuritka added a commit to k8gb-io/k8gb that referenced this pull request Oct 21, 2021
Thanks to ENV-BINDER we have moved the responsibility for bindings of environment variables to an external, well tested package.

ENV-BINDER works with unexported fields, so we can bind the values of some fields and calculate a new value from them in the calculation phase.
An example is enum, where env_variable has the value "info" but the internal state of the structure has the value 1. (I have also created a
PR in [kelsyhightower/envconfig](kelseyhightower/envconfig#198), which solves the problem with private fields).

Thanks to the delegation of responsibility I could delete about a third of the test without changing the depressolver
 coverage, which increased to 95% with the changes.

Signed-off-by: kuritka <[email protected]>
kuritka added a commit to k8gb-io/k8gb that referenced this pull request Oct 22, 2021
Thanks to ENV-BINDER we have moved the responsibility for bindings of environment variables to an external, well tested package.

ENV-BINDER works with unexported fields, so we can bind the values of some fields and calculate a new value from them in the calculation phase.
An example is enum, where env_variable has the value "info" but the internal state of the structure has the value 1. (I have also created a
PR in [kelsyhightower/envconfig](kelseyhightower/envconfig#198), which solves the problem with private fields).

Thanks to the delegation of responsibility I could delete about a third of the test without changing the depressolver
 coverage, which increased to 95% with the changes.

Signed-off-by: kuritka <[email protected]>
kuritka added a commit to k8gb-io/k8gb that referenced this pull request Oct 22, 2021
Thanks to ENV-BINDER we have moved the responsibility for bindings of environment variables to an external, well tested package.

ENV-BINDER works with unexported fields, so we can bind the values of some fields and calculate a new value from them in the calculation phase.
An example is enum, where env_variable has the value "info" but the internal state of the structure has the value 1. (I have also created a
PR in [kelsyhightower/envconfig](kelseyhightower/envconfig#198), which solves the problem with private fields).

Thanks to the delegation of responsibility I could delete about a third of the test without changing the depressolver
 coverage, which increased to 95% with the changes.

Signed-off-by: kuritka <[email protected]>
kuritka added a commit to k8gb-io/k8gb that referenced this pull request Oct 25, 2021
* Bind env variables with ENV-BINDER, clean tests

Thanks to ENV-BINDER we have moved the responsibility for bindings of environment variables to an external, well tested package.

ENV-BINDER works with unexported fields, so we can bind the values of some fields and calculate a new value from them in the calculation phase.
An example is enum, where env_variable has the value "info" but the internal state of the structure has the value 1. (I have also created a
PR in [kelsyhightower/envconfig](kelseyhightower/envconfig#198), which solves the problem with private fields).

Thanks to the delegation of responsibility I could delete about a third of the test without changing the depressolver
 coverage, which increased to 95% with the changes.

Signed-off-by: kuritka <[email protected]>

* refs #683: remove EXTERNAL_DNS_ from infoblox wapi username and password (#688)

Signed-off-by: Jimmy <[email protected]>
Signed-off-by: kuritka <[email protected]>

Co-authored-by: Sascha <[email protected]>
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.

1 participant