Documentation ¶
Overview ¶
Package resources defines the command execution logic.
Index ¶
- Constants
- func AnalyseBackendExist(jsonStr string) (interface{}, error)
- func ConfigOneBackend(backendConfig *BackendConfiguration) error
- func FetchBackendConfig(namespace string, names ...string) (map[string]*BackendConfiguration, error)
- func FetchConfiguredBackends(namespace string) (map[string]*BackendConfiguration, error)
- func LoadBackendsFromConfigMap(configmap corev1.ConfigMap, fromLocalFile string) (map[string]*BackendConfiguration, error)
- func LoadBackendsFromJson(filename string) (map[string]*BackendConfiguration, error)
- func LoadBackendsFromYaml(filename string) (map[string]*BackendConfiguration, error)
- func RegisterCollector(name PodType, collector FileLogsCollect)
- func RegisterIdentifyPodTypeFunc(name PodType, f func(pod *coreV1.Pod) bool)
- type Backend
- type BackendConfigShow
- type BackendConfiguration
- type BackendShow
- type BackendShowWide
- func (b *BackendShowWide) ShowWithClaimOption(claim xuanwuv1.StorageBackendClaim) *BackendShowWide
- func (b *BackendShowWide) ShowWithConfigOption(configuration BackendConfiguration) *BackendShowWide
- func (b *BackendShowWide) ShowWithContentOption(content xuanwuv1.StorageBackendContent) *BackendShowWide
- func (b *BackendShowWide) ToBackendShow() BackendShow
- type BaseFileLogsCollect
- type Cert
- type CertConfig
- type CertShow
- type ConfigMapConfig
- type Display
- type FileLogsCollect
- type FileLogsCollector
- type Logs
- type NodeLogCollector
- type PodType
- type Resource
- type ResourceBuilder
- func (b *ResourceBuilder) AllNamespaces(allNamespace bool) *ResourceBuilder
- func (b *ResourceBuilder) AllNodes(isAllNodes bool) *ResourceBuilder
- func (b *ResourceBuilder) BoundBackend(backend string) *ResourceBuilder
- func (b *ResourceBuilder) Build() *Resource
- func (b *ResourceBuilder) DefaultNamespace() *ResourceBuilder
- func (b *ResourceBuilder) FileName(fileName string) *ResourceBuilder
- func (b *ResourceBuilder) FileType(fileType string) *ResourceBuilder
- func (b *ResourceBuilder) MaxNodeThreads(maxNodeThreads int) *ResourceBuilder
- func (b *ResourceBuilder) Names(names ...string) *ResourceBuilder
- func (b *ResourceBuilder) NamespaceParam(namespace string) *ResourceBuilder
- func (b *ResourceBuilder) NodeName(nodeName string) *ResourceBuilder
- func (b *ResourceBuilder) Output(output string) *ResourceBuilder
- func (b *ResourceBuilder) ResourceNames(resource string, names ...string) *ResourceBuilder
- func (b *ResourceBuilder) ResourceTypes(types ...string) *ResourceBuilder
- func (b *ResourceBuilder) SelectAll(selectAll bool) *ResourceBuilder
- func (b *ResourceBuilder) Selector(selector string) *ResourceBuilder
- type SecretConfig
- type Status
- type StorageBackendClaimConfig
- type TransmitTask
- type Validator
- type ValidatorBuilder
- func (b *ValidatorBuilder) Build() *Validator
- func (b *ValidatorBuilder) ValidateBackend() *ValidatorBuilder
- func (b *ValidatorBuilder) ValidateNameIsExist() *ValidatorBuilder
- func (b *ValidatorBuilder) ValidateNameIsSingle() *ValidatorBuilder
- func (b *ValidatorBuilder) ValidateOutputFormat() *ValidatorBuilder
- func (b *ValidatorBuilder) ValidateSelector() *ValidatorBuilder
Constants ¶
const ( // ApiVersion is the version of meta type ApiVersion = "v1" // XuanWuApiVersion is the version of xuanwu api XuanWuApiVersion = "xuanwu.huawei.io/v1" // KindSecret is secret kind string KindSecret = "Secret" // KindConfigMap is the configmap kind string KindConfigMap = "ConfigMap" // KindStorageBackendClaim is the storage backend claim kind string KindStorageBackendClaim = "StorageBackendClaim" // YamlSeparator defines the separator of yaml file YamlSeparator = "---" )
Variables ¶
This section is empty.
Functions ¶
func AnalyseBackendExist ¶
AnalyseBackendExist analyse backend,an error is returned if backends not exist
func ConfigOneBackend ¶
func ConfigOneBackend(backendConfig *BackendConfiguration) error
ConfigOneBackend config one backend
func FetchBackendConfig ¶
func FetchBackendConfig(namespace string, names ...string) (map[string]*BackendConfiguration, error)
FetchBackendConfig fetch backend config from configmap
func FetchConfiguredBackends ¶
func FetchConfiguredBackends(namespace string) (map[string]*BackendConfiguration, error)
FetchConfiguredBackends to fetch backend configuration
func LoadBackendsFromConfigMap ¶
func LoadBackendsFromConfigMap(configmap corev1.ConfigMap, fromLocalFile string) (map[string]*BackendConfiguration, error)
LoadBackendsFromConfigMap load backend from configmap resource. fromLocalFile should be "" if the configmap is from kubernetes.
func LoadBackendsFromJson ¶
func LoadBackendsFromJson(filename string) (map[string]*BackendConfiguration, error)
LoadBackendsFromJson load backend from json bytes
func LoadBackendsFromYaml ¶
func LoadBackendsFromYaml(filename string) (map[string]*BackendConfiguration, error)
LoadBackendsFromYaml load backend from yaml
func RegisterCollector ¶
func RegisterCollector(name PodType, collector FileLogsCollect)
RegisterCollector used to register a collector into the collectorSet
Types ¶
type Backend ¶
type Backend struct {
// contains filtered or unexported fields
}
Backend is a storage backend object
func NewBackend ¶
NewBackend initialize a Backend instance
func (*Backend) LoadBackendFile ¶
func (b *Backend) LoadBackendFile() (map[string]*BackendConfiguration, error)
LoadBackendFile to load backend defined file on disk, the file type can be "json" or "yaml"
type BackendConfigShow ¶
type BackendConfigShow struct { Number string `show:"NUMBER"` Configured string `show:"CONFIGURED"` Name string `show:"NAME"` Storage string `show:"STORAGE"` Urls string `show:"URLS"` }
BackendConfigShow the content echoed by executing the oceanctl create backend
type BackendConfiguration ¶
type BackendConfiguration struct { Name string `json:"name,omitempty" yaml:"name"` NameSpace string `json:"namespace,omitempty" yaml:"namespace"` Storage string `json:"storage,omitempty" yaml:"storage"` VstoreName string `json:"vstoreName,omitempty" yaml:"vstoreName"` AccountName string `json:"accountName,omitempty" yaml:"accountName"` Urls []string `json:"urls,omitempty" yaml:"urls"` Pools []string `json:"pools,omitempty" yaml:"pools"` MetrovStorePairID string `json:"metrovStorePairID,omitempty" yaml:"metrovStorePairID"` MetroBackend string `json:"metroBackend,omitempty" yaml:"metroBackend"` SupportedTopologies []map[string]interface{} `json:"supportedTopologies,omitempty" yaml:"supportedTopologies"` MaxClientThreads string `json:"maxClientThreads,omitempty" yaml:"maxClientThreads"` Configured bool `json:"-" yaml:"configured"` Provisioner string `json:"provisioner,omitempty" yaml:"provisioner"` Parameters struct { Protocol string `json:"protocol,omitempty" yaml:"protocol"` ParentName string `json:"parentname,omitempty" yaml:"parentname"` Portals interface{} `json:"portals,omitempty" yaml:"portals"` Alua map[string]map[string]interface{} `json:"ALUA,omitempty" yaml:"ALUA"` } `json:"parameters,omitempty" yaml:"parameters"` }
BackendConfiguration backend config
func LoadMultipleBackendFromConfigmap ¶
func LoadMultipleBackendFromConfigmap(jsonStr string) ([]*BackendConfiguration, error)
LoadMultipleBackendFromConfigmap load multiple backend
func LoadSingleBackendFromConfigmap ¶
func LoadSingleBackendFromConfigmap(jsonStr string) ([]*BackendConfiguration, error)
LoadSingleBackendFromConfigmap load single backend
func MergeBackends ¶
func MergeBackends(notConfigured, configured map[string]*BackendConfiguration) []*BackendConfiguration
MergeBackends to merge two backend configuration
func (*BackendConfiguration) ToConfigMapConfig ¶
func (b *BackendConfiguration) ToConfigMapConfig() (ConfigMapConfig, error)
ToConfigMapConfig convert backend to helper.ConfigMapConfig
func (*BackendConfiguration) ToSecretConfig ¶
func (b *BackendConfiguration) ToSecretConfig() (SecretConfig, error)
ToSecretConfig convert backend to helper.SecretConfig If start stdin failed, an error will return.
func (*BackendConfiguration) ToStorageBackendClaimConfig ¶
func (b *BackendConfiguration) ToStorageBackendClaimConfig() StorageBackendClaimConfig
ToStorageBackendClaimConfig covert backend to StorageBackendClaimConfig
type BackendShow ¶
type BackendShow struct { Namespace string `show:"NAMESPACE"` Name string `show:"NAME"` Protocol string `show:"PROTOCOL"` StorageType string `show:"STORAGETYPE"` Sn string `show:"SN"` Status string `show:"STATUS"` Online string `show:"ONLINE"` Url string `show:"Url"` }
BackendShow the content echoed by executing the oceanctl get backend
type BackendShowWide ¶
type BackendShowWide struct { Namespace string `show:"NAMESPACE"` Name string `show:"NAME"` Protocol string `show:"PROTOCOL"` StorageType string `show:"STORAGETYPE"` Sn string `show:"SN"` Status string `show:"STATUS"` Online string `show:"ONLINE"` Url string `show:"Url"` VendorName string `show:"VENDORNAME"` StorageBackendContentName string `show:"STORAGEBACKENDCONTENTNAME"` }
BackendShowWide the content echoed by executing the oceanctl get backend -o wide
func (*BackendShowWide) ShowWithClaimOption ¶
func (b *BackendShowWide) ShowWithClaimOption(claim xuanwuv1.StorageBackendClaim) *BackendShowWide
ShowWithClaimOption set StorageBackendClaim value for BackendShowWide
func (*BackendShowWide) ShowWithConfigOption ¶
func (b *BackendShowWide) ShowWithConfigOption(configuration BackendConfiguration) *BackendShowWide
ShowWithConfigOption set BackendConfiguration value for BackendShowWide
func (*BackendShowWide) ShowWithContentOption ¶
func (b *BackendShowWide) ShowWithContentOption(content xuanwuv1.StorageBackendContent) *BackendShowWide
ShowWithContentOption set StorageBackendContent value for BackendShowWide
func (*BackendShowWide) ToBackendShow ¶
func (b *BackendShowWide) ToBackendShow() BackendShow
ToBackendShow convert BackendShowWide to BackendShow
type BaseFileLogsCollect ¶
type BaseFileLogsCollect struct{}
BaseFileLogsCollect collect file logs.
func (*BaseFileLogsCollect) CopyToLocal ¶
func (b *BaseFileLogsCollect) CopyToLocal(namespace, nodeName, podName, containerName string) error
CopyToLocal copy the compressed log file to the local host.
func (*BaseFileLogsCollect) GetHostInformation ¶
func (b *BaseFileLogsCollect) GetHostInformation(namespace, containerName, nodeName, podName string) error
GetHostInformation get the host information of a specified node.
type Cert ¶
type Cert struct {
// contains filtered or unexported fields
}
Cert is the cert resource
func (*Cert) LoadCertFile ¶
func (c *Cert) LoadCertFile() (*CertConfig, error)
LoadCertFile to load cert file from disk
func (*Cert) LoadCertsFromDate ¶
func (c *Cert) LoadCertsFromDate(Data []byte) (*CertConfig, error)
LoadCertsFromDate load cert from bytes
type CertConfig ¶
CertConfig used to create a cert object
func (*CertConfig) ToCertSecret ¶
func (c *CertConfig) ToCertSecret() corev1.Secret
ToCertSecret convert CertSecretConfig to Secret resource
type CertShow ¶
type CertShow struct { Namespace string `show:"NAMESPACE"` Name string `show:"NAME"` BoundBackend string `show:"BOUNDBACKEND"` }
CertShow the content echoed by executing the oceanctl get cert
type ConfigMapConfig ¶
ConfigMapConfig used to create a configmap object
func (*ConfigMapConfig) ToConfigMap ¶
func (c *ConfigMapConfig) ToConfigMap() corev1.ConfigMap
ToConfigMap convert ConfigMapConfig to ConfigMap resource
type Display ¶
type Display struct {
// contains filtered or unexported fields
}
Display Collects the progress display function of all nodes to display the progress.
type FileLogsCollect ¶
type FileLogsCollect interface { GetFileLogs(namespace, podName, nodeName, fileLogPath string) (err error) GetHostInformation(namespace, containerName, nodeName, podName string) error CopyToLocal(namespace, nodeName, podName, containerName string) error }
FileLogsCollect is the interface to collect file logs.
func LoadSupportedCollector ¶
func LoadSupportedCollector(name PodType) (FileLogsCollect, error)
LoadSupportedCollector used to load supported collector. Return a collector of type FileLogsCollect and nil error if a client with the specified testName exists. If not exists, return an error with not supported.
type FileLogsCollector ¶
type FileLogsCollector struct {
BaseFileLogsCollect
}
FileLogsCollector collect specific file logs.
func (*FileLogsCollector) GetFileLogs ¶
func (c *FileLogsCollector) GetFileLogs(namespace, podName, containerName, fileLogPath string) (err error)
GetFileLogs get the file log of a specified node.
type Logs ¶
type Logs struct {
// contains filtered or unexported fields
}
Logs Records specified conditions and provides a method for collecting logs.
type NodeLogCollector ¶
type NodeLogCollector struct {
// contains filtered or unexported fields
}
NodeLogCollector Collecting Node Logs
func NewNodeLogsCollector ¶
func NewNodeLogsCollector(podList []coreV1.Pod, transmitter *helper.TaskHandler, display *Display) *NodeLogCollector
NewNodeLogsCollector initialize a NodeLogsCollector instance
func (*NodeLogCollector) Collect ¶
func (n *NodeLogCollector) Collect()
Collect collects container logs of specified conditions on the node.
type ResourceBuilder ¶
type ResourceBuilder struct {
// contains filtered or unexported fields
}
ResourceBuilder is used to build a resource object
func NewResourceBuilder ¶
func NewResourceBuilder() *ResourceBuilder
NewResourceBuilder initialize a ResourceBuilder instance
func (*ResourceBuilder) AllNamespaces ¶
func (b *ResourceBuilder) AllNamespaces(allNamespace bool) *ResourceBuilder
AllNamespaces instructs the builder to metav1.NamespaceAll as a namespace to request resources across all the namespace. This overrides the namespace set by NamespaceParam().
func (*ResourceBuilder) AllNodes ¶
func (b *ResourceBuilder) AllNodes(isAllNodes bool) *ResourceBuilder
AllNodes instructs the builder to request isAllNodes options.
func (*ResourceBuilder) BoundBackend ¶
func (b *ResourceBuilder) BoundBackend(backend string) *ResourceBuilder
BoundBackend instructs the builder to request backend name.
func (*ResourceBuilder) Build ¶
func (b *ResourceBuilder) Build() *Resource
Build convert ResourceBuilder to Resource
func (*ResourceBuilder) DefaultNamespace ¶
func (b *ResourceBuilder) DefaultNamespace() *ResourceBuilder
DefaultNamespace instructs the builder to set the namespace value for any object found to NamespaceParam() if empty.
func (*ResourceBuilder) FileName ¶
func (b *ResourceBuilder) FileName(fileName string) *ResourceBuilder
FileName instructs the builder to request file name.
func (*ResourceBuilder) FileType ¶
func (b *ResourceBuilder) FileType(fileType string) *ResourceBuilder
FileType instructs the builder to request file type.
func (*ResourceBuilder) MaxNodeThreads ¶
func (b *ResourceBuilder) MaxNodeThreads(maxNodeThreads int) *ResourceBuilder
MaxNodeThreads instructs the builder to request maxNodeThreads.
func (*ResourceBuilder) Names ¶
func (b *ResourceBuilder) Names(names ...string) *ResourceBuilder
Names instructs the builder to request resources names
func (*ResourceBuilder) NamespaceParam ¶
func (b *ResourceBuilder) NamespaceParam(namespace string) *ResourceBuilder
NamespaceParam accepts the namespace that these resources should be considered under from - used by DefaultNamespace()
func (*ResourceBuilder) NodeName ¶
func (b *ResourceBuilder) NodeName(nodeName string) *ResourceBuilder
NodeName instructs the builder to request node name.
func (*ResourceBuilder) Output ¶
func (b *ResourceBuilder) Output(output string) *ResourceBuilder
Output instructs the builder to request output type
func (*ResourceBuilder) ResourceNames ¶
func (b *ResourceBuilder) ResourceNames(resource string, names ...string) *ResourceBuilder
ResourceNames accepts a default type and one or more names, and creates tuples of resources
func (*ResourceBuilder) ResourceTypes ¶
func (b *ResourceBuilder) ResourceTypes(types ...string) *ResourceBuilder
ResourceTypes is a list of types of resources to operate on, when listing objects on the server or retrieving objects that match a selector.
func (*ResourceBuilder) SelectAll ¶
func (b *ResourceBuilder) SelectAll(selectAll bool) *ResourceBuilder
SelectAll accepts a bool value and will filter the resulting list by that object.
func (*ResourceBuilder) Selector ¶
func (b *ResourceBuilder) Selector(selector string) *ResourceBuilder
Selector accepts a selector directly and will filter the resulting list by that object.
type SecretConfig ¶
SecretConfig used to create a secret object
func (*SecretConfig) ToSecret ¶
func (c *SecretConfig) ToSecret() corev1.Secret
ToSecret convert SecretConfig to Secret resource
type Status ¶
type Status struct {
// contains filtered or unexported fields
}
Status Collection status display
type StorageBackendClaimConfig ¶
type StorageBackendClaimConfig struct { Name string Namespace string ConfigmapMeta string SecretMeta string MaxClientThreads string Provisioner string }
StorageBackendClaimConfig used to create a storageBackendClaim object
func (*StorageBackendClaimConfig) ToStorageBackendClaim ¶
func (c *StorageBackendClaimConfig) ToStorageBackendClaim() xuanwuv1.StorageBackendClaim
ToStorageBackendClaim convert StorageBackendClaimConfig to Secret StorageBackendClaim
type TransmitTask ¶
type TransmitTask struct { FileLogsCollect // contains filtered or unexported fields }
TransmitTask Configuring a Pod Log File Transfer Task
func (*TransmitTask) Do ¶
func (t *TransmitTask) Do()
Do copy the compressed log file to the local host.
type Validator ¶
type Validator struct {
// contains filtered or unexported fields
}
Validator is used to validate a Resource object
type ValidatorBuilder ¶
type ValidatorBuilder struct {
*Validator
}
ValidatorBuilder is used to build a Validator object
func NewValidatorBuilder ¶
func NewValidatorBuilder(resource *Resource) *ValidatorBuilder
NewValidatorBuilder initialize a ValidatorBuilder instance
func (*ValidatorBuilder) Build ¶
func (b *ValidatorBuilder) Build() *Validator
Build used to convert ValidatorBuilder to Validator
func (*ValidatorBuilder) ValidateBackend ¶
func (b *ValidatorBuilder) ValidateBackend() *ValidatorBuilder
ValidateBackend used to validate backend
func (*ValidatorBuilder) ValidateNameIsExist ¶
func (b *ValidatorBuilder) ValidateNameIsExist() *ValidatorBuilder
ValidateNameIsExist used to validate resource names is exists. For example, the following operations are illegal oceanctl update backend
func (*ValidatorBuilder) ValidateNameIsSingle ¶
func (b *ValidatorBuilder) ValidateNameIsSingle() *ValidatorBuilder
ValidateNameIsSingle used to validate resource names is single. For example, the following operations are illegal oceanctl update backend <name-1> <name-2>
func (*ValidatorBuilder) ValidateOutputFormat ¶
func (b *ValidatorBuilder) ValidateOutputFormat() *ValidatorBuilder
ValidateOutputFormat used to validate resource names is single.For example, the following operations are illegal oceanctl get backend <name-1> -o xml
func (*ValidatorBuilder) ValidateSelector ¶
func (b *ValidatorBuilder) ValidateSelector() *ValidatorBuilder
ValidateSelector used to validate selector. For example, the following operations are illegal oceanctl delete backend oceanctl delete backend <name> --all