Helper Scripts to commit changes to OpenShift Api Objects to Git
This repository has been archived on 2026-05-06. You can view files and clone it, but you cannot make any changes to its state, such as pushing and creating new issues, pull requests or comments.
  • Shell 55.8%
  • Python 44.2%
Find a file
2018-04-29 18:18:40 +02:00
check-labels.sh added labels support 2018-02-13 14:06:16 +01:00
check-project.sh many bugfixed during practical testing 2018-01-24 16:39:25 +01:00
fixDockerUrls.py do not delete volume bindings anymore 2018-03-28 19:30:03 +02:00
install.sh make export/import of API objects project independent 2018-01-26 15:18:43 +01:00
oc-apply.sh use apply instead of create to also update existing service accounts 2018-01-30 14:45:41 +01:00
oc-edit.sh added labels support 2018-02-13 14:06:16 +01:00
oc-sync-git.sh added labels support 2018-02-13 14:06:16 +01:00
README.md test commit 2018-04-09 19:33:04 +02:00
README_oc2git.md renamed README-oc2git.md to README_oc2git.md with underline, such that it didn't was the preferred readme file on gitlab or github 2018-02-02 08:26:07 +01:00

Track OpenShift API Objects in Git

This repository delivers two shell scripts to you, that allow you to easily maintain your OpenShift API object in Git.

Installation

On most Linux systems, where /usr/local/bin is in your $PATH, just run

./install.sh

Otherwise you have to manually add symlinks of following files to your $PATH:

  • oc-sync-git -> oc-sync-git.sh
  • oc-edit -> oc-edit.sh
  • oc-apply -> oc-apply.sh

Usage

When using the default install script, three commands should be available to you system wide:

  • oc-sync-git will export all OpenShift API objects but secrets of your current active project to the api-objects.yaml file and create a git commit if changes occur
  • oc-edit will
    • first call oc-sync-git to gather all externally made changes
    • second open an editor for changing all your OpenShift API objects but secrets
    • finally call oc-sync-git again to commit your changes to Git
  • oc-apply will import the previously exported API objects to the current logged in OpenShift project again

To setup a new project you need to fullfill following prerequisites:

  • Having an OpenShift project meaningfully containing some API objects
  • Having the oc binary installed and beeing logged into the cluster and project
  • Beeing inside the (empty) git repository clone you want the API objects being committed to

Then you can call

  • oc-edit whenenver you want to edit the API objects and commit them to git
  • oc-sync-git whenever you have intentionally made changes to your OpenShift project 'from outside' and want to commit them to git

None of the scripts will do a git push. This you have to do explicitly!

Use the oc-apply to import the objects back to the current OpenShift project.

Using labels

The scripts oc-sync-git and oc-edit support labels. With labels you can commit just parts of your OpenShift project to the git repository. An example:

oc-sync-git app=myapplication

.