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

colin的Python项目详细描述


科林

PyPIPyPI - LicensePyPI - Python VersionPyPI - StatusCodacy BadgeBuild Status

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

有关详细信息,请查看我们的documentation on colin.readthedocs.io

example

功能

  • 根据规则集验证选定的项目。
  • 工件可以是容器图像和dockerfile。
  • 我们提供了一个默认的规则集,我们相信每个容器映像都应该满足。
  • 有一个规则集来验证工件是否符合Fedora Container Guidelines
  • colin可以在规则集中列出可用的规则集和列表检查。
  • 有一个可用的python api
  • colin可以很容易地集成到您的工作流中,它可以提供json格式的结果。

安装

通过pip

如果您使用的是Fedora发行版,请安装python3 pyxattr,这样您就不会 当从pypi获得它时,必须自己编译它。

$ pip3 install --user colin

colin仅在python 3.6+上受支持。

关于Fedora分布

科林被打包在官方的Fedora存储库中:

$ dnf install -y colin

要求

  • 要检查image目标类型,必须安装podman。如果需要检查本地Docker图像,则需要在图像前面加上docker-daemon(例如colin check docker-daemon:docker.io/openshift/origin-web-console:v3.11)。

  • 如果要使用ostree目标,需要安装以下工具:

用法

$ 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, ostree). For ostree, please specify
                               image name and path like this: image@path
  --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
< H3>退出代码< EH3>

柯林可以用多个代码退出:

  • 0-->;确定
  • 1-->;执行中出错
  • 2-->;cli错误,错误参数
  • 3-->;至少有一个检查失败

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java Apache Flink外部Jar   创建和强制转换对象数组时发生java错误   Java,添加数组   具有相同包结构和类的java JAR   java Jenkins未能构建Maven项目   java为什么一个forloop比另一个更快,尽管它们做的“一样”?   servlets在将“/”站点迁移到Java EE包时处理contextpath引用   无法解析java MavReplugin:2.21或其某个依赖项   泛型如何编写比较器来泛化Java中的两种类型的对象?   java Android Emulator未在netbeans上加载   多线程Java使用线程对数组中的数字求和:在同步块中使用新变量作为锁:差异   java如何在JSP/servlet中设置<input>标记的值?