-
Notifications
You must be signed in to change notification settings - Fork 5
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
Allow Non-Admin user to create Backup Storage Locations - fixes #36 #115
Draft
mpryc
wants to merge
4
commits into
migtools:master
Choose a base branch
from
mpryc:nonadminstoragelocation_controller
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
6d9db57
Generated scaffold for the NonAdminBackupStorageLocation
mpryc eeaaf4d
Generated manifests after scaffold of NABSL
mpryc cb2508e
Rename some of the imports to be consistent from oadpv1alpha1 to nacv…
mpryc 306fe37
NonAdminBackup BSL - WIP
mpryc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
/* | ||
Copyright 2024. | ||
|
||
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 ( | ||
velerov1 "github.com/vmware-tanzu/velero/pkg/apis/velero/v1" | ||
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. | ||
|
||
// NonAdminBackupStorageLocationPhase is a simple one high-level summary of the lifecycle of an NonAdminBackupStorageLocation. | ||
// +kubebuilder:validation:Enum=New;Available;Unavailable;Created;Deleting | ||
type NonAdminBackupStorageLocationPhase string | ||
|
||
// NonAdminBackupStorageLocationPhase constants similar to velerov1.BackupStorageLocationPhase | ||
const ( | ||
NaBSLPhaseNew NonAdminBackupStorageLocationPhase = "New" | ||
NaBSLPhaseAvailable NonAdminBackupStorageLocationPhase = "Available" | ||
NaBSLPhaseUnavailable NonAdminBackupStorageLocationPhase = "Unavailable" | ||
NaBSLPhaseCreated NonAdminBackupStorageLocationPhase = "Created" | ||
NaBSLPhaseDeleting NonAdminBackupStorageLocationPhase = "Deleting" | ||
) | ||
|
||
// NonAdminBSLCondition contains addition conditions to the | ||
// generic ones defined as NonAdminCondition | ||
// +kubebuilder:validation:Enum=SecretSynced;BSLSynced | ||
type NonAdminBSLCondition string | ||
|
||
// Predefined NonAdminBSLConditions | ||
const ( | ||
NonAdminBSLConditionSecretSynced NonAdminBSLCondition = "SecretSynced" | ||
NonAdminBSLConditionBSLSynced NonAdminBSLCondition = "BackupStorageLocationSynced" | ||
) | ||
|
||
// NonAdminBackupStorageLocationSpec defines the desired state of NonAdminBackupStorageLocation | ||
type NonAdminBackupStorageLocationSpec struct { | ||
// Embeds the Velero BackupStorageLocationSpec to inherit all fields | ||
velerov1.BackupStorageLocationSpec `json:",inline"` | ||
} | ||
|
||
// VeleroBackupStorageLocation contains information of the related Velero backup object. | ||
type VeleroBackupStorageLocation struct { | ||
// status captures the current status of the Velero backup storage location. | ||
// +optional | ||
Status *velerov1.BackupStorageLocationStatus `json:"status,omitempty"` | ||
|
||
// nacuuid references the Velero BackupStorageLocation object by it's label containing same NACUUID. | ||
// +optional | ||
NACUUID string `json:"nacuuid,omitempty"` | ||
|
||
// references the Velero BackupStorageLocation object by it's name. | ||
// +optional | ||
Name string `json:"name,omitempty"` | ||
|
||
// namespace references the Namespace in which Velero backup storage location exists. | ||
// +optional | ||
Namespace string `json:"namespace,omitempty"` | ||
} | ||
|
||
// NonAdminBackupStorageLocationStatus defines the observed state of NonAdminBackupStorageLocation | ||
type NonAdminBackupStorageLocationStatus struct { | ||
// Important: Run "make" to regenerate code after modifying this file | ||
// +optional | ||
VeleroBackupStorageLocation *VeleroBackupStorageLocation `json:"veleroBackupStorageLocation,omitempty"` | ||
|
||
Phase NonAdminBackupStorageLocationPhase `json:"phase,omitempty"` | ||
Conditions []metav1.Condition `json:"conditions,omitempty"` | ||
} | ||
|
||
// NonAdminBackupStorageLocation is the Schema for the nonadminbackupstoragelocations API | ||
// +kubebuilder:object:root=true | ||
// +kubebuilder:subresource:status | ||
type NonAdminBackupStorageLocation struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
||
Spec NonAdminBackupStorageLocationSpec `json:"spec,omitempty"` | ||
Status NonAdminBackupStorageLocationStatus `json:"status,omitempty"` | ||
} | ||
|
||
// NonAdminBackupStorageLocationList contains a list of NonAdminBackupStorageLocation | ||
// +kubebuilder:object:root=true | ||
type NonAdminBackupStorageLocationList struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ListMeta `json:"metadata,omitempty"` | ||
Items []NonAdminBackupStorageLocation `json:"items"` | ||
} | ||
|
||
func init() { | ||
SchemeBuilder.Register(&NonAdminBackupStorageLocation{}, &NonAdminBackupStorageLocationList{}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
Copyright 2024. | ||
|
||
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 | ||
|
||
// NonAdminCondition are used for more detailed information supporing NonAdminBackupPhase state. | ||
// +kubebuilder:validation:Enum=Accepted;Queued;Deleting | ||
type NonAdminCondition string | ||
|
||
// Predefined conditions for NonAdminController objects. | ||
// One NonAdminController object may have multiple conditions. | ||
// It is more granular knowledge of the NonAdminController object and represents the | ||
// array of the conditions through which the NonAdminController has or has not passed | ||
const ( | ||
NonAdminConditionAccepted NonAdminCondition = "Accepted" | ||
NonAdminConditionQueued NonAdminCondition = "Queued" | ||
NonAdminConditionDeleting NonAdminCondition = "Deleting" | ||
) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,8 +30,6 @@ import ( | |
"k8s.io/apimachinery/pkg/runtime" | ||
utilruntime "k8s.io/apimachinery/pkg/util/runtime" | ||
clientgoscheme "k8s.io/client-go/kubernetes/scheme" | ||
// Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. undo |
||
// to ensure that exec-entrypoint and run can make use of them. | ||
_ "k8s.io/client-go/plugin/pkg/client/auth" | ||
"k8s.io/client-go/rest" | ||
ctrl "sigs.k8s.io/controller-runtime" | ||
|
@@ -51,6 +49,11 @@ var ( | |
setupLog = ctrl.Log.WithName("setup") | ||
) | ||
|
||
const ( | ||
unableToCreateControllerString = "unable to create controller" | ||
controllerString = "controller" | ||
) | ||
|
||
func init() { | ||
utilruntime.Must(clientgoscheme.AddToScheme(scheme)) | ||
|
||
|
@@ -153,15 +156,23 @@ func main() { | |
OADPNamespace: oadpNamespace, | ||
EnforcedBackupSpec: enforcedBackupSpec, | ||
}).SetupWithManager(mgr); err != nil { | ||
setupLog.Error(err, "unable to create controller", "controller", "NonAdminBackup") | ||
setupLog.Error(err, unableToCreateControllerString, controllerString, "NonAdminBackup") | ||
os.Exit(1) | ||
} | ||
if err = (&controller.NonAdminRestoreReconciler{ | ||
Client: mgr.GetClient(), | ||
Scheme: mgr.GetScheme(), | ||
OADPNamespace: oadpNamespace, | ||
}).SetupWithManager(mgr); err != nil { | ||
setupLog.Error(err, "unable to create controller", "controller", "NonAdminRestore") | ||
setupLog.Error(err, unableToCreateControllerString, controllerString, "NonAdminRestore") | ||
os.Exit(1) | ||
} | ||
if err = (&controller.NonAdminBackupStorageLocationReconciler{ | ||
Client: mgr.GetClient(), | ||
Scheme: mgr.GetScheme(), | ||
OADPNamespace: oadpNamespace, | ||
}).SetupWithManager(mgr); err != nil { | ||
setupLog.Error(err, unableToCreateControllerString, controllerString, "NonAdminBackupStorageLocation") | ||
os.Exit(1) | ||
} | ||
// +kubebuilder:scaffold:builder | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove scaffolded comments