main.go 1.4 KB
Newer Older
Angus Lees's avatar
Angus Lees committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
// Copyright 2017 The kubecfg authors
//
//
//    Licensed under the Apache License, Version 2.0 (the "License");
//    you may not use this file except in compliance with the License.
//    You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
//    Unless required by applicable law or agreed to in writing, software
//    distributed under the License is distributed on an "AS IS" BASIS,
//    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//    See the License for the specific language governing permissions and
//    limitations under the License.

16 17 18
package main

import (
19 20
	"os"

21
	log "github.com/sirupsen/logrus"
22

bryanl's avatar
bryanl committed
23
	"github.com/ksonnet/ksonnet/pkg/clicmd"
24
	"github.com/ksonnet/ksonnet/pkg/kubecfg"
25 26 27 28
)

// Version is overridden using `-X main.version` during release builds
var version = "(dev build)"
bryanl's avatar
bryanl committed
29
var apimachineryVersion = ""
30 31

func main() {
bryanl's avatar
bryanl committed
32 33
	clicmd.Version = version
	clicmd.APImachineryVersion = apimachineryVersion
34

bryanl's avatar
bryanl committed
35
	if err := clicmd.RootCmd.Execute(); err != nil {
36 37
		// PersistentPreRunE may not have been run for early
		// errors, like invalid command line flags.
bryanl's avatar
bryanl committed
38 39 40 41 42
		logFmt := &log.TextFormatter{
			DisableTimestamp:       true,
			DisableLevelTruncation: true,
			QuoteEmptyFields:       true,
		}
43
		log.SetFormatter(logFmt)
bryanl's avatar
bryanl committed
44

45
		log.Error(err.Error())
46

47
		switch err {
48
		case kubecfg.ErrDiffFound:
49
			os.Exit(10)
50
		default:
51
			os.Exit(1)
52
		}
53 54
	}
}