fs

package
v1.15.3 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2026 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateUniqueDir

func CreateUniqueDir(projectsRoot, basePath, name string, perm os.FileMode) (path, folderName string, err error)

CreateUniqueDir creates a unique directory within the allowed projectsRoot. It validates that the created directory is always within projectsRoot.

func EnsureDefaultTemplates

func EnsureDefaultTemplates(ctx context.Context) error

func EnsureTemplateDir

func EnsureTemplateDir(ctx context.Context, base string) (dir, composePath, envPath string, err error)

func GetProjectsDirectory

func GetProjectsDirectory(ctx context.Context, projectsDir string) (string, error)

func GetTemplatesDirectory

func GetTemplatesDirectory(ctx context.Context) (string, error)

func ImportedComposeDescription

func ImportedComposeDescription(dir string) string

func IsSafeSubdirectory

func IsSafeSubdirectory(baseDir, subdir string) bool

IsSafeSubdirectory returns true if subdir is a subdirectory of baseDir (absolute, normalized)

func ReadFolderComposeTemplate

func ReadFolderComposeTemplate(baseDir, folder string) (string, *string, string, bool, error)

func ReadProjectFiles

func ReadProjectFiles(projectPath string) (composeContent, envContent string, err error)

func SanitizeProjectName

func SanitizeProjectName(name string) string

func SaveOrUpdateProjectFiles

func SaveOrUpdateProjectFiles(projectsRoot, projectPath, composeContent string, envContent *string) error

func Slugify

func Slugify(in string) string

func WriteComposeFile

func WriteComposeFile(projectsRoot, dirPath, content string) error

WriteComposeFile writes a compose file to the specified directory. It detects existing compose file names (docker-compose.yml, compose.yaml, etc.) and uses the existing name if found, otherwise defaults to compose.yaml projectsRoot is the allowed root directory to prevent path traversal attacks

func WriteEnvFile

func WriteEnvFile(projectsRoot, dirPath, content string) error

WriteEnvFile writes a .env file to the specified directory projectsRoot is the allowed root directory to prevent path traversal attacks

func WriteFileWithPerm

func WriteFileWithPerm(filePath, content string, perm os.FileMode) error

WriteFileWithPerm is a generic file writer with custom permissions

func WriteProjectFiles

func WriteProjectFiles(projectsRoot, dirPath, composeContent string, envContent *string) error

WriteProjectFiles writes both compose and env files to a project directory. An empty .env file is always created to prevent compose-go from failing when the compose file references env_file: .env projectsRoot is the allowed root directory to prevent path traversal attacks

func WriteTemplateFile

func WriteTemplateFile(filePath, content string) error

WriteTemplateFile writes a template file (like .compose.template or .env.template)

func WriteTemplateFiles

func WriteTemplateFiles(composePath, envPath, composeContent, envContent string) (*string, error)

Types

type Watcher

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

func NewWatcher

func NewWatcher(watchPath string, opts WatcherOptions) (*Watcher, error)

func (*Watcher) Start

func (fw *Watcher) Start(ctx context.Context) error

func (*Watcher) Stop

func (fw *Watcher) Stop() error

type WatcherOptions

type WatcherOptions struct {
	Debounce time.Duration
	OnChange func(ctx context.Context)
	MaxDepth int
}

Jump to

Keyboard shortcuts

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