type Client interface { // GetFlags gets the flag specific to init operation so that it can correctly decide on the backend to be used // It ignores all the flags except the ones specific to init operation, for e.g. verbosity flag GetFlags(flags map[string]string) map[string]string // Validate checks for each backend if flags are valid Validate(flags map[string]string, fs filesystem.Filesystem, dir string) error // InitDevfile allows to initialize a Devfile in cases where this operation is needed as a prerequisite, // like if the directory contains no Devfile at all. // `preInitHandlerFunc` allows to perform operations prior to triggering the actual Devfile // initialization and personalization process. // `newDevfileHandlerFunc` is called only when a new Devfile object has been instantiated. // It allows to perform operations right after the Devfile has been initialized and personalized. // It is not called if the context directory already has a Devfile file. InitDevfile(ctx context.Context, flags map[string]string, contextDir string, preInitHandlerFunc func(interactiveMode bool), newDevfileHandlerFunc func(newDevfileObj parser.DevfileObj) error) error // SelectDevfile returns information about a devfile selected based on Alizer if the directory content, // or based on the flags if the directory is empty, or // interactively if flags is empty SelectDevfile(ctx context.Context, flags map[string]string, fs filesystem.Filesystem, dir string) (*api.DetectionResult, error) // DownloadDevfile downloads a devfile given its location information and a destination directory // and returns the path of the downloaded file DownloadDevfile(ctx context.Context, devfileLocation *api.DetectionResult, destDir string) (string, error) // SelectStarterProject selects a starter project from the devfile and returns information about the starter project, // depending on the flags. If not starter project is selected, a nil starter is returned SelectStarterProject(devfile parser.DevfileObj, flags map[string]string, isEmptyDir bool) (*v1alpha2.StarterProject, error) // DownloadStarterProject downloads the starter project referenced in devfile and stores it in dest directory // WARNING: This will first remove all the content of dest. DownloadStarterProject(project *v1alpha2.StarterProject, dest string) (bool, error) // PersonalizeName returns the customized Devfile Metadata Name. // Depending on the flags, it may return a name set interactively or not. PersonalizeName(devfile parser.DevfileObj, flags map[string]string) (string, error) // PersonalizeDevfileConfig updates the env vars, and URL endpoints PersonalizeDevfileConfig(devfileobj parser.DevfileObj, flags map[string]string, fs filesystem.Filesystem, dir string) (parser.DevfileObj, error) // SelectAndPersonalizeDevfile selects a devfile, then downloads, parse and personalize it // Returns the devfile object, its path and pointer to *api.devfileLocation SelectAndPersonalizeDevfile(ctx context.Context, flags map[string]string, contextDir string) (parser.DevfileObj, string, *api.DetectionResult, error) // HandleApplicationPorts updates the ports in the Devfile accordingly. HandleApplicationPorts(devfileobj parser.DevfileObj, ports []int, flags map[string]string, fs filesystem.Filesystem, dir string) (parser.DevfileObj, error) }
type InitClient struct {
// contains filtered or unexported fields
}
func NewInitClient(fsys filesystem.Filesystem, preferenceClient preference.Client, registryClient registry.Client, alizerClient alizer.Client) *InitClient
func (o *InitClient) DownloadDevfile(ctx context.Context, devfileLocation *api.DetectionResult, destDir string) (string, error)
func (o *InitClient) DownloadStarterProject(starter *v1alpha2.StarterProject, dest string) (containsDevfile bool, err error)
func (o *InitClient) GetFlags(flags map[string]string) map[string]string
GetFlags gets the flag specific to init operation so that it can correctly decide on the backend to be used It ignores all the flags except the ones specific to init operation, for e.g. verbosity flag
func (o *InitClient) HandleApplicationPorts(devfileobj parser.DevfileObj, ports []int, flags map[string]string, fs filesystem.Filesystem, dir string) (parser.DevfileObj, error)
func (o *InitClient) InitDevfile(ctx context.Context, flags map[string]string, contextDir string, preInitHandlerFunc func(interactiveMode bool), newDevfileHandlerFunc func(newDevfileObj parser.DevfileObj) error) error
func (o *InitClient) PersonalizeDevfileConfig(devfileobj parser.DevfileObj, flags map[string]string, fs filesystem.Filesystem, dir string) (parser.DevfileObj, error)
func (o *InitClient) PersonalizeName(devfile parser.DevfileObj, flags map[string]string) (string, error)
PersonalizeName calls PersonalizeName methods of the adequate backend
func (o *InitClient) SelectAndPersonalizeDevfile(ctx context.Context, flags map[string]string, contextDir string) (parser.DevfileObj, string, *api.DetectionResult, error)
func (o *InitClient) SelectDevfile(ctx context.Context, flags map[string]string, fs filesystem.Filesystem, dir string) (*api.DetectionResult, error)
SelectDevfile calls SelectDevfile methods of the adequate backend
func (o *InitClient) SelectStarterProject(devfile parser.DevfileObj, flags map[string]string, isEmptyDir bool) (*v1alpha2.StarterProject, error)
SelectStarterProject calls SelectStarterProject methods of the adequate backend
func (o *InitClient) Validate(flags map[string]string, fs filesystem.Filesystem, dir string) error
Validate calls Validate method of the adequate backend
MockClient is a mock of Client interface.
type MockClient struct {
// contains filtered or unexported fields
}
func NewMockClient(ctrl *gomock.Controller) *MockClient
NewMockClient creates a new mock instance.
func (m *MockClient) DownloadDevfile(ctx context.Context, devfileLocation *api.DetectionResult, destDir string) (string, error)
DownloadDevfile mocks base method.
func (m *MockClient) DownloadStarterProject(project *v1alpha2.StarterProject, dest string) (bool, error)
DownloadStarterProject mocks base method.
func (m *MockClient) EXPECT() *MockClientMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (m *MockClient) GetFlags(flags map[string]string) map[string]string
GetFlags mocks base method.
func (m *MockClient) HandleApplicationPorts(devfileobj parser.DevfileObj, ports []int, flags map[string]string, fs filesystem.Filesystem, dir string) (parser.DevfileObj, error)
HandleApplicationPorts mocks base method.
func (m *MockClient) InitDevfile(ctx context.Context, flags map[string]string, contextDir string, preInitHandlerFunc func(bool), newDevfileHandlerFunc func(parser.DevfileObj) error) error
InitDevfile mocks base method.
func (m *MockClient) PersonalizeDevfileConfig(devfileobj parser.DevfileObj, flags map[string]string, fs filesystem.Filesystem, dir string) (parser.DevfileObj, error)
PersonalizeDevfileConfig mocks base method.
func (m *MockClient) PersonalizeName(devfile parser.DevfileObj, flags map[string]string) (string, error)
PersonalizeName mocks base method.
func (m *MockClient) SelectAndPersonalizeDevfile(ctx context.Context, flags map[string]string, contextDir string) (parser.DevfileObj, string, *api.DetectionResult, error)
SelectAndPersonalizeDevfile mocks base method.
func (m *MockClient) SelectDevfile(ctx context.Context, flags map[string]string, fs filesystem.Filesystem, dir string) (*api.DetectionResult, error)
SelectDevfile mocks base method.
func (m *MockClient) SelectStarterProject(devfile parser.DevfileObj, flags map[string]string, isEmptyDir bool) (*v1alpha2.StarterProject, error)
SelectStarterProject mocks base method.
func (m *MockClient) Validate(flags map[string]string, fs filesystem.Filesystem, dir string) error
Validate mocks base method.
MockClientMockRecorder is the mock recorder for MockClient.
type MockClientMockRecorder struct {
// contains filtered or unexported fields
}
func (mr *MockClientMockRecorder) DownloadDevfile(ctx, devfileLocation, destDir interface{}) *gomock.Call
DownloadDevfile indicates an expected call of DownloadDevfile.
func (mr *MockClientMockRecorder) DownloadStarterProject(project, dest interface{}) *gomock.Call
DownloadStarterProject indicates an expected call of DownloadStarterProject.
func (mr *MockClientMockRecorder) GetFlags(flags interface{}) *gomock.Call
GetFlags indicates an expected call of GetFlags.
func (mr *MockClientMockRecorder) HandleApplicationPorts(devfileobj, ports, flags, fs, dir interface{}) *gomock.Call
HandleApplicationPorts indicates an expected call of HandleApplicationPorts.
func (mr *MockClientMockRecorder) InitDevfile(ctx, flags, contextDir, preInitHandlerFunc, newDevfileHandlerFunc interface{}) *gomock.Call
InitDevfile indicates an expected call of InitDevfile.
func (mr *MockClientMockRecorder) PersonalizeDevfileConfig(devfileobj, flags, fs, dir interface{}) *gomock.Call
PersonalizeDevfileConfig indicates an expected call of PersonalizeDevfileConfig.
func (mr *MockClientMockRecorder) PersonalizeName(devfile, flags interface{}) *gomock.Call
PersonalizeName indicates an expected call of PersonalizeName.
func (mr *MockClientMockRecorder) SelectAndPersonalizeDevfile(ctx, flags, contextDir interface{}) *gomock.Call
SelectAndPersonalizeDevfile indicates an expected call of SelectAndPersonalizeDevfile.
func (mr *MockClientMockRecorder) SelectDevfile(ctx, flags, fs, dir interface{}) *gomock.Call
SelectDevfile indicates an expected call of SelectDevfile.
func (mr *MockClientMockRecorder) SelectStarterProject(devfile, flags, isEmptyDir interface{}) *gomock.Call
SelectStarterProject indicates an expected call of SelectStarterProject.
func (mr *MockClientMockRecorder) Validate(flags, fs, dir interface{}) *gomock.Call
Validate indicates an expected call of Validate.