Environement variables don't work with Redis configuraiton #9

Closed
opened 2023-07-10 14:34:10 +02:00 by pcaseiro · 0 comments
Owner

If you use env with redis configuration Bouncer don't work.

For this configuration :

redis:
    addresses:
        - ${REDIS_SERVER_NAME}:${REDIS_PORT}
    master: "${REDIS_MASTER_NAME}"

This code don't work


var reVar = regexp.MustCompile(`^\${(\w+)}$`)
...
type InterpolatedStringSlice []string

func (iss *InterpolatedStringSlice) UnmarshalYAML(value *yaml.Node) error {
	var data []string

	if err := value.Decode(&data); err != nil {
		return errors.Wrapf(err, "could not decode value '%v' (line '%d') into map", value.Value, value.Line)
	}

	for index, value := range data {
		if match := reVar.FindStringSubmatch(value); len(match) > 0 {
			value = os.Getenv(match[1])
		} 
        
		data[index] = value
	}

	*iss = data

	return nil
}
If you use env with redis configuration Bouncer don't work. For this configuration : ```yaml redis: addresses: - ${REDIS_SERVER_NAME}:${REDIS_PORT} master: "${REDIS_MASTER_NAME}" ``` This code don't work ```go var reVar = regexp.MustCompile(`^\${(\w+)}$`) ... type InterpolatedStringSlice []string func (iss *InterpolatedStringSlice) UnmarshalYAML(value *yaml.Node) error { var data []string if err := value.Decode(&data); err != nil { return errors.Wrapf(err, "could not decode value '%v' (line '%d') into map", value.Value, value.Line) } for index, value := range data { if match := reVar.FindStringSubmatch(value); len(match) > 0 { value = os.Getenv(match[1]) } data[index] = value } *iss = data return nil } ```
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: Cadoles/bouncer#9
No description provided.