Implement routes to list, get and delete execution environments
* #9 Implement routes to list, get and delete execution environments. A refactoring was required to introduce the ExecutionEnvironment interface. * Fix MR comments, linting issues and bug that lead to e2e test failure * Add e2e tests * Add unit tests
This commit is contained in:
@ -5,6 +5,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"path"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@ -31,6 +32,27 @@ func (er *ExecutionRequest) FullCommand() []string {
|
||||
return command
|
||||
}
|
||||
|
||||
// EnvironmentID is an id of an environment.
|
||||
type EnvironmentID int
|
||||
|
||||
// NewEnvironmentID parses a string into an EnvironmentID.
|
||||
func NewEnvironmentID(id string) (EnvironmentID, error) {
|
||||
environment, err := strconv.Atoi(id)
|
||||
return EnvironmentID(environment), err
|
||||
}
|
||||
|
||||
// ToString pareses an EnvironmentID back to a string.
|
||||
func (e EnvironmentID) ToString() string {
|
||||
return strconv.Itoa(int(e))
|
||||
}
|
||||
|
||||
// ExecutionEnvironmentData is the expected json structure of the response body
|
||||
// for routes returning an execution environment.
|
||||
type ExecutionEnvironmentData struct {
|
||||
ExecutionEnvironmentRequest
|
||||
ID int `json:"id"`
|
||||
}
|
||||
|
||||
// ExecutionEnvironmentRequest is the expected json structure of the request body
|
||||
// for the create execution environment function.
|
||||
type ExecutionEnvironmentRequest struct {
|
||||
|
Reference in New Issue
Block a user