...

Source file src/k8s.io/client-go/util/exec/exec.go

Documentation: k8s.io/client-go/util/exec

     1  /*
     2  Copyright 2014 The Kubernetes Authors.
     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  
    17  package exec
    18  
    19  // ExitError is an interface that presents an API similar to os.ProcessState, which is
    20  // what ExitError from os/exec is.  This is designed to make testing a bit easier and
    21  // probably loses some of the cross-platform properties of the underlying library.
    22  type ExitError interface {
    23  	String() string
    24  	Error() string
    25  	Exited() bool
    26  	ExitStatus() int
    27  }
    28  
    29  // CodeExitError is an implementation of ExitError consisting of an error object
    30  // and an exit code (the upper bits of os.exec.ExitStatus).
    31  type CodeExitError struct {
    32  	Err  error
    33  	Code int
    34  }
    35  
    36  var _ ExitError = CodeExitError{}
    37  
    38  func (e CodeExitError) Error() string {
    39  	return e.Err.Error()
    40  }
    41  
    42  func (e CodeExitError) String() string {
    43  	return e.Err.Error()
    44  }
    45  
    46  func (e CodeExitError) Exited() bool {
    47  	return true
    48  }
    49  
    50  func (e CodeExitError) ExitStatus() int {
    51  	return e.Code
    52  }
    53  

View as plain text