本文整理匯總了Golang中github.com/golang/glog.FatalDepth函數的典型用法代碼示例。如果您正苦於以下問題:Golang FatalDepth函數的具體用法?Golang FatalDepth怎麽用?Golang FatalDepth使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了FatalDepth函數的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: NewCmdConfigView
func NewCmdConfigView(out io.Writer, pathOptions *pathOptions) *cobra.Command {
options := &viewOptions{pathOptions: pathOptions}
cmd := &cobra.Command{
Use: "view",
Short: "displays merged .kubeconfig settings or a specified .kubeconfig file.",
Long: view_long,
Example: view_example,
Run: func(cmd *cobra.Command, args []string) {
options.complete()
printer, _, err := cmdutil.PrinterForCommand(cmd)
if err != nil {
glog.FatalDepth(1, err)
}
config, err := options.loadConfig()
if err != nil {
glog.FatalDepth(1, err)
}
err = printer.PrintObj(config, out)
if err != nil {
glog.FatalDepth(1, err)
}
},
}
cmdutil.AddPrinterFlags(cmd)
// Default to yaml
cmd.Flags().Set("output", "yaml")
options.merge.Default(true)
cmd.Flags().Var(&options.merge, "merge", "merge together the full hierarchy of .kubeconfig files")
return cmd
}
示例2: CheckErr
func CheckErr(err error) {
if err != nil {
if errors.IsStatusError(err) {
glog.FatalDepth(1, fmt.Sprintf("Error received from API: %s", err.Error()))
}
if errors.IsUnexpectedObjectError(err) {
glog.FatalDepth(1, fmt.Sprintf("Unexpected object received from server: %s", err.Error()))
}
if client.IsUnexpectedStatusError(err) {
glog.FatalDepth(1, fmt.Sprintf("Unexpected status received from server: %s", err.Error()))
}
glog.FatalDepth(1, fmt.Sprintf("Client error processing command: %s", err.Error()))
}
}
示例3: fatal
func fatal(msg string) {
if glog.V(2) {
glog.FatalDepth(2, msg)
}
fmt.Fprintln(os.Stderr, msg)
os.Exit(1)
}
示例4: GetConfigFromFileOrDie
// GetConfigFromFileOrDie tries to read a kubeconfig file and if it can't, it calls exit. One exception, missing files result in empty configs, not an exit
func GetConfigFromFileOrDie(filename string) *clientcmdapi.Config {
config, err := getConfigFromFile(filename)
if err != nil {
glog.FatalDepth(1, err)
}
return config
}
示例5: NewCmdConfigView
func NewCmdConfigView(out io.Writer, ConfigAccess ConfigAccess) *cobra.Command {
options := &ViewOptions{ConfigAccess: ConfigAccess}
// Default to yaml
defaultOutputFormat := "yaml"
cmd := &cobra.Command{
Use: "view",
Short: "Displays merged kubeconfig settings or a specified kubeconfig file.",
Long: view_long,
Example: view_example,
Run: func(cmd *cobra.Command, args []string) {
options.Complete()
outputFormat := cmdutil.GetFlagString(cmd, "output")
if outputFormat == "wide" {
fmt.Printf("--output wide is not available in kubectl config view; reset to default output format (%s)\n\n", defaultOutputFormat)
cmd.Flags().Set("output", defaultOutputFormat)
}
printer, _, err := cmdutil.PrinterForCommand(cmd)
if err != nil {
glog.FatalDepth(1, err)
}
version := cmdutil.OutputVersion(cmd, latest.Version)
printer = kubectl.NewVersionedPrinter(printer, clientcmdapi.Scheme, version)
if err := options.Run(out, printer); err != nil {
glog.FatalDepth(1, err)
}
},
}
cmdutil.AddPrinterFlags(cmd)
cmd.Flags().Set("output", defaultOutputFormat)
options.Merge.Default(true)
cmd.Flags().Var(&options.Merge, "merge", "merge together the full hierarchy of kubeconfig files")
cmd.Flags().BoolVar(&options.RawByteData, "raw", false, "display raw byte data")
cmd.Flags().BoolVar(&options.Flatten, "flatten", false, "flatten the resulting kubeconfig file into self contained output (useful for creating portable kubeconfig files)")
cmd.Flags().BoolVar(&options.Minify, "minify", false, "remove all information not used by current-context from the output")
return cmd
}
示例6: fatal
// fatal prints the message and then exits. If V(2) or greater, glog.Fatal
// is invoked for extended information.
func fatal(msg string) {
// add newline if needed
if !strings.HasSuffix(msg, "\n") {
msg += "\n"
}
if glog.V(2) {
glog.FatalDepth(2, msg)
}
fmt.Fprint(os.Stderr, msg)
os.Exit(1)
}
示例7: GetConfigFromFileOrDie
// GetConfigFromFileOrDie tries to read a kubeconfig file and if it can't, it calls exit. One exception, missing files result in empty configs, not an exit
func GetConfigFromFileOrDie(filename string) *clientcmdapi.Config {
config, err := LoadFromFile(filename)
if err != nil && !os.IsNotExist(err) {
glog.FatalDepth(1, err)
}
if config == nil {
return clientcmdapi.NewConfig()
}
return config
}
示例8: fatal
// fatal prints the message (if provided) and then exits. If V(2) or greater,
// glog.Fatal is invoked for extended information.
func fatal(msg string, code int) {
if glog.V(2) {
glog.FatalDepth(2, msg)
}
if len(msg) > 0 {
// add newline if needed
if !strings.HasSuffix(msg, "\n") {
msg += "\n"
}
fmt.Fprint(os.Stderr, msg)
}
os.Exit(code)
}
示例9: checkErr
func checkErr(err error) {
if err != nil {
glog.FatalDepth(1, err)
}
}
示例10: Fatalf
func (Logger) Fatalf(format string, args ...interface{}) {
glog.FatalDepth(3, fmt.Sprintf(format, args...))
}
示例11: Fatalln
func (g *glogger) Fatalln(args ...interface{}) {
glog.FatalDepth(2, fmt.Sprintln(args...))
}
示例12: Fatal
func (g *glogger) Fatal(args ...interface{}) {
glog.FatalDepth(2, args...)
}