config

package
v0.0.0-...-f54f16c Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ROOT_CA             = "root_ca"
	PUBLIC_KEY          = "public_key"
	PRIVATE_KEY         = "private_key"
	ADMIN_KEY           = "admin_key"
	ADMIN_CERT          = "admin_cert"
	AUTOMATE            = "automate"
	CHEFSERVER          = "chef-infra-server"
	POSTGRESQL          = "postgresql"
	OPENSEARCH          = "opensearch"
	BASTION             = "bastion"
	INVALID_EMPTY_VALUE = "invalid or empty: %s"
	EMPTY_VALUE         = "empty value: %s"
	INVALID_STRING_TYPE = "invalid string type: %s"
	INVALID_FIELD_VALUE = "invalid value '%s' for field '%s'"
	INVALID_PORT_NUMBER = "invalid value '%s' for field '%s' port number must be between 1 and 65535"
	AWS                 = "aws"
	SELF_MANAGED        = "self-managed"
)
View Source
const (
	AWS_S3      = "s3"
	GCS_STORAGE = "gcs"
)

Variables

This section is empty.

Functions

func GetNameServersFromResolveConfig

func GetNameServersFromResolveConfig(filePath string) ([]string, error)

GetNameServersFromResolveConfig parses a file in the format of /etc/resolv.conf The resolve.conf format is described in resolv.conf(5):

https://man7.org/linux/man-pages/man5/resolv.conf.5.html

This function looks up at the lines starting with `nameserver`. There can be a single nameserver each line and maximum 3 (defined my MAXNS in resolv.h) in the file.

func GetSystemResolvers

func GetSystemResolvers() []string

GetSystemResolvers returns resolvers discovered via /etc/resolv.conf. If not valid resolvers are found, an empty array is returned.

func ParseNameServers

func ParseNameServers(fileContent []byte) []string

ParseNameServers parses an array of bytes and returns the nameservers The content should be of format of /etc/resolv.conf i.e. nameserver 12.0.0.3

Types

type Architecture

type Architecture struct {
	ExistingInfra *ConfigInitials `toml:"existing_infra,omitempty"`
	Aws           *ConfigInitials `toml:"aws,omitempty"`
}

func (*Architecture) InitAws

func (c *Architecture) InitAws() *ConfigInitials

func (*Architecture) InitExistingInfra

func (c *Architecture) InitExistingInfra() *ConfigInitials

type AutomateSettings

type AutomateSettings struct {
	Config *ConfigAutomateSettings `toml:"config,omitempty"`
}

func (*AutomateSettings) InitConfig

func (c *AutomateSettings) InitConfig() *ConfigAutomateSettings

type AwsExternalOsSettings

type AwsExternalOsSettings struct {
	AwsOsSnapshotRoleArn          string `toml:"aws_os_snapshot_role_arn,omitempty"`
	OsSnapshotUserAccessKeyID     string `toml:"os_snapshot_user_access_key_id,omitempty"`
	OsSnapshotUserAccessKeySecret string `toml:"os_snapshot_user_access_key_secret,omitempty"`
}

type AwsSettings

type AwsSettings struct {
	Config *ConfigAwsSettings `toml:"config,omitempty"`
}

func (*AwsSettings) InitConfigAwsSettings

func (c *AwsSettings) InitConfigAwsSettings() *ConfigAwsSettings

type CertByIP

type CertByIP struct {
	IP         string `toml:"ip,omitempty"`
	PrivateKey string `toml:"private_key,omitempty"`
	PublicKey  string `toml:"public_key,omitempty"`
	NodesDn    string `toml:"nodes_dn,omitempty"`
}

type ChefServerSettings

type ChefServerSettings struct {
	Config *ConfigChefServerSettings `toml:"config,omitempty"`
}

func (*ChefServerSettings) InitConfig

type ConfigAutomateSettings

type ConfigAutomateSettings struct {
	AdminPassword     string      `toml:"admin_password,omitempty"`
	Fqdn              string      `toml:"fqdn,omitempty"`
	ConfigFile        string      `toml:"config_file,omitempty"`
	TeamsPort         string      `toml:"teams_port,omitempty"`
	FqdnRootCA        string      `toml:"root_ca,omitempty"`
	InstanceCount     string      `toml:"instance_count,omitempty"`
	EnableCustomCerts bool        `toml:"enable_custom_certs,omitempty"`
	PrivateKey        string      `toml:"private_key,omitempty"`
	PublicKey         string      `toml:"public_key,omitempty"`
	CertsByIP         *[]CertByIP `toml:"certs_by_ip,omitempty"`
}

func (*ConfigAutomateSettings) InitCertsByIP

func (c *ConfigAutomateSettings) InitCertsByIP() *[]CertByIP

type ConfigAwsSettings

type ConfigAwsSettings struct {
	Profile                       string   `toml:"profile,omitempty"`
	Region                        string   `toml:"region,omitempty"`
	AwsVpcID                      string   `toml:"aws_vpc_id,omitempty"`
	AwsCidrBlockAddr              string   `toml:"aws_cidr_block_addr,omitempty"`
	PrivateCustomSubnets          []string `toml:"private_custom_subnets,omitempty"`
	PublicCustomSubnets           []string `toml:"public_custom_subnets,omitempty"`
	SSHKeyPairName                string   `toml:"ssh_key_pair_name,omitempty"`
	SetupManagedServices          bool     `toml:"setup_managed_services,omitempty"`
	ManagedOpensearchDomainName   string   `toml:"managed_opensearch_domain_name,omitempty"`
	ManagedOpensearchDomainURL    string   `toml:"managed_opensearch_domain_url,omitempty"`
	ManagedOpensearchUsername     string   `toml:"managed_opensearch_username,omitempty"`
	ManagedOpensearchUserPassword string   `toml:"managed_opensearch_user_password,omitempty"`
	ManagedOpensearchCertificate  string   `toml:"managed_opensearch_certificate,omitempty"`
	AwsOsSnapshotRoleArn          string   `toml:"aws_os_snapshot_role_arn"`
	OsSnapshotUserAccessKeyID     string   `toml:"os_snapshot_user_access_key_id"`
	OsSnapshotUserAccessKeySecret string   `toml:"os_snapshot_user_access_key_secret"`
	ManagedRdsInstanceURL         string   `toml:"managed_rds_instance_url,omitempty"`
	ManagedRdsSuperuserUsername   string   `toml:"managed_rds_superuser_username,omitempty"`
	ManagedRdsSuperuserPassword   string   `toml:"managed_rds_superuser_password,omitempty"`
	ManagedRdsDbuserUsername      string   `toml:"managed_rds_dbuser_username,omitempty"`
	ManagedRdsDbuserPassword      string   `toml:"managed_rds_dbuser_password,omitempty"`
	ManagedRdsCertificate         string   `toml:"managed_rds_certificate,omitempty"`
	AmiID                         string   `toml:"ami_id,omitempty"`
	DeleteOnTermination           bool     `toml:"delete_on_termination,omitempty"`
	AutomateServerInstanceType    string   `toml:"automate_server_instance_type,omitempty"`
	ChefServerInstanceType        string   `toml:"chef_server_instance_type,omitempty"`
	OpensearchServerInstanceType  string   `toml:"opensearch_server_instance_type,omitempty"`
	PostgresqlServerInstanceType  string   `toml:"postgresql_server_instance_type,omitempty"`
	AutomateLbCertificateArn      string   `toml:"automate_lb_certificate_arn,omitempty"`
	ChefServerLbCertificateArn    string   `toml:"chef_server_lb_certificate_arn,omitempty"`
	ChefEbsVolumeIops             string   `toml:"chef_ebs_volume_iops,omitempty"`
	ChefEbsVolumeSize             string   `toml:"chef_ebs_volume_size,omitempty"`
	ChefEbsVolumeType             string   `toml:"chef_ebs_volume_type,omitempty"`
	OpensearchEbsVolumeIops       string   `toml:"opensearch_ebs_volume_iops,omitempty"`
	OpensearchEbsVolumeSize       string   `toml:"opensearch_ebs_volume_size,omitempty"`
	OpensearchEbsVolumeType       string   `toml:"opensearch_ebs_volume_type,omitempty"`
	PostgresqlEbsVolumeIops       string   `toml:"postgresql_ebs_volume_iops,omitempty"`
	PostgresqlEbsVolumeSize       string   `toml:"postgresql_ebs_volume_size,omitempty"`
	PostgresqlEbsVolumeType       string   `toml:"postgresql_ebs_volume_type,omitempty"`
	AutomateEbsVolumeIops         string   `toml:"automate_ebs_volume_iops,omitempty"`
	AutomateEbsVolumeSize         string   `toml:"automate_ebs_volume_size,omitempty"`
	AutomateEbsVolumeType         string   `toml:"automate_ebs_volume_type,omitempty"`
	AmiFilterName                 string   `toml:"ami_filter_name,omitempty"`
	AmiFilterVirtType             string   `toml:"ami_filter_virt_type,omitempty"`
	AmiFilterOwner                string   `toml:"ami_filter_owner,omitempty"`
	LbAccessLogs                  string   `toml:"lb_access_logs,omitempty"`
	XContact                      string   `toml:"X-Contact,omitempty"`
	XDept                         string   `toml:"X-Dept,omitempty"`
	XProject                      string   `toml:"X-Project,omitempty"`
}

type ConfigChefServerSettings

type ConfigChefServerSettings struct {
	ChefServerFqdn    string      `toml:"fqdn,omitempty"`
	FqdnRootCA        string      `toml:"lb_root_ca,omitempty"`
	InstanceCount     string      `toml:"instance_count,omitempty"`
	EnableCustomCerts bool        `toml:"enable_custom_certs,omitempty"`
	PrivateKey        string      `toml:"private_key,omitempty"`
	PublicKey         string      `toml:"public_key,omitempty"`
	CertsByIP         *[]CertByIP `toml:"certs_by_ip,omitempty"`
}

func (*ConfigChefServerSettings) InitCertsByIP

func (c *ConfigChefServerSettings) InitCertsByIP() *[]CertByIP

type ConfigExistingInfraSettings

type ConfigExistingInfraSettings struct {
	AutomatePrivateIps   []string `toml:"automate_private_ips,omitempty"`
	ChefServerPrivateIps []string `toml:"chef_server_private_ips,omitempty"`
	OpensearchPrivateIps []string `toml:"opensearch_private_ips,omitempty"`
	PostgresqlPrivateIps []string `toml:"postgresql_private_ips,omitempty"`
}

type ConfigInitials

type ConfigInitials struct {
	SSHUser                     string `toml:"ssh_user,omitempty"`
	SSHGroupName                string `toml:"ssh_group_name,omitempty"`
	SSHKeyFile                  string `toml:"ssh_key_file,omitempty"`
	SSHPort                     string `toml:"ssh_port,omitempty"`
	SecretsKeyFile              string `toml:"secrets_key_file,omitempty"`
	SecretsStoreFile            string `toml:"secrets_store_file,omitempty"`
	SudoPassword                string `toml:"sudo_password,omitempty"`
	LoggingMonitoringManagement string `toml:"logging_monitoring_management,omitempty"`
	Architecture                string `toml:"architecture,omitempty"`
	WorkspacePath               string `toml:"workspace_path,omitempty"`
	BackupMount                 string `toml:"backup_mount,omitempty"`
	BackupConfig                string `toml:"backup_config,omitempty"`
	S3BucketName                string `toml:"s3_bucketName,omitempty"`
	HabitatUIDGid               string `toml:"habitat_uid_gid,omitempty"`
}

type ConfigObjectStorage

type ConfigObjectStorage struct {
	Location                 string             `toml:"location,omitempty"`
	BucketName               string             `toml:"bucket_name,omitempty"`
	AccessKey                string             `toml:"access_key,omitempty"`
	SecretKey                string             `toml:"secret_key,omitempty"`
	Endpoint                 string             `toml:"endpoint,omitempty"`
	Region                   string             `toml:"region,omitempty"`
	GoogleServiceAccountFile string             `toml:"google_service_account_file"`
	GcpServiceAccount        *GcpServiceAccount `toml:"gcp_service_account,omitempty"`
}

type ConfigOpensearchSettings

type ConfigOpensearchSettings struct {
	AdminCert         string      `toml:"admin_cert,omitempty"`
	AdminKey          string      `toml:"admin_key,omitempty"`
	AdminDn           string      `toml:"admin_dn,omitempty"`
	NodesDn           string      `toml:"nodes_dn,omitempty"`
	RootCA            string      `toml:"root_ca,omitempty"`
	InstanceCount     string      `toml:"instance_count,omitempty"`
	EnableCustomCerts bool        `toml:"enable_custom_certs,omitempty"`
	PrivateKey        string      `toml:"private_key,omitempty"`
	PublicKey         string      `toml:"public_key,omitempty"`
	CertsByIP         *[]CertByIP `toml:"certs_by_ip,omitempty"`
}

func (*ConfigOpensearchSettings) InitCertsByIP

func (c *ConfigOpensearchSettings) InitCertsByIP() *[]CertByIP

type ConfigSettings

type ConfigSettings struct {
	RootCA            string      `toml:"root_ca,omitempty"`
	InstanceCount     string      `toml:"instance_count,omitempty"`
	EnableCustomCerts bool        `toml:"enable_custom_certs,omitempty"`
	PrivateKey        string      `toml:"private_key,omitempty"`
	PublicKey         string      `toml:"public_key,omitempty"`
	CertsByIP         *[]CertByIP `toml:"certs_by_ip,omitempty"`
}

func (*ConfigSettings) InitCertsByIP

func (c *ConfigSettings) InitCertsByIP() *[]CertByIP

type ExistingInfraSettings

type ExistingInfraSettings struct {
	Config *ConfigExistingInfraSettings `toml:"config,omitempty"`
}

func (*ExistingInfraSettings) InitConfig

type ExternalDBSettings

type ExternalDBSettings struct {
	Type       string              `toml:"type,omitempty"`
	PostgreSQL *ExternalPgSettings `toml:"postgre_sql,omitempty"`
	OpenSearch *ExternalOsSettings `toml:"open_search,omitempty"`
}

func (*ExternalDBSettings) InitOpenSearch

func (c *ExternalDBSettings) InitOpenSearch() *ExternalOsSettings

func (*ExternalDBSettings) InitPostgresql

func (c *ExternalDBSettings) InitPostgresql() *ExternalPgSettings

type ExternalOsSettings

type ExternalOsSettings struct {
	OpensearchDomainName   string                 `toml:"opensearch_domain_name,omitempty"`
	OpensearchDomainURL    string                 `toml:"opensearch_domain_url,omitempty"`
	OpensearchUsername     string                 `toml:"opensearch_username,omitempty"`
	OpensearchUserPassword string                 `toml:"opensearch_user_password,omitempty"`
	OpensearchCertificate  string                 `toml:"opensearch_certificate,omitempty"`
	OpensearchRootCert     string                 `toml:"opensearch_root_cert,omitempty"`
	Aws                    *AwsExternalOsSettings `toml:"aws,omitempty"`
}

func (*ExternalOsSettings) InitOpenSearchAws

func (c *ExternalOsSettings) InitOpenSearchAws() *AwsExternalOsSettings

type ExternalPgSettings

type ExternalPgSettings struct {
	InstanceURL           string `toml:"instance_url,omitempty"`
	SuperuserUsername     string `toml:"superuser_username,omitempty"`
	SuperuserPassword     string `toml:"superuser_password,omitempty"`
	DbuserUsername        string `toml:"dbuser_username,omitempty"`
	DbuserPassword        string `toml:"dbuser_password,omitempty"`
	PostgresqlRootCert    string `toml:"postgresql_root_cert,omitempty"`
	PostgreSQLCertificate string `toml:"postgresql_certificate,omitempty"`
}

type ExternalSettings

type ExternalSettings struct {
	Database *ExternalDBSettings `toml:"database,omitempty"`
}

func (*ExternalSettings) InitDatabase

func (c *ExternalSettings) InitDatabase() *ExternalDBSettings

type GcpServiceAccount

type GcpServiceAccount struct {
	Type                    string `json:"type"`
	ProjectID               string `json:"project_id"`
	PrivateKeyID            string `json:"private_key_id"`
	PrivateKey              string `json:"private_key"`
	ClientEmail             string `json:"client_email"`
	ClientID                string `json:"client_id"`
	AuthURI                 string `json:"auth_uri"`
	TokenURI                string `json:"token_uri"`
	AuthProviderX509CertURL string `json:"auth_provider_x509_cert_url"`
	ClientX509CertURL       string `json:"client_x509_cert_url"`
	UniverseDomain          string `json:"universe_domain"`
}

type HaDeployConfig

type HaDeployConfig struct {
	Architecture  *Architecture          `toml:"architecture,omitempty"`
	ObjectStorage *ObjectStorage         `toml:"object_storage,omitempty"`
	Automate      *AutomateSettings      `toml:"automate,omitempty"`
	ChefServer    *ChefServerSettings    `toml:"chef_server,omitempty"`
	Opensearch    *OpensearchSettings    `toml:"opensearch,omitempty"`
	Postgresql    *PostgresqlSettings    `toml:"postgresql,omitempty"`
	ExistingInfra *ExistingInfraSettings `toml:"existing_infra,omitempty"`
	Aws           *AwsSettings           `toml:"aws,omitempty"`
	External      *ExternalSettings      `toml:"external,omitempty"`
}

func NewHaDeployConfig

func NewHaDeployConfig() *HaDeployConfig

func (*HaDeployConfig) GetConfigInitials

func (config *HaDeployConfig) GetConfigInitials() *ConfigInitials

func (*HaDeployConfig) GetObjectStorageConfig

func (config *HaDeployConfig) GetObjectStorageConfig() *ConfigObjectStorage

func (*HaDeployConfig) InitArchitecture

func (c *HaDeployConfig) InitArchitecture() *Architecture

func (*HaDeployConfig) InitAutomate

func (c *HaDeployConfig) InitAutomate() *AutomateSettings

func (*HaDeployConfig) InitAws

func (c *HaDeployConfig) InitAws() *AwsSettings

func (*HaDeployConfig) InitChefServer

func (c *HaDeployConfig) InitChefServer() *ChefServerSettings

func (*HaDeployConfig) InitExistingInfra

func (c *HaDeployConfig) InitExistingInfra() *ExistingInfraSettings

func (*HaDeployConfig) InitExternal

func (c *HaDeployConfig) InitExternal() *ExternalSettings

func (*HaDeployConfig) InitObjectStorage

func (c *HaDeployConfig) InitObjectStorage() *ObjectStorage

func (*HaDeployConfig) InitOpenSearch

func (c *HaDeployConfig) InitOpenSearch() *OpensearchSettings

func (*HaDeployConfig) InitPostgresql

func (c *HaDeployConfig) InitPostgresql() *PostgresqlSettings

func (*HaDeployConfig) IsAws

func (c *HaDeployConfig) IsAws() bool

func (*HaDeployConfig) IsAwsExternalOsConfigured

func (c *HaDeployConfig) IsAwsExternalOsConfigured() bool

func (*HaDeployConfig) IsExistingInfra

func (c *HaDeployConfig) IsExistingInfra() bool

func (*HaDeployConfig) IsExternalDb

func (c *HaDeployConfig) IsExternalDb() bool

func (*HaDeployConfig) IsExternalDbSelfManaged

func (c *HaDeployConfig) IsExternalDbSelfManaged() bool

func (*HaDeployConfig) IsValidHaDeployConfig

func (c *HaDeployConfig) IsValidHaDeployConfig() bool

func (*HaDeployConfig) Parse

func (c *HaDeployConfig) Parse(configFile string) error

func (*HaDeployConfig) ParseAndVerify

func (c *HaDeployConfig) ParseAndVerify(configFile string) error

func (*HaDeployConfig) Verify

func (c *HaDeployConfig) Verify() error

type Manager

type Manager struct {
	Config interface{}
	// contains filtered or unexported fields
}

Manager - configuration manager for the service

This manager is multiple goroutines safe. Multiple goroutines can use one of these objects, and data updates are performed asynchronously. When an update function is pushed onto a channel, a single goroutine handles the update. When an update occurs the data is written to the config file. Read access is synchronous, where there is some time between seeing updates to the data. This is patterned after Akka's Agents (https://doc.akka.io/docs/akka/2.5.6/java/agents.html)

func NewManager

func NewManager(configFile string, initialConfig interface{}) *Manager

NewManager - create a new config. There should only be one config for the service.

func (*Manager) Close

func (manager *Manager) Close()

Close - to close out the channel for this object. This should only be called when the service is being shutdown

func (*Manager) UpdateConfig

func (manager *Manager) UpdateConfig(updateFunc func(interface{}) (interface{}, error)) error

UpdateConfig - update the config

type ObjectStorage

type ObjectStorage struct {
	Config *ConfigObjectStorage `toml:"config,omitempty"`
}

func (*ObjectStorage) InitConfig

func (c *ObjectStorage) InitConfig() *ConfigObjectStorage

type OpensearchSettings

type OpensearchSettings struct {
	Config *ConfigOpensearchSettings `toml:"config,omitempty"`
}

func (*OpensearchSettings) InitConfig

type PostgresqlSettings

type PostgresqlSettings struct {
	Config *ConfigSettings `toml:"config,omitempty"`
}

func (*PostgresqlSettings) InitConfig

func (c *PostgresqlSettings) InitConfig() *ConfigSettings

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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