Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/add storage download url #20

Merged
merged 4 commits into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,13 @@ resources:
kind: CustomCertificate
path: github.com/alperencelik/kubemox/api/proxmox/v1alpha1
version: v1alpha1
- api:
crdVersion: v1
namespaced: true
controller: true
domain: alperen.cloud
group: proxmox
kind: StorageDownloadURL
path: github.com/alperencelik/kubemox/api/proxmox/v1alpha1
version: v1alpha1
version: "3"
72 changes: 72 additions & 0 deletions api/proxmox/v1alpha1/storagedownloadurl_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
Copyright 2023.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1alpha1

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.

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

Content string `json:"content"`
Filename string `json:"filename"`
Node string `json:"node"`
Storage string `json:"storage"`
URL string `json:"url"`
// Optional fields
Checksum string `json:"checksum,omitempty"`
ChecksumAlgorithm string `json:"checksumAlgorithm,omitempty"`
Compression string `json:"compression,omitempty"`
VerifyCertificate bool `json:"verifyCertificate,omitempty"`
}

// StorageDownloadURLStatus defines the observed state of StorageDownloadURL
type StorageDownloadURLStatus 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

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

Spec StorageDownloadURLSpec `json:"spec,omitempty"`
Status StorageDownloadURLStatus `json:"status,omitempty"`
}

//+kubebuilder:object:root=true

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

func init() {
SchemeBuilder.Register(&StorageDownloadURL{}, &StorageDownloadURLList{})
}
88 changes: 88 additions & 0 deletions api/proxmox/v1alpha1/zz_generated.deepcopy.go

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

44 changes: 25 additions & 19 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,27 +133,33 @@ func main() {
setupLog.Error(err, "unable to create controller", "controller", "Container")
os.Exit(1)
}
if err = (&proxmoxcontroller.CustomCertificateReconciler{
if err = (&proxmoxcontroller.StorageDownloadURLReconciler{
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
}).SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "CustomCertificate")
os.Exit(1)
}
//+kubebuilder:scaffold:builder

if err := mgr.AddHealthzCheck("healthz", healthz.Ping); err != nil {
setupLog.Error(err, "unable to set up health check")
os.Exit(1)
}
if err := mgr.AddReadyzCheck("readyz", healthz.Ping); err != nil {
setupLog.Error(err, "unable to set up ready check")
os.Exit(1)
}

setupLog.Info("starting manager")
if err := mgr.Start(ctrl.SetupSignalHandler()); err != nil {
setupLog.Error(err, "problem running manager")
os.Exit(1)
setupLog.Error(err, "unable to create controller", "controller", "StorageDownloadURL")
if err = (&proxmoxcontroller.CustomCertificateReconciler{
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
}).SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "CustomCertificate")
os.Exit(1)
}
//+kubebuilder:scaffold:builder

if err := mgr.AddHealthzCheck("healthz", healthz.Ping); err != nil {
setupLog.Error(err, "unable to set up health check")
os.Exit(1)
}
if err := mgr.AddReadyzCheck("readyz", healthz.Ping); err != nil {
setupLog.Error(err, "unable to set up ready check")
os.Exit(1)
}

setupLog.Info("starting manager")
if err := mgr.Start(ctrl.SetupSignalHandler()); err != nil {
setupLog.Error(err, "problem running manager")
os.Exit(1)
}
}
}
71 changes: 71 additions & 0 deletions config/crd/bases/proxmox.alperen.cloud_storagedownloadurls.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.12.0
name: storagedownloadurls.proxmox.alperen.cloud
spec:
group: proxmox.alperen.cloud
names:
kind: StorageDownloadURL
listKind: StorageDownloadURLList
plural: storagedownloadurls
singular: storagedownloadurl
scope: Namespaced
versions:
- name: v1alpha1
schema:
openAPIV3Schema:
description: StorageDownloadURL is the Schema for the storagedownloadurls
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: StorageDownloadURLSpec defines the desired state of StorageDownloadURL
properties:
checksum:
description: Optional fields
type: string
checksumAlgorithm:
type: string
compression:
type: string
content:
type: string
filename:
type: string
node:
type: string
storage:
type: string
url:
type: string
verifyCertificate:
type: boolean
required:
- content
- filename
- node
- storage
- url
type: object
status:
description: StorageDownloadURLStatus defines the observed state of StorageDownloadURL
type: object
type: object
served: true
storage: true
subresources:
status: {}
3 changes: 3 additions & 0 deletions config/crd/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ resources:
- bases/proxmox.alperen.cloud_virtualmachinesnapshots.yaml
- bases/proxmox.alperen.cloud_virtualmachinesnapshotpolicies.yaml
- bases/proxmox.alperen.cloud_containers.yaml
- bases/proxmox.alperen.cloud_storagedownloadurls.yaml
- bases/proxmox.alperen.cloud_customcertificates.yaml
#+kubebuilder:scaffold:crdkustomizeresource

Expand All @@ -20,6 +21,7 @@ patches:
#- path: patches/webhook_in_virtualmachinesnapshots.yaml
#- path: patches/webhook_in_virtualmachinesnapshotpolicies.yaml
#- path: patches/webhook_in_containers.yaml
#- path: patches/webhook_in_proxmox_storagedownloadurls.yaml
#- path: patches/webhook_in_proxmox_customcertificates.yaml
#+kubebuilder:scaffold:crdkustomizewebhookpatch

Expand All @@ -31,6 +33,7 @@ patches:
#- path: patches/cainjection_in_virtualmachinesnapshots.yaml
#- path: patches/cainjection_in_virtualmachinesnapshotpolicies.yaml
#- path: patches/cainjection_in_containers.yaml
#- path: patches/cainjection_in_proxmox_storagedownloadurls.yaml
#- path: patches/cainjection_in_proxmox_customcertificates.yaml
#+kubebuilder:scaffold:crdkustomizecainjectionpatch

Expand Down
31 changes: 31 additions & 0 deletions config/rbac/proxmox_storagedownloadurl_editor_role.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# permissions for end users to edit storagedownloadurls.
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
labels:
app.kubernetes.io/name: clusterrole
app.kubernetes.io/instance: storagedownloadurl-editor-role
app.kubernetes.io/component: rbac
app.kubernetes.io/created-by: kubemox
app.kubernetes.io/part-of: kubemox
app.kubernetes.io/managed-by: kustomize
name: storagedownloadurl-editor-role
rules:
- apiGroups:
- proxmox.alperen.cloud
resources:
- storagedownloadurls
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- proxmox.alperen.cloud
resources:
- storagedownloadurls/status
verbs:
- get
27 changes: 27 additions & 0 deletions config/rbac/proxmox_storagedownloadurl_viewer_role.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# permissions for end users to view storagedownloadurls.
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
labels:
app.kubernetes.io/name: clusterrole
app.kubernetes.io/instance: storagedownloadurl-viewer-role
app.kubernetes.io/component: rbac
app.kubernetes.io/created-by: kubemox
app.kubernetes.io/part-of: kubemox
app.kubernetes.io/managed-by: kustomize
name: storagedownloadurl-viewer-role
rules:
- apiGroups:
- proxmox.alperen.cloud
resources:
- storagedownloadurls
verbs:
- get
- list
- watch
- apiGroups:
- proxmox.alperen.cloud
resources:
- storagedownloadurls/status
verbs:
- get
Loading
Loading