const ( FLAG_WORKLOAD = "workload" FLAG_SERVICE = "service" FLAG_SERVICE_NAMESPACE = "service-namespace" FLAG_NAME = "name" FLAG_BIND_AS_FILES = "bind-as-files" FLAG_NAMING_STRATEGY = "naming-strategy" )
type AddBindingBackend interface { // SelectNamespace returns the namespace which services instances should be listed from. // An empty return value means that service instances will be listed from the current namespace. SelectNamespace(flags map[string]string) (string, error) // Validate returns error if the backend failed to validate; mainly useful for flags backend Validate(flags map[string]string, withDevfile bool) error // SelectWorkloadInstance asks user to select the workload to be bind; // it returns the workload name in the form of '<name> (<kind>.<apigroup>)' SelectWorkloadInstance(workloadName string) (string, schema.GroupVersionKind, error) // SelectServiceInstance asks user to select the service to be bound to the component; // it returns the service name in the form of '<name> (<kind>.<apigroup>)' SelectServiceInstance(serviceName string, serviceMap map[string]unstructured.Unstructured) (string, error) // AskBindingName asks for the service name to be set AskBindingName(defaultName string, flags map[string]string) (string, error) // AskBindAsFiles asks if service should be binded as files AskBindAsFiles(flags map[string]string) (bool, error) // AskNamingStrategy asks for the naming strategy to be used AskNamingStrategy(flags map[string]string) (string, error) // SelectCreationOption asks to select how to output the created servicebinding SelectCreationOptions(flags map[string]string) ([]asker.CreationOption, error) // AskOutputFilePath asks for the path of the file to output service binding AskOutputFilePath(flags map[string]string, defaultValue string) (string, error) }
FlagsBackend is a backend that will extract all needed information from flags passed to the command
type FlagsBackend struct{}
func NewFlagsBackend() *FlagsBackend
func (o *FlagsBackend) AskBindAsFiles(flags map[string]string) (bool, error)
func (o *FlagsBackend) AskBindingName(_ string, flags map[string]string) (string, error)
func (o *FlagsBackend) AskNamingStrategy(flags map[string]string) (string, error)
func (o *FlagsBackend) AskOutputFilePath(flags map[string]string, defaultValue string) (string, error)
func (o *FlagsBackend) SelectCreationOptions(flags map[string]string) ([]asker.CreationOption, error)
func (o *FlagsBackend) SelectNamespace(flags map[string]string) (string, error)
func (o *FlagsBackend) SelectServiceInstance(serviceName string, serviceMap map[string]unstructured.Unstructured) (string, error)
SelectServiceInstance parses the service's name, kind, and group from arg:serviceName, after which it checks if the service is available in arg:serviceMap, it further checks for kind, and group If a single service is found, it returns the service name in the form of '<name> (<kind>.<apigroup>)', else errors out. serviceMap: a map of bindable service name with it's unstructured.Unstructured; this map is used to stay independent of the service name format.
func (o *FlagsBackend) SelectWorkloadInstance(workloadName string) (string, schema.GroupVersionKind, error)
func (o *FlagsBackend) Validate(flags map[string]string, withDevfile bool) error
InteractiveBackend is a backend that will ask information interactively using the `asker` package
type InteractiveBackend struct {
// contains filtered or unexported fields
}
func NewInteractiveBackend(askerClient asker.Asker, projectClient project.Client, kubernetesClient kclient.ClientInterface) *InteractiveBackend
func (o *InteractiveBackend) AskBindAsFiles(_ map[string]string) (bool, error)
func (o *InteractiveBackend) AskBindingName(defaultName string, _ map[string]string) (string, error)
func (o *InteractiveBackend) AskNamingStrategy(_ map[string]string) (string, error)
func (o *InteractiveBackend) AskOutputFilePath(flags map[string]string, defaultValue string) (string, error)
func (o *InteractiveBackend) SelectCreationOptions(flags map[string]string) ([]asker.CreationOption, error)
func (o *InteractiveBackend) SelectNamespace(_ map[string]string) (string, error)
SelectNamespace prompts users to select the namespace which services instances should be listed from. If they choose all the namespaces they have access to, it attempts to get the list of accessible namespaces in the cluster, from which the user can select one. If the list is empty (e.g. because of permission-related issues), the user is prompted to manually provide a namespace.
func (o *InteractiveBackend) SelectServiceInstance(_ string, serviceMap map[string]unstructured.Unstructured) (string, error)
func (o *InteractiveBackend) SelectWorkloadInstance(_ string) (string, schema.GroupVersionKind, error)
func (o *InteractiveBackend) Validate(_ map[string]string, _ bool) error
MockAddBindingBackend is a mock of AddBindingBackend interface.
type MockAddBindingBackend struct {
// contains filtered or unexported fields
}
func NewMockAddBindingBackend(ctrl *gomock.Controller) *MockAddBindingBackend
NewMockAddBindingBackend creates a new mock instance.
func (m *MockAddBindingBackend) AskBindAsFiles(flags map[string]string) (bool, error)
AskBindAsFiles mocks base method.
func (m *MockAddBindingBackend) AskBindingName(defaultName string, flags map[string]string) (string, error)
AskBindingName mocks base method.
func (m *MockAddBindingBackend) AskNamingStrategy(flags map[string]string) (string, error)
AskNamingStrategy mocks base method.
func (m *MockAddBindingBackend) AskOutputFilePath(flags map[string]string, defaultValue string) (string, error)
AskOutputFilePath mocks base method.
func (m *MockAddBindingBackend) EXPECT() *MockAddBindingBackendMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (m *MockAddBindingBackend) SelectCreationOptions(flags map[string]string) ([]asker.CreationOption, error)
SelectCreationOptions mocks base method.
func (m *MockAddBindingBackend) SelectNamespace(flags map[string]string) (string, error)
SelectNamespace mocks base method.
func (m *MockAddBindingBackend) SelectServiceInstance(serviceName string, serviceMap map[string]unstructured.Unstructured) (string, error)
SelectServiceInstance mocks base method.
func (m *MockAddBindingBackend) SelectWorkloadInstance(workloadName string) (string, schema.GroupVersionKind, error)
SelectWorkloadInstance mocks base method.
func (m *MockAddBindingBackend) Validate(flags map[string]string, withDevfile bool) error
Validate mocks base method.
MockAddBindingBackendMockRecorder is the mock recorder for MockAddBindingBackend.
type MockAddBindingBackendMockRecorder struct {
// contains filtered or unexported fields
}
func (mr *MockAddBindingBackendMockRecorder) AskBindAsFiles(flags interface{}) *gomock.Call
AskBindAsFiles indicates an expected call of AskBindAsFiles.
func (mr *MockAddBindingBackendMockRecorder) AskBindingName(defaultName, flags interface{}) *gomock.Call
AskBindingName indicates an expected call of AskBindingName.
func (mr *MockAddBindingBackendMockRecorder) AskNamingStrategy(flags interface{}) *gomock.Call
AskNamingStrategy indicates an expected call of AskNamingStrategy.
func (mr *MockAddBindingBackendMockRecorder) AskOutputFilePath(flags, defaultValue interface{}) *gomock.Call
AskOutputFilePath indicates an expected call of AskOutputFilePath.
func (mr *MockAddBindingBackendMockRecorder) SelectCreationOptions(flags interface{}) *gomock.Call
SelectCreationOptions indicates an expected call of SelectCreationOptions.
func (mr *MockAddBindingBackendMockRecorder) SelectNamespace(flags interface{}) *gomock.Call
SelectNamespace indicates an expected call of SelectNamespace.
func (mr *MockAddBindingBackendMockRecorder) SelectServiceInstance(serviceName, serviceMap interface{}) *gomock.Call
SelectServiceInstance indicates an expected call of SelectServiceInstance.
func (mr *MockAddBindingBackendMockRecorder) SelectWorkloadInstance(workloadName interface{}) *gomock.Call
SelectWorkloadInstance indicates an expected call of SelectWorkloadInstance.
func (mr *MockAddBindingBackendMockRecorder) Validate(flags, withDevfile interface{}) *gomock.Call
Validate indicates an expected call of Validate.