forked from carvel-dev/kapp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkapp.go
50 lines (39 loc) · 1016 Bytes
/
kapp.go
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
// Copyright 2020 VMware, Inc.
// SPDX-License-Identifier: Apache-2.0
package main
import (
"math/rand"
"os"
"time"
uierrs "github.com/cppforlife/go-cli-ui/errors"
"github.com/cppforlife/go-cli-ui/ui"
"github.com/k14s/kapp/pkg/kapp/cmd"
cmdapp "github.com/k14s/kapp/pkg/kapp/cmd/app"
// Import to initialize client auth plugins.
_ "k8s.io/client-go/plugin/pkg/client/auth"
)
func main() {
err := nonExitingMain()
if err != nil {
if typedErr, ok := err.(cmdapp.ExitStatus); ok {
os.Exit(typedErr.ExitStatus())
}
os.Exit(1)
}
}
// nonExitingMain does not use os.Exit to make sure Go runs defers
func nonExitingMain() error {
rand.Seed(time.Now().UTC().UnixNano())
// TODO logs
// TODO log flags used
confUI := ui.NewConfUI(ui.NewNoopLogger())
defer confUI.Flush()
command := cmd.NewDefaultKappCmd(confUI)
err := command.Execute()
if err != nil {
confUI.ErrorLinef("kapp: Error: %v", uierrs.NewMultiLineError(err))
return err
}
confUI.PrintLinef("Succeeded")
return nil
}