Skip to content

Commit

Permalink
Add new type Users
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreasBergmeier6176 committed Jun 23, 2023
1 parent daa50c9 commit 9434026
Show file tree
Hide file tree
Showing 10 changed files with 729 additions and 57 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ RUN go mod download
COPY cmd/main.go cmd/main.go
COPY api/ api/
COPY internal/controller/ internal/controller/
COPY internal/ internal/

# Build
# the GOARCH has not a default value to allow the binary be built according to the host where the command
Expand Down
11 changes: 10 additions & 1 deletion PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,18 @@ resources:
crdVersion: v1
namespaced: true
controller: true
domain: my.domain
domain: grafana.abergmeier.github.io
group: grafana
kind: Organization
path: github.com/abergmeier/grafana-org/api/v1
version: v1
- api:
crdVersion: v1
namespaced: true
controller: true
domain: grafana.abergmeier.github.io
group: grafana
kind: Users
path: github.com/abergmeier/grafana-org/api/v1
version: v1
version: "3"
1 change: 0 additions & 1 deletion api/v1/organization_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (

// OrganizationSpec defines the desired state of Organization
type OrganizationSpec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
// Important: Run "make" to regenerate code after modifying this file

Url string `json:"url"`
Expand Down
52 changes: 52 additions & 0 deletions api/v1/users_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package v1

import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.

// UserSpec defines the desired state of User
type UserSpec struct {
// Important: Run "make" to regenerate code after modifying this file

Url string `json:"url"`
Admin *GrafanaAdmin `json:"admin,omitempty"`
Users []User `json:"users,omitempty"`
}

type User struct {
Name string `json:"name,omitempty"`
Login string `json:"login"`
Email string `json:"email,omitempty"`
}

// UserStatus defines the observed state of User
type UserStatus struct {
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
// Important: Run "make" to regenerate code after modifying this file
}

//+kubebuilder:object:root=true
//+kubebuilder:subresource:status

// Users is the Schema for the users API
type Users struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec UserSpec `json:"spec,omitempty"`
Status UserStatus `json:"status,omitempty"`
}

//+kubebuilder:object:root=true

// UsersList contains a list of User
type UsersList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []Users `json:"items"`
}

func init() {
SchemeBuilder.Register(&Users{}, &UsersList{})
}
114 changes: 114 additions & 0 deletions api/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

125 changes: 125 additions & 0 deletions config/crd/bases/grafana.abergmeier.github.io_users.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.11.3
creationTimestamp: null
name: users.grafana.abergmeier.github.io
spec:
group: grafana.abergmeier.github.io
names:
kind: Users
listKind: UsersList
plural: users
singular: users
scope: Namespaced
versions:
- name: v1
schema:
openAPIV3Schema:
description: Users is the Schema for the users API
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: UserSpec defines the desired state of User
properties:
admin:
properties:
password:
properties:
valueFrom:
description: 'Optional: Specifies a source the value should
come from.'
properties:
secretKeyRef:
description: SecretKeySelector selects a key of a Secret.
properties:
key:
description: The key of the secret to select from. Must
be a valid secret key.
type: string
name:
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
TODO: Add other useful fields. apiVersion, kind,
uid?'
type: string
optional:
description: Specify whether the Secret or its key
must be defined
type: boolean
required:
- key
type: object
x-kubernetes-map-type: atomic
type: object
type: object
username:
properties:
valueFrom:
description: 'Optional: Specifies a source the value should
come from.'
properties:
secretKeyRef:
description: SecretKeySelector selects a key of a Secret.
properties:
key:
description: The key of the secret to select from. Must
be a valid secret key.
type: string
name:
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
TODO: Add other useful fields. apiVersion, kind,
uid?'
type: string
optional:
description: Specify whether the Secret or its key
must be defined
type: boolean
required:
- key
type: object
x-kubernetes-map-type: atomic
type: object
type: object
required:
- password
- username
type: object
url:
type: string
users:
items:
properties:
email:
type: string
login:
type: string
name:
type: string
required:
- login
type: object
type: array
required:
- url
type: object
status:
description: UserStatus defines the observed state of User
type: object
type: object
served: true
storage: true
subresources:
status: {}
26 changes: 26 additions & 0 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,29 @@ rules:
- get
- patch
- update
- apiGroups:
- grafana.abergmeier.github.io
resources:
- users
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- grafana.abergmeier.github.io
resources:
- users/finalizers
verbs:
- update
- apiGroups:
- grafana.abergmeier.github.io
resources:
- users/status
verbs:
- get
- patch
- update

0 comments on commit 9434026

Please sign in to comment.