Closed pdettori closed 4 years ago
the problem seems to happen in custom_env_parser.go
, in
// Parse interpolates and caches the templates in EnvMap.
func (c *CustomEnvParser) Parse() (map[string]interface{}, error) {
data := make(map[string]interface{})
for _, v := range c.EnvMap {
tmpl, err := template.New("set").Parse(v.Value)
if err != nil {
return data, err
}
// evaluating template and storing value in a buffer
buf := new(bytes.Buffer)
err = tmpl.Execute(buf, c.Cache)
if err != nil {
return data, err
}
// saving buffer in cache
data[v.Name] = buf.String()
}
return data, nil
}
Seems like the content of the cache is not what expected, printing c.Cache as json provides:
{
"DATABASE_CONFIGMAP_DB_HOST": "MTcyLjMwLjY3LjE1NA==",
"DATABASE_CONFIGMAP_DB_NAME": "ZGItZGVtbw==",
"DATABASE_CONFIGMAP_DB_PASSWORD": "cGFzc3dvcmQ=",
"DATABASE_CONFIGMAP_DB_PORT": "NTQzMg==",
"DATABASE_CONFIGMAP_DB_USERNAME": "cG9zdGdyZXM=",
"DATABASE_CONFIGMAP_PASSWORD": "cGFzc3dvcmQ=",
"DATABASE_CONFIGMAP_USER": "cG9zdGdyZXM=",
"DATABASE_DBCONNECTIONIP": "MTcyLjMwLjY3LjE1NA==",
"DATABASE_DBCONNECTIONPORT": "NTQzMg==",
"DATABASE_DBNAME": "ZGItZGVtbw==",
"DATABASE_SECRET_PASSWORD": "cGFzc3dvcmQ=",
"DATABASE_SECRET_USER": "cG9zdGdyZXM="
}
if I go back to older commits for master, that specific error does not show up and printing the cache shows something that makes more sense:
{
"status": {
"data.user": {},
"db.host": {
"db-demo": {}
},
"db.name": {
"db-demo": {}
},
"db.password": {
"db-demo": {}
},
"db.port": {
"db-demo": {}
},
"db.user": {
"db-demo": {}
},
"dbConfigMap": "db-demo",
"dbConnectionIP": "172.30.67.154",
"dbConnectionPort": 5432,
"dbCredentials": {
"password": "password",
"user": "postgres"
},
"dbName": "db-demo",
"password": {},
"user": {}
}
}
I believe you're being affected by the issue being solved in #275, will look closer to it.
Avni's PR #281 should address this issue. There is some unit test. But no e2e test.
@pdettori #281 is merged. Can you try now?
@Avni-Sharma I just tried with the latest master and it works fine.
I am running the service binding operator from master (b0c9641574269f58b6126a406bace6a4b2c07afd on Dec 5) and using
make local
to run. When I try to run the example inexamples/nodejs_postgresql
with the following service binding request:I get the following error: