inveniosoftware / inveniosoftware/docker-services-cli

cli: error when exporting *_VERSION env vars with values service_name+service_version

Open
#22 3 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Python
Stars
0
Forks
18
Avg merge
1d 15h
Merged PRs (30d)
3

Description

```console
$ docker-services-cli --version
docker-services-cli, version 0.3.0
```

## Description
When a user exports one of the reserved environment variables to set the selected service version (`[ELASTICSEARCH|REDIS|POSTGRESQL]_VERSION`) in a string+version format e.g. `postgresql7` the execution fails.

## Steps to Reproduce
```console
$ export ELASTICSEARCH_VERSION=elasticsearch7
$ docker-services-cli up --search $ELASTICSEARCH_VERSION
Environment variable for version elasticsearch7 not set or set to a non-compliant format (dot separated numbers).
```

## Expected behavior

```console
$ export ELASTICSEARCH_VERSION=elasticsearch7
$ docker-services-cli up --search $ELASTICSEARCH_VERSION
Environment setup
Creating network "docker_services_cli_default" with the default driver
Creating docker_services_cli_elasticsearch_1 ... done
elasticsearch not ready at 1 retries, waiting 2s
elasticsearch not ready at 2 retries, waiting 4s
elasticsearch not ready at 3 retries, waiting 8s
elasticsearch up and running!
Services up!
$ docker ps | grep -i elasticsearch-oss:7
563d457cbfd6 docker.elastic.co/elasticsearch/elasticsearch-oss:7.9.0 "/tini -- /usr/local…" 51 seconds ago Up 50 seconds 0.0.0.0:9200->9200/tcp, 0.0.0.0:9300->9300/tcp docker_services_cli_elasticsearch_1
```

1. It should not fail.
2. I should boot up the correct Elasticsearch version as if one would execute `docker-services-cli up --search elasticsearch7` directly.

## Possible solutions

- Use [the same logic to extract versions from service+version strings](https://github.com/inveniosoftware/docker-services-cli/blob/347bce92f8abfc07b58e54850d8a38cf1c89596d/docker_services_cli/env.py#L100-L106) inside [`_load_or_set_env `](https://github.com/inveniosoftware/docker-services-cli/blob/7a53a2019e37a87e0484d1155e3ec4bddda79c1a/docker_services_cli/env.py#L59).
- Rethink how environment variables are handled inside this module?

## Additional context

This has blocked `invenio-records-resources` builds. See more [here](https://github.com/inveniosoftware/invenio-records-resources/pull/174).

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.