//go:build mage package main import ( "fmt" "os" "github.com/magefile/mage/sh" ) const ( configFile string = "./config/services.json" rootBuildDir string = "./build" templateExtension string = ".gotmpl" rootTemplatesDir string = "./templates" ) // Clean cleans the workspace. func Clean() error { buildDir := "./build" objects, err := os.ReadDir(buildDir) if err != nil { return err } for i := range objects { name := objects[i].Name() if name != ".gitkeep" { if err := sh.Rm(buildDir + "/" + name); err != nil { return err } } } return nil } // Download downaloads the binaries for a given service. func Download(name string) error { cfg, err := newConfig(configFile) if err != nil { return fmt.Errorf("unable to load the configuration; %v", err) } if name == "forgejo" { if err := downloadForgejo(cfg.Forgejo.Version); err != nil { return fmt.Errorf("an error occurred whilst getting the forgejo binary; %w", err) } } else { return fmt.Errorf("unsupported service: %s", name) } return nil }