Documentation
¶
Index ¶
- func CreateUniqueDir(projectsRoot, basePath, name string, perm os.FileMode) (path, folderName string, err error)
- func EnsureDefaultTemplates(ctx context.Context) error
- func EnsureTemplateDir(ctx context.Context, base string) (dir, composePath, envPath string, err error)
- func GetProjectsDirectory(ctx context.Context, projectsDir string) (string, error)
- func GetTemplatesDirectory(ctx context.Context) (string, error)
- func ImportedComposeDescription(dir string) string
- func IsSafeSubdirectory(baseDir, subdir string) bool
- func ReadFolderComposeTemplate(baseDir, folder string) (string, *string, string, bool, error)
- func ReadProjectFiles(projectPath string) (composeContent, envContent string, err error)
- func SanitizeProjectName(name string) string
- func SaveOrUpdateProjectFiles(projectsRoot, projectPath, composeContent string, envContent *string) error
- func Slugify(in string) string
- func WriteComposeFile(projectsRoot, dirPath, content string) error
- func WriteEnvFile(projectsRoot, dirPath, content string) error
- func WriteFileWithPerm(filePath, content string, perm os.FileMode) error
- func WriteProjectFiles(projectsRoot, dirPath, composeContent string, envContent *string) error
- func WriteTemplateFile(filePath, content string) error
- func WriteTemplateFiles(composePath, envPath, composeContent, envContent string) (*string, error)
- type Watcher
- type WatcherOptions
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 EnsureTemplateDir ¶
func GetProjectsDirectory ¶
func IsSafeSubdirectory ¶
IsSafeSubdirectory returns true if subdir is a subdirectory of baseDir (absolute, normalized)
func ReadProjectFiles ¶
func SanitizeProjectName ¶
func WriteComposeFile ¶
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 ¶
WriteEnvFile writes a .env file to the specified directory projectsRoot is the allowed root directory to prevent path traversal attacks
func WriteFileWithPerm ¶
WriteFileWithPerm is a generic file writer with custom permissions
func WriteProjectFiles ¶
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 ¶
WriteTemplateFile writes a template file (like .compose.template or .env.template)
func WriteTemplateFiles ¶
Types ¶
type Watcher ¶
type Watcher struct {
// contains filtered or unexported fields
}
func NewWatcher ¶
func NewWatcher(watchPath string, opts WatcherOptions) (*Watcher, error)