Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to override/merge items in local .DEREK.yml #140

Merged
merged 1 commit into from
Mar 9, 2020

Conversation

Waterdrips
Copy link
Contributor

Description

We can now provide some local overrides from our Local DEREK.yml,
these overrides are then merged with the remote DEREK.yaml.
This allows us to add specific users to specific repos, or add
features for specific ones too. Any slices are merged and the
single values are overridden by the local values.

Signed-off-by: Alistair Hey alistair@heyal.co.uk

Motivation and Context

How Has This Been Tested?

Unit tests written, and this was tested on github using this repo: https://github.com/Waterdrips/heyal-ofc-customers

I setup a .DEREK.yml that had me as a contributor and a load of general config, but no "features"
pointed the Redirect at .DEREK-OVERRIDE.yml in the same repo, which added @alexellis as a contributor, plus it had the features listed.

Then I created a non signed commit and PR, DCO check was done (features in redirect file)
I was able to use the derek commands (local file)

And Alex was able to use Derek commands (set in redirect file)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I've read the CONTRIBUTION guide
  • I have signed-off my commits with git commit -s
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Copy link
Owner

@alexellis alexellis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good so far. I think we need to add an abuse-prevention technique for cyclic redirects or redirects which are too deep.

@Waterdrips
Copy link
Contributor Author

Looks good so far. I think we need to add an abuse-prevention technique for cyclic redirects or redirects which are too deep.

Currently it only follows the local file's redirect url (only goes 1 layer deep)
We could add the ability to follow redirects, adding a max depth?

We can now provide some local overrides from our Local DEREK.yml,
these overrides are then merged with the remote DEREK.yaml.
This allows us to add specific users to specific repos, or add
features for specific ones too. Any slices are merged and the
single values are overridden by the local values.

Signed-off-by: Alistair Hey <alistair@heyal.co.uk>
@alexellis alexellis changed the title Add ability to overide/merge items in local .DEREK.yml Add ability to override/merge items in local .DEREK.yml Feb 5, 2020
@Waterdrips Waterdrips requested a review from alexellis February 5, 2020 17:36

func MergeDerekRepoConfigs(localConfig, remoteConfig DerekRepoConfig) (DerekRepoConfig, error) {

mergeErr := mergo.Merge(&remoteConfig, &localConfig, mergo.WithAppendSlice)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we going to have the same issues we have with ofc-bootstrap? I saw some tests, do we need more?

Copy link
Owner

@alexellis alexellis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@alexellis alexellis merged commit 6086fa2 into alexellis:master Mar 9, 2020
@alexellis
Copy link
Owner

I suspect the messages list might break @Waterdrips, can you add some tests for union/intersection?

@Waterdrips
Copy link
Contributor Author

Good spot. Iv just written a failing test.

I'll get a pr in to sort that messages list soon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants