-
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
feat: Add Non Admin Restore controller #42
Closed
mateusoliveira43
wants to merge
8
commits into
migtools:master
from
mateusoliveira43:feat/restore-controller
Closed
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
1dac5f6
feat: Add Non Admin Restore controller
mateusoliveira43 344be35
fixup! feat: Add Non Admin Restore controller
mateusoliveira43 3067eb3
fixup! feat: Add Non Admin Restore controller
mateusoliveira43 cdb9390
fixup! feat: Add Non Admin Restore controller
mateusoliveira43 e0e01ed
fixup! feat: Add Non Admin Restore controller
mateusoliveira43 49de8b5
fixup! feat: Add Non Admin Restore controller
mateusoliveira43 47605cd
fixup! feat: Add Non Admin Restore controller
mateusoliveira43 ba8553e
fixup! feat: Add Non Admin Restore controller
mateusoliveira43 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
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 |
---|---|---|
|
@@ -38,6 +38,8 @@ To use NAC functionality: | |
``` | ||
|
||
Check the application was successful deployed by accessing its route. | ||
|
||
Create and update items in application UI, to later check if application was successfully restored. | ||
- create NonAdminBackup | ||
|
||
For example, use one of the sample NonAdminBackup available in `hack/samples/backups/` folder, by running | ||
|
@@ -47,7 +49,28 @@ To use NAC functionality: | |
| oc create -f - | ||
``` | ||
<!-- TODO how to track status --> | ||
- TODO NonAdminRestore | ||
- delete sample application | ||
|
||
For example, delete one of the sample applications available in `hack/samples/apps/` folder, by running | ||
```sh | ||
oc process -f ./hack/samples/apps/<name> \ | ||
-p NAMESPACE=<non-admin-user-namespace> \ | ||
| oc delete -f - | ||
``` | ||
|
||
Check that application was successful deleted by accessing its route. | ||
- create NonAdminRestore | ||
|
||
For example, use one of the sample NonAdminRestore available in `hack/samples/restores/` folder, by running | ||
```sh | ||
oc process -f ./hack/samples/restores/<type> \ | ||
-p NAMESPACE=<non-admin-user-namespace> \ | ||
-p NAME=<NonAdminBackup-name> \ | ||
| oc create -f - | ||
``` | ||
<!-- TODO how to track status --> | ||
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. TODO |
||
|
||
After NonAdminRestore completes, check if the application was successful restored by accessing its route and seeing its items in application UI. | ||
|
||
## Contributing | ||
|
||
|
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,75 @@ | ||
/* | ||
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 ( | ||
velerov1api "github.com/vmware-tanzu/velero/pkg/apis/velero/v1" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
// NonAdminRestoreSpec defines the desired state of NonAdminRestore | ||
type NonAdminRestoreSpec struct { | ||
// Specification for a Velero restore. | ||
RestoreSpec *velerov1api.RestoreSpec `json:"restoreSpec"` | ||
// TODO need to investigate restoreSpec.namespaceMapping, depends on how NAC tracks the namespace access per user | ||
|
||
// TODO NonAdminRestore log level, by default TODO. | ||
// +optional | ||
// +kubebuilder:validation:Enum=trace;debug;info;warning;error;fatal;panic | ||
LogLevel string `json:"logLevel,omitempty"` | ||
// TODO ALSO ADD TEST FOR DIFFERENT LOG LEVELS | ||
} | ||
|
||
// NonAdminRestoreStatus defines the observed state of NonAdminRestore | ||
type NonAdminRestoreStatus struct { | ||
// Related Velero Restore name. | ||
// +optional | ||
VeleroRestoreName string `json:"veleroRestoreName,omitempty"` | ||
|
||
mateusoliveira43 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// Related Velero Restore status. | ||
// +optional | ||
VeleroRestoreStatus *velerov1api.RestoreStatus `json:"veleroRestoreStatus,omitempty"` | ||
|
||
Phase NonAdminPhase `json:"phase,omitempty"` | ||
Conditions []metav1.Condition `json:"conditions,omitempty"` | ||
} | ||
|
||
// +kubebuilder:object:root=true | ||
// +kubebuilder:subresource:status | ||
mateusoliveira43 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// +kubebuilder:resource:path=nonadminrestores,shortName=nar | ||
|
||
// NonAdminRestore is the Schema for the nonadminrestores API | ||
type NonAdminRestore struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
||
Spec NonAdminRestoreSpec `json:"spec,omitempty"` | ||
Status NonAdminRestoreStatus `json:"status,omitempty"` | ||
} | ||
|
||
// +kubebuilder:object:root=true | ||
|
||
// NonAdminRestoreList contains a list of NonAdminRestore | ||
type NonAdminRestoreList struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ListMeta `json:"metadata,omitempty"` | ||
Items []NonAdminRestore `json:"items"` | ||
} | ||
|
||
func init() { | ||
SchemeBuilder.Register(&NonAdminRestore{}, &NonAdminRestoreList{}) | ||
} |
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 |
---|---|---|
|
@@ -98,7 +98,8 @@ func main() { | |
TLSOpts: tlsOpts, | ||
}) | ||
|
||
if len(constant.OadpNamespace) == 0 { | ||
// TODO create get function in common :question: | ||
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. TODO |
||
if len(os.Getenv(constant.NamespaceEnvVar)) == 0 { | ||
setupLog.Error(fmt.Errorf("%v environment variable is empty", constant.NamespaceEnvVar), "environment variable must be set") | ||
os.Exit(1) | ||
} | ||
|
@@ -138,6 +139,13 @@ func main() { | |
setupLog.Error(err, "unable to create controller", "controller", "NonAdminBackup") | ||
os.Exit(1) | ||
} | ||
if err = (&controller.NonAdminRestoreReconciler{ | ||
Client: mgr.GetClient(), | ||
Scheme: mgr.GetScheme(), | ||
}).SetupWithManager(mgr); err != nil { | ||
setupLog.Error(err, "unable to create controller", "controller", "NonAdminRestore") | ||
os.Exit(1) | ||
} | ||
// +kubebuilder:scaffold:builder | ||
|
||
if err := mgr.AddHealthzCheck("healthz", healthz.Ping); err != nil { | ||
|
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
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.
for better user experience