config

package module
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2023 License: Apache-2.0 Imports: 11 Imported by: 1

Documentation

Overview

Package config holds all of the data structures for DeployStack. Having them in main package caused circular dependecy issues.

Index

Constants

This section is empty.

Variables

View Source
var ErrConfigNotExist = fmt.Errorf("could not file and parse a config file")

Functions

This section is empty.

Types

type Config

type Config struct {
	Title                string            `json:"title" yaml:"title"`
	Name                 string            `json:"name" yaml:"name"`
	Description          string            `json:"description" yaml:"description"`
	Duration             int               `json:"duration" yaml:"duration"`
	Project              bool              `json:"collect_project" yaml:"collect_project"`
	ProjectNumber        bool              `json:"collect_project_number" yaml:"collect_project_number"`
	BillingAccount       bool              `json:"collect_billing_account" yaml:"collect_billing_account"`
	Domain               bool              `json:"register_domain" yaml:"register_domain"`
	Region               bool              `json:"collect_region" yaml:"collect_region"`
	RegionType           string            `json:"region_type" yaml:"region_type"`
	RegionDefault        string            `json:"region_default" yaml:"region_default"`
	Zone                 bool              `json:"collect_zone" yaml:"collect_zone"`
	HardSet              map[string]string `json:"hard_settings" yaml:"hard_settings"`
	CustomSettings       []Custom          `json:"custom_settings" yaml:"custom_settings"`
	ConfigureGCEInstance bool              `json:"configure_gce_instance" yaml:"configure_gce_instance"`
	DocumentationLink    string            `json:"documentation_link" yaml:"documentation_link"`
	PathTerraform        string            `json:"path_terraform" yaml:"path_terraform"`
	PathMessages         string            `json:"path_messages" yaml:"path_messages"`
	PathScripts          string            `json:"path_scripts" yaml:"path_scripts"`
	Projects             Projects          `json:"projects" yaml:"projects"`
	Products             []struct {
		Info    string `json:"info" yaml:"info"`
		Product string `json:"product" yaml:"product"`
	} `json:"products" yaml:"products"`
}

Config represents the settings this app will collect from a user. It should be in a json file. The idea is minimal programming has to be done to setup a DeployStack and export out a tfvars file for terraform part of solution.

func NewConfigJSON

func NewConfigJSON(content []byte) (Config, error)

NewConfigJSON returns a Config object from a file read.

func NewConfigYAML

func NewConfigYAML(content []byte) (Config, error)

NewConfigYAML returns a Config object from a file read.

func (*Config) ComputeName

func (c *Config) ComputeName() error

ComputeName uses the git repo in the working directory to compute the shortname for the application.

type Custom

type Custom struct {
	Name           string   `json:"name"  yaml:"name"`
	Description    string   `json:"description"  yaml:"description"`
	Default        string   `json:"default"  yaml:"default"`
	Value          string   `json:"value"  yaml:"value"`
	Options        []string `json:"options"  yaml:"options"`
	PrependProject bool     `json:"prepend_project"  yaml:"prepend_project"`
	Validation     string   `json:"validation,omitempty"  yaml:"validation,omitempty"`
	// contains filtered or unexported fields
}

Custom represents a custom setting that we would like to collect from a user We will collect these settings from the user before continuing.

type Customs

type Customs []Custom

Customs are a slice of Custom variables.

func (Customs) Get

func (cs Customs) Get(name string) Custom

Get returns one Custom Variable

type Project

type Project struct {
	Name         string `json:"variable_name"  yaml:"variable_name"`
	UserPrompt   string `json:"user_prompt"  yaml:"user_prompt"`
	SetAsDefault bool   `json:"set_as_default"  yaml:"set_as_default"`
	// contains filtered or unexported fields
}

Project represets a GCP project for use in a stack

type Projects

type Projects struct {
	Items           []Project `json:"items"  yaml:"items"`
	AllowDuplicates bool      `json:"allow_duplicates"  yaml:"allow_duplicates"`
}

Projects is a list of projects that we will collect info for

type Stack

type Stack struct {
	Settings map[string]string
	Config   Config
}

Stack represents the input config and output settings for this DeployStack

func NewStack

func NewStack() Stack

NewStack returns an initialized Stack

func (Stack) AddSetting

func (s Stack) AddSetting(key, value string)

AddSetting stores a setting key/value pair.

func (Stack) DeleteSetting

func (s Stack) DeleteSetting(key string)

DeleteSetting removes a setting value.

func (*Stack) FindAndReadRequired

func (s *Stack) FindAndReadRequired() error

FindAndReadRequired finds and reads in a Config from a json file.

func (Stack) GetSetting

func (s Stack) GetSetting(key string) string

GetSetting returns a setting value.

func (Stack) Terraform

func (s Stack) Terraform() string

Terraform returns all of the settings as a Terraform variables format.

func (Stack) TerraformFile

func (s Stack) TerraformFile(filename string) error

TerraformFile exports TFVars format to input file.

Jump to

Keyboard shortcuts

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