Serge Bazanski | be538db | 2020-11-12 00:22:42 +0100 | [diff] [blame] | 1 | // Copyright 2017 The kubecfg authors |
| 2 | // |
| 3 | // |
| 4 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | // you may not use this file except in compliance with the License. |
| 6 | // You may obtain a copy of the License at |
| 7 | // |
| 8 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | // |
| 10 | // Unless required by applicable law or agreed to in writing, software |
| 11 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | // See the License for the specific language governing permissions and |
| 14 | // limitations under the License. |
| 15 | |
| 16 | package main |
| 17 | |
| 18 | import ( |
| 19 | "os" |
| 20 | |
| 21 | log "github.com/sirupsen/logrus" |
| 22 | |
| 23 | "code.hackerspace.pl/hscloud/cluster/tools/kartongips/cmd" |
| 24 | "code.hackerspace.pl/hscloud/cluster/tools/kartongips/pkg/kubecfg" |
| 25 | ) |
| 26 | |
Serge Bazanski | 6403361 | 2020-11-12 00:36:50 +0100 | [diff] [blame] | 27 | var Version = "unknown" |
Serge Bazanski | be538db | 2020-11-12 00:22:42 +0100 | [diff] [blame] | 28 | |
| 29 | func main() { |
Serge Bazanski | 6403361 | 2020-11-12 00:36:50 +0100 | [diff] [blame] | 30 | cmd.Version = Version |
Serge Bazanski | be538db | 2020-11-12 00:22:42 +0100 | [diff] [blame] | 31 | |
| 32 | if err := cmd.RootCmd.Execute(); err != nil { |
| 33 | // PersistentPreRunE may not have been run for early |
| 34 | // errors, like invalid command line flags. |
| 35 | logFmt := cmd.NewLogFormatter(log.StandardLogger().Out) |
| 36 | log.SetFormatter(logFmt) |
| 37 | log.Error(err.Error()) |
| 38 | |
| 39 | switch err { |
| 40 | case kubecfg.ErrDiffFound: |
| 41 | os.Exit(10) |
| 42 | default: |
| 43 | os.Exit(1) |
| 44 | } |
| 45 | } |
| 46 | } |