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 design document for multiples-url-to-the-same-repo feature #1644

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions docs/content/dev/design/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
title: Design Proposals
weight: 3
---
# Pipelines-as-Code Design proposals

{{<section>}}
105 changes: 105 additions & 0 deletions docs/content/dev/design/multiple-url-to-same-repo.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
---
title: Matching multiple URLs to the same Repository CR
weight: 1
---

# Matching multiple URLs to the same Repository CR

## Background

The current implementation of the Repository CR allows specifying a single URL
for the repository. This is limiting in cases where the repository is mirrored
to multiple URLs. This document proposes a way to allow specifying multiple URLs
Copy link
Contributor

Choose a reason for hiding this comment

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

creating one CR for each repo?
is this a lot of work for this use case? or sharing the settings? across repos?

Copy link
Member Author

Choose a reason for hiding this comment

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

I listed this in the alternatives sections that we could potentially reuse the configmap features of that setting you implemented sometime ago and extend it, but that's an admin thing that doesn't allow much flexibility...

sharing setting is an interesting idea,having a configmap reference that would embed the value..

Copy link
Contributor

Choose a reason for hiding this comment

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

I think allowing multiple repo url could be a nice thing but if we allow regex then it might become quite complex as you have defined in scenarios
handling cases with multiple repos, what if a repo is edited and all

if the requirement for this design is to somehow share settings across repos then we could find someother way πŸ€”

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think there is flow in the scenarios i have listed, it's just a matter to have the webhook check if the new value (on update or creation) matches already and fail otherwise? is there more complexities to it do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah webhook can handle that.

wdym by multiples-url-to-the-same-repo?

if we go with regex https://github.com/foo/.*
how it could be same repo?
differen repos can also be in this case right πŸ€”

for the same repository.

## Goal

The goal is to allows specifying multiple URLs for the same repository in the
same namespace. All settings for all repositories are inside a single Repository
CR.

## Non Goals

- Allowing multiple URLs for the same repository in different namespaces.

## Proposal

- Extend the Repository CR to allow specifying a regexp for the URL.
- Extend the Repository CR to allow specifying a non-matching regexp.
- Extend the Pipelines-as-Code webhook to ensure that no other Repo CR
configuration match the newly or updated Repository CR.

```yaml
spec:
url: https://github.com/foo/.*
non-url: https://github.com/foo/hello-*
```

This will match all repositories in the `foo` organization except the one
starting with `hello-*`

- Repository status will have a new field `url` that will show the
matched URL.

## Discussion

The full security model of Pipelines-as-Code is based on the assumption that the
first one wins. Since we don't have a way (or we decided not to for the
sake of making it simple) to know who is the real owner of a GitHub (or
others) repository, we assume that the first one that creates the Repository
is the owner of the repository. It is up to the cluster administrator to make
sure which team that has access to a namespace have the proper Repository CR
matching the GitHub Repository.

If we start letting people making a regexp for the URL, we need to make sure
they are not able to hijack other repositories.

Example scenario:

- User A creates a Repository CR with a regexp for the URL that matches
all repositories in the organization.
- User B creates another Repository CR with a regexp for the URL that as well
matches all repositories in the organization with a different syntax (regexp
have many ways to express the same thing).

The webhook will need to make sure that when User B create that Repository CR to
deny it since User A had already have a match for it. It is up to the
Users/Teams to communicate to have the regexps works (using `non-url` setting
for example) for some repositories and not the others.

Second scenario:

- User A has created a Repository CR matching URL: <https://github.com/org/repos>
- User B has a Repository CR matching URL: <https://github.com/org/otherrepos>
- User A decide to update their Repo CR with: <https://github.com/org/.*>

The webhook will deny User A since we have a repository CR in user B already
matching the new update.

## CLI

- [ ] The CLI will probably not need to handle such advanced use case, this is up to
the user to directly edit the `Repository` CR Yaml.

## UI

- OpenShift Console will need to be updated I believe to be able to show a status for multiple URL match (TBC)

## Tekton Results

- TBD

## Alternatives

We could extend the global `ConfigMap` setting `auto-configure-new-github-repo` to
only allows a certain regexps and have a `Repository` template.

The problem with this is that:

- It is specific to GitHub
- The settings is admin level.
- The Repository CR are not allowed to be customized by the user.
- The regexps may need to be adjusted and it will only works for a specific
scenario.

The advantages is that UI and tools would not need to be adjusted.