Documentation ¶
Index ¶
- Constants
- Variables
- type CLIOptionsReader
- type Cluster
- func (c *Cluster) Connect(config string) error
- func (c *Cluster) DeleteNamespaceIfOwned(namespace string) (string, error)
- func (c *Cluster) Exec(namespace, podName, containerName string, command, stdin string) (string, string, error)
- func (c *Cluster) GetPlatform() Platform
- func (c *Cluster) GetPodEvents(namespace, podName string) (string, error)
- func (c *Cluster) GetPodEventsWithSelector(namespace, selector string) (string, error)
- func (c *Cluster) GetSecret(namespace, name string) (*v1.Secret, error)
- func (c *Cluster) GetVersion() (string, error)
- func (c *Cluster) IsPodRunning(podName, namespace string) wait.ConditionFunc
- func (c *Cluster) LabelNamespace(namespace, labelKey, labelValue string) error
- func (c *Cluster) ListIngress(namespace, selector string) (*v1beta1.IngressList, error)
- func (c *Cluster) ListIngressRoutes(namespace, name string) ([]string, error)
- func (c *Cluster) ListPods(namespace, selector string) (*v1.PodList, error)
- func (c *Cluster) NamespaceLabelExists(namespaceName, labelKey string) (bool, error)
- func (c *Cluster) PodExists(namespace, selector string) wait.ConditionFunc
- func (c *Cluster) StatefulSetStatus(namespace, selector string) (string, error)
- func (c *Cluster) WaitForPodBySelectorRunning(ui *ui.UI, namespace, selector string, timeout int) error
- func (c *Cluster) WaitForPodRunning(namespace, podName string, timeout time.Duration) error
- func (c *Cluster) WaitUntilPodBySelectorExist(ui *ui.UI, namespace, selector string, timeout int) error
- type DefaultOptionsReader
- type Deployment
- type InstallationOption
- type InstallationOptionDynamicDefault
- type InstallationOptionType
- type InstallationOptions
- func (opts InstallationOptions) AsCobraFlagsFor(cmd *cobra.Command)
- func (opts InstallationOptions) ForDeployment(deploymentID string) InstallationOptions
- func (opts InstallationOptions) GetBool(optionName string, deploymentID string) (bool, error)
- func (opts InstallationOptions) GetInt(optionName string, deploymentID string) (int, error)
- func (opts InstallationOptions) GetOpt(optionName string, deploymentID string) (*InstallationOption, error)
- func (opts InstallationOptions) GetString(optionName string, deploymentID string) (string, error)
- func (opts InstallationOptions) Merge(toMerge InstallationOptions) InstallationOptions
- func (opts *InstallationOptions) Populate(reader OptionsReader) (*InstallationOptions, error)
- func (opts InstallationOptions) ToOptMap() map[string]InstallationOption
- type InteractiveOptionsReader
- type OptionsReader
- type Platform
Constants ¶
const ( BooleanType = iota StringType IntType )
const (
// APISGroupName is the api name used for carrier
APISGroupName = "carrier.suse.org"
)
Variables ¶
var ( CarrierDeploymentLabelKey = fmt.Sprintf("%s/%s", APISGroupName, "deployment") CarrierDeploymentLabelValue = "true" )
var SupportedPlatforms []Platform = []Platform{ kind.NewPlatform(), k3s.NewPlatform(), ibm.NewPlatform(), minikube.NewPlatform(), }
Functions ¶
This section is empty.
Types ¶
type CLIOptionsReader ¶
type CLIOptionsReader struct {
// contains filtered or unexported fields
}
func NewCLIOptionsReader ¶
func NewCLIOptionsReader(cmd *cobra.Command) CLIOptionsReader
NewCLIOptionsReader is a reader used by the Installer to fill configuration variables from cli options.
func (CLIOptionsReader) Read ¶
func (reader CLIOptionsReader) Read(option *InstallationOption) error
Queries the cobra command for a flag associated with the given InstallationOption and returns its value converted to the appropriate (Go) type as defined by the Type field of the InstallationOption. Does nothing if no cobra flag is found.
type Cluster ¶
type Cluster struct { // InternalIPs []string // Ingress bool Kubectl *kubernetes.Clientset RestConfig *restclient.Config // contains filtered or unexported fields }
func NewCluster ¶
func NewClusterFromClient ¶
func NewClusterFromClient(restConfig *restclient.Config) (*Cluster, error)
NewClusterFromClient creates a new Cluster from a Kubernetes rest client config
func (*Cluster) DeleteNamespaceIfOwned ¶
DeleteNamespaceIfOwned deletes the namepace if it exists and has a carrier label otherwise returns the warning as a string
func (*Cluster) GetPlatform ¶
func (*Cluster) GetPodEvents ¶
func (*Cluster) GetPodEventsWithSelector ¶
GetPodEventsWithSelector tries to find a pod using the provided selector and namespace. If found it returns the events on that Pod. If not found it returns an error. An equivalent kubectl command would look like this (label selector being "app.kubernetes.io/name=container-registry"):
kubectl get event --namespace my-namespace \ --field-selector involvedObject.name=$( \ kubectl get pods -o=jsonpath='{.items[0].metadata.name}' --selector=app.kubernetes.io/name=container-registry -n my-namespace)
func (*Cluster) GetVersion ¶
GetVersion get the kube server version
func (*Cluster) IsPodRunning ¶
func (c *Cluster) IsPodRunning(podName, namespace string) wait.ConditionFunc
IsPodRunning returns a condition function that indicates whether the given pod is currently running
func (*Cluster) LabelNamespace ¶
LabelNamespace adds a label to the namespace
func (*Cluster) ListIngress ¶
func (c *Cluster) ListIngress(namespace, selector string) (*v1beta1.IngressList, error)
ListIngress returns the list of available ingresses in `namespace` with the given selector
func (*Cluster) ListIngressRoutes ¶
ListIngressRoutes returns a list of all routes for ingresses in `namespace` with the given selector
func (*Cluster) ListPods ¶
ListPods returns the list of currently scheduled or running pods in `namespace` with the given selector
func (*Cluster) NamespaceLabelExists ¶
NamespaceLabelExists checks if a specific label exits on the namespace
func (*Cluster) PodExists ¶
func (c *Cluster) PodExists(namespace, selector string) wait.ConditionFunc
func (*Cluster) StatefulSetStatus ¶
StatefulSetStatus returns running status for a StatefulSet If the sts doesn't exist, the status is set to 0/0
func (*Cluster) WaitForPodBySelectorRunning ¶
func (c *Cluster) WaitForPodBySelectorRunning(ui *ui.UI, namespace, selector string, timeout int) error
WaitForPodBySelectorRunning waits timeout seconds for all pods in 'namespace' with given 'selector' to enter running state. Returns an error if no pods are found or not all discovered pods enter running state.
func (*Cluster) WaitForPodRunning ¶
Poll up to timeout seconds for pod to enter running state. Returns an error if the pod never enters the running state.
func (*Cluster) WaitUntilPodBySelectorExist ¶
func (c *Cluster) WaitUntilPodBySelectorExist(ui *ui.UI, namespace, selector string, timeout int) error
Wait up to timeout seconds for all pods in 'namespace' with given 'selector' to enter running state. Returns an error if no pods are found or not all discovered pods enter running state.
type DefaultOptionsReader ¶
type DefaultOptionsReader struct{}
func NewDefaultOptionsReader ¶
func NewDefaultOptionsReader() DefaultOptionsReader
NewDefaultOptionsReader is a reader used by the Installer to fill InstallationOptions with a default value, either static, or dynamic per function vector.
func (DefaultOptionsReader) Read ¶
func (reader DefaultOptionsReader) Read(option *InstallationOption) error
Read attempts to fill the option with a default, dynamic or static.
type Deployment ¶
type Deployment interface { Deploy(*Cluster, *ui.UI, InstallationOptions) error Upgrade(*Cluster, *ui.UI, InstallationOptions) error Delete(*Cluster, *ui.UI) error Describe() string GetVersion() string NeededOptions() InstallationOptions Restore(*Cluster, *ui.UI, string) error Backup(*Cluster, *ui.UI, string) error ID() string }
type InstallationOption ¶
type InstallationOption struct { Name string // Identifying name of the configuration variable Value interface{} // Value to use (may not be valid, see `Valid` field). Default interface{} // Static default value for the value. DynDefaultFunc InstallationOptionDynamicDefault // Function to provide a default. Has priority over `Default`. UserSpecified bool // Flag, true if `Value` came from the user. Description string // Short description of the variable Type InstallationOptionType // Type information for `Value` and `Default`. DeploymentID string // If set, this option will be passed only to this deployment (private) }
func (*InstallationOption) DynDefault ¶
func (opt *InstallationOption) DynDefault() error
func (*InstallationOption) SetDefault ¶
func (opt *InstallationOption) SetDefault() error
func (InstallationOption) ToOptMapKey ¶
func (opt InstallationOption) ToOptMapKey() string
type InstallationOptionDynamicDefault ¶
type InstallationOptionDynamicDefault func(o *InstallationOption) error
A InstallationOptionDynamicDefault function may provide a dynamic default value for an option. When present it has precedence over any static default value in the structure.
ATTENTION: The function is responsible for setting both Value and Valid flag of the specified option. This is necessary for cases where the dynamic default could not be determined, yet is not an error.
type InstallationOptionType ¶
type InstallationOptionType int
type InstallationOptions ¶
type InstallationOptions []InstallationOption
func (InstallationOptions) AsCobraFlagsFor ¶
func (opts InstallationOptions) AsCobraFlagsFor(cmd *cobra.Command)
func (InstallationOptions) ForDeployment ¶
func (opts InstallationOptions) ForDeployment(deploymentID string) InstallationOptions
func (InstallationOptions) GetBool ¶
func (opts InstallationOptions) GetBool(optionName string, deploymentID string) (bool, error)
func (InstallationOptions) GetInt ¶
func (opts InstallationOptions) GetInt(optionName string, deploymentID string) (int, error)
func (InstallationOptions) GetOpt ¶
func (opts InstallationOptions) GetOpt(optionName string, deploymentID string) (*InstallationOption, error)
GetOpt finds the given option in opts.
When the deploymentID is the empty string the function searches for and returns only global options (not associated to any deployment). Otherwise it searches for private options associated with the specified deployment as well.
ATTENTION: In the second case private options have precedence. In other words if we have private and global options of the same name, then the private option is returned.
ATTENTION: This function returns a reference, enabling the caller to modify the structure.
func (InstallationOptions) GetString ¶
func (opts InstallationOptions) GetString(optionName string, deploymentID string) (string, error)
func (InstallationOptions) Merge ¶
func (opts InstallationOptions) Merge(toMerge InstallationOptions) InstallationOptions
Merge returns a merge of the two options respecting uniqueness of name+deploymentID
func (*InstallationOptions) Populate ¶
func (opts *InstallationOptions) Populate(reader OptionsReader) (*InstallationOptions, error)
Populate will try to give values to the needed options using the given OptionsReader. If none is given, the default is the InteractiveOptionsReader which will ask in the terminal. This method only populates what is possible and leaves the rest empty. TODO: Implement another method to validate that all options have been set.
func (InstallationOptions) ToOptMap ¶
func (opts InstallationOptions) ToOptMap() map[string]InstallationOption
type InteractiveOptionsReader ¶
type InteractiveOptionsReader struct {
// contains filtered or unexported fields
}
func NewInteractiveOptionsReader ¶
func NewInteractiveOptionsReader(stdout io.Writer, stdin io.Reader) InteractiveOptionsReader
NewInteractiveOptionsReader is the default reader used by the Installer when one is not defined. It asks the user questions on stdout and gets answers on stdin.
func (InteractiveOptionsReader) Read ¶
func (reader InteractiveOptionsReader) Read(option *InstallationOption) error
Read asks the user what value should the given InstallationOption have and returns that value validated and converted to the appropriate type as defined by the Type field of the InstallationOption.
type OptionsReader ¶
type OptionsReader interface {
Read(*InstallationOption) error
}
OptionsReader is the interface to the structures and objects used to fill InstallationOption instances with a valid value.
Note, each reader has the discretion to not modify the provided option instance based on its state. The option's Valid flag is, for example, how the defaults, cli, and interactive readers communicate and decide which options to handle.