approval

package
v0.0.0-...-8041c63 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2022 License: MPL-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ERR_NO_DESCRIPTION      = errors.New("No description is set")
	ERR_NO_ACTION           = errors.New("Approval is not configured for 'provision', 'delete' nor 'reconfigure'")
	ERR_NO_RECIPIENTS       = errors.New("No recipients are configured")
	ERR_BAD_RECIPIENT_EMAIL = errors.New("Recipient email address appears to be invalid")
	ERR_TEMPLATE_NOT_EXIST  = errors.New("Configured message template cannot be found")
	ERR_MULTIPLE_SCOPES     = errors.New("Multiple Scopes found")
)

Functions

func ReadAndParseConfig

func ReadAndParseConfig(cfgFile string) error

ReadAndParseConfig reads the contents of the YAML approvals config filer and parses it to a map of Approval structs

func ValidateConfig

func ValidateConfig() error

ValidateConfig will check that the config parsed can be used by application

Types

type Approval

type Approval struct {
	Id          int       `json:"id"`
	Name        string    `json:"name"`
	RequestType string    `json:"requestType"`
	Status      string    `json:"status"`
	DateCreated time.Time `json:"datedCreated"`
	RequestBy   string    `json:"requestBy"`
	Items       []Item    `json:"approvalItems"`
	Scope       Scope     `json:"scope"`
	Cost        float64   `jsom:"cost"`
}

Approval holds information about an approval, some properties are partially populated by the approval api request, we flesh out Scope by checking the instance or app information. we are also going to determine the cost from the instance/app info as it is not included in the approval response itself

type ApprovalConfig

type ApprovalConfig struct {
	Description    string   `yaml:"description"`
	TemplateFile   string   `yaml:"template"`
	OnProvision    bool     `yaml:"onProvision"`
	OnDelete       bool     `yaml:"onDelete"`
	OnReconfigure  bool     `yaml:"onReconfigure"`
	LinkedApproval bool     `yaml:"linkedApproval"`
	RecipientList  []string `yaml:"recipientList"`
	Scope          Scope    `yaml:"scope"`
}

ApprovalConfig represents a single approval configuration

type ApprovalsConfig

type ApprovalsConfig []struct {
	ApprovalConfig `yaml:"approval"`
}

ApprovalsConfig is a representation of the parsed YAML approvals.yaml configuration file

type Item

type Item struct {
	Id        int       `json:"id"`
	Reference Reference `json:"reference"`
}

Item holds the basic data we need in order to integorate an instance of application for scope metadata

type Reference

type Reference struct {
	Id int `json:"id"`
}

type Scope

type Scope struct {
	Group       string `yaml:"group"`
	Cloud       string `yaml:"cloud"`
	User        string `yaml:"user"`
	Tenant      string `yaml:"tenant"`
	Environment string `yaml:"environment"`
}

Scope represents the scope configuration options which can be set in the YAML. Default scope is 'global' unless overridden here - by a single setting here

Jump to

Keyboard shortcuts

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