-
Notifications
You must be signed in to change notification settings - Fork 184
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
provider: add server side implementation of rpc calls
Signed-off-by: Rewant Soni <[email protected]>
- Loading branch information
1 parent
0418d73
commit e96b0be
Showing
29 changed files
with
3,947 additions
and
43 deletions.
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,50 @@ | ||
package server | ||
|
||
import ( | ||
"context" | ||
ramenv1alpha1 "github.com/ramendr/ramen/api/v1alpha1" | ||
"sigs.k8s.io/controller-runtime/pkg/client" | ||
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" | ||
) | ||
|
||
type maintenanceModeManager struct { | ||
client client.Client | ||
namespace string | ||
} | ||
|
||
func newMaintenanceModeManager(cl client.Client, namespace string) (*maintenanceModeManager, error) { | ||
return &maintenanceModeManager{ | ||
client: cl, | ||
namespace: namespace, | ||
}, nil | ||
} | ||
|
||
func (m maintenanceModeManager) Create(ctx context.Context, name string, spec *ramenv1alpha1.MaintenanceModeSpec) error { | ||
mModeObj := &ramenv1alpha1.MaintenanceMode{} | ||
mModeObj.Name = name | ||
_, err := controllerutil.CreateOrUpdate(ctx, m.client, mModeObj, func() error { | ||
mModeObj.Spec = *spec | ||
return nil | ||
}) | ||
return err | ||
} | ||
|
||
func (m maintenanceModeManager) Get(ctx context.Context, name string) (*ramenv1alpha1.MaintenanceMode, error) { | ||
mModeObj := &ramenv1alpha1.MaintenanceMode{} | ||
mModeObj.Name = name | ||
err := m.client.Get(ctx, client.ObjectKey{Name: name}, mModeObj) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return mModeObj, nil | ||
} | ||
|
||
func (m maintenanceModeManager) Delete(ctx context.Context, name string) error { | ||
mModeObj := &ramenv1alpha1.MaintenanceMode{} | ||
mModeObj.Name = name | ||
err := m.client.Delete(ctx, mModeObj) | ||
if err != nil { | ||
return err | ||
} | ||
return 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.