-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
updated/fixed hauler directory (#354)
* added env variables for haulerDir/tempDir * updated hauler directory for the install script * cleanup/fixes for install script * updated variables based on feedback * revert "updated variables based on feedback" * reverts commit 54f7a4d * minor restructure to root flags * updated logic to include haulerdir flag * cleaned up/formatted new logic * more cleanup and formatting
- Loading branch information
1 parent
38c7d1b
commit 1b77295
Showing
26 changed files
with
256 additions
and
184 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,46 @@ | ||
package cli | ||
|
||
import ( | ||
"context" | ||
"embed" | ||
|
||
"github.com/spf13/cobra" | ||
|
||
"hauler.dev/go/hauler/internal/flags" | ||
"hauler.dev/go/hauler/pkg/consts" | ||
"hauler.dev/go/hauler/pkg/cosign" | ||
"hauler.dev/go/hauler/pkg/log" | ||
) | ||
|
||
var ro = &flags.CliRootOpts{} | ||
|
||
func New() *cobra.Command { | ||
func New(ctx context.Context, binaries embed.FS, ro *flags.CliRootOpts) *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: " + consts.HaulerDir + " | " + consts.HaulerTempDir, | ||
PersistentPreRunE: func(cmd *cobra.Command, args []string) error { | ||
l := log.FromContext(cmd.Context()) | ||
l := log.FromContext(ctx) | ||
l.SetLevel(ro.LogLevel) | ||
l.Debugf("running cli command [%s]", cmd.CommandPath()) | ||
|
||
// ensure cosign binary is available | ||
if err := cosign.EnsureBinaryExists(ctx, binaries, ro); err != nil { | ||
l.Errorf("cosign binary missing: %v", err) | ||
return err | ||
} | ||
|
||
return nil | ||
}, | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
return cmd.Help() | ||
}, | ||
} | ||
|
||
pf := cmd.PersistentFlags() | ||
pf.StringVarP(&ro.LogLevel, "log-level", "l", "info", "") | ||
flags.AddRootFlags(cmd, ro) | ||
|
||
// Add subcommands | ||
addLogin(cmd) | ||
addStore(cmd) | ||
addVersion(cmd) | ||
addCompletion(cmd) | ||
addLogin(cmd, ro) | ||
addStore(cmd, ro) | ||
addVersion(cmd, ro) | ||
addCompletion(cmd, ro) | ||
|
||
return cmd | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.