environments

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2021 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Overview

Package environments defines data structure representing a environment instance and methods for interacting with them it is left to concrete implementations in package db or others to implement these interfaces

Index

Constants

This section is empty.

Variables

View Source
var ErrEnvironmentNotFound = gorm.ErrRecordNotFound

ErrEnvironmentNotFound is the error to represent a failed lookup of a environment db record

Functions

This section is empty.

Types

type CreateEnvironmentRequest

type CreateEnvironmentRequest struct {
	Name string `json:"name" binding:"required"`
}

CreateEnvironmentRequest struct defines the data required to create a new environment in db

type Environment

type Environment struct {
	ID          int
	Name        string
	IsPermanent bool
	Requester   string
	DestroyedAt time.Time
	CreatedAt   time.Time
	UpdatedAt   time.Time
}

Environment is the data structure that models a persisted to a database via gorm

type EnvironmentController

type EnvironmentController struct {
	// contains filtered or unexported fields
}

EnvironmentController is the management layer for environments

func NewController

func NewController(dbConn *gorm.DB) *EnvironmentController

NewController accepts a gorm DB connection and returns a new instance of the environment controller

func (*EnvironmentController) CreateNew

func (environmentController *EnvironmentController) CreateNew(newEnvironment CreateEnvironmentRequest) (Environment, error)

CreateNew is the public api on the environmentController for persisting a new service entity to the data store

func (EnvironmentController) DoesEnvironmentExist

func (environmentController EnvironmentController) DoesEnvironmentExist(name string) (id int, ok bool)

DoesEnvironmentExist is a helper method to check if a environment with the given name already exists in sherlock's data storage

func (*EnvironmentController) GetByName

func (environmentController *EnvironmentController) GetByName(name string) (Environment, error)

GetByName is the public API for looking up a environment from the data store by name

func (*EnvironmentController) ListAll

func (environmentController *EnvironmentController) ListAll() ([]Environment, error)

ListAll is the public api for listing out all environments tracked by sherlock

type Response

type Response struct {
	Environments []Environment `json:"environments"`
	Error        string        `json:"error,omitempty"`
}

Response is a type that allows all data returned from the /environment api group to share a consistent structure

Jump to

Keyboard shortcuts

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