Skip to content
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
27 changes: 26 additions & 1 deletion environment.proto
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ message Environment {
string Version = 5; // Version associated with an environment
string Size = 6; // Size of the environment
Ingress Ingress = 7; // Ingress configuration for routing
Image Image = 8; // Image respository information
Image Image = 8; // Image repository information
repeated Cron Cron = 9; // Cron configuration for an environment
repeated MySQL MySQL = 10; // MySQL configuration for an environment
SMTP SMTP = 11; // SMTP configuration for an environment
Expand All @@ -67,6 +67,7 @@ message Environment {
repeated Daemon Daemon = 19; // Daemon configuration for an environment
EnvironmentResources Resources = 20; // Resources utilised by this environment
EnvironmentMetrics Metrics = 21; // Metrics configuration for this environment
bool Suspended = 22; // Environment is suspended
}

/**
Expand Down Expand Up @@ -146,6 +147,30 @@ message EnvironmentGetResponse {
Environment Environment = 1; // Environment status
}

/**
* Request that environment is suspended
*/
message EnvironmentSuspendRequest {
string Name = 1; // Name of the environment
}

/**
* Response if the environment suspend was successful
*/
message EnvironmentSuspendResponse {}

/**
* Request that environment be resumed
*/
message EnvironmentResumeRequest {
string Name = 1; // Name of the environment
}

/**
* Response if the environment resume was successful
*/
message EnvironmentResumeResponse {}

/**
* Request a list of environment
*/
Expand Down
1 change: 1 addition & 0 deletions internal/model/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ func (s *Model) CreateEnvironment(name string, size int32, metrics bool) {
Version: "v0.0.1",
Phase: "Deployed",
Production: name == "prod",
Suspended: false,
Ingress: &pb.Ingress{
Routes: []string{
fmt.Sprintf("%s.mock.local.skpr.dev", name),
Expand Down
24 changes: 24 additions & 0 deletions internal/server/mock/environment/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,27 @@ func (c *Server) Delete(ctx context.Context, req *pb.EnvironmentDeleteRequest) (
resp := &pb.EnvironmentDeleteResponse{}
return resp, nil
}

func (c *Server) Suspend(ctx context.Context, req *pb.EnvironmentSuspendRequest) (*pb.EnvironmentSuspendResponse, error) {
environment, err := c.Model.GetEnvironment(req.Name)
if err != nil {
return nil, err
}

environment.Environment.Suspended = true

resp := &pb.EnvironmentSuspendResponse{}
return resp, nil
}

func (c *Server) Resume(ctx context.Context, req *pb.EnvironmentResumeRequest) (*pb.EnvironmentResumeResponse, error) {
environment, err := c.Model.GetEnvironment(req.Name)
if err != nil {
return nil, err
}

environment.Environment.Suspended = false

resp := &pb.EnvironmentResumeResponse{}
return resp, nil
}
Loading
Loading