Skip to content

Commit 9f9b5e2

Browse files
author
Hunter-Thompson
committed
feat: global repo settings & invite user fixes
1 parent d1ae975 commit 9f9b5e2

21 files changed

Lines changed: 976 additions & 86 deletions

PROJECT

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,13 @@ resources:
3232
kind: InviteUser
3333
path: github.com/Hunter-Thompson/github-operator/apis/settings/v1beta1
3434
version: v1beta1
35+
- api:
36+
crdVersion: v1
37+
namespaced: true
38+
controller: true
39+
domain: github.com
40+
group: settings
41+
kind: GlobalRepository
42+
path: github.com/Hunter-Thompson/github-operator/apis/settings/v1beta1
43+
version: v1beta1
3544
version: "3"
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
/*
2+
Copyright 2023.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package v1beta1
18+
19+
import (
20+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21+
)
22+
23+
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
24+
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
25+
26+
// GlobalRepositorySpec defines the desired state of GlobalRepository
27+
type GlobalRepositorySpec struct {
28+
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
29+
// Important: Run "make" to regenerate code after modifying this file
30+
31+
// GitHub Org
32+
Organization string `json:"organization"`
33+
// A short description of the repository that will show up on GitHub
34+
Description *string `json:"description,omitempty"`
35+
// A URL with more information about the repository
36+
Homepage *string `json:"homepage,omitempty"`
37+
// A list of topics to set on the repository - can alternatively set like this: [github, probot, new-topic, another-topic, topic-12]
38+
Topics []string `json:"topics,omitempty"`
39+
// Either `true` to make the repository private, or `false` to make it public.
40+
Private *bool `json:"private,omitempty"`
41+
// Either `true` to enable issues for this repository, `false` to disable them.
42+
HasIssues *bool `json:"hasIssues,omitempty"`
43+
// Either `true` to enable pages for this repository, `false` to disable them.
44+
HasPages *bool `json:"hasPages,omitempty"`
45+
// Either `true` to enable projects for this repository, or `false` to disable them.
46+
HasProjects *bool `json:"hasProjects,omitempty"`
47+
// Either `true` to enable the wiki for this repository, `false` to disable it.
48+
HasWiki *bool `json:"hasWiki,omitempty"`
49+
// The default branch for this repository.
50+
DefaultBranch *string `json:"defaultBranch,omitempty"`
51+
// Either `true` to allow squash-merging pull requests, or `false` to prevent squash-merging.
52+
AllowSquashMerge *bool `json:"allowSquashMerge,omitempty"`
53+
// Either `true` to allow merging pull requests with a merge commit, or `false` to prevent merging pull requests with merge commits.
54+
AllowMergeCommit *bool `json:"allowMergeCommit,omitempty"`
55+
// Either `true` to allow merging pull requests with a merge commit, or `false` to prevent merging pull requests with merge commits.
56+
AllowRebaseMerge *bool `json:"allowRebaseMerge,omitempty"`
57+
// Either `true` to allow auto-merge on pull requests, or `false` to disallow auto-merge.
58+
AllowAutoMerge *bool `json:"allowAutoMerge,omitempty"`
59+
// Either `true` to allow automatically deleting head branches, when pull requests are merged, or `false` to prevent automatic deletion.
60+
DeleteBranchOnMerge *bool `json:"deleteBranchOnMerge,omitempty"`
61+
// Either `true` if its a template repo, false if its not
62+
IsTemplate *bool `json:"isTemplate,omitempty"`
63+
// Can be one of: PR_TITLE, COMMIT_OR_PR_TITLE
64+
SquashMergeCommitTitle *string `json:"squashMergeCommitTitle,omitempty"`
65+
// Can be one of: PR_BODY, COMMIT_MESSAGES, BLANK
66+
SquashMergeCommitMessage *string `json:"squashMergeCommitMessage,omitempty"`
67+
// Can be one of: PR_TITLE, MERGE_MESSAGE
68+
MergeCommitTitle *string `json:"mergeCommitTitle,omitempty"`
69+
// Can be one of: PR_BODY, PR_TITLE, BLANK
70+
MergeCommitMessage *string `json:"mergeCommitMessage,omitempty"`
71+
72+
RepositoryCollaborators *RepositoryCollaborators `json:"repositoryCollaborators,omitempty"`
73+
}
74+
75+
// GlobalRepositoryStatus defines the observed state of GlobalRepository
76+
type GlobalRepositoryStatus struct {
77+
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
78+
// Important: Run "make" to regenerate code after modifying this file
79+
}
80+
81+
//+kubebuilder:object:root=true
82+
//+kubebuilder:subresource:status
83+
84+
// GlobalRepository is the Schema for the globalrepositories API
85+
type GlobalRepository struct {
86+
metav1.TypeMeta `json:",inline"`
87+
metav1.ObjectMeta `json:"metadata,omitempty"`
88+
89+
Spec GlobalRepositorySpec `json:"spec,omitempty"`
90+
Status GlobalRepositoryStatus `json:"status,omitempty"`
91+
}
92+
93+
//+kubebuilder:object:root=true
94+
95+
// GlobalRepositoryList contains a list of GlobalRepository
96+
type GlobalRepositoryList struct {
97+
metav1.TypeMeta `json:",inline"`
98+
metav1.ListMeta `json:"metadata,omitempty"`
99+
Items []GlobalRepository `json:"items"`
100+
}
101+
102+
func init() {
103+
SchemeBuilder.Register(&GlobalRepository{}, &GlobalRepositoryList{})
104+
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
package v1beta1
2+
3+
func (gr *GlobalRepository) GetDescription() *string {
4+
return gr.Spec.Description
5+
}
6+
7+
func (gr *GlobalRepository) GetHomepage() *string {
8+
return gr.Spec.Homepage
9+
}
10+
11+
func (gr *GlobalRepository) GetTopics() []string {
12+
return gr.Spec.Topics
13+
}
14+
15+
func (gr *GlobalRepository) GetPrivate() *bool {
16+
return gr.Spec.Private
17+
}
18+
19+
func (gr *GlobalRepository) GetHasIssues() *bool {
20+
return gr.Spec.HasIssues
21+
}
22+
23+
func (gr *GlobalRepository) GetHasPages() *bool {
24+
return gr.Spec.HasPages
25+
}
26+
27+
func (gr *GlobalRepository) GetHasProjects() *bool {
28+
return gr.Spec.HasProjects
29+
}
30+
31+
func (gr *GlobalRepository) GetHasWiki() *bool {
32+
return gr.Spec.HasWiki
33+
}
34+
35+
func (gr *GlobalRepository) GetAllowSquashMerge() *bool {
36+
return gr.Spec.AllowSquashMerge
37+
}
38+
39+
func (gr *GlobalRepository) GetAllowMergeCommit() *bool {
40+
return gr.Spec.AllowMergeCommit
41+
}
42+
43+
func (gr *GlobalRepository) GetAllowRebaseMerge() *bool {
44+
return gr.Spec.AllowRebaseMerge
45+
}
46+
47+
func (gr *GlobalRepository) GetAllowAutoMerge() *bool {
48+
return gr.Spec.AllowAutoMerge
49+
}
50+
51+
func (gr *GlobalRepository) GetDeleteBranchOnMerge() *bool {
52+
return gr.Spec.DeleteBranchOnMerge
53+
}
54+
55+
func (gr *GlobalRepository) GetIsTemplate() *bool {
56+
return gr.Spec.IsTemplate
57+
}

apis/settings/v1beta1/repository_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ type RepositorySpec struct {
3535
// A URL with more information about the repository
3636
Homepage *string `json:"homepage,omitempty"`
3737
// A list of topics to set on the repository - can alternatively set like this: [github, probot, new-topic, another-topic, topic-12]
38-
Topics *[]string `json:"topics,omitempty"`
38+
Topics []string `json:"topics,omitempty"`
3939
// Either `true` to make the repository private, or `false` to make it public.
4040
Private *bool `json:"private,omitempty"`
4141
// Either `true` to enable issues for this repository, `false` to disable them.
Lines changed: 1 addition & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,103 +1,57 @@
11
package v1beta1
22

33
func (repo *Repository) GetDescription() *string {
4-
if repo.Spec.Description == nil {
5-
return new(string)
6-
}
74
return repo.Spec.Description
85
}
96

107
func (repo *Repository) GetHomepage() *string {
11-
if repo.Spec.Homepage == nil {
12-
return new(string)
13-
}
148
return repo.Spec.Homepage
159
}
1610

1711
func (repo *Repository) GetTopics() []string {
18-
if repo.Spec.Topics == nil {
19-
return []string{}
20-
}
21-
return *repo.Spec.Topics
12+
return repo.Spec.Topics
2213
}
2314

2415
func (repo *Repository) GetPrivate() *bool {
25-
if repo.Spec.Private == nil {
26-
return boolPointer(true)
27-
}
2816
return repo.Spec.Private
2917
}
3018

3119
func (repo *Repository) GetHasIssues() *bool {
32-
if repo.Spec.HasIssues == nil {
33-
return boolPointer(true)
34-
}
3520
return repo.Spec.HasIssues
3621
}
3722

3823
func (repo *Repository) GetHasPages() *bool {
39-
if repo.Spec.HasPages == nil {
40-
return boolPointer(true)
41-
}
4224
return repo.Spec.HasPages
4325
}
4426

4527
func (repo *Repository) GetHasProjects() *bool {
46-
if repo.Spec.HasProjects == nil {
47-
return boolPointer(true)
48-
}
4928
return repo.Spec.HasProjects
5029
}
5130

5231
func (repo *Repository) GetHasWiki() *bool {
53-
if repo.Spec.HasWiki == nil {
54-
return boolPointer(true)
55-
}
5632
return repo.Spec.HasWiki
5733
}
5834

5935
func (repo *Repository) GetAllowSquashMerge() *bool {
60-
if repo.Spec.AllowSquashMerge == nil {
61-
return boolPointer(true)
62-
}
6336
return repo.Spec.AllowSquashMerge
6437
}
6538

6639
func (repo *Repository) GetAllowMergeCommit() *bool {
67-
if repo.Spec.AllowMergeCommit == nil {
68-
return boolPointer(true)
69-
}
7040
return repo.Spec.AllowMergeCommit
7141
}
7242

7343
func (repo *Repository) GetAllowRebaseMerge() *bool {
74-
if repo.Spec.AllowRebaseMerge == nil {
75-
return boolPointer(true)
76-
}
7744
return repo.Spec.AllowRebaseMerge
7845
}
7946

8047
func (repo *Repository) GetAllowAutoMerge() *bool {
81-
if repo.Spec.AllowAutoMerge == nil {
82-
return boolPointer(false)
83-
}
8448
return repo.Spec.AllowAutoMerge
8549
}
8650

8751
func (repo *Repository) GetDeleteBranchOnMerge() *bool {
88-
if repo.Spec.DeleteBranchOnMerge == nil {
89-
return boolPointer(false)
90-
}
9152
return repo.Spec.DeleteBranchOnMerge
9253
}
9354

9455
func (repo *Repository) GetIsTemplate() *bool {
95-
if repo.Spec.IsTemplate == nil {
96-
return boolPointer(false)
97-
}
9856
return repo.Spec.IsTemplate
9957
}
100-
101-
func boolPointer(bool bool) *bool {
102-
return &bool
103-
}

0 commit comments

Comments
 (0)