Skip to content

Commit def9119

Browse files
committed
Initial commit
0 parents  commit def9119

24 files changed

+1937
-0
lines changed

.circleci/config.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
version: 2.1
2+
orbs:
3+
codecov: codecov/[email protected]
4+
5+
jobs:
6+
test:
7+
working_directory: ~/repo
8+
parameters:
9+
python-version:
10+
type: string
11+
docker:
12+
- image: cimg/python:<< parameters.python-version >>
13+
steps:
14+
- checkout
15+
- restore_cache:
16+
keys:
17+
- venv-<< parameters.python-version >>-{{ checksum "poetry.lock" }}
18+
- run:
19+
name: Install Dependencies
20+
command: |
21+
pip install poetry --user --upgrade
22+
poetry config virtualenvs.in-project true
23+
poetry install
24+
- run:
25+
name: Create Test Results Dir
26+
command: mkdir -p test-reports/safety test-reports/mypy test-reports/pytest
27+
28+
- run:
29+
name: Black
30+
command: poetry run black . --check
31+
32+
- run:
33+
name: isort
34+
command: poetry run isort . --check
35+
36+
- run:
37+
name: Safety
38+
command: poetry export -f requirements.txt | poetry run safety check --stdin
39+
40+
- run:
41+
name: mypy
42+
command: poetry run mypy src --junit-xml=test-reports/mypy/results.xml
43+
44+
- run:
45+
name: Unit Tests
46+
command: |
47+
poetry run pytest --junitxml=test-reports/pytest/results.xml --cov=src tests
48+
poetry run coverage xml
49+
- codecov/upload:
50+
file: coverage.xml
51+
52+
- store_test_results:
53+
path: test-reports
54+
55+
- run:
56+
command: poetry run pip uninstall debops -y
57+
name: Uninstall Package
58+
- save_cache:
59+
key: venv-<< parameters.python-version >>-{{ checksum "poetry.lock" }}
60+
paths:
61+
- ./.venv
62+
63+
workflows:
64+
tests:
65+
jobs:
66+
- test:
67+
matrix:
68+
parameters:
69+
python-version: ["3.8"]

.flake8

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[flake8]
2+
max-line-length = 90

.gitignore

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
output/*
2+
3+
# Byte-compiled / optimized / DLL files
4+
__pycache__/
5+
*.py[cod]
6+
*$py.class
7+
8+
# Distribution / packaging
9+
.Python
10+
build/
11+
develop-eggs/
12+
dist/
13+
downloads/
14+
eggs/
15+
.eggs/
16+
lib/
17+
lib64/
18+
parts/
19+
sdist/
20+
var/
21+
wheels/
22+
pip-wheel-metadata/
23+
share/python-wheels/
24+
*.egg-info/
25+
.installed.cfg
26+
*.egg
27+
MANIFEST
28+
29+
# PyInstaller
30+
# Usually these files are written by a python script from a template
31+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
32+
*.manifest
33+
*.spec
34+
35+
# Installer logs
36+
pip-log.txt
37+
pip-delete-this-directory.txt
38+
39+
# Unit test / coverage reports
40+
htmlcov/
41+
.tox/
42+
.nox/
43+
.coverage
44+
.coverage.*
45+
.cache
46+
nosetests.xml
47+
coverage.xml
48+
*.cover
49+
.hypothesis/
50+
.pytest_cache/
51+
52+
# Translations
53+
*.mo
54+
*.pot
55+
56+
# Django stuff:
57+
*.log
58+
local_settings.py
59+
db.sqlite3
60+
61+
# Flask stuff:
62+
instance/
63+
.webassets-cache
64+
65+
# Scrapy stuff:
66+
.scrapy
67+
68+
# Sphinx documentation
69+
docs/_build/
70+
71+
# PyBuilder
72+
target/
73+
74+
# Jupyter Notebook
75+
.ipynb_checkpoints
76+
77+
# IPython
78+
profile_default/
79+
ipython_config.py
80+
81+
# pyenv
82+
.python-version
83+
84+
# pipenv
85+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
86+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
87+
# having no cross-platform support, pipenv may install dependencies that don’t work, or not
88+
# install all needed dependencies.
89+
#Pipfile.lock
90+
91+
# celery beat schedule file
92+
celerybeat-schedule
93+
94+
# SageMath parsed files
95+
*.sage.py
96+
97+
# Environments
98+
.env
99+
.venv
100+
env/
101+
venv/
102+
ENV/
103+
env.bak/
104+
venv.bak/
105+
106+
# mkdocs documentation
107+
/site
108+
109+
# mypy
110+
.mypy_cache/
111+
.dmypy.json
112+
dmypy.json
113+
114+
# Pyre type checker
115+
.pyre/
116+
117+
# Pycharm
118+
.idea

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2020 Upciti
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# debops
2+
3+
Are you tired of checking if your favorite devops tools are up-to-date? Are you using a debian based GNU/Linux distribution?
4+
Debops is designed to generate Debian packages for common devops tools such as kubectl, kustomize, helm, ...,
5+
but it could be used to package any statically linked application. In short, it consumes a configuration file and outputs `.deb` packages.
6+
7+
## Configuration file
8+
9+
Written in YAML and composed of a list of package blueprints. A blueprint is defined by the following:
10+
11+
12+
| Field | Meaning | Default |
13+
| ------------- | ---------------------------------------------------------------------------------------------- | ------------ |
14+
| `name` | Component name, e.g. `kustomize` | |
15+
| `version` | Application release to package | |
16+
| `arch` | Package architecture | `amd64` |
17+
| `revision` | Package revistion | `1` |
18+
| `summary` | Package short description | |
19+
| `description` | Package full description | `Null` |
20+
| `fetch` | A binary to download, and a `sha256` checksum. `tar.gz` archives are extracted automatically | |
21+
| `script` | A list of build instructions templated with jinja2 and intepreted with the default `shell` | |
22+
23+
Example:
24+
25+
```yaml
26+
- name: kubectl
27+
version: 1.20.1
28+
summary: Command line client for controlling a Kubernetes cluster
29+
description: |
30+
kubectl is a command line client for running commands against Kubernetes clusters.
31+
fetch:
32+
url: https://storage.googleapis.com/kubernetes-release/release/v{{version}}/bin/linux/amd64/kubectl
33+
sha256: 3f4b52a8072013e4cd34c9ea07e3c0c4e0350b227e00507fb1ae44a9adbf6785
34+
script:
35+
- mv kubectl {{src}}/usr/bin/
36+
```
37+
38+
## Dependencies
39+
40+
* Python >= 3.8
41+
* To build debian packages with `debops build` you need the following packages on your host:
42+
43+
```shell
44+
sudo apt install build-essential fakeroot devscripts
45+
```
46+
47+
## Usage example
48+
49+
Install `debops` in a virtualenv or with [pipx](https://github.com/pipxproject/pipx)
50+
51+
```shell
52+
pipx install debops
53+
```
54+
55+
Then, in a test directory run:
56+
57+
```shell
58+
curl https://raw.githubusercontent.com/upciti/debops/main/debops.yml
59+
debops generate
60+
debops build
61+
```
62+
63+
To check for new releases run:
64+
65+
```shell
66+
debops update
67+
```
68+
69+
`debops` uses temp directories to cache downloaded binaries and to run build instructions:
70+
71+
```shell
72+
tree /tmp/debops_*
73+
```
74+
75+
The cache can be flushed with:
76+
```shell
77+
debops purge
78+
```
79+
80+
## Development
81+
82+
You will need [poetry](https://python-poetry.org/)
83+
84+
```shell
85+
poetry install
86+
poetry run task check
87+
```
88+
89+
## Important notes
90+
91+
`debops` **DOES NOT** sandbox build instructions so if you do something like:
92+
93+
```shell
94+
script:
95+
- rm -rf ~/*
96+
```
97+
98+
You will loose your files... To make sure that you won't mess with your system, run it within a container.

debops.yml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
- name: kubectl
2+
version: 1.20.1
3+
summary: Command line client for controlling a Kubernetes cluster
4+
description: |
5+
kubectl is a command line client for running commands against Kubernetes clusters.
6+
fetch:
7+
url: https://storage.googleapis.com/kubernetes-release/release/v{{version}}/bin/linux/amd64/kubectl
8+
sha256: 3f4b52a8072013e4cd34c9ea07e3c0c4e0350b227e00507fb1ae44a9adbf6785
9+
script:
10+
- mv kubectl {{src}}/usr/bin/
11+
12+
- name: kustomize
13+
version: 3.8.8
14+
depends:
15+
- kubectl
16+
summary: Kubernetes native configuration management
17+
description: |
18+
kustomize lets you customize raw, template-free YAML files for multiple purposes,
19+
leaving the original YAML untouched and usable as is.
20+
kustomize targets kubernetes; it understands and can patch kubernetes style API objects.
21+
It's like make, in that what it does is declared in a file,
22+
and it's like sed, in that it emits edited text.
23+
fetch:
24+
url: https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/v{{version}}/kustomize_v{{version}}_linux_amd64.tar.gz
25+
sha256: 175938206f23956ec18dac3da0816ea5b5b485a8493a839da278faac82e3c303
26+
script:
27+
- mv kustomize {{src}}/usr/bin/
28+
29+
- name: helm
30+
version: 3.4.2
31+
depends:
32+
- kubectl
33+
summary: The Kubernetes package manager
34+
description: |
35+
Tool for managing Kubernetes charts.
36+
Charts are packages of pre-configured Kubernetes resources.
37+
fetch:
38+
url: https://get.helm.sh/helm-v{{version}}-linux-amd64.tar.gz
39+
sha256: cacde7768420dd41111a4630e047c231afa01f67e49cc0c6429563e024da4b98
40+
script:
41+
- mv linux-amd64/helm {{src}}/usr/bin/
42+
43+
- name: istioctl
44+
version: 1.6.13
45+
depends:
46+
- kubectl
47+
summary: Istio service mesh CLI
48+
description: Istio is an open platform to connect, manage, and secure microservices.
49+
fetch:
50+
url: https://github.com/istio/istio/releases/download/{{version}}/istio-{{version}}-linux-amd64.tar.gz
51+
sha256: 34ee63458f2cb65d8e0b9a2d67f386f13eb1c8c8456f72a02f389380d86bb2f4
52+
script:
53+
- install -d {{src}}/opt/istio
54+
- mv * {{src}}/opt/istio/
55+
- ln -s /opt/istio/istio-{{version}}/bin/istioctl {{src}}/usr/bin/istioctl
56+
57+
- name: kubeseal
58+
version: 0.13.1
59+
summary: Secret management solution for k8s
60+
description: Encrypt your Secret into a SealedSecret, which is safe to store - even to a public repository.
61+
fetch:
62+
url: https://github.com/bitnami-labs/sealed-secrets/releases/download/v{{version}}/kubeseal-linux-amd64
63+
sha256: e6f2f5a8c22124a055c1b6bdbee7936c5b92bc44105a92441d86595b22d71604
64+
script:
65+
- install -m 755 kubeseal-linux-amd64 {{src}}/usr/bin/kubeseal
66+
67+
- name: helmfile
68+
version: 0.135.0
69+
depends:
70+
- kubectl
71+
- helm
72+
summary: Deploy Kubernetes Helm Charts
73+
description: |
74+
Helmfile is a declarative spec for deploying helm charts. It lets you...
75+
- Keep a directory of chart value files and maintain changes in version control.
76+
- Apply CI/CD to configuration changes.
77+
- Periodically sync to avoid skew in environments.
78+
fetch:
79+
url: https://github.com/roboll/helmfile/releases/download/v{{version}}/helmfile_linux_amd64
80+
sha256: d8aaea6c07401f9e32bc09f8fb601458cbf2d5d8d196e4e06935358e76d46d05
81+
script:
82+
- install -m 755 helmfile_linux_amd64 {{src}}/usr/bin/helmfile

0 commit comments

Comments
 (0)