Add an ability to uninstall applications
This commit is contained in:
@ -6,6 +6,8 @@ import (
|
||||
"git.badhouseplants.net/softplayer/softplayer-backend/internal/controllers"
|
||||
proto "git.badhouseplants.net/softplayer/softplayer-go-proto/pkg/applications"
|
||||
"github.com/go-logr/logr"
|
||||
"github.com/golang/protobuf/ptypes/empty"
|
||||
"google.golang.org/protobuf/types/known/emptypb"
|
||||
ctrl "sigs.k8s.io/controller-runtime"
|
||||
)
|
||||
|
||||
@ -56,3 +58,27 @@ func (app *ApplicationServer) Create(ctx context.Context, in *proto.CreateOption
|
||||
Spec: in.GetSpec(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (app *ApplicationServer) Delete(ctx context.Context, in *proto.DeleteOptions) (*empty.Empty, error) {
|
||||
log := app.logInstance
|
||||
log.WithValues("user_id", in.GetOwnerId().GetUuid(), "app_id", in.GetId().GetUuid())
|
||||
ctx = logr.NewContext(ctx, log)
|
||||
|
||||
data := &controllers.ApplicationData{
|
||||
Name: in.Metadata.Name,
|
||||
UUID: in.GetId().GetUuid(),
|
||||
}
|
||||
|
||||
application := &controllers.Application{
|
||||
UserID: in.GetOwnerId().GetUuid(),
|
||||
Controller: app.controller,
|
||||
Data: data,
|
||||
Token: in.GetToken().GetToken(),
|
||||
}
|
||||
|
||||
err := application.Delete(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &emptypb.Empty{}, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user