A lot of changes

This commit is contained in:
Nikolai Rodionov
2024-07-25 18:44:58 +02:00
parent 625450ca25
commit 6e08510b3d
25 changed files with 225 additions and 443 deletions

View File

@ -1,9 +1,19 @@
package workdir
import "os"
import (
"context"
"os"
func CreateWorkdir(path string) (workdir string, err error) {
"github.com/go-logr/logr"
)
func CreateWorkdir(ctx context.Context, path string) (workdir string, err error) {
log, err := logr.FromContext(ctx)
if err != nil {
return "", err
}
if len(path) > 0 {
log.Info("Creating a new directory", "path", path)
// Create a dir using the path
if err := os.Mkdir(path, 0777); err != nil {
return path, err
@ -11,6 +21,7 @@ func CreateWorkdir(path string) (workdir string, err error) {
// TODO(@allanger): I've got a feeling that it doesn't have to look that bad
workdir = path
} else {
log.Info("Path is not set, creating a temporary directory")
// Create a temporary dir
workdir, err = os.MkdirTemp("", "shoebill")
if err != nil {