filesystem

package
v0.3.13 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 19, 2024 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// WORKSPACES_DIR is the name of the directory where the workspaces are stored
	WORKSPACES_DIR = "workspaces"
	// PROJECTS_DIR is the name of the directory where the projects are stored
	PROJECTS_DIR = "projects"
	// INPUTS_DIR is the directory where project inputs are stored
	INPUTS_DIR = "inputs"
	// PROJECT_OUTPUTS_DIR is the directory where project outputs are stored
	PROJECT_OUTPUTS_DIR = "outputs"
	// PROJECT_PLAN_DIR is the directory where planning is done
	PROJECT_PLAN_DIR = "plan"
	// ARCHIVES_DIR is the directory where the archive files for project inputs are stored
	ARCHIVES_DIR = "archives"
	// EXPANDED_DIR is the directory where the archive files for project inputs are expanded and stored
	EXPANDED_DIR = "expanded"
	// SOURCES_DIR is the directory where the sources directory project inputs are stored
	SOURCES_DIR = string(types.ProjectInputSources)
	// CUSTOMIZATIONS_DIR is the directory where the customizations directory project inputs are stored
	CUSTOMIZATIONS_DIR = string(types.ProjectInputCustomizations)
	// CONFIGS_DIR is the directory where the configs files project inputs are stored
	CONFIGS_DIR = string(types.ProjectInputConfigs)
	// M2K_PLAN_FILENAME is the name of the plan file generated by Move2Kube CLI
	M2K_PLAN_FILENAME = common.APP_NAME_SHORT + ".plan"
	// M2K_QA_SERVER_METADATA_FILE is the name of the file containing the QA server metadata
	M2K_QA_SERVER_METADATA_FILE = common.APP_NAME_SHORT + ".qaserver"
	// M2K_PLAN_PROGRESS_SERVER_METADATA_FILE is the name of the file containing the plan progress server metadata
	M2K_PLAN_PROGRESS_SERVER_METADATA_FILE = common.APP_NAME_SHORT + ".planprogressserver"
	// M2K_CLI_LOG_FILE is the name of the log file that the CLI writes to
	M2K_CLI_LOG_FILE = common.APP_NAME_SHORT + "cli.log"
	// PROJECT_METADATA_FILE is the name of the file containing the project metadata
	PROJECT_METADATA_FILE = "metadata"
	// DEFAULT_DIRECTORY_PERMISSIONS is the default permissions used when creating new directories
	DEFAULT_DIRECTORY_PERMISSIONS os.FileMode = 0775
	// DEFAULT_FILE_PERMISSIONS is the default permissions used when creating new files
	DEFAULT_FILE_PERMISSIONS os.FileMode = 0660
	// DATABASE_FILENAME is the database filename
	DATABASE_FILENAME = "database"
	// WORKSPACES_BUCKET is the workspaces bucket
	WORKSPACES_BUCKET = "workspaces"
	// PROJECTS_BUCKET is the projects bucket
	PROJECTS_BUCKET = "projects"
)

Variables

View Source
var (
	// VALID_ARCHIVE_EXTS is the list of archive formats that are supported
	VALID_ARCHIVE_EXTS = []string{".zip", ".tar", ".tgz", ".gz"}
	// LOG_LEVEL_REGEXP is the regexp used to capture the loglevel from the CLI output
	LOG_LEVEL_REGEXP = regexp.MustCompile(`level=([a-z]+) `)
	// TIMESTAMP_REGEXP is the regexp used to replace the the timestamp in the CLI output with a different message
	TIMESTAMP_REGEXP = regexp.MustCompile(`time="\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(Z|\+\d{2}:\d{2})"`)
)

Functions

func CopyFile

func CopyFile(dst, src string) error

CopyFile copies a file from src to dst. The dst file will be truncated if it exists. Returns an error if it failed to copy all the bytes.

Types

type FileSystem

type FileSystem struct{}

FileSystem implements the IFileSystem interface and manages the workspace and project data in the filesystem

func NewFileSystem

func NewFileSystem() (*FileSystem, error)

NewFileSystem returns a new IFileSystem object which manages workspaces and projects in the filesystem

func (*FileSystem) CreateProject

func (fs *FileSystem) CreateProject(workspaceId string, project types.Project) error

CreateProject creates a new project in the filesystem

func (*FileSystem) CreateProjectInput

func (fs *FileSystem) CreateProjectInput(workspaceId, projectId string, projInput types.ProjectInput, file io.Reader, isCommon bool) error

CreateProjectInput creates an input for the project in the filesystem

func (*FileSystem) CreateWorkspace

func (fs *FileSystem) CreateWorkspace(workspace types.Workspace) error

CreateWorkspace creates a new workspace

func (*FileSystem) DeletePlan

func (fs *FileSystem) DeletePlan(workspaceId, projectId string) error

DeletePlan deletes plan for a project

func (*FileSystem) DeleteProject

func (fs *FileSystem) DeleteProject(workspaceId string, projectId string) error

DeleteProject deletes an project from the filesysem

func (*FileSystem) DeleteProjectInput

func (fs *FileSystem) DeleteProjectInput(workspaceId, projectId, projInputId string, isCommon bool) error

DeleteProjectInput deletes the project input

func (*FileSystem) DeleteProjectOutput

func (fs *FileSystem) DeleteProjectOutput(workspaceId, projectId, projOutputId string) error

DeleteProjectOutput deletes the project output

func (*FileSystem) DeleteWorkspace

func (fs *FileSystem) DeleteWorkspace(workspaceId string) error

DeleteWorkspace deletes an existing workspace

func (*FileSystem) Download

func (*FileSystem) Download() (io.Reader, string, error)

Download returns the app binary

func (*FileSystem) GetDatabase

func (*FileSystem) GetDatabase(readOnly bool) (*bolt.DB, error)

GetDatabase returns the database. The database must be closed by the caller.

func (*FileSystem) GetQuestion

func (fs *FileSystem) GetQuestion(workspaceId, projectId, projOutputId string) (problem string, err error)

GetQuestion returns the current question for application which is in transformation phase. If there are no more questions, this will return "", nil.

func (*FileSystem) GetSupportInfo

func (*FileSystem) GetSupportInfo() map[string]string

GetSupportInfo returns information useful for debugging. Returns the output of move2kube version -l

func (*FileSystem) ListProjects

func (fs *FileSystem) ListProjects(workspaceId string) ([]types.Project, error)

ListProjects returns the list of projects in the workspace

func (*FileSystem) ListWorkspaceIds

func (fs *FileSystem) ListWorkspaceIds() ([]string, error)

ListWorkspaceIds returns the list of workspace Ids

func (*FileSystem) ListWorkspaces

func (fs *FileSystem) ListWorkspaces(workspaceIds []string) ([]types.Workspace, error)

ListWorkspaces returns the list of workspaces

func (*FileSystem) PostSolution

func (fs *FileSystem) PostSolution(workspaceId, projectId, projOutputId, solution string) error

PostSolution posts the solution for the current question

func (*FileSystem) ReadPlan

func (fs *FileSystem) ReadPlan(workspaceId, projectId string) (file io.Reader, err error)

ReadPlan returns the plan for a project

func (*FileSystem) ReadProject

func (fs *FileSystem) ReadProject(workspaceId string, projectId string) (types.Project, error)

ReadProject returns the metadata about a project

func (*FileSystem) ReadProjectInput

func (fs *FileSystem) ReadProjectInput(workspaceId, projectId, projInputId string, isCommon bool) (projInput types.ProjectInput, file io.Reader, err error)

ReadProjectInput returns a project input

func (*FileSystem) ReadProjectOutput

func (fs *FileSystem) ReadProjectOutput(workspaceId, projectId, projOutputId string) (projOutput types.ProjectOutput, file io.Reader, err error)

ReadProjectOutput returns the target artifacts for an application

func (*FileSystem) ReadProjectOutputGraph added in v0.3.3

func (fs *FileSystem) ReadProjectOutputGraph(workspaceId, projectId, projOutputId string) (projOutput types.ProjectOutput, file io.Reader, err error)

ReadProjectOutputGraph returns the graph file from the target artifacts for an application

func (*FileSystem) ReadWorkspace

func (fs *FileSystem) ReadWorkspace(workspaceId string) (types.Workspace, error)

ReadWorkspace reads an existing workspace

func (*FileSystem) ResumeTransformation

func (fs *FileSystem) ResumeTransformation(workspaceId, projectId, projOutputId string, debugMode, skipQA bool) error

ResumeTransformation resumes a transformation that did not finish

func (*FileSystem) StartPlanning

func (fs *FileSystem) StartPlanning(workspaceId, projectId, remoteSource string, debugMode bool) error

StartPlanning starts the generation of a plan for a project. If plan generation is ongoing it will return an error.

func (*FileSystem) StartTransformation

func (fs *FileSystem) StartTransformation(workspaceId, projectId string, projOutput types.ProjectOutput, plan io.Reader, debugMode, skipQA bool) error

StartTransformation starts the transformation for a project.

func (*FileSystem) UpdatePlan

func (fs *FileSystem) UpdatePlan(workspaceId, projectId string, plan io.Reader) error

UpdatePlan updates the plan file for a project

func (*FileSystem) UpdateProject

func (fs *FileSystem) UpdateProject(workspaceId string, project types.Project) error

UpdateProject updates a new project in the filesystem

func (*FileSystem) UpdateWorkspace

func (fs *FileSystem) UpdateWorkspace(workspace types.Workspace) error

UpdateWorkspace updates an existing workspace

type IFileSystem

type IFileSystem interface {
	GetSupportInfo() map[string]string
	Download() (file io.Reader, filename string, err error)
	ListWorkspaceIds() ([]string, error)
	ListWorkspaces(workspaceIds []string) ([]types.Workspace, error)
	CreateWorkspace(workspace types.Workspace) error
	ReadWorkspace(workspaceId string) (types.Workspace, error)
	UpdateWorkspace(workspace types.Workspace) error
	DeleteWorkspace(workspaceId string) error
	ListProjects(workspaceId string) ([]types.Project, error)
	CreateProject(workspaceId string, project types.Project) error
	ReadProject(workspaceId, projectId string) (types.Project, error)
	UpdateProject(workspaceId string, project types.Project) error
	DeleteProject(workspaceId, projectId string) error
	CreateProjectInput(workspaceId, projectId string, projInput types.ProjectInput, file io.Reader, isCommon bool) error
	ReadProjectInput(workspaceId, projectId, projInputId string, isCommon bool) (projInput types.ProjectInput, file io.Reader, err error)
	DeleteProjectInput(workspaceId, projectId, projInputId string, isCommon bool) error
	StartPlanning(workspaceId, projectId, remoteSource string, debugMode bool) error
	ReadPlan(workspaceId, projectId string) (plan io.Reader, err error)
	UpdatePlan(workspaceId, projectId string, plan io.Reader) error
	DeletePlan(workspaceId, projectId string) error
	StartTransformation(workspaceId, projectId string, projOutput types.ProjectOutput, plan io.Reader, debugMode, skipQA bool) error
	ResumeTransformation(workspaceId, projectId, projOutputId string, debugMode, skipQA bool) error
	ReadProjectOutput(workspaceId, projectId, projOutputId string) (projOutput types.ProjectOutput, file io.Reader, err error)
	ReadProjectOutputGraph(workspaceId, projectId, projOutputId string) (projOutput types.ProjectOutput, file io.Reader, err error)
	DeleteProjectOutput(workspaceId, projectId, projOutputId string) error
	GetQuestion(workspaceId, projectId, projOutputId string) (problem string, err error)
	PostSolution(workspaceId, projectId, projOutputId, solution string) error
}

IFileSystem defines an interface that can manage Move2Kube workspaces and projects

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL