Documentation ¶
Index ¶
- Constants
- func FilterOptionDisabled(c *Component) bool
- func FilterOptionEnabled(c *Component) bool
- func FilterOptionFormPod(c *Component) bool
- func FilterOptionFormServer(c *Component) bool
- type Component
- func (c *Component) Check() error
- func (c *Component) Compute(cm *cmdb.CMDB) error
- func (c *Component) DownloadPkg(dstDir string) error
- func (c *Component) GenAnsiblePlay() (*ansible.Play, error)
- func (c *Component) GetRoleName() string
- func (c *Component) GetRoles() []string
- func (c *Component) Merge(in *Component)
- type FilterOption
- type Pkg
- type Product
- func (p *Product) Check(cm *cmdb.CMDB) error
- func (p *Product) ComponentList() []string
- func (p *Product) ComponentListWithFilterOptionsAnd(filterOptions ...FilterOption) []string
- func (p *Product) ComponentListWithFitlerOptionsOr(filterOptions ...FilterOption) []string
- func (p *Product) Compute(cm *cmdb.CMDB) error
- func (p *Product) DefaultPlaybook() string
- func (p *Product) GenSail() (ansible.Playbook, error)
- func (p *Product) HasComponent(name string) bool
- func (p *Product) Init() error
- func (p *Product) LoadZone(zoneVarsFile string) error
- func (p *Product) SailPlaybookFile() string
- func (p *Product) SetComponentEnabled(name string, flag bool) error
- func (p *Product) SetComponentExternalEnabled(name string, flag bool) error
- type Require
- type Role
- type Service
- type ServiceComputed
Constants ¶
View Source
const ( ComponentFormPod = "pod" ComponentFormServer = "server" )
View Source
const DefaultPlaybook string = "sail"
View Source
const DefaultPlaybookFile string = ".sail.yaml"
Variables ¶
This section is empty.
Functions ¶
func FilterOptionDisabled ¶
func FilterOptionEnabled ¶
func FilterOptionFormPod ¶
func FilterOptionFormServer ¶
Types ¶
type Component ¶
type Component struct { Name string `yaml:"-"` Version string `yaml:"version"` // Group can be used to group by components. Group string `yaml:"group"` // If RoleName is empty, it will be set to component Name. RoleName string `yaml:"roleName"` // Form represents the installation method of this component, valid values: // * server // * pod // (组件的部署形态) Form string `yaml:"form"` // Pkgs hold all files that are used to complete the deployment of the component. Pkgs []Pkg `yaml:"pkgs"` // Enabled represents whether this component will be deployed in the specific environment. Enabled bool `yaml:"enabled"` // External represents whether this component is provided by external system like cloud, and thus no need to be deployed. External bool `yaml:"external"` // Services holds all exposed service of the component. // Each service is exposed by a specific port. Services map[string]Service `yaml:"services"` // Computed holds all auto computed service info. // This field SHOULD NEVER be edited or changed by operators. // The field is always automaticllay computed based on other fields of Component. Computed map[string]ServiceComputed `yaml:"computed"` // Requires represents the other components on which this component depends on. // If this component is activated (enabled:true or external:true), then all these required components also need to be activated. // 依赖的服务(其它组件提供的服务,不能依赖自身组件) // Todo, check cycle Requires []Require `yaml:"requires"` // The list value of `deps` represents the other services which depend on this service. // If the number of hosts of this service changed, it required that // those services who depend on it also need to be reconfigured or restarted. // For `service-scaleup` and `service-scaledown`, these dependencies will be used Dependencies []string `yaml:"dependencies"` // Children represents some children-level components of this component. // The children components have the following characteristics: // * They can declared to be activated or not enabled: true or false. // * They can be upgraded like normal components. // * They DO NOT have their own hosts group in ansible inventory, they share the hosts group of its parent component. Children []string `yaml:"children"` // Applied roles for this component. // The empty list will apply at least one role with the component's RoleName. Roles []string `yaml:"roles"` Vars map[string]interface{} `yaml:"vars"` Tags map[string]interface{} `yaml:"tags"` }
Component represents the configuration of a component.
func (*Component) DownloadPkg ¶
func (*Component) GenAnsiblePlay ¶
GenAnsiblePlay generatea a ansible play for this component.
func (*Component) GetRoleName ¶
type FilterOption ¶
func NewFilterOptionByComponentsMap ¶
func NewFilterOptionByComponentsMap(m map[string]string) FilterOption
type Pkg ¶
Pkg represents a package file. We can use the Pkg.File field to check whether those pkg files exists and use the Pkg.URL field to download the file.
type Product ¶
type Product struct { Name string `json:"Name,omitempty" yaml:"Name,omitempty"` // zone specific vars of product Vars map[string]interface{} `json:"Vars,omitempty" yaml:"Vars,omitempty"` // zone specific components of product Components map[string]*Component `json:"Components,omitempty" yaml:"Components,omitempty"` // default vars of product, it is loaded from products/<productName>/vars.yaml DefaultVars map[string]interface{} // default components of product, it is loaded from products/<productName>/{components.yaml,components/*.yaml} DefaultComponents map[string]Component Dir string RolesDir string // contains filtered or unexported fields }
func NewProduct ¶
func (*Product) ComponentList ¶
func (*Product) ComponentListWithFilterOptionsAnd ¶
func (p *Product) ComponentListWithFilterOptionsAnd(filterOptions ...FilterOption) []string
func (*Product) ComponentListWithFitlerOptionsOr ¶
func (p *Product) ComponentListWithFitlerOptionsOr(filterOptions ...FilterOption) []string
func (*Product) DefaultPlaybook ¶
func (*Product) HasComponent ¶
func (*Product) LoadZone ¶
LoadZone will fill zone's specific variables from zoneVarsFile into the Vars and Components fields of product p.
func (*Product) SailPlaybookFile ¶
func (*Product) SetComponentEnabled ¶
type Service ¶
type Service struct { ComponentName string `yaml:"-"` Name string `yaml:"-"` Scheme string `yaml:"scheme"` // Host, IPv4, IPv6 does not means where the component installed. // Host can be domain name or ip address Host string `yaml:"host"` IPv4 string `yaml:"ipv4"` IPv6 string `yaml:"ipv6"` // The port should be set to the actual port on which the process listend, // thus ansible playbook can use this variable to render configuration files. Port int `yaml:"port"` Addr string `yaml:"addr"` Path string `yaml:"path"` Addrs []string `yaml:"addrs"` Endpoints []string `yaml:"endpoints"` URLs []string `yaml:"urls"` PubPort int `yaml:"pubPort"` LBPort int `yaml:"lbPort"` }
Service represents the service exposed by component.
func NewService ¶
NewService returns a service
type ServiceComputed ¶
type ServiceComputed struct { Scheme string `yaml:"scheme"` Host string `yaml:"host"` Port int `yaml:"port"` Addr string `yaml:"addr"` Path string `yaml:"path"` Hosts []string `yaml:"hosts"` Addrs []string `yaml:"addrs"` Endpoints []string `yaml:"endpoints"` URLs []string `yaml:"urls"` }
ServiceComputed represents the computed configuration for a service.
func NewServiceComputed ¶
func NewServiceComputed() *ServiceComputed
NewServiceComputed returns a computed service.
Click to show internal directories.
Click to hide internal directories.