A lot of changes
This commit is contained in:
@ -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 {
|
||||
|
Reference in New Issue
Block a user