...

Package files

Overview ▾

func GetFilesGeneratedByOdo

func GetFilesGeneratedByOdo(filesys filesystem.Filesystem, rootDirectory string) ([]string, error)

GetFilesGeneratedByOdo returns a list of files that were initially created by odo. Under the hood, it works by reading the content of the .odo/generated file (ignoring blank lines), which is filled by any command that generates a file. odo commands that generate files should call ReportLocalFileGeneratedByOdo anytime a file is generated. Note that the .odo directory itself is always included in the list returned. No error is returned if the .odo/generated file does not exist.

func ReportLocalFileGeneratedByOdo

func ReportLocalFileGeneratedByOdo(filesys filesystem.Filesystem, rootDirectory string, filePath string) error

ReportLocalFileGeneratedByOdo appends the specified file path to the .odo/generated file, taking care of creating it if it does not exist. The file path can be absolute or relative to the root directory specified. This function should be called by odo commands that generate a file, anytime a new file is generated by odo. This way, we would be able to determine (via GetFilesGeneratedByOdo) if a file was created by odo or not, in case we need for example to delete it.

Note that it is quite impossible with this approach to cover all scenarios; for example, if an odo command generates a new file (and calls ReportLocalFileGeneratedByOdo as expected), but the user later deletes it and recreates it, GetFilesGeneratedByOdo would still return this file path.