Package: updater
Version updater for components in your codebaseProblem to solveIn the project where there are many components to track new versions (docker
images and pypi packages) this tool automates finding new versions,
running tests and commit changes to git.TL;DRCreate YAML file with definition of your components (see example intests/test_files/components.yaml). Placecomponents.yamlin the
root of your project directory and run:>>>python-mupdatercheck10componentstocheck1componentstoupdate>>>python-mupdatercheck--verbose10componentstocheck1componentstoupdatepymongo-current:3.12.1next:3.12.2This will check versions for all components defined incomponents2.yaml:>>>python-mupdater--file=/path/to/your/components2.yamlcheck10componentstocheck1componentstoupdateHere is an example of update script which will do checking and print out updated config file without making any changes in your files:>>>python-mupdater--dry-run--printupdateHere is full example of using update command:>>>python-mupdaterupdate--git-commit--test-command="make test"It will, for each defined component incomponents.yamlfrom the local directory:Check if there are new versions of your components availableReplace in all files version numbers to the newest oneRun testsAdd and commit changes to gitInstallationInstall via pypi packages repository:>>>python-mpipinstallupdaterYAML Config file formatExample of components definition:# name of the component
python:
   # docker-image or pypi
   component-type: docker-image
   # this version tak needs to aligned with versions in files
   # if you put "latest" then check and update will be skipped for this component
   current-version: 3.6.6-alpine3.8
   # for docker-image component-type only
   docker-repo: library
   # filter used to get all possible versions
   filter: /^\d+\.\d+\.\d+-alpine\d+\.\d+$/
   # files in which version number should be replaced
   files: [locust/Dockerfile, locust/some_script.sh]
   # this is the find (current version) and replace (new version) pattern.
   # {version} and {component} can be used
   version-pattern: "PYTHON_VERSION {version}"
   # if there are different patterns in particular files, you can specify them here
   # file level pattern overrides component level pattern
   files-version-pattern:
      - file: locust/Dockerfile
         pattern: PYTHON_VERSION={version}
      - file: locust/some_script.sh
         pattern: version {version}
Django:
   component-type: pypi
   current-version: 2.2.24
   filter: /^\d+\.\d+(\.\d+)?$/
   files: [app/requirements.txt]
logspout:
   component-type: docker-image
   current-version: v3.1
   docker-repo: gliderlabs
   filter: /^v\d+\.\d+\.\d+$/
   # if there is prefix before numeric part of version, you can specify it here
   prefix: v
   files: [logspout/Dockerfile-logspout]
   # put here versions which should be skipped
   exclude-versions: [v3.2.6]Import python packages to components.yamlIf you want to “copy” python packages to components.yaml from requirements.txt, pipfile (pipenv)
or Poetry (project.toml) you need useimport-reqcommand with--sourceset to one ofrequirements,pipfileorpoetry. In each cases the--requirements-fileparam needs to point at
requirements.txt like file but will set properversion-patternandfiles.Usageupdaterupdater [OPTIONS] COMMAND [ARGS]...Options--versionShow the version and exit.--fileYAML file with components configuration. If not present other options for ‘check’ command are required.--destination-file <destination_file>If this option is given components configuration with new versions will be written here.--dry-runIf set no changes to any files are written.--printConfig is printed to stdout at the end.checkCheck if new versions of ddefined components are available.updater check [OPTIONS]Options--type <component_type>Component type: docker-image or pypi package.Optionsdocker-image|pypi--componentA component name for which the version should be verified.--repo_name <repo_name>A repository name if component is a docker image.--version_tag <version_tag>Version tag eg. v2.3.0 against which new version check will be run.--verbosePrint detailed info for each component about new version avaialble.--clear-cacheClear all the cached responses about versions in rpositories.--ignore-default-fileIgnore components.yaml file in local directory if exists.import-reqImports python packages from requirements.txt file.updater import-req [OPTIONS]Options--sourceSource of the requirement.txt file.  [required]Optionsrequirements|pipfile|poetry--requirements-file <requirements_file>Requirements.txt file from which packages and versions will be added to components.yaml file.  [required]updateUpdate files, run test and commit changes.updater update [OPTIONS]Options--test-command <test_command>Command that should be run after updating each component.--test-dir <test_dir>If test-command param is given, this will be the context dir to run it.--git-commitWhen set after each components update, git commit is performed in active branch.--project-dir <project_dir>If given, then it will be treated as a root dir for paths in config file.-v(, --verbosePrint at the end detailed info for each component about update process.-vv(, --very-verbosePrint at the end detailed info for each component about update process.