mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-10-23 07:29:39 +00:00
Update storageos api dependency to 0.3.4
This commit is contained in:
28
vendor/github.com/storageos/go-api/serror/BUILD
generated
vendored
Normal file
28
vendor/github.com/storageos/go-api/serror/BUILD
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"error_kind.go",
|
||||
"kind_lookup_map.go",
|
||||
"storageos_error.go",
|
||||
"storageoserrorkind_string.go",
|
||||
"typed_error.go",
|
||||
],
|
||||
importpath = "github.com/storageos/go-api/serror",
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "package-srcs",
|
||||
srcs = glob(["**"]),
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [":package-srcs"],
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
11
vendor/github.com/storageos/go-api/serror/error_kind.go
generated
vendored
Normal file
11
vendor/github.com/storageos/go-api/serror/error_kind.go
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
package serror
|
||||
|
||||
//go:generate stringer -type=StorageOSErrorKind error_kind.go
|
||||
type StorageOSErrorKind int
|
||||
|
||||
// Known error kinds
|
||||
const (
|
||||
UnknownError StorageOSErrorKind = iota
|
||||
APIUncontactable
|
||||
InvalidHostConfig
|
||||
)
|
37
vendor/github.com/storageos/go-api/serror/kind_lookup_map.go
generated
vendored
Normal file
37
vendor/github.com/storageos/go-api/serror/kind_lookup_map.go
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
package serror
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var kindLookupMap map[string]StorageOSErrorKind
|
||||
|
||||
func init() {
|
||||
kindLookupMap = make(map[string]StorageOSErrorKind)
|
||||
|
||||
// Populate the lookup map with all the known constants
|
||||
for i := StorageOSErrorKind(0); !strings.HasPrefix(i.String(), "StorageOSErrorKind("); i++ {
|
||||
kindLookupMap[i.String()] = i
|
||||
}
|
||||
}
|
||||
|
||||
func (s *StorageOSErrorKind) UnmarshalJSON(b []byte) error {
|
||||
str := ""
|
||||
if err := json.Unmarshal(b, &str); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
v, ok := kindLookupMap[str]
|
||||
if !ok {
|
||||
return fmt.Errorf("Failed to unmarshal ErrorKind %s", s)
|
||||
}
|
||||
|
||||
*s = v
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *StorageOSErrorKind) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(s.String())
|
||||
}
|
34
vendor/github.com/storageos/go-api/serror/storageos_error.go
generated
vendored
Normal file
34
vendor/github.com/storageos/go-api/serror/storageos_error.go
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
package serror
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
type StorageOSError interface {
|
||||
// embedding error provides compatibility with standard error handling code
|
||||
error
|
||||
|
||||
// Encoding/decoding methods to help errors traverse API boundaries
|
||||
json.Marshaler
|
||||
json.Unmarshaler
|
||||
|
||||
Err() error // Returns the underlying error that caused this event
|
||||
String() string // A short string representing the error (for logging etc)
|
||||
Help() string // A larger string that should provide informative debug instruction to users
|
||||
Kind() StorageOSErrorKind // A type representing a set of known error conditions, helpful to switch on
|
||||
Extra() map[string]string // A container for error specific information
|
||||
|
||||
// TODO: should we include callstack traces here? We could have a debug mode for it.
|
||||
}
|
||||
|
||||
func ErrorKind(err error) StorageOSErrorKind {
|
||||
if serr, ok := err.(StorageOSError); ok {
|
||||
return serr.Kind()
|
||||
}
|
||||
return UnknownError
|
||||
}
|
||||
|
||||
func IsStorageOSError(err error) bool {
|
||||
_, ok := err.(StorageOSError)
|
||||
return ok
|
||||
}
|
16
vendor/github.com/storageos/go-api/serror/storageoserrorkind_string.go
generated
vendored
Normal file
16
vendor/github.com/storageos/go-api/serror/storageoserrorkind_string.go
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
// Code generated by "stringer -type=StorageOSErrorKind error_kind.go"; DO NOT EDIT.
|
||||
|
||||
package serror
|
||||
|
||||
import "strconv"
|
||||
|
||||
const _StorageOSErrorKind_name = "UnknownErrorAPIUncontactableInvalidHostConfig"
|
||||
|
||||
var _StorageOSErrorKind_index = [...]uint8{0, 12, 28, 45}
|
||||
|
||||
func (i StorageOSErrorKind) String() string {
|
||||
if i < 0 || i >= StorageOSErrorKind(len(_StorageOSErrorKind_index)-1) {
|
||||
return "StorageOSErrorKind(" + strconv.FormatInt(int64(i), 10) + ")"
|
||||
}
|
||||
return _StorageOSErrorKind_name[_StorageOSErrorKind_index[i]:_StorageOSErrorKind_index[i+1]]
|
||||
}
|
64
vendor/github.com/storageos/go-api/serror/typed_error.go
generated
vendored
Normal file
64
vendor/github.com/storageos/go-api/serror/typed_error.go
generated
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
package serror
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
func NewTypedStorageOSError(kind StorageOSErrorKind, err error, msg string, help string) StorageOSError {
|
||||
return &typedStorageOSError{
|
||||
internal: &internal_TypedStorageOSError{
|
||||
ErrorKind: &kind,
|
||||
Cause: err,
|
||||
ErrMessage: msg,
|
||||
HelpMessage: help,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func NewUntypedStorageOSError(err error, msg string, help string) StorageOSError {
|
||||
var kind StorageOSErrorKind = UnknownError
|
||||
|
||||
return &typedStorageOSError{
|
||||
internal: &internal_TypedStorageOSError{
|
||||
ErrorKind: &kind,
|
||||
Cause: err,
|
||||
ErrMessage: msg,
|
||||
HelpMessage: help,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
type internal_TypedStorageOSError struct {
|
||||
ErrorKind *StorageOSErrorKind `json:"error_kind"`
|
||||
Cause error `json:"caused_by"`
|
||||
ErrMessage string `json:"error_message"`
|
||||
HelpMessage string `json:"help_message"`
|
||||
ExtraMap map[string]string `json:"extra"`
|
||||
}
|
||||
|
||||
type typedStorageOSError struct {
|
||||
internal *internal_TypedStorageOSError
|
||||
}
|
||||
|
||||
func (t *typedStorageOSError) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(t.internal)
|
||||
}
|
||||
|
||||
func (t *typedStorageOSError) UnmarshalJSON(d []byte) error {
|
||||
internal := &internal_TypedStorageOSError{}
|
||||
|
||||
err := json.Unmarshal(d, internal)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
t.internal = internal
|
||||
return nil
|
||||
}
|
||||
|
||||
func (t *typedStorageOSError) Error() string { return t.String() }
|
||||
func (t *typedStorageOSError) Err() error { return t.internal.Cause }
|
||||
func (t *typedStorageOSError) String() string { return t.internal.ErrMessage }
|
||||
func (t *typedStorageOSError) Help() string { return t.internal.HelpMessage }
|
||||
func (t *typedStorageOSError) Kind() StorageOSErrorKind { return *t.internal.ErrorKind }
|
||||
func (t *typedStorageOSError) Extra() map[string]string { return t.internal.ExtraMap }
|
Reference in New Issue
Block a user