跳转到主要内容

检查容器/镜像/dockerfile的通用规则/最佳实践的工具。

项目描述

Colin

PyPI PyPI - License PyPI - Python Version PyPI - Status Codacy Badge Build Status

检查容器镜像和dockerfile的通用规则和最佳实践的工具。

有关更多信息,请参阅我们的colin.readthedocs.io文档

example

功能

  • 验证选定的工件是否与规则集兼容。
  • 工件可以是容器镜像和dockerfile。
  • 我们提供了一个默认的规则集,我们认为每个容器镜像都应该满足。
  • 有一个规则集来验证工件是否符合Fedora容器指南
  • Colin可以列出可用的规则集和列出规则集中的检查。
  • 有一个Python API可用
  • Colin可以轻松集成到您的流程中 - 它可以以json格式提供结果。

安装

通过pip

如果您在Fedora发行版上,请安装python3-pyxattr,这样您在从PyPI获取时就不需要自行编译。

$ pip3 install --user colin

colin只支持Python 3.6+。

Fedora发行版上

colin包含在官方Fedora仓库中

$ dnf install -y colin

需求

  • 为了检查image目标类型,您必须安装podman。如果您需要检查本地Docker镜像,您需要使用docker-daemon作为镜像的前缀(例如:colin check docker-daemon:docker.io/openshift/origin-web-console:v3.11)。

  • 如果您想使用oci目标,您需要安装以下工具

使用方法

$ colin --help
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/dockerfile (default).
  info           Show info about colin and its dependencies.
  list-checks    Print the checks.
  list-rulesets  List available rulesets.
$ colin check --help
Usage: colin check [OPTIONS] TARGET

  Check the image/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/rulesets).
  --debug                      Enable debugging mode (debugging logs, full
                               tracebacks).
  --json FILENAME              File to save the output as json to.
  --stat                       Print statistics instead of full results.
  -s, --skip TEXT              Name of the check to skip. (this option is
                               repeatable)
  -t, --tag TEXT               Filter checks with the tag.
  -v, --verbose                Verbose mode.
  --checks-path DIRECTORY      Path to directory containing checks (default
                               ['/home/flachman/.local/lib/python3.7/site-
                               packages/colin/checks']).
  --pull                       Pull the image from registry.
  --target-type TEXT           Type of selected target (one of image,
                               dockerfile, oci). For oci, please specify
                               image name and path like this: oci:path:image
  --timeout INTEGER            Timeout for each check in seconds.
                               (default=600)
  --insecure                   Pull from an insecure registry (HTTP or invalid
                               TLS).
  -h, --help                   Show this message and exit.

让我们试试看

$ colin -f ./rulesets/fedora.json registry.fedoraproject.org/f29/cockpit
PASS:Label 'architecture' has to be specified.
PASS:Label 'build-date' has to be specified.
FAIL:Label 'description' has to be specified.
PASS:Label 'distribution-scope' has to be specified.
:
:
PASS:10 FAIL:8

直接从git

您可以直接从git使用colin

$ git clone https://github.com/user-cont/colin.git
$ cd colin

现在我们可以运行分析

$ python3 -m colin.cli.colin -f ./rulesets/fedora.json registry.fedoraproject.org/f29/cockpit
PASS:Label 'architecture' has to be specified.
PASS:Label 'build-date' has to be specified.
FAIL:Label 'description' has to be specified.
PASS:Label 'distribution-scope' has to be specified.
:
:
PASS:10 FAIL:8

退出代码

Colin可以以几个代码退出

  • 0 --> 正常
  • 1 --> 执行错误
  • 2 --> CLI错误,参数错误
  • 3 --> 至少有一个检查失败

项目详情


下载文件

下载您平台的文件。如果您不确定选择哪个,请了解更多关于安装包的信息。

源代码分发

colin-0.5.3.tar.gz (604.4 kB 查看哈希值)

上传时间 源代码

构建分发

colin-0.5.3-py3-none-any.whl (78.1 kB 查看哈希值)

上传时间 Python 3

由以下机构支持

AWSAWS云计算和安全赞助商DatadogDatadog监控FastlyFastlyCDNGoogleGoogle下载分析MicrosoftMicrosoftPSF赞助商PingdomPingdom监控SentrySentry错误记录StatusPageStatusPage状态页