Skip to content

Commit

Permalink
apply formatters
Browse files Browse the repository at this point in the history
  • Loading branch information
JTaeuber committed Dec 9, 2024
1 parent ae35f2c commit eabefc4
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 54 deletions.
10 changes: 5 additions & 5 deletions .github/ISSUE_TEMPLATE/issue-template.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
---
name: Issue template
about: The general template for issues
title: ''
labels: ''
assignees: ''

title: ""
labels: ""
assignees: ""
---

<!--
Use this issue template for pointing out a general issue.
-->

## Issue

<!--
Briefly describe the issue.
-->


### Problem to solve

<!-- Include the following detail as necessary:
Expand Down
32 changes: 8 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,26 @@
new-pykube
=========
# new-pykube

[![PyPI version](https://badge.fury.io/py/new-pykube.svg)](https://pypi.org/project/new-pykube)
[![Downloads](https://static.pepy.tech/badge/new-pykube/month)](https://github.com/caas-team/new-pykube/releases)
[![Python Test](https://github.com/caas-team/new-pykube/actions/workflows/python-tests.yml/badge.svg)](https://github.com/caas-team/new-pykube/actions/workflows/python-tests.yml)

Pykube (new-pykube) is a lightweight Python 3.6+ client library for Kubernetes.

This is a fork of [pykube-ng](https://codeberg.org/hjacobs/pykube-ng) which is no longer maintained.

This is a fork of the no longer maintained [pykube-ng](https://codeberg.org/hjacobs/pykube-ng).

## Features

* HTTP interface using requests using kubeconfig for authentication
* Python native querying of Kubernetes API objects

- HTTP interface using requests using kubeconfig for authentication
- Python native querying of Kubernetes API objects

## Installation

To install pykube, use pip:

```bash
pip install new-pykube
```


## Interactive Console

The `pykube` library module can be run as an interactive console locally for quick exploration.
Expand All @@ -34,10 +31,8 @@ python3 -m pykube
>>> [d.name for d in Deployment.objects(api)]
```
## Usage
### Query for all ready pods in a custom namespace:
```python
Expand All @@ -49,15 +44,13 @@ pods = pykube.Pod.objects(api).filter(namespace="gondor-system")
ready_pods = filter(operator.attrgetter("ready"), pods)
```
### Access any attribute of the Kubernetes object:
```python
pod = pykube.Pod.objects(api).filter(namespace="gondor-system").get(name="my-pod")
pod.obj["spec"]["containers"][0]["image"]
```
### Selector query:
```python
Expand All @@ -70,7 +63,6 @@ pending_pods = pykube.objects.Pod.objects(api).filter(
)
```
### Watch query:
```python
Expand All @@ -83,7 +75,6 @@ for watch_event in watch:
print(watch_event.object) # pykube.Job object
```
### Create a Deployment:
```python
Expand Down Expand Up @@ -124,7 +115,6 @@ obj = {
pykube.Deployment(api, obj).create()
```
### Delete a Deployment:
```python
Expand All @@ -139,21 +129,18 @@ obj = {
pykube.Deployment(api, obj).delete()
```
### Check server version:
```python
api = pykube.HTTPClient(pykube.KubeConfig.from_file())
api.version
```
## Requirements
* Python 3.6+
* requests (included in `install_requires`)
* PyYAML (included in `install_requires`)
- Python 3.6+
- requests (included in `install_requires`)
- PyYAML (included in `install_requires`)
## Local Development
Expand All @@ -174,18 +161,15 @@ To run PEP8 (flake8) checks and unit tests including coverage report:
make test
```
## License
The code in this project is licensed under the [Apache License, version 2.0](./LICENSE)
## Contributing
Easiest way to contribute is to provide feedback! We would love to hear what you like and what you think is missing.
Create an issue and we will take a look. PRs are welcome.
## Code of Conduct
In order to foster a kind, inclusive, and harassment-free community, this project follows the [Contributor Covenant Code of Conduct](http://contributor-covenant.org/version/1/4/).
Expand Down
4 changes: 1 addition & 3 deletions pykube/config.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
"""
Configuration code.
"""
# Configuration code.
import base64
import copy
import hashlib
Expand Down
4 changes: 1 addition & 3 deletions pykube/http.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
"""
HTTP request related code.
"""
# HTTP request related code.
import base64
import datetime
import json
Expand Down
4 changes: 1 addition & 3 deletions tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
"""
Unittests
"""
# Unittests
import unittest


Expand Down
4 changes: 1 addition & 3 deletions tests/test_config.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
"""
pykube.config unittests
"""
# pykube.config unittests
import os
from pathlib import Path
from unittest.mock import MagicMock
Expand Down
8 changes: 4 additions & 4 deletions tests/test_http.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
"""
pykube.http unittests
"""
# pykube.http unittests
import os
from pathlib import Path
from unittest import mock
Expand Down Expand Up @@ -38,7 +36,9 @@ def test_http(monkeypatch):
mock_send.call_args[0][0].headers["Authorization"]
== "Basic YWRtOnNvbWVwYXNzd29yZA=="
)
assert mock_send.call_args[0][0].headers["User-Agent"] == f"new-pykube/{__version__}"
assert (
mock_send.call_args[0][0].headers["User-Agent"] == f"new-pykube/{__version__}"
)
# check that the default HTTP timeout was set
assert mock_send.call_args[1]["timeout"] == DEFAULT_HTTP_TIMEOUT

Expand Down
7 changes: 1 addition & 6 deletions tests/test_httpclient.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
"""
pykube.http unittests
"""
# pykube.http unittests
import copy
import logging

Expand Down Expand Up @@ -89,6 +87,3 @@ def test_build_session_bearer_token(self):

client = pykube.HTTPClient(pykube.KubeConfig(doc=self.config))
_log.debug("Checking headers %s", client.session.headers)
# TODO: session.headers is no long filled due to KubernetesHTTPAdapter!
# self.assertIn('Authorization', client.session.headers)
# self.assertEqual(client.session.headers['Authorization'], 'Bearer test')
4 changes: 1 addition & 3 deletions tests/test_session.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
"""
pykube.http unittests
"""
# pykube.http unittests
import copy
import logging
import tempfile
Expand Down

0 comments on commit eabefc4

Please sign in to comment.