Skip to content
This repository has been archived by the owner on Jul 15, 2024. It is now read-only.

Add support for generating based on scraping the Github API. #209

Merged
merged 23 commits into from
May 10, 2021

Conversation

coderanger
Copy link
Contributor

@coderanger coderanger commented Apr 23, 2021

Includes general support for repo hosts and a specific implementation for Github.

I'm not sold on the naming of "repo host" but I couldn't think of anything better to cover future expansion to GitLab, Bitbucket, etc.

Closes #216

Includes general support for repo hosts and a specific implementation for Github.
@CLAassistant
Copy link

CLAassistant commented Apr 23, 2021

CLA assistant check
All committers have signed the CLA.

@coderanger
Copy link
Contributor Author

An example YAML:

apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
  name: testing
  namespace: default
spec:
  generators:
  - repoHost:
      github:
        organization: myorg
        tokenRef:
          name: github-token
          key: token
      filters:
      - repositoryMatch: ^service-.*
        pathExists: kubernetes/kustomization.yaml
  template:
    metadata:
      name: '{{ repository }}'
    spec:
      source:
        repoURL: '{{ url }}'
        targetRevision: '{{ branch }}'
        path: kubernetes/
      project: default
      destination:
        server: https://kubernetes.default.svc
        namespace: default

@jgwest jgwest changed the title ✨ Add support for generating based on scraping the Github API. Add support for generating based on scraping the Github API. Apr 23, 2021
@jgwest jgwest self-requested a review April 23, 2021 12:04
Copy link
Contributor

@OmerKahani OmerKahani left a comment

Choose a reason for hiding this comment

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

Can you please also add docs, an example, and E2E tests?

Very nice generator and use case!

pkg/generators/repo_host.go Outdated Show resolved Hide resolved
pkg/generators/repo_host_test.go Outdated Show resolved Hide resolved
@OmerKahani
Copy link
Contributor

@coderanger try to rebase / merge master, #207 should have fixed the problem in "Verify generated manifests"

@coderanger
Copy link
Contributor Author

A question raised from a friend: should this support discovering branches as well as repos. Right now its hardwired to only consider the default branch of a repo. Seems like a thing that could be added in the future, another filter and a flag for allBranches: true or something.

Copy link
Member

@jgwest jgwest left a comment

Choose a reason for hiding this comment

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

Really nice PR @coderanger , thanks for contributing this! I've got some suggestions around name changes, and some doc/comment tweaks below, but nothing major... let me know what you think 😄 .

api/v1alpha1/applicationset_types.go Outdated Show resolved Hide resolved
api/v1alpha1/applicationset_types.go Outdated Show resolved Hide resolved
pkg/generators/repo_host.go Outdated Show resolved Hide resolved
api/v1alpha1/applicationset_types.go Outdated Show resolved Hide resolved
docs/Generators.md Outdated Show resolved Hide resolved
docs/Generators.md Outdated Show resolved Hide resolved
docs/Generators.md Show resolved Hide resolved
docs/Generators.md Show resolved Hide resolved
pkg/services/repo_host/github.go Outdated Show resolved Hide resolved
docs/Generators.md Show resolved Hide resolved
…ode for GitHub, and configurable clone protocol.

The first two combined allow generating deployment projects for new branches automatically. The last allows using HTTPS clone URLs if needed for token authentication.
@coderanger
Copy link
Contributor Author

Updated those three todos so they now all exist and work :)

Because no human can truly grok go.sum.
@coderanger
Copy link
Contributor Author

Okay, I renamed everything to "SCM provider" as the overall subsystem name and reworked the multi-filter behavior to be simpler (the OR/AND approach discussed above).

@jgwest
Copy link
Member

jgwest commented May 7, 2021

@coderanger - FYI if you see an E2E test failure in the PR check, it's not anything wrong with your code, it's this: #227 (I'm working on a fix).

Copy link
Member

@jgwest jgwest left a comment

Choose a reason for hiding this comment

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

Looking great, one tweak to the example and good to go (unless you had anything else you wanted to add)

@coderanger
Copy link
Contributor Author

I think that's everything I can think of to add to start with :) I'm sure when folks with other use cases get their hands on it, there will be more options and filters that we can ponder but I think this covers the bulk of it.

Copy link
Member

@jgwest jgwest left a comment

Choose a reason for hiding this comment

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

Really nice, thanks for working on this! It adds a powerful new tool into the ApplicationSet tool belt, and should really enable folks doing GitOps over multiple repositories in an organization to best automate that using ApplicationSets 🎉.

@jgwest jgwest merged commit 1b57a9c into argoproj:master May 10, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for generator based on scraping the Github API
4 participants