Giter Club home page Giter Club logo

container-build-checks's Introduction

openSUSE Container Build Checks Hopefully green test status

This tool checks that built container images conform to the openSUSE container image policies (https://en.opensuse.org/Building_derived_containers).

It is designed to run at the end of image builds inside OBS, where it will look at all built images (both KIWI and DOCKER types) and fail the build if fatal issues were found. make install copies it to the directory where OBS expects it (openSUSE/obs-build#675).

As input, it reads .containerinfo files generated by OBS, which contain information like the disturl, chosen tags and the name of the tarball in docker save format (other container tools are available). The latter contains manifest.json, the image config and layers.

To run it against built containers outside of OBS, it's necessary to craft a .containerinfo file containing the needed metainfo yourself, e.g.:

{
   "disturl" : "obs://build.opensuse.org/home:favogt:container-checks/containerfile/e6f02b3d61214e205f11d1c2075b14cc-dockerfile-application-container",
   "file" : "proper-derived.tar",
   "release" : "7.21",
   "tags" : [
      "opensuse/example:latest",
      "opensuse/example:5.7",
      "opensuse/example:5.7.7.21"
   ]
}

When called outside of OBS, it looks at all *.containerinfo files in the current directory.

Configuration

Configuration files are in ini-format. All *.conf files in the configuration directory are read in alphabetical order. By default it looks for files in /usr/share/container-build-checks/, but the CBC_CONFIG_DIR environment variable can be used to override the path.

Available configuration options and their default values are:

[General]
# If true, treat all warnings as fatal. Errors are always fatal.
FatalWarnings=false
# If set, verify that the image-specific label prefix starts with this
Vendor=
# If set, verify that the org.opensuse.reference value uses this as registry
Registry=

[Tags]
# All tags have to match one of the patterns, e.g. opensuse/*,kubic/*
Allowed+=
# Tags must not match any of the patterns in here.
Blocked+=

Testing

To build and run tests, run make test (parallel jobs are fine). If there are differences to the expected output, the diff will be shown and the test run fails.

Each subdirectory in tests/ contains a Dockerfile used to build the tarball, a suitable .containerinfo with the metainformation and a checks.out file. The latter contains the expected output and exit status of running container-build-checks.py against that image.

Whenever the Dockerfile changes (tracked by the built stamp file), the image is rebuilt and the tarball updated. The image is tagged as c-b-c-tests/<dirname> and can be used as base image by other tests.

To update the checks.out files for all tests, run make test-regen.

make lint invokes flake8 to perform linting on the source code.

Creating test cases

To create a new test case, create a subdirectory in tests/ and create or copy suitable Dockerfile and *.containerinfo files.

LABEL statements can be created from an existing image by running:

podman image inspect foo | jq '.[0]["Config"]["Labels"]' | sed 's/": /=/g;s/^ "/LABEL /g;s/,$//g'

Run make test (or just make tests/foo/tested) to see the output and make test-regen (or just make tests/foo/regen) to save it as checks.out.

Editing in Gitpod

You can apply your edits directly from within your browser on Gitpod.

container-build-checks's People

Contributors

dcermak avatar dirkmueller avatar vogtinator avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.