Skip to content

Commit e695202

Browse files
Reformat using pre-commit
Signed-off-by: Frantisek Lachman <[email protected]>
1 parent 2a27524 commit e695202

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+1280
-979
lines changed

Diff for: .bandit

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
[bandit]
22
skips: B101,B101,B311,B404,B603,B606,B607,C0103
33
exclude: /docs
4-

Diff for: CHANGELOG.md

+36-40
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,19 @@
22

33
## Features
44

5-
* Create a new check which makes sure that certain labels are overridden in
5+
- Create a new check which makes sure that certain labels are overridden in
66
layered images.
7-
* Certain remote API calls are now being retried - this should help in environments where network is unreliable.
7+
- Certain remote API calls are now being retried - this should help in environments where network is unreliable.
88

99
## Breaking changes
1010

11-
* Python 2 is now completely unsupported.
11+
- Python 2 is now completely unsupported.
1212

1313
## Minor
1414

15-
* A bunch of usability issues: when things go wrong, colin should not
15+
- A bunch of usability issues: when things go wrong, colin should not
1616
produce more helpful error messages and logs.
1717

18-
1918
# 0.3.1
2019

2120
## Fixes
@@ -26,72 +25,69 @@
2625

2726
## Breaking changes
2827

29-
* Remove support for Python 2.
30-
28+
- Remove support for Python 2.
3129

3230
# 0.3.0
3331

3432
## New Features
3533

36-
* You can configure timeout for checks now:
37-
* This can be done via CLI or add `timeout: <seconds>` to a check in a ruleset.
38-
* Default timeout is set to 10 minutes.
39-
* Checks can be skipped via CLI option `--skip`.
34+
- You can configure timeout for checks now:
35+
- This can be done via CLI or add `timeout: <seconds>` to a check in a ruleset.
36+
- Default timeout is set to 10 minutes.
37+
- Checks can be skipped via CLI option `--skip`.
4038

4139
## Breaking changes
4240

43-
* Colin searches a value in label now instead of matching it using a regex.
41+
- Colin searches a value in label now instead of matching it using a regex.
4442

4543
## Fixes
4644

47-
* Output a sensible error message when the check code cannot be found.
48-
* Handle the situation when the instruction FROM is missing in testing image tag.
49-
45+
- Output a sensible error message when the check code cannot be found.
46+
- Handle the situation when the instruction FROM is missing in testing image tag.
5047

5148
# 0.2.1
5249

5350
## New Features
5451

55-
* Allow setting CLI options via environment variables
56-
* Allow loading rulesets from virtualenv
57-
* Add info subcommand
52+
- Allow setting CLI options via environment variables
53+
- Allow loading rulesets from virtualenv
54+
- Add info subcommand
5855

5956
# 0.2.0
6057

6158
## Breaking changes
6259

63-
* switch from docker to podman, thanks to @lachmanfrantisek
64-
* remove `container` target type
65-
* new cli arg: target type (defaults to image -- for podman)
60+
- switch from docker to podman, thanks to @lachmanfrantisek
61+
- remove `container` target type
62+
- new cli arg: target type (defaults to image -- for podman)
6663

6764
## New Features
6865

69-
* add `ostree` target, thanks to @TomasTomecek
70-
* use fmf format in checks, thanks to @jscotka
71-
* allow rulesets in the YAML format, thanks to @SkullTech
66+
- add `ostree` target, thanks to @TomasTomecek
67+
- use fmf format in checks, thanks to @jscotka
68+
- allow rulesets in the YAML format, thanks to @SkullTech
7269

7370
## Fixes
7471

75-
* many code style fixes
76-
* use Centos CI, thanks to @jpopelka
77-
* better loading of the ruleset files (subdir -> user -> system), thanks to @SkullTech
78-
* check existence of json output file directory
79-
* simpler loading of checks
80-
* tinker CONTRIBUTING.md
81-
* do not mount whole FS when checking for files
82-
* improve tests quality
83-
72+
- many code style fixes
73+
- use Centos CI, thanks to @jpopelka
74+
- better loading of the ruleset files (subdir -> user -> system), thanks to @SkullTech
75+
- check existence of json output file directory
76+
- simpler loading of checks
77+
- tinker CONTRIBUTING.md
78+
- do not mount whole FS when checking for files
79+
- improve tests quality
8480

8581
# 0.1.0
8682

8783
Welcome to the first official release of colin. With `0.0.*` releases we tried to iterate on a minimal viable product and with this `0.1.0` release we believe it's finally here.
8884

8985
# Features
9086

91-
* Validate a selected artifact against a ruleset.
92-
* Artifacts can be container images, containers and dockerfiles.
93-
* We provide a default ruleset we believe every container should satisfy.
94-
* There is a ruleset to validate an artifact whether it complies to [Fedora Container Guidelines](https://fedoraproject.org/wiki/Container:Guidelines)
95-
* Colin can list available rulesets and list checks in a ruleset.
96-
* There is a python API available
97-
* Colin can be integrated into your workflow easily - it can provide results in json format.
87+
- Validate a selected artifact against a ruleset.
88+
- Artifacts can be container images, containers and dockerfiles.
89+
- We provide a default ruleset we believe every container should satisfy.
90+
- There is a ruleset to validate an artifact whether it complies to [Fedora Container Guidelines](https://fedoraproject.org/wiki/Container:Guidelines)
91+
- Colin can list available rulesets and list checks in a ruleset.
92+
- There is a python API available
93+
- Colin can be integrated into your workflow easily - it can provide results in json format.

Diff for: CONTRIBUTING.md

+34-23
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,19 @@ Use your best judgement, and feel free to propose changes to this document in a
88
By contributing to this project you agree to the Developer Certificate of Origin (DCO). This document is a simple statement that you, as a contributor, have the legal right to submit the contribution. See the [DCO](DCO) file for details.
99

1010
## Reporting Bugs
11+
1112
Before creating bug reports, please check a [list of known issues](https://github.com/user-cont/colin/issues) to see
1213
if the problem has already been reported (or fixed in a master branch).
1314

1415
If you're unable to find an open issue addressing the problem, [open a new one](https://github.com/user-cont/colin/issues/new).
1516
Be sure to include a **descriptive title and a clear description**. Ideally, please provide:
16-
* version of colin you are using (`rpm -q colin` or `pip3 freeze | grep colin`)
17-
* version of [conu](https://github.com/user-cont/conu) library (`rpm -q python3-conu` or `pip3 freeze | grep conu`)
18-
* version of [dockerfile-parse](https://github.com/DBuildService/dockerfile-parse) library (`rpm -q python3-dockerfile-parse` or `pip3 freeze | grep dockerfile-parse`)
19-
* version of container runtime you are using (`rpm -qa | grep docker`)
20-
* the command you executed, output and ideally please describe the image, container or dockerfile you are validating
21-
* invoke colin in debug mode (`--debug`)
17+
18+
- version of colin you are using (`rpm -q colin` or `pip3 freeze | grep colin`)
19+
- version of [conu](https://github.com/user-cont/conu) library (`rpm -q python3-conu` or `pip3 freeze | grep conu`)
20+
- version of [dockerfile-parse](https://github.com/DBuildService/dockerfile-parse) library (`rpm -q python3-dockerfile-parse` or `pip3 freeze | grep dockerfile-parse`)
21+
- version of container runtime you are using (`rpm -qa | grep docker`)
22+
- the command you executed, output and ideally please describe the image, container or dockerfile you are validating
23+
- invoke colin in debug mode (`--debug`)
2224

2325
If possible, add a **code sample** or an **executable test case** demonstrating the expected behavior that is not occurring.
2426

@@ -33,24 +35,27 @@ in as many details as possible.
3335

3436
## How to contribute code to colin
3537

36-
* Please make sure that your code complies with [PEP8](https://www.python.org/dev/peps/pep-0008/).
37-
* One line should not contain more than 100 characters.
38-
* Make sure that new code is covered by a test case (new or existing one).
39-
* We don't like [spaghetti code](https://en.wikipedia.org/wiki/Spaghetti_code).
40-
* The tests have to pass.
38+
- Please make sure that your code complies with [PEP8](https://www.python.org/dev/peps/pep-0008/).
39+
- One line should not contain more than 100 characters.
40+
- Make sure that new code is covered by a test case (new or existing one).
41+
- We don't like [spaghetti code](https://en.wikipedia.org/wiki/Spaghetti_code).
42+
- The tests have to pass.
4143

4244
# How to write the new check to colin
45+
4346
All checks are stored in the directory
4447
[checks](https://github.com/user-cont/colin/tree/master/colin/checks).
4548
[Loader](https://github.com/user-cont/colin/tree/master/colin/core/loader.py)
4649
obtains checks from there, and here's how:
47-
* classes which end with `AbstractCheck` are NOT loaded
48-
* only classes which with `Check` are loaded
49-
* the check class needs to be a child of a `AbstractCheck`
50+
51+
- classes which end with `AbstractCheck` are NOT loaded
52+
- only classes which with `Check` are loaded
53+
- the check class needs to be a child of a `AbstractCheck`
5054

5155
Here's a simple template how you can create a new check:
5256

5357
## Label check example
58+
5459
```python
5560
from colin.core.checks.labels import LabelAbstractCheck
5661

@@ -81,6 +86,7 @@ Let's go through the list of keyword arguments:
8186
- `required` — keyword specific to `LabelCheck` class. If the check fails and this is true, the check is marked as failed. If this is false and the check fails, it is a warning.
8287

8388
## File system check example
89+
8490
```python
8591
from colin.core.checks.filesystem import FileCheck
8692

@@ -100,12 +106,14 @@ class FooBarFileCheck(FileCheck):
100106
```
101107

102108
We only need to describe one argument here:
109+
103110
- `files` is specific to `FileSystemCheck` class and indicates on what files we want to operate on.
104111

105112
## Add the new check into a ruleset
113+
106114
Once code for your check is complete, here's how you can run it.
107115

108-
Create a new ruleset file with your locally created check(s):
116+
Create a new ruleset file with your locally created check(s):
109117

110118
```bash
111119
$ cat foobar.yaml
@@ -115,8 +123,9 @@ checks:
115123
- {name: foobar_file_required}
116124

117125
```
118-
__NOTE__: _Colin_ accepts `YAML` formatted ruleset files. As `JSON` is a subset of the `YAML` standard, `JSON` formatted
119-
rulesets are also supported, but `YAML` is recommended.
126+
127+
**NOTE**: _Colin_ accepts `YAML` formatted ruleset files. As `JSON` is a subset of the `YAML` standard, `JSON` formatted
128+
rulesets are also supported, but `YAML` is recommended.
120129

121130
Then run it with colin using command:
122131

@@ -127,6 +136,7 @@ $ python3 -m colin.cli.colin -f ./foobar.yaml <IMAGE-OR-DOCKERFILE>
127136
The command above implies that your check lives happily with other checks in this upstream repo. It's possible to have checks stored externally and point colin to them.
128137

129138
Let's move one of the checks mentioned above to `/tmp/external_checks/checks.py`:
139+
130140
```
131141
$ cat /tmp/external_checks/checks.py
132142
from colin.core.checks.filesystem import FileCheck
@@ -147,6 +157,7 @@ class FooBarFileCheck(FileCheck):
147157
```
148158

149159
This would be our simple ruleset:
160+
150161
```bash
151162
$ cat foobar.json
152163
{
@@ -158,6 +169,7 @@ $ cat foobar.json
158169
```
159170

160171
And we would just call colin and point it to the directory containing python files with checks:
172+
161173
```
162174
$ python3 -m colin.cli.colin -f ./foobar.json --checks-path /tmp/external_checks/ fedora:28
163175
10:43:38.165 loader.py DEBUG Getting check(s) from the file '/tmp/external_checks/checks.py'.
@@ -188,18 +200,17 @@ directory](https://github.com/user-cont/colin/tree/master/rulesets).
188200

189201
If your check is generic enough, it may make sense to add it to [default ruleset](https://github.com/user-cont/colin/blob/master/rulesets/default.json).
190202

191-
192203
## Changelog
193204

194205
When you are contributing to changelog, please follow these suggestions:
195206

196-
* The changelog is meant to be read by everyone. Imagine that an average user
207+
- The changelog is meant to be read by everyone. Imagine that an average user
197208
will read it and should understand the changes. `Add check timeouts` is
198209
completely undescriptive.
199-
* Every line should be a complete sentence. Either tell what is the change that the tool is doing or describe it precisely:
200-
* Bad: `Use search method in label regex`
201-
* Good: `Colin now uses search method when...`
202-
* And finally, with the changelogs we are essentially selling our projects:
210+
- Every line should be a complete sentence. Either tell what is the change that the tool is doing or describe it precisely:
211+
- Bad: `Use search method in label regex`
212+
- Good: `Colin now uses search method when...`
213+
- And finally, with the changelogs we are essentially selling our projects:
203214
think about a situation that you met someone at a conference and you are
204215
trying to convince the person to use the project and that the changelog
205216
should help with that.

Diff for: Makefile.docs

-1
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,3 @@ html:
3232
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
3333
@echo
3434
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
35-

Diff for: README.md

+13-15
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
![PyPI - License](https://img.shields.io/pypi/l/colin.svg)
55
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/colin.svg)
66
![PyPI - Status](https://img.shields.io/pypi/status/colin.svg)
7-
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/427eb0c5dfc040cea798b23575dba025)](https://www.codacy.com/app/user-cont/colin?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=user-cont/colin&amp;utm_campaign=Badge_Grade)
7+
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/427eb0c5dfc040cea798b23575dba025)](https://www.codacy.com/app/user-cont/colin?utm_source=github.com&utm_medium=referral&utm_content=user-cont/colin&utm_campaign=Badge_Grade)
88
[![Build Status](https://ci.centos.org/job/user-cont-colin-master/badge/icon)](https://ci.centos.org/job/user-cont-colin-master/)
99

1010
Tool to check generic rules and best-practices for container images and dockerfiles.
@@ -13,21 +13,18 @@ For more information, please check our [documentation on colin.readthedocs.io](h
1313

1414
![example](./docs/example.gif)
1515

16-
1716
# Features
1817

19-
* Validate a selected artifact against a ruleset.
20-
* Artifacts can be container images and dockerfiles.
21-
* We provide a default ruleset we believe every container image should satisfy.
22-
* There is a ruleset to validate an artifact whether it complies to [Fedora Container Guidelines](https://fedoraproject.org/wiki/Container:Guidelines)
23-
* Colin can list available rulesets and list checks in a ruleset.
24-
* There is a python API available
25-
* Colin can be integrated into your workflow easily - it can provide results in json format.
26-
18+
- Validate a selected artifact against a ruleset.
19+
- Artifacts can be container images and dockerfiles.
20+
- We provide a default ruleset we believe every container image should satisfy.
21+
- There is a ruleset to validate an artifact whether it complies to [Fedora Container Guidelines](https://fedoraproject.org/wiki/Container:Guidelines)
22+
- Colin can list available rulesets and list checks in a ruleset.
23+
- There is a python API available
24+
- Colin can be integrated into your workflow easily - it can provide results in json format.
2725

2826
## Installation
2927

30-
3128
### Via `pip`
3229

3330
If you are on Fedora distribution, please install python3-pyxattr so you don't
@@ -42,6 +39,7 @@ $ pip3 install --user colin
4239
### On Fedora distribution
4340

4441
colin is packaged in official Fedora repositories:
42+
4543
```
4644
$ dnf install -y colin
4745
```
@@ -51,9 +49,9 @@ $ dnf install -y colin
5149
- For checking `image` target-type, you have to install [podman](https://github.com/containers/libpod/blob/master/docs/tutorials/podman_tutorial.md). If you need to check local docker images, you need to prefix your images with `docker-daemon` (e.g. `colin check docker-daemon:docker.io/openshift/origin-web-console:v3.11`).
5250

5351
- If you want to use `ostree` target, you need to install following tools:
54-
- [ostree](https://github.com/ostreedev/ostree)
55-
- [atomic](https://github.com/projectatomic/atomic#atomic-usrbinatomic)
56-
- [skopeo](https://github.com/containers/skopeo#skopeo-)
52+
- [ostree](https://github.com/ostreedev/ostree)
53+
- [atomic](https://github.com/projectatomic/atomic#atomic-usrbinatomic)
54+
- [skopeo](https://github.com/containers/skopeo#skopeo-)
5755

5856
## Usage
5957

@@ -108,6 +106,7 @@ Options:
108106
```
109107

110108
Let's give it a shot:
109+
111110
```
112111
$ colin -f ./rulesets/fedora.json registry.fedoraproject.org/f29/cockpit
113112
PASS:Label 'architecture' has to be specified.
@@ -119,7 +118,6 @@ PASS:Label 'distribution-scope' has to be specified.
119118
PASS:10 FAIL:8
120119
```
121120

122-
123121
### Directly from git
124122

125123
It's possible to use colin directly from git:

0 commit comments

Comments
 (0)