Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve exception when missing env var #253

Merged
merged 1 commit into from Mar 21, 2023
Merged

Conversation

jwhonce
Copy link
Member

@jwhonce jwhonce commented Mar 20, 2023

When using from_env() and having not set one of the necessary env var.

import podman
podman.from_env()

causes:

ValueError: CONTAINER_HOST or DOCKER_HOST must be set to URL of podman service.

fixes #223

When using from_env() and having not set one of the necessary env var.

```python
import sys
sys.path.insert(0, './podman')
import podman
podman.from_env()
```

causes:

```ValueError: CONTAINER_HOST or DOCKER_HOST must be set to URL of podman service.```

fixes containers#223

Signed-off-by: Jhon Honce <jhonce@redhat.com>
@jwhonce jwhonce self-assigned this Mar 20, 2023
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Mar 20, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jwhonce

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@umohnani8
Copy link
Member

LGTM

@rhatdan
Copy link
Member

rhatdan commented Mar 20, 2023

If the service is running, it should just work correct? Isn't it reading XDG_RUNTIME_DIR looking for the socket?

@jwhonce
Copy link
Member Author

jwhonce commented Mar 21, 2023

@rhatdan The from_env() call reads the configuration from the environment variables. Calling PodmanClient() will use XDG variables to search for the socket.

@rhatdan
Copy link
Member

rhatdan commented Mar 21, 2023

LGTM

@rhatdan rhatdan merged commit 4223e94 into containers:main Mar 21, 2023
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

podman.from_env() not working
3 participants