...

Package init

Overview ▾

Package init provides methods to initiate an odo project. Most of the methods of the package get a `flags` parameter representing the flags passed from the user through the command line. Several backends are available to complete the operations, the backend being chosen depending on the flags content: - if no flags are passed, the `interactive` backend will be used - if some flags are passed, the `flags` backend will be used.

Package init is a generated GoMock package.

Index ▾

type Client
type InitClient
    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
    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)
    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)
    func (o *InitClient) SelectStarterProject(devfile parser.DevfileObj, flags map[string]string, isEmptyDir bool) (*v1alpha2.StarterProject, error)
    func (o *InitClient) Validate(flags map[string]string, fs filesystem.Filesystem, dir string) error
type MockClient
    func NewMockClient(ctrl *gomock.Controller) *MockClient
    func (m *MockClient) DownloadDevfile(ctx context.Context, devfileLocation *api.DetectionResult, destDir string) (string, error)
    func (m *MockClient) DownloadStarterProject(project *v1alpha2.StarterProject, dest string) (bool, error)
    func (m *MockClient) EXPECT() *MockClientMockRecorder
    func (m *MockClient) GetFlags(flags map[string]string) map[string]string
    func (m *MockClient) HandleApplicationPorts(devfileobj parser.DevfileObj, ports []int, flags map[string]string, fs filesystem.Filesystem, dir string) (parser.DevfileObj, error)
    func (m *MockClient) InitDevfile(ctx context.Context, flags map[string]string, contextDir string, preInitHandlerFunc func(bool), newDevfileHandlerFunc func(parser.DevfileObj) error) error
    func (m *MockClient) PersonalizeDevfileConfig(devfileobj parser.DevfileObj, flags map[string]string, fs filesystem.Filesystem, dir string) (parser.DevfileObj, error)
    func (m *MockClient) PersonalizeName(devfile parser.DevfileObj, flags map[string]string) (string, error)
    func (m *MockClient) SelectAndPersonalizeDevfile(ctx context.Context, flags map[string]string, contextDir string) (parser.DevfileObj, string, *api.DetectionResult, error)
    func (m *MockClient) SelectDevfile(ctx context.Context, flags map[string]string, fs filesystem.Filesystem, dir string) (*api.DetectionResult, error)
    func (m *MockClient) SelectStarterProject(devfile parser.DevfileObj, flags map[string]string, isEmptyDir bool) (*v1alpha2.StarterProject, error)
    func (m *MockClient) Validate(flags map[string]string, fs filesystem.Filesystem, dir string) error
type MockClientMockRecorder
    func (mr *MockClientMockRecorder) DownloadDevfile(ctx, devfileLocation, destDir interface{}) *gomock.Call
    func (mr *MockClientMockRecorder) DownloadStarterProject(project, dest interface{}) *gomock.Call
    func (mr *MockClientMockRecorder) GetFlags(flags interface{}) *gomock.Call
    func (mr *MockClientMockRecorder) HandleApplicationPorts(devfileobj, ports, flags, fs, dir interface{}) *gomock.Call
    func (mr *MockClientMockRecorder) InitDevfile(ctx, flags, contextDir, preInitHandlerFunc, newDevfileHandlerFunc interface{}) *gomock.Call
    func (mr *MockClientMockRecorder) PersonalizeDevfileConfig(devfileobj, flags, fs, dir interface{}) *gomock.Call
    func (mr *MockClientMockRecorder) PersonalizeName(devfile, flags interface{}) *gomock.Call
    func (mr *MockClientMockRecorder) SelectAndPersonalizeDevfile(ctx, flags, contextDir interface{}) *gomock.Call
    func (mr *MockClientMockRecorder) SelectDevfile(ctx, flags, fs, dir interface{}) *gomock.Call
    func (mr *MockClientMockRecorder) SelectStarterProject(devfile, flags, isEmptyDir interface{}) *gomock.Call
    func (mr *MockClientMockRecorder) Validate(flags, fs, dir interface{}) *gomock.Call

Package files

init.go interface.go mock.go

type Client

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

type InitClient struct {
    // contains filtered or unexported fields
}

func NewInitClient

func NewInitClient(fsys filesystem.Filesystem, preferenceClient preference.Client, registryClient registry.Client, alizerClient alizer.Client) *InitClient

func (*InitClient) DownloadDevfile

func (o *InitClient) DownloadDevfile(ctx context.Context, devfileLocation *api.DetectionResult, destDir string) (string, error)

func (*InitClient) DownloadStarterProject

func (o *InitClient) DownloadStarterProject(starter *v1alpha2.StarterProject, dest string) (containsDevfile bool, err error)

func (*InitClient) GetFlags

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 (*InitClient) HandleApplicationPorts

func (o *InitClient) HandleApplicationPorts(devfileobj parser.DevfileObj, ports []int, flags map[string]string, fs filesystem.Filesystem, dir string) (parser.DevfileObj, error)

func (*InitClient) InitDevfile

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 (*InitClient) PersonalizeDevfileConfig

func (o *InitClient) PersonalizeDevfileConfig(devfileobj parser.DevfileObj, flags map[string]string, fs filesystem.Filesystem, dir string) (parser.DevfileObj, error)

func (*InitClient) PersonalizeName

func (o *InitClient) PersonalizeName(devfile parser.DevfileObj, flags map[string]string) (string, error)

PersonalizeName calls PersonalizeName methods of the adequate backend

func (*InitClient) SelectAndPersonalizeDevfile

func (o *InitClient) SelectAndPersonalizeDevfile(ctx context.Context, flags map[string]string, contextDir string) (parser.DevfileObj, string, *api.DetectionResult, error)

func (*InitClient) SelectDevfile

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 (*InitClient) SelectStarterProject

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 (*InitClient) Validate

func (o *InitClient) Validate(flags map[string]string, fs filesystem.Filesystem, dir string) error

Validate calls Validate method of the adequate backend

type MockClient

MockClient is a mock of Client interface.

type MockClient struct {
    // contains filtered or unexported fields
}

func NewMockClient

func NewMockClient(ctrl *gomock.Controller) *MockClient

NewMockClient creates a new mock instance.

func (*MockClient) DownloadDevfile

func (m *MockClient) DownloadDevfile(ctx context.Context, devfileLocation *api.DetectionResult, destDir string) (string, error)

DownloadDevfile mocks base method.

func (*MockClient) DownloadStarterProject

func (m *MockClient) DownloadStarterProject(project *v1alpha2.StarterProject, dest string) (bool, error)

DownloadStarterProject mocks base method.

func (*MockClient) EXPECT

func (m *MockClient) EXPECT() *MockClientMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockClient) GetFlags

func (m *MockClient) GetFlags(flags map[string]string) map[string]string

GetFlags mocks base method.

func (*MockClient) HandleApplicationPorts

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 (*MockClient) InitDevfile

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 (*MockClient) PersonalizeDevfileConfig

func (m *MockClient) PersonalizeDevfileConfig(devfileobj parser.DevfileObj, flags map[string]string, fs filesystem.Filesystem, dir string) (parser.DevfileObj, error)

PersonalizeDevfileConfig mocks base method.

func (*MockClient) PersonalizeName

func (m *MockClient) PersonalizeName(devfile parser.DevfileObj, flags map[string]string) (string, error)

PersonalizeName mocks base method.

func (*MockClient) SelectAndPersonalizeDevfile

func (m *MockClient) SelectAndPersonalizeDevfile(ctx context.Context, flags map[string]string, contextDir string) (parser.DevfileObj, string, *api.DetectionResult, error)

SelectAndPersonalizeDevfile mocks base method.

func (*MockClient) SelectDevfile

func (m *MockClient) SelectDevfile(ctx context.Context, flags map[string]string, fs filesystem.Filesystem, dir string) (*api.DetectionResult, error)

SelectDevfile mocks base method.

func (*MockClient) SelectStarterProject

func (m *MockClient) SelectStarterProject(devfile parser.DevfileObj, flags map[string]string, isEmptyDir bool) (*v1alpha2.StarterProject, error)

SelectStarterProject mocks base method.

func (*MockClient) Validate

func (m *MockClient) Validate(flags map[string]string, fs filesystem.Filesystem, dir string) error

Validate mocks base method.

type MockClientMockRecorder

MockClientMockRecorder is the mock recorder for MockClient.

type MockClientMockRecorder struct {
    // contains filtered or unexported fields
}

func (*MockClientMockRecorder) DownloadDevfile

func (mr *MockClientMockRecorder) DownloadDevfile(ctx, devfileLocation, destDir interface{}) *gomock.Call

DownloadDevfile indicates an expected call of DownloadDevfile.

func (*MockClientMockRecorder) DownloadStarterProject

func (mr *MockClientMockRecorder) DownloadStarterProject(project, dest interface{}) *gomock.Call

DownloadStarterProject indicates an expected call of DownloadStarterProject.

func (*MockClientMockRecorder) GetFlags

func (mr *MockClientMockRecorder) GetFlags(flags interface{}) *gomock.Call

GetFlags indicates an expected call of GetFlags.

func (*MockClientMockRecorder) HandleApplicationPorts

func (mr *MockClientMockRecorder) HandleApplicationPorts(devfileobj, ports, flags, fs, dir interface{}) *gomock.Call

HandleApplicationPorts indicates an expected call of HandleApplicationPorts.

func (*MockClientMockRecorder) InitDevfile

func (mr *MockClientMockRecorder) InitDevfile(ctx, flags, contextDir, preInitHandlerFunc, newDevfileHandlerFunc interface{}) *gomock.Call

InitDevfile indicates an expected call of InitDevfile.

func (*MockClientMockRecorder) PersonalizeDevfileConfig

func (mr *MockClientMockRecorder) PersonalizeDevfileConfig(devfileobj, flags, fs, dir interface{}) *gomock.Call

PersonalizeDevfileConfig indicates an expected call of PersonalizeDevfileConfig.

func (*MockClientMockRecorder) PersonalizeName

func (mr *MockClientMockRecorder) PersonalizeName(devfile, flags interface{}) *gomock.Call

PersonalizeName indicates an expected call of PersonalizeName.

func (*MockClientMockRecorder) SelectAndPersonalizeDevfile

func (mr *MockClientMockRecorder) SelectAndPersonalizeDevfile(ctx, flags, contextDir interface{}) *gomock.Call

SelectAndPersonalizeDevfile indicates an expected call of SelectAndPersonalizeDevfile.

func (*MockClientMockRecorder) SelectDevfile

func (mr *MockClientMockRecorder) SelectDevfile(ctx, flags, fs, dir interface{}) *gomock.Call

SelectDevfile indicates an expected call of SelectDevfile.

func (*MockClientMockRecorder) SelectStarterProject

func (mr *MockClientMockRecorder) SelectStarterProject(devfile, flags, isEmptyDir interface{}) *gomock.Call

SelectStarterProject indicates an expected call of SelectStarterProject.

func (*MockClientMockRecorder) Validate

func (mr *MockClientMockRecorder) Validate(flags, fs, dir interface{}) *gomock.Call

Validate indicates an expected call of Validate.

Subdirectories

Name Synopsis
..
asker package asker uses the Survey library to interact with the user and ask various information needed to initiate a project.
backend Package backend provides different backends to initiate projects.