Skip to content

Commit c409622

Browse files
author
Aatman
authored
feat(settings): invite user to org (#2)
``` apiVersion: settings.github.com/v1beta1 kind: InviteUser metadata: name: inviteuser-sample spec: organization: "octocat" users: - username: Hunter-Thompson email: aatman@auroville.org.in ```
1 parent b2df4b2 commit c409622

14 files changed

+559
-0
lines changed

PROJECT

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,13 @@ resources:
2323
kind: Team
2424
path: github.com/Hunter-Thompson/github-operator/apis/settings/v1beta1
2525
version: v1beta1
26+
- api:
27+
crdVersion: v1
28+
namespaced: true
29+
controller: true
30+
domain: github.com
31+
group: settings
32+
kind: InviteUser
33+
path: github.com/Hunter-Thompson/github-operator/apis/settings/v1beta1
34+
version: v1beta1
2635
version: "3"
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
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+
// InviteUserSpec defines the desired state of InviteUser
27+
type InviteUserSpec 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,omitempty"`
33+
Users []User `json:"users,omitempty"`
34+
}
35+
36+
type User struct {
37+
Username string `json:"username,omitempty"`
38+
Email string `json:"email,omitempty"`
39+
}
40+
41+
// InviteUserStatus defines the observed state of InviteUser
42+
type InviteUserStatus struct {
43+
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
44+
// Important: Run "make" to regenerate code after modifying this file
45+
}
46+
47+
//+kubebuilder:object:root=true
48+
//+kubebuilder:subresource:status
49+
50+
// InviteUser is the Schema for the inviteusers API
51+
type InviteUser struct {
52+
metav1.TypeMeta `json:",inline"`
53+
metav1.ObjectMeta `json:"metadata,omitempty"`
54+
55+
Spec InviteUserSpec `json:"spec,omitempty"`
56+
Status InviteUserStatus `json:"status,omitempty"`
57+
}
58+
59+
//+kubebuilder:object:root=true
60+
61+
// InviteUserList contains a list of InviteUser
62+
type InviteUserList struct {
63+
metav1.TypeMeta `json:",inline"`
64+
metav1.ListMeta `json:"metadata,omitempty"`
65+
Items []InviteUser `json:"items"`
66+
}
67+
68+
func init() {
69+
SchemeBuilder.Register(&InviteUser{}, &InviteUserList{})
70+
}

apis/settings/v1beta1/zz_generated.deepcopy.go

Lines changed: 109 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
---
2+
apiVersion: apiextensions.k8s.io/v1
3+
kind: CustomResourceDefinition
4+
metadata:
5+
annotations:
6+
controller-gen.kubebuilder.io/version: v0.9.2
7+
creationTimestamp: null
8+
name: inviteusers.settings.github.com
9+
spec:
10+
group: settings.github.com
11+
names:
12+
kind: InviteUser
13+
listKind: InviteUserList
14+
plural: inviteusers
15+
singular: inviteuser
16+
scope: Namespaced
17+
versions:
18+
- name: v1beta1
19+
schema:
20+
openAPIV3Schema:
21+
description: InviteUser is the Schema for the inviteusers API
22+
properties:
23+
apiVersion:
24+
description: 'APIVersion defines the versioned schema of this representation
25+
of an object. Servers should convert recognized schemas to the latest
26+
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
27+
type: string
28+
kind:
29+
description: 'Kind is a string value representing the REST resource this
30+
object represents. Servers may infer this from the endpoint the client
31+
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
32+
type: string
33+
metadata:
34+
type: object
35+
spec:
36+
description: InviteUserSpec defines the desired state of InviteUser
37+
properties:
38+
organization:
39+
description: GitHub Org
40+
type: string
41+
users:
42+
items:
43+
properties:
44+
email:
45+
type: string
46+
username:
47+
type: string
48+
type: object
49+
type: array
50+
type: object
51+
status:
52+
description: InviteUserStatus defines the observed state of InviteUser
53+
type: object
54+
type: object
55+
served: true
56+
storage: true
57+
subresources:
58+
status: {}

config/crd/kustomization.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
resources:
55
- bases/settings.github.com_repositories.yaml
66
- bases/settings.github.com_teams.yaml
7+
- bases/settings.github.com_inviteusers.yaml
78
#+kubebuilder:scaffold:crdkustomizeresource
89

910
patchesStrategicMerge:
@@ -12,13 +13,15 @@ patchesStrategicMerge:
1213
#- patches/webhook_in_repositories.yaml
1314
#- patches/webhook_in_teams.yaml
1415
#- patches/webhook_in_collaborators.yaml
16+
#- patches/webhook_in_inviteusers.yaml
1517
#+kubebuilder:scaffold:crdkustomizewebhookpatch
1618

1719
# [CERTMANAGER] To enable cert-manager, uncomment all the sections with [CERTMANAGER] prefix.
1820
# patches here are for enabling the CA injection for each CRD
1921
#- patches/cainjection_in_repositories.yaml
2022
#- patches/cainjection_in_teams.yaml
2123
#- patches/cainjection_in_collaborators.yaml
24+
#- patches/cainjection_in_inviteusers.yaml
2225
#+kubebuilder:scaffold:crdkustomizecainjectionpatch
2326

2427
# the following config is for teaching kustomize how to do kustomization for CRDs.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# The following patch adds a directive for certmanager to inject CA into the CRD
2+
apiVersion: apiextensions.k8s.io/v1
3+
kind: CustomResourceDefinition
4+
metadata:
5+
annotations:
6+
cert-manager.io/inject-ca-from: CERTIFICATE_NAMESPACE/CERTIFICATE_NAME
7+
name: inviteusers.settings.github.com
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# The following patch enables a conversion webhook for the CRD
2+
apiVersion: apiextensions.k8s.io/v1
3+
kind: CustomResourceDefinition
4+
metadata:
5+
name: inviteusers.settings.github.com
6+
spec:
7+
conversion:
8+
strategy: Webhook
9+
webhook:
10+
clientConfig:
11+
service:
12+
namespace: system
13+
name: webhook-service
14+
path: /convert
15+
conversionReviewVersions:
16+
- v1

config/rbac/role.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,32 @@ metadata:
55
creationTimestamp: null
66
name: manager-role
77
rules:
8+
- apiGroups:
9+
- settings.github.com
10+
resources:
11+
- inviteusers
12+
verbs:
13+
- create
14+
- delete
15+
- get
16+
- list
17+
- patch
18+
- update
19+
- watch
20+
- apiGroups:
21+
- settings.github.com
22+
resources:
23+
- inviteusers/finalizers
24+
verbs:
25+
- update
26+
- apiGroups:
27+
- settings.github.com
28+
resources:
29+
- inviteusers/status
30+
verbs:
31+
- get
32+
- patch
33+
- update
834
- apiGroups:
935
- settings.github.com
1036
resources:
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# permissions for end users to edit inviteusers.
2+
apiVersion: rbac.authorization.k8s.io/v1
3+
kind: ClusterRole
4+
metadata:
5+
name: inviteuser-editor-role
6+
rules:
7+
- apiGroups:
8+
- settings.github.com
9+
resources:
10+
- inviteusers
11+
verbs:
12+
- create
13+
- delete
14+
- get
15+
- list
16+
- patch
17+
- update
18+
- watch
19+
- apiGroups:
20+
- settings.github.com
21+
resources:
22+
- inviteusers/status
23+
verbs:
24+
- get
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# permissions for end users to view inviteusers.
2+
apiVersion: rbac.authorization.k8s.io/v1
3+
kind: ClusterRole
4+
metadata:
5+
name: inviteuser-viewer-role
6+
rules:
7+
- apiGroups:
8+
- settings.github.com
9+
resources:
10+
- inviteusers
11+
verbs:
12+
- get
13+
- list
14+
- watch
15+
- apiGroups:
16+
- settings.github.com
17+
resources:
18+
- inviteusers/status
19+
verbs:
20+
- get

0 commit comments

Comments
 (0)