You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you want to overwrite the SQS endpoint for all services for all clients, you might specify the env variable CLOUD_AWS_SQS_CLIENTS_DEFAULT_ENDPOINT. This works fine for the default client. However, if you now have a client with a different name, it does not pick up the endpoint anymore and ends up with the default. This is caused by the following code in UnmarshalClientSettings in gosoline/pkg/cloud/aws/awsv2.go:
For the default client, we have clientsKey == "cloud.aws.sqs.clients.default" (for SQS), thus using the normal unmarshal functionality and everything works. If we have a different client, though, we have clientsKey == "cloud.aws.sqs.clients.different" and only access the env variable via cfg.UnmarshalWithDefaultsFromKey(defaultClientKey, "."). This does not pick up the nested env variable and thus only provides the default value from the struct.
The following unit test triggers the same problem without any AWS related code:
func (s*ConfigTestSuite) TestConfig_FromEnvNested() {
typeconfigMapstruct {
Namestring`cfg:"name"`Endpointstring`cfg:"endpoint" default:"https://example.com"`Credentialsstring`cfg:"credentials"`
}
expected:=configMap{
Name: "custom",
Endpoint: "https://api.example.com",
Credentials: "secret",
}
s.setupConfigValues(map[string]interface{}{
"gosoline": map[string]interface{}{
"example": map[string]interface{}{
"config": map[string]interface{}{
"credentials": "secret",
},
},
// remove the following field for a different failure scenario (with s.config.IsSet("gosoline.default.config") no longer being true)"default": map[string]interface{}{
"config": map[string]interface{}{
"name": "default",
},
},
},
})
err:=s.envProvider.SetEnv("GOSOLINE_EXAMPLE_CONFIG_NAME", "custom")
s.NoError(err)
err=s.envProvider.SetEnv("GOSOLINE_DEFAULT_CONFIG_ENDPOINT", "https://api.example.com")
s.NoError(err)
s.True(s.config.IsSet("gosoline.default.config"))
cm:=configMap{}
s.config.UnmarshalKey("gosoline.example.config", &cm,
cfg.UnmarshalWithDefaultsFromKey("gosoline.default.config", "."),
)
s.Equal(expected, cm)
}
The text was updated successfully, but these errors were encountered:
If you want to overwrite the SQS endpoint for all services for all clients, you might specify the env variable
CLOUD_AWS_SQS_CLIENTS_DEFAULT_ENDPOINT
. This works fine for the default client. However, if you now have a client with a different name, it does not pick up the endpoint anymore and ends up with the default. This is caused by the following code inUnmarshalClientSettings
ingosoline/pkg/cloud/aws/awsv2.go
:For the default client, we have
clientsKey == "cloud.aws.sqs.clients.default"
(for SQS), thus using the normal unmarshal functionality and everything works. If we have a different client, though, we haveclientsKey == "cloud.aws.sqs.clients.different"
and only access the env variable viacfg.UnmarshalWithDefaultsFromKey(defaultClientKey, ".")
. This does not pick up the nested env variable and thus only provides the default value from the struct.The following unit test triggers the same problem without any AWS related code:
The text was updated successfully, but these errors were encountered: