opal icon indicating copy to clipboard operation
opal copied to clipboard

Track git tags

Open philipclaesson opened this issue 1 year ago • 4 comments

This change was discussed on slack and @orweis said a contribution adding tracking of git tags could be considered.

Changes proposed

Why tracking git tags instead of branch

In a way this could be considered "against" how git is supposed to be used - some say tags should be immutable. However, mutable tags are defacto sometimes used, the most clear example being using a "latest" tag or a "v1-latest" tag.

Using tags this way could let you use a policy repo with a single base branch, while still giving control of what is rolled out in each env. Consider the traditional dev/prod setup:

  • the dev instance of OPAL is tracking the base branch (ex. master)
  • the prodinstance of OPAL is tracking a prod tag which can be moved at will once the changes in dev/master is tested properly.

This current way of doing this is to have multiple long lived branches in the same repo - this can be cumbersome and lead to a bunch of manual merging of branches.

Changes

  • Add env variable POLICY_REPO_TAG and cli arg --policy-repo-tag, defaulting to None. When used, OPAL will track the tag.

POLICY_REPO_TAG and POLICY_REPO_MAIN_BRANCH

The two variables are obviously dependent on eachother. My idea was to not break default behaviour.

POLICY_REPO_TAG POLICY_REPO_MAIN_BRANCH Behaviour
Empty Empty OPAL tracks the master branch
Empty Not Empty OPAL tracks the given branch
Not Empty Empty OPAL tracks the given tag
Not Empty Not Empty OPAL fails (cannot decide what to track)

Check List (Check all the applicable boxes)

  • [x] I sign off on contributing this submission to open-source
  • [x] My code follows the code style of this project.
  • [x] My change requires changes to the documentation.
  • [x] I have updated the documentation accordingly.
  • [x] All new and existing tests passed.
  • [x] This PR does not contain plagiarized content.
  • [x] The title of my pull request is a short description of the requested changes.

Note to reviewers

  • Some of tests are a bit flaky on my local machine - but all relevant and new tests should pass
  • I have updated documentation where applicable (I think) - let me know if I've missed anywhere
  • This PR only affects polling a git repo - not via webhooks. I am not sure whether you think webhooks + tag is a strong use case. If you want, I can look into that use case as well.

philipclaesson avatar Nov 17 '23 15:11 philipclaesson

Deploy Preview for opal-docs canceled.

Name Link
Latest commit 279415462e6830480320b85b54e2af379ac3bcfa
Latest deploy log https://app.netlify.com/sites/opal-docs/deploys/655797783f2c7b0007a4a1dc

netlify[bot] avatar Nov 17 '23 15:11 netlify[bot]

This is great 💜, I think we can review it early /.mid next week.

@philipclaesson please note that tests and formatting checks are already alerting issues we'll have to fix before this can be merged.

orweis avatar Nov 17 '23 15:11 orweis

Thanks @orweis! Formatting fixed now which made tests pass. I might add one or two test cases next week.

philipclaesson avatar Nov 17 '23 16:11 philipclaesson

Hi @philipclaesson @orweis - Where those that PR stand? What changes are still pending? Adding it to scopes as well? LMK if and how I can help with the remaining work.

For now moving this to draft

roekatz avatar Apr 30 '24 13:04 roekatz