-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathmain.go
More file actions
60 lines (56 loc) · 2.3 KB
/
Copy pathmain.go
File metadata and controls
60 lines (56 loc) · 2.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package main
import (
"fmt"
"os"
"path/filepath"
"github.com/konveyor/crane/cmd/apply"
"github.com/konveyor/crane/cmd/convert"
export "github.com/konveyor/crane/cmd/export"
plugin_manager "github.com/konveyor/crane/cmd/plugin-manager"
skopeo_sync_gen "github.com/konveyor/crane/cmd/skopeo-sync-gen"
transfer_pvc "github.com/konveyor/crane/cmd/transfer-pvc"
"github.com/konveyor/crane/cmd/transform"
tunnel_api "github.com/konveyor/crane/cmd/tunnel-api"
"github.com/konveyor/crane/cmd/validate"
"github.com/konveyor/crane/cmd/version"
"github.com/konveyor/crane/internal/flags"
"github.com/spf13/cobra"
"k8s.io/cli-runtime/pkg/genericclioptions"
)
func main() {
os.Exit(run())
}
func run() int {
f := &flags.GlobalFlags{}
defer func() {
if err := f.Close(); err != nil {
fmt.Fprintf(os.Stderr, "warning: failed to close audit log: %v\n", err)
}
}()
root := cobra.Command{
Use: filepath.Base(os.Args[0]),
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
// Validate audit logger initialization.
// Note: Logger is initialized before convert's Complete() applies --debug flag,
// so the console hook is created with debug disabled. Subsequent Debug=true
// doesn't update the hook's log level. This affects only the deprecated convert command.
_, err := f.GetLoggerOrDefault()
return err
},
}
f.ApplyFlags(&root)
root.AddCommand(export.NewExportCommand(genericclioptions.IOStreams{In: os.Stdin, Out: os.Stdout, ErrOut: os.Stderr}, f))
root.AddCommand(transfer_pvc.NewTransferPVCCommand(genericclioptions.IOStreams{In: os.Stdin, Out: os.Stdout, ErrOut: os.Stderr}, f))
root.AddCommand(tunnel_api.NewTunnelAPIOptions(genericclioptions.IOStreams{In: os.Stdin, Out: os.Stdout, ErrOut: os.Stderr}, f))
root.AddCommand(convert.NewConvertOptions(genericclioptions.IOStreams{In: os.Stdin, Out: os.Stdout, ErrOut: os.Stderr}, f))
root.AddCommand(transform.NewTransformCommand(f))
root.AddCommand(skopeo_sync_gen.NewSkopeoSyncGenCommand(f))
root.AddCommand(apply.NewApplyCommand(f))
root.AddCommand(plugin_manager.NewPluginManagerCommand(f))
root.AddCommand(version.NewVersionCommand(f))
root.AddCommand(validate.NewValidateCommand(genericclioptions.IOStreams{In: os.Stdin, Out: os.Stdout, ErrOut: os.Stderr}, f))
if err := root.Execute(); err != nil {
return 1
}
return 0
}