Skip to content

Commit e257107

Browse files
committed
feat: add support for repo team/collaborator permissions
Signed-off-by: Mário Santos <mario.rf.santos@gmail.com>
1 parent ee4e99d commit e257107

26 files changed

Lines changed: 1559 additions & 12 deletions

api/v1alpha1/applyconfiguration/api/v1alpha1/repositorycollaboratorpermission.go

Lines changed: 58 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1alpha1/applyconfiguration/api/v1alpha1/repositoryspec.go

Lines changed: 36 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1alpha1/applyconfiguration/api/v1alpha1/repositoryteampermission.go

Lines changed: 56 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1alpha1/applyconfiguration/api/v1alpha1/teamref.go

Lines changed: 43 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1alpha1/applyconfiguration/api/v1alpha1/teamspec.go

Lines changed: 0 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1alpha1/applyconfiguration/internal/internal.go

Lines changed: 40 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1alpha1/applyconfiguration/utils.go

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1alpha1/repository_types.go

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,20 @@ type RepositorySpec struct {
179179
// +kubebuilder:validation:Required
180180
OrganizationRef OrganizationRef `json:"organizationRef,omitempty"`
181181

182+
// Teams defines team permissions for this repository.
183+
// Each entry references an existing Team CRD via TeamRef and assigns it a specific permission level.
184+
// Teams not present in this list will have their explicit repository access removed.
185+
// See: https://docs.github.com/en/rest/teams/teams#add-or-update-team-repository-permissions
186+
Teams []RepositoryTeamPermission `json:"teams,omitempty"`
187+
188+
// Collaborators defines direct repository member (collaborator) permissions.
189+
// Each entry assigns a GitHub user a specific permission level.
190+
// Collaborators not present in this list will have their explicit repository access removed.
191+
// See: https://docs.github.com/en/rest/collaborators/collaborators#add-a-repository-collaborator
192+
// +listType=map
193+
// +listMapKey=username
194+
Collaborators []RepositoryCollaboratorPermission `json:"collaborators,omitempty"`
195+
182196
// RulesetPresetList references RulesetPreset CRDs to apply to this repository.
183197
// These define branch protection rules, required status checks, and other policies.
184198
// See: https://docs.github.com/en/rest/repos/rules
@@ -217,6 +231,45 @@ type CodeSecurityConfigurationRef struct {
217231
Name string `json:"name"`
218232
}
219233

234+
// RepositoryTeamPermission defines repository-level access for a GitHub team.
235+
type RepositoryTeamPermission struct {
236+
// TeamRef references the Team CRD that should be granted access to this repository.
237+
// +kubebuilder:validation:Required
238+
TeamRef TeamRef `json:"teamRef"`
239+
240+
// Permission is the access level granted to the team for this repository.
241+
// - "pull": Read-only access
242+
// - "triage": Manage issues and pull requests without write access
243+
// - "push": Read and write access
244+
// - "maintain": Manage repository settings except sensitive/destructive actions
245+
// - "admin": Full repository administrative access
246+
// +kubebuilder:validation:Enum=pull;triage;push;maintain;admin
247+
// +kubebuilder:default=pull
248+
Permission string `json:"permission,omitempty"`
249+
}
250+
251+
// RepositoryCollaboratorPermission defines repository-level access for a GitHub user.
252+
type RepositoryCollaboratorPermission struct {
253+
// Username is the GitHub username of the member.
254+
// Supports standard GitHub usernames and Enterprise Managed Users-style
255+
// usernames with an underscore suffix (for example: "name-surname_org").
256+
// +kubebuilder:validation:MinLength=1
257+
// +kubebuilder:validation:MaxLength=39
258+
// +kubebuilder:validation:Pattern=`^[a-zA-Z0-9](?:-?[a-zA-Z0-9])*(?:_[a-zA-Z0-9](?:-?[a-zA-Z0-9])*)?$`
259+
// +kubebuilder:validation:Required
260+
Username string `json:"username"`
261+
262+
// Permission is the access level granted to the member for this repository.
263+
// - "pull": Read-only access
264+
// - "triage": Manage issues and pull requests without write access
265+
// - "push": Read and write access
266+
// - "maintain": Manage repository settings except sensitive/destructive actions
267+
// - "admin": Full repository administrative access
268+
// +kubebuilder:validation:Enum=pull;triage;push;maintain;admin
269+
// +kubebuilder:default=pull
270+
Permission string `json:"permission,omitempty"`
271+
}
272+
220273
// MergeStrategy defines an allowed merge strategy for pull requests.
221274
// See: https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/configuring-pull-request-merges/about-merge-methods-on-github
222275
type MergeStrategy struct {

0 commit comments

Comments
 (0)