Skip to content

Adding and Enabling Github Topics#40

Merged
iul1an merged 3 commits intoprovider-github:mainfrom
emeentag:feature/adding-gh-topics
Nov 4, 2025
Merged

Adding and Enabling Github Topics#40
iul1an merged 3 commits intoprovider-github:mainfrom
emeentag:feature/adding-gh-topics

Conversation

@emeentag
Copy link
Copy Markdown
Contributor

@emeentag emeentag commented Nov 4, 2025

Changes Implemented

1. API Types Updated (apis/organizations/v1alpha1/repository_types.go)

  • Added Topics field to RepositoryParameters with proper validation:
    • Maximum 20 topics (as per GitHub requirements)
    • Array of strings
    • Optional field

2. Controller Logic Updated (internal/controller/repository/repository.go)

  • Observe function: Added logic to compare desired topics with actual GitHub topics
  • Create function: Added logic to set topics when creating new repositories
  • Update function: Added logic to update topics when they change

3. Client Interface Updated (internal/clients/client.go)

  • Added ReplaceAllTopics method to the RepositoriesClient interface

4. Mock Client Updated (internal/clients/fake/client.go)

  • Added MockReplaceAllTopics field and implementation method to support testing

5. Example Updated (examples/organizations/repository.yaml)

  • Added example topics to the sample repository:
    topics:
      - crossplane
      - github
      - infrastructure-as-code

6. CRDs Regenerated (package/crds/organizations.github.crossplane.io_repositories.yaml)

  • The CRD now includes the topics field with proper OpenAPI schema validation

Usage

Users can now add topics to their repositories like this:

apiVersion: organizations.github.crossplane.io/v1alpha1
kind: Repository
metadata:
  name: my-repo
spec:
  forProvider:
    description: My awesome repository
    org: my-org
    topics:
      - kubernetes
      - crossplane
      - gitops

Features

  • Topics are automatically synchronized with GitHub
  • Maximum 20 topics per repository (enforced by Kubernetes validation)
  • Topics are sorted for consistent comparison
  • Empty topics list will remove all topics from the repository
  • Topics work with all repository types (normal, fork, template)

Fixes #

I have:

  • Read and followed Crossplane's contribution process.
  • Run make reviewable to ensure this PR is ready for review.
  • [] Added backport release-x.y labels to auto-backport this PR if necessary.

How has this code been tested

  • Created a sample repo.
  • Applied some topic.
  • Remove topic.
  • Add duplicate topic.
  • Try to add more topic than 20.
  • Test with empty topic list.

@iul1an iul1an self-assigned this Nov 4, 2025
@iul1an
Copy link
Copy Markdown
Collaborator

iul1an commented Nov 4, 2025

Thank you for the contribution @emeentag 🚀

@iul1an iul1an merged commit 16d44b3 into provider-github:main Nov 4, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants