models

package
v0.0.0-...-21eebf0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 1, 2020 License: GPL-3.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ProjectStatusInit indicates that the project was created but with nothing
	// more
	ProjectStatusInit = "initialized"
	// ProjectStatusPreparingEnclave indicates that a request to boot the enclave
	// has been sent
	ProjectStatusPreparingEnclave = "preparingEnclave"
	// ProjectStatusPreparingEnclaveErrored indicates that a request to boot the
	// enclave has been sent and that is errored
	ProjectStatusPreparingEnclaveErrored = "preparingEnclaveErrored"
	// ProjectStatusPreparingEnclaveDone indicates that a request to boot the
	// enclave has been sent and that it terminated well
	ProjectStatusPreparingEnclaveDone = "preparingEnclaveDone"
	// ProjectStatusUpdatingAttributes indicates that a request to update the
	// attributes has been submitted
	ProjectStatusUpdatingAttributes = "updatingAttributes"
	// ProjectStatusAttributesUpdatedDone indicated the attributes have been updated
	ProjectStatusAttributesUpdatedDone = "attributesUpdated"
	// ProjectStatusAttributesUpdatedErrored indicates an error occured while
	// updating the attributes.
	ProjectStatusAttributesUpdatedErrored = "attributesUpdatedErrored"
	// ProjectStatusUnlockingEnclave indicates that a request to unlock the
	// enclave has been submitted
	ProjectStatusUnlockingEnclave = "unlockingEnclave"
	// ProjectStatusUnlockingEnclaveDone indicates that a request to unlock the
	// enclave has been submitted and is done
	ProjectStatusUnlockingEnclaveDone = "unlockingEnclaveDone"
	// ProjectStatusUnlockingEnclaveErrored indicates that a request to unlock the
	// enclave has been submitted and errored
	ProjectStatusUnlockingEnclaveErrored = "unlockingEnclaveErrored"
	// ProjectStatusDeletingEnclave indicate that we are trying to delete the
	// enclave
	ProjectStatusDeletingEnclave = "deletingEnclave"
	// ProjectStatusDeletingEnclaveDone indicate that the enclave was
	// successfully deleted
	ProjectStatusDeletingEnclaveDone = "deletingEnclaveDone"
	// ProjectStatusDeletingEnclaveErrored indicate that we failed to delete the
	// enclave
	ProjectStatusDeletingEnclaveErrored = "deletingEnclaveErrored"
	// RequestStatusRunning indicates the request is running
	RequestStatusRunning = "requestRunning"
	// RequestStatusErrored indicates the request stopped with an error
	RequestStatusErrored = "requestErrored"
	// RequestStatusDone indicates the request ended well
	RequestStatusDone = "requestDone"
)

Variables

View Source
var ProjectList = make(map[string]*Project)

ProjectList holds all the project created

Functions

This section is empty.

Types

type Config

type Config struct {
	*TOMLConfig
	TaskManager helpers.TaskManagerI
	Executor    helpers.Executor
	CloudClient helpers.CloudClient
	RunHTTP     helpers.RunHTTP
}

Config holds the global configuration of the server

func NewConfig

func NewConfig() (*Config, error)

NewConfig creates a new Config

type Dataset

type Dataset struct {
	Title       string
	Description string
	Author      string
	WriteInstID string
	CloudURL    string
	SHA2        string
}

Dataset contains the public informations of a dataset. This should match exactly what is stored as json in the extra data field of a write instance, as this struct is used to directly decode the json content.

type Project

type Project struct {
	Status ProjectStatus
	// Uniq ID. Also servers as the enclave name and cloud endpoint.
	UID            string
	Title          string
	Description    string
	InstanceID     string
	Requests       []*Request
	StatusNotifier *helpers.StatusNotifier
	CreatedAt      time.Time
	PubKey         string
}

Project holds a project request

func NewProject

func NewProject(title, description string) *Project

NewProject creates an empty project. If the title is empty (""), will use a random generated title.

func (*Project) AddRequest

func (p *Project) AddRequest(request *Request)

AddRequest adds a new request to the project by prepending the request to the list of existing requests.

func (*Project) GetLastestTaskMsg

func (p *Project) GetLastestTaskMsg() (string, string)

GetLastestTaskMsg return the latest task message, or an empty one if there isn't any. This is convenient to check if the last message was an error and display an output to the client, for example the reasons why the enclave can't be unlocked.

func (*Project) MarshalBinary

func (p *Project) MarshalBinary() ([]byte, error)

MarshalBinary implements encoding.BinaryMarshaler

func (*Project) RequestBootEnclave

func (p *Project) RequestBootEnclave(request *Request, task helpers.TaskI, conf *Config)

RequestBootEnclave talks to the enclave manager and asks it to boot an enclave.

func (*Project) RequestCreateProjectInstance

func (p *Project) RequestCreateProjectInstance(datasetIDs []string, conf *Config) (*Request, helpers.TaskI)

RequestCreateProjectInstance creates and runs a request that creates a new instance of a project contract.

func (*Project) RequestDeleteEnclave

func (p *Project) RequestDeleteEnclave(conf *Config)

RequestDeleteEnclave talks to the enclave manager and asks it to delete an enclave.

func (*Project) RequestUnlockEnclave

func (p *Project) RequestUnlockEnclave(conf *Config)

RequestUnlockEnclave talks to the enclave manager and asks it to boot an enclave.

func (*Project) RequestUpdateAttributes

func (p *Project) RequestUpdateAttributes(values url.Values, conf *Config)

RequestUpdateAttributes creates a new request to update the attributes

func (*Project) UnmarshalBinary

func (p *Project) UnmarshalBinary(data []byte) error

UnmarshalBinary implements encoding.BinaryUnmarshaler

func (*Project) UpdateProjectcStatus

func (p *Project) UpdateProjectcStatus(conf *Config, status string) error

UpdateProjectcStatus updated the status of the project instance

type ProjectSorter

type ProjectSorter []*Project

ProjectSorter is used to define a sorter that sorts projects by the CreatedAt field.

func (ProjectSorter) Len

func (p ProjectSorter) Len() int

Len returns the len ...

func (ProjectSorter) Less

func (p ProjectSorter) Less(i, j int) bool

Less compares two projects based on their CreatedAt fields

func (ProjectSorter) Swap

func (p ProjectSorter) Swap(i, j int)

Swap swaps ...

type ProjectStatus

type ProjectStatus string

ProjectStatus indicates the status of a project

type Request

type Request struct {
	Description    string
	Status         RequestStatus
	Tasks          []helpers.TaskI
	StatusNotifier *helpers.StatusNotifier
	Index          int
}

Request holds a request for a project

func (*Request) GetCloudAttributes

func (r *Request) GetCloudAttributes(projectUID string) (string, string, string)

GetCloudAttributes return the alias, bucket name and prefix

func (*Request) MarshalBinary

func (r *Request) MarshalBinary() ([]byte, error)

MarshalBinary implements encoding.BinaryMarshaler

func (*Request) UnmarshalBinary

func (r *Request) UnmarshalBinary(data []byte) error

UnmarshalBinary implements encoding.BinaryUnmarshaler

type RequestSorter

type RequestSorter []*Request

RequestSorter is used to define a sorter that sorts requests by the Index field.

func (RequestSorter) Len

func (p RequestSorter) Len() int

Len returns the len ...

func (RequestSorter) Less

func (p RequestSorter) Less(i, j int) bool

Less compares two projects based on their CreatedAt fields

func (RequestSorter) Swap

func (p RequestSorter) Swap(i, j int)

Swap swaps ...

type RequestStatus

type RequestStatus string

RequestStatus indicates the status of a request

type TOMLConfig

type TOMLConfig struct {
	CatalogID  string
	BCPath     string
	DarcID     string
	KeyID      string
	ConfigPath string
	PubKeyPath string
}

TOMLConfig is a struct matching the configuration parameters that are stored in the 'config.toml' file.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL