Closed JonasBak closed 10 months ago
@JonasBak Thanks you!
Can we unit-test it? This would better document the expected behavior.
func Test_provider_configValue(t *testing.T) {
t.Setenv("FOO", "foo")
t.Setenv("BAR", "bar")
t.Setenv("BAZ", "baz")
assert.Equal(t, "foo", configValue(types.StringValue("foo"), "bar"))
assert.Equal(t, "", configValue(types.StringValue(""), "SOME_ENV"))
assert.Equal(t, "bar", configValue(types.StringValue(""), "BAR"))
assert.Equal(t, "baz", configValue(types.StringValue(""), "QUX", "BAZ"))
}
Thanks for the feedback 🙌 I added a test as you suggested.
About the changes
This change introduces the possibility of configuring the auth token using
UNLEASH_AUTH_TOKEN
, instead ofAUTH_TOKEN
. This is useful when using a bunch of providers, to be able to more easily keep track of which env variables are used where, and avoid conflicts with other providers.Closes #90
Important files
Discussion points
To avoid a breaking change I changed the
configValue
so it cloud take multiple values for env variables, and "selects" the first non-empty one. I also saw thatconfigValue.ValueString()
returns""
whenconfigValue.IsNull() == true
(for the case where no env variable is set andconfigValue.IsNull() == true
), so I think it still keeps its old behaviour.Maybe the more "specific"
UNLEASH_AUTH_TOKEN
should be beforeAUTH_TOKEN
so the more specific version if prioritized, in case another provider uses theAUTH_TOKEN
variable?