config

package
v1.0.86 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: Apache-2.0 Imports: 12 Imported by: 16

Documentation

Overview

Package config provides utilities for reading and writing cf-mgmt's configuration.

Index

Constants

View Source
const (
	MEGABYTE = 1.0
	GIGABYTE = 1024 * MEGABYTE
	TERABYTE = 1000000 * MEGABYTE
)
View Source
const UNLIMITED = "unlimited"

Variables

View Source
var DefaultProtectedOrgs = []string{
	"^system$",
	"splunk-nozzle-org",
	"redis-test-ORG",
	"appdynamics-org",
	"credhub-service-broker-org",
	"^p-",
}

DefaultProtectedOrgs lists the organizations that are considered protected and should never be deleted by cf-mgmt. Note that these are regexes.

Functions

func AsString added in v1.0.12

func AsString(i *int) string

func ByteSize added in v1.0.12

func ByteSize(bytes *int) string

func DeleteDirectory added in v0.0.68

func DeleteDirectory(path string) error

DeleteDirectory - deletes a directory

func FileOrDirectoryExists added in v0.0.68

func FileOrDirectoryExists(path string) bool

FileOrDirectoryExists - checks if file exists

func FindFiles added in v0.0.68

func FindFiles(configDir, pattern string) ([]string, error)

FindFiles -

func FutureTime added in v1.0.13

func FutureTime(t time.Time, timeToAdd string) (string, error)

func LoadFile added in v0.0.68

func LoadFile(configFile string, dataType interface{}) error

LoadFile -

func LoadFileBytes added in v0.0.68

func LoadFileBytes(path string) ([]byte, error)

LoadFileBytes - Load a file and return the bytes

func RenameDirectory added in v1.0.9

func RenameDirectory(originalDirectory, newDirectory string) error

RenameDirectory -

func StringToMegabytes added in v1.0.12

func StringToMegabytes(s string) (string, error)

func ToInteger added in v1.0.12

func ToInteger(s string) (*int, error)

func ToMegabytes added in v1.0.12

func ToMegabytes(s string) (*int, error)

func WriteFile added in v0.0.68

func WriteFile(configFile string, dataType interface{}) error

WriteFile -

func WriteFileBytes added in v0.0.68

func WriteFileBytes(configFile string, data []byte) error

WriteFileBytes -

Types

type ASGConfig added in v0.0.68

type ASGConfig struct {
	Rules string
	Name  string
}

ASGConfig describes is an array of Rules

type Broker added in v1.0.31

type Broker struct {
	Name     string `yaml:"broker"`
	Services []*Service
}

func (*Broker) GetService added in v1.0.31

func (b *Broker) GetService(serviceName string) *Service

type GlobalConfig added in v0.0.68

type GlobalConfig struct {
	EnableDeleteIsolationSegments  bool                    `yaml:"enable-delete-isolation-segments"`
	EnableUnassignSecurityGroups   bool                    `yaml:"enable-unassign-security-groups"`
	SkipUnassignSecurityGroupRegex string                  `yaml:"skip-unassign-security-group-regex"`
	RunningSecurityGroups          []string                `yaml:"running-security-groups"`
	StagingSecurityGroups          []string                `yaml:"staging-security-groups"`
	SharedDomains                  map[string]SharedDomain `yaml:"shared-domains"`
	EnableDeleteSharedDomains      bool                    `yaml:"enable-remove-shared-domains"`
	MetadataPrefix                 string                  `yaml:"metadata-prefix"`
	EnableServiceAccess            bool                    `yaml:"enable-service-access"`
	IgnoreLegacyServiceAccess      bool                    `yaml:"ignore-legacy-service-access"`
	ServiceAccess                  []*Broker               `yaml:"service-access"`
	ProtectedUsers                 []string                `yaml:"protected-users"`
}

GlobalConfig configuration for global settings

func (*GlobalConfig) GetBroker added in v1.0.31

func (g *GlobalConfig) GetBroker(brokerName string) *Broker

func (*GlobalConfig) GetPlanInfo added in v1.0.31

func (g *GlobalConfig) GetPlanInfo(brokerName, serviceName, planName string) PlanInfo

type LdapConfig added in v1.0.0

type LdapConfig struct {
	Enabled            bool   `yaml:"enabled"`
	LdapHost           string `yaml:"ldapHost"`
	LdapPort           int    `yaml:"ldapPort"`
	TLS                bool   `yaml:"use_tls"`
	BindDN             string `yaml:"bindDN"`
	BindPassword       string `yaml:"bindPwd,omitempty"`
	UserSearchBase     string `yaml:"userSearchBase"`
	UserNameAttribute  string `yaml:"userNameAttribute"`
	UserMailAttribute  string `yaml:"userMailAttribute"`
	UserObjectClass    string `yaml:"userObjectClass"`
	GroupSearchBase    string `yaml:"groupSearchBase"`
	GroupAttribute     string `yaml:"groupAttribute"`
	GroupObjectClass   string `yaml:"groupObjectClass"`
	Origin             string `yaml:"origin"`
	InsecureSkipVerify string `yaml:"insecure_skip_verify"`
	CACert             string `yaml:"ca_cert"`
	UseIDForSAMLUser   bool   `yaml:"useIDForSAMLUser"`
	MinTLSVersion      string `yaml:"minTLSVersion"`
	MaxTLSVersion      string `yaml:"maxTLSVersion"`
}

Config -

type Manager

type Manager interface {
	Updater
	Reader
}

Manager can read and write the cf-mgmt configuration.

func NewManager

func NewManager(configDir string) Manager

NewManager creates a Manager that is backed by a set of YAML files in the specified configuration directory.

type Metadata added in v1.0.26

type Metadata struct {
	Annotations map[string]string `yaml:"annotations"`
	Labels      map[string]string `yaml:"labels"`
}

type OrgConfig added in v0.0.48

type OrgConfig struct {
	Org                        string              `yaml:"org"`
	OriginalOrg                string              `yaml:"original-org,omitempty"`
	BillingManagerGroup        string              `yaml:"org-billingmanager-group,omitempty"`
	ManagerGroup               string              `yaml:"org-manager-group,omitempty"`
	AuditorGroup               string              `yaml:"org-auditor-group,omitempty"`
	BillingManager             UserMgmt            `yaml:"org-billingmanager"`
	Manager                    UserMgmt            `yaml:"org-manager"`
	Auditor                    UserMgmt            `yaml:"org-auditor"`
	PrivateDomains             []string            `yaml:"private-domains"`
	RemovePrivateDomains       bool                `yaml:"enable-remove-private-domains"`
	SharedPrivateDomains       []string            `yaml:"shared-private-domains"`
	RemoveSharedPrivateDomains bool                `yaml:"enable-remove-shared-private-domains"`
	EnableOrgQuota             bool                `yaml:"enable-org-quota"`
	MemoryLimit                string              `yaml:"memory-limit,omitempty"`
	InstanceMemoryLimit        string              `yaml:"instance-memory-limit,omitempty"`
	TotalRoutes                string              `yaml:"total-routes,omitempty"`
	TotalServices              string              `yaml:"total-services,omitempty"`
	PaidServicePlansAllowed    bool                `yaml:"paid-service-plans-allowed"`
	RemoveUsers                bool                `yaml:"enable-remove-users"`
	TotalPrivateDomains        string              `yaml:"total_private_domains,omitempty"`
	TotalReservedRoutePorts    string              `yaml:"total_reserved_route_ports,omitempty"`
	TotalServiceKeys           string              `yaml:"total_service_keys,omitempty"`
	AppInstanceLimit           string              `yaml:"app_instance_limit,omitempty"`
	AppTaskLimit               string              `yaml:"app_task_limit,omitempty"`
	LogRateLimitBytesPerSecond string              `yaml:"log_rate_limit_bytes_per_second,omitempty"`
	DefaultIsoSegment          string              `yaml:"default_isolation_segment"`
	ServiceAccess              map[string][]string `yaml:"service-access,omitempty"`
	NamedQuota                 string              `yaml:"named_quota"`
	Metadata                   *Metadata           `yaml:"metadata"`
}

OrgConfig describes configuration for an org.

func (*OrgConfig) GetAuditorGroups added in v0.0.68

func (o *OrgConfig) GetAuditorGroups() []string

func (*OrgConfig) GetBillingManagerGroups added in v0.0.68

func (o *OrgConfig) GetBillingManagerGroups() []string

func (*OrgConfig) GetManagerGroups added in v0.0.68

func (o *OrgConfig) GetManagerGroups() []string

func (*OrgConfig) GetQuota added in v1.0.12

func (o *OrgConfig) GetQuota() OrgQuota

type OrgQuota added in v1.0.12

type OrgQuota struct {
	Name                       string `yaml:"-"`
	TotalPrivateDomains        string `yaml:"total_private_domains"`
	TotalReservedRoutePorts    string `yaml:"total_reserved_route_ports"`
	TotalServiceKeys           string `yaml:"total_service_keys"`
	AppInstanceLimit           string `yaml:"app_instance_limit"`
	AppTaskLimit               string `yaml:"app_task_limit"`
	MemoryLimit                string `yaml:"memory-limit"`
	InstanceMemoryLimit        string `yaml:"instance-memory-limit"`
	TotalRoutes                string `yaml:"total-routes"`
	TotalServices              string `yaml:"total-services"`
	PaidServicePlansAllowed    bool   `yaml:"paid-service-plans-allowed"`
	LogRateLimitBytesPerSecond string `yaml:"log_rate_limit_bytes_per_second"`
}

type Orgs added in v0.0.68

type Orgs struct {
	Orgs             []string `yaml:"orgs"`
	EnableDeleteOrgs bool     `yaml:"enable-delete-orgs"`
	ProtectedOrgs    []string `yaml:"protected_orgs"`
}

Orgs contains cf-mgmt configuration for all orgs.

func (*Orgs) Contains added in v0.0.68

func (o *Orgs) Contains(orgName string) bool

Contains determines whether an org is present in a list of orgs.

func (*Orgs) ProtectedOrgList added in v1.0.8

func (o *Orgs) ProtectedOrgList() []string

func (*Orgs) Replace added in v1.0.9

func (o *Orgs) Replace(originalOrgName, newOrgName string)

type PlanInfo added in v1.0.31

type PlanInfo struct {
	Limited   bool
	AllAccess bool
	NoAccess  bool
	Orgs      []string
}

type PlanVisibility added in v1.0.31

type PlanVisibility struct {
	Name string   `yaml:"plan,omitempty"`
	Orgs []string `yaml:"orgs,omitempty"`
}

type Reader added in v0.0.68

type Reader interface {
	Orgs() (*Orgs, error)
	OrgSpaces(orgName string) (*Spaces, error)
	Spaces() ([]Spaces, error)
	GetOrgConfigs() ([]OrgConfig, error)
	GetSpaceConfigs() ([]SpaceConfig, error)
	GetASGConfigs() ([]ASGConfig, error)
	GetDefaultASGConfigs() ([]ASGConfig, error)
	GetGlobalConfig() (*GlobalConfig, error)
	GetSpaceDefaults() (*SpaceConfig, error)
	GetOrgConfig(orgName string) (*OrgConfig, error)
	GetSpaceConfig(orgName, spaceName string) (*SpaceConfig, error)
	LdapConfig(bindUser, bindPassword, ldapServer string) (*LdapConfig, error)
	GetOrgQuotas() ([]OrgQuota, error)
	GetSpaceQuotas(org string) ([]SpaceQuota, error)
	GetOrgQuota(name string) (*OrgQuota, error)
	GetSpaceQuota(name, org string) (*SpaceQuota, error)
}

Reader is used to read the cf-mgmt configuration.

type Service added in v1.0.31

type Service struct {
	Name               string            `yaml:"service"`
	AllAccessPlans     []string          `yaml:"all_access_plans,omitempty"`
	LimitedAccessPlans []*PlanVisibility `yaml:"limited_access_plans,omitempty"`
	NoAccessPlans      []string          `yaml:"no_access_plans,omitempty"`
}

func (*Service) AddAllAccessPlan added in v1.0.31

func (s *Service) AddAllAccessPlan(planName string)

func (*Service) AddLimitedAccessPlan added in v1.0.31

func (s *Service) AddLimitedAccessPlan(planName string, orgsToAdd, orgsToRemove []string)

func (*Service) AddNoAccessPlan added in v1.0.31

func (s *Service) AddNoAccessPlan(planName string)

func (*Service) GetLimitedPlan added in v1.0.31

func (s *Service) GetLimitedPlan(planName string) *PlanVisibility

func (*Service) LimitedAccessPlanNames added in v1.0.31

func (s *Service) LimitedAccessPlanNames() []string

type SharedDomain added in v1.0.12

type SharedDomain struct {
	Internal    bool   `yaml:"internal"`
	RouterGroup string `yaml:"router-group,omitempty"`
}

type SpaceConfig added in v0.0.48

type SpaceConfig struct {
	Org                         string    `yaml:"org"`
	Space                       string    `yaml:"space"`
	OriginalSpace               string    `yaml:"original-space,omitempty"`
	Developer                   UserMgmt  `yaml:"space-developer"`
	Manager                     UserMgmt  `yaml:"space-manager"`
	Auditor                     UserMgmt  `yaml:"space-auditor"`
	Supporter                   UserMgmt  `yaml:"space-supporter"`
	DeveloperGroup              string    `yaml:"space-developer-group,omitempty"`
	ManagerGroup                string    `yaml:"space-manager-group,omitempty"`
	AuditorGroup                string    `yaml:"space-auditor-group,omitempty"`
	SupporterGroup              string    `yaml:"space-supporter-group,omitempty"`
	AllowSSH                    bool      `yaml:"allow-ssh"`
	AllowSSHUntil               string    `yaml:"allow-ssh-until,omitempty"`
	EnableSpaceQuota            bool      `yaml:"enable-space-quota"`
	EnableSecurityGroup         bool      `yaml:"enable-security-group"`
	EnableUnassignSecurityGroup bool      `yaml:"enable-unassign-security-group"`
	SecurityGroupContents       string    `yaml:"security-group-contents,omitempty"`
	RemoveUsers                 bool      `yaml:"enable-remove-users"`
	IsoSegment                  string    `yaml:"isolation_segment"`
	ASGs                        []string  `yaml:"named-security-groups"`
	MemoryLimit                 string    `yaml:"memory-limit,omitempty"`
	InstanceMemoryLimit         string    `yaml:"instance-memory-limit,omitempty"`
	TotalRoutes                 string    `yaml:"total-routes,omitempty"`
	TotalServices               string    `yaml:"total-services,omitempty"`
	PaidServicePlansAllowed     bool      `yaml:"paid-service-plans-allowed"`
	TotalReservedRoutePorts     string    `yaml:"total_reserved_route_ports,omitempty"`
	TotalServiceKeys            string    `yaml:"total_service_keys,omitempty"`
	AppInstanceLimit            string    `yaml:"app_instance_limit,omitempty"`
	AppTaskLimit                string    `yaml:"app_task_limit,omitempty"`
	LogRateLimitBytesPerSecond  string    `yaml:"log_rate_limit_bytes_per_second,omitempty"`
	NamedQuota                  string    `yaml:"named_quota"`
	Metadata                    *Metadata `yaml:"metadata"`
}

SpaceConfig describes attributes for a space.

func (*SpaceConfig) GetAuditorGroups added in v0.0.68

func (i *SpaceConfig) GetAuditorGroups() []string

func (*SpaceConfig) GetDeveloperGroups added in v0.0.68

func (i *SpaceConfig) GetDeveloperGroups() []string

func (*SpaceConfig) GetManagerGroups added in v0.0.68

func (i *SpaceConfig) GetManagerGroups() []string

func (*SpaceConfig) GetQuota added in v1.0.12

func (s *SpaceConfig) GetQuota() SpaceQuota

func (*SpaceConfig) GetSecurityGroupContents added in v1.0.26

func (s *SpaceConfig) GetSecurityGroupContents() string

func (*SpaceConfig) GetSupporterGroups added in v1.0.52

func (i *SpaceConfig) GetSupporterGroups() []string

type SpaceQuota added in v1.0.12

type SpaceQuota struct {
	Name                       string `yaml:"-"`
	Org                        string `yaml:"-"`
	MemoryLimit                string `yaml:"memory-limit"`
	InstanceMemoryLimit        string `yaml:"instance-memory-limit"`
	TotalRoutes                string `yaml:"total-routes"`
	TotalServices              string `yaml:"total-services"`
	PaidServicePlansAllowed    bool   `yaml:"paid-service-plans-allowed"`
	TotalReservedRoutePorts    string `yaml:"total_reserved_route_ports"`
	TotalServiceKeys           string `yaml:"total_service_keys"`
	AppInstanceLimit           string `yaml:"app_instance_limit"`
	AppTaskLimit               string `yaml:"app_task_limit"`
	LogRateLimitBytesPerSecond string `yaml:"log_rate_limit_bytes_per_second"`
}

func (*SpaceQuota) IsUnlimitedMemory added in v1.0.12

func (s *SpaceQuota) IsUnlimitedMemory() bool

type Spaces added in v0.0.68

type Spaces struct {
	Org                string   `yaml:"org"`
	Spaces             []string `yaml:"spaces"`
	EnableDeleteSpaces bool     `yaml:"enable-delete-spaces"`
}

Spaces describes cf-mgmt config for all spaces.

func (*Spaces) Contains added in v0.0.68

func (s *Spaces) Contains(spaceName string) bool

Contains determines whether a space is present in a list of spaces.

func (*Spaces) Replace added in v1.0.9

func (s *Spaces) Replace(originalSpaceName, newSpaceName string)

type Updater added in v0.0.68

type Updater interface {
	AddOrgToConfig(orgConfig *OrgConfig) error
	AddSpaceToConfig(spaceConfig *SpaceConfig) error
	AddSecurityGroupToSpace(orgName, spaceName string, securityGroupDefinition []byte) error
	AddSecurityGroup(securityGroupName string, securityGroupDefinition []byte) error
	AddOrgQuota(orgQuota OrgQuota) error
	AddSpaceQuota(spaceQuota SpaceQuota) error
	AddDefaultSecurityGroup(securityGroupName string, securityGroupDefinition []byte) error
	CreateConfigIfNotExists(uaaOrigin string) error
	DeleteConfigIfExists() error

	AssociateOrgAuditor(origin UserOrigin, orgName, user string) error
	AssociateSpaceDeveloper(origin UserOrigin, orgName, spaceName, user string) error
	AssociateSpaceAuditor(origin UserOrigin, orgName, spaceName, user string) error

	SaveOrgSpaces(spaces *Spaces) error
	SaveSpaceConfig(spaceConfig *SpaceConfig) error
	SaveOrgConfig(orgConfig *OrgConfig) error
	RenameOrgConfig(orgConfig *OrgConfig) error
	RenameSpaceConfig(spaceConfig *SpaceConfig) error

	DeleteOrgConfig(orgName string) error
	DeleteSpaceConfig(orgName, spaceName string) error

	SaveOrgs(*Orgs) error
	SaveGlobalConfig(*GlobalConfig) error
	SaveOrgQuota(*OrgQuota) error
	SaveSpaceQuota(*SpaceQuota) error
}

Updater is used to update the cf-mgmt configuration.

type UserMgmt added in v0.0.68

type UserMgmt struct {
	LDAPUsers  []string `yaml:"ldap_users"`
	Users      []string `yaml:"users"`
	SamlUsers  []string `yaml:"saml_users"`
	LDAPGroup  string   `yaml:"ldap_group,omitempty"`
	LDAPGroups []string `yaml:"ldap_groups"`
}

UserMgmt specifies users and groups that can be associated to a particular org or space.

type UserOrigin added in v1.0.45

type UserOrigin int

UserOrigin is an enum type encoding from what source a user originated. Choices are: internal, saml, ldap. If you give a UserOrigin value that lies outside of these options, the behaviour is undefined.

const (
	// InternalOrigin corresponds to a UAA user
	InternalOrigin UserOrigin = iota

	// SAMLOrigin corresponds to a SAML backed user
	SAMLOrigin

	// LDAPOrigin corresponds to a LDAP backed user
	LDAPOrigin
)

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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