diff --git a/cmd/hauler/cli/cli.go b/cmd/hauler/cli/cli.go index 7ebc136..17bb49b 100644 --- a/cmd/hauler/cli/cli.go +++ b/cmd/hauler/cli/cli.go @@ -11,8 +11,9 @@ var ro = &flags.CliRootOpts{} func New() *cobra.Command { cmd := &cobra.Command{ - Use: "hauler", - Short: "Airgap Swiss Army Knife", + Use: "hauler", + Short: "Airgap Swiss Army Knife", + Example: " View the Docs: https://docs.hauler.dev\n Environment Variables: HAULER_DIR | HAULER_TEMP_DIR", PersistentPreRunE: func(cmd *cobra.Command, args []string) error { l := log.FromContext(cmd.Context()) l.SetLevel(ro.LogLevel) diff --git a/cmd/hauler/cli/store/load.go b/cmd/hauler/cli/store/load.go index 4e00a7b..ed68ae2 100644 --- a/cmd/hauler/cli/store/load.go +++ b/cmd/hauler/cli/store/load.go @@ -30,17 +30,21 @@ func LoadCmd(ctx context.Context, o *flags.LoadOpts, archiveRefs ...string) erro // unarchiveLayoutTo accepts an archived oci layout and extracts the contents to an existing oci layout, preserving the index func unarchiveLayoutTo(ctx context.Context, archivePath string, dest string, tempOverride string) error { - tmpdir, err := os.MkdirTemp(tempOverride, "hauler") + if tempOverride == "" { + tempOverride = os.Getenv("HAULER_TEMP_DIR") + } + + tempDir, err := os.MkdirTemp(tempOverride, "hauler") if err != nil { return err } - defer os.RemoveAll(tmpdir) + defer os.RemoveAll(tempDir) - if err := archiver.Unarchive(archivePath, tmpdir); err != nil { + if err := archiver.Unarchive(archivePath, tempDir); err != nil { return err } - s, err := store.NewLayout(tmpdir) + s, err := store.NewLayout(tempDir) if err != nil { return err } diff --git a/pkg/content/chart/chart_test.go b/pkg/content/chart/chart_test.go index fda3f76..94133e9 100644 --- a/pkg/content/chart/chart_test.go +++ b/pkg/content/chart/chart_test.go @@ -14,11 +14,11 @@ import ( ) func TestNewChart(t *testing.T) { - tmpdir, err := os.MkdirTemp("", "hauler") + tempDir, err := os.MkdirTemp("", "hauler") if err != nil { t.Fatal(err) } - defer os.RemoveAll(tmpdir) + defer os.RemoveAll(tempDir) type args struct { name string @@ -53,7 +53,7 @@ func TestNewChart(t *testing.T) { // { // name: "should create from a chart directory", // args: args{ - // path: filepath.Join(tmpdir, "podinfo"), + // path: filepath.Join(tempDir, "podinfo"), // }, // want: want, // wantErr: false, diff --git a/pkg/cosign/cosign.go b/pkg/cosign/cosign.go index 71fed74..cc3c80c 100644 --- a/pkg/cosign/cosign.go +++ b/pkg/cosign/cosign.go @@ -256,7 +256,10 @@ func getCosignPath() (string, error) { homeDir := currentUser.HomeDir // Construct the path to the .hauler directory - haulerDir := filepath.Join(homeDir, ".hauler") + haulerDir := os.Getenv("HAULER_DIR") + if haulerDir == "" { + haulerDir = filepath.Join(homeDir, ".hauler") + } // Create the .hauler directory if it doesn't exist if _, err := os.Stat(haulerDir); os.IsNotExist(err) { diff --git a/pkg/store/store_test.go b/pkg/store/store_test.go index 5c4bd59..c7bcf76 100644 --- a/pkg/store/store_test.go +++ b/pkg/store/store_test.go @@ -63,16 +63,16 @@ func TestLayout_AddOCI(t *testing.T) { } func setup(t *testing.T) func() error { - tmpdir, err := os.MkdirTemp("", "hauler") + tempDir, err := os.MkdirTemp("", "hauler") if err != nil { t.Fatal(err) } - root = tmpdir + root = tempDir ctx = context.Background() return func() error { - os.RemoveAll(tmpdir) + os.RemoveAll(tempDir) return nil } }