Skip to content

Commit

Permalink
Merge pull request #138 from user-cont/0.1.0-release
Browse files Browse the repository at this point in the history
0.1.0 release
  • Loading branch information
jpopelka authored May 30, 2018
2 parents a8cf9a7 + ef2f93b commit 23aae1f
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 166 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# 0.1.0

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.

# Features

* Validate a selected artifact against a ruleset.
* Artifacts can be container images, containers and dockerfiles.
* We provide a default ruleset we believe every container should satisfy.
* There is a ruleset to validate an artifact whether it complies to [Fedora Container Guidelines](https://fedoraproject.org/wiki/Container:Guidelines)
* Colin can list available rulesets and list checks in a ruleset.
* There is a python API available
* Colin can be integrated into your workflow easily - it can provide results in json format.
6 changes: 0 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
TEST_IMAGE_NAME := colin-test
TEST_IMAGE_LABELS_NAME := colin-labels
TEST_TARGET = ./tests/integration/
RESULTS := colin.json
RULESET := fedora
ARTIFACTS_DIR := ./artifacts

check: build-test-image build-labels-image test-in-container

Expand Down Expand Up @@ -53,9 +50,6 @@ rpm-in-mock-f27: srpm
rpm-in-mock-el7: srpm
mock --rebuild -r epel-7-x86_64 ./*.src.rpm

check-local:
ansible-playbook $(ANSIBLE_EXTRA_ARGS) -e ruleset=$(RULESET) -e subject=$(TEST_IMAGE_NAME) -e results=$(RESULTS) -e artifacts_dir=$(ARTIFACTS_DIR) ./local.yml -e setup=true

install: clean
pip install --user .

Expand Down
114 changes: 40 additions & 74 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,31 @@
![PyPI - Status](https://img.shields.io/pypi/status/colin.svg)
[![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)

Tool to check generic rules/best-practices for containers/images/dockerfiles.

Initial plan is to validate containers/images/dockerfiles against different ecosystems:
- Red Hat Container Catalogue
- Fedora Infrastructure (and [Fedora Container Guidelines](https://fedoraproject.org/wiki/Container:Guidelines))
- Project Atomic [Container Best Practices](http://docs.projectatomic.io/container-best-practices/)

*Colin* will also provide generic checks for maintainers or users of containerized content.
Tool to check generic rules and best-practices for containers, images and dockerfiles.

For more information, please check our [documentation on colin.readthedocs.io](https://colin.readthedocs.io/en/latest/).

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


# Features

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


## Installation


### Via `pip`

If you are on Fedora distribution, please install python3-pyxattr so you don't have to compile yourself when getting it from PyPI.
If you are on Fedora distribution, please install python3-pyxattr so you don't
have to compile it yourself when getting it from PyPI.

```bash
$ pip3 install --user colin
Expand Down Expand Up @@ -53,7 +58,7 @@ Options:
-h, --help Show this message and exit.
Commands:
check Check the image/container (default).
check Check the image/container/dockerfile...
list-checks Print the checks.
list-rulesets List available rulesets.
```
Expand All @@ -62,16 +67,18 @@ Commands:
$ colin check -h
Usage: colin check [OPTIONS] TARGET
Check the image/container (default).
Check the image/container/dockerfile (default).
Options:
-r, --ruleset TEXT Select a predefined ruleset (e.g. fedora).
-f, --ruleset-file FILENAME Path to a file to use for validation (by
default they are placed in /usr/share/colin).
default they are placed in
/usr/share/colin/rulesets).
--debug Enable debugging mode (debugging logs, full
tracebacks).
--json FILENAME File to save the output as json to.
-s, --stat Print statistics instead of full results.
-t, --tag TEXT Filter checks with the tag.
-v, --verbose Verbose mode.
-h, --help Show this message and exit.
```
Expand Down Expand Up @@ -113,33 +120,6 @@ FAIL:Label 'name' has to be specified.
...
```

### How to test a container image and Dockerfile with Colin locally

We provide a simple Ansible playbook which you can put inside your CI system and use colin in there. It installs and executes colin.

```bash
make check-local -e TEST_IMAGE_NAME=<image_name> -e ANSIBLE_EXTRA_ARGS=-vv -e RULESET=fedora -e ARTIFACTS_DIR=<directory_for_results> -e RESULTS=<result_file> -e setup=true
```

The makefile target above executes the playbook like this:

```bash
ansible-playbook $(ANSIBLE_EXTRA_ARGS) -e ruleset=$(RULESET) -e subject=$(TEST_IMAGE_NAME) -e results=$(RESULTS) -e artifacts_dir=$(ARTIFACTS_DIR) ./local.yml -e setup=true
```

Description of the parameters:
- `TEST_IMAGE_NAME` — name of the image to check.
- `ANSIBLE_EXTRA_ARGS` — extra arguments for `ansible-playbook` command.
- `RULESET` — name of ruleset to use. By default it's `fedora` ruleset.
- `ARTIFACTS_DIR` — directory where the results are stored. Ansible playbook creates it if needed. By default `./artifacts`.
- `RESULTS` — filename which is being used by `colin` for storing results. By default `colin.json`.

E.g. checking `fedora:27` image with ruleset `fedora` and stored results `colin.json` into directory `artifacts`:

```bash
make check-local -e TEST_IMAGE_NAME=fedora:27 -e RULESET=fedora -e ARTIFACTS_DIR=./artifacts
```


### Directly from git

Expand All @@ -148,46 +128,36 @@ It's possible to use colin directly from git:
```
$ git clone https://github.com/user-cont/colin.git
$ cd colin
$ python3 -m colin.cli.colin -h
Usage: colin [OPTIONS] COMMAND [ARGS]...
COLIN -- Container Linter
Options:
-V, --version Show the version and exit.
-h, --help Show this message and exit.
Commands:
check Check the image/container (default).
list-checks Print the checks.
list-rulesets List available rulesets.
```

We can now run the analysis:

```
$ python3 -m colin.cli.colin -f ./rulesets/fedora.json fedora:27
LABELS:
FAIL:Label 'maintainer' has to be specified.
PASS:Label 'name' has to be specified.
FAIL:Label 'architecture' has to be specified.
FAIL:Label 'build-date' has to be specified.
FAIL:Label 'description' has to be specified.
FAIL:Label 'distribution-scope' has to be specified.
FAIL:Label 'help' has to be specified.
FAIL:Label 'io.k8s.description' has to be specified.
FAIL:Label 'io.openshift.expose-services' has to be specified.
FAIL:Label 'io.openshift.tags' has to be specified.
FAIL:Label 'url' has to be specified.
FAIL:Label 'vcs-ref' has to be specified.
FAIL:Label 'vcs-type' has to be specified.
FAIL:Label 'vcs-url' has to be specified.
FAIL:Label 'com.redhat.component' has to be specified.
FAIL:Label 'maintainer' has to be specified.
FAIL:Label 'name' has to be specified.
FAIL:Label 'release' has to be specified.
FAIL:Label 'summary' has to be specified.
PASS:Label 'version' has to be specified.
FAIL:Label 'version' has to be specified.
FAIL:Cmd or Entrypoint has to be specified
ERROR:The 'helpfile' has to be provided.
FAIL:Service should not run as root by default.
FAIL:Label 'usage' has to be specified.
FAIL:Label 'release' has to be specified.
FAIL:Label 'architecture' has to be specified.
WARN:Label 'url' has to be specified.
WARN:Label 'help' has to be specified.
WARN:Label 'build-date' has to be specified.
WARN:Label 'distribution-scope' has to be specified.
WARN:Label 'vcs-ref' has to be specified.
WARN:Label 'vcs-type' has to be specified.
WARN:Label 'description' has to be specified.
WARN:Label 'io.k8s.description' has to be specified.
WARN:Label 'vcs-url' has to be specified.
WARN:Label 'maintainer' has to be specified.
WARN:Label 'io.openshift.expose-services' has to be specified.
...
FAIL:21 ERROR:1
```

### Exit codes
Expand All @@ -198,7 +168,3 @@ Colin can exit with several codes:
- `1` --> error in the execution
- `2` --> CLI error, wrong parameters
- `3` --> at least one check failed

## Technical details

![Scheme](./docs/scheme.png)
13 changes: 9 additions & 4 deletions colin.spec
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
%endif

Name: %{pypi_name}
Version: 0.0.4
Release: 3%{?dist}
Version: 0.1.0
Release: 1%{?dist}
Summary: Tool to check generic rules/best-practices for containers/images/dockerfiles

License: GPLv3+
Expand All @@ -28,8 +28,10 @@ Summary: %{summary}
%{?python_provide:%python_provide python3-%{pypi_name}}
BuildRequires: python3-devel
BuildRequires: python3-setuptools
Requires: docker
Recommends: atomic
Requires: python3-conu
Requires: python3-click
Requires: python3-six
Requires: python3-dockerfile-parse

%description -n python3-%{pypi_name}
`colin` as a tool to check generic rules/best-practices
Expand Down Expand Up @@ -76,6 +78,9 @@ rm -rf html/.{doctrees,buildinfo}
%doc html

%changelog
* Mon May 28 2018 Tomas Tomecek <[email protected]> - 0.1.0-1
- new upstream release: 0.1.0

* Wed May 02 2018 Petr Hracek <[email protected]> - 0.0.4-3
- Polishing texts and remove leftovers (#1572084)

Expand Down
2 changes: 1 addition & 1 deletion colin/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#

__version__ = "0.0.4"
__version__ = "0.1.0"
Binary file removed docs/scheme.png
Binary file not shown.
80 changes: 0 additions & 80 deletions local.yml

This file was deleted.

2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
version=version["__version__"],
description="Tool to check generic rules/best-practices for containers/images/dockerfiles.",
long_description=long_description,
long_description_content_type='text/markdown',
# long_description_content_type='text/markdown',
packages=find_packages(exclude=['examples', 'tests']),
install_requires=[
'Click',
Expand Down

0 comments on commit 23aae1f

Please sign in to comment.